diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/actions/CreateBuildAction.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/actions/CreateBuildAction.java
index d05faa5c2f5..e8bd55e91f3 100644
--- a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/actions/CreateBuildAction.java
+++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/actions/CreateBuildAction.java
@@ -8,7 +8,14 @@
***********************************************************************/
package org.eclipse.cdt.make.ui.actions;
+import org.eclipse.cdt.core.model.ICContainer;
+import org.eclipse.cdt.make.core.IMakeTarget;
+import org.eclipse.cdt.make.core.MakeCorePlugin;
+import org.eclipse.cdt.make.internal.ui.MakeUIPlugin;
+import org.eclipse.cdt.make.ui.dialogs.BuildTargetDialog;
import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.QualifiedName;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
@@ -24,8 +31,25 @@ public class CreateBuildAction extends ActionDelegate implements IObjectActionDe
IContainer fContainer;
public void run(IAction action) {
- BuildTargetDialog dialog = new BuildTargetDialog(fPart.getSite().getShell(), fContainer);
- dialog.open();
+ if ( fContainer != null ) {
+ BuildTargetDialog dialog = new BuildTargetDialog(fPart.getSite().getShell(), fContainer);
+ dialog.setOpenMode(BuildTargetDialog.OPEN_MODE_BUILD);
+ String name;
+ try {
+ name = (String) fContainer.getSessionProperty(new QualifiedName(MakeUIPlugin.getUniqueIdentifier(), "lastTarget"));
+ IMakeTarget target = MakeCorePlugin.getDefault().getTargetManager().findTarget(fContainer, name);
+ dialog.setSelectedTarget(target);
+ } catch (CoreException e) {
+ }
+ dialog.open();
+ IMakeTarget target = dialog.getSelectedTarget();
+ if ( target != null ) {
+ try {
+ fContainer.setSessionProperty(new QualifiedName(MakeUIPlugin.getUniqueIdentifier(), "lastTarget"), target.getName());
+ } catch (CoreException e1) {
+ }
+ }
+ }
}
public void setActivePart(IAction action, IWorkbenchPart targetPart) {
@@ -37,8 +61,14 @@ public class CreateBuildAction extends ActionDelegate implements IObjectActionDe
public void selectionChanged(IAction action, ISelection selection) {
if ( selection instanceof IStructuredSelection ) {
- fContainer = (IContainer)((IStructuredSelection)selection).getFirstElement();
+ IStructuredSelection sel = (IStructuredSelection)selection;
+ if ( sel.getFirstElement() instanceof ICContainer ) {
+ fContainer = (IContainer) ((ICContainer)sel.getFirstElement()).getUnderlyingResource();
+ } else if (sel.getFirstElement() instanceof IContainer ) {
+ fContainer = (IContainer)sel.getFirstElement();
+ } else {
+ fContainer = null;
+ }
}
}
-
}
diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/actions/BuildTargetDialog.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/BuildTargetDialog.java
similarity index 91%
rename from build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/actions/BuildTargetDialog.java
rename to build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/BuildTargetDialog.java
index bb1ca428414..d1aea057b88 100644
--- a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/actions/BuildTargetDialog.java
+++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/BuildTargetDialog.java
@@ -1,8 +1,9 @@
-package org.eclipse.cdt.make.ui.actions;
+package org.eclipse.cdt.make.ui.dialogs;
import java.util.HashMap;
import org.eclipse.cdt.make.core.IMakeBuilderInfo;
+import org.eclipse.cdt.make.core.IMakeTarget;
import org.eclipse.cdt.make.core.IMakeTargetManager;
import org.eclipse.cdt.make.core.MakeCorePlugin;
import org.eclipse.cdt.make.internal.ui.MakeUIPlugin;
@@ -26,6 +27,13 @@ import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
public class BuildTargetDialog extends TitleAreaDialog {
+ private IMakeTarget fSelection;
+ public static int OPEN_MODE_BUILD = 1;
+ public static int OPEN_MODE_CREATE_NEW = 2;
+ public static int OPEN_MODE_RENAME = 2;
+
+ private int openMode;
+
private static final String PREFIX = "SettingsBlock"; //$NON-NLS-1$
private static final String MAKE_SETTING_GROUP = PREFIX + ".makeSetting.group_label"; //$NON-NLS-1$
@@ -43,9 +51,9 @@ public class BuildTargetDialog extends TitleAreaDialog {
Text buildCommand;
Button defButton;
- IMakeBuilderInfo fBuildInfo;
+ IMakeBuilderInfo fBuildInfo;
IMakeTargetManager fTargetManager;
-
+
/**
* @param parentShell
*/
@@ -53,7 +61,7 @@ public class BuildTargetDialog extends TitleAreaDialog {
super(parentShell);
fTargetManager = MakeCorePlugin.getDefault().getTargetManager();
String[] id = fTargetManager.getTargetBuilders(container.getProject());
- if ( id != null) {
+ if (id != null) {
fBuildInfo = MakeCorePlugin.createBuildInfo(new HashMap(), id[0]);
}
}
@@ -63,13 +71,13 @@ public class BuildTargetDialog extends TitleAreaDialog {
*/
protected Control createDialogArea(Composite parent) {
Control control = super.createDialogArea(parent);
-
+
createSettingControls(parent);
createBuildCmdControls(parent);
-
+
return control;
}
-
+
protected void createSettingControls(Composite parent) {
String[][] radios = new String[][] { { MakeUIPlugin.getResourceString(MAKE_SETTING_STOP_ERROR), STOP_ARG }, {
MakeUIPlugin.getResourceString(MAKE_SETTING_KEEP_GOING), KEEP_ARG }
@@ -137,4 +145,16 @@ public class BuildTargetDialog extends TitleAreaDialog {
defButton.setSelection(fBuildInfo.isDefaultBuildCmd());
}
+ public void setOpenMode(int mode) {
+ openMode = mode;
+ }
+
+ public void setSelectedTarget(IMakeTarget target) {
+ fSelection = target;
+ }
+
+ public IMakeTarget getSelectedTarget() {
+ return null;
+ }
+
}
diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/views/AddTargetAction.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/views/AddTargetAction.java
index ca40fc7967e..db72b23bc80 100644
--- a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/views/AddTargetAction.java
+++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/views/AddTargetAction.java
@@ -5,26 +5,51 @@ package org.eclipse.cdt.make.ui.views;
* All Rights Reserved.
*/
+import java.util.List;
+
import org.eclipse.cdt.make.internal.ui.MakeUIImages;
+import org.eclipse.cdt.make.ui.dialogs.BuildTargetDialog;
+import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IResource;
+import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.actions.SelectionListenerAction;
-
-public class AddTargetAction extends SelectionListenerAction {
+public class AddTargetAction extends SelectionListenerAction {
Shell shell;
IResource resource;
- public AddTargetAction (Shell shell) {
+ public AddTargetAction(Shell shell) {
super("Add Build Target");
this.shell = shell;
-
+
setToolTipText("Add Build Target");
MakeUIImages.setImageDescriptors(this, "tool16", MakeUIImages.IMG_TOOLS_MAKE_TARGET_ADD);
}
public void run() {
-
+ if (canAdd()) {
+ BuildTargetDialog dialog = new BuildTargetDialog(shell, (IContainer) getStructuredSelection().getFirstElement());
+ dialog.setOpenMode(BuildTargetDialog.OPEN_MODE_CREATE_NEW);
+ dialog.open();
+ }
+
}
+
+ protected boolean updateSelection(IStructuredSelection selection) {
+ return super.updateSelection(selection) && canAdd();
+ }
+
+ private boolean canAdd() {
+ List elements = getStructuredSelection().toList();
+ if (elements.size() > 1 || elements.size() < 1) {
+ return false;
+ }
+ if (elements.get(0) instanceof IContainer) {
+ return true;
+ }
+ return false;
+ }
+
}
diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/views/DeleteTargetAction.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/views/DeleteTargetAction.java
index ddb2443da32..cd9de094fcd 100644
--- a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/views/DeleteTargetAction.java
+++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/views/DeleteTargetAction.java
@@ -5,26 +5,83 @@ package org.eclipse.cdt.make.ui.views;
* All Rights Reserved.
*/
+import java.text.MessageFormat;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.cdt.make.core.IMakeTarget;
import org.eclipse.cdt.make.internal.ui.MakeUIImages;
import org.eclipse.core.resources.IResource;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.actions.SelectionListenerAction;
-
-public class DeleteTargetAction extends SelectionListenerAction {
+public class DeleteTargetAction extends SelectionListenerAction {
Shell shell;
IResource resource;
- public DeleteTargetAction (Shell shell) {
+ public DeleteTargetAction(Shell shell) {
super("Delete Build Target");
this.shell = shell;
-
+
setToolTipText("Delete Build Target");
MakeUIImages.setImageDescriptors(this, "tool16", MakeUIImages.IMG_TOOLS_MAKE_TARGET_DELETE);
}
- public void run() {
-
+ /**
+ * Asks the user to confirm a delete operation.
+ *
+ * @return true
if the user says to go ahead, and false
+ * if the deletion should be abandoned
+ */
+ boolean confirmDelete() {
+ List targets = getTargetsToDelete();
+ String title;
+ String msg;
+ if (targets.size() == 1) {
+ title = "Confirm Target Deletion";
+ IMakeTarget target = (IMakeTarget) targets.get(0);
+ msg = MessageFormat.format("Are you sure you want to delete ''{0}''?", new Object[] { target.getName()});
+ } else {
+ title = "Confirm Multiple Target Deletion";
+ msg = MessageFormat.format("Are you sure you want to delete these {0} targets?", new Object[] { new Integer(targets.size())});
+ }
+ return MessageDialog.openQuestion(shell, title, msg);
}
+
+ public void run() {
+ if (canDelete() && confirmDelete() == false)
+ return;
+ }
+
+ protected boolean updateSelection(IStructuredSelection selection) {
+ return super.updateSelection(selection) && canDelete();
+ }
+
+ /**
+ * @return
+ */
+ private List getTargetsToDelete() {
+ return getStructuredSelection().toList();
+ }
+
+ /**
+ * @return
+ */
+ private boolean canDelete() {
+ List elements = getStructuredSelection().toList();
+ if (elements.size() > 0) {
+ Iterator iterator = elements.iterator();
+ while (iterator.hasNext()) {
+ if (!(iterator.next() instanceof IMakeTarget)) {
+ return false;
+ }
+ }
+ return true;
+ }
+ return false;
+ }
+
}
diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/views/EditTargetAction.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/views/EditTargetAction.java
new file mode 100644
index 00000000000..9695fc08e56
--- /dev/null
+++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/views/EditTargetAction.java
@@ -0,0 +1,55 @@
+package org.eclipse.cdt.make.ui.views;
+
+/*
+ * (c) Copyright QNX Software Systems Ltd. 2002.
+ * All Rights Reserved.
+ */
+
+import java.util.List;
+
+import org.eclipse.cdt.make.core.IMakeTarget;
+import org.eclipse.cdt.make.internal.ui.MakeUIImages;
+import org.eclipse.cdt.make.ui.dialogs.BuildTargetDialog;
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.actions.SelectionListenerAction;
+
+public class EditTargetAction extends SelectionListenerAction {
+
+ Shell shell;
+ IResource resource;
+
+ public EditTargetAction(Shell shell) {
+ super("Edit Build Target");
+ this.shell = shell;
+
+ setToolTipText("Edit Build Target");
+ MakeUIImages.setImageDescriptors(this, "tool16", MakeUIImages.IMG_TOOLS_MAKE_TARGET_EDIT);
+ }
+
+ public void run() {
+ if (canRename()) {
+ BuildTargetDialog dialog = new BuildTargetDialog(shell, (IContainer) getStructuredSelection().getFirstElement());
+ dialog.setOpenMode(BuildTargetDialog.OPEN_MODE_CREATE_NEW);
+ dialog.setSelectedTarget((IMakeTarget) getStructuredSelection().getFirstElement());
+ dialog.open();
+ }
+ }
+
+ protected boolean updateSelection(IStructuredSelection selection) {
+ return super.updateSelection(selection) && canRename();
+ }
+
+ private boolean canRename() {
+ List elements = getStructuredSelection().toList();
+ if (elements.size() > 1 || elements.size() < 1) {
+ return false;
+ }
+ if (elements.get(0) instanceof IMakeTarget) {
+ return true;
+ }
+ return false;
+ }
+}
diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/views/MakeView.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/views/MakeView.java
index 1f4f131967d..a5d480de356 100644
--- a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/views/MakeView.java
+++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/views/MakeView.java
@@ -30,7 +30,7 @@ import org.eclipse.ui.part.ViewPart;
public class MakeView extends ViewPart {
private BuildTargetAction buildTargetAction;
- private RenameTargetAction renameTargetAction;
+ private EditTargetAction editTargetAction;
private DeleteTargetAction deleteTargetAction;
AddTargetAction addTargetAction;
TreeViewer viewer;
@@ -90,7 +90,7 @@ public class MakeView extends ViewPart {
buildTargetAction = new BuildTargetAction(viewer.getControl().getShell());
addTargetAction = new AddTargetAction(viewer.getControl().getShell());
deleteTargetAction = new DeleteTargetAction(viewer.getControl().getShell());
- renameTargetAction = new RenameTargetAction(viewer.getControl().getShell());
+ editTargetAction = new EditTargetAction(viewer.getControl().getShell());
}
private void contributeToActionBars() {
IActionBars bars = getViewSite().getActionBars();
@@ -126,7 +126,7 @@ public class MakeView extends ViewPart {
manager.add(buildTargetAction);
manager.add(addTargetAction);
manager.add(deleteTargetAction);
- manager.add(renameTargetAction);
+ manager.add(editTargetAction);
manager.add(new Separator());
drillDownAdapter.addNavigationActions(manager);
@@ -150,6 +150,6 @@ public class MakeView extends ViewPart {
void updateActions(IStructuredSelection sel) {
buildTargetAction.selectionChanged(sel);
deleteTargetAction.selectionChanged(sel);
- renameTargetAction.selectionChanged(sel);
+ editTargetAction.selectionChanged(sel);
}
}
diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/views/RenameTargetAction.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/views/RenameTargetAction.java
deleted file mode 100644
index 6f15c7f7d81..00000000000
--- a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/views/RenameTargetAction.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package org.eclipse.cdt.make.ui.views;
-
-/*
- * (c) Copyright QNX Software Systems Ltd. 2002.
- * All Rights Reserved.
- */
-
-import org.eclipse.cdt.make.internal.ui.MakeUIImages;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.actions.SelectionListenerAction;
-
-
-public class RenameTargetAction extends SelectionListenerAction {
-
- Shell shell;
- IResource resource;
-
- public RenameTargetAction (Shell shell) {
- super("Rename Build Target");
- this.shell = shell;
-
- setToolTipText("Rename Build Target");
- MakeUIImages.setImageDescriptors(this, "tool16", MakeUIImages.IMG_TOOLS_MAKE_TARGET_RENAME);
- }
-
- public void run() {
-
- }
-}