Bug 226550 - [api] Launch Shell and Launch Terminal actions should be contributed declaratively
Summary: [api] Launch Shell and Launch Terminal actions should be contributed declarat...
Status: RESOLVED FIXED
Alias: None
Product: Target Management
Classification: Tools
Component: RSE (show other bugs)
Version: 3.0   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: 3.0 RC2   Edit
Assignee: Martin Oberhuber CLA
QA Contact: Martin Oberhuber CLA
URL:
Whiteboard:
Keywords: api, contributed
Depends on: 218304 226764 227535
Blocks: 230400 181939 228577 234274
  Show dependency tree
 
Reported: 2008-04-10 11:27 EDT by Martin Oberhuber CLA
Modified: 2011-05-25 07:25 EDT (History)
1 user (show)

See Also:
mober.at+eclipse: pmc_approved+


Attachments
patch for using property testers in Launch Shell action definition (13.90 KB, patch)
2008-05-21 16:11 EDT, Anna Dushistova CLA
mober.at+eclipse: iplog+
mober.at+eclipse: review+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Oberhuber CLA 2008-04-10 11:27:10 EDT
The "Launch Shell" action should be contributed declaratively rather than by program, for two reasons:

1.) Avoid eager loading of the shells.ui plugin, see the comment in 
    SystemViewSubSystemAdapter line 107

2.) Avoid semantic dependency in SystemViewRemoteFileAdapter line 3611
    ("iscommandsubsystemexists") and replace it by a PropertyTester extension

The same fix should also be applied for "Launch Terminal" when the Terminal Subsystem becomes available as per bug 170910.

This request is "a weak form of API" since the org.eclipse.core.expressions.PropertyTester extension would be used by other extensions of org.eclipse.ui.menus and org.eclipse.ui.handlers.
Comment 1 Martin Oberhuber CLA 2008-04-24 07:17:18 EDT
Assigning to Anna since she seems to have some PropertyTester for this already.
Comment 2 Anna Dushistova CLA 2008-04-24 09:25:17 EDT
The only thing why I cannot get rid of files.core dependency in action classes is launching shell/terminal on virtual folder (see method updateSelection() in SystemCommandAction and LaunchTerminalAction).
I couldn't find any substitution for IRemoteFileSubSystem.getRemoteFileObject() method. Do you have any ideas how to change the code in a proper way?  

We can test if it's virtual folder with a property tester though and don't allow it, but means reducing functionality.
Comment 3 Martin Oberhuber CLA 2008-04-24 12:47:34 EDT
Why do you think that this would reduce functionality? - You cannot launch a Shell inside with a startup directory inside a ZIP file anyways. You could only take the parent folder that holdes the virtual path.

Your selection is any RSE object. You can adapt it to an ISystemViewElementAdapter or IRemoteElementAdapter, from which you get the absolute path of the object. The absolute path could be split into parent folder and virtual part. I do not see any need for a files.core dependency here, do you?
Comment 4 Martin Oberhuber CLA 2008-05-20 17:37:04 EDT
With the fix for bug 227535 committed, contributing the "Launch Shell" action declaratively as a command should be fairly easy now, because we already have the Property Testers?

See bug 153249 for something that could probably be fixed along with this.
Comment 5 Anna Dushistova CLA 2008-05-21 16:11:25 EDT
Created attachment 101372 [details]
patch for using property testers in Launch Shell action definition

This is what I have for now. Unfortunatelly, the action is still contributed programmatically for subsystem element, since there are other actions that are contributed that way and I wasn't able to make mixed contribution work.
I got rid of *LaunchDelegate classes here since they are not needed anymore,
got rid of the code in testAttribute() method checking for subsystem and created new command handler class that is copied from corresponding LaunchDelegate.
Comment 6 Anna Dushistova CLA 2008-05-21 16:13:38 EDT
I, Anna Dushistova, declare that I developed attached code from scratch,
without referencing any 3rd party materials except material licensed under the
EPL. I am authorized by my employer to make this contribution under the EPL.
Comment 7 Martin Oberhuber CLA 2008-05-27 18:44:53 EDT
Patch applied, thanks! +80 / -110 lines of code:
[226550] [api] Launch Shell and Launch Terminal actions should be contributed declaratively (patch applied from Anna Dushistova)

I fixed 2 minor gotchas:
* Updated Copyright Year 2008 in 2 files
* Removed reference to "isCommandSubsystemExists" check in 
  SystemViewRemoteFileAdapter Javadocs

And I found 2 other minor issues, for which I filed bug 234274.

This is nominally a breaking API change, since it's now no longer possible to use the "isCommandSubsystemExists" property in IActionFilter checks provided by the remote file adapter.

Migration Notes:
----------------
Existing users of isCommandSubsystemExists in IActionFilter expressions should migrate to using org.eclipse.ui.menus / org.eclipse.ui.handlers extension points, and use the new "org.eclipse.rse.core.hasSubSystemCategory" propertyTester as currently done in org.eclipse.rse.shells.ui/plugin.xml

Advantage of the new propertyTester is that it avoids plugin loading and subsystem loading, and looks at the SubSystemConfigurationProxy only.