Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 7723 Details for
Bug 18338
Run/Debug in the context menu
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Part one of final release
org.eclipse.debug.ui.contextuallaunch.patch (text/plain), 17.69 KB, created by
Chris Tilt
on 2004-02-07 18:58:05 EST
(
hide
)
Description:
Part one of final release
Filename:
MIME Type:
Creator:
Chris Tilt
Created:
2004-02-07 18:58:05 EST
Size:
17.69 KB
patch
obsolete
>Index: schema/launchShortcuts.exsd >=================================================================== >retrieving revision 1.7 >diff -u -r1.7 launchShortcuts.exsd >--- schema/launchShortcuts.exsd 29 Jan 2004 16:25:41 -0000 1.7 >+++ schema/launchShortcuts.exsd 7 Feb 2004 23:44:19 -0000 >@@ -118,8 +118,11 @@ > <attribute name="filterClass" type="string"> > <annotation> > <documentation> >- an optional attribute that specifies the fully qualified path of a Java class that implements the <samp>org.eclipse.ui.IActionFilter</samp> interface. The testAttribute() method is called with the selected resource and the name/value pair specified by subsequent filter elements. If all return values of all filter elements are true, the shortcut will appear in the contextual launch menu of the selected resource. If the filterClass attribute is not specifies, the shortcut will not appear in the contextual launch menu. If the filterClass is specified, but no filter elements are found, the shortcut will appear in the menu. >+ an optional attribute that specifies the fully qualified path of a Java class that implements the <samp>org.eclipse.ui.ILaunchFilter</samp> interface. The testAttribute() method is called with the selected resource and the name/value pair specified by subsequent filter elements. If all return values of all filter elements are true, the shortcut will appear in the contextual launch menu of the selected resource. If the filterClass attribute is not specifies, the shortcut will not appear in the contextual launch menu. If the filterClass is specified, but no filter elements are found, the shortcut will appear in the menu. > </documentation> >+ <appInfo> >+ <meta.attribute kind="java" basedOn="org.eclipse.debug.ui.ILaunchFilter"/> >+ </appInfo> > </annotation> > </attribute> > </complexType> >Index: ui/org/eclipse/debug/internal/ui/actions/ContextualLaunchObjectActionDelegate.java >=================================================================== >retrieving revision 1.2 >diff -u -r1.2 ContextualLaunchObjectActionDelegate.java >--- ui/org/eclipse/debug/internal/ui/actions/ContextualLaunchObjectActionDelegate.java 29 Jan 2004 17:52:15 -0000 1.2 >+++ ui/org/eclipse/debug/internal/ui/actions/ContextualLaunchObjectActionDelegate.java 7 Feb 2004 23:44:22 -0000 >@@ -15,13 +15,14 @@ > import java.util.List; > import java.util.Set; > >+import org.eclipse.core.resources.IResource; > import org.eclipse.core.runtime.IExtension; > import org.eclipse.core.runtime.IPluginDescriptor; > import org.eclipse.debug.internal.ui.DebugUIPlugin; > import org.eclipse.debug.internal.ui.Pair; > import org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationManager; >-import org.eclipse.debug.internal.ui.launchConfigurations.LaunchGroupExtension; > import org.eclipse.debug.internal.ui.launchConfigurations.LaunchShortcutExtension; >+import org.eclipse.debug.ui.ILaunchFilter; > import org.eclipse.jface.action.Action; > import org.eclipse.jface.action.ActionContributionItem; > import org.eclipse.jface.action.IAction; >@@ -33,7 +34,6 @@ > import org.eclipse.swt.widgets.Control; > import org.eclipse.swt.widgets.Menu; > import org.eclipse.swt.widgets.MenuItem; >-import org.eclipse.ui.IActionFilter; > import org.eclipse.ui.IObjectActionDelegate; > import org.eclipse.ui.IPerspectiveDescriptor; > import org.eclipse.ui.IWorkbenchPage; >@@ -54,45 +54,14 @@ > * (run, debug, profile, etc.) in the contextual launch sub-menu. The filterClass > * is loaded and run over the list of "filter" elements to determine if the > * shortcut extension item is appropriate for the selected resource. >- * <p> >- * An example is the JDT Java Applet extension, which is only applicable on files >- * of extension "*.java" and being a sub-class of type Applet. Note that it is up >- * to the filterClass to provide attributes and methods to implement the test. In >- * this example, we have extended the AppletShortcut to implement the IActionFilter >- * interface so that it can function as the filterClass, adding only a testAttribute() >- * method. >- * <p> >- * <pre> >- * <shortcut >- * label="%AppletShortcut.label" >- * icon="icons/full/ctool16/java_applet.gif" >- * helpContextId="org.eclipse.jdt.debug.ui.shortcut_java_applet" >- * modes="run, debug" >- * filterClass="org.eclipse.jdt.internal.debug.ui.launcher.JavaAppletLaunchShortcut" >- * class="org.eclipse.jdt.internal.debug.ui.launcher.JavaAppletLaunchShortcut" >- * id="org.eclipse.jdt.debug.ui.javaAppletShortcut"> >- * <filter >- * name="NameMatches" >- * value="*.java"/> >- * <filter >- * name="ContextualLaunchActionFilter" >- * value="supportsContextualLaunch"/> >- * <contextLabel >- * mode="run" >- * label="%RunJavaApplet.label"/> >- * <contextLabel >- * mode="debug" >- * label="%DebugJavaApplet.label"/> >- * ... >- * <shortcut> >- * </pre> >+ * </p> > */ > public class ContextualLaunchObjectActionDelegate > implements > IObjectActionDelegate, > IMenuCreator { > >- private ISelection fSelection; >+ private IResource fSelection; > > /* > * @see org.eclipse.ui.IObjectActionDelegate#setActivePart(org.eclipse.jface.action.IAction, org.eclipse.ui.IWorkbenchPart) >@@ -149,23 +118,25 @@ > * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection) > */ > public void selectionChanged(IAction action, ISelection selection) { >- if (((IStructuredSelection) selection).size() != 1) >- action.setEnabled(false); // Can only handle one resource at a time >- else { >- if (action instanceof Action) { >+ // if the selection is an IResource, save it and enable our action >+ if (selection instanceof IStructuredSelection) { >+ IStructuredSelection ss = (IStructuredSelection) selection; >+ if (ss.size() == 1 && action instanceof Action) { > if (delegateAction != action) { > delegateAction = (Action) action; > delegateAction.setMenuCreator(this); > } >- action.setEnabled(true); >- fSelection = selection; >- } else { >- action.setEnabled(false); >+ Object object = ss.getFirstElement(); // already tested size above >+ if(object instanceof IResource) { >+ fSelection = (IResource)object; >+ action.setEnabled(true); >+ return; >+ } > } > } >+ action.setEnabled(false); > } > >- private int fCount = 0; > /** > * Fill pull down menu with the pages of the JTabbedPane > */ >@@ -207,11 +178,11 @@ > } > } > >- private IActionFilter getFilterClassIfLoaded(LaunchShortcutExtension ext) { >+ private ILaunchFilter getFilterClassIfLoaded(LaunchShortcutExtension ext) { > IExtension extensionPoint = ext.getConfigurationElement().getDeclaringExtension(); > IPluginDescriptor pluginDescriptor = extensionPoint.getDeclaringPluginDescriptor(); > if (pluginDescriptor.isPluginActivated()) { >- IActionFilter filter = ext.getFilterClass(); >+ ILaunchFilter filter = ext.getFilterClass(); > return filter; > } else { > return null; >@@ -225,9 +196,9 @@ > private boolean isApplicable(LaunchShortcutExtension ext) { > // boolean hasMode = ext.getModes().contains(getMode(launchGroupIdentifier)); > // return false if there isn't a filter class or there are no filters specified by the shortcut >- // Only loaded plugins will be used, so the actionFilter is null if the filterClass is not loaded >- IActionFilter actionFilter = getFilterClassIfLoaded(ext); >- if (actionFilter == null) { >+ // Only loaded plugins will be used, so the launchFilter is null if the filterClass is not loaded >+ ILaunchFilter launchFilter = getFilterClassIfLoaded(ext); >+ if (launchFilter == null) { > return false; > } > List filters = ext.getFilters(); >@@ -239,9 +210,8 @@ > Pair pair = (Pair) iter.next(); > String name = pair.firstAsString(); > String value= pair.secondAsString(); >- Object target = fSelection; > // any filter that returns false makes the shortcut non-visible >- if (!actionFilter.testAttribute(target,name,value)) { >+ if (!launchFilter.testAttribute(fSelection,name,value)) { > return false; > } > } >@@ -264,14 +234,7 @@ > ActionContributionItem item= new ActionContributionItem(action); > item.fill(menu, -1); > } >- >- private class FakeAction extends Action { >- public FakeAction(String name) { >- super(name); >- } >- public void run() { >- } >- } >+ > /** > * Return the ID of the currently active perspective. > * >@@ -296,32 +259,7 @@ > * @return launch configuration manager > */ > private LaunchConfigurationManager getLaunchConfigurationManager() { >-return DebugUIPlugin.getDefault().getLaunchConfigurationManager(); >-} >-/** >- * Returns the launch group associatd with this action. >- * >- * @return the launch group associatd with this action >- */ >-private LaunchGroupExtension getLaunchGroup(String fLaunchGroupIdentifier) { >- return getLaunchConfigurationManager().getLaunchGroup(fLaunchGroupIdentifier); >-} >-/** >- * Returns the mode of this action - run or debug >- * >- * @return the mode of this action - run or debug >- */ >-private String getMode(String fLaunchGroupIdentifier) { >- return getLaunchGroup(fLaunchGroupIdentifier).getMode(); >-} >- >-/** >- * Returns the category of this action - possibly <code>null</code> >- * >- * @return the category of this action - possibly <code>null</code> >- */ >-private String getCategory(String fLaunchGroupIdentifier) { >- return getLaunchGroup(fLaunchGroupIdentifier).getCategory(); >+ return DebugUIPlugin.getDefault().getLaunchConfigurationManager(); > } > > } >Index: ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchShortcutExtension.java >=================================================================== >retrieving revision 1.8 >diff -u -r1.8 LaunchShortcutExtension.java >--- ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchShortcutExtension.java 29 Jan 2004 16:25:41 -0000 1.8 >+++ ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchShortcutExtension.java 7 Feb 2004 23:44:25 -0000 >@@ -24,10 +24,10 @@ > import org.eclipse.core.runtime.IConfigurationElement; > import org.eclipse.debug.internal.ui.DebugUIPlugin; > import org.eclipse.debug.internal.ui.Pair; >+import org.eclipse.debug.ui.ILaunchFilter; > import org.eclipse.debug.ui.ILaunchShortcut; > import org.eclipse.jface.resource.ImageDescriptor; > import org.eclipse.jface.viewers.ISelection; >-import org.eclipse.ui.IActionFilter; > import org.eclipse.ui.IEditorPart; > > >@@ -40,7 +40,7 @@ > private List fPerspectives = null; > private ILaunchShortcut fDelegate = null; > private Set fModes = null; >- private IActionFilter fActionFilter = null; >+ private ILaunchFilter fLaunchFilter = null; > private /* <Pair> */ List fFilters = null; > > /** >@@ -125,16 +125,23 @@ > * @return the filter class of this shortcut., or <code>null</code> if not > * specified > */ >- public IActionFilter getFilterClass() { >- if (fActionFilter == null) { >+ public ILaunchFilter getFilterClass() { >+ if (fLaunchFilter == null) { > try { >- fActionFilter = (IActionFilter)fConfig.createExecutableExtension("filterClass"); //$NON-NLS-1$ >+ // The underlying code logs an error if the filterClass is missing, >+ // even though the attribute is optional, so check for existence first. >+ if (fConfig.getAttribute("filterClass") != null) { //$NON-NLS-1$ >+ Object object = fConfig.createExecutableExtension("filterClass"); //$NON-NLS-1$ >+ if (object instanceof ILaunchFilter) { >+ fLaunchFilter = (ILaunchFilter) object; >+ } >+ } > } catch (CoreException e) { > // silently ignore because filterClass is optional > // DebugUIPlugin.errorDialog(DebugUIPlugin.getShell(), LaunchConfigurationsMessages.getString("LaunchShortcutExtension.Error_4"), LaunchConfigurationsMessages.getString("LaunchShortcutExtension.Unable_to_use_launch_shortcut_5"), e.getStatus()); //$NON-NLS-1$ //$NON-NLS-2$ > } > } >- return fActionFilter; >+ return fLaunchFilter; > } > /** > * Returns all of the filter elements of this shortcut as a List of String Pairs. >Index: ui/org/eclipse/debug/ui/ILaunchShortcut.java >=================================================================== >retrieving revision 1.4 >diff -u -r1.4 ILaunchShortcut.java >--- ui/org/eclipse/debug/ui/ILaunchShortcut.java 20 Mar 2003 22:33:20 -0000 1.4 >+++ ui/org/eclipse/debug/ui/ILaunchShortcut.java 7 Feb 2004 23:44:28 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2003 IBM Corporation and others. >+ * Copyright (c) 2000, 2003, 2004 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Common Public License v1.0 > * which accompanies this distribution, and is available at >@@ -34,12 +34,26 @@ > * <launchShortcut > * id="com.example.ExampleLaunchShortcut" > * class="com.example.ExampleLaunchShortcutClass" >+ * filterClass="com.example.ExampleLaunchShortcutFilterClass" > * label="Example Label" > * icon="\icons\exampleshortcut.gif" > * helpContextId="com.example.shortcut_context" > * modes="run, debug"> >- * <perspective id="com.example.perspectiveId1"/> >+ * <perspective id="com.example.perspectiveId1"/> > * <perspective id="com.example.perspectiveId2"/> >+ * <filter >+ * name="NameMatches" >+ * value="*.java"/> >+ * <filter >+ * name="ContextualLaunchActionFilter" >+ * value="supportsContextualLaunch"/> >+ * <contextLabel >+ * mode="run" >+ * label="%RunJavaApplet.label"/> >+ * <contextLabel >+ * mode="debug" >+ * label="%DebugJavaApplet.label"/> >+ * ... > * </launchShortcut> > * </extension> > * </pre> >@@ -47,7 +61,9 @@ > * <ul> > * <li><code>id</code> specifies a unique identifier for this launch shortcut.</li> > * <li><code>class</code> specifies a fully qualified name of a Java class >- * that implements <code>IlaunchShortcut</code>.</li> >+ * that implements <code>ILaunchShortcut</code>.</li><li> >+ * <code>filterClass</code> optionally specifies a fully qualified name of a Java class >+ * that implements <code>ILaunchFilter</code> for context menu filtering.</li> > * <li><code>label</code> specifies a label used to render this shortcut.</li> > * <li><code>icon</code> specifies a plug-in relative path to an icon used to > * render this shortcut.</li> >@@ -58,6 +74,16 @@ > * <li><code>perspective</code> one or more perspective entries enumerate the > * perspectives that this shortcut is avilable in, from the run/debug cascade > * menus.</li> >+ * <li><code>filter</code> zero or more filter entries specify the attribute >+ * <code>name</code> and attribute <code>value</code> that will be supplied to >+ * the <code>testAttribute</code> method implemented by the <code>filterClass</code> >+ * Java Class. If all filters in this list return <code>true</code> when applied >+ * to a selection target, the shortcut will be avilable in the run/debug context menu. >+ * menu.</li> >+ * <li><code>contextLabel</code> zero or more context menu labels. For >+ * shortcuts that pass their filter tests, the specified label will appear >+ * in the "Run ->" context menu and be bound to a launch action of the >+ * specified mode (e.g. run,debug,profile).</li> > * </ul> > * </p> > * @since 2.0 >Index: ui/org/eclipse/debug/ui/ILaunchFilter.java >=================================================================== >RCS file: ui/org/eclipse/debug/ui/ILaunchFilter.java >diff -N ui/org/eclipse/debug/ui/ILaunchFilter.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ ui/org/eclipse/debug/ui/ILaunchFilter.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,41 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2003, 2004 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Common Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/cpl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.debug.ui; >+ >+import org.eclipse.core.resources.IResource; >+ >+/** >+ * Interface for context-menu launch shortcut visibility. >+ * <p> >+ * An optional <code>filterClass</code> attribute in the <code>ILaunchShortcut</code> >+ * extension allows a shortcut provider to specify a Java class that will >+ * answer filtering questions. The shortcut extension point accepts a list >+ * of "contextFilter" elements that specify tests. If the tests all return >+ * <code>true</code>, the shortcut will appear on the context menu for the >+ * selected resource. >+ * </p><p> >+ * Each <code>contextFilter</code> test receives an <code>IResource</code> >+ * object, the name of a test attribute, and the expected attribute value. >+ * </p> >+ * @see org.eclipse.debug.ui.ILaunchShortcut >+ */ >+public interface ILaunchFilter { >+ /** >+ * Returns whether the specific attribute matches the state of the target >+ * resource object. >+ * >+ * @param target the target resource object >+ * @param name the attribute name >+ * @param value expected attribute value >+ * @return <code>true</code> if the attribute matches; <code>false</code> otherwise >+ */ >+ public boolean testAttribute(IResource target, String name, String value); >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 18338
:
7595
|
7596
|
7597
|
7621
|
7622
| 7723 |
7724