1 11 package org.eclipse.debug.internal.ui.actions; 12 13 import org.eclipse.core.expressions.PropertyTester; 14 import org.eclipse.core.resources.IResource; 15 import org.eclipse.core.runtime.IAdaptable; 16 import org.eclipse.core.runtime.Platform; 17 import org.eclipse.debug.internal.ui.DebugUIPlugin; 18 import org.eclipse.debug.internal.ui.IInternalDebugUIConstants; 19 import org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationManager; 20 import org.eclipse.debug.ui.actions.ILaunchable; 21 22 25 public class LaunchablePropertyTester extends PropertyTester { 26 27 30 public boolean test(Object receiver, String property, Object [] args, Object expectedValue) { 31 if ("launchable".equals(property)) { if (DebugUIPlugin.getDefault().getLaunchConfigurationManager().launchModeAvailable((String )expectedValue)) { 33 return Platform.getAdapterManager().hasAdapter(receiver, ILaunchable.class.getName()); 34 } 35 } 36 if("contextlaunch".equals(property)) { if(DebugUIPlugin.getDefault().getPreferenceStore().getBoolean(IInternalDebugUIConstants.PREF_USE_CONTEXTUAL_LAUNCH)) { 38 IResource res = getResource(receiver); 39 if(res != null) { 40 return res.isAccessible() && getLaunchConfiguraitonManager().getLaunchShortcuts(getResource(receiver)).size() > 0 && getLaunchConfiguraitonManager().isSharedConfig(receiver) == null; 41 } 42 return false; 43 } 44 } 45 return false; 46 } 47 48 52 protected LaunchConfigurationManager getLaunchConfiguraitonManager() { 53 return DebugUIPlugin.getDefault().getLaunchConfigurationManager(); 54 } 55 56 61 protected IResource getResource(Object element) { 62 IResource resource = null; 63 if (element instanceof IResource) { 64 resource = (IResource) element; 65 } else if (element instanceof IAdaptable) { 66 resource = (IResource) ((IAdaptable)element).getAdapter(IResource.class); 67 } 68 return resource; 69 } 70 } 71 | Popular Tags |