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 8516 Details for
Bug 54117
Contextual Launch should use XML Expression Language
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]
Patches org.eclipse.debug.ui
org.eclipse.debug.ui.xml.patch (text/plain), 25.23 KB, created by
Chris Tilt
on 2004-03-11 19:55:30 EST
(
hide
)
Description:
Patches org.eclipse.debug.ui
Filename:
MIME Type:
Creator:
Chris Tilt
Created:
2004-03-11 19:55:30 EST
Size:
25.23 KB
patch
obsolete
>Index: plugin.xml >=================================================================== >RCS file: /home/eclipse/org.eclipse.debug.ui/plugin.xml,v >retrieving revision 1.187 >diff -u -r1.187 plugin.xml >--- plugin.xml 11 Mar 2004 21:58:35 -0000 1.187 >+++ plugin.xml 12 Mar 2004 00:46:26 -0000 >@@ -1729,6 +1729,15 @@ > </action> > </objectContribution> > </extension> >+ <extension point="org.eclipse.core.expressions.propertyTesters"> >+ <propertyTester >+ namespace="org.eclipse.debug.ui" >+ properties="matchesPattern, projectNature, canDelete" >+ type="org.eclipse.core.resources.IResource" >+ class="org.eclipse.debug.internal.ui.ResourceExtender" >+ id="org.eclipse.debug.IResourceExtender"> >+ </propertyTester> >+ </extension> > <!-- End Contextual Run Menu (Work in Progress) --> > <!-- Context extensions --> > <extension >Index: schema/launchShortcuts.exsd >=================================================================== >RCS file: /home/eclipse/org.eclipse.debug.ui/schema/launchShortcuts.exsd,v >retrieving revision 1.10 >diff -u -r1.10 launchShortcuts.exsd >--- schema/launchShortcuts.exsd 11 Mar 2004 18:23:29 -0000 1.10 >+++ schema/launchShortcuts.exsd 12 Mar 2004 00:46:31 -0000 >@@ -49,8 +49,7 @@ > <complexType> > <sequence> > <element ref="perspective" minOccurs="0" maxOccurs="unbounded"/> >- <element ref="filter" minOccurs="0" maxOccurs="unbounded"/> >- <element ref="contextLabel" minOccurs="0" maxOccurs="unbounded"/> >+ <element ref="contextualLaunch" minOccurs="0" maxOccurs="1"/> > </sequence> > <attribute name="id" type="string" use="required"> > <annotation> >@@ -108,30 +107,6 @@ > </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.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> >- <attribute name="nameFilter" type="string"> >- <annotation> >- <documentation> >- An expression (* and ? wildcards supported), matched against the name of a selected resource. A match allows this launch shortcut to appear in the contextual launch popup menu for the selected resource, unless one of the filters fails in filterClass. If the filterClass is not yet loaded (lazy plugin), the result of the nameFilter test will decide inclusion in the context menu. >- </documentation> >- </annotation> >- </attribute> > </complexType> > </element> > >@@ -147,27 +122,17 @@ > </complexType> > </element> > >- <element name="filter"> >+ <element name="contextualLaunch"> > <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. >+ Holds all descriptions for adding shortcuts to the Run context menu (pop-up). > </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> >+ <sequence> >+ <element ref="contextLabel" minOccurs="0" maxOccurs="unbounded"/> >+ <element ref="enablement" minOccurs="0" maxOccurs="1"/> >+ </sequence> > </complexType> > </element> > >@@ -203,6 +168,14 @@ > </annotation> > </attribute> > </complexType> >+ </element> >+ >+ <element name="enablement" type="string"> >+ <annotation> >+ <documentation> >+ Enablement logic using XML expression language. This should use some kind of schema reference. >+ </documentation> >+ </annotation> > </element> > > <annotation> >Index: ui/org/eclipse/debug/internal/ui/actions/ContextualLaunchObjectActionDelegate.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/ContextualLaunchObjectActionDelegate.java,v >retrieving revision 1.5 >diff -u -r1.5 ContextualLaunchObjectActionDelegate.java >--- ui/org/eclipse/debug/internal/ui/actions/ContextualLaunchObjectActionDelegate.java 11 Feb 2004 00:31:16 -0000 1.5 >+++ ui/org/eclipse/debug/internal/ui/actions/ContextualLaunchObjectActionDelegate.java 12 Mar 2004 00:46:33 -0000 >@@ -15,15 +15,14 @@ > import java.util.List; > import java.util.Set; > >+import org.eclipse.core.expressions.EvaluationContext; >+import org.eclipse.core.expressions.Expression; >+import org.eclipse.core.expressions.IEvaluationContext; > import org.eclipse.core.resources.IResource; >-import org.eclipse.core.runtime.IExtension; >-import org.eclipse.core.runtime.IPluginDescriptor; >+import org.eclipse.core.runtime.CoreException; > import org.eclipse.debug.internal.ui.DebugUIPlugin; >-import org.eclipse.debug.internal.ui.Pair; >-import org.eclipse.debug.internal.ui.StringMatcher; > import org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationManager; > 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; >@@ -62,7 +61,7 @@ > IObjectActionDelegate, > IMenuCreator { > >- private IResource fSelection; >+ private IStructuredSelection fSelection; > > /* > * @see org.eclipse.ui.IObjectActionDelegate#setActivePart(org.eclipse.jface.action.IAction, org.eclipse.ui.IWorkbenchPart) >@@ -121,20 +120,15 @@ > public void selectionChanged(IAction action, ISelection selection) { > // 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 (action instanceof Action) { > if (delegateAction != action) { > delegateAction = (Action) action; > delegateAction.setMenuCreator(this); > } >- Object object = ss.getFirstElement(); // already tested size above >- if(object instanceof IResource) { >- fSelection = (IResource)object; >- if (fSelection.getType() == IResource.FILE) { >- action.setEnabled(true); >- return; >- } >- } >+ // save selection and enable our menu >+ fSelection = (IStructuredSelection) selection; >+ action.setEnabled(true); >+ return; > } > } > action.setEnabled(false); >@@ -153,6 +147,8 @@ > * Fill pull down menu with the pages of the JTabbedPane > */ > protected void fillMenu(Menu menu) { >+ IEvaluationContext context = createContext(); >+ > // lookup appropriate launch config types and build launch actions for them. > // Retrieve the current perspective and the registered shortcuts > String activePerspID = getActivePerspectiveID(); >@@ -167,8 +163,13 @@ > List filteredShortCuts = new ArrayList(10); > while (iter.hasNext()) { > LaunchShortcutExtension ext = (LaunchShortcutExtension) iter.next(); >- if (isApplicable(ext)) { >- filteredShortCuts.add(ext); >+ try { >+ if (isApplicable(ext, context)) { >+ filteredShortCuts.add(ext); >+ } >+ } catch (CoreException e) { >+ // bogus XML Expression Language provided. >+ // TODO provide entry in the log? > } > } > iter = filteredShortCuts.iterator(); >@@ -189,59 +190,46 @@ > item.fill(menu, -1); > } > } >- >- private ILaunchFilter getFilterClassIfLoaded(LaunchShortcutExtension ext) { >- IExtension extensionPoint = ext.getConfigurationElement().getDeclaringExtension(); >- IPluginDescriptor pluginDescriptor = extensionPoint.getDeclaringPluginDescriptor(); >- if (pluginDescriptor.isPluginActivated()) { >- ILaunchFilter 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) { >- String nameFilterPattern = ext.getNameFilter(); >- boolean nameMatches = false; >- if (nameFilterPattern != null) { >- StringMatcher sm = new StringMatcher(nameFilterPattern, true, false); >- nameMatches = sm.match(fSelection.getName()); >- if (!nameMatches) { >- // return now to avoid loading the filterClass >- return false; >- } >- } >- >- // Only loaded plugins will be used, so the launchFilter is null if the filterClass is not loaded >- ILaunchFilter launchFilter = getFilterClassIfLoaded(ext); >- if (launchFilter == null) { >- // no launch filter available, just use nameMatches (see bug# 51420) >- return nameMatches; >- } > >- List filters = ext.getFilters(); >- if (filters.isEmpty()) { >- return false; >- } >- Iterator iter = filters.listIterator(); >+ /** >+ * @return an Evaluation context with default variable = selection >+ */ >+ private IEvaluationContext createContext() { >+ // create a default evaluation context with default variable of the user selection >+ List selection = getSelection(); >+ IEvaluationContext context = new EvaluationContext(null, selection); >+ context.addVariable("selection", selection); //$NON-NLS-1$ >+ >+ return context; >+ } >+ >+ /** >+ * @return current selection as a List of IResource elements. >+ */ >+ private List getSelection() { >+ ArrayList result = new ArrayList(); >+ Iterator iter = fSelection.iterator(); > while (iter.hasNext()) { >- Pair pair = (Pair) iter.next(); >- String name = pair.firstAsString(); >- String value= pair.secondAsString(); >- // any filter that returns false makes the shortcut non-visible >- if (!launchFilter.testAttribute(fSelection,name,value)) { >- return false; >- } >+ IResource selection = (IResource) iter.next(); >+ result.add(selection); > } >- return true; >+ return result; > } >- /* Add the shortcut to the context menu's launch submenu. >- * >+ >+ /** >+ * Evaluate the enablement logic in the contextualLaunch >+ * element description. A true result means that we should >+ * include this shortcut in the context menu. >+ * @return true iff shortcut should appear in context menu >+ */ >+ private boolean isApplicable(LaunchShortcutExtension ext, IEvaluationContext context) throws CoreException { >+ // evaluate the enablement logic in the contextual launch description >+ Expression expr = ext.getContextualLaunchEnablementExpression(); >+ return ext.evalContextualLaunchEnablementExpression(context, expr); >+ } >+ >+ /** >+ * 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); >@@ -258,31 +246,31 @@ > item.fill(menu, -1); > } > >-/** >- * 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 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(); > } >- return null; >-} >-/** >- * Returns the launch configuration manager. >-* >-* @return launch configuration manager >-*/ >-private LaunchConfigurationManager getLaunchConfigurationManager() { >- return DebugUIPlugin.getDefault().getLaunchConfigurationManager(); >-} > > } >Index: ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchShortcutExtension.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchShortcutExtension.java,v >retrieving revision 1.12 >diff -u -r1.12 LaunchShortcutExtension.java >--- ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchShortcutExtension.java 11 Mar 2004 18:23:29 -0000 1.12 >+++ ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchShortcutExtension.java 12 Mar 2004 00:46:35 -0000 >@@ -20,11 +20,15 @@ > import java.util.Set; > import java.util.StringTokenizer; > >+import org.eclipse.core.expressions.EvaluationResult; >+import org.eclipse.core.expressions.Expression; >+import org.eclipse.core.expressions.ExpressionConverter; >+import org.eclipse.core.expressions.ExpressionTagNames; >+import org.eclipse.core.expressions.IEvaluationContext; > 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.ILaunchFilter; > import org.eclipse.debug.ui.ILaunchShortcut; > import org.eclipse.jface.resource.ImageDescriptor; > import org.eclipse.jface.viewers.ISelection; >@@ -40,8 +44,8 @@ > private List fPerspectives = null; > private ILaunchShortcut fDelegate = null; > private Set fModes = null; >- private ILaunchFilter fLaunchFilter = null; >- private /* <Pair> */ List fFilters = null; >+ private IConfigurationElement fContextualLaunchConfigurationElement = null; >+ private Expression fContextualLaunchExpr = null; > > /** > * The configuration element defining this tab. >@@ -93,17 +97,32 @@ > } > > /** >- * Returns the name filter of this shortcut or <code>null</code> >- * >- * @return the name filter of this shortcut, or <code>null</code> if not >- * specified >- */ >- public String getNameFilter() { >- return getConfigurationElement().getAttribute("nameFilter"); //$NON-NLS-1$ >+ * Returns the configuration element for the optional Contextual Launch >+ * element of this Launch Configuration description. >+ * @return contextualLaunch element >+ */ >+ public IConfigurationElement getContextualLaunchConfigurationElement() { >+ if (fContextualLaunchConfigurationElement == null) { >+ IConfigurationElement[] elements = getConfigurationElement().getChildren("contextualLaunch"); //$NON-NLS-1$ >+ if (elements.length > 0) { >+ // remember so we don't have to hunt again >+ fContextualLaunchConfigurationElement = elements[0]; >+ } >+ } >+ return fContextualLaunchConfigurationElement; > } >- > /** >- * Returns the contextual launch label of this shortcut >+ * Returns the contextual launch label of this shortcut for the named mode. >+ * <p> >+ * <samp> >+ * <launchShortcut...> >+ * <contextualLaunch> >+ * <contextLabel mode="run" label="Run Java Application"/> >+ * <contextLabel mode="debug" label="Debug Java Application"/> >+ * ... >+ * </contextualLaunch> >+ * </launchShortcut> >+ * </samp> > * > * @return the contextual label of this shortcut, or <code>null</code> if not > * specified >@@ -111,7 +130,11 @@ > 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$ >+ IConfigurationElement context = getContextualLaunchConfigurationElement(); >+ if (context == null) { >+ return null; >+ } >+ IConfigurationElement[] labels = context.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"), //$NON-NLS-1$ >@@ -130,47 +153,44 @@ > } > > /** >- * Returns the filter class of this shortcut. > * >- * @return the filter class of this shortcut., or <code>null</code> if not >- * specified >- */ >- public ILaunchFilter getFilterClass() { >- if (fLaunchFilter == null) { >- try { >- // 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 fLaunchFilter; >+ * @param exp >+ * @param context >+ * @return >+ * @throws CoreException >+ */ >+ public boolean evalContextualLaunchEnablementExpression(IEvaluationContext context, Expression exp) throws CoreException { >+ // return true if result is either TRUE or NOT_LOADED >+ // This allows optimistic inclusion of shortcuts before plugins are loaded >+ return (exp != null) ? ((exp.evaluate(context)) != EvaluationResult.FALSE) : false; > } > > /** >- * 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"), //$NON-NLS-1$ >- filters[i].getAttribute("value"))); //$NON-NLS-1$ >+ * Returns an expression that represents the enablement logic for the >+ * contextual launch element of this launch shortcut description. >+ * @return an evaluatable expression >+ * @throws CoreException if the configuration element can't be >+ * converted. Reasons include: (a) no handler is available to >+ * cope with a certain configuration element or (b) the XML >+ * expression tree is malformed. >+ */ >+ public Expression getContextualLaunchEnablementExpression() throws CoreException { >+ // all of this stuff is optional, so...tedius testing is required >+ if (fContextualLaunchExpr == null) { >+ IConfigurationElement contextualLaunchElement = getContextualLaunchConfigurationElement(); >+ if (contextualLaunchElement == null) { >+ // not available >+ return null; > } >+ IConfigurationElement[] elements = contextualLaunchElement.getChildren(ExpressionTagNames.ENABLEMENT); >+ IConfigurationElement enablement = elements.length > 0 ? elements[0] : null; >+ >+ if (enablement != null) >+ fContextualLaunchExpr= ExpressionConverter.getDefault().perform(enablement); > } >- return fFilters; >+ return fContextualLaunchExpr; > } >+ > /** > * Returns the id of this shortcut > * >@@ -221,6 +241,16 @@ > public ImageDescriptor getImageDescriptor() { > if (fImageDescriptor == null) { > String iconPath = getIconPath(); >+<<<<<<< LaunchShortcutExtension.java >+ // iconPath may be null becuase imageIcon is now optional in shortcut >+ if (iconPath != null) { >+ try { >+ iconURL = new URL(iconURL, iconPath); >+ fImageDescriptor = ImageDescriptor.createFromURL(iconURL); >+ } catch (MalformedURLException e) { >+ DebugUIPlugin.log(e); >+ } >+======= > // iconPath may be null because imageIcon is optional > if (iconPath != null) { > try { >@@ -230,6 +260,7 @@ > } catch (MalformedURLException e) { > DebugUIPlugin.log(e); > } >+>>>>>>> 1.12 > } > } > return fImageDescriptor; >@@ -305,7 +336,14 @@ > } > } > return fModes; >- } >- >+ } >+ >+ /* >+ * Only for debugging >+ * @see java.lang.Object#toString() >+ */ >+ public String toString() { >+ return getId(); >+ } > } > > >Index: ui/org/eclipse/debug/internal/ui/ResourceExtender.java >=================================================================== >RCS file: ui/org/eclipse/debug/internal/ui/ResourceExtender.java >diff -N ui/org/eclipse/debug/internal/ui/ResourceExtender.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ ui/org/eclipse/debug/internal/ui/ResourceExtender.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,57 @@ >+/******************************************************************************* >+ * Copyright (c) 2004 International Business Machines Corp. and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Common Public License v0.5 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/cpl-v05.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ ******************************************************************************/ >+package org.eclipse.debug.internal.ui; >+ >+import org.eclipse.core.expressions.PropertyTester; >+import org.eclipse.core.resources.IProject; >+import org.eclipse.core.resources.IResource; >+import org.eclipse.core.runtime.CoreException; >+ >+/** >+ * ResourceExtender provides property testers for the XML expression >+ * language evaluation. We provide a copy in Debug so that launch shortcuts >+ * can add contextual launch enablement that does not require their plugins >+ * to be loaded. >+ */ >+public class ResourceExtender extends PropertyTester { >+ >+ private static final String PROPERTY_MATCHES_PATTERN= "matchesPattern"; //$NON-NLS-1$ >+ private static final String PROJECT_NATURE = "projectNature"; //$NON-NLS-1$ >+ private static final String CAN_DELETE= "canDelete"; //$NON-NLS-1$ >+ >+ >+ public boolean test(Object receiver, String method, Object[] args, Object expectedValue) { >+ IResource resource= (IResource)receiver; >+ if (PROPERTY_MATCHES_PATTERN.equals(method)) { //$NON-NLS-1$ >+ String fileName= resource.getName(); >+ StringMatcher matcher= new StringMatcher((String)expectedValue, false, false); >+ return matcher.match(fileName); >+ } else if (PROJECT_NATURE.equals(method)) { >+ try { >+ IProject proj = resource.getProject(); >+ return proj.isAccessible() && proj.hasNature((String)expectedValue); >+ } catch (CoreException e) { >+ return false; >+ } >+ } else if (CAN_DELETE.equals(method)) { >+ return canDelete(resource); >+ } >+ return false; >+ } >+ >+ private boolean canDelete(IResource resource) { >+ if (!resource.exists() || resource.isPhantom()) >+ return false; >+ if (resource.getType() == IResource.ROOT || resource.getType() == IResource.PROJECT) >+ return false; >+ return true; >+ } >+}
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 54117
: 8516 |
8540
|
8542