mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-17 05:55:22 +02:00
Change shortcut context launch enablement to be true for executables and C projects.
This commit is contained in:
parent
b2f48c45c9
commit
a0b8eefc60
2 changed files with 28 additions and 31 deletions
|
@ -80,11 +80,17 @@
|
|||
<enablement>
|
||||
<with variable="selection">
|
||||
<count value="1"/>
|
||||
<iterate>
|
||||
<or>
|
||||
<test property="org.eclipse.cdt.launch.isCElement"/>
|
||||
<instanceof value="org.eclipse.cdt.internal.core.model.CProject"/>
|
||||
</or>
|
||||
<iterate
|
||||
ifEmpty="false"
|
||||
operator="or">
|
||||
<or>
|
||||
<test
|
||||
forcePluginActivation="true"
|
||||
property="org.eclipse.cdt.launch.isExecutable"/>
|
||||
<test
|
||||
forcePluginActivation="true"
|
||||
property="org.eclipse.cdt.launch.isCProject"/>
|
||||
</or>
|
||||
</iterate>
|
||||
</with>
|
||||
</enablement>
|
||||
|
@ -110,7 +116,7 @@
|
|||
<extension point="org.eclipse.core.expressions.propertyTesters">
|
||||
<propertyTester
|
||||
namespace="org.eclipse.cdt.launch"
|
||||
properties="isCElement"
|
||||
properties="isExecutable,isCProject"
|
||||
type="org.eclipse.core.runtime.IAdaptable"
|
||||
class="org.eclipse.cdt.launch.internal.CPropertyTester"
|
||||
id="org.eclipse.cdt.launch.CPropertyTester">
|
||||
|
|
|
@ -14,7 +14,9 @@ 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.cdt.core.model.ICProject;
|
||||
import org.eclipse.core.expressions.PropertyTester;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.runtime.IAdaptable;
|
||||
|
||||
|
@ -23,35 +25,15 @@ import org.eclipse.core.runtime.IAdaptable;
|
|||
*/
|
||||
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 ("isCElement".equals(property)) { //$NON-NLS-1$
|
||||
return isCElement(receiver);
|
||||
}
|
||||
if ("isExecutable".equals(property)) { //$NON-NLS-1$
|
||||
if ("isExecutable".equals(property)) //$NON-NLS-1$
|
||||
return isExecutable(receiver);
|
||||
}
|
||||
return false;
|
||||
else if ("isCProject".equals(property)) //$NON-NLS-1$
|
||||
return isCProject(receiver);
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean isCElement(Object receiver) {
|
||||
ICElement celement = null;
|
||||
if (receiver instanceof IAdaptable) {
|
||||
IResource res = (IResource) ((IAdaptable)receiver).getAdapter(IResource.class);
|
||||
if (res != null) {
|
||||
celement = CoreModel.getDefault().create(res);
|
||||
}
|
||||
}
|
||||
return (celement != null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Look for executable.
|
||||
* @return true if the target resource has a <code>main</code> method,
|
||||
* <code>false</code> otherwise.
|
||||
*/
|
||||
private boolean isExecutable(Object receiver) {
|
||||
ICElement celement = null;
|
||||
if (receiver instanceof IAdaptable) {
|
||||
|
@ -63,4 +45,13 @@ public class CPropertyTester extends PropertyTester {
|
|||
return (celement != null && celement instanceof IBinary);
|
||||
}
|
||||
|
||||
private boolean isCProject(Object receiver) {
|
||||
if (receiver instanceof IProject)
|
||||
return CoreModel.hasCNature((IProject)receiver);
|
||||
else if (receiver instanceof ICProject)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue