1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-19 15:05:36 +02:00
David Inglis 2004-04-23 13:37:24 +00:00
parent 34f1154c4f
commit 57c631cd4c
4 changed files with 84 additions and 35 deletions

View file

@ -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

View file

@ -14,6 +14,7 @@
</runtime>
<requires>
<import plugin="org.eclipse.ui.ide"/>
<import plugin="org.eclipse.core.expressions"/>
<import plugin="org.eclipse.core.resources"/>
<import plugin="org.eclipse.debug.core"/>
<import plugin="org.eclipse.debug.ui"/>
@ -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">
<contextualLaunch>
<enablement>
<with variable="selection">
<count value="1"/>
<iterate>
<test property="org.eclipse.cdt.launch.isExecutable"/>
</iterate>
</with>
</enablement>
<contextLabel
mode="run"
label="%ContextualRunJavaApplication.label"/>
<contextLabel
mode="debug"
label="%ContextualDebugJavaApplication.label"/>
</contextualLaunch>
<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>
@ -96,5 +106,15 @@
</perspective>
</shortcut>
</extension>
<!-- Property testers -->
<extension point="org.eclipse.core.expressions.propertyTesters">
<propertyTester
namespace="org.eclipse.cdt.launch"
properties="isExecutable"
type="org.eclipse.core.resources.IResource"
class="org.eclipse.cdt.launch.internal.CPropertyTester"
id="org.eclipse.cdt.launch.CPropertyTester">
</propertyTester>
</extension>
</plugin>

View file

@ -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 <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);
}
}

View file

@ -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 <code>main</code> method,
* <code>false</code> 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);
}
}