Skip to main content
summaryrefslogtreecommitdiffstats
path: root/launch
diff options
context:
space:
mode:
authorAlain Magloire2004-02-19 18:29:54 -0500
committerAlain Magloire2004-02-19 18:29:54 -0500
commit9579ebb09c442bc77eaaad8a12e3258cf9d0cc77 (patch)
treebeae0f456f63df6e5b09c8fec2fbd67e10c56229 /launch
parenta0d5e302cba93632b5ae01220ce8ba44a9bf3f50 (diff)
downloadorg.eclipse.cdt-9579ebb09c442bc77eaaad8a12e3258cf9d0cc77.tar.gz
org.eclipse.cdt-9579ebb09c442bc77eaaad8a12e3258cf9d0cc77.tar.xz
org.eclipse.cdt-9579ebb09c442bc77eaaad8a12e3258cf9d0cc77.zip
Support For the Run contribution
Diffstat (limited to 'launch')
-rw-r--r--launch/org.eclipse.cdt.launch/plugin.properties5
-rw-r--r--launch/org.eclipse.cdt.launch/plugin.xml12
-rw-r--r--launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/CApplicationLaunchShortcut.java32
3 files changed, 45 insertions, 4 deletions
diff --git a/launch/org.eclipse.cdt.launch/plugin.properties b/launch/org.eclipse.cdt.launch/plugin.properties
index de0ff3f849..27020f9589 100644
--- a/launch/org.eclipse.cdt.launch/plugin.properties
+++ b/launch/org.eclipse.cdt.launch/plugin.properties
@@ -13,3 +13,8 @@ providerName=Eclipse.org
LocalCDTLaunch.name= C/C++ Local
CoreFileCDTLaunch.name= C/C++ Postmortem debugger
+
+CApplicationShortcut.label=C Local Application
+ContextualRunJavaApplication.label=Run C Local Application
+ContextualDebugJavaApplication.label=Debug C Local Application
+
diff --git a/launch/org.eclipse.cdt.launch/plugin.xml b/launch/org.eclipse.cdt.launch/plugin.xml
index 197d114594..06f7800365 100644
--- a/launch/org.eclipse.cdt.launch/plugin.xml
+++ b/launch/org.eclipse.cdt.launch/plugin.xml
@@ -73,11 +73,21 @@
<extension
point="org.eclipse.debug.ui.launchShortcuts">
<shortcut
- label="C Local Application"
+ 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">
+ <filter
+ name="ContextualLaunchActionFilter"
+ value="supportsContextualLaunch"/>
+ <contextLabel
+ mode="run"
+ label="%ContextualRunJavaApplication.label"/>
+ <contextLabel
+ mode="debug"
+ label="%ContextualDebugJavaApplication.label"/>
<perspective
id="org.eclipse.cdt.ui.CPerspective">
</perspective>
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 4cdf80a20f..33443777a6 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
@@ -7,6 +7,7 @@ import java.util.List;
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;
@@ -16,6 +17,7 @@ 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;
@@ -28,6 +30,7 @@ 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;
@@ -43,7 +46,7 @@ import org.eclipse.ui.dialogs.TwoPaneElementSelector;
/**
*/
-public class CApplicationLaunchShortcut implements ILaunchShortcut {
+public class CApplicationLaunchShortcut implements ILaunchShortcut, ILaunchFilter {
/**
* @see org.eclipse.debug.ui.ILaunchShortcut#launch(IEditorPart, String)
@@ -288,8 +291,8 @@ public class CApplicationLaunchShortcut implements ILaunchShortcut {
if (element instanceof IBinary) {
IBinary bin = (IBinary)element;
StringBuffer name = new StringBuffer();
- name.append(bin.getCPU() + (bin.isLittleEndian() ? "le" : "be"));
- name.append(" - ");
+ name.append(bin.getCPU() + (bin.isLittleEndian() ? "le" : "be")); //$NON-NLS-1$ //$NON-NLS-2$
+ name.append(" - "); //$NON-NLS-1$
name.append(bin.getPath().toString());
return name.toString();
}
@@ -385,4 +388,27 @@ public class CApplicationLaunchShortcut implements ILaunchShortcut {
}
}
+ /* (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 <code>main</code> method,
+ * <code>false</code> otherwise.
+ */
+ private boolean isExecutable(IResource target) {
+ ICElement celement = null;
+ if (target instanceof IFile) {
+ celement = CoreModel.getDefault().create(target);
+ }
+ return (celement != null && celement instanceof IBinary);
+ }
+
}

Back to the top