| Summary: | Allow to subclass OpenFileAction and OpenWithMenu | ||
|---|---|---|---|
| Product: | [Eclipse Project] Platform | Reporter: | Dani Megert <daniel_megert> |
| Component: | IDE | Assignee: | Dani Megert <daniel_megert> |
| Status: | RESOLVED WONTFIX | QA Contact: | |
| Severity: | enhancement | ||
| Priority: | P3 | CC: | bokowski, pwebster, remy.suen |
| Version: | 3.6 | ||
| Target Milestone: | 3.7 | ||
| Hardware: | All | ||
| OS: | All | ||
| Whiteboard: | |||
|
Description
Dani Megert
Let me take that one. org.eclipse.team.internal.ui.synchronize.actions.OpenFileInSystemEditorAction also extends OpenFileAction. Boris, OK for you to do this? Can we stop promoting actions? The compatibility layer needs to support them, but because they're bridged they're slower in 4.x and not supported at all in e4. If we're going to add new API, it should be in the supported command/handler system. PW >If we're going to add new API, it should be in the supported command/handler
>system.
Would you have time to do this? Where would they live and how would they look like?
I would be in favour of publishing API that made it possible for clients to get at the required functionality. However, we should try to make this available "library-style" (through a refactoring of the current code if necessary). This would make the new API independent of the current class hierarchy and would address Paul's concerns about making more of the action classes API. > However, we should try to make this available "library-style"
Can you be a bit more specific? Is there already such a library entry point? Wouldn't it be better to do it as Paul suggested?
Also, the class is already API. We would only allow to extend it. Is that really an issue regarding e4?
(In reply to comment #5) > Would you have time to do this? Where would they live and how would they look > like? I'm having a quick look at this tomorrow. PW >I'm having a quick look at this tomorrow.
>PW
Great, thanks! Could you also explain to me why allowing to sub-class an existing API class which has to be supported in 4.x causes problems for 4.x?
> (In reply to comment #8)
> I'm having a quick look at this tomorrow.
> PW
;-)
(In reply to comment #10) > ;-) Sorry, Dani, I went out with a Flu all last week. But it's still on my list of things to write up :-) Soon, Paul > Soon,
> Paul
Ping ;-)
A command version of this would probably look like: An openResource command with 2 optional parameters, editorId and file The behaviour would be similar to org.eclipse.ui.actions.OpenFileAction. If there was an editorId specified, it would try and open the IFile with that editor, otherwise fall back on something like IDE.openEditor(*). If there is an IFile specified try and open it, otherwise request the appropriate selection from the IEvaluationService context. With the handled execute(*) implementing the behaviour, it could be overridden by another handler. Then it's up to use if we want to make the handler API to make that easier. For placing in menus we can provide something like the call below as a shortcut. IContributionItem openItem = IDEContributionItemFactory.OPEN_FILE.create(window, String editorId, IFile file); although anyone can build a CommandContributionItem themselves. OpenWithMenu is already a contribution item. I would change it to a CompoundContributionItem and generate the CommandContributionItems necessary to use the openResource command. Depending on how useful it could also be modified so it could be used in the menuContribution/dynamic element. PW Hi Dani, Once again, sorry for the lateness of my reply. (In reply to comment #9) > Great, thanks! Could you also explain to me why allowing to sub-class an > existing API class which has to be supported in 4.x causes problems for 4.x? In 4.0 action extension points are deprecated, and in 4.1 this will apply to the workbench use of actions. Resourcing has slowed down our conversion of actions to commands although not stopped it. The actions will continue to work, of course. They'll still excel in the "localized case" since they're a useful API to encapsulate creating a menu item/tool item and providing something to execute for an SWT.Selection event. But they're even more removed from the e4 framework than they are from the 3.x commands and menu contributions. Evolving our 4.1/4.x into something that can take advantage of the new e4 functionality will hopefull accelerate over 4.1, but actions are more a wrapper on creating SWT widgets and less part of the framework. Given that, even though we must continue to provide our 3.x action API in the compatibility layer, opening them up (expanding their scope as API) seems to be heading "the other way" down the road. I'm not dead set against it, and of course we must do what we must do, but I'd prefer to avoid it. PW > For a concrete use case see bug 153912. There we need to be able to extend > - OpenWithMenu.openEditor(IEditorDescriptor, boolean) > - OpenFileAction.run() Sorry, that was the wrong bug #. It was need to fix bug 40632, bug 267171 and bug 315722. It looks like the preference is to not allow an existing API class which is all this bug is about. Therefore closing as WONTFIX. It looks like the preference is to not allow an existing API class
>allow to extend an existing API class
Paul, I've read your comments and still don't understand why one would switch over to commands and/or handlers instead of using the action to create the menu items. In comment 14 you say yourself: They'll still excel in the "localized case" since they're a useful API to encapsulate creating a menu item/tool item and that's exactly where the subclasses of OpenWithMenu and OpenFileAction are used. I don't see what it would buy us to do some inconvenient dances to go via commands and/or handlers here. In addition I believe that if we did so, it would result in code duplication. (In reply to comment #17) > Paul, I've read your comments and still don't understand why one would switch > over to commands and/or handlers instead of using the action to create the menu > items. In comment 14 you say yourself: > > They'll still excel in the "localized case" since they're a > useful API to encapsulate creating a menu item/tool item Yes, actions are localized. They're nice window dressing on top of an SWT.Selection event. And I would still recommend them if a behaviour (or action, pardon the overuse :-) doesn't need to be represented in a number of places, doesn't need to be accessed through keybindings or the framework, etc. > and that's exactly where the subclasses of OpenWithMenu and OpenFileAction are > used. I don't see what it would buy us to do some inconvenient dances to go via > commands and/or handlers here. In addition I believe that if we did so, it > would result in code duplication. In this specific case I would say that OpenFile isn't a localized behaviour, but is applicable to more than just a view menu. It's not unreasonable that Open File can be used in a number of places. That is something that I would recommend be a command/handler. PW |