Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJared Burns2002-10-03 20:59:24 +0000
committerJared Burns2002-10-03 20:59:24 +0000
commit237c071f1b18b03c214979bcb102f0e4c654f6a6 (patch)
treeba4c8934bfe59b5f88ba8d9f24b21a2fd36c13c2
parent9392e6aea07b11ceb4df20763a5360d86260f624 (diff)
downloadeclipse.platform.debug-SA_NEW_UI.tar.gz
eclipse.platform.debug-SA_NEW_UI.tar.xz
eclipse.platform.debug-SA_NEW_UI.zip
Implemented rename action changed workspace_loc references to resource_locSA_NEW_UI
-rw-r--r--org.eclipse.ui.externaltools/Ant Tools Support/org/eclipse/ui/externaltools/internal/ant/dialog/AntExternalToolNewWizard.java2
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/group/ExternalToolMainGroup.java2
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/registry/ExternalToolRegistry.java11
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/view/RenameExternalToolAction.java40
4 files changed, 46 insertions, 9 deletions
diff --git a/org.eclipse.ui.externaltools/Ant Tools Support/org/eclipse/ui/externaltools/internal/ant/dialog/AntExternalToolNewWizard.java b/org.eclipse.ui.externaltools/Ant Tools Support/org/eclipse/ui/externaltools/internal/ant/dialog/AntExternalToolNewWizard.java
index 8995794a3..593283944 100644
--- a/org.eclipse.ui.externaltools/Ant Tools Support/org/eclipse/ui/externaltools/internal/ant/dialog/AntExternalToolNewWizard.java
+++ b/org.eclipse.ui.externaltools/Ant Tools Support/org/eclipse/ui/externaltools/internal/ant/dialog/AntExternalToolNewWizard.java
@@ -114,7 +114,7 @@ public class AntExternalToolNewWizard extends ExternalToolNewWizard {
String fileLocation= null;
if (xmlFile != null) {
StringBuffer buffer = new StringBuffer();
- ToolUtil.buildVariableTag(IExternalToolConstants.VAR_WORKSPACE_LOC, xmlFile.getFullPath().toString(), buffer);
+ ToolUtil.buildVariableTag(IExternalToolConstants.VAR_RESOURCE_LOC, xmlFile.getFullPath().toString(), buffer);
fileLocation= buffer.toString();
String baseName= xmlFile.getName() + " [" + xmlFile.getProject().getName() + "]" ;
String name= baseName;
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/group/ExternalToolMainGroup.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/group/ExternalToolMainGroup.java
index 06777bb4d..6cd594404 100644
--- a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/group/ExternalToolMainGroup.java
+++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/group/ExternalToolMainGroup.java
@@ -210,7 +210,7 @@ public class ExternalToolMainGroup extends ExternalToolGroup {
containerDialog.open();
Object[] resource = containerDialog.getResult();
if (resource != null && resource.length > 0) {
- text= ToolUtil.buildVariableTag(IExternalToolConstants.VAR_WORKSPACE_LOC, ((IPath)resource[0]).toString());
+ text= ToolUtil.buildVariableTag(IExternalToolConstants.VAR_RESOURCE_LOC, ((IPath)resource[0]).toString());
}
field= workDirectoryField;
}
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/registry/ExternalToolRegistry.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/registry/ExternalToolRegistry.java
index 99bace7e9..bdd290344 100644
--- a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/registry/ExternalToolRegistry.java
+++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/registry/ExternalToolRegistry.java
@@ -371,15 +371,14 @@ public class ExternalToolRegistry {
String msg = MessageFormat.format("The file for tool {0} could not be found", new Object[] {tool.getName()});
return ExternalToolsPlugin.newErrorStatus(msg, null);
}
- IFile file= ResourcesPlugin.getWorkspace().getRoot().getFile(filename);
+ File file= new File(filename.toOSString());
IPath newPath= generateToolFilename(newName);
- try {
- file.move(newPath, false, true, null);
- } catch (CoreException exception) {
- String msg = MessageFormat.format("An exception occurred creating file {0}", new Object[] {newPath.toString()});
+ if (!file.renameTo(new File(newPath.toOSString()))) {
+ String msg = MessageFormat.format("Failed to create new file for external tool: {0}", new Object[] {newPath.toString()});
return ExternalToolsPlugin.newErrorStatus(msg, null);
}
- filenames.put(tool.getName().toLowerCase(), newPath);
+ filenames.remove(tool.getName().toLowerCase());
+ filenames.put(newName.toLowerCase(), newPath);
return ExternalToolsPlugin.OK_STATUS;
}
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/view/RenameExternalToolAction.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/view/RenameExternalToolAction.java
index 9cdccf5ea..be0cdf4db 100644
--- a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/view/RenameExternalToolAction.java
+++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/view/RenameExternalToolAction.java
@@ -9,12 +9,23 @@ http://www.eclipse.org/legal/cpl-v10.html
Contributors:
**********************************************************************/
+import java.text.MessageFormat;
+
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.action.Action;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.dialogs.IInputValidator;
+import org.eclipse.jface.dialogs.InputDialog;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.actions.TextActionHandler;
import org.eclipse.ui.externaltools.internal.model.ExternalToolsPlugin;
import org.eclipse.ui.externaltools.internal.model.IHelpContextIds;
import org.eclipse.ui.externaltools.internal.model.ToolMessages;
import org.eclipse.ui.externaltools.model.ExternalTool;
+import org.eclipse.ui.externaltools.model.ExternalToolStorage;
import org.eclipse.ui.help.WorkbenchHelp;
/**
@@ -47,11 +58,38 @@ public class RenameExternalToolAction extends Action {
return selectedTool;
}
+ private Shell getShell() {
+ return Display.getCurrent().getActiveShell();
+ }
+
/* (non-Javadoc)
* Method declared on Action.
*/
public void run() {
- org.eclipse.jface.dialogs.MessageDialog.openInformation(view.getSite().getShell(), "Action", "This action is not yet implemented");
+ if (selectedTool != null) {
+ InputDialog dialog= new InputDialog(getShell(), "Rename Tool", "Enter a new name for the tool", selectedTool.getName(), new IInputValidator() {
+ public String isValid(String newText) {
+ if (newText.equals(selectedTool.getName())) {
+ return null;
+ } else if (ExternalToolsPlugin.getDefault().getToolRegistry(getShell()).hasToolNamed(newText)) {
+ return "An external tool of that name already exists";
+ }
+ return ExternalTool.validateToolName(newText);
+ }
+ });
+ if (dialog.open() == Dialog.OK) {
+ String newName= dialog.getValue();
+ if (newName.equals(selectedTool.getName())) {
+ return;
+ }
+ try {
+ selectedTool.rename(newName);
+ ExternalToolStorage.saveTool(selectedTool, getShell());
+ } catch (CoreException exception) {
+ ErrorDialog.openError(getShell(), "External Tool Error", MessageFormat.format("An exception occurred while renaming {0}", new String[] {selectedTool.getName()}), exception.getStatus());
+ }
+ }
+ }
}
/**

Back to the top