Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 51420

Summary: Remove/reduce plug-in loading dependency in Run context menu
Product: [Eclipse Project] Platform Reporter: Jared Burns <jared_burns>
Component: DebugAssignee: Chris Tilt <chris>
Status: RESOLVED DUPLICATE QA Contact:
Severity: normal    
Priority: P3 CC: chris, darin.eclipse
Version: 3.0   
Target Milestone: 3.0 M8   
Hardware: PC   
OS: All   
Whiteboard:
Bug Depends on:    
Bug Blocks: 51506    
Attachments:
Description Flags
nameFilter addition, part one of two
none
nameFilter addition, part two of two none

Description Jared Burns CLA 2004-02-09 19:15:04 EST
I took a look at moving the "Run Ant..." action to the Run context menu today but we decided that 
we can't use the support as it stands because we want "Run Ant..." to show up even before the 
Ant UI plug-in is loaded. Moving to the Run context menu would be a loss of function for the user.

Other products (such as WSAD) are going to have the same problem. Other Eclipse-based 
products have top-level items like our "Run Ant..." action. When an end user asks why they can't 
launch from the context menu anymore, it will be hard to tell them, "Well, you have to do something 
to load the plug-in first or it won't show up."

For "Run Ant..." we currently use the objectContribution's <nameFilter> and <visibility> support to 
check if the file is an XML file with a project as the top-level node. This allows the action to come 
and go dynamically without loading the Ant UI plug-in. If we could add <visibility> support to our 
extension point, that would solve Ant's problem. But I'm not sure this solves the problem for 
everyone.
Comment 1 Jared Burns CLA 2004-02-09 19:27:34 EST
After discussing it a bit, I suggest adding support for "contextNameFilter" and "contextVisibility" 
elements. Before the filterClass is loaded, the menu should add all shortcuts that pass these filters. 
Once the filterClass is loaded, it should use the xmlFilters first and then run the filterClass.

This not only solves the "Run Ant..." problem, it also solves the problem of applicable shortcuts not 
appearing when they should. For example, "Run Java Application" would appear on all *.java files 
before JDT is loaded. This means it would show up on files that don't have main methods, but I 
think that's better than *not* having it show up on files that do. If the filtering isn't precise, I think it 
should be imprecise in favor of the user's ability to perform their desired action (launch their app).
Comment 2 Darin Wright CLA 2004-02-10 09:30:36 EST
This sounds like a nice improvement, that I think we should try.

My concern is that it could cause many options to appear in the menu. I.e. if 
there are tons of shortcuts for ".java" files in a product, will they all show 
up all the time in the case that those plug-ins are never loaded/used?
Comment 3 Chris Tilt CLA 2004-02-10 18:36:47 EST
Created attachment 7759 [details]
nameFilter addition, part one of two
Comment 4 Chris Tilt CLA 2004-02-10 18:40:34 EST
Created attachment 7760 [details]
nameFilter addition, part two of two

adds a nameFilter attribute to the launch shortcut extension that allows
optimistic inclusion of launch shortcuts to the context menu. If the plugin
containing the filterClass is not loaded yet, nameFilter decides the
visibility. If the filterClass is loaded, nameFilter && filterClass tests
decide. This seems like a good middle ground for context menu population.
Comment 5 Jared Burns CLA 2004-02-10 19:43:08 EST
Applied patches and released to HEAD.
Comment 6 Jared Burns CLA 2004-02-10 20:19:58 EST
The supplied patch adds support for a single nameFilter, but we should expand this a bit to support 
multiple names. For example, the Java stuff wants to specify "*.java,*.class".
Comment 7 Chris Tilt CLA 2004-03-09 01:08:04 EST
Expanding the name filter to support a list of patterns is better, but does not
solve the whole problem. Consider multi-selections that require an XML, XSL, and
Java file to be selected.

So, the thing to consider is how to allow generic filtering that can serve as
the first order approximation before loading the plugin that really knows wether
the shortcut applies to the selection. The issue of multi-selection is what
makes it interesting. I propose a fancier version of the existing nameFilter,
which currently only supports a basic pattern of "*.ext". The new version would
also support logical OR "||", AND "&&", ONE OR MORE "+", and ZERO OR MORE "*",
as well as parenthetical grouping of basic terms (don't see a case or allowing
arbitrary grouping and instance counts).

nameFilter="*.java && *.xml && *.xsl" - one java, one xml and one xsl file
nameFilter="*.java || *.class" - one of either a java or class file
nameFilter="(*.java)+" - one or more java files
nameFilter="(*.xml)* && *.java" - zero or more xml files and one java file
Comment 8 Chris Tilt CLA 2004-03-09 01:13:45 EST
Adding Darin as a CC to get his comments.

This proposal will also be key in addressing bug #51506
Comment 9 Chris Tilt CLA 2004-03-12 20:05:04 EST
Bug #54717 subsumes this request.

*** This bug has been marked as a duplicate of 54717 ***