mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 06:32:10 +02:00
Support For the Run contribution
This commit is contained in:
parent
a0d5e302cb
commit
9579ebb09c
3 changed files with 45 additions and 4 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue