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 7621 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 (semi-final) release
org.eclipse.debug.ui.patch (text/plain), 27.14 KB, created by
Chris Tilt
on 2004-01-28 19:47:27 EST
(
hide
)
Description:
Part one of (semi-final) release
Filename:
MIME Type:
Creator:
Chris Tilt
Created:
2004-01-28 19:47:27 EST
Size:
27.14 KB
patch
obsolete
>Index: plugin.properties >=================================================================== >retrieving revision 1.104 >diff -u -r1.104 plugin.properties >--- plugin.properties 27 Jan 2004 20:46:35 -0000 1.104 >+++ plugin.properties 29 Jan 2004 00:36:29 -0000 >@@ -188,6 +188,10 @@ > > SourceContainerPresentationsName = Source Container Presentations > >+#---Chris' work in progress >+LaunchMenu.label=&Run >+LaunchMenuNoneApplicable.label=(None Applicable) >+ > containerName.workingSet = Working set > sourceNotFoundEditorName=Source Not Found Editor > >Index: plugin.xml >=================================================================== >retrieving revision 1.172 >diff -u -r1.172 plugin.xml >--- plugin.xml 27 Jan 2004 20:46:35 -0000 1.172 >+++ plugin.xml 29 Jan 2004 00:36:33 -0000 >@@ -1507,5 +1507,24 @@ > id="org.eclipse.debug.ui.containerPresentation.default"> > </sourceContainerPresentation> > </extension> >- >+<!-- ========================================= --> >+<!-- Contextual Launch Menu (Work in Progress) --> >+<!-- ========================================= --> >+ <extension >+ point="org.eclipse.ui.popupMenus"> >+ <objectContribution >+ objectClass="org.eclipse.core.resources.IResource" >+ adaptable="true" >+ id="org.eclipse.debug.ui.contextualLaunch"> >+ <action >+ label="%LaunchMenu.label" >+ style="pulldown" >+ class="org.eclipse.debug.internal.ui.actions.ContextualLaunchObjectActionDelegate" >+ menubarPath="additions" >+ enablesFor="1" >+ id="org.eclipse.debug.ui.contextualLaunch.submenu"> >+ </action> >+ </objectContribution> >+ </extension> >+<!-- End Contextual Run Menu (Work in Progress) --> > </plugin> >Index: schema/launchShortcuts.exsd >=================================================================== >retrieving revision 1.6 >diff -u -r1.6 launchShortcuts.exsd >--- schema/launchShortcuts.exsd 9 Jun 2003 16:43:59 -0000 1.6 >+++ schema/launchShortcuts.exsd 29 Jan 2004 00:36:37 -0000 >@@ -3,7 +3,7 @@ > <schema targetNamespace="org.eclipse.debug.ui"> > <annotation> > <appInfo> >- <meta.schema plugin="org.eclipse.debug.ui" id="launchShortcuts" name="Launch Shortcuts"/> >+ <meta.schema plugin="org.eclipse.debug.ui" id="filaunchShortcuts" name="Launch Shortcuts"/> > </appInfo> > <documentation> > This extension point provides support for selection sensitive launching. Extensions register a shortcut which >@@ -49,6 +49,8 @@ > <complexType> > <sequence> > <element ref="perspective" minOccurs="0" maxOccurs="unbounded"/> >+ <element ref="filter" minOccurs="0" maxOccurs="unbounded"/> >+ <element ref="contextLabel" minOccurs="0" maxOccurs="unbounded"/> > </sequence> > <attribute name="id" type="string" use="required"> > <annotation> >@@ -106,6 +108,20 @@ > </documentation> > </annotation> > </attribute> >+ <attribute name="contextLabel" type="string"> >+ <annotation> >+ <documentation> >+ an optional attribute that specifies the label to appear in the contextual launch menu (if this shortcut is not filtered according to the rules described in the filterClass attribute). If unspecified, the <samp>label</samp> attribute will be used instead. >+ </documentation> >+ </annotation> >+ </attribute> >+ <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. >+ </documentation> >+ </annotation> >+ </attribute> > </complexType> > </element> > >@@ -121,6 +137,64 @@ > </complexType> > </element> > >+ <element name="filter"> >+ <annotation> >+ <documentation> >+ specifies the name/value pair that will be tested for boolean true/false by calling the <samp>org.eclipse.ui.IActionFilter:testAttribute()</samp> method of the class specified by the <samp>filterClass</samp> attribute of the parent <samp>shortcut</samp> element. If all filters return a true value, the shortcut will be visible in the contextual launch menu. >+ </documentation> >+ </annotation> >+ <complexType> >+ <attribute name="name" type="string" use="required"> >+ <annotation> >+ <documentation> >+ specifies the name of the filter property. >+ </documentation> >+ </annotation> >+ </attribute> >+ <attribute name="value" type="string" use="required"> >+ <annotation> >+ <documentation> >+ specifies the expected value of the filter property. >+ </documentation> >+ </annotation> >+ </attribute> >+ </complexType> >+ </element> >+ >+ <element name="contextLabel"> >+ <annotation> >+ <documentation> >+ Specify the label for a contextual launch mode. >+ </documentation> >+ </annotation> >+ <complexType> >+ <attribute name="mode" use="required"> >+ <annotation> >+ <documentation> >+ specifies a mode from the set {"run","debug","profile"} >+ </documentation> >+ </annotation> >+ <simpleType> >+ <restriction base="string"> >+ <enumeration value="run"> >+ </enumeration> >+ <enumeration value="debug"> >+ </enumeration> >+ <enumeration value="profile"> >+ </enumeration> >+ </restriction> >+ </simpleType> >+ </attribute> >+ <attribute name="label" type="string" use="required"> >+ <annotation> >+ <documentation> >+ specifies the label to appear in the contextual launch menu. >+ </documentation> >+ </annotation> >+ </attribute> >+ </complexType> >+ </element> >+ > <annotation> > <appInfo> > <meta.section type="examples"/> >@@ -165,9 +239,9 @@ > </appInfo> > <documentation> > <p> >-<a href="hglegal.htm"> >- <img SRC="ngibmcpy.gif" >- ALT="Copyright (c) 2000, 2003 IBM Corporation and others. All Rights Reserved." >+<a href="hglegal.htm"> >+ <img SRC="ngibmcpy.gif" >+ ALT="Copyright (c) 2000, 2003 IBM Corporation and others. All Rights Reserved." > BORDER=0 height=14 width=324></a> > </p> > </documentation> >Index: ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationManager.java >=================================================================== >retrieving revision 1.44 >diff -u -r1.44 LaunchConfigurationManager.java >--- ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationManager.java 9 Dec 2003 23:39:28 -0000 1.44 >+++ ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationManager.java 29 Jan 2004 00:36:40 -0000 >@@ -512,11 +512,11 @@ > > /** > * Returns all launch shortcuts defined for the given perspective, >- * or <code>null</code> if none >+ * empty list if none. > * > * @param perpsective perspective identifier > * @return all launch shortcuts defined for the given perspective, >- * or <code>null</code> if none >+ * empty list if none. > */ > public List getLaunchShortcuts(String perpsective, String category) { > if (fLaunchShortcutsByPerspective == null) { >@@ -538,7 +538,7 @@ > } > List list = (List)fLaunchShortcutsByPerspective.get(perpsective); > if (list == null) { >- return null; >+ return new ArrayList(); > } else { > return filterShortcuts(list, category); > } >Index: ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchShortcutExtension.java >=================================================================== >retrieving revision 1.7 >diff -u -r1.7 LaunchShortcutExtension.java >--- ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchShortcutExtension.java 10 Mar 2003 21:56:23 -0000 1.7 >+++ ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchShortcutExtension.java 29 Jan 2004 00:36:42 -0000 >@@ -15,6 +15,7 @@ > import java.net.URL; > import java.util.ArrayList; > import java.util.HashSet; >+import java.util.Iterator; > import java.util.List; > import java.util.Set; > import java.util.StringTokenizer; >@@ -22,9 +23,11 @@ > import org.eclipse.core.runtime.CoreException; > 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.ILaunchShortcut; > import org.eclipse.jface.resource.ImageDescriptor; > import org.eclipse.jface.viewers.ISelection; >+import org.eclipse.ui.IActionFilter; > import org.eclipse.ui.IEditorPart; > > >@@ -37,11 +40,14 @@ > private List fPerspectives = null; > private ILaunchShortcut fDelegate = null; > private Set fModes = null; >+ private IActionFilter fActionFilter = null; >+ private /* <Pair> */ List fFilters = null; > > /** > * The configuration element defining this tab. > */ > private IConfigurationElement fConfig; >+ private /* <Pair> */ List fContextLabels; > > /** > * Constructs a launch configuration tab extension based >@@ -72,7 +78,7 @@ > * @param configuration element that defines the attributes > * for this launch configuration tab extension > */ >- protected IConfigurationElement getConfigurationElement() { >+ public IConfigurationElement getConfigurationElement() { > return fConfig; > } > >@@ -86,6 +92,67 @@ > return getConfigurationElement().getAttribute("label"); //$NON-NLS-1$ > } > >+ /** >+ * Returns the contextual launch label of this shortcut >+ * >+ * @return the contextual label of this shortcut, or <code>null</code> if not >+ * specified >+ */ >+ public String getContextLabel(String mode) { >+ // remember the list of context labels for this shortcut >+ if (fContextLabels == null) { >+ IConfigurationElement[] labels = getConfigurationElement().getChildren("contextLabel"); //$NON-NLS-1$ >+ fContextLabels = new ArrayList(labels.length); >+ for (int i = 0; i < labels.length; i++) { >+ fContextLabels.add(new Pair(labels[i].getAttribute("mode"), >+ labels[i].getAttribute("label"))); //$NON-NLS-1$ >+ } >+ } >+ // pick out the first occurance of the "name" bound to "mode" >+ Iterator iter = fContextLabels.iterator(); >+ while (iter.hasNext()) { >+ Pair p = (Pair) iter.next(); >+ if (p.firstAsString().equals(mode)) { >+ return p.secondAsString(); >+ } >+ } >+ return "no label"; >+ } >+ >+ /** >+ * Returns the filter class of this shortcut. >+ * >+ * @return the filter class of this shortcut., or <code>null</code> if not >+ * specified >+ */ >+ public IActionFilter getFilterClass() { >+ if (fActionFilter == null) { >+ try { >+ fActionFilter = (IActionFilter)fConfig.createExecutableExtension("filterClass"); //$NON-NLS-1$ >+ } 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; >+ } >+ /** >+ * Returns all of the filter elements of this shortcut as a List of String Pairs. >+ * >+ * @return all of the filter elements of this shortcut., or <code>null</code> if not >+ * specified >+ */ >+ public /* <Pair> */ List getFilters() { >+ if (fFilters == null) { >+ IConfigurationElement[] filters = getConfigurationElement().getChildren("filter"); //$NON-NLS-1$ >+ fFilters = new ArrayList(filters.length); >+ for (int i = 0; i < filters.length; i++) { >+ fFilters.add(new Pair(filters[i].getAttribute("name"), >+ filters[i].getAttribute("value"))); //$NON-NLS-1$ >+ } >+ } >+ return fFilters; >+ } > /** > * Returns the id of this shortcut > * >Index: ui/org/eclipse/debug/internal/ui/Pair.java >=================================================================== >RCS file: ui/org/eclipse/debug/internal/ui/Pair.java >diff -N ui/org/eclipse/debug/internal/ui/Pair.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ ui/org/eclipse/debug/internal/ui/Pair.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,45 @@ >+/******************************************************************************* >+ * 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.internal.ui; >+ >+/** >+ * @author chris@tilts.net >+ * >+ * Pair is a basic tuple of two with classic first and second members. >+ * Since Java is non-polymorphic, we use Object(s) for the pair elements >+ * and cast our brains out. >+ */ >+public class Pair { >+ public Object fFirst = null; >+ public Object fSecond = null; >+ public Pair(Object first, Object second) { >+ fFirst = first; >+ fSecond = second; >+ } >+ /* >+ * String accessors >+ */ >+ public String firstAsString() { >+ return (String) fFirst; >+ } >+ public String secondAsString() { >+ return (String) fSecond; >+ } >+ /* >+ * Integer accessors >+ */ >+ public Integer firstAsInteger() { >+ return (Integer) fFirst; >+ } >+ public Integer secondAsInteger() { >+ return (Integer) fSecond; >+ } >+} >Index: ui/org/eclipse/debug/internal/ui/actions/ContextualLaunchObjectActionDelegate.java >=================================================================== >RCS file: ui/org/eclipse/debug/internal/ui/actions/ContextualLaunchObjectActionDelegate.java >diff -N ui/org/eclipse/debug/internal/ui/actions/ContextualLaunchObjectActionDelegate.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ ui/org/eclipse/debug/internal/ui/actions/ContextualLaunchObjectActionDelegate.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,327 @@ >+/******************************************************************************* >+ * 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.internal.ui.actions; >+ >+import java.util.ArrayList; >+import java.util.Iterator; >+import java.util.List; >+import java.util.Set; >+ >+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.jface.action.Action; >+import org.eclipse.jface.action.ActionContributionItem; >+import org.eclipse.jface.action.IAction; >+import org.eclipse.jface.action.IMenuCreator; >+import org.eclipse.jface.viewers.ISelection; >+import org.eclipse.jface.viewers.IStructuredSelection; >+import org.eclipse.swt.events.MenuAdapter; >+import org.eclipse.swt.events.MenuEvent; >+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; >+import org.eclipse.ui.IWorkbenchPart; >+import org.eclipse.ui.IWorkbenchWindow; >+import org.eclipse.ui.help.WorkbenchHelp; >+ >+/** >+ * An action delegate that builds a context menu with applicable launch shortcuts. >+ * <p> >+ * This class can be contributed as pop-up menu extension action. When envolked, >+ * it becomes a sub-menu that dynamically builds a list of applicable shortcuts >+ * for the current selection (ISelection in the workspace). The LaunchShortCut >+ * extension is consulted to obtain the list of registered short cuts. Each short >+ * cut may have optional information to support a context menu action. The extra >+ * information includes a "filterClass", a list of "contextLabel"s, and a list of >+ * "filter" elements. ContextLabels allow custom labels to appear for any mode >+ * (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> >+ */ >+public class ContextualLaunchObjectActionDelegate >+ implements >+ IObjectActionDelegate, >+ IMenuCreator { >+ >+ private ISelection fSelection; >+ >+ /* >+ * @see org.eclipse.ui.IObjectActionDelegate#setActivePart(org.eclipse.jface.action.IAction, org.eclipse.ui.IWorkbenchPart) >+ */ >+ public void setActivePart(IAction action, IWorkbenchPart targetPart) { >+ // We don't have a need for the active part. >+ } >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.action.IMenuCreator#dispose() >+ */ >+ public void dispose() { >+ // nothing to do >+ } >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.action.IMenuCreator#getMenu(org.eclipse.swt.widgets.Control) >+ */ >+ public Menu getMenu(Control parent) { >+ // never called >+ return null; >+ } >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.action.IMenuCreator#getMenu(org.eclipse.swt.widgets.Menu) >+ */ >+ public Menu getMenu(Menu parent) { >+ //Create the new menu. The menu will get filled when it is about to be shown. see fillMenu(Menu). >+ Menu menu = new Menu(parent); >+ /** >+ * Add listener to repopulate the menu each time >+ * it is shown because MenuManager.update(boolean, boolean) >+ * doesn't dispose pulldown ActionContribution items for each popup menu. >+ */ >+ menu.addMenuListener(new MenuAdapter() { >+ public void menuShown(MenuEvent e) { >+ Menu m = (Menu)e.widget; >+ MenuItem[] items = m.getItems(); >+ for (int i=0; i < items.length; i++) { >+ items[i].dispose(); >+ } >+ fillMenu(m); >+ } >+ }); >+ return menu; >+ } >+ >+ /* >+ * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) >+ */ >+ public void run(IAction action) { >+ // Never called because we become a menu. >+ } >+ >+ IAction delegateAction; >+ /* >+ * @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 (delegateAction != action) { >+ delegateAction = (Action) action; >+ delegateAction.setMenuCreator(this); >+ } >+ action.setEnabled(true); >+ fSelection = selection; >+ } else { >+ action.setEnabled(false); >+ } >+ } >+ } >+ >+ private int fCount = 0; >+ /** >+ * Fill pull down menu with the pages of the JTabbedPane >+ */ >+ protected void fillMenu(Menu menu) { >+ // lookup appropriate launch config types and build launch actions for them. >+ // Retrieve the current perspective and the registered shortcuts >+ String activePerspID = getActivePerspectiveID(); >+ if (activePerspID == null || fSelection == null) { >+ return; >+ } >+ // gather all shortcuts and run their filters so that we only run the >+ // filters one time for each shortcut. Running filters can be expensive. >+ // Also, only *LOADED* plugins get their filters run. >+ List /* <LaunchShortcutExtension> */ allShortCuts = getLaunchConfigurationManager().getLaunchShortcuts(); >+ Iterator iter = allShortCuts.iterator(); >+ List filteredShortCuts = new ArrayList(10); >+ while (iter.hasNext()) { >+ LaunchShortcutExtension ext = (LaunchShortcutExtension) iter.next(); >+ if (isApplicable(ext)) { >+ filteredShortCuts.add(ext); >+ } >+ } >+ iter = filteredShortCuts.iterator(); >+ if (iter.hasNext()) { >+ while (iter.hasNext()) { >+ LaunchShortcutExtension ext = (LaunchShortcutExtension) iter.next(); >+ Set modes = ext.getModes(); // supported launch modes >+ Iterator modeIter = modes.iterator(); >+ while (modeIter.hasNext()) { >+ String mode = (String) modeIter.next(); >+ populateMenu(mode, ext, menu); >+ } >+ } >+ } else { >+ // put in a fake action to show there are none >+// IAction action = new FakeAction("{ }"); >+// ActionContributionItem item= new ActionContributionItem(action); >+// item.fill(menu, -1); >+ } >+ } >+ >+ private IActionFilter getFilterClassIfLoaded(LaunchShortcutExtension ext) { >+ IExtension extensionPoint = ext.getConfigurationElement().getDeclaringExtension(); >+ IPluginDescriptor pluginDescriptor = extensionPoint.getDeclaringPluginDescriptor(); >+ if (pluginDescriptor.isPluginActivated()) { >+ IActionFilter filter = ext.getFilterClass(); >+ return filter; >+ } else { >+ return null; >+ } >+ } >+ /* (non-javadoc) >+ * Apply contextFilters for this extension to decide visibility. >+ * >+ * @return true if this shortcut should appear in the contextual launch menu >+ */ >+ 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) { >+ return false; >+ } >+ List filters = ext.getFilters(); >+ if (filters.isEmpty()) { >+ return false; >+ } >+ Iterator iter = filters.listIterator(); >+ while (iter.hasNext()) { >+ Pair pair = (Pair) iter.next(); >+ String name = pair.firstAsString(); >+ String value= pair.secondAsString(); >+ Object target = (Object) fSelection; >+ // any filter that returns false makes the shortcut non-visible >+ if (!actionFilter.testAttribute(target,name,value)) { >+ return false; >+ } >+ } >+ return true; >+ } >+ /* Add the shortcut to the context menu's launch submenu. >+ * >+ */ >+ private void populateMenu(String mode, LaunchShortcutExtension ext, Menu menu) { >+ LaunchShortcutAction action = new LaunchShortcutAction(mode, ext); >+ action.setActionDefinitionId(ext.getId()); >+ String helpContextId = ext.getHelpContextId(); >+ if (helpContextId != null) { >+ WorkbenchHelp.setHelp(action, helpContextId); >+ } >+ // replace default action label with context label if specified. >+ String label = ext.getContextLabel(mode); >+ label = (label != null) ? label : action.getText(); >+ action.setText(label); >+ 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. >+ * >+ * @return the active perspective ID or <code>null</code> if there is none. >+ */ >+private String getActivePerspectiveID() { >+ IWorkbenchWindow window = DebugUIPlugin.getActiveWorkbenchWindow(); >+ if (window != null) { >+ IWorkbenchPage page = window.getActivePage(); >+ if (page != null) { >+ IPerspectiveDescriptor persp = page.getPerspective(); >+ if (persp != null) { >+ return persp.getId(); >+ } >+ } >+ } >+ return null; >+} >+/** >+ * Returns the launch configuration manager. >+* >+* @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(); >+} >+ >+}
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