Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/build
diff options
context:
space:
mode:
authorChris Recoskie2006-05-03 10:50:06 +0000
committerChris Recoskie2006-05-03 10:50:06 +0000
commit033966ab4c22a8f61ea9109f7c90d1eb3e7068cc (patch)
tree59b006a32b06e8a2709812e9da43d4bae94b2915 /build
parentf8bfa05b185d73881960f7f8dcb4105b5f958f53 (diff)
downloadorg.eclipse.cdt-033966ab4c22a8f61ea9109f7c90d1eb3e7068cc.tar.gz
org.eclipse.cdt-033966ab4c22a8f61ea9109f7c90d1eb3e7068cc.tar.xz
org.eclipse.cdt-033966ab4c22a8f61ea9109f7c90d1eb3e7068cc.zip
fixes for 139667 and 139797
Diffstat (limited to 'build')
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/plugin.properties6
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/plugin.xml10
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/actions/BuildFilesAction.java114
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/actions/CleanFilesAction.java95
4 files changed, 151 insertions, 74 deletions
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/plugin.properties b/build/org.eclipse.cdt.managedbuilder.ui/plugin.properties
index 3b1807cc8a6..ec805c443ce 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/plugin.properties
+++ b/build/org.eclipse.cdt.managedbuilder.ui/plugin.properties
@@ -38,8 +38,8 @@ BuildConfigContextAction.label=Active Bui&ld Configuration
BuildConfigAction.tooltip=Change active build configuration for the current project
# Build/clean selected files actions
-BuildSelectedFiles.label=Build F&ile(s)
-CleanSelectedFiles.label=Cl&ean File(s)
+BuildSelectedFiles.label=Build Selected &File(s)
+CleanSelectedFiles.label=C&lean Selected File(s)
BuildSelectedFilesActionSet.label=Build/Clean Selected File(s)
-BuildSelectedFiles.tooltip=Rebuilds the selected file(s) including all dependencies
+BuildSelectedFiles.tooltip=Rebuilds the selected file(s)
CleanSelectedFiles.tooltip=Cleans the output file(s) for the selected file(s) \ No newline at end of file
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/plugin.xml b/build/org.eclipse.cdt.managedbuilder.ui/plugin.xml
index cf59f749e66..52393992fcd 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/plugin.xml
+++ b/build/org.eclipse.cdt.managedbuilder.ui/plugin.xml
@@ -158,7 +158,8 @@
label="%BuildSelectedFiles.label"
menubarPath="project/build"
style="push"
- tooltip="%buildSelectedFiles.tooltip"/>
+ tooltip="%buildSelectedFiles.tooltip">
+ </action>
<action
class="org.eclipse.cdt.managedbuilder.ui.actions.CleanFilesAction"
enablesFor="+"
@@ -166,7 +167,8 @@
label="%CleanSelectedFiles.label"
menubarPath="project/build"
style="push"
- tooltip="%cleanFilesAction.tooltip"/>
+ tooltip="%cleanFilesAction.tooltip">
+ </action>
</actionSet>
</extension>
<extension
@@ -188,9 +190,9 @@
value="org.eclipse.cdt.managedbuilder.core.managedBuildNature"/>
</objectContribution>
<objectContribution
- adaptable="false"
+ adaptable="true"
id="org.eclipse.cdt.managedbuilder.ui.objectContribution1"
- objectClass="org.eclipse.cdt.core.model.ITranslationUnit">
+ objectClass="org.eclipse.core.resources.IResource">
<action
class="org.eclipse.cdt.managedbuilder.ui.actions.BuildFilesAction"
enablesFor="+"
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/actions/BuildFilesAction.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/actions/BuildFilesAction.java
index 933ba44cd86..92bb91207b3 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/actions/BuildFilesAction.java
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/actions/BuildFilesAction.java
@@ -15,6 +15,7 @@ import java.util.LinkedList;
import java.util.List;
import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.jface.action.Action;
@@ -28,27 +29,32 @@ import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.internal.core.GeneratedMakefileBuilder;
import org.eclipse.cdt.managedbuilder.internal.core.ManagedMakeMessages;
+import org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.ISelectionService;
+import org.eclipse.ui.actions.ActionDelegate;
/**
* @author crecoskie
*
*/
-public class BuildFilesAction extends Action implements IWorkbenchWindowActionDelegate {
+public class BuildFilesAction extends ActionDelegate implements IWorkbenchWindowActionDelegate {
/**
* The workbench window; or <code>null</code> if this action has been
* <code>dispose</code>d.
*/
- private IWorkbenchWindow workbenchWindow;
+ private IWorkbenchWindow workbenchWindow = null;
+ private IAction action = null;
+
/**
*
*/
@@ -60,39 +66,10 @@ public class BuildFilesAction extends Action implements IWorkbenchWindowActionDe
* Creates an instance of this action, for use in the given window.
*/
public BuildFilesAction(IWorkbenchWindow window) {
- super(ManagedMakeMessages.getResourceString("BuildFilesAction.buildFiles")); //$NON-NLS-1$
if (window == null) {
throw new IllegalArgumentException();
}
this.workbenchWindow = window;
- setToolTipText(ManagedMakeMessages.getResourceString("BuildFilesAction.buildSelectedFile")); //$NON-NLS-1$
- setActionDefinitionId("org.eclipse.cdt.managedbuilder.ui.BuildFilesAction"); //$NON-NLS-1$
- }
-
- /**
- * @param text
- */
- public BuildFilesAction(String text) {
- super(text);
- // TODO Auto-generated constructor stub
- }
-
- /**
- * @param text
- * @param image
- */
- public BuildFilesAction(String text, ImageDescriptor image) {
- super(text, image);
- // TODO Auto-generated constructor stub
- }
-
- /**
- * @param text
- * @param style
- */
- public BuildFilesAction(String text, int style) {
- super(text, style);
- // TODO Auto-generated constructor stub
}
/*
@@ -105,6 +82,15 @@ public class BuildFilesAction extends Action implements IWorkbenchWindowActionDe
}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.actions.ActionDelegate#init(org.eclipse.jface.action.IAction)
+ */
+ public void init(IAction action) {
+ this.action = action;
+ update();
+ }
+
/*
* (non-Javadoc)
*
@@ -182,7 +168,7 @@ public class BuildFilesAction extends Action implements IWorkbenchWindowActionDe
IManagedBuildInfo buildInfo = ManagedBuildManager
.getBuildInfo(file.getProject());
- if (buildInfo.buildsFileType(file.getFileExtension())) {
+ if (buildInfo != null && buildInfo.buildsFileType(file.getFileExtension())) {
files.add(file);
}
}
@@ -260,6 +246,7 @@ public class BuildFilesAction extends Action implements IWorkbenchWindowActionDe
}
+
/*
* (non-Javadoc)
*
@@ -275,6 +262,65 @@ public class BuildFilesAction extends Action implements IWorkbenchWindowActionDe
}
+ private boolean shouldBeEnabled() {
+ ISelectionService selectionService = workbenchWindow
+ .getSelectionService();
+ ISelection selection = selectionService.getSelection();
+
+ if (selection instanceof IStructuredSelection) {
+ IStructuredSelection structuredSelection = (IStructuredSelection) selection;
+ for (Iterator elements = structuredSelection.iterator(); elements
+ .hasNext();) {
+ IFile file = convertToIFile(elements.next());
+ if (file != null) {
+ // we only add files that we can actually build
+ if(!ManagedBuildManager.manages(file.getProject()))
+ {
+ return false;
+ }
+
+ IManagedBuildInfo buildInfo = ManagedBuildManager
+ .getBuildInfo(file.getProject());
+
+ if(buildInfo == null)
+ return false;
+
+ IManagedBuilderMakefileGenerator buildfileGenerator = ManagedBuildManager
+ .getBuildfileGenerator(buildInfo
+ .getDefaultConfiguration());
+
+ if(buildfileGenerator == null)
+ return false;
+
+ // make sure build file generator is initialized
+ buildfileGenerator.initialize(file.getProject(), buildInfo, new NullProgressMonitor());
+
+ // if we have no build info or we can't build the file, then
+ // disable the action
+ if (!buildInfo.buildsFileType(file.getFileExtension())
+ || buildfileGenerator.isGeneratedResource(file) ) {
+
+ return false;
+
+ }
+ }
+ }
+ }
+
+ return true;
+ }
+
+ /*
+ * Updates the enablement state for the action based upon the selection. If
+ * the selection corresponds to files buildable by MBS, then the action will
+ * be enabled.
+ */
+ private void update() {
+ if(action != null)
+ action.setEnabled(shouldBeEnabled());
+ }
+
+
/*
* (non-Javadoc)
*
@@ -282,8 +328,8 @@ public class BuildFilesAction extends Action implements IWorkbenchWindowActionDe
* org.eclipse.jface.viewers.ISelection)
*/
public void selectionChanged(IAction action, ISelection selection) {
- // TODO Auto-generated method stub
-
+ // update state
+ update();
}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/actions/CleanFilesAction.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/actions/CleanFilesAction.java
index 81d4a3e046b..5998755d0c0 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/actions/CleanFilesAction.java
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/actions/CleanFilesAction.java
@@ -48,17 +48,20 @@ import org.eclipse.ui.ISelectionService;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.IWorkbenchWindowActionDelegate;
import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.actions.ActionDelegate;
/**
* @author crecoskie
*
*/
-public class CleanFilesAction extends Action implements IWorkbenchWindowActionDelegate {
+public class CleanFilesAction extends ActionDelegate implements IWorkbenchWindowActionDelegate {
/**
* The workbench window; or <code>null</code> if this action has been
* <code>dispose</code>d.
*/
- private IWorkbenchWindow workbenchWindow;
+ private IWorkbenchWindow workbenchWindow = null;
+
+ private IAction action = null;
/**
*
@@ -71,39 +74,10 @@ public class CleanFilesAction extends Action implements IWorkbenchWindowActionDe
* Creates an instance of this action, for use in the given window.
*/
public CleanFilesAction(IWorkbenchWindow window) {
- super(ManagedMakeMessages.getResourceString("CleanFilesAction.cleanFiles")); //$NON-NLS-1$
if (window == null) {
throw new IllegalArgumentException();
}
this.workbenchWindow = window;
- setToolTipText(ManagedMakeMessages.getResourceString("CleanFilesAction.cleanSelectedFiles")); //$NON-NLS-1$
- setActionDefinitionId("org.eclipse.cdt.managedbuilder.ui.CleanFilesAction"); //$NON-NLS-1$
- }
-
- /**
- * @param text
- */
- public CleanFilesAction(String text) {
- super(text);
- // TODO Auto-generated constructor stub
- }
-
- /**
- * @param text
- * @param image
- */
- public CleanFilesAction(String text, ImageDescriptor image) {
- super(text, image);
- // TODO Auto-generated constructor stub
- }
-
- /**
- * @param text
- * @param style
- */
- public CleanFilesAction(String text, int style) {
- super(text, style);
- // TODO Auto-generated constructor stub
}
/*
@@ -116,6 +90,15 @@ public class CleanFilesAction extends Action implements IWorkbenchWindowActionDe
}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.actions.ActionDelegate#init(org.eclipse.jface.action.IAction)
+ */
+ public void init(IAction action) {
+ this.action = action;
+ update();
+ }
+
/*
* (non-Javadoc)
*
@@ -287,6 +270,53 @@ public class CleanFilesAction extends Action implements IWorkbenchWindowActionDe
job.schedule();
}
+
+ private boolean shouldBeEnabled() {
+ ISelectionService selectionService = workbenchWindow
+ .getSelectionService();
+ ISelection selection = selectionService.getSelection();
+
+ if (selection instanceof IStructuredSelection) {
+ IStructuredSelection structuredSelection = (IStructuredSelection) selection;
+ for (Iterator elements = structuredSelection.iterator(); elements
+ .hasNext();) {
+ IFile file = convertToIFile(elements.next());
+ if (file != null) {
+ // we only add files that we can actually build
+ if(!ManagedBuildManager.manages(file.getProject()))
+ {
+ return false;
+ }
+
+ IManagedBuildInfo buildInfo = ManagedBuildManager
+ .getBuildInfo(file.getProject());
+
+ // if we have no build info or we can't build the file, then
+ // disable the action
+ if (buildInfo == null
+ || !buildInfo.buildsFileType(file.getFileExtension()) ) {
+ return false;
+ }
+ }
+ }
+ }
+
+ return true;
+ }
+
+
+
+
+ /*
+ * Updates the enablement state for the action based upon the selection. If
+ * the selection corresponds to files buildable by MBS, then the action will
+ * be enabled.
+ */
+ private void update() {
+ if(action != null)
+ action.setEnabled(shouldBeEnabled());
+ }
+
/*
* (non-Javadoc)
*
@@ -294,8 +324,7 @@ public class CleanFilesAction extends Action implements IWorkbenchWindowActionDe
* org.eclipse.jface.viewers.ISelection)
*/
public void selectionChanged(IAction action, ISelection selection) {
- // TODO Auto-generated method stub
-
+ update();
}
}

Back to the top