From 57c631cd4c4b5864e4b30a70575c9270050f594f Mon Sep 17 00:00:00 2001 From: David Inglis Date: Fri, 23 Apr 2004 13:37:24 +0000 Subject: [PATCH] fixed https://bugs.eclipse.org/bugs/show_bug.cgi?id=59680 --- launch/org.eclipse.cdt.launch/ChangeLog | 10 +++- launch/org.eclipse.cdt.launch/plugin.xml | 34 +++++++++++--- .../internal/CApplicationLaunchShortcut.java | 28 +---------- .../cdt/launch/internal/CPropertyTester.java | 47 +++++++++++++++++++ 4 files changed, 84 insertions(+), 35 deletions(-) create mode 100644 launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/CPropertyTester.java diff --git a/launch/org.eclipse.cdt.launch/ChangeLog b/launch/org.eclipse.cdt.launch/ChangeLog index e47b6b5fc48..d0ba37475bd 100644 --- a/launch/org.eclipse.cdt.launch/ChangeLog +++ b/launch/org.eclipse.cdt.launch/ChangeLog @@ -1,8 +1,16 @@ +2004-04-23 David Inglis + + fix for https://bugs.eclipse.org/bugs/show_bug.cgi?id=59680 + + * src/org/eclipse/cdt/launch/internal/CApplicationLaunchShortcut.java + * src/org/eclipse/cdt/launch/internal/CPropertyTester.java + * plugin.xml + 2004-04-19 Alain Magloire Core Model interface throws Exception * src/org/eclipse/cdt/launch/internal/CApplicationLaunchShortcut.java - * sr/org/eclipse/cdt/launch/ui/CMaintab.java + * src/org/eclipse/cdt/launch/ui/CMaintab.java 2004-04-06 Mikhail Khodjaiants diff --git a/launch/org.eclipse.cdt.launch/plugin.xml b/launch/org.eclipse.cdt.launch/plugin.xml index 06f78003658..4949ee678f4 100644 --- a/launch/org.eclipse.cdt.launch/plugin.xml +++ b/launch/org.eclipse.cdt.launch/plugin.xml @@ -14,6 +14,7 @@ + @@ -76,18 +77,27 @@ label="%CApplicationShortcut.label" icon="icons/c_app.gif" modes="run, debug" - filterClass="org.eclipse.cdt.launch.internal.CApplicationLaunchShortcut" class="org.eclipse.cdt.launch.internal.CApplicationLaunchShortcut" id="org.eclipse.cdt.debug.ui.localCShortcut"> + + + + + + + + + + + + - - @@ -96,5 +106,15 @@ + + + + + diff --git a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/CApplicationLaunchShortcut.java b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/CApplicationLaunchShortcut.java index 0d09717465e..436a511db05 100644 --- a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/CApplicationLaunchShortcut.java +++ b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/CApplicationLaunchShortcut.java @@ -8,7 +8,6 @@ import java.util.List; import org.eclipse.cdt.core.model.CModelException; import org.eclipse.cdt.core.model.CoreModel; import org.eclipse.cdt.core.model.IBinary; -import org.eclipse.cdt.core.model.ICElement; import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.debug.core.CDebugCorePlugin; import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants; @@ -18,7 +17,6 @@ import org.eclipse.cdt.launch.AbstractCLaunchDelegate; import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin; import org.eclipse.cdt.ui.CElementLabelProvider; import org.eclipse.core.boot.BootLoader; -import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IAdaptable; @@ -31,7 +29,6 @@ import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; import org.eclipse.debug.core.ILaunchManager; import org.eclipse.debug.ui.DebugUITools; import org.eclipse.debug.ui.IDebugModelPresentation; -import org.eclipse.debug.ui.ILaunchFilter; import org.eclipse.debug.ui.ILaunchShortcut; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.dialogs.ProgressMonitorDialog; @@ -47,7 +44,7 @@ import org.eclipse.ui.dialogs.TwoPaneElementSelector; /** */ -public class CApplicationLaunchShortcut implements ILaunchShortcut, ILaunchFilter { +public class CApplicationLaunchShortcut implements ILaunchShortcut { /** * @see org.eclipse.debug.ui.ILaunchShortcut#launch(IEditorPart, String) @@ -400,27 +397,4 @@ public class CApplicationLaunchShortcut implements ILaunchShortcut, ILaunchFilte } } - /* (non-Javadoc) - * @see org.eclipse.debug.ui.ILaunchFilter#testAttribute(org.eclipse.core.resources.IResource, java.lang.String, java.lang.String) - */ - public boolean testAttribute(IResource target, String name, String value) { - if ("ContextualLaunchActionFilter".equals(name)) { //$NON-NLS-1$ - return isExecutable(target); - } - return false; - } - - /** - * Look for executable. - * @return true if the target resource has a main method, - * false otherwise. - */ - private boolean isExecutable(IResource target) { - ICElement celement = null; - if (target instanceof IFile) { - celement = CoreModel.getDefault().create(target); - } - return (celement != null && celement instanceof IBinary); - } - } diff --git a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/CPropertyTester.java b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/CPropertyTester.java new file mode 100644 index 00000000000..e06c953f7c1 --- /dev/null +++ b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/CPropertyTester.java @@ -0,0 +1,47 @@ +/******************************************************************************* + * Copyright (c) 2000, 2003 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 implementation + *******************************************************************************/ +package org.eclipse.cdt.launch.internal; + +import org.eclipse.cdt.core.model.CoreModel; +import org.eclipse.cdt.core.model.IBinary; +import org.eclipse.cdt.core.model.ICElement; +import org.eclipse.core.expressions.PropertyTester; +import org.eclipse.core.resources.IFile; + +/** + * A property tester that determines if a file is an executable. + */ +public class CPropertyTester extends PropertyTester { + + /* (non-Javadoc) + * @see org.eclipse.core.expressions.IPropertyTester#test(java.lang.Object, java.lang.String, java.lang.Object[], java.lang.Object) + */ + public boolean test(Object receiver, String property, Object[] args, Object expectedValue) { + if ("isExecutable".equals(property)) { //$NON-NLS-1$ + return isExecutable(receiver); + } + return false; + } + + /** + * Look for executable. + * @return true if the target resource has a main method, + * false otherwise. + */ + private boolean isExecutable(Object target) { + ICElement celement = null; + if (target instanceof IFile) { + celement = CoreModel.getDefault().create((IFile) target); + } + return (celement != null && celement instanceof IBinary); + } + +}