Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.eclipse.ui.externaltools/Ant Runner Support/org/eclipse/ui/externaltools/internal/ant/logger/AntBuildLogger.java (renamed from org.eclipse.ui.externaltools/Ant Builder/org/eclipse/ui/externaltools/internal/ui/ant/AntBuildLogger.java)2
-rw-r--r--org.eclipse.ui.externaltools/Ant Runner Support/org/eclipse/ui/externaltools/internal/ant/logger/NullBuildLogger.java (renamed from org.eclipse.ui.externaltools/Ant Builder/org/eclipse/ui/externaltools/internal/ui/ant/NullBuildLogger.java)4
-rw-r--r--org.eclipse.ui.externaltools/Ant Tools Support/org/eclipse/ui/externaltools/internal/ant/dialog/AddTaskDialog.java207
-rw-r--r--org.eclipse.ui.externaltools/Ant Tools Support/org/eclipse/ui/externaltools/internal/ant/dialog/AntClasspathPage.java200
-rw-r--r--org.eclipse.ui.externaltools/Ant Tools Support/org/eclipse/ui/externaltools/internal/ant/dialog/AntExternalToolNewWizard.java134
-rw-r--r--org.eclipse.ui.externaltools/Ant Tools Support/org/eclipse/ui/externaltools/internal/ant/dialog/AntOptionGroupPropertyPage.java29
-rw-r--r--org.eclipse.ui.externaltools/Ant Tools Support/org/eclipse/ui/externaltools/internal/ant/dialog/AntPage.java258
-rw-r--r--org.eclipse.ui.externaltools/Ant Tools Support/org/eclipse/ui/externaltools/internal/ant/dialog/AntPreferencePage.java133
-rw-r--r--org.eclipse.ui.externaltools/Ant Tools Support/org/eclipse/ui/externaltools/internal/ant/dialog/AntTargetsGroup.java733
-rw-r--r--org.eclipse.ui.externaltools/Ant Tools Support/org/eclipse/ui/externaltools/internal/ant/dialog/AntTargetsGroupPropertyPage.java42
-rw-r--r--org.eclipse.ui.externaltools/Ant Tools Support/org/eclipse/ui/externaltools/internal/ant/dialog/AntTargetsGroupWizardPage.java46
-rw-r--r--org.eclipse.ui.externaltools/Ant Tools Support/org/eclipse/ui/externaltools/internal/ant/dialog/AntTasksPage.java184
-rw-r--r--org.eclipse.ui.externaltools/Ant Tools Support/org/eclipse/ui/externaltools/internal/ant/dialog/AntTypesPage.java189
-rw-r--r--org.eclipse.ui.externaltools/Ant Tools Support/org/eclipse/ui/externaltools/internal/ant/model/AntFileRunner.java102
-rw-r--r--org.eclipse.ui.externaltools/Ant Tools Support/org/eclipse/ui/externaltools/internal/ant/model/AntUtil.java116
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/action/RunExternalToolAction.java304
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/action/RunWithExternalToolAction.java39
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/dialog/ExternalToolGroupPropertyPage.java160
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/dialog/ExternalToolGroupWizardPage.java102
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/dialog/ExternalToolMainGroupPropertyPage.java26
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/dialog/ExternalToolNewWizard.java280
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/dialog/ExternalToolOptionGroupPropertyPage.java26
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/dialog/ExternalToolRefreshGroupPropertyPage.java26
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/group/ExternalToolGroup.java146
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/group/ExternalToolMainGroup.java640
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/group/ExternalToolOptionGroup.java687
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/group/ExternalToolRefreshGroup.java279
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/group/IExternalToolGroup.java72
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/group/IGroupDialogPage.java62
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/dialog/ExternalToolVariableForm.java207
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/menu/ExternalToolMenuDelegate.java212
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/menu/FavoritesManager.java173
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/model/DefaultRunnerContext.java263
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/model/ExternalToolBuilder.java74
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/model/ExternalToolsPlugin.java172
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/model/IHelpContextIds.java58
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/model/IPreferenceConstants.java27
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/model/ToolMessages.java61
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/model/messages.properties364
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/registry/ArgumentVariable.java65
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/registry/ArgumentVariableRegistry.java50
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/registry/ExternalToolMigration.java252
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/registry/ExternalToolRegistry.java692
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/registry/ExternalToolType.java155
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/registry/ExternalToolTypeRegistry.java156
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/registry/ExternalToolVariable.java154
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/registry/ExternalToolVariableRegistry.java135
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/registry/PathLocationVariable.java62
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/registry/PathLocationVariableRegistry.java49
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/registry/RefreshScopeVariable.java62
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/registry/RefreshScopeVariableRegistry.java50
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/AntAction.java166
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/AntLaunchWizard.java176
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/AntLaunchWizardPage.java246
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/AntRunActionDelegate.java56
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/AntTargetContentProvider.java45
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/AntTargetLabelProvider.java64
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/BuilderPropertyPage.java542
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/LogConsoleDocument.java334
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/LogConsoleView.java1
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/LogTreeContentProvider.java67
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/LogTreeLabelProvider.java72
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/OutputStructureElement.java102
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/ToolsPreferencePage.java1
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/view/DeleteExternalToolAction.java78
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/view/DuplicateExternalToolAction.java63
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/view/EditExternalToolPropertiesAction.java64
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/view/ExternalToolActionGroup.java179
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/view/ExternalToolContentProvider.java178
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/view/ExternalToolLabelProvider.java108
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/view/ExternalToolView.java333
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/view/NewExternalToolAction.java48
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/view/RefreshViewAction.java49
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/view/RenameExternalToolAction.java71
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/model/ExternalTool.java543
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/model/ExternalToolStorage.java153
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/model/IExternalToolConstants.java210
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/model/IExternalToolFilter.java34
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/model/IExternalToolRunner.java38
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/model/IRunnerContext.java67
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/model/IRunnerLog.java43
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/model/IStorageListener.java50
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/model/ToolUtil.java450
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/variable/ExpandVariableContext.java101
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/variable/IVariableComponent.java76
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/variable/IVariableLocationExpander.java39
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/variable/IVariableResourceExpander.java38
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/variable/IVariableTextExpander.java35
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/variable/ResourceComponent.java260
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/variable/ResourceContainerExpander.java40
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/variable/ResourceExpander.java89
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/variable/ResourceProjectExpander.java47
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/variable/SpecificFileResourceComponent.java71
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/variable/SpecificFolderResourceComponent.java109
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/variable/WorkingSetExpander.java56
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/variable/WorkspaceExpander.java36
-rw-r--r--org.eclipse.ui.externaltools/Program Tools Support/org/eclipse/ui/externaltools/internal/program/dialog/ProgramExternalToolNewWizard.java44
-rw-r--r--org.eclipse.ui.externaltools/Program Tools Support/org/eclipse/ui/externaltools/internal/program/model/ProgramRunner.java174
-rw-r--r--org.eclipse.ui.externaltools/icons/full/clcl16/copy_tool.gifbin0 -> 167 bytes
-rw-r--r--org.eclipse.ui.externaltools/icons/full/clcl16/del_tool.gifbin0 -> 143 bytes
-rw-r--r--org.eclipse.ui.externaltools/icons/full/clcl16/new_tool.gifbin0 -> 125 bytes
-rw-r--r--org.eclipse.ui.externaltools/icons/full/clcl16/paste_tool.gifbin0 -> 245 bytes
-rw-r--r--org.eclipse.ui.externaltools/icons/full/clcl16/prop_tool.gifbin0 -> 116 bytes
-rw-r--r--org.eclipse.ui.externaltools/icons/full/clcl16/refresh.gifbin0 -> 182 bytes
-rw-r--r--org.eclipse.ui.externaltools/icons/full/clcl16/rename_tool.gifbin0 -> 163 bytes
-rw-r--r--org.eclipse.ui.externaltools/icons/full/clcl16/run_tool.gifbin0 -> 128 bytes
-rw-r--r--org.eclipse.ui.externaltools/icons/full/clcl16/runwith_tool.gifbin0 -> 128 bytes
-rw-r--r--org.eclipse.ui.externaltools/icons/full/cview16/external_tools.gifbin0 -> 240 bytes
-rw-r--r--org.eclipse.ui.externaltools/icons/full/dlcl16/copy_tool.gifbin0 -> 84 bytes
-rw-r--r--org.eclipse.ui.externaltools/icons/full/dlcl16/del_tool.gifbin0 -> 91 bytes
-rw-r--r--org.eclipse.ui.externaltools/icons/full/dlcl16/new_tool.gifbin0 -> 96 bytes
-rw-r--r--org.eclipse.ui.externaltools/icons/full/dlcl16/paste_tool.gifbin0 -> 100 bytes
-rw-r--r--org.eclipse.ui.externaltools/icons/full/dlcl16/prop_tool.gifbin0 -> 116 bytes
-rw-r--r--org.eclipse.ui.externaltools/icons/full/dlcl16/refresh.gifbin0 -> 104 bytes
-rw-r--r--org.eclipse.ui.externaltools/icons/full/dlcl16/rename_tool.gifbin0 -> 90 bytes
-rw-r--r--org.eclipse.ui.externaltools/icons/full/dlcl16/run_tool.gifbin0 -> 79 bytes
-rw-r--r--org.eclipse.ui.externaltools/icons/full/dlcl16/runwith_tool.gifbin0 -> 79 bytes
-rw-r--r--org.eclipse.ui.externaltools/icons/full/elcl16/copy_tool.gifbin0 -> 160 bytes
-rw-r--r--org.eclipse.ui.externaltools/icons/full/elcl16/del_tool.gifbin0 -> 110 bytes
-rw-r--r--org.eclipse.ui.externaltools/icons/full/elcl16/new_tool.gifbin0 -> 127 bytes
-rw-r--r--org.eclipse.ui.externaltools/icons/full/elcl16/paste_tool.gifbin0 -> 139 bytes
-rw-r--r--org.eclipse.ui.externaltools/icons/full/elcl16/prop_tool.gifbin0 -> 116 bytes
-rw-r--r--org.eclipse.ui.externaltools/icons/full/elcl16/refresh.gifbin0 -> 144 bytes
-rw-r--r--org.eclipse.ui.externaltools/icons/full/elcl16/rename_tool.gifbin0 -> 158 bytes
-rw-r--r--org.eclipse.ui.externaltools/icons/full/elcl16/run_tool.gifbin0 -> 97 bytes
-rw-r--r--org.eclipse.ui.externaltools/icons/full/elcl16/runwith_tool.gifbin0 -> 97 bytes
-rw-r--r--org.eclipse.ui.externaltools/icons/full/eview16/external_tools.gifbin0 -> 175 bytes
-rw-r--r--org.eclipse.ui.externaltools/icons/full/obj16/ttype_ant.gifbin0 -> 906 bytes
-rw-r--r--org.eclipse.ui.externaltools/icons/full/obj16/ttype_program.gifbin0 -> 240 bytes
-rw-r--r--org.eclipse.ui.externaltools/icons/full/wizban/program_wiz.gifbin0 -> 2601 bytes
130 files changed, 14564 insertions, 3 deletions
diff --git a/org.eclipse.ui.externaltools/Ant Builder/org/eclipse/ui/externaltools/internal/ui/ant/AntBuildLogger.java b/org.eclipse.ui.externaltools/Ant Runner Support/org/eclipse/ui/externaltools/internal/ant/logger/AntBuildLogger.java
index 3764cafc0..d7e869486 100644
--- a/org.eclipse.ui.externaltools/Ant Builder/org/eclipse/ui/externaltools/internal/ui/ant/AntBuildLogger.java
+++ b/org.eclipse.ui.externaltools/Ant Runner Support/org/eclipse/ui/externaltools/internal/ant/logger/AntBuildLogger.java
@@ -1,4 +1,4 @@
-package org.eclipse.ui.externaltools.internal.ui.ant;
+package org.eclipse.ui.externaltools.internal.ant.logger;
/**********************************************************************
Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
diff --git a/org.eclipse.ui.externaltools/Ant Builder/org/eclipse/ui/externaltools/internal/ui/ant/NullBuildLogger.java b/org.eclipse.ui.externaltools/Ant Runner Support/org/eclipse/ui/externaltools/internal/ant/logger/NullBuildLogger.java
index 13a2c07e2..4b70dbf59 100644
--- a/org.eclipse.ui.externaltools/Ant Builder/org/eclipse/ui/externaltools/internal/ui/ant/NullBuildLogger.java
+++ b/org.eclipse.ui.externaltools/Ant Runner Support/org/eclipse/ui/externaltools/internal/ant/logger/NullBuildLogger.java
@@ -1,4 +1,4 @@
-package org.eclipse.ui.externaltools.internal.ui.ant;
+package org.eclipse.ui.externaltools.internal.ant.logger;
/**********************************************************************
Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
@@ -13,7 +13,7 @@ import org.apache.tools.ant.BuildEvent;
import org.apache.tools.ant.BuildLogger;
import org.apache.tools.ant.Project;
import org.eclipse.ant.core.AntSecurityException;
-import org.eclipse.ui.externaltools.internal.core.ToolMessages;
+import org.eclipse.ui.externaltools.internal.model.ToolMessages;
import org.eclipse.ui.externaltools.internal.ui.LogConsoleDocument;
public class NullBuildLogger implements BuildLogger {
diff --git a/org.eclipse.ui.externaltools/Ant Tools Support/org/eclipse/ui/externaltools/internal/ant/dialog/AddTaskDialog.java b/org.eclipse.ui.externaltools/Ant Tools Support/org/eclipse/ui/externaltools/internal/ant/dialog/AddTaskDialog.java
new file mode 100644
index 000000000..3fb72555f
--- /dev/null
+++ b/org.eclipse.ui.externaltools/Ant Tools Support/org/eclipse/ui/externaltools/internal/ant/dialog/AddTaskDialog.java
@@ -0,0 +1,207 @@
+package org.eclipse.ui.externaltools.internal.ant.dialog;
+
+/**********************************************************************
+Copyright (c) 2002 IBM Corp. and others. All rights reserved.
+This file is 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:
+**********************************************************************/
+
+import java.net.URL;
+
+import org.eclipse.ant.core.AntCorePlugin;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.externaltools.internal.model.IHelpContextIds;
+import org.eclipse.ui.externaltools.internal.model.ToolMessages;
+import org.eclipse.ui.help.WorkbenchHelp;
+
+/**
+ * Dialog to prompt the user to add a custom Ant task or type.
+ */
+public class AddTaskDialog extends Dialog {
+ private String title;
+ private String description;
+
+ //task/type attributes
+ private String taskName;
+ private String className;
+ private URL library;
+
+ //widgets
+ private Button okButton;
+ private Text nameField;
+ private Text classField;
+ private Combo libraryField;
+
+ private URL[] libraryUrls;
+
+ /**
+ * Creates a new dialog with the given shell and title.
+ */
+ protected AddTaskDialog(Shell parent, String title, String description) {
+ super(parent);
+ this.title = title;
+ this.description = description;
+ }
+
+ /* (non-Javadoc)
+ * Method declared on Window.
+ */
+ protected void configureShell(Shell newShell) {
+ super.configureShell(newShell);
+ newShell.setText(title);
+ WorkbenchHelp.setHelp(newShell, IHelpContextIds.ADD_TASK_DIALOG);
+ }
+
+ /* (non-Javadoc)
+ * Method declared on Dialog.
+ */
+ protected void createButtonsForButtonBar(Composite parent) {
+ okButton = createButton(
+ parent,
+ IDialogConstants.OK_ID,
+ IDialogConstants.OK_LABEL,
+ true);
+ createButton(
+ parent,
+ IDialogConstants.CANCEL_ID,
+ IDialogConstants.CANCEL_LABEL,
+ false);
+ updateEnablement();
+ }
+
+ /* (non-Javadoc)
+ * Method declared on Dialog.
+ */
+ protected Control createDialogArea(Composite parent) {
+ Composite dialogArea = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 2;
+ layout.marginHeight = 10;
+ layout.marginWidth = 10;
+ dialogArea.setLayout(layout);
+
+ Label label = new Label(dialogArea, SWT.NONE);
+ label.setText(description);
+ GridData data = new GridData(GridData.FILL_HORIZONTAL);
+ data.horizontalSpan = 2;
+ label.setLayoutData(data);
+
+ label = new Label(dialogArea, SWT.NONE);
+ label.setText(ToolMessages.getString("AddTaskDialog.name")); //$NON-NLS-1$;
+ nameField = new Text(dialogArea, SWT.BORDER);
+ data = new GridData(GridData.FILL_HORIZONTAL);
+ data.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH;
+ nameField.setLayoutData(data);
+ nameField.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ updateEnablement();
+ }
+ });
+
+ label = new Label(dialogArea, SWT.NONE);
+ label.setText(ToolMessages.getString("AddTaskDialog.class")); //$NON-NLS-1$;
+ classField = new Text(dialogArea, SWT.BORDER);
+ data = new GridData(GridData.FILL_HORIZONTAL);
+ data.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH;
+ classField.setLayoutData(data);
+ classField.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ updateEnablement();
+ }
+ });
+
+ label = new Label(dialogArea, SWT.NONE);
+ label.setText(ToolMessages.getString("AddTaskDialog.library")); //$NON-NLS-1$;
+ libraryField = new Combo(dialogArea, SWT.READ_ONLY | SWT.BORDER);
+ data = new GridData(GridData.FILL_HORIZONTAL);
+ data.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH;
+ libraryField.setLayoutData(data);
+ libraryField.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ updateEnablement();
+ }
+ });
+
+ //populate library combo and select input library
+ libraryUrls = AntCorePlugin.getPlugin().getPreferences().getCustomURLs();
+ int selection = 0;
+ for (int i = 0; i < libraryUrls.length; i++) {
+ libraryField.add(libraryUrls[i].getFile());
+ if (libraryUrls[i].equals(library))
+ selection = i;
+ }
+
+ //intialize fields
+ if (taskName != null)
+ nameField.setText(taskName);
+ if (className != null)
+ classField.setText(className);
+ if (libraryUrls.length >= 0)
+ libraryField.select(selection);
+
+ return dialogArea;
+ }
+
+ public String getClassName() {
+ return className;
+ }
+
+ public URL getLibrary() {
+ return library;
+ }
+
+ public String getTaskName() {
+ return taskName;
+ }
+
+ /* (non-Javadoc)
+ * Method declared on Dialog.
+ */
+ protected void okPressed() {
+ className = classField.getText();
+ taskName = nameField.getText();
+ int selection = libraryField.getSelectionIndex();
+ if (selection >= 0)
+ library = libraryUrls[selection];
+ super.okPressed();
+ }
+
+ public void setClassName(String className) {
+ this.className = className;
+ }
+
+ public void setLibrary(URL library) {
+ this.library = library;
+ }
+
+ public void setTaskName(String taskName) {
+ this.taskName = taskName;
+ }
+
+ private void updateEnablement() {
+ if (okButton != null) {
+ okButton.setEnabled(
+ nameField.getText().length() > 0
+ && classField.getText().length() > 0
+ && libraryField.getSelectionIndex() >= 0);
+ }
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.ui.externaltools/Ant Tools Support/org/eclipse/ui/externaltools/internal/ant/dialog/AntClasspathPage.java b/org.eclipse.ui.externaltools/Ant Tools Support/org/eclipse/ui/externaltools/internal/ant/dialog/AntClasspathPage.java
new file mode 100644
index 000000000..aee26999e
--- /dev/null
+++ b/org.eclipse.ui.externaltools/Ant Tools Support/org/eclipse/ui/externaltools/internal/ant/dialog/AntClasspathPage.java
@@ -0,0 +1,200 @@
+package org.eclipse.ui.externaltools.internal.ant.dialog;
+
+/**********************************************************************
+Copyright (c) 2002 IBM Corp. and others. All rights reserved.
+This file is 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:
+**********************************************************************/
+
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.DirectoryDialog;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.TabFolder;
+import org.eclipse.swt.widgets.TabItem;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.externaltools.internal.model.ExternalToolsPlugin;
+import org.eclipse.ui.externaltools.internal.model.ToolMessages;
+
+/**
+ * Sub-page that allows the user to enter custom classpaths
+ * to be used when running Ant build files.
+ */
+public class AntClasspathPage extends AntPage {
+ private static final int ADD_JAR_BUTTON = IDialogConstants.CLIENT_ID + 1;
+ private static final int ADD_FOLDER_BUTTON = IDialogConstants.CLIENT_ID + 2;
+ private static final int REMOVE_BUTTON = IDialogConstants.CLIENT_ID + 3;
+
+ private final AntClasspathLabelProvider labelProvider = new AntClasspathLabelProvider();
+
+ /**
+ * Creates an instance.
+ */
+ public AntClasspathPage(AntPreferencePage preferencePage) {
+ super(preferencePage);
+ }
+
+ /* (non-Javadoc)
+ * Method declared on AntPage.
+ */
+ protected void addButtonsToButtonGroup(Composite parent) {
+ createButton(parent, "AntClasspathPage.addJarButtonTitle", ADD_JAR_BUTTON); //$NON-NLS-1$;
+ createButton(parent, "AntClasspathPage.addFolderButtonTitle", ADD_FOLDER_BUTTON); //$NON-NLS-1$;
+ createSeparator(parent);
+ createButton(parent, "AntClasspathPage.removeButtonTitle", REMOVE_BUTTON); //$NON-NLS-1$;
+ }
+
+ /**
+ * Allows the user to enter a folder as a classpath.
+ */
+ private void addFolderButtonPressed() {
+ DirectoryDialog dialog = new DirectoryDialog(getShell());
+ String result = dialog.open();
+ if (result != null) {
+ try {
+ URL url = new URL("file:" + result + "/"); //$NON-NLS-2$;//$NON-NLS-1$;
+ addContent(url);
+ } catch (MalformedURLException e) {
+ }
+ }
+ }
+
+ /**
+ * Allows the user to enter a JAR as a classpath.
+ */
+ private void addJarButtonPressed() {
+ FileDialog dialog = new FileDialog(getShell());
+ dialog.setFilterExtensions(new String[] { "*.jar" }); //$NON-NLS-1$;
+ String result = dialog.open();
+ if (result != null) {
+ try {
+ URL url = new URL("file:" + result); //$NON-NLS-1$;
+ addContent(url);
+ } catch (MalformedURLException e) {
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * Method declared on AntPage.
+ */
+ protected void buttonPressed(int buttonId) {
+ switch (buttonId) {
+ case ADD_JAR_BUTTON :
+ addJarButtonPressed();
+ break;
+ case ADD_FOLDER_BUTTON :
+ addFolderButtonPressed();
+ break;
+ case REMOVE_BUTTON :
+ removeButtonPressed();
+ break;
+ }
+ }
+
+ /**
+ * Creates the tab item that contains this sub-page.
+ */
+ public TabItem createTabItem(TabFolder folder) {
+ TabItem item = new TabItem(folder, SWT.NONE);
+ item.setText(ToolMessages.getString("AntClasspathPage.title")); //$NON-NLS-1$;
+ item.setImage(labelProvider.getClasspathImage());
+ item.setData(this);
+ item.setControl(createControl(folder));
+ return item;
+ }
+
+ /* (non-Javadoc)
+ * Method declared on AntPage.
+ */
+ protected ITableLabelProvider getLabelProvider() {
+ return labelProvider;
+ }
+
+
+ /**
+ * Label provider for classpath elements
+ */
+ private static final class AntClasspathLabelProvider extends LabelProvider implements ITableLabelProvider {
+ private static final String IMG_JAR_FILE = "icons/full/obj16/jar_l_obj.gif"; //$NON-NLS-1$;
+ private static final String IMG_CLASSPATH = "icons/full/obj16/classpath.gif"; //$NON-NLS-1$;
+
+ private Image classpathImage;
+ private Image folderImage;
+ private Image jarImage;
+
+ /**
+ * Creates an instance.
+ */
+ public AntClasspathLabelProvider() {
+ }
+
+ /* (non-Javadoc)
+ * Method declared on IBaseLabelProvider.
+ */
+ public void dispose() {
+ // Folder image is shared, do not dispose.
+ folderImage = null;
+ if (jarImage != null) {
+ jarImage.dispose();
+ jarImage = null;
+ }
+ if (classpathImage != null) {
+ classpathImage.dispose();
+ classpathImage = null;
+ }
+ }
+
+ /* (non-Javadoc)
+ * Method declared on ITableLabelProvider.
+ */
+ public Image getColumnImage(Object element, int columnIndex) {
+ URL url = (URL) element;
+ if (url.getFile().endsWith("/")) //$NON-NLS-1$
+ return getFolderImage();
+ else
+ return getJarImage();
+ }
+
+ /* (non-Javadoc)
+ * Method declared on ITableLabelProvider.
+ */
+ public String getColumnText(Object element, int columnIndex) {
+ return ((URL) element).getFile();
+ }
+
+ private Image getFolderImage() {
+ if (folderImage == null)
+ folderImage = PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FOLDER);
+ return folderImage;
+ }
+
+ private Image getJarImage() {
+ if (jarImage == null) {
+ ImageDescriptor desc = ExternalToolsPlugin.getDefault().getImageDescriptor(IMG_JAR_FILE);
+ jarImage = desc.createImage();
+ }
+ return jarImage;
+ }
+
+ private Image getClasspathImage() {
+ if (classpathImage == null) {
+ ImageDescriptor desc = ExternalToolsPlugin.getDefault().getImageDescriptor(IMG_CLASSPATH);
+ classpathImage = desc.createImage();
+ }
+ return classpathImage;
+ }
+ }
+} \ No newline at end of file
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
new file mode 100644
index 000000000..8995794a3
--- /dev/null
+++ b/org.eclipse.ui.externaltools/Ant Tools Support/org/eclipse/ui/externaltools/internal/ant/dialog/AntExternalToolNewWizard.java
@@ -0,0 +1,134 @@
+package org.eclipse.ui.externaltools.internal.ant.dialog;
+
+/**********************************************************************
+Copyright (c) 2002 IBM Corp. and others. All rights reserved.
+This file is 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:
+**********************************************************************/
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.externaltools.dialog.ExternalToolGroupWizardPage;
+import org.eclipse.ui.externaltools.dialog.ExternalToolNewWizard;
+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.IExternalToolConstants;
+import org.eclipse.ui.externaltools.model.ToolUtil;
+
+/**
+ * Wizard that will create a new external tool of type Ant build.
+ */
+public class AntExternalToolNewWizard extends ExternalToolNewWizard {
+ private AntTargetsGroup antTargetsGroup;
+ private IFile xmlFile;
+
+ /**
+ * Creates the wizard for a new external tool
+ */
+ public AntExternalToolNewWizard() {
+ super(IExternalToolConstants.TOOL_TYPE_ANT_BUILD);
+ }
+
+ public AntExternalToolNewWizard(IFile file) {
+ super(IExternalToolConstants.TOOL_TYPE_ANT_BUILD);
+ xmlFile= validateXMLFile(file);
+ }
+
+ /* (non-Javadoc)
+ * Method declared on IWizard.
+ */
+ public void addPages() {
+ addMainPage();
+ addAntTargetsPage();
+ addOptionPage();
+ addRefreshPage();
+
+ optionGroup.setPromptForArgumentLabel(ToolMessages.getString("AntExternalToolNewWizard.promptForArgumentLabel")); //$NON-NLS-1$
+ }
+
+ /**
+ * Returns whether the given resource is an XML file
+ * based on the resource's file extension
+ * * @param resource the resource to examine * @return whether the given resource is an XML file */
+ private IFile validateXMLFile(IFile file) {
+ if ("xml".equals(file.getFileExtension().toLowerCase())) {
+ return file;
+ }
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * Method declared on ExternalToolNewWizard.
+ */
+ protected ImageDescriptor getDefaultImageDescriptor() {
+ return ExternalToolsPlugin.getDefault().getImageDescriptor("icons/full/wizban/ant_wiz.gif"); //$NON-NLS-1$
+ }
+
+ /*
+ * (non-Javadoc)
+ * Method declared on ExternalToolNewWizard.
+ */
+ protected boolean updateTool(ExternalTool tool) {
+ if (super.updateTool(tool))
+ return updateToolFromGroup(tool, antTargetsGroup);
+ return false;
+ }
+
+ /**
+ * Creates a wizard page to contain the ant build tool
+ * targets component and adds it to the wizard page
+ * list.
+ */
+ private void addAntTargetsPage() {
+ createAntTargetsGroup();
+ if (antTargetsGroup == null)
+ return;
+ ExternalToolGroupWizardPage page;
+ page = new AntTargetsGroupWizardPage("antGroupPage", antTargetsGroup, mainGroup, IHelpContextIds.ANT_TARGETS_WIZARD_PAGE); //$NON-NLS-1$
+ page.setTitle(ToolMessages.getString("AntExternalToolNewWizard.antTargetsPageTitle")); //$NON-NLS-1$
+ page.setDescription(ToolMessages.getString("AntExternalToolNewWizard.antTargetsPageDescription")); //$NON-NLS-1$
+ addPage(page);
+ }
+
+ /**
+ * Creates and initializes the group for selecting
+ * which Ant targets to run.
+ */
+ private void createAntTargetsGroup() {
+ if (antTargetsGroup != null)
+ return;
+ antTargetsGroup = new AntTargetsGroup();
+ }
+ public IWizardPage getStartingPage() {
+ return super.getStartingPage();
+ }
+
+ public void createPageControls(Composite pageContainer) {
+ String fileLocation= null;
+ if (xmlFile != null) {
+ StringBuffer buffer = new StringBuffer();
+ ToolUtil.buildVariableTag(IExternalToolConstants.VAR_WORKSPACE_LOC, xmlFile.getFullPath().toString(), buffer);
+ fileLocation= buffer.toString();
+ String baseName= xmlFile.getName() + " [" + xmlFile.getProject().getName() + "]" ;
+ String name= baseName;
+ int index= 0;
+ while (ExternalToolsPlugin.getDefault().getToolRegistry(getShell()).hasToolNamed(name)) {
+ name= baseName + "_" + index;
+ }
+ mainGroup.setInitialName(name);
+ mainGroup.setInitialLocation(fileLocation);
+ }
+ super.createPageControls(pageContainer);
+ if (fileLocation != null) {
+ antTargetsGroup.setFileLocation(fileLocation);
+ }
+ }
+
+}
diff --git a/org.eclipse.ui.externaltools/Ant Tools Support/org/eclipse/ui/externaltools/internal/ant/dialog/AntOptionGroupPropertyPage.java b/org.eclipse.ui.externaltools/Ant Tools Support/org/eclipse/ui/externaltools/internal/ant/dialog/AntOptionGroupPropertyPage.java
new file mode 100644
index 000000000..91c892d41
--- /dev/null
+++ b/org.eclipse.ui.externaltools/Ant Tools Support/org/eclipse/ui/externaltools/internal/ant/dialog/AntOptionGroupPropertyPage.java
@@ -0,0 +1,29 @@
+package org.eclipse.ui.externaltools.internal.ant.dialog;
+
+/**********************************************************************
+Copyright (c) 2002 IBM Corp. and others. All rights reserved.
+This file is 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:
+**********************************************************************/
+
+import org.eclipse.ui.externaltools.dialog.ExternalToolOptionGroupPropertyPage;
+import org.eclipse.ui.externaltools.group.ExternalToolOptionGroup;
+import org.eclipse.ui.externaltools.internal.model.ToolMessages;
+
+/**
+ * Property page to show the options group. Sets the
+ * appropriate label to prompt for targets and arguments.
+ */
+public class AntOptionGroupPropertyPage extends ExternalToolOptionGroupPropertyPage {
+
+ /**
+ * Creates the option group property page.
+ */
+ public AntOptionGroupPropertyPage() {
+ super();
+ ((ExternalToolOptionGroup) getGroup()).setPromptForArgumentLabel(ToolMessages.getString("AntOptionGroupPropertyPage.promptForArgumentLabel")); //$NON-NLS-1$
+ }
+}
diff --git a/org.eclipse.ui.externaltools/Ant Tools Support/org/eclipse/ui/externaltools/internal/ant/dialog/AntPage.java b/org.eclipse.ui.externaltools/Ant Tools Support/org/eclipse/ui/externaltools/internal/ant/dialog/AntPage.java
new file mode 100644
index 000000000..fd4796bc2
--- /dev/null
+++ b/org.eclipse.ui.externaltools/Ant Tools Support/org/eclipse/ui/externaltools/internal/ant/dialog/AntPage.java
@@ -0,0 +1,258 @@
+package org.eclipse.ui.externaltools.internal.ant.dialog;
+
+/**********************************************************************
+Copyright (c) 2002 IBM Corp. and others. All rights reserved.
+This file is 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:
+**********************************************************************/
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.ui.externaltools.internal.model.ToolMessages;
+
+/**
+ * Provides the generic implementation for a sub-page in the
+ * Ant preference page.
+ */
+public abstract class AntPage {
+ private SelectionAdapter selectionAdapter = new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ buttonPressed(((Integer) e.widget.getData()).intValue());
+ }
+ };
+ private AntPreferencePage preferencePage;
+ private TableViewer tableViewer;
+ private AntPageContentProvider contentProvider;
+
+ /**
+ * Creates an instance of this page.
+ */
+ public AntPage(AntPreferencePage preferencePage) {
+ super();
+ this.preferencePage = preferencePage;
+ }
+
+ /**
+ * Adds buttons specific to the page.
+ */
+ protected abstract void addButtonsToButtonGroup(Composite parent);
+
+ /**
+ * Adds an object to the contents
+ */
+ protected final void addContent(Object o) {
+ if (contentProvider != null)
+ contentProvider.add(o);
+ }
+
+ /**
+ * Handles a button pressed event.
+ */
+ protected void buttonPressed(int buttonId) {
+ }
+
+ /**
+ * Creates and returns a button with appropriate size and layout.
+ *
+ * @param parent the control to create the button on
+ * @param labelKey the key to lookup the button's label
+ * @param buttonId the id to assign to this button
+ * @return a new and initialized button
+ */
+ protected Button createButton(Composite parent, String labelKey, int buttonId) {
+ Button button = new Button(parent, SWT.PUSH);
+ button.setText(ToolMessages.getString(labelKey));
+ button.setData(new Integer(buttonId));
+ button.addSelectionListener(selectionAdapter);
+ preferencePage.setButtonGridData(button);
+ return button;
+ }
+
+ /**
+ * Creates the group which will contain the buttons.
+ */
+ private void createButtonGroup(Composite top) {
+ Composite buttonGroup = new Composite(top, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
+ buttonGroup.setLayout(layout);
+ buttonGroup.setLayoutData(new GridData(GridData.FILL_VERTICAL));
+
+ addButtonsToButtonGroup(buttonGroup);
+ }
+
+ /**
+ * Creates a space between controls
+ */
+ protected final Label createSeparator(Composite parent) {
+ Label separator = new Label(parent, SWT.NONE);
+ GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_BEGINNING);
+ gd.heightHint = 4;
+ separator.setLayoutData(gd);
+ return separator;
+ }
+
+ /**
+ * Creates the table viewer.
+ */
+ private void createTable(Composite parent) {
+ Table table = new Table(parent, SWT.MULTI | SWT.FULL_SELECTION | SWT.BORDER);
+ table.setLayoutData(new GridData(GridData.FILL_BOTH));
+ contentProvider = new AntPageContentProvider();
+ tableViewer = new TableViewer(table);
+ tableViewer.setContentProvider(contentProvider);
+ tableViewer.setLabelProvider(getLabelProvider());
+ tableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
+ public void selectionChanged(SelectionChangedEvent event) {
+ tableSelectionChanged((IStructuredSelection) event.getSelection());
+ }
+ });
+ }
+
+ /**
+ * Returns the currently listed objects in the table. Returns null
+ * if this widget has not yet been created or has been disposed.
+ */
+ public List getContents() {
+ if (tableViewer == null || tableViewer.getControl().isDisposed())
+ return null;
+ Object[] elements = contentProvider.getElements(tableViewer.getInput());
+ return Arrays.asList(elements);
+ }
+
+ /**
+ * Returns the label provider the sub-page wants to use
+ * to display its content with.
+ */
+ protected abstract ITableLabelProvider getLabelProvider();
+
+ /**
+ * Returns the first selected element in the viewer, or
+ * <code>null</code> if none.
+ */
+ protected final Object getSelectedElement() {
+ if (tableViewer == null || tableViewer.getControl().isDisposed())
+ return null;
+ return ((IStructuredSelection) tableViewer.getSelection()).getFirstElement();
+ }
+
+ /**
+ * Returns the shell of the sub-page.
+ */
+ protected final Shell getShell() {
+ if (tableViewer == null || tableViewer.getControl().isDisposed())
+ return null;
+ return tableViewer.getControl().getShell();
+ }
+
+ /**
+ * Handles the remove button pressed event
+ */
+ protected void removeButtonPressed() {
+ IStructuredSelection sel = (IStructuredSelection) tableViewer.getSelection();
+ Iterator enum = sel.iterator();
+ while (enum.hasNext())
+ contentProvider.remove(enum.next());
+ }
+
+ /**
+ * Sets the contents of the table on this page. Has no effect
+ * if this widget has not yet been created or has been disposed.
+ */
+ public void setInput(List inputs) {
+ if (tableViewer == null || tableViewer.getControl().isDisposed())
+ return;
+ tableViewer.setInput(inputs);
+ tableSelectionChanged((IStructuredSelection) tableViewer.getSelection());
+ }
+ /**
+ * Handles selection changes in the table viewer.
+ */
+ protected void tableSelectionChanged(IStructuredSelection newSelection) {
+ }
+
+ /**
+ * Updates the content element in the table viewer.
+ */
+ protected final void updateContent(Object element) {
+ if (tableViewer == null || tableViewer.getControl().isDisposed())
+ return;
+ tableViewer.update(element, null);
+ }
+
+ /**
+ * Creates this page's controls
+ */
+ public Control createControl(Composite parent) {
+ Composite top = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 2;
+ layout.marginHeight = 2;
+ layout.marginWidth = 2;
+ top.setLayout(layout);
+
+ createTable(top);
+ createButtonGroup(top);
+
+ return top;
+ }
+
+
+ /**
+ * Content provider that maintains a generic list of objects which
+ * are shown in a table viewer.
+ */
+ private static final class AntPageContentProvider implements IStructuredContentProvider {
+ private ArrayList elements = new ArrayList();
+ private TableViewer viewer;
+
+ public void add(Object o) {
+ elements.add(o);
+ viewer.add(o);
+ }
+
+ public void dispose() {
+ }
+
+ public Object[] getElements(Object inputElement) {
+ return (Object[]) elements.toArray(new Object[elements.size()]);
+ }
+
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ this.viewer = (TableViewer) viewer;
+ elements.clear();
+ if (newInput != null)
+ elements.addAll((List) newInput);
+ }
+
+ public void remove(Object o) {
+ elements.remove(o);
+ viewer.remove(o);
+ }
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.ui.externaltools/Ant Tools Support/org/eclipse/ui/externaltools/internal/ant/dialog/AntPreferencePage.java b/org.eclipse.ui.externaltools/Ant Tools Support/org/eclipse/ui/externaltools/internal/ant/dialog/AntPreferencePage.java
new file mode 100644
index 000000000..94b91b6dc
--- /dev/null
+++ b/org.eclipse.ui.externaltools/Ant Tools Support/org/eclipse/ui/externaltools/internal/ant/dialog/AntPreferencePage.java
@@ -0,0 +1,133 @@
+package org.eclipse.ui.externaltools.internal.ant.dialog;
+
+/**********************************************************************
+Copyright (c) 2002 IBM Corp. and others. All rights reserved.
+This file is 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:
+**********************************************************************/
+
+import java.net.URL;
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.ant.core.AntCorePlugin;
+import org.eclipse.ant.core.AntCorePreferences;
+import org.eclipse.ant.core.Task;
+import org.eclipse.ant.core.Type;
+import org.eclipse.jface.preference.PreferencePage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.TabFolder;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+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.help.WorkbenchHelp;
+
+/**
+ * Ant preference page to set the classpath, tasks, and types.
+ */
+public class AntPreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
+
+ private AntClasspathPage fClasspathPage;
+ private AntTasksPage fTasksPage;
+ private AntTypesPage fTypesPage;
+
+ /**
+ * Creates the preference page
+ */
+ public AntPreferencePage() {
+ setDescription(ToolMessages.getString("AntPreferencePage.description")); //$NON-NLS-1$
+ setPreferenceStore(ExternalToolsPlugin.getDefault().getPreferenceStore());
+ }
+
+ /* (non-Javadoc)
+ * Method declared on IWorkbenchPreferencePage.
+ */
+ public void init(IWorkbench workbench) {
+ }
+
+ /* (non-Javadoc)
+ * Method declared on PreferencePage.
+ */
+ protected Control createContents(Composite parent) {
+ WorkbenchHelp.setHelp(parent, IHelpContextIds.ANT_PREFERENCE_PAGE);
+
+ TabFolder folder = new TabFolder(parent, SWT.NONE);
+ folder.setLayout(new GridLayout());
+ folder.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+ fClasspathPage = new AntClasspathPage(this);
+ fClasspathPage.createTabItem(folder);
+ fTasksPage = new AntTasksPage(this);
+ fTasksPage.createTabItem(folder);
+ fTypesPage = new AntTypesPage(this);
+ fTypesPage.createTabItem(folder);
+
+ AntCorePreferences prefs = AntCorePlugin.getPlugin().getPreferences();
+ fClasspathPage.setInput(Arrays.asList(prefs.getCustomURLs()));
+ fTasksPage.setInput(Arrays.asList(prefs.getCustomTasks()));
+ fTypesPage.setInput(Arrays.asList(prefs.getCustomTypes()));
+
+ return folder;
+ }
+
+ /* (non-Javadoc)
+ * Method declared on PreferencePage.
+ */
+ protected void performDefaults() {
+ super.performDefaults();
+
+ AntCorePreferences prefs = AntCorePlugin.getPlugin().getPreferences();
+ fClasspathPage.setInput(Arrays.asList(prefs.getDefaultCustomURLs()));
+ fTasksPage.setInput(Arrays.asList(prefs.getCustomTasks()));
+ fTypesPage.setInput(Arrays.asList(prefs.getCustomTypes()));
+ }
+
+ /* (non-Javadoc)
+ * Method declared on PreferencePage.
+ */
+ public boolean performOk() {
+ AntCorePreferences prefs = AntCorePlugin.getPlugin().getPreferences();
+
+ List contents = fClasspathPage.getContents();
+ if (contents != null) {
+ URL[] urls = (URL[]) contents.toArray(new URL[contents.size()]);
+ prefs.setCustomURLs(urls);
+ }
+
+ contents = fTasksPage.getContents();
+ if (contents != null) {
+ Task[] tasks = (Task[]) contents.toArray(new Task[contents.size()]);
+ prefs.setCustomTasks(tasks);
+ }
+
+ contents = fTypesPage.getContents();
+ if (contents != null) {
+ Type[] types = (Type[]) contents.toArray(new Type[contents.size()]);
+ prefs.setCustomTypes(types);
+ }
+
+ prefs.updatePluginPreferences();
+ return super.performOk();
+ }
+
+ /**
+ * Sets the <code>GridData</code> on the specified button to
+ * be one that is spaced for the current dialog page units.
+ *
+ * @param button the button to set the <code>GridData</code>
+ * @return the <code>GridData</code> set on the specified button
+ */
+ /*package*/ GridData setButtonGridData(Button button) {
+ return setButtonLayoutData(button);
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.ui.externaltools/Ant Tools Support/org/eclipse/ui/externaltools/internal/ant/dialog/AntTargetsGroup.java b/org.eclipse.ui.externaltools/Ant Tools Support/org/eclipse/ui/externaltools/internal/ant/dialog/AntTargetsGroup.java
new file mode 100644
index 000000000..ef4972332
--- /dev/null
+++ b/org.eclipse.ui.externaltools/Ant Tools Support/org/eclipse/ui/externaltools/internal/ant/dialog/AntTargetsGroup.java
@@ -0,0 +1,733 @@
+package org.eclipse.ui.externaltools.internal.ant.dialog;
+
+/**********************************************************************
+Copyright (c) 2002 IBM Corp. and others. All rights reserved.
+This file is 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:
+**********************************************************************/
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.eclipse.ant.core.TargetInfo;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.MultiStatus;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.List;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.externaltools.group.ExternalToolGroup;
+import org.eclipse.ui.externaltools.internal.ant.model.AntUtil;
+import org.eclipse.ui.externaltools.internal.model.ToolMessages;
+import org.eclipse.ui.externaltools.model.ExternalTool;
+import org.eclipse.ui.externaltools.model.IExternalToolConstants;
+import org.eclipse.ui.externaltools.model.ToolUtil;
+import org.eclipse.ui.externaltools.variable.ExpandVariableContext;
+
+/**
+ * Group for selecting the targets of an Ant build tool.
+ */
+public class AntTargetsGroup extends ExternalToolGroup {
+ private static final int DESCRIPTION_FIELD_HEIGHT = 3;
+
+ private String fileLocation = null;
+ private TargetInfo defaultTarget = null;
+ private Map mapTargetNamesToTargetInfos = new HashMap();
+ private ArrayList subTargets = new ArrayList();
+
+ private Button runDefaultTargetButton;
+ private Button showSubTargetsButton;
+ private List availableTargetsList;
+ private List activeTargetsList;
+ private Button addButton;
+ private Button removeButton;
+ private Button addAll;
+ private Button removeAll;
+ private Button upButton;
+ private Button downButton;
+ private Text descriptionField;
+ private Label descriptionLabel;
+ private Label availableLabel;
+ private Label activeLabel;
+
+ /**
+ * Creates the group
+ */
+ public AntTargetsGroup() {
+ super();
+ }
+
+ /* (non-Javadoc)
+ * Method declared on ExternalToolGroup.
+ */
+ protected Control createGroupContents(Composite parent, ExternalTool tool) {
+ // main composite
+ Composite mainComposite = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.marginWidth = 0;
+ layout.marginHeight = 0;
+ mainComposite.setLayout(layout);
+ GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
+ mainComposite.setLayoutData(gridData);
+
+ Composite upperComposite = new Composite(mainComposite, SWT.NONE);
+ layout = new GridLayout();
+ layout.marginWidth = 0;
+ layout.marginHeight = 0;
+ gridData = new GridData(GridData.FILL_HORIZONTAL);
+ upperComposite.setLayout(layout);
+ upperComposite.setLayoutData(gridData);
+
+ createRunDefaultTargetButton(upperComposite);
+
+ Composite middleComposite = new Composite(mainComposite, SWT.NONE);
+ layout = new GridLayout();
+ layout.marginWidth = 0;
+ layout.marginHeight = 0;
+ layout.numColumns = 4;
+ gridData = new GridData(GridData.FILL_HORIZONTAL);
+ middleComposite.setLayout(layout);
+ middleComposite.setLayoutData(gridData);
+
+ createAvailableTargetsList(middleComposite);
+ createAddRemoveComposite(middleComposite);
+ createActiveTargetsList(middleComposite);
+ createUpDownComposite(middleComposite);
+
+ Composite lowerComposite = new Composite(mainComposite, SWT.NONE);
+ layout = new GridLayout();
+ layout.marginWidth = 0;
+ layout.marginHeight = 0;
+ gridData = new GridData(GridData.FILL_HORIZONTAL);
+ lowerComposite.setLayout(layout);
+ lowerComposite.setLayoutData(gridData);
+
+ createDescriptionField(lowerComposite);
+ createShowSubTargetsButton(lowerComposite);
+
+ if (tool != null)
+ restoreValues(tool);
+ allowSelectTargets(!runDefaultTargetButton.getSelection());
+
+ return mainComposite;
+ }
+
+ /*
+ * Creates the checkbox button for the
+ * "Run default target" preference.
+ */
+ private void createRunDefaultTargetButton(Composite parent) {
+ runDefaultTargetButton = new Button(parent, SWT.CHECK);
+ // The label that is applied if the default target is unknown
+ runDefaultTargetButton.setText(ToolMessages.getString("AntTargetsGroup.runDefaultTargetUnknownLabel")); //$NON-NLS-1$
+ runDefaultTargetButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ runDefaultTargetSelected();
+ }
+ });
+ runDefaultTargetButton.setSelection(true);
+ }
+
+ /*
+ * Creates the checkbox button for the
+ * "Show sub-targets" preference.
+ */
+ private void createShowSubTargetsButton(Composite parent) {
+ showSubTargetsButton = new Button(parent, SWT.CHECK);
+ showSubTargetsButton.setText(ToolMessages.getString("AntTargetsGroup.showSubTargetsLabel")); //$NON-NLS-1$
+ showSubTargetsButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ if (showSubTargetsButton.getSelection()) {
+ showSubTargets();
+ } else {
+ hideSubTargets();
+ }
+ }
+ });
+ showSubTargetsButton.setSelection(false);
+ }
+
+ /*
+ * Creates the list of targets provided by the ant build tool.
+ */
+ private void createAvailableTargetsList(Composite parent) {
+ Composite listComposite = new Composite(parent, SWT.NONE);
+
+ GridData gridData = new GridData(GridData.FILL_BOTH);
+ listComposite.setLayoutData(gridData);
+
+ GridLayout layout = new GridLayout();
+ layout.marginWidth = 0;
+ layout.marginHeight = 0;
+ listComposite.setLayout(layout);
+
+ availableLabel = new Label(listComposite, SWT.LEFT);
+ availableLabel.setText(ToolMessages.getString("AntTargetsGroup.availableTargetsLabel")); //$NON-NLS-1$
+
+ availableTargetsList = new List(listComposite, SWT.BORDER | SWT.MULTI);
+ gridData = new GridData(GridData.FILL_BOTH);
+ availableTargetsList.setLayoutData(gridData);
+
+ availableTargetsList.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ int index = availableTargetsList.getSelectionIndex();
+ if (index >= 0)
+ targetsSelected(availableTargetsList.getItem(index), availableTargetsList);
+ else
+ deselectAll();
+ }
+ });
+ }
+
+ /*
+ * Creates the list of targets that will be used when the tool is run.
+ */
+ private void createActiveTargetsList(Composite parent) {
+ Composite listComposite = new Composite(parent, SWT.NONE);
+
+ GridData gridData = new GridData(GridData.FILL_BOTH);
+ listComposite.setLayoutData(gridData);
+
+ GridLayout layout = new GridLayout();
+ layout.marginWidth = 0;
+ layout.marginHeight = 0;
+ listComposite.setLayout(layout);
+
+ activeLabel = new Label(listComposite, SWT.LEFT);
+ activeLabel.setText(ToolMessages.getString("AntTargetsGroup.activeTargetsLabel")); //$NON-NLS-1$
+
+ activeTargetsList = new List(listComposite, SWT.BORDER | SWT.MULTI);
+ gridData = new GridData(GridData.FILL_BOTH);
+ activeTargetsList.setLayoutData(gridData);
+
+ activeTargetsList.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ int index = activeTargetsList.getSelectionIndex();
+ if (index >= 0)
+ targetsSelected(activeTargetsList.getItem(index), activeTargetsList);
+ else
+ deselectAll();
+ }
+ });
+ }
+
+ /*
+ * Creates the bank of buttons that allow the user to
+ * addButton and removeButton targets from the active list.
+ */
+ private void createAddRemoveComposite(Composite parent) {
+ Composite addRemoveComposite = new Composite(parent, SWT.NONE);
+
+ GridData gridData = new GridData();
+ addRemoveComposite.setLayoutData(gridData);
+
+ GridLayout layout = new GridLayout();
+ layout.marginWidth = 0;
+ layout.marginHeight = 0;
+ addRemoveComposite.setLayout(layout);
+
+ new Label(addRemoveComposite, SWT.NONE);
+
+ addButton = createButton(
+ addRemoveComposite,
+ ToolMessages.getString("AntTargetsGroup.addLabel"), //$NON-NLS-1$
+ new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ addTargets();
+ }
+ },
+ false);
+
+ removeButton = createButton(
+ addRemoveComposite,
+ ToolMessages.getString("AntTargetsGroup.removeLabel"), //$NON-NLS-1$
+ new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ removeTargets();
+ }
+ },
+ false);
+
+ new Label(addRemoveComposite, SWT.NONE);
+
+ addAll = createButton(
+ addRemoveComposite,
+ ToolMessages.getString("AntTargetsGroup.addAllLabel"), //$NON-NLS-1$
+ new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ addAllTargets();
+ }
+ },
+ false);
+
+ removeAll = createButton(
+ addRemoveComposite,
+ ToolMessages.getString("AntTargetsGroup.removeAllLabel"), //$NON-NLS-1$
+ new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ removeAllTargets();
+ }
+ },
+ false);
+ }
+
+ /*
+ * Creates a button bank containing the buttons for moving
+ * targets in the active list upButton and downButton.
+ */
+ private void createUpDownComposite(Composite parent) {
+ Composite upDownComposite = new Composite(parent, SWT.NONE);
+
+ GridData gridData = new GridData();
+ upDownComposite.setLayoutData(gridData);
+
+ GridLayout layout = new GridLayout();
+ layout.marginWidth = 0;
+ layout.marginHeight = 0;
+ upDownComposite.setLayout(layout);
+
+ new Label(upDownComposite, SWT.NONE);
+
+ upButton = createButton(
+ upDownComposite,
+ ToolMessages.getString("AntTargetsGroup.upLabel"), //$NON-NLS-1$
+ new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ moveTargetUp();
+ }
+ },
+ true);
+
+ downButton = createButton(
+ upDownComposite,
+ ToolMessages.getString("AntTargetsGroup.downLabel"), //$NON-NLS-1$
+ new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ moveTargetDown();
+ }
+ },
+ true);
+ }
+
+ /*
+ * Creates a button in the given composite with the given label and selection adapter.
+ * minWidth specifies whether the button should be at minimum IDialogConstants.BUTTON_WIDTH
+ * wide.
+ */
+ private Button createButton(Composite parent, String label, SelectionAdapter adapter, boolean minWidth) {
+ Button button = new Button(parent, SWT.PUSH);
+ button.setText(label);
+ GridData data = getPage().setButtonGridData(button);
+ if (!minWidth)
+ data.widthHint = button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x;
+ button.addSelectionListener(adapter);
+
+ return button;
+ }
+
+ /*
+ * Creates the text field which displays the descriptionField of the selected target.
+ */
+ private void createDescriptionField(Composite parent) {
+ descriptionLabel = new Label(parent, SWT.NONE);
+ descriptionLabel.setText(ToolMessages.getString("AntTargetsGroup.descriptionLabel")); //$NON-NLS-1$
+
+ descriptionField = new Text(parent, SWT.READ_ONLY | SWT.BORDER);
+ GridData data = new GridData(GridData.FILL_HORIZONTAL);
+ data.heightHint = getPage().convertHeightHint(DESCRIPTION_FIELD_HEIGHT);
+ descriptionField.setLayoutData(data);
+ }
+
+ /* (non-Javadoc)
+ * Method declared on IExternalToolGroup.
+ */
+ public void restoreValues(ExternalTool tool) {
+ if (activeTargetsList != null) {
+ activeTargetsList.setItems(toArray(tool.getExtraAttribute(AntUtil.RUN_TARGETS_ATTRIBUTE)));
+
+ if (activeTargetsList.getItemCount() == 0) {
+ runDefaultTargetButton.setSelection(true);
+ runDefaultTargetSelected();
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * Method declared on IExternalToolGroup.
+ */
+ public void updateTool(ExternalTool tool) {
+ if (runDefaultTargetButton == null)
+ return;
+ if (runDefaultTargetButton.getSelection()) {
+ tool.setExtraAttribute(AntUtil.RUN_TARGETS_ATTRIBUTE, null);
+ } else {
+ if (activeTargetsList != null)
+ tool.setExtraAttribute(AntUtil.RUN_TARGETS_ATTRIBUTE, toString(activeTargetsList.getItems()));
+ }
+ }
+
+ /* (non-Javadoc)
+ * Method declared on IExternalToolGroup.
+ */
+ public void validate() {
+ }
+
+ /**
+ * Informs the group of the current external tool
+ * file location.
+ */
+ public void setFileLocation(String newLocation) {
+ if (newLocation == null) {
+ if (fileLocation != null) {
+ fileLocation = newLocation;
+ updateAvailableTargets();
+ }
+ } else if (!newLocation.equals(fileLocation)) {
+ fileLocation = newLocation;
+ updateAvailableTargets();
+ }
+ }
+
+ /*
+ * Translates an array of target names into a
+ * single string for storage.
+ */
+ private String toString(String[] targetArray) {
+ return AntUtil.combineRunTargets(targetArray);
+ }
+
+ /*
+ * Translates a single string of target names into
+ * an array of target names.
+ */
+ private String[] toArray(String targetString) {
+ return AntUtil.parseRunTargets(targetString);
+ }
+
+ /*
+ * The "run default target" preference has been selected.
+ */
+ private void runDefaultTargetSelected() {
+ allowSelectTargets(! runDefaultTargetButton.getSelection());
+ }
+
+ /*
+ * Adds the current selection in the available list
+ * to the active list.
+ */
+ private void addTargets() {
+ String[] targets = availableTargetsList.getSelection();
+ for (int i=0; i < targets.length; i++) {
+ activeTargetsList.add(targets[i]);
+ }
+ updateButtonEnablement();
+ }
+
+ /*
+ * Removes the current selection in the active list.
+ */
+ private void removeTargets() {
+ String[] targets = activeTargetsList.getSelection();
+ for (int i=0; i < targets.length; i++) {
+ activeTargetsList.remove(targets[i]);
+ }
+ deselectAll();
+ }
+
+ /*
+ * Adds all the available targets to the active list.
+ */
+ private void addAllTargets() {
+ String[] targets = availableTargetsList.getItems();
+ for (int i=0; i < targets.length; i++) {
+ activeTargetsList.add(targets[i]);
+ }
+ updateButtonEnablement();
+ }
+
+ /*
+ * Removes all the active targets.
+ */
+ private void removeAllTargets() {
+ activeTargetsList.removeAll();
+ deselectAll();
+ }
+
+ /*
+ * Moves the current selection in the active list upButton.
+ */
+ private void moveTargetUp() {
+ int index = activeTargetsList.getSelectionIndex();
+ // Action only works if selected element is not first element.
+ if (index > 0) {
+ String target = activeTargetsList.getItem(index);
+ activeTargetsList.remove(index);
+ activeTargetsList.add(target, index - 1);
+ activeTargetsList.setSelection(index - 1);
+ }
+
+ updateUpDownButtonEnablement();
+ }
+
+ /*
+ * Moves the current selection in the active list downButton.
+ */
+ private void moveTargetDown() {
+ int index = activeTargetsList.getSelectionIndex();
+ if (index < 0)
+ return;
+ // Action only works if selected element is not last element.
+ if (index < activeTargetsList.getItemCount() - 1) {
+ String target = activeTargetsList.getItem(index);
+ activeTargetsList.remove(index);
+ activeTargetsList.add(target, index + 1);
+ activeTargetsList.setSelection(index + 1);
+ }
+
+ updateUpDownButtonEnablement();
+ }
+
+ /*
+ * Updates the available targets list based on the tool location
+ * for this tool.
+ */
+ private void updateAvailableTargets() {
+ // Clear the map of target names to target infos.
+ mapTargetNamesToTargetInfos.clear();
+ subTargets.clear();
+ availableTargetsList.removeAll();
+ activeTargetsList.removeAll();
+
+ if (fileLocation == null)
+ return;
+
+ try {
+ MultiStatus status = new MultiStatus(IExternalToolConstants.PLUGIN_ID, 0, "", null); //$NON-NLS-1$
+ String expandedLocation = ToolUtil.expandFileLocation(fileLocation, ExpandVariableContext.EMPTY_CONTEXT, status);
+ if (expandedLocation != null && status.isOK()) {
+ TargetInfo[] targets = AntUtil.getTargets(expandedLocation);
+ ArrayList targetNameList = new ArrayList();
+ for (int i=0; i < targets.length; i++) {
+ if (! AntUtil.isInternalTarget(targets[i])) {
+ // Add the target to the map of target names to target infos.
+ mapTargetNamesToTargetInfos.put(targets[i].getName(), targets[i]);
+
+ if (targets[i].isDefault()) {
+ defaultTarget = targets[i];
+ runDefaultTargetButton.setText(ToolMessages.format("AntTargetsGroup.runDefaultTargetLabel", new Object[] {targets[i].getName()})); //NON-NLS-1$
+ }
+
+ if (AntUtil.isSubTarget(targets[i])) {
+ subTargets.add(targets[i].getName());
+ } else {
+ targetNameList.add(targets[i].getName());
+ }
+ }
+ }
+ if (showSubTargetsButton.getSelection())
+ targetNameList.addAll(subTargets);
+
+ String[] targetNames = (String[]) targetNameList.toArray(new String[targetNameList.size()]);
+ availableTargetsList.setItems(targetNames);
+ } else {
+ displayErrorStatus(status);
+ }
+ } catch (CoreException e) {
+ displayErrorStatus(e.getStatus());
+ }
+ }
+
+ /*
+ * Displays an error dialog with the given status.
+ */
+ private void displayErrorStatus(IStatus status) {
+ ErrorDialog.openError(
+ null,
+ ToolMessages.getString("AntTargetsGroup.getTargetsTitle"), //$NON-NLS-1$;
+ ToolMessages.getString("AntTargetsGroup.getTargetsProblem"), //$NON-NLS-1$;
+ status);
+ }
+
+ /*
+ * A target was selected in one of the lists.
+ */
+ private void targetsSelected(String targetName, List list) {
+ updateButtonEnablement();
+
+ if (targetName == null)
+ return;
+ if (list == availableTargetsList) {
+ activeTargetsList.deselectAll();
+ } else {
+ availableTargetsList.deselectAll();
+ }
+
+ showDescription(targetName);
+ }
+
+ /*
+ * Updates the enablement of all the buttons in the group.
+ */
+ private void updateButtonEnablement() {
+ updateUpDownButtonEnablement();
+ updateAddRemoveButtonEnablement();
+ }
+
+ /*
+ * Updates the enabled state of the upButton and downButton buttons based
+ * on the current list selection.
+ */
+ private void updateUpDownButtonEnablement() {
+ if (activeTargetsList.getEnabled() == false) {
+ disableUpDownButtons();
+ return;
+ }
+ // Disable upButton and downButton buttons if there is not one
+ // target selected in the active list.
+ if (activeTargetsList.getSelectionCount() != 1) {
+ disableUpDownButtons();
+ return;
+ }
+
+ int index = activeTargetsList.getSelectionIndex();
+ if (index > 0)
+ upButton.setEnabled(true);
+ else
+ upButton.setEnabled(false);
+
+ if (index >= 0 && index < activeTargetsList.getItemCount() - 1)
+ downButton.setEnabled(true);
+ else
+ downButton.setEnabled(false);
+ }
+
+ /*
+ * Updates the enabled state of the addButton, removeButton, addAll, and
+ * removeAll buttons based on the current list selection.
+ */
+ private void updateAddRemoveButtonEnablement() {
+ if (runDefaultTargetButton.getSelection()) {
+ disableAddRemoveButtons();
+ return;
+ }
+ int availableIndex = availableTargetsList.getSelectionIndex();
+ int activeIndex = activeTargetsList.getSelectionIndex();
+ addButton.setEnabled(availableIndex >= 0);
+ removeButton.setEnabled(activeIndex >= 0);
+ addAll.setEnabled(availableTargetsList.getItemCount() > 0);
+ removeAll.setEnabled(activeTargetsList.getItemCount() > 0);
+ }
+
+ /*
+ * Deselects all targets in both lists.
+ */
+ private void deselectAll() {
+ availableTargetsList.deselectAll();
+ activeTargetsList.deselectAll();
+ updateButtonEnablement();
+ clearDescriptionField();
+ }
+
+ /*
+ * Enables all the appropriate controls.
+ */
+ private void allowSelectTargets(boolean enabled) {
+ if (! enabled) {
+ deselectAll();
+ if (defaultTarget != null && defaultTarget.getDescription() != null)
+ descriptionField.setText(defaultTarget.getDescription());
+ } else {
+ descriptionField.setText(""); //$NON-NLS-1$
+ }
+
+ availableLabel.setEnabled(enabled);
+ availableTargetsList.setEnabled(enabled);
+ activeLabel.setEnabled(enabled);
+ activeTargetsList.setEnabled(enabled);
+ descriptionLabel.setEnabled(enabled);
+ descriptionField.setEnabled(enabled);
+ showSubTargetsButton.setEnabled(enabled);
+ updateButtonEnablement();
+ }
+
+ /*
+ * Disables all buttons in the group.
+ */
+ private void disableAllButtons() {
+ disableAddRemoveButtons();
+ disableUpDownButtons();
+ }
+
+ /*
+ * Disables the addButton, removeButton, addAll, and
+ * removeAll buttons.
+ */
+ private void disableAddRemoveButtons() {
+ addButton.setEnabled(false);
+ removeButton.setEnabled(false);
+ addAll.setEnabled(false);
+ removeAll.setEnabled(false);
+ }
+
+ /*
+ * Disables the upButton and downButton buttons.
+ */
+ private void disableUpDownButtons() {
+ upButton.setEnabled(false);
+ downButton.setEnabled(false);
+ }
+
+ /*
+ * Shows the descriptionField of the given target in the
+ * descriptionField field.
+ */
+ private void showDescription(String targetName) {
+ clearDescriptionField();
+ if (targetName == null)
+ return;
+ TargetInfo targetInfo = (TargetInfo) mapTargetNamesToTargetInfos.get(targetName);
+ if (targetInfo != null && targetInfo.getDescription() != null)
+ descriptionField.setText(targetInfo.getDescription());
+ }
+
+ /*
+ * Clears the descriptionField field.
+ */
+ private void clearDescriptionField() {
+ descriptionField.setText(""); //$NON-NLS-1$
+ }
+
+ /*
+ * Shows sub-targets in the available targets list.
+ */
+ private void showSubTargets() {
+ Iterator i = subTargets.iterator();
+ while (i.hasNext()) {
+ String target = (String) i.next();
+ availableTargetsList.add(target);
+ }
+ }
+
+ /*
+ * Hides sub-targets in the available targets list.
+ */
+ private void hideSubTargets() {
+ int startOfSubTargets = availableTargetsList.getItemCount() - subTargets.size();
+ int endOfSubTargets = availableTargetsList.getItemCount() - 1;
+ availableTargetsList.remove(startOfSubTargets, endOfSubTargets);
+ }
+}
diff --git a/org.eclipse.ui.externaltools/Ant Tools Support/org/eclipse/ui/externaltools/internal/ant/dialog/AntTargetsGroupPropertyPage.java b/org.eclipse.ui.externaltools/Ant Tools Support/org/eclipse/ui/externaltools/internal/ant/dialog/AntTargetsGroupPropertyPage.java
new file mode 100644
index 000000000..87dedece2
--- /dev/null
+++ b/org.eclipse.ui.externaltools/Ant Tools Support/org/eclipse/ui/externaltools/internal/ant/dialog/AntTargetsGroupPropertyPage.java
@@ -0,0 +1,42 @@
+package org.eclipse.ui.externaltools.internal.ant.dialog;
+
+/**********************************************************************
+Copyright (c) 2002 IBM Corp. and others. All rights reserved.
+This file is 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:
+**********************************************************************/
+
+import org.eclipse.ui.externaltools.dialog.ExternalToolGroupPropertyPage;
+import org.eclipse.ui.externaltools.internal.model.IHelpContextIds;
+import org.eclipse.ui.externaltools.model.ExternalTool;
+
+/**
+ * Property page to show the Ant targets group.
+ */
+public class AntTargetsGroupPropertyPage extends ExternalToolGroupPropertyPage {
+
+ /**
+ * Creates the Ant targets group property page.
+ */
+ public AntTargetsGroupPropertyPage() {
+ super(new AntTargetsGroup(), IHelpContextIds.ANT_TARGETS_PROPERTY_PAGE);
+ }
+
+ /*
+ * (non-Javadoc)
+ * Method declared on DialogPage.
+ */
+ public void setVisible(boolean visible) {
+ super.setVisible(visible);
+
+ ExternalTool tool = getExternalTool();
+ if (tool != null) {
+ AntTargetsGroup group = (AntTargetsGroup) getGroup();
+ if (group != null)
+ group.setFileLocation(tool.getLocation());
+ }
+ }
+}
diff --git a/org.eclipse.ui.externaltools/Ant Tools Support/org/eclipse/ui/externaltools/internal/ant/dialog/AntTargetsGroupWizardPage.java b/org.eclipse.ui.externaltools/Ant Tools Support/org/eclipse/ui/externaltools/internal/ant/dialog/AntTargetsGroupWizardPage.java
new file mode 100644
index 000000000..cfb241842
--- /dev/null
+++ b/org.eclipse.ui.externaltools/Ant Tools Support/org/eclipse/ui/externaltools/internal/ant/dialog/AntTargetsGroupWizardPage.java
@@ -0,0 +1,46 @@
+package org.eclipse.ui.externaltools.internal.ant.dialog;
+
+/**********************************************************************
+Copyright (c) 2002 IBM Corp. and others. All rights reserved.
+This file is 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:
+**********************************************************************/
+
+import org.eclipse.ui.externaltools.dialog.ExternalToolGroupWizardPage;
+import org.eclipse.ui.externaltools.group.ExternalToolMainGroup;
+
+/**
+ * Wizard page that will display an <code>AntTargetsGroup</code>
+ * as its content.
+ */
+public class AntTargetsGroupWizardPage extends ExternalToolGroupWizardPage {
+ private ExternalToolMainGroup mainGroup;
+
+ /**
+ * Creates a wizard page for the specified group.
+ *
+ * @param pageName name given to the page
+ * @param group the ant targets group to display
+ * @param mainGroup the main group for access to the location
+ * @param helpContextId the help context id for this page
+ */
+ public AntTargetsGroupWizardPage(String pageName, AntTargetsGroup group, ExternalToolMainGroup mainGroup, String helpContextId) {
+ super(pageName, group, helpContextId);
+ this.mainGroup = mainGroup;
+ }
+
+ /*
+ * (non-Javadoc)
+ * Method declared on DialogPage.
+ */
+ public void setVisible(boolean visible) {
+ super.setVisible(visible);
+ AntTargetsGroup group = (AntTargetsGroup) getGroup();
+ if (group != null && mainGroup != null) {
+ group.setFileLocation(mainGroup.getLocationFieldValue());
+ }
+ }
+}
diff --git a/org.eclipse.ui.externaltools/Ant Tools Support/org/eclipse/ui/externaltools/internal/ant/dialog/AntTasksPage.java b/org.eclipse.ui.externaltools/Ant Tools Support/org/eclipse/ui/externaltools/internal/ant/dialog/AntTasksPage.java
new file mode 100644
index 000000000..c69124522
--- /dev/null
+++ b/org.eclipse.ui.externaltools/Ant Tools Support/org/eclipse/ui/externaltools/internal/ant/dialog/AntTasksPage.java
@@ -0,0 +1,184 @@
+package org.eclipse.ui.externaltools.internal.ant.dialog;
+
+/**********************************************************************
+Copyright (c) 2002 IBM Corp. and others. All rights reserved.
+This file is 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:
+**********************************************************************/
+
+import org.eclipse.ant.core.Task;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.TabFolder;
+import org.eclipse.swt.widgets.TabItem;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.externaltools.internal.model.ToolMessages;
+
+/**
+ * Sub-page that allows the user to enter custom tasks
+ * to be used when running Ant build files.
+ */
+public class AntTasksPage extends AntPage {
+ private static final int ADD_TASK_BUTTON = IDialogConstants.CLIENT_ID + 1;
+ private static final int EDIT_TASK_BUTTON = IDialogConstants.CLIENT_ID + 2;
+ private static final int REMOVE_BUTTON = IDialogConstants.CLIENT_ID + 3;
+
+ private final AntTasksLabelProvider labelProvider = new AntTasksLabelProvider();
+ private Button editButton;
+ private Button removeButton;
+
+ /**
+ * Creates an instance.
+ */
+ public AntTasksPage(AntPreferencePage preferencePage) {
+ super(preferencePage);
+ }
+
+ /* (non-Javadoc)
+ * Method declared on AntPage.
+ */
+ protected void addButtonsToButtonGroup(Composite parent) {
+ createButton(parent, "AntTasksPage.addTaskButtonTitle", ADD_TASK_BUTTON); //$NON-NLS-1$
+ editButton = createButton(parent, "AntTasksPage.editTaskButtonTitle", EDIT_TASK_BUTTON); //$NON-NLS-1$
+ createSeparator(parent);
+ removeButton = createButton(parent, "AntTasksPage.removeButtonTitle", REMOVE_BUTTON); //$NON-NLS-1$
+ }
+
+ /**
+ * Allows the user to enter a custom task.
+ */
+ private void addTaskButtonPressed() {
+ String title = ToolMessages.getString("AntTasksPage.addTaskDialogTitle"); //$NON-NLS-1$
+ String msg = ToolMessages.getString("AntTasksPage.addTaskDialogDescription"); //$NON-NLS-1$
+ AddTaskDialog dialog = new AddTaskDialog(getShell(), title, msg);
+ if (dialog.open() == Dialog.CANCEL)
+ return;
+
+ Task task = new Task();
+ task.setTaskName(dialog.getTaskName());
+ task.setClassName(dialog.getClassName());
+ task.setLibrary(dialog.getLibrary());
+ addContent(task);
+ }
+
+ /* (non-Javadoc)
+ * Method declared on AntPage.
+ */
+ protected void buttonPressed(int buttonId) {
+ switch (buttonId) {
+ case ADD_TASK_BUTTON :
+ addTaskButtonPressed();
+ break;
+ case EDIT_TASK_BUTTON :
+ editTaskButtonPressed();
+ break;
+ case REMOVE_BUTTON :
+ removeButtonPressed();
+ break;
+ }
+ }
+
+ /**
+ * Creates the tab item that contains this sub-page.
+ */
+ public TabItem createTabItem(TabFolder folder) {
+ TabItem item = new TabItem(folder, SWT.NONE);
+ item.setText(ToolMessages.getString("AntTasksPage.title")); //$NON-NLS-1$
+ item.setImage(labelProvider.getTaskImage());
+ item.setData(this);
+ item.setControl(createControl(folder));
+ return item;
+ }
+
+ /**
+ * Allows the user to edit a custom Ant task.
+ */
+ private void editTaskButtonPressed() {
+ String title = ToolMessages.getString("AntTasksPage.editTaskDialogTitle"); //$NON-NLS-1$
+ String msg = ToolMessages.getString("AntTasksPage.editTaskDialogDescription"); //$NON-NLS-1$
+ AddTaskDialog dialog = new AddTaskDialog(getShell(), title, msg);
+ Task task = (Task) getSelectedElement();
+ if (task == null)
+ return;
+ dialog.setClassName(task.getClassName());
+ dialog.setTaskName(task.getTaskName());
+ dialog.setLibrary(task.getLibrary());
+ if (dialog.open() == Dialog.CANCEL)
+ return;
+
+ task.setTaskName(dialog.getTaskName());
+ task.setClassName(dialog.getClassName());
+ task.setLibrary(dialog.getLibrary());
+ updateContent(task);
+ }
+
+ /* (non-Javadoc)
+ * Method declared on AntPage.
+ */
+ protected ITableLabelProvider getLabelProvider() {
+ return labelProvider;
+ }
+
+ /* (non-Javadoc)
+ * Method declared on AntPage.
+ */
+ protected void tableSelectionChanged(IStructuredSelection newSelection) {
+ int size = newSelection.size();
+ editButton.setEnabled(size == 1);
+ removeButton.setEnabled(size > 0);
+ }
+
+
+ /**
+ * Label provider for task elements
+ */
+ private static final class AntTasksLabelProvider extends LabelProvider implements ITableLabelProvider {
+ private Image taskImage;
+
+ /**
+ * Creates an instance.
+ */
+ public AntTasksLabelProvider() {
+ }
+
+ /* (non-Javadoc)
+ * Method declared on IBaseLabelProvider.
+ */
+ public void dispose() {
+ // Task image is shared, do not dispose.
+ taskImage = null;
+ }
+
+ /* (non-Javadoc)
+ * Method declared on ITableLabelProvider.
+ */
+ public Image getColumnImage(Object element, int columnIndex) {
+ return getTaskImage();
+ }
+
+ /* (non-Javadoc)
+ * Method declared on ITableLabelProvider.
+ */
+ public String getColumnText(Object element, int columnIndex) {
+ Task task = (Task) element;
+ return task.getTaskName() + " (" + task.getLibrary().getFile() + ": " + task.getClassName() + ")"; //$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$
+ }
+
+ public Image getTaskImage() {
+ if (taskImage == null)
+ taskImage = PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_TASK_TSK);
+ return taskImage;
+ }
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.ui.externaltools/Ant Tools Support/org/eclipse/ui/externaltools/internal/ant/dialog/AntTypesPage.java b/org.eclipse.ui.externaltools/Ant Tools Support/org/eclipse/ui/externaltools/internal/ant/dialog/AntTypesPage.java
new file mode 100644
index 000000000..4a0d7cb05
--- /dev/null
+++ b/org.eclipse.ui.externaltools/Ant Tools Support/org/eclipse/ui/externaltools/internal/ant/dialog/AntTypesPage.java
@@ -0,0 +1,189 @@
+package org.eclipse.ui.externaltools.internal.ant.dialog;
+
+/**********************************************************************
+Copyright (c) 2002 IBM Corp. and others. All rights reserved.
+This file is 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:
+**********************************************************************/
+
+import org.eclipse.ant.core.Type;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.TabFolder;
+import org.eclipse.swt.widgets.TabItem;
+import org.eclipse.ui.externaltools.internal.model.ExternalToolsPlugin;
+import org.eclipse.ui.externaltools.internal.model.ToolMessages;
+
+/**
+ * Sub-page that allows the user to enter custom types
+ * to be used when running Ant build files.
+ */
+public class AntTypesPage extends AntPage {
+ private static final int ADD_TYPE_BUTTON = IDialogConstants.CLIENT_ID + 1;
+ private static final int EDIT_TYPE_BUTTON = IDialogConstants.CLIENT_ID + 2;
+ private static final int REMOVE_BUTTON = IDialogConstants.CLIENT_ID + 3;
+
+ private final AntTypesLabelProvider labelProvider = new AntTypesLabelProvider();
+ private Button editButton;
+ private Button removeButton;
+
+ /**
+ * Creates an instance.
+ */
+ public AntTypesPage(AntPreferencePage preferencePage) {
+ super(preferencePage);
+ }
+
+ /* (non-Javadoc)
+ * Method declared on AntPage.
+ */
+ protected void addButtonsToButtonGroup(Composite parent) {
+ createButton(parent, "AntTypesPage.addTypeButtonTitle", ADD_TYPE_BUTTON); //$NON-NLS-1$
+ editButton = createButton(parent, "AntTypesPage.editTypeButtonTitle", EDIT_TYPE_BUTTON); //$NON-NLS-1$
+ createSeparator(parent);
+ removeButton = createButton(parent, "AntTypesPage.removeButtonTitle", REMOVE_BUTTON); //$NON-NLS-1$
+ }
+
+ /**
+ * Allows the user to enter a custom type.
+ */
+ private void addTypeButtonPressed() {
+ String title = ToolMessages.getString("AntTypesPage.addTypeDialogTitle"); //$NON-NLS-1$
+ String msg = ToolMessages.getString("AntTypesPage.addTypeDialogDescription"); //$NON-NLS-1$
+ AddTaskDialog dialog = new AddTaskDialog(getShell(), title, msg);
+ if (dialog.open() == Dialog.CANCEL)
+ return;
+
+ Type type = new Type();
+ type.setTypeName(dialog.getTaskName());
+ type.setClassName(dialog.getClassName());
+ type.setLibrary(dialog.getLibrary());
+ addContent(type);
+ }
+
+ /* (non-Javadoc)
+ * Method declared on AntPage.
+ */
+ protected void buttonPressed(int buttonId) {
+ switch (buttonId) {
+ case ADD_TYPE_BUTTON :
+ addTypeButtonPressed();
+ break;
+ case EDIT_TYPE_BUTTON :
+ editTypeButtonPressed();
+ break;
+ case REMOVE_BUTTON :
+ removeButtonPressed();
+ break;
+ }
+ }
+
+ /**
+ * Creates the tab item that contains this sub-page.
+ */
+ public TabItem createTabItem(TabFolder folder) {
+ TabItem item = new TabItem(folder, SWT.NONE);
+ item.setText(ToolMessages.getString("AntTypesPage.typesPageTitle")); //$NON-NLS-1$
+ item.setImage(labelProvider.getTypeImage());
+ item.setData(this);
+ item.setControl(createControl(folder));
+ return item;
+ }
+
+ /**
+ * Allows the user to edit a custom Ant type.
+ */
+ private void editTypeButtonPressed() {
+ String title = ToolMessages.getString("AntTypesPage.editTypeDialogTitle"); //$NON-NLS-1$
+ String msg = ToolMessages.getString("AntTypesPage.editTypeDialogDescription"); //$NON-NLS-1$
+ AddTaskDialog dialog = new AddTaskDialog(getShell(), title, msg);
+ Type type = (Type) getSelectedElement();
+ if (type == null)
+ return;
+ dialog.setClassName(type.getClassName());
+ dialog.setTaskName(type.getTypeName());
+ dialog.setLibrary(type.getLibrary());
+ if (dialog.open() == Dialog.CANCEL)
+ return;
+
+ type.setTypeName(dialog.getTaskName());
+ type.setClassName(dialog.getClassName());
+ type.setLibrary(dialog.getLibrary());
+ updateContent(type);
+ }
+
+ /* (non-Javadoc)
+ * Method declared on AntPage.
+ */
+ protected ITableLabelProvider getLabelProvider() {
+ return labelProvider;
+ }
+
+ /* (non-Javadoc)
+ * Method declared on AntPage.
+ */
+ protected void tableSelectionChanged(IStructuredSelection newSelection) {
+ int size = newSelection.size();
+ editButton.setEnabled(size == 1);
+ removeButton.setEnabled(size > 0);
+ }
+
+
+ /**
+ * Label provider for type elements
+ */
+ private static final class AntTypesLabelProvider extends LabelProvider implements ITableLabelProvider {
+ private static final String IMG_TYPE = "icons/full/obj16/type.gif"; //$NON-NLS-1$;
+ private Image typeImage;
+
+ /**
+ * Creates an instance.
+ */
+ public AntTypesLabelProvider() {
+ }
+
+ /* (non-Javadoc)
+ * Method declared on IBaseLabelProvider.
+ */
+ public void dispose() {
+ if (typeImage != null) {
+ typeImage.dispose();
+ typeImage = null;
+ }
+ }
+
+ /* (non-Javadoc)
+ * Method declared on ITableLabelProvider.
+ */
+ public Image getColumnImage(Object element, int columnIndex) {
+ return getTypeImage();
+ }
+
+ /* (non-Javadoc)
+ * Method declared on ITableLabelProvider.
+ */
+ public String getColumnText(Object element, int columnIndex) {
+ Type type = (Type) element;
+ return type.getTypeName() + " (" + type.getLibrary().getFile() + ": " + type.getClassName() + ")"; //$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$
+ }
+
+ public Image getTypeImage() {
+ if (typeImage == null) {
+ ImageDescriptor desc = ExternalToolsPlugin.getDefault().getImageDescriptor(IMG_TYPE);
+ typeImage = desc.createImage();
+ }
+ return typeImage;
+ }
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.ui.externaltools/Ant Tools Support/org/eclipse/ui/externaltools/internal/ant/model/AntFileRunner.java b/org.eclipse.ui.externaltools/Ant Tools Support/org/eclipse/ui/externaltools/internal/ant/model/AntFileRunner.java
new file mode 100644
index 000000000..ab15a8c5a
--- /dev/null
+++ b/org.eclipse.ui.externaltools/Ant Tools Support/org/eclipse/ui/externaltools/internal/ant/model/AntFileRunner.java
@@ -0,0 +1,102 @@
+package org.eclipse.ui.externaltools.internal.ant.model;
+
+/**********************************************************************
+Copyright (c) 2002 IBM Corp. and others. All rights reserved.
+This file is 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:
+**********************************************************************/
+
+import org.eclipse.ant.core.AntRunner;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.MultiStatus;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.ui.externaltools.internal.model.ToolMessages;
+import org.eclipse.ui.externaltools.model.IExternalToolRunner;
+import org.eclipse.ui.externaltools.model.IRunnerContext;
+import org.eclipse.ui.externaltools.model.IRunnerLog;
+
+/**
+ * Responsible for running ant build files.
+ */
+public class AntFileRunner implements IExternalToolRunner {
+ private static final String ANT_LOGGER_CLASS = "org.eclipse.ui.externaltools.internal.ant.logger.AntBuildLogger"; //$NON-NLS-1$
+ private static final String BASE_DIR_PREFIX = "-Dbasedir="; //$NON-NLS-1$
+
+ /**
+ * Creates an ant build file runner
+ */
+ public AntFileRunner() {
+ super();
+ }
+
+ /* (non-Javadoc)
+ * Method declared in IExternalToolsRunner.
+ */
+ public void run(IProgressMonitor monitor, IRunnerContext runnerContext, MultiStatus status) {
+ try {
+ // Determine the targets to run.
+ String value = runnerContext.getExtraAttribute(AntUtil.RUN_TARGETS_ATTRIBUTE);
+ String[] targets = AntUtil.parseRunTargets(value);
+
+ AntRunner runner = new AntRunner();
+
+ // Setup the arguments
+ String[] args = runnerContext.getExpandedArguments();
+ String[] runnerArgs = args;
+ String baseDir = runnerContext.getExpandedWorkingDirectory();
+ if (baseDir.length() > 0) {
+ // Ant requires the working directory to be specified
+ // as one of the arguments, so it needs to be appended.
+ runnerArgs = new String[args.length + 1];
+ System.arraycopy(args, 0, runnerArgs, 0, args.length);
+ runnerArgs[args.length] = BASE_DIR_PREFIX + baseDir;
+ }
+ runner.setArguments(runnerArgs);
+
+ runner.setBuildFileLocation(runnerContext.getExpandedLocation());
+ if (targets.length > 0) {
+ runner.setExecutionTargets(targets);
+ }
+ if (runnerContext.getCaptureOutput()) {
+ runner.addBuildLogger(ANT_LOGGER_CLASS);
+ }
+
+ // Print out the command used to run the ant build file.
+ if (IRunnerLog.LEVEL_VERBOSE <= runnerContext.getLog().getFilterLevel()) {
+ runnerContext.getLog().append(
+ ToolMessages.getString("AntFileRunner.callingAntRunner"), //$NON-NLS-1$;
+ IRunnerLog.LEVEL_VERBOSE);
+ runnerContext.getLog().append(
+ ToolMessages.format("AntFileRunner.antFile", new Object[] {runnerContext.getExpandedLocation()}), //$NON-NLS-1$;
+ IRunnerLog.LEVEL_VERBOSE);
+ for (int i = 1; i < runnerArgs.length; i++) {
+ runnerContext.getLog().append(
+ ToolMessages.format("AntFileRunner.argument", new Object[] {runnerArgs[i]}), //$NON-NLS-1$;
+ IRunnerLog.LEVEL_VERBOSE);
+ }
+ for (int i = 0; i < targets.length; i++) {
+ runnerContext.getLog().append(
+ ToolMessages.format("AntFileRunner.target", new Object[] {targets[i]}), //$NON-NLS-1$;
+ IRunnerLog.LEVEL_VERBOSE);
+ }
+ }
+
+ if (!monitor.isCanceled()) {
+ runner.run(monitor);
+ }
+ } catch (CoreException e) {
+ Throwable carriedException = e.getStatus().getException();
+ if (carriedException instanceof OperationCanceledException) {
+ monitor.setCanceled(true);
+ } else {
+ status.merge(e.getStatus());
+ }
+ } finally {
+ monitor.done();
+ }
+ }
+}
diff --git a/org.eclipse.ui.externaltools/Ant Tools Support/org/eclipse/ui/externaltools/internal/ant/model/AntUtil.java b/org.eclipse.ui.externaltools/Ant Tools Support/org/eclipse/ui/externaltools/internal/ant/model/AntUtil.java
new file mode 100644
index 000000000..6e05486a8
--- /dev/null
+++ b/org.eclipse.ui.externaltools/Ant Tools Support/org/eclipse/ui/externaltools/internal/ant/model/AntUtil.java
@@ -0,0 +1,116 @@
+package org.eclipse.ui.externaltools.internal.ant.model;
+
+/**********************************************************************
+Copyright (c) 2002 IBM Corp. and others. All rights reserved.
+This file is 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:
+**********************************************************************/
+
+import java.util.StringTokenizer;
+
+import org.eclipse.ant.core.AntRunner;
+import org.eclipse.ant.core.TargetInfo;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.ui.externaltools.model.IExternalToolConstants;
+
+/**
+ * General utility class dealing with Ant build files
+ */
+public final class AntUtil {
+ public static final String RUN_TARGETS_ATTRIBUTE = IExternalToolConstants.TOOL_TYPE_ANT_BUILD + ".runTargets"; //$NON-NLS-1$;
+ private static final String TARGET_SEPARATOR = ","; //$NON-NLS-1$;
+
+ /**
+ * No instances allowed
+ */
+ private AntUtil() {
+ super();
+ }
+
+ /**
+ * Returns a single-string of target names for storage.
+ *
+ * @param targets the array of target names
+ * @return a single-string representation of the target names,
+ * or <code>null</code> if the target array is empty.
+ */
+ public static String combineRunTargets(String[] targets) {
+ if (targets.length == 0)
+ return null;
+
+ if (targets.length == 1)
+ return targets[0];
+
+ StringBuffer buf = new StringBuffer();
+ for (int i = 0; i < targets.length - 1; i++) {
+ buf.append(targets[i]);
+ buf.append(TARGET_SEPARATOR);
+ }
+ buf.append(targets[targets.length - 1]);
+ return buf.toString();
+ }
+
+ /**
+ * Returns the list of all targets for the Ant build file specified by
+ * the provided IPath, or <code>null</code> if no targets found.
+ *
+ * @param path the location of the ant build file to get the targets from
+ * @return a list of <code>TargetInfo</code>
+ *
+ * @throws CoreException if file does not exist, IO problems, or invalid format.
+ */
+ public static TargetInfo[] getTargets(String path) throws CoreException {
+ AntRunner runner = new AntRunner();
+ runner.setBuildFileLocation(path);
+ return runner.getAvailableTargets();
+ }
+
+ /**
+ * Returns whether the target described by the given
+ * <code>TargetInfo</code> is an internal target.
+ *
+ * @param info the info of the target in question
+ * @return <code>true</code> if the target is an internal
+ * target, <code>false</code> otherwise
+ */
+ public static boolean isInternalTarget(TargetInfo info) {
+ return info.getName().charAt(0) == '-';
+ }
+
+ /**
+ * Returns whether the target described by the given
+ * <code>TargetInfo</code> is a sub-target.
+ *
+ * @param info the info of the target in question
+ * @return <code>true</code> if the target is a sub-target,
+ * <code>false</code> otherwise
+ */
+ public static boolean isSubTarget(TargetInfo info) {
+ return info.getDescription() == null;
+ }
+
+ /**
+ * Returns the list of target names to run
+ *
+ * @param extraAttibuteValue the external tool's extra attribute value
+ * for the run targets key.
+ * @return a list of target names
+ */
+ public static String[] parseRunTargets(String extraAttibuteValue) {
+ if (extraAttibuteValue == null)
+ return new String[0];
+
+ // Need to handle case where separator character is
+ // actually part of the target name!
+ StringTokenizer tokenizer = new StringTokenizer(extraAttibuteValue, TARGET_SEPARATOR);
+ String[] results = new String[tokenizer.countTokens()];
+ for (int i = 0; i < results.length; i++) {
+ results[i] = tokenizer.nextToken();
+ }
+
+ return results;
+ }
+}
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/action/RunExternalToolAction.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/action/RunExternalToolAction.java
new file mode 100644
index 000000000..fdeac7baf
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/action/RunExternalToolAction.java
@@ -0,0 +1,304 @@
+package org.eclipse.ui.externaltools.action;
+
+/**********************************************************************
+Copyright (c) 2002 IBM Corp. and others. All rights reserved.
+This file is 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:
+**********************************************************************/
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.MultiStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.WorkbenchException;
+import org.eclipse.ui.externaltools.internal.menu.FavoritesManager;
+import org.eclipse.ui.externaltools.internal.model.DefaultRunnerContext;
+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.internal.ui.LogConsoleDocument;
+import org.eclipse.ui.externaltools.model.ExternalTool;
+import org.eclipse.ui.externaltools.model.IExternalToolConstants;
+import org.eclipse.ui.help.WorkbenchHelp;
+
+/**
+ * Action to run an external tool.
+ * <p>
+ * This class is not intended to be extended by clients.
+ * </p>
+ */
+public class RunExternalToolAction extends Action {
+ private boolean alwaysPromptForArguments = false;
+ private IWorkbenchWindow window;
+ private ExternalTool tool;
+
+ /**
+ * Create an action to run an external tool
+ */
+ public RunExternalToolAction(IWorkbenchWindow window) {
+ this(window, false);
+ setText(ToolMessages.getString("RunExternalToolAction.text")); //$NON-NLS-1$
+ setToolTipText(ToolMessages.getString("RunExternalToolAction.toolTip")); //$NON-NLS-1$
+ setHoverImageDescriptor(ExternalToolsPlugin.getDefault().getImageDescriptor("icons/full/clcl16/run_tool.gif")); //$NON-NLS-1$
+ setImageDescriptor(ExternalToolsPlugin.getDefault().getImageDescriptor("icons/full/elcl16/run_tool.gif")); //$NON-NLS-1$
+ setDisabledImageDescriptor(ExternalToolsPlugin.getDefault().getImageDescriptor("icons/full/dlcl16/run_tool.gif")); //$NON-NLS-1$
+ WorkbenchHelp.setHelp(this, IHelpContextIds.RUN_TOOL_ACTION);
+ }
+
+ /**
+ * Create an action to run an external tool
+ */
+ protected RunExternalToolAction(IWorkbenchWindow window, boolean alwaysPromptForArguments) {
+ super();
+ this.window = window;
+ this.alwaysPromptForArguments = alwaysPromptForArguments;
+ }
+
+ /**
+ * Returns the last external tool to be run
+ * or <code>null</code> if none.
+ */
+ public static final ExternalTool getLastTool() {
+ return FavoritesManager.getInstance().getLastTool();
+ }
+
+ /**
+ * Returns the external tool that will be run
+ * or <code>null</code> if none.
+ */
+ public final ExternalTool getTool() {
+ return tool;
+ }
+
+ /**
+ * Returns the workbench window this action
+ * is to be run in.
+ */
+ protected final IWorkbenchWindow getWindow() {
+ return window;
+ }
+
+ /**
+ * Opens the console to which messages captured
+ * from the running tool's output will be logged
+ * to.
+ */
+ protected final void openLogConsole() {
+ IWorkbenchPage page = window.getActivePage();
+ try {
+ if (page != null) {
+ page.showView(IExternalToolConstants.LOG_CONSOLE_VIEW_ID);
+ }
+ } catch (PartInitException e) {
+ ExternalToolsPlugin.getDefault().getLog().log(e.getStatus());
+ }
+ LogConsoleDocument.getInstance().clearOutput();
+ }
+
+
+ /**
+ * Opens the perspective as spedified by the id.
+ *
+ * @param perspectiveId the perspective id to open
+ */
+ protected final void openPerspective(String perspectiveId) {
+ try {
+ window.getWorkbench().showPerspective(perspectiveId, window);
+ } catch (WorkbenchException e) {
+ ErrorDialog.openError(
+ window.getShell(),
+ ToolMessages.getString("RunExternalToolAction.openPerspTitle"), //$NON-NLS-1$;
+ ToolMessages.getString("RunExternalToolAction.openPerspProblem"), //$NON-NLS-1$;
+ e.getStatus());
+ ExternalToolsPlugin.getDefault().log(ToolMessages.getString("RunExternalToolAction.openPerspProblem"), e);
+ }
+ }
+
+ /**
+ * Prompts the user to change the tool's arguments before
+ * running the tool.
+ *
+ * @return <code>true</code> to continue, or <code>false</code> to stop
+ */
+ protected final boolean promptForArguments() {
+ return true;
+ }
+
+ /* (non-Javadoc)
+ * Method declared on Action.
+ */
+ public void run() {
+ if (tool == null)
+ return;
+
+ // Get the selection now to avoid invalid thread access and current
+ // active part changes when perspective and/or console is shown.
+ ISelection sel = window.getSelectionService().getSelection();
+ IWorkbenchPart activePart = window.getPartService().getActivePart();
+
+ if (alwaysPromptForArguments || tool.getPromptForArguments()) {
+ if (!promptForArguments())
+ return;
+ }
+
+ if (tool.getSaveDirtyEditors())
+ saveDirtyEditors();
+
+ if (tool.getOpenPerspective() != null)
+ openPerspective(tool.getOpenPerspective());
+
+ if (tool.getShowConsole())
+ openLogConsole();
+
+ try {
+ ToolRunnable runnable = new ToolRunnable(tool, window);
+ runnable.selection = sel;
+ runnable.activePart = activePart;
+ ProgressMonitorDialog dialog = new ProgressMonitorDialog(window.getShell());
+ dialog.run(true, true, runnable);
+ } catch (InterruptedException e) {
+ // Do nothing.
+ } catch (InvocationTargetException e) {
+ IStatus status = null;
+ if (e.getTargetException() instanceof CoreException) {
+ status = ((CoreException)e.getTargetException()).getStatus();
+ } else {
+ String msg = ToolMessages.getString("RunExternalToolAction.internalError"); //$NON-NLS-1$;
+ status = ExternalToolsPlugin.newErrorStatus(msg, e.getTargetException());
+ }
+ ErrorDialog.openError(
+ window.getShell(),
+ ToolMessages.getString("RunExternalToolAction.runErrorTitle"), //$NON-NLS-1$;
+ ToolMessages.getString("RunExternalToolAction.runProblem"), //$NON-NLS-1$;
+ status);
+ }
+
+ // Keep track of the most recently run tool.
+ FavoritesManager.getInstance().setLastTool(tool);
+ }
+
+ /**
+ * Saves all dirty editors.
+ */
+ protected final void saveDirtyEditors() {
+ IWorkbenchWindow[] windows = window.getWorkbench().getWorkbenchWindows();
+ for (int i = 0; i < windows.length; i++) {
+ IWorkbenchPage[] pages = windows[i].getPages();
+ for (int j = 0; j < pages.length; j++) {
+ pages[j].saveAllEditors(false);
+ }
+ }
+ }
+
+ /**
+ * Sets the external tool to run or
+ * <code>null</code> to not run any tool.
+ */
+ public final void setTool(ExternalTool tool) {
+ this.tool = tool;
+ setEnabled(tool != null);
+ }
+
+
+ /**
+ * Helper class that implements the runnable interface
+ * and will run the external tool.
+ */
+ private static final class ToolRunnable implements IRunnableWithProgress {
+ private IWorkbenchWindow window;
+ private ExternalTool tool;
+ private IResource selectedResource = null;
+ private DefaultRunnerContext context;
+ private MultiStatus status;
+ protected ISelection selection;
+ protected IWorkbenchPart activePart;
+
+ public ToolRunnable(ExternalTool tool, IWorkbenchWindow window) {
+ super();
+ this.tool = tool;
+ this.window = window;
+ }
+
+ private void determineSelectedResource() {
+ if (selection instanceof IStructuredSelection) {
+ Object result = ((IStructuredSelection)selection).getFirstElement();
+ if (result instanceof IResource) {
+ selectedResource = (IResource) result;
+ } else if (result instanceof IAdaptable) {
+ selectedResource = (IResource)((IAdaptable) result).getAdapter(IResource.class);
+ }
+ }
+
+ if (selectedResource == null) {
+ // If the active part is an editor, get the file resource used as input.
+ if (activePart instanceof IEditorPart) {
+ IEditorPart editorPart = (IEditorPart) activePart;
+ IEditorInput input = editorPart.getEditorInput();
+ selectedResource = (IResource) input.getAdapter(IResource.class);
+ }
+ }
+ }
+
+ private void displayErrorStatus() {
+ ErrorDialog.openError(
+ window.getShell(),
+ ToolMessages.getString("RunExternalToolAction.runErrorTitle"), //$NON-NLS-1$;
+ null,
+ status);
+ }
+
+ public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+ determineSelectedResource();
+ context = new DefaultRunnerContext(tool, selectedResource);
+ status = new MultiStatus(IExternalToolConstants.PLUGIN_ID, 0, ToolMessages.getString("RunExternalToolAction.runProblem"), null); //$NON-NLS-1$;
+
+ if (tool.getRunInBackground()) {
+ Thread thread = new Thread(new Runnable() {
+ public void run() {
+ context.run(new NullProgressMonitor(), status);
+ if (!status.isOK()) {
+ if (window.getShell() != null && !window.getShell().isDisposed()) {
+ window.getShell().getDisplay().syncExec(new Runnable() {
+ public void run() {
+ displayErrorStatus();
+ }
+ });
+ }
+ }
+ }
+ });
+ thread.start();
+ } else {
+ context.run(monitor, status);
+ if (!status.isOK())
+ if (window.getShell() != null && !window.getShell().isDisposed()) {
+ window.getShell().getDisplay().syncExec(new Runnable() {
+ public void run() {
+ displayErrorStatus();
+ }
+ });
+ }
+ }
+ };
+ }
+}
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/action/RunWithExternalToolAction.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/action/RunWithExternalToolAction.java
new file mode 100644
index 000000000..69b4c9a16
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/action/RunWithExternalToolAction.java
@@ -0,0 +1,39 @@
+package org.eclipse.ui.externaltools.action;
+
+/**********************************************************************
+Copyright (c) 2002 IBM Corp. and others. All rights reserved.
+This file is 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:
+**********************************************************************/
+
+import org.eclipse.ui.IWorkbenchWindow;
+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.help.WorkbenchHelp;
+
+/**
+ * Action to run an external tool and prompt the
+ * user for arguments beforehand.
+ * <p>
+ * This class is not intended to be extended by clients.
+ * </p>
+ */
+public class RunWithExternalToolAction extends RunExternalToolAction {
+
+ /**
+ * Create an action to run an external tool.
+ */
+ public RunWithExternalToolAction(IWorkbenchWindow window) {
+ super(window, true);
+ setText(ToolMessages.getString("RunWithExternalToolAction.text")); //$NON-NLS-1$
+ setToolTipText(ToolMessages.getString("RunWithExternalToolAction.toolTip")); //$NON-NLS-1$
+ setHoverImageDescriptor(ExternalToolsPlugin.getDefault().getImageDescriptor("icons/full/clcl16/runwith_tool.gif")); //$NON-NLS-1$
+ setImageDescriptor(ExternalToolsPlugin.getDefault().getImageDescriptor("icons/full/elcl16/runwith_tool.gif")); //$NON-NLS-1$
+ setDisabledImageDescriptor(ExternalToolsPlugin.getDefault().getImageDescriptor("icons/full/dlcl16/runwith_tool.gif")); //$NON-NLS-1$
+ WorkbenchHelp.setHelp(this, IHelpContextIds.RUN_WITH_TOOL_ACTION);
+ }
+}
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/dialog/ExternalToolGroupPropertyPage.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/dialog/ExternalToolGroupPropertyPage.java
new file mode 100644
index 000000000..796cc7040
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/dialog/ExternalToolGroupPropertyPage.java
@@ -0,0 +1,160 @@
+package org.eclipse.ui.externaltools.dialog;
+
+/**********************************************************************
+Copyright (c) 2002 IBM Corp. and others. All rights reserved.
+This file is 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:
+**********************************************************************/
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.dialogs.PropertyPage;
+import org.eclipse.ui.externaltools.group.IExternalToolGroup;
+import org.eclipse.ui.externaltools.group.IGroupDialogPage;
+import org.eclipse.ui.externaltools.model.ExternalTool;
+import org.eclipse.ui.externaltools.model.ExternalToolStorage;
+import org.eclipse.ui.help.WorkbenchHelp;
+
+/**
+ * Generic property page that will display an <code>IExternalToolGroup</code>
+ * as its content.
+ * <p>
+ * Client can extend this class.
+ * </p>
+ */
+public class ExternalToolGroupPropertyPage extends PropertyPage implements IGroupDialogPage {
+ private IExternalToolGroup group;
+ private String helpContextId;
+
+ /**
+ * Creates a property page for the specified group.
+ *
+ * @param group the external tool group component to display
+ * @param helpContextId the help context id for this page
+ */
+ protected ExternalToolGroupPropertyPage(IExternalToolGroup group, String helpContextId) {
+ super();
+ this.group = group;
+ this.helpContextId = helpContextId;
+ }
+
+ /*
+ * (non-Javadoc)
+ * Method declared on IGroupDialogPage.
+ */
+ public int convertHeightHint(int chars) {
+ return convertHeightInCharsToPixels(chars);
+ }
+
+ /* (non-Javadoc)
+ * Method declared on PreferencePage.
+ */
+ protected Control createContents(Composite parent) {
+ Composite composite = new Composite(parent, SWT.NULL);
+ composite.setLayout(new GridLayout());
+ composite.setLayoutData(new GridData(GridData.FILL_BOTH));
+ if (helpContextId != null)
+ WorkbenchHelp.setHelp(composite, helpContextId);
+
+ if (group != null) {
+ initializeDialogUnits(parent);
+ group.createContents(composite, getExternalTool(), this);
+ }
+
+ return composite;
+ }
+
+ /* (non-Javadoc)
+ * Method declared on IDialogPage.
+ */
+ public void dispose() {
+ super.dispose();
+ if (group != null)
+ group.dispose();
+ }
+
+ /**
+ * Returns the external tool using the property
+ * page element, or <code>null</code> if not possible.
+ */
+ protected ExternalTool getExternalTool() {
+ IAdaptable element = getElement();
+ if (element instanceof ExternalTool)
+ return (ExternalTool)element;
+ return (ExternalTool) element.getAdapter(ExternalTool.class);
+ }
+
+ /**
+ * Returns the external tool group component.
+ */
+ public IExternalToolGroup getGroup() {
+ return group;
+ }
+
+ /* (non-Javadoc)
+ * Method declared on PreferencePage.
+ */
+ protected void performDefaults() {
+ if (group != null) {
+ ExternalTool tool = getExternalTool();
+ if (tool != null)
+ group.restoreValues(tool);
+ }
+
+ super.performDefaults();
+ }
+
+ /* (non-Javadoc)
+ * Method declared on IPreferencePage.
+ */
+ public boolean performOk() {
+ if (group != null) {
+ if (!group.isValid())
+ return false;
+ ExternalTool tool = getExternalTool();
+ if (tool != null) {
+ group.updateTool(tool);
+ return ExternalToolStorage.saveTool(tool, getShell());
+ }
+ }
+
+ return super.performOk();
+ }
+
+ /* (non-Javadoc)
+ * Method declared on IGroupDialogPage.
+ */
+ public GridData setButtonGridData(Button button) {
+ return setButtonLayoutData(button);
+ }
+
+ /* (non-Javadoc)
+ * Method declared on IWorkbenchPropertyPage.
+ */
+ public void setElement(IAdaptable element) {
+ super.setElement(element);
+ if (group != null) {
+ ExternalTool tool = getExternalTool();
+ if (tool != null)
+ group.restoreValues(tool);
+ }
+ }
+
+ /* (non-Javadoc)
+ * Method declared on IGroupDialogPage.
+ */
+ public void updateValidState() {
+ if (group != null)
+ setValid(group.isValid());
+ else
+ setValid(true);
+ }
+}
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/dialog/ExternalToolGroupWizardPage.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/dialog/ExternalToolGroupWizardPage.java
new file mode 100644
index 000000000..6b219d0e5
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/dialog/ExternalToolGroupWizardPage.java
@@ -0,0 +1,102 @@
+package org.eclipse.ui.externaltools.dialog;
+
+/**********************************************************************
+Copyright (c) 2002 IBM Corp. and others. All rights reserved.
+This file is 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:
+**********************************************************************/
+
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.externaltools.group.IExternalToolGroup;
+import org.eclipse.ui.externaltools.group.IGroupDialogPage;
+import org.eclipse.ui.help.WorkbenchHelp;
+
+/**
+ * Generic wizard page that will display an <code>IExternalToolGroup</code>
+ * as its content. Client is responsible to set the page's title,
+ * description, and image descriptor.
+ * <p>
+ * This class can be used as is by clients.
+ * </p>
+ */
+public class ExternalToolGroupWizardPage extends WizardPage implements IGroupDialogPage {
+ private IExternalToolGroup group;
+ private String helpContextId;
+
+ /**
+ * Creates a wizard page for the specified group.
+ *
+ * @param pageName name given to the page
+ * @param group the external tool group component to display
+ */
+ public ExternalToolGroupWizardPage(String pageName, IExternalToolGroup group, String helpContextId) {
+ super(pageName);
+ this.group = group;
+ this.helpContextId = helpContextId;
+ }
+
+ /*
+ * (non-Javadoc)
+ * Method declared on IGroupDialogPage.
+ */
+ public int convertHeightHint(int chars) {
+ return convertHeightInCharsToPixels(chars);
+ }
+
+ /* (non-Javadoc)
+ * Method declared on IDialogPage.
+ */
+ public void createControl(Composite parent) {
+ if (group != null && getControl() == null) {
+ initializeDialogUnits(parent);
+ Composite composite = new Composite(parent, SWT.NULL);
+ composite.setLayout(new GridLayout());
+ composite.setLayoutData(new GridData(GridData.FILL_BOTH));
+ if (helpContextId != null)
+ WorkbenchHelp.setHelp(composite, helpContextId);
+ group.createContents(composite, null, this);
+ setControl(composite);
+ }
+ }
+
+ /* (non-Javadoc)
+ * Method declared on IDialogPage.
+ */
+ public void dispose() {
+ super.dispose();
+ if (group != null)
+ group.dispose();
+ }
+
+ /**
+ * Returns the external tool group component.
+ */
+ public IExternalToolGroup getGroup() {
+ return group;
+ }
+
+ /* (non-Javadoc)
+ * Method declared on IGroupDialogPage.
+ */
+ public GridData setButtonGridData(Button button) {
+ return setButtonLayoutData(button);
+ }
+
+ /* (non-Javadoc)
+ * Method declared on IGroupDialogPage.
+ */
+ public void updateValidState() {
+ if (group != null)
+ setPageComplete(group.isValid());
+ else
+ setPageComplete(true);
+ }
+}
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/dialog/ExternalToolMainGroupPropertyPage.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/dialog/ExternalToolMainGroupPropertyPage.java
new file mode 100644
index 000000000..b4887fa8f
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/dialog/ExternalToolMainGroupPropertyPage.java
@@ -0,0 +1,26 @@
+package org.eclipse.ui.externaltools.dialog;
+
+/**********************************************************************
+Copyright (c) 2002 IBM Corp. and others. All rights reserved.
+This file is 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:
+**********************************************************************/
+
+import org.eclipse.ui.externaltools.group.ExternalToolMainGroup;
+import org.eclipse.ui.externaltools.internal.model.IHelpContextIds;
+
+/**
+ * Property page to show the main group.
+ */
+public class ExternalToolMainGroupPropertyPage extends ExternalToolGroupPropertyPage {
+
+ /**
+ * Creates the main group property page.
+ */
+ public ExternalToolMainGroupPropertyPage() {
+ super(new ExternalToolMainGroup(), IHelpContextIds.TOOL_MAIN_PROPERTY_PAGE);
+ }
+}
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/dialog/ExternalToolNewWizard.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/dialog/ExternalToolNewWizard.java
new file mode 100644
index 000000000..7f5530f3c
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/dialog/ExternalToolNewWizard.java
@@ -0,0 +1,280 @@
+package org.eclipse.ui.externaltools.dialog;
+
+/**********************************************************************
+Copyright (c) 2002 IBM Corp. and others. All rights reserved.
+This file is 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:
+**********************************************************************/
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.externaltools.group.ExternalToolMainGroup;
+import org.eclipse.ui.externaltools.group.ExternalToolOptionGroup;
+import org.eclipse.ui.externaltools.group.ExternalToolRefreshGroup;
+import org.eclipse.ui.externaltools.group.IExternalToolGroup;
+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.internal.registry.ExternalToolType;
+import org.eclipse.ui.externaltools.model.ExternalTool;
+import org.eclipse.ui.externaltools.model.ExternalToolStorage;
+import org.eclipse.ui.externaltools.model.IExternalToolConstants;
+import org.eclipse.ui.externaltools.model.ToolUtil;
+
+/**
+
+
+/**
+ * Abstract wizard to create new external tools of a specified type.
+ * <p>
+ * This class can be extended by clients.
+ * </p>
+ */
+public abstract class ExternalToolNewWizard extends Wizard implements INewWizard {
+ private ExternalToolType toolType;
+ private IResource selectedResource;
+ private IWorkbench workbench;
+ protected ExternalToolMainGroup mainGroup;
+ protected ExternalToolOptionGroup optionGroup;
+ protected ExternalToolRefreshGroup refreshGroup;
+
+ /**
+ * Creates the wizard for a new external tool
+ */
+ public ExternalToolNewWizard(String toolTypeId) {
+ super();
+ setWindowTitle(ToolMessages.getString("ExternalToolNewWizard.shellTitle")); //$NON-NLS-1$
+ setDefaultPageImageDescriptor(getDefaultImageDescriptor());
+ setNeedsProgressMonitor(true);
+ toolType = ExternalToolsPlugin.getDefault().getTypeRegistry().getToolType(toolTypeId);
+ }
+
+ /**
+ * Creates a wizard page to contain the external tool
+ * main group component and adds it to the wizard page
+ * list.
+ */
+ protected void addMainPage() {
+ createMainGroup();
+ if (mainGroup == null)
+ return;
+ ExternalToolGroupWizardPage page;
+ page = new ExternalToolGroupWizardPage("mainGroupPage", mainGroup, IHelpContextIds.TOOL_MAIN_WIZARD_PAGE); //$NON-NLS-1$
+ if (toolType != null) {
+ page.setTitle(toolType.getName());
+ page.setDescription(toolType.getDescription());
+ }
+ addPage(page);
+ }
+
+ /**
+ * Creates a wizard page to contain the external tool
+ * option group component and adds it to the wizard page
+ * list.
+ */
+ protected void addOptionPage() {
+ createOptionGroup();
+ if (optionGroup == null)
+ return;
+ ExternalToolGroupWizardPage page;
+ page = new ExternalToolGroupWizardPage("optionGroupPage", optionGroup, IHelpContextIds.TOOL_OPTION_WIZARD_PAGE); //$NON-NLS-1$
+ page.setTitle(ToolMessages.getString("ExternalToolNewWizard.optionPageTitle")); //$NON-NLS-1$
+ page.setDescription(ToolMessages.getString("ExternalToolNewWizard.optionPageDescription")); //$NON-NLS-1$
+ addPage(page);
+ }
+
+ /**
+ * Creates a wizard page to contain the external tool
+ * refresh scope group component and adds it to the wizard page
+ * list.
+ */
+ protected void addRefreshPage() {
+ createRefreshGroup();
+ if (refreshGroup == null)
+ return;
+ ExternalToolGroupWizardPage page;
+ page = new ExternalToolGroupWizardPage("refreshGroupPage", refreshGroup, IHelpContextIds.TOOL_REFRESH_WIZARD_PAGE); //$NON-NLS-1$
+ page.setTitle(ToolMessages.getString("ExternalToolNewWizard.refreshPageTitle")); //$NON-NLS-1$
+ page.setDescription(ToolMessages.getString("ExternalToolNewWizard.refreshPageDescription")); //$NON-NLS-1$
+ addPage(page);
+ }
+
+ /**
+ * Creates the main group and initializes it using
+ * the information from the selected resource.
+ */
+ protected void createMainGroup() {
+ if (mainGroup != null)
+ return;
+ mainGroup = new ExternalToolMainGroup();
+ if (selectedResource != null) {
+ String path = selectedResource.getFullPath().toString();
+ String loc = ToolUtil.buildVariableTag(
+ IExternalToolConstants.VAR_RESOURCE_LOC,
+ path);
+ mainGroup.setInitialLocation(loc);
+
+ String name = path.replace(IPath.SEPARATOR, '-');
+ int start = 0;
+ while (name.charAt(start) == '-' && start < name.length())
+ start++;
+ int end = name.lastIndexOf('.');
+ if (end == -1)
+ end = name.length();
+ name = name.substring(start, end);
+ mainGroup.setInitialName(name);
+ }
+ }
+
+ /**
+ * Creates the option group and initializes it.
+ */
+ protected void createOptionGroup() {
+ if (optionGroup != null)
+ return;
+ optionGroup = new ExternalToolOptionGroup();
+ }
+
+ /**
+ * Creates the refresh scope group and initializes it.
+ */
+ protected void createRefreshGroup() {
+ if (refreshGroup != null)
+ return;
+ refreshGroup = new ExternalToolRefreshGroup();
+ }
+
+ /* (non-Javadoc)
+ * Method declared on IWizard.
+ */
+ public void dispose() {
+ super.dispose();
+ selectedResource = null;
+ }
+
+ /**
+ * Returns the selected resource.
+ */
+ protected final IResource getSelectedResource() {
+ return selectedResource;
+ }
+
+ /**
+ * Returns the default image descriptor for this wizard.
+ *
+ * @return the image descriptor or <code>null</code> if
+ * none required.
+ */
+ protected abstract ImageDescriptor getDefaultImageDescriptor();
+
+ /**
+ * Returns the workbench.
+ */
+ protected final IWorkbench getWorkbench() {
+ return workbench;
+ }
+
+ /* (non-Javadoc)
+ * Method declared on IWorkbenchWizard.
+ */
+ public void init(IWorkbench workbench, IStructuredSelection selection) {
+ this.workbench = workbench;
+
+ Object sel = selection.getFirstElement();
+ if (sel != null) {
+ if (sel instanceof IResource)
+ selectedResource = (IResource) sel;
+ else if (sel instanceof IAdaptable)
+ selectedResource = (IResource)((IAdaptable)sel).getAdapter(IResource.class);
+ }
+ }
+
+ /**
+ * Returns a new external tool object that is not yet
+ * initialized with the information collected by the
+ * wizard.
+ * <p>
+ * By default, return a new external tool using the name
+ * specified in the main page and the tool type of the wizard.
+ * </p>
+ *
+ * @return a new external tool or <code>null</code> if not possible
+ */
+ protected ExternalTool newTool() {
+ if (mainGroup == null)
+ return null;
+ String name = mainGroup.getNameFieldValue();
+ if (name == null || name.length() == 0)
+ return null;
+ if (toolType == null)
+ return null;
+ try {
+ return new ExternalTool(toolType.getId(), name);
+ } catch (CoreException e) {
+ return null;
+ }
+ }
+
+ /* (non-Javadoc)
+ * Method declared on IWizard.
+ */
+ public final boolean performFinish() {
+ ExternalTool tool = newTool();
+ if (tool == null)
+ return false;
+ if (!updateTool(tool))
+ return false;
+ return ExternalToolStorage.saveTool(tool, getShell());
+ }
+
+ /**
+ * Update the new external tool with the information
+ * collected from the user.
+ * <p>
+ * By default, ask each group to update the tool.
+ * </p>
+ *
+ * @param tool the new external tool to update
+ * @return <code>true</code> if the tool was updated properly,
+ * or <code>false</code> if the tool could not be updated
+ * and the wiard should remain open.
+ */
+ protected boolean updateTool(ExternalTool tool) {
+ if (!updateToolFromGroup(tool, mainGroup))
+ return false;
+ if (!updateToolFromGroup(tool, optionGroup))
+ return false;
+ if (!updateToolFromGroup(tool, refreshGroup))
+ return false;
+ return true;
+ }
+
+ /**
+ * Update the new external tool with the information
+ * collected from the user via an external tool group.
+ *
+ * @param tool the new external tool to update
+ * @param group the external tool group of visual component (<code>null</code> is ignored)
+ * @return <code>true</code> if the tool was updated properly,
+ * or <code>false</code> if the tool could not be updated
+ * because the group was in an invalid state.
+ */
+ protected final boolean updateToolFromGroup(ExternalTool tool, IExternalToolGroup group) {
+ if (group == null)
+ return true;
+ if (!group.isValid())
+ return false;
+ group.updateTool(tool);
+ return true;
+ }
+}
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/dialog/ExternalToolOptionGroupPropertyPage.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/dialog/ExternalToolOptionGroupPropertyPage.java
new file mode 100644
index 000000000..62314b206
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/dialog/ExternalToolOptionGroupPropertyPage.java
@@ -0,0 +1,26 @@
+package org.eclipse.ui.externaltools.dialog;
+
+/**********************************************************************
+Copyright (c) 2002 IBM Corp. and others. All rights reserved.
+This file is 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:
+**********************************************************************/
+
+import org.eclipse.ui.externaltools.group.ExternalToolOptionGroup;
+import org.eclipse.ui.externaltools.internal.model.IHelpContextIds;
+
+/**
+ * Property page to show the main group.
+ */
+public class ExternalToolOptionGroupPropertyPage extends ExternalToolGroupPropertyPage {
+
+ /**
+ * Creates the main group property page.
+ */
+ public ExternalToolOptionGroupPropertyPage() {
+ super(new ExternalToolOptionGroup(), IHelpContextIds.TOOL_OPTION_PROPERTY_PAGE);
+ }
+}
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/dialog/ExternalToolRefreshGroupPropertyPage.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/dialog/ExternalToolRefreshGroupPropertyPage.java
new file mode 100644
index 000000000..94e7a6c60
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/dialog/ExternalToolRefreshGroupPropertyPage.java
@@ -0,0 +1,26 @@
+package org.eclipse.ui.externaltools.dialog;
+
+/**********************************************************************
+Copyright (c) 2002 IBM Corp. and others. All rights reserved.
+This file is 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:
+**********************************************************************/
+
+import org.eclipse.ui.externaltools.group.ExternalToolRefreshGroup;
+import org.eclipse.ui.externaltools.internal.model.IHelpContextIds;
+
+/**
+ * Property page to show the main group.
+ */
+public class ExternalToolRefreshGroupPropertyPage extends ExternalToolGroupPropertyPage {
+
+ /**
+ * Creates the main group property page.
+ */
+ public ExternalToolRefreshGroupPropertyPage() {
+ super(new ExternalToolRefreshGroup(), IHelpContextIds.TOOL_REFRESH_PROPERTY_PAGE);
+ }
+}
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/group/ExternalToolGroup.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/group/ExternalToolGroup.java
new file mode 100644
index 000000000..ba6d519ff
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/group/ExternalToolGroup.java
@@ -0,0 +1,146 @@
+package org.eclipse.ui.externaltools.group;
+
+/**********************************************************************
+Copyright (c) 2002 IBM Corp. and others. All rights reserved.
+This file is 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:
+**********************************************************************/
+
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.externaltools.model.ExternalTool;
+
+/**
+ * The standard abstract implementation of an <code>IExternalToolGroup</code>.
+ */
+public abstract class ExternalToolGroup implements IExternalToolGroup {
+ /**
+ * Recommended initial size for a text field within a group.
+ */
+ public static final int SIZING_TEXT_FIELD_WIDTH = 250;
+
+ /**
+ * Dialog page this group is part of.
+ */
+ private IGroupDialogPage page;
+
+ /**
+ * Whether the group is working with an existing external
+ * tool, or a, yet to be created, new external tool.
+ */
+ private boolean isEditMode = true;
+
+ /**
+ * Whether the group's values are all valid.
+ */
+ private boolean isValid = true;
+
+ /**
+ * Creates the group.
+ */
+ public ExternalToolGroup() {
+ super();
+ }
+
+ /* (non-Javadoc)
+ * Method declared on IExternalToolGroup.
+ */
+ public final Control createContents(Composite parent, ExternalTool tool, IGroupDialogPage page) {
+ this.page = page;
+ this.isEditMode = tool != null;
+ return createGroupContents(parent, tool);
+ }
+
+ /**
+ * Creates this group's visual components.
+ *
+ * @param parent the composite to parent the group's control
+ * @param tool the external tool to be edited, or <code>null</code> for a new tool
+ * @return the control for the group
+ */
+ protected abstract Control createGroupContents(Composite parent, ExternalTool tool);
+
+ /* (non-Javadoc)
+ * Method declared on IExternalToolGroup.
+ */
+ public void dispose() {
+ page = null;
+ }
+
+ /**
+ * Returns the dialog page this group is part of.
+ *
+ * @return the dialog page this group is part of
+ */
+ protected final IGroupDialogPage getPage() {
+ return page;
+ }
+
+ /**
+ * Returns <code>true</code> if the group is editing an existing
+ * external tool, or <code>false</code> if the external tool is new
+ * and yet to be created.
+ *
+ * @return <code>true</code> if the external tool exist already, or
+ * <code>false</code> if the external tool is yet to be created.
+ */
+ protected final boolean isEditMode() {
+ return isEditMode;
+ }
+
+ /* (non-Javadoc)
+ * Method declared on IExternalToolGroup.
+ */
+ public boolean isValid() {
+ return isValid;
+ }
+
+ /**
+ * Sets whether the group's values are all valid.
+ * Updates the group's page valid state. No action
+ * taken if new valid state same as current one.
+ *
+ * @param isValid <code>true</code> if all values valid,
+ * <code>false</code> otherwise
+ */
+ protected final void setIsValid(boolean isValid) {
+ if (this.isValid != isValid) {
+ this.isValid = isValid;
+ this.page.updateValidState();
+ }
+ }
+
+ /* (non-Javadoc)
+ * Method declared on IExternalToolGroup.
+ */
+ public abstract void restoreValues(ExternalTool tool);
+
+ /* (non-Javadoc)
+ * Method declared on IExternalToolGroup.
+ */
+ public void setVisible(boolean visible) {
+ }
+
+ /* (non-Javadoc)
+ * Method declared on IExternalToolGroup.
+ */
+ public abstract void updateTool(ExternalTool tool);
+
+ /* (non-Javadoc)
+ * Method declared on IExternalToolGroup.
+ */
+ public abstract void validate();
+
+
+ /**
+ * Helper class to report group validation information.
+ */
+ protected static final class ValidationStatus {
+ public boolean isValid = true;
+ public String message = null;
+ public int messageType = IGroupDialogPage.NONE;
+ }
+}
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
new file mode 100644
index 000000000..06777bb4d
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/group/ExternalToolMainGroup.java
@@ -0,0 +1,640 @@
+package org.eclipse.ui.externaltools.group;
+
+/**********************************************************************
+Copyright (c) 2002 IBM Corp. and others. All rights reserved.
+This file is 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:
+**********************************************************************/
+
+import java.io.File;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.MultiStatus;
+import org.eclipse.jface.dialogs.IMessageProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.DirectoryDialog;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.dialogs.ContainerSelectionDialog;
+import org.eclipse.ui.dialogs.SelectionDialog;
+import org.eclipse.ui.externaltools.internal.dialog.ExternalToolVariableForm;
+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.IExternalToolConstants;
+import org.eclipse.ui.externaltools.model.ToolUtil;
+import org.eclipse.ui.externaltools.variable.ExpandVariableContext;
+import org.eclipse.ui.help.WorkbenchHelp;
+import org.eclipse.ui.model.WorkbenchContentProvider;
+import org.eclipse.ui.model.WorkbenchLabelProvider;
+
+/**
+ * Group of components applicable to most external tools. This group
+ * will collect from the user the location, working directory,
+ * name, and description for the tool.
+ * <p>
+ * This group can be used or extended by clients.
+ * </p>
+ */
+public class ExternalToolMainGroup extends ExternalToolGroup {
+ private String initialLocation = ""; //$NON-NLS-1$
+ private String initialName = ""; //$NON-NLS-1$
+ private String initialWorkDirectory = ""; //$NON-NLS-1$
+ protected Text locationField;
+ protected Text workDirectoryField;
+ protected Text nameField;
+ protected Text descriptionField;
+ private Button fileLocationButton;
+ private Button workspaceLocationButton;
+ private Button fileWorkingDirectoryButton;
+ private Button workspaceWorkingDirectoryButton;
+
+ private ModifyListener modifyListener = new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ validate();
+ }
+ };
+
+ /**
+ * Creates the group
+ */
+ public ExternalToolMainGroup() {
+ super();
+ }
+
+ /* (non-Javadoc)
+ * Method declared on ExternalToolGroup.
+ */
+ protected Control createGroupContents(Composite parent, ExternalTool tool) {
+ // main composite
+ Composite mainComposite = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.marginWidth = 0;
+ layout.marginHeight = 0;
+ layout.numColumns = 2;
+ GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
+ mainComposite.setLayout(layout);
+ mainComposite.setLayoutData(gridData);
+
+ createLocationComponent(mainComposite);
+ createWorkDirectoryComponent(mainComposite);
+ createNameComponent(mainComposite);
+ createDescriptionComponent(mainComposite);
+
+ if (locationField != null) {
+ locationField.setText(isEditMode() ? tool.getLocation() : initialLocation);
+ locationField.addModifyListener(modifyListener);
+ }
+
+ if (workDirectoryField != null) {
+ workDirectoryField.setText(isEditMode() ? tool.getWorkingDirectory() : initialWorkDirectory);
+ workDirectoryField.addModifyListener(modifyListener);
+ }
+
+ if (nameField != null) {
+ nameField.setText(isEditMode() ? tool.getName() : initialName);
+ if (isEditMode())
+ nameField.setEditable(false);
+ else
+ nameField.addModifyListener(modifyListener);
+ }
+
+ validate();
+
+ return mainComposite;
+ }
+
+ /**
+ * Creates the controls needed to edit the description
+ * attribute of an external tool
+ *
+ * @param parent the composite to create the controls in
+ */
+ protected void createDescriptionComponent(Composite parent) {
+ Label label = new Label(parent, SWT.NONE);
+ label.setText(ToolMessages.getString("ExternalToolMainGroup.descriptionLabel")); //$NON-NLS-1$
+ GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ data.horizontalSpan = 2;
+ label.setLayoutData(data);
+
+ descriptionField = new Text(parent, SWT.BORDER);
+ data = new GridData(GridData.FILL_HORIZONTAL);
+ data.widthHint = SIZING_TEXT_FIELD_WIDTH;
+ descriptionField.setLayoutData(data);
+
+ createSpacer(parent);
+ }
+
+ /**
+ * Creates the controls needed to edit the location
+ * attribute of an external tool
+ *
+ * @param parent the composite to create the controls in
+ */
+ protected void createLocationComponent(Composite parent) {
+ Label label = new Label(parent, SWT.NONE);
+ label.setText(ToolMessages.getString("ExternalToolMainGroup.locationLabel")); //$NON-NLS-1$
+ GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ data.horizontalSpan = 2;
+ label.setLayoutData(data);
+
+ locationField = new Text(parent, SWT.BORDER);
+ data = new GridData(GridData.FILL_HORIZONTAL);
+ data.widthHint = SIZING_TEXT_FIELD_WIDTH;
+ data.verticalSpan= 2;
+ locationField.setLayoutData(data);
+
+ workspaceLocationButton= createPushButton(parent, "Browse Workspace...");
+ fileLocationButton= createPushButton(parent, "Browse File System...");
+
+ createSpacer(parent);
+ }
+
+ private Button createPushButton(Composite parent, String label) {
+ Button button= new Button(parent, SWT.PUSH );
+ button.setText(ToolMessages.getString(label));
+ button.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ handleButtonPressed((Button)e.widget);
+ }
+ });
+ getPage().setButtonGridData(button);
+ return button;
+ }
+
+ private void handleButtonPressed(Button button) {
+ String text= null;
+ Text field= null;
+ if (button == fileLocationButton) {
+ text= getFileLocation();
+ field= locationField;
+ } else if (button == workspaceLocationButton) {
+ text= getWorkspaceLocation();
+ field= locationField;
+ } else if (button == fileWorkingDirectoryButton) {
+ DirectoryDialog dialog = new DirectoryDialog(getShell(), SWT.SAVE);
+ dialog.setMessage("Select a directory");
+ dialog.setFilterPath(workDirectoryField.getText());
+ text= dialog.open();
+ field= workDirectoryField;
+ } else if (button == workspaceWorkingDirectoryButton) {
+ ContainerSelectionDialog containerDialog;
+ containerDialog = new ContainerSelectionDialog(
+ getShell(),
+ ResourcesPlugin.getWorkspace().getRoot(),
+ false,
+ "Select a directory");
+ containerDialog.open();
+ Object[] resource = containerDialog.getResult();
+ if (resource != null && resource.length > 0) {
+ text= ToolUtil.buildVariableTag(IExternalToolConstants.VAR_WORKSPACE_LOC, ((IPath)resource[0]).toString());
+ }
+ field= workDirectoryField;
+ }
+ if (text != null && field != null) {
+ field.setText(text);
+ }
+ }
+
+ private String getFileLocation() {
+ FileDialog fileDialog = new FileDialog(getShell(), SWT.NONE);
+ fileDialog.setFileName(locationField.getText());
+ return fileDialog.open();
+ }
+
+ /**
+ * Prompts the user for a workspace location and returns the location
+ * as a String containing the workspace_loc variable or <code>null</code>
+ * if no location was obtained from the user. */
+ private String getWorkspaceLocation() {
+ ResourceSelectionDialog dialog;
+ dialog = new ResourceSelectionDialog(getShell(), ResourcesPlugin.getWorkspace().getRoot(), "Select a resource");
+ dialog.open();
+ Object[] results = dialog.getResult();
+ if (results == null || results.length < 1) {
+ return null;
+ }
+ IResource resource = (IResource)results[0];
+ StringBuffer buf = new StringBuffer();
+ ToolUtil.buildVariableTag(IExternalToolConstants.VAR_WORKSPACE_LOC, resource.getFullPath().toString(), buf);
+ return buf.toString();
+ }
+
+ /**
+ * Internal dialog to show available resources from which
+ * the user can select one
+ */
+ private class ResourceSelectionDialog extends SelectionDialog {
+ String labelText;
+ IContainer root;
+ TreeViewer wsTree;
+
+ public ResourceSelectionDialog(Shell parent, IContainer root, String labelText) {
+ super(parent);
+ this.root = root;
+ this.labelText = labelText;
+ setShellStyle(getShellStyle() | SWT.RESIZE);
+ setTitle(ToolMessages.getString("EditDialog.browseWorkspaceTitle")); //$NON-NLS-1$
+ WorkbenchHelp.setHelp(parent, IHelpContextIds.RESOURCE_SELECTION_DIALOG);
+ }
+
+ /* (non-Javadoc)
+ * Method declared on Dialog.
+ */
+ protected Control createDialogArea(Composite parent) {
+ // create composite
+ Composite dialogArea = (Composite)super.createDialogArea(parent);
+
+ Label label = new Label(dialogArea, SWT.LEFT);
+ label.setText(labelText);
+
+ Tree tree = new Tree(dialogArea, SWT.H_SCROLL | SWT.V_SCROLL | SWT.SINGLE | SWT.BORDER);
+ GridData data = new GridData(GridData.FILL_BOTH);
+ data.heightHint = 300;
+ data.widthHint = 300;
+ tree.setLayoutData(data);
+ wsTree = new TreeViewer(tree);
+ wsTree.setContentProvider(new WorkbenchContentProvider());
+ wsTree.setLabelProvider(new WorkbenchLabelProvider());
+ wsTree.setInput(root);
+
+ return dialogArea;
+ }
+
+ /* (non-Javadoc)
+ * Method declared on Dialog.
+ */
+ protected void okPressed() {
+ IStructuredSelection sel = (IStructuredSelection)wsTree.getSelection();
+ if (sel != null)
+ setSelectionResult(sel.toArray());
+ super.okPressed();
+ }
+ }
+
+ private class WorkspaceSelectionDialog extends SelectionDialog {
+ public WorkspaceSelectionDialog() {
+ super(ExternalToolMainGroup.this.getShell());
+ }
+ protected Control createDialogArea(Composite parent) {
+ Composite composite= (Composite)super.createDialogArea(parent);
+ ExternalToolVariableForm form= new ExternalToolVariableForm("Select from workspace", ExternalToolsPlugin.getDefault().getDirectoryLocationVariableRegistry().getPathLocationVariables());
+ form.createContents(composite, new IGroupDialogPage() {
+ public GridData setButtonGridData(Button button) {
+ return null;
+ }
+
+ public void setMessage(String newMessage, int newType) {
+ }
+
+ public void updateValidState() {
+ }
+
+ public int convertHeightHint(int chars) {
+ return 0;
+ }
+
+ public String getMessage() {
+ return null;
+ }
+
+ public int getMessageType() {
+ return 0;
+ }
+ });
+ return composite;
+ }
+
+ }
+
+ private Shell getShell() {
+ return PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
+ }
+
+ /**
+ * Creates the controls needed to edit the name
+ * attribute of an external tool
+ *
+ * @param parent the composite to create the controls in
+ */
+ protected void createNameComponent(Composite parent) {
+ Label label = new Label(parent, SWT.NONE);
+ label.setText(ToolMessages.getString("ExternalToolMainGroup.nameLabel")); //$NON-NLS-1$
+ GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ data.horizontalSpan = 2;
+ label.setLayoutData(data);
+
+ nameField = new Text(parent, SWT.BORDER);
+ data = new GridData(GridData.FILL_HORIZONTAL);
+ data.widthHint = SIZING_TEXT_FIELD_WIDTH;
+ nameField.setLayoutData(data);
+
+ createSpacer(parent);
+ }
+
+ /**
+ * Creates a vertical space between controls.
+ */
+ protected void createSpacer(Composite parent) {
+ Label label = new Label(parent, SWT.NONE);
+ GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ data.horizontalSpan = 2;
+ label.setLayoutData(data);
+ }
+
+ /**
+ * Creates the controls needed to edit the working directory
+ * attribute of an external tool
+ *
+ * @param parent the composite to create the controls in
+ */
+ protected void createWorkDirectoryComponent(Composite parent) {
+ Label label = new Label(parent, SWT.NONE);
+ label.setText(ToolMessages.getString("ExternalToolMainGroup.workDirLabel")); //$NON-NLS-1$
+ GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ data.horizontalSpan = 2;
+ label.setLayoutData(data);
+
+ workDirectoryField = new Text(parent, SWT.BORDER);
+ data = new GridData(GridData.FILL_HORIZONTAL);
+ data.widthHint = SIZING_TEXT_FIELD_WIDTH;
+ data.verticalSpan= 2;
+ workDirectoryField.setLayoutData(data);
+
+ workspaceWorkingDirectoryButton= createPushButton(parent, "Browse Workspace...");
+ fileWorkingDirectoryButton= createPushButton(parent, "Browse File System...");
+
+ createSpacer(parent);
+ }
+
+ /**
+ * Returns the proposed initial location for the external
+ * tool if no tool provided in the createContents.
+ *
+ * @return the proposed initial location when editing new tool.
+ */
+ public final String getInitialLocation() {
+ return initialLocation;
+ }
+
+ /**
+ * Returns the proposed initial name for the external
+ * tool if no tool provided in the createContents.
+ *
+ * @return the proposed initial name when editing new tool.
+ */
+ public final String getInitialName() {
+ return initialName;
+ }
+
+ /**
+ * Returns the proposed initial working directory for the external
+ * tool if no tool provided in the createContents.
+ *
+ * @return the proposed initial working directory when editing new tool.
+ */
+ public final String getInitialWorkDirectory() {
+ return initialWorkDirectory;
+ }
+
+ /**
+ * Returns the name given to the external tool as
+ * found in the text field, or <code>null</code> if
+ * field does not exist
+ */
+ public String getNameFieldValue() {
+ if (nameField != null)
+ return nameField.getText().trim();
+ else
+ return null;
+ }
+
+ /**
+ * Returns the location of the external tool as
+ * found in the text field, or <code>null</code> if
+ * field does not exist.
+ */
+ public String getLocationFieldValue() {
+ if (locationField != null)
+ return locationField.getText().trim();
+ else
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * Method declared on IExternalToolGroup.
+ */
+ public void restoreValues(ExternalTool tool) {
+ if (locationField != null)
+ locationField.setText(tool.getLocation());
+ if (workDirectoryField != null)
+ workDirectoryField.setText(tool.getWorkingDirectory());
+ if (nameField != null)
+ nameField.setText(tool.getName());
+ if (descriptionField != null)
+ descriptionField.setText(tool.getDescription());
+ }
+
+ /**
+ * Sets the proposed initial location for the external
+ * tool if no tool provided in the createContents.
+ *
+ * @param initialLocation the proposed initial location when editing new tool.
+ */
+ public final void setInitialLocation(String initialLocation) {
+ if (initialLocation != null)
+ this.initialLocation = initialLocation;
+ }
+
+ /**
+ * Sets the proposed initial name for the external
+ * tool if no tool provided in the createContents.
+ *
+ * @param initialName the proposed initial name when editing new tool.
+ */
+ public final void setInitialName(String initialName) {
+ if (initialName != null)
+ this.initialName = initialName;
+ }
+
+ /**
+ * Sets the proposed initial working directory for the external
+ * tool if no tool provided in the createContents.
+ *
+ * @param initialWorkDirectory the proposed initial working directory when editing new tool.
+ */
+ public final void setInitialWorkDirectory(String initialWorkDirectory) {
+ if (initialWorkDirectory != null)
+ this.initialWorkDirectory = initialWorkDirectory;
+ }
+
+ /* (non-Javadoc)
+ * Method declared on IExternalToolGroup.
+ */
+ public void updateTool(ExternalTool tool) {
+ if (locationField != null)
+ tool.setLocation(locationField.getText().trim());
+ if (workDirectoryField != null)
+ tool.setWorkingDirectory(workDirectoryField.getText().trim());
+ if (descriptionField != null)
+ tool.setDescription(descriptionField.getText().trim());
+ }
+
+ /* (non-Javadoc)
+ * Method declared on IExternalToolGroup.
+ */
+ public void validate() {
+ ValidationStatus status = new ValidationStatus();
+ validateLocation(status);
+ validateWorkDirectory(status);
+ validateName(status);
+
+ getPage().setMessage(status.message, status.messageType);
+ setIsValid(status.isValid);
+ }
+
+ /**
+ * Validates the content of the location field, and
+ * updates the validation status. Does nothing if the
+ * validation status is already invalid.
+ */
+ protected void validateLocation(ValidationStatus status) {
+ if (locationField == null || !status.isValid)
+ return;
+
+ String value = locationField.getText().trim();
+ if (value.length() < 1) {
+ status.message = ToolMessages.getString("ExternalToolMainGroup.locationRequired"); //$NON-NLS-1$
+ status.messageType = IMessageProvider.NONE;
+ status.isValid = false;
+ return;
+ }
+
+ // Translate field contents to the actual file location so we
+ // can check to ensure the file actually exists.
+ MultiStatus multiStatus = new MultiStatus(IExternalToolConstants.PLUGIN_ID, 0, "", null); //$NON-NLS-1$
+ value = ToolUtil.expandFileLocation(value, ExpandVariableContext.EMPTY_CONTEXT, multiStatus);
+ if (!multiStatus.isOK()) {
+ IStatus[] children = multiStatus.getChildren();
+ if (children.length > 0) {
+ status.message = children[0].getMessage();
+ status.messageType = IMessageProvider.WARNING;
+ }
+ status.isValid = false;
+ return;
+ }
+
+ if (value == null) { // The resource could not be found.
+ status.message = ToolMessages.getString("ExternalToolMainGroup.invalidLocation"); //$NON-NLS-1$
+ status.messageType = IMessageProvider.INFORMATION;
+ status.isValid = true;
+ return;
+ }
+
+ File file = new File(value);
+ if (!file.exists()) { // The file does not exist.
+ status.message = ToolMessages.getString("ExternalToolMainGroup.invalidLocation"); //$NON-NLS-1$
+ status.messageType = IMessageProvider.INFORMATION;
+ status.isValid = true;
+ return;
+ }
+ }
+
+ /**
+ * Validates the content of the name field, and
+ * updates the validation status. Does nothing if the
+ * validation status is already invalid.
+ */
+ protected void validateName(ValidationStatus status) {
+ if (isEditMode() || nameField == null || !status.isValid)
+ return;
+
+ String value = nameField.getText().trim();
+ if (value.length() < 1) {
+ status.message = ToolMessages.getString("ExternalToolMainGroup.nameRequired"); //$NON-NLS-1$
+ status.messageType = IMessageProvider.WARNING;
+ status.isValid = false;
+ return;
+ }
+
+ String errorText = ExternalTool.validateToolName(value);
+ if (errorText != null) {
+ status.message = errorText;
+ status.messageType = IMessageProvider.WARNING;
+ status.isValid = false;
+ return;
+ }
+
+ boolean exists = ExternalToolsPlugin.getDefault().getToolRegistry(nameField.getShell()).hasToolNamed(value);
+ if (exists) {
+ status.message = ToolMessages.getString("ExternalToolMainGroup.nameAlreadyExist"); //$NON-NLS-1$
+ status.messageType = IMessageProvider.WARNING;
+ status.isValid = false;
+ return;
+ }
+ }
+
+ /**
+ * Validates the content of the working directory field, and
+ * updates the validation status. Does nothing if the
+ * validation status is already invalid.
+ */
+ protected void validateWorkDirectory(ValidationStatus status) {
+ if (workDirectoryField == null || !status.isValid)
+ return;
+
+ String value = workDirectoryField.getText().trim();
+ if (value.length() > 0) {
+ // Translate field contents to the actual directory location so we
+ // can check to ensure the directory actually exists.
+ MultiStatus multiStatus = new MultiStatus(IExternalToolConstants.PLUGIN_ID, 0, "", null); //$NON-NLS-1$
+ value = ToolUtil.expandDirectoryLocation(value, ExpandVariableContext.EMPTY_CONTEXT, multiStatus);
+ if (!multiStatus.isOK()) {
+ IStatus[] children = multiStatus.getChildren();
+ if (children.length > 0) {
+ status.message = children[0].getMessage();
+ status.messageType = IMessageProvider.WARNING;
+ }
+ status.isValid = false;
+ return;
+ }
+
+ if (value == null) { // The resource could not be found.
+ status.message = ToolMessages.getString("ExternalToolMainGroup.invalidWorkDir"); //$NON-NLS-1$
+ status.messageType = IMessageProvider.INFORMATION;
+ status.isValid = true;
+ return;
+ }
+ File file = new File(value);
+ if (!file.exists()) { // The directory does not exist.
+ status.message = ToolMessages.getString("ExternalToolMainGroup.invalidWorkDir"); //$NON-NLS-1$
+ status.messageType = IMessageProvider.INFORMATION;
+ status.isValid = true;
+ return;
+ }
+ }
+ }
+}
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/group/ExternalToolOptionGroup.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/group/ExternalToolOptionGroup.java
new file mode 100644
index 000000000..e30961e59
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/group/ExternalToolOptionGroup.java
@@ -0,0 +1,687 @@
+package org.eclipse.ui.externaltools.group;
+
+/**********************************************************************
+Copyright (c) 2002 IBM Corp. and others. All rights reserved.
+This file is 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:
+**********************************************************************/
+
+import java.text.Collator;
+import java.util.Arrays;
+import java.util.Comparator;
+
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.IPerspectiveDescriptor;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.dialogs.SelectionDialog;
+import org.eclipse.ui.externaltools.internal.dialog.ExternalToolVariableForm;
+import org.eclipse.ui.externaltools.internal.model.ExternalToolsPlugin;
+import org.eclipse.ui.externaltools.internal.model.ToolMessages;
+import org.eclipse.ui.externaltools.internal.registry.ExternalToolVariable;
+import org.eclipse.ui.externaltools.model.ExternalTool;
+
+/**
+ * Group of components applicable to most external tools. This group
+ * will collect from the user the options:
+ * <ul>
+ * <li>log tool messages to console</li>
+ * <li>run tool in background</li>
+ * <li>open perspective on run</li>
+ * <li>tool arguments</li>
+ * <li>prompt for arguments on run</li>
+ * </ul>
+ * <p>
+ * This group can be used or extended by clients.
+ * </p>
+ */
+public class ExternalToolOptionGroup extends ExternalToolGroup {
+ private boolean initialCaptureOutput = true;
+ private boolean initialShowConsole = true;
+ private boolean initialRunBackground = true;
+ private String initialOpenPersp = null;
+ private String initialArgument = ""; //$NON-NLS-1$
+ private boolean initialPromptArg = false;
+ private boolean initialShowInMenu = false;
+ private boolean initialSaveDirtyEditors = false;
+
+ private String promptArgLabel = null;
+
+ protected Button captureOutputButton;
+ protected Button showConsoleButton;
+ protected Button runBackgroundButton;
+ protected Button openPerspButton;
+ protected Combo openPerspNameField;
+ protected Text argumentField;
+ protected Button promptArgButton;
+ protected Button showInMenuButton;
+ protected Button saveDirtyEditorsButton;
+ private Button variableButton;
+
+ private IPerspectiveDescriptor[] perspectives;
+
+ /**
+ * Creates the group
+ */
+ public ExternalToolOptionGroup() {
+ super();
+ }
+
+ /* (non-Javadoc)
+ * Method declared on ExternalToolGroup.
+ */
+ protected Control createGroupContents(Composite parent, ExternalTool tool) {
+ // main composite
+ Composite mainComposite = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.marginWidth = 0;
+ layout.marginHeight = 0;
+ GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
+ mainComposite.setLayout(layout);
+ mainComposite.setLayoutData(gridData);
+
+ createRunBackgroundComponent(mainComposite);
+ createCaptureOutputComponent(mainComposite);
+ createShowConsoleComponent(mainComposite);
+ createOpenPerspComponent(mainComposite);
+ createShowInMenuComponent(mainComposite);
+ createSaveDirtyEditorsComponent(mainComposite);
+ createSpacer(parent);
+ createArgumentComponent(mainComposite);
+ createPromptForArgumentComponent(mainComposite);
+ createSpacer(parent);
+
+ if (runBackgroundButton != null) {
+ runBackgroundButton.setSelection(isEditMode() ? tool.getRunInBackground() : initialRunBackground);
+ }
+
+ if (captureOutputButton != null) {
+ captureOutputButton.setSelection(isEditMode() ? tool.getCaptureOutput() : initialCaptureOutput);
+ }
+
+ if (showConsoleButton != null) {
+ showConsoleButton.setSelection(isEditMode() ? tool.getShowConsole() : initialShowConsole);
+ }
+
+ if (openPerspButton != null) {
+ String perspId = isEditMode() ? tool.getOpenPerspective() : initialOpenPersp;
+ openPerspButton.setSelection(perspId != null);
+ }
+
+ if (openPerspNameField != null) {
+ int index = -1;
+ if (isEditMode())
+ index = getPerspectiveIndex(tool.getOpenPerspective());
+ else
+ index = getPerspectiveIndex(initialOpenPersp);
+ if (index != -1)
+ openPerspNameField.select(index);
+ updateOpenPerspNameField();
+ }
+
+ if (showInMenuButton != null) {
+ showInMenuButton.setSelection(isEditMode() ? tool.getShowInMenu() : initialShowInMenu);
+ }
+
+ if (saveDirtyEditorsButton != null) {
+ saveDirtyEditorsButton.setSelection(isEditMode() ? tool.getSaveDirtyEditors() : initialSaveDirtyEditors);
+ }
+
+ if (argumentField != null) {
+ argumentField.setText(isEditMode() ? tool.getArguments() : initialArgument);
+ }
+
+ if (promptArgButton != null) {
+ promptArgButton.setSelection(isEditMode() ? tool.getPromptForArguments() : initialPromptArg);
+ }
+
+ validate();
+
+ return mainComposite;
+ }
+
+ /**
+ * Creates the controls needed to edit the argument and
+ * prompt for argument attributes of an external tool
+ *
+ * @param parent the composite to create the controls in
+ */
+ protected void createArgumentComponent(Composite parent) {
+ Composite comp = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.marginWidth = 0;
+ layout.marginHeight = 0;
+ layout.numColumns = 2;
+ GridData data = new GridData(GridData.FILL_HORIZONTAL);
+ comp.setLayout(layout);
+ comp.setLayoutData(data);
+
+ Label label = new Label(comp, SWT.NONE);
+ label.setText(ToolMessages.getString("ExternalToolOptionGroup.argumentLabel")); //$NON-NLS-1$
+ data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ data.horizontalSpan = 2;
+ label.setLayoutData(data);
+
+ argumentField = new Text(comp, SWT.BORDER);
+ data = new GridData(GridData.FILL_HORIZONTAL);
+ data.widthHint = SIZING_TEXT_FIELD_WIDTH;
+ argumentField.setLayoutData(data);
+
+ variableButton= new Button(comp, SWT.PUSH);
+ variableButton.setText(ToolMessages.getString("ExternalToolOptionGroup.argumentVariableLabel")); //$NON-NLS-1$
+ variableButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ handleButtonPressed((Button)e.getSource());
+ }
+ });
+ getPage().setButtonGridData(variableButton);
+
+ Label instruction = new Label(comp, SWT.NONE);
+ instruction.setText(ToolMessages.getString("ExternalToolOptionGroup.argumentInstruction")); //$NON-NLS-1$
+ data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ data.horizontalSpan = 2;
+ instruction.setLayoutData(data);
+ }
+
+ private void handleButtonPressed(Button button) {
+ if (button == variableButton) {
+ VariableSelectionDialog dialog= new VariableSelectionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
+ if (dialog.open() == SelectionDialog.OK) {
+ Object[] objects= dialog.getResult();
+ argumentField.append(((ExternalToolVariable)objects[0]).getTag());
+ }
+ }
+ }
+
+ private class VariableSelectionDialog extends SelectionDialog {
+ private VariableSelectionDialog(Shell parent) {
+ super(parent);
+ setTitle("Select variable");
+ }
+ protected Control createDialogArea(Composite parent) {
+ // Create the dialog area
+ Composite composite= (Composite)super.createDialogArea(parent);
+ ExternalToolVariable[] variables= ExternalToolsPlugin.getDefault().getArgumentVariableRegistry().getArgumentVariables();
+ ExternalToolVariableForm form= new ExternalToolVariableForm("Choose a variable", variables);
+ form.createContents(composite, new IGroupDialogPage() {
+ public GridData setButtonGridData(Button button) {
+ GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ data.heightHint = convertVerticalDLUsToPixels(IDialogConstants.BUTTON_HEIGHT);
+ int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
+ data.widthHint = Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
+ button.setLayoutData(data);
+ return data;
+ }
+
+ public void setMessage(String newMessage, int newType) {
+ VariableSelectionDialog.this.setMessage(newMessage);
+ }
+
+ public void updateValidState() {
+ }
+
+ public int convertHeightHint(int chars) {
+ return convertHeightInCharsToPixels(chars);
+ }
+
+ public String getMessage() {
+ return VariableSelectionDialog.this.getMessage();
+ }
+
+ public int getMessageType() {
+ return 0;
+ }
+ });
+ return composite;
+ }
+
+ }
+
+ /**
+ * Creates the controls needed to edit the show console
+ * attribute of an external tool
+ *
+ * @param parent the composite to create the controls in
+ */
+ protected void createCaptureOutputComponent(Composite parent) {
+ captureOutputButton = new Button(parent, SWT.CHECK);
+ captureOutputButton.setText(ToolMessages.getString("ExternalToolOptionGroup.captureOutputLabel")); //$NON-NLS-1$
+ GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ captureOutputButton.setLayoutData(data);
+ }
+
+ /**
+ * Creates the controls needed to edit the prompt for argument
+ * attribute of an external tool
+ *
+ * @param parent the composite to create the controls in
+ */
+ protected void createPromptForArgumentComponent(Composite parent) {
+ promptArgButton = new Button(parent, SWT.CHECK);
+ if (promptArgLabel != null)
+ promptArgButton.setText(promptArgLabel);
+ else
+ promptArgButton.setText(ToolMessages.getString("ExternalToolOptionGroup.promptArgLabel")); //$NON-NLS-1$
+ GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ promptArgButton.setLayoutData(data);
+ }
+
+ /**
+ * Creates the controls needed to edit the open perspective
+ * attribute of an external tool
+ *
+ * @param parent the composite to create the controls in
+ */
+ protected void createOpenPerspComponent(Composite parent) {
+ Composite comp = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.marginWidth = 0;
+ layout.marginHeight = 0;
+ layout.numColumns = 2;
+ GridData data = new GridData(GridData.FILL_HORIZONTAL);
+ comp.setLayout(layout);
+ comp.setLayoutData(data);
+
+ openPerspButton = new Button(comp, SWT.CHECK);
+ openPerspButton.setText(ToolMessages.getString("ExternalToolOptionGroup.openPerspLabel")); //$NON-NLS-1$
+ data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ openPerspButton.setLayoutData(data);
+ openPerspButton.addSelectionListener(new SelectionListener() {
+ public void widgetSelected(SelectionEvent e) {
+ updateOpenPerspNameField();
+ }
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
+ });
+
+ openPerspNameField = new Combo(comp, (SWT.DROP_DOWN | SWT.READ_ONLY));
+ openPerspNameField.setItems(getOpenPerspectiveNames());
+ data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ openPerspNameField.setLayoutData(data);
+ }
+
+ /**
+ * Creates the controls needed to edit the run in background
+ * attribute of an external tool
+ *
+ * @param parent the composite to create the controls in
+ */
+ protected void createRunBackgroundComponent(Composite parent) {
+ runBackgroundButton = new Button(parent, SWT.CHECK);
+ runBackgroundButton.setText(ToolMessages.getString("ExternalToolOptionGroup.runBackgroundLabel")); //$NON-NLS-1$
+ GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ runBackgroundButton.setLayoutData(data);
+ }
+
+ /**
+ * Creates the controls needed to edit the save dirty editors
+ * attribute of an external tool.
+ *
+ * @param parent the composite to create the controls in
+ */
+ protected void createSaveDirtyEditorsComponent(Composite parent) {
+ saveDirtyEditorsButton = new Button(parent, SWT.CHECK);
+ saveDirtyEditorsButton.setText(ToolMessages.getString("ExternalToolOptionGroup.saveDirtyEditorsLabel")); //$NON-NLS-1$
+ GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ saveDirtyEditorsButton.setLayoutData(data);
+ }
+
+ /**
+ * Creates the controls needed to edit the show console
+ * attribute of an external tool
+ *
+ * @param parent the composite to create the controls in
+ */
+ protected void createShowConsoleComponent(Composite parent) {
+ showConsoleButton = new Button(parent, SWT.CHECK);
+ showConsoleButton.setText(ToolMessages.getString("ExternalToolOptionGroup.showConsoleLabel")); //$NON-NLS-1$
+ GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ showConsoleButton.setLayoutData(data);
+ }
+
+ /**
+ * Creates the controls needed to edit the show in menu
+ * attribute of an external tool.
+ *
+ * @param parent the composite to create the controls in
+ */
+ protected void createShowInMenuComponent(Composite parent) {
+ showInMenuButton = new Button(parent, SWT.CHECK);
+ showInMenuButton.setText(ToolMessages.getString("ExternalToolOptionGroup.showInMenuLabel")); //$NON-NLS-1$
+ GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ showInMenuButton.setLayoutData(data);
+ }
+
+ /**
+ * Creates a vertical space between controls.
+ */
+ protected final void createSpacer(Composite parent) {
+ Label label = new Label(parent, SWT.NONE);
+ GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ data.horizontalSpan = 1;
+ label.setLayoutData(data);
+ }
+
+ /**
+ * Returns the proposed initial argument for the external
+ * tool if no tool provided in the createContents.
+ *
+ * @return the proposed initial argument when editing new tool.
+ */
+ public final String getInitialArgument() {
+ return initialArgument;
+ }
+
+ /**
+ * Returns the proposed initial capture output for the external
+ * tool if no tool provided in the createContents.
+ *
+ * @return the proposed initial capture output when editing new tool.
+ */
+ public final boolean getInitialCaptureOutput() {
+ return initialCaptureOutput;
+ }
+
+ /**
+ * Returns the proposed initial open perspective id for the external
+ * tool if no tool provided in the createContents.
+ *
+ * @return the proposed initial open perspective id when editing new tool.
+ */
+ public final String getInitialOpenPerspective() {
+ return initialOpenPersp;
+ }
+
+ /**
+ * Returns the proposed initial prompt for argument for the external
+ * tool if no tool provided in the createContents.
+ *
+ * @return the proposed initial prompt for argument when editing new tool.
+ */
+ public final boolean getInitialPromptForArgument() {
+ return initialPromptArg;
+ }
+
+ /**
+ * Returns the proposed initial run in background for the external
+ * tool if no tool provided in the createContents.
+ *
+ * @return the proposed initial run in background when editing new tool.
+ */
+ public final boolean getInitialRunInBackground() {
+ return initialRunBackground;
+ }
+
+ /**
+ * Returns the proposed initial save dirty editors for the external
+ * tool if no tool provided in the createContents.
+ *
+ * @return the proposed initial save dirty editors when editing new tool.
+ */
+ public final boolean getInitialSaveDirtyEditors() {
+ return initialSaveDirtyEditors;
+ }
+
+ /**
+ * Returns the proposed initial show console for the external
+ * tool if no tool provided in the createContents.
+ *
+ * @return the proposed initial show console when editing new tool.
+ */
+ public final boolean getInitialShowConsole() {
+ return initialShowConsole;
+ }
+
+ /**
+ * Returns the proposed initial show in menu for the external
+ * tool if no tool provided in the createContents.
+ *
+ * @return the proposed initial show in menu when editing new tool.
+ */
+ public final boolean getInitialShowInMenu() {
+ return initialShowInMenu;
+ }
+
+ /**
+ * Returns the list of perspective names to place in
+ * the open perspective combo box. This list contains
+ * all the available perspectives in the workbench.
+ */
+ protected final String[] getOpenPerspectiveNames() {
+ String[] names = new String[getPerspectives().length];
+
+ for (int i = 0; i < getPerspectives().length; i++) {
+ names[i] = getPerspectives()[i].getLabel();
+ }
+
+ return names;
+ }
+
+ /**
+ * Returns the ID for the perspective in the combo box
+ * at the specified index, or <code>null</code> if
+ * none.
+ */
+ protected final String getPerspectiveId(int index) {
+ if (index < 0 || index > getPerspectives().length)
+ return null;
+ return getPerspectives()[index].getId();
+ }
+
+ /**
+ * Returns the index in the perspective combo that
+ * matches the specified perspective ID, or -1 if
+ * none found.
+ */
+ protected final int getPerspectiveIndex(String perspId) {
+ if (perspId == null)
+ return -1;
+
+ for (int i = 0; i < getPerspectives().length; i++) {
+ if (perspId.equals(getPerspectives()[i].getId()))
+ return i;
+ }
+
+ return -1;
+ }
+
+ /**
+ * Returns the list of perspectives known to the workbench.
+ * The list is also sorted by name in alphabetical order.
+ */
+ protected final IPerspectiveDescriptor[] getPerspectives() {
+ if (perspectives == null) {
+ perspectives = PlatformUI.getWorkbench().getPerspectiveRegistry().getPerspectives();
+ Arrays.sort(perspectives, new Comparator() {
+ private Collator collator = Collator.getInstance();
+
+ public int compare(Object o1, Object o2) {
+ String name1 = ((IPerspectiveDescriptor)o1).getLabel();
+ String name2 = ((IPerspectiveDescriptor)o2).getLabel();
+ return collator.compare(name1, name2);
+ }
+ });
+ }
+ return perspectives;
+ }
+
+ /* (non-Javadoc)
+ * Method declared on IExternalToolGroup.
+ */
+ public void restoreValues(ExternalTool tool) {
+ if (runBackgroundButton != null)
+ runBackgroundButton.setSelection(tool.getRunInBackground());
+ if (captureOutputButton != null)
+ captureOutputButton.setSelection(tool.getCaptureOutput());
+ if (showConsoleButton != null)
+ showConsoleButton.setSelection(tool.getShowConsole());
+ if (showInMenuButton != null)
+ showInMenuButton.setSelection(tool.getShowInMenu());
+ if (saveDirtyEditorsButton != null)
+ saveDirtyEditorsButton.setSelection(tool.getSaveDirtyEditors());
+ if (openPerspButton != null)
+ openPerspButton.setSelection(tool.getOpenPerspective() != null);
+ if (openPerspNameField != null) {
+ int index = getPerspectiveIndex(tool.getOpenPerspective());
+ if (index != -1)
+ openPerspNameField.select(index);
+ }
+ updateOpenPerspNameField();
+ if (argumentField != null)
+ argumentField.setText(tool.getArguments());
+ if (promptArgButton != null)
+ promptArgButton.setSelection(tool.getPromptForArguments());
+ }
+
+ /**
+ * Sets the proposed initial argument for the external
+ * tool if no tool provided in the createContents.
+ *
+ * @param initialArgument the proposed initial argument when editing new tool.
+ */
+ public final void setInitialArgument(String initialArgument) {
+ if (initialArgument != null)
+ this.initialArgument = initialArgument;
+ }
+
+ /**
+ * Sets the proposed initial capture output for the external
+ * tool if no tool provided in the createContents.
+ *
+ * @param initialCaptureOutput the proposed initial capture output when editing new tool.
+ */
+ public final void setInitialCaptureOutput(boolean initialCaptureOutput) {
+ this.initialCaptureOutput = initialCaptureOutput;
+ }
+
+ /**
+ * Sets the proposed initial open perspective id for the external
+ * tool if no tool provided in the createContents.
+ *
+ * @param initialOpenPersp the proposed initial open perspective id when editing new tool.
+ */
+ public final void setInitialOpenPerspective(String initialOpenPersp) {
+ this.initialOpenPersp = initialOpenPersp;
+ }
+
+ /**
+ * Sets the proposed initial prompt for argument for the external
+ * tool if no tool provided in the createContents.
+ *
+ * @param initialPromptArg the proposed initial prompt for argument when editing new tool.
+ */
+ public final void setInitialPromptForArgument(boolean initialPromptArg) {
+ this.initialPromptArg = initialPromptArg;
+ }
+
+ /**
+ * Sets the proposed initial run in background for the external
+ * tool if no tool provided in the createContents.
+ *
+ * @param initialRunBackground the proposed initial run in background when editing new tool.
+ */
+ public final void setInitialRunInBackground(boolean initialRunBackground) {
+ this.initialRunBackground = initialRunBackground;
+ }
+
+ /**
+ * Sets the proposed initial save dirty editors for the external
+ * tool if no tool provided in the createContents.
+ *
+ * @param initialSaveDirtyEditors the proposed save dirty editors when editing new tool.
+ */
+ public final void setInitialSaveDirtyEditors(boolean initialSaveDirtyEditors) {
+ this.initialSaveDirtyEditors = initialSaveDirtyEditors;
+ }
+
+ /**
+ * Sets the proposed initial show console for the external
+ * tool if no tool provided in the createContents.
+ *
+ * @param initialShowConsole the proposed initial show console when editing new tool.
+ */
+ public final void setInitialShowConsole(boolean initialShowConsole) {
+ this.initialShowConsole = initialShowConsole;
+ }
+
+ /**
+ * Sets the proposed initial show in menu for the external
+ * tool if no tool provided in the createContents.
+ *
+ * @param initialShowInMenu the proposed show in menu when editing new tool.
+ */
+ public final void setInitialShowInMenu(boolean initialShowInMenu) {
+ this.initialShowInMenu = initialShowInMenu;
+ }
+
+ /**
+ * Sets the label for the prompt for argument option
+ * of the tool. Does nothing if passed <code>null</code>.
+ */
+ public final void setPromptForArgumentLabel(String label) {
+ if (label == null)
+ promptArgLabel = null;
+ else {
+ promptArgLabel = label.trim();
+ if (promptArgLabel.length() == 0)
+ promptArgLabel = null;
+ }
+ }
+
+ /**
+ * Updates the enablement state of the open perspective
+ * combo box if required.
+ */
+ protected void updateOpenPerspNameField() {
+ if (openPerspNameField != null && openPerspButton != null)
+ openPerspNameField.setEnabled(openPerspButton.getSelection());
+ }
+
+ /* (non-Javadoc)
+ * Method declared on IExternalToolGroup.
+ */
+ public void updateTool(ExternalTool tool) {
+ if (runBackgroundButton != null)
+ tool.setRunInBackground(runBackgroundButton.getSelection());
+ if (captureOutputButton != null)
+ tool.setCaptureOutput(captureOutputButton.getSelection());
+ if (showConsoleButton != null)
+ tool.setShowConsole(showConsoleButton.getSelection());
+ if (showInMenuButton != null)
+ tool.setShowInMenu(showInMenuButton.getSelection());
+ if (saveDirtyEditorsButton != null)
+ tool.setSaveDirtyEditors(saveDirtyEditorsButton.getSelection());
+ if (openPerspButton != null && openPerspNameField != null) {
+ if (openPerspButton.getSelection())
+ tool.setOpenPerspective(getPerspectiveId(openPerspNameField.getSelectionIndex()));
+ else
+ tool.setOpenPerspective(null);
+ }
+ if (argumentField != null)
+ tool.setArguments(argumentField.getText().trim());
+ if (promptArgButton != null)
+ tool.setPromptForArguments(promptArgButton.getSelection());
+ }
+
+ /* (non-Javadoc)
+ * Method declared on IExternalToolGroup.
+ */
+ public void validate() {
+ // do nothing
+ }
+}
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/group/ExternalToolRefreshGroup.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/group/ExternalToolRefreshGroup.java
new file mode 100644
index 000000000..f0f47ce12
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/group/ExternalToolRefreshGroup.java
@@ -0,0 +1,279 @@
+package org.eclipse.ui.externaltools.group;
+
+/**********************************************************************
+Copyright (c) 2002 IBM Corp. and others. All rights reserved.
+This file is 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:
+**********************************************************************/
+
+import org.eclipse.jface.dialogs.IMessageProvider;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.ui.externaltools.internal.dialog.ExternalToolVariableForm;
+import org.eclipse.ui.externaltools.internal.model.ExternalToolsPlugin;
+import org.eclipse.ui.externaltools.internal.model.ToolMessages;
+import org.eclipse.ui.externaltools.internal.registry.ExternalToolVariable;
+import org.eclipse.ui.externaltools.model.ExternalTool;
+import org.eclipse.ui.externaltools.model.ToolUtil;
+
+/**
+ * Group of components applicable to most external tools. This group
+ * will collect from the user the refresh scope to perform after
+ * the external tool is done.
+ * <p>
+ * This group can be used or extended by clients.
+ * </p>
+ */
+public class ExternalToolRefreshGroup extends ExternalToolGroup {
+ private String initialScope = null;
+ private boolean initialRecursive = true;
+
+ private ExternalToolVariableForm variableForm;
+
+ protected Button refreshField;
+ protected Button recursiveField;
+
+ /**
+ * Creates the group
+ */
+ public ExternalToolRefreshGroup() {
+ super();
+ }
+
+ /* (non-Javadoc)
+ * Method declared on ExternalToolGroup.
+ */
+ protected Control createGroupContents(Composite parent, ExternalTool tool) {
+ // main composite
+ Composite mainComposite = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.marginWidth = 0;
+ layout.marginHeight = 0;
+ layout.numColumns = 1;
+ GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
+ mainComposite.setLayout(layout);
+ mainComposite.setLayoutData(gridData);
+
+ createRefreshComponent(mainComposite);
+ createRecursiveComponent(mainComposite);
+ createScopeComponent(mainComposite);
+
+ if (refreshField != null) {
+ refreshField.setSelection(isEditMode() ? tool.getRefreshScope() != null : initialScope != null);
+ refreshField.addSelectionListener(new SelectionListener() {
+ public void widgetSelected(SelectionEvent e) {
+ updateEnabledState();
+ }
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
+ });
+ updateEnabledState();
+ }
+
+ if (recursiveField != null) {
+ recursiveField.setSelection(isEditMode() ? tool.getRefreshRecursive() : initialRecursive);
+ }
+
+ if (variableForm != null) {
+ String scope = isEditMode() ? tool.getRefreshScope() : initialScope;
+ updateForm(scope);
+ }
+
+ validate();
+
+ return mainComposite;
+ }
+
+ /**
+ * Creates the controls needed to edit the refresh recursive
+ * attribute of an external tool
+ *
+ * @param parent the composite to create the controls in
+ */
+ protected void createRecursiveComponent(Composite parent) {
+ recursiveField = new Button(parent, SWT.CHECK);
+ recursiveField.setText(ToolMessages.getString("ExternalToolRefreshGroup.recursiveLabel")); //$NON-NLS-1$
+ GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ recursiveField.setLayoutData(data);
+
+ createSpacer(parent);
+ }
+
+ /**
+ * Creates the controls needed to edit the refresh scope
+ * attribute of an external tool
+ *
+ * @param parent the composite to create the controls in
+ */
+ protected void createRefreshComponent(Composite parent) {
+ refreshField = new Button(parent, SWT.CHECK);
+ refreshField.setText(ToolMessages.getString("ExternalToolRefreshGroup.refreshLabel")); //$NON-NLS-1$
+ GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ refreshField.setLayoutData(data);
+ }
+
+ /**
+ * Creates the controls needed to edit the refresh scope variable
+ * attribute of an external tool
+ *
+ * @param parent the composite to create the controls in
+ */
+ protected void createScopeComponent(Composite parent) {
+ String label = ToolMessages.getString("ExternalToolRefreshGroup.scopeLabel"); //$NON-NLS-1$
+ ExternalToolVariable[] vars = ExternalToolsPlugin.getDefault().getRefreshVariableRegistry().getRefreshVariables();
+ variableForm = new ExternalToolVariableForm(label, vars);
+ variableForm.createContents(parent, getPage());
+ }
+
+ /**
+ * Creates a vertical space between controls.
+ */
+ protected void createSpacer(Composite parent) {
+ Label label = new Label(parent, SWT.NONE);
+ GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ data.horizontalSpan = 2;
+ label.setLayoutData(data);
+ }
+
+ /**
+ * Returns the proposed initial refresh scope for the external
+ * tool if no tool provided in the createContents.
+ *
+ * @return the proposed initial refresh scope when editing new tool.
+ */
+ public final String getInitialScope() {
+ return initialScope;
+ }
+
+ /**
+ * Returns the proposed initial refresh recursive for the external
+ * tool if no tool provided in the createContents.
+ *
+ * @return the proposed initial refresh recursive when editing new tool.
+ */
+ public final boolean getInitialRecursive() {
+ return initialRecursive;
+ }
+
+ /* (non-Javadoc)
+ * Method declared on IExternalToolGroup.
+ */
+ public boolean isValid() {
+ if (!super.isValid())
+ return false;
+
+ if (variableForm != null)
+ return variableForm.isValid();
+ else
+ return true;
+ }
+
+ /* (non-Javadoc)
+ * Method declared on IExternalToolGroup.
+ */
+ public void restoreValues(ExternalTool tool) {
+ if (refreshField != null) {
+ refreshField.setSelection(tool.getRefreshScope() != null);
+ updateEnabledState();
+ }
+ if (recursiveField != null) {
+ recursiveField.setSelection(tool.getRefreshRecursive());
+ }
+ if (variableForm != null) {
+ updateForm(tool.getRefreshScope());
+ }
+ }
+
+ /**
+ * Sets the proposed initial refresh scope for the external
+ * tool if no tool provided in the createContents.
+ *
+ * @param initialLocation the proposed initial refresh scope when editing new tool.
+ */
+ public final void setInitialScope(String initialScope) {
+ this.initialScope = initialScope;
+ }
+
+ /**
+ * Sets the proposed initial refresh recursive for the external
+ * tool if no tool provided in the createContents.
+ *
+ * @param initialName the proposed initial refresh recursive when editing new tool.
+ */
+ public final void setInitialRecursive(boolean initialRecursive) {
+ this.initialRecursive = initialRecursive;
+ }
+
+ /**
+ * Updates the enablement state of the fields.
+ */
+ protected void updateEnabledState() {
+ if (refreshField != null) {
+ if (recursiveField != null)
+ recursiveField.setEnabled(refreshField.getSelection());
+ if (variableForm != null)
+ variableForm.setEnabled(refreshField.getSelection());
+ }
+ }
+
+ /**
+ * Update the variable form to match the specified
+ * refresh scope.
+ */
+ protected final void updateForm(String refreshScope) {
+ if (variableForm == null)
+ return;
+
+ String varName = null;
+ String varValue = null;
+ if (refreshScope != null) {
+ ToolUtil.VariableDefinition varDef = ToolUtil.extractVariableTag(refreshScope, 0);
+ varName = varDef.name;
+ varValue = varDef.argument;
+ }
+ variableForm.selectVariable(varName, varValue);
+ }
+
+ /* (non-Javadoc)
+ * Method declared on IExternalToolGroup.
+ */
+ public void updateTool(ExternalTool tool) {
+ if (refreshField != null) {
+ if (refreshField.getSelection()) {
+ if (variableForm != null)
+ tool.setRefreshScope(variableForm.getSelectedVariable());
+ else
+ tool.setRefreshScope(null);
+ }
+ else
+ tool.setRefreshScope(null);
+ }
+ if (recursiveField != null)
+ tool.setRefreshRecursive(recursiveField.getSelection());
+ }
+
+
+ /**
+ * @see org.eclipse.ui.externaltools.group.IExternalToolGroup#validate()
+ */
+ public void validate() {
+ if (variableForm != null) {
+ variableForm.validate();
+ if (!variableForm.isValid())
+ return;
+ }
+
+ getPage().setMessage(null, IMessageProvider.NONE);
+ setIsValid(true);
+ }
+}
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/group/IExternalToolGroup.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/group/IExternalToolGroup.java
new file mode 100644
index 000000000..a82367988
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/group/IExternalToolGroup.java
@@ -0,0 +1,72 @@
+package org.eclipse.ui.externaltools.group;
+
+/**********************************************************************
+Copyright (c) 2002 IBM Corp. and others. All rights reserved.
+This file is 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:
+**********************************************************************/
+
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.externaltools.model.ExternalTool;
+
+/**
+ * Represents the API for a group of controls to edit
+ * a number of attributes of an external tool.
+ * <p>
+ * This interface is not intended to be extended
+ * nor implemented by clients. Clients should subclass
+ * <code>ExternalToolGroup</code> instead.
+ * </p>
+ */
+public interface IExternalToolGroup {
+
+ /**
+ * Creates this group's visual components.
+ *
+ * @param parent the composite to parent the group's control
+ * @param tool the external tool to be edited, or <code>null</code> for a new tool
+ * @param page the dialog page this group will be part of
+ * @return the control for the group
+ */
+ public Control createContents(Composite parent, ExternalTool tool, IGroupDialogPage page);
+
+ /**
+ * Disposed of the group's resources. This can be called
+ * even if <code>createContents</code> was never called.
+ */
+ public void dispose();
+
+ /**
+ * Returns whether the group's components have acceptable
+ * values.
+ *
+ * @return <code>true</code> if all values acceptable, or <code>false</code> otherwise
+ */
+ public boolean isValid();
+
+ /**
+ * Restores the group's components values from the
+ * specified external tool.
+ *
+ * @param tool the external tool to retrieve values from
+ */
+ public void restoreValues(ExternalTool tool);
+
+ /**
+ * Updates the external tool with the information
+ * collected by the group's visual components.
+ *
+ * @param tool the external tool to update
+ */
+ public void updateTool(ExternalTool tool);
+
+ /**
+ * Validates this group's current values entered by the
+ * user and updates it's valid state if needed
+ */
+ public void validate();
+}
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/group/IGroupDialogPage.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/group/IGroupDialogPage.java
new file mode 100644
index 000000000..5eabf4eac
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/group/IGroupDialogPage.java
@@ -0,0 +1,62 @@
+package org.eclipse.ui.externaltools.group;
+
+/**********************************************************************
+Copyright (c) 2002 IBM Corp. and others. All rights reserved.
+This file is 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:
+**********************************************************************/
+
+import org.eclipse.jface.dialogs.IMessageProvider;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Button;
+
+/**
+ * Represents the API for a group of visual components
+ * to access the dialog page that contains it.
+ * <p>
+ * This interface is not intended to be extended
+ * nor implemented by clients.
+ * </p>
+ */
+public interface IGroupDialogPage extends IMessageProvider {
+ /**
+ * Sets the <code>GridData</code> on the specified button to
+ * be one that is spaced for the current dialog page units.
+ *
+ * @param button the button to set the <code>GridData</code>
+ * @return the <code>GridData</code> set on the specified button
+ */
+ public GridData setButtonGridData(Button button);
+
+ /**
+ * Sets the message for this page with an indication of what type
+ * of message it is.
+ * <p>
+ * The valid message types are one of <code>NONE</code>,
+ * <code>INFORMATION</code>, <code>WARNING</code>, or <code>ERROR</code>.
+ * </p>
+ *
+ * @param newMessage the message, or <code>null</code> to clear the message
+ * @param newType the message type
+ */
+ public void setMessage(String newMessage, int newType);
+
+ /**
+ * Updates the page's valid state using the group's
+ * current valid state. This will cause the dialog's
+ * buttons dependent on the page's valid state to
+ * update to reflect the new state.
+ */
+ public void updateValidState();
+
+ /**
+ * Converts a height in characters to a height in pixels.
+ *
+ * @param chars the height in characters to be converted
+ * @return the corresponding height in pixels
+ */
+ public int convertHeightHint(int chars);
+}
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/dialog/ExternalToolVariableForm.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/dialog/ExternalToolVariableForm.java
new file mode 100644
index 000000000..34e6247c7
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/dialog/ExternalToolVariableForm.java
@@ -0,0 +1,207 @@
+package org.eclipse.ui.externaltools.internal.dialog;
+
+/**********************************************************************
+Copyright (c) 2002 IBM Corp. and others. All rights reserved.
+This file is 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:
+**********************************************************************/
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.StackLayout;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.List;
+import org.eclipse.ui.externaltools.group.IGroupDialogPage;
+import org.eclipse.ui.externaltools.internal.registry.ExternalToolVariable;
+import org.eclipse.ui.externaltools.model.ToolUtil;
+import org.eclipse.ui.externaltools.variable.IVariableComponent;
+
+/**
+ * Visual grouping of controls that allows the user to
+ * select a variable and configure it with extra
+ * information.
+ */
+public class ExternalToolVariableForm {
+ private static final int VISIBLE_ITEM_COUNT = 6;
+
+ private String variableListLabelText;
+ private ExternalToolVariable[] variables;
+ private IVariableComponent[] components;
+ private IGroupDialogPage page;
+
+ private Label variableListLabel;
+ private List variableList;
+ private Composite variableComposite;
+ private StackLayout variableLayout;
+ private int activeComponentIndex = -1;
+
+ /**
+ * Creates the visual grouping
+ *
+ * @param variableListLabelText the label text to use for identifying the list of variables
+ * @param variables the collection of variables to display to the user
+ */
+ public ExternalToolVariableForm(String variableListLabelText, ExternalToolVariable[] variables) {
+ super();
+ this.variableListLabelText = variableListLabelText;
+ this.variables = variables;
+ this.components = new IVariableComponent[variables.length];
+ }
+
+ public Composite createContents(Composite parent, IGroupDialogPage page) {
+ this.page = page;
+
+ Composite mainComposite = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.marginWidth = 0;
+ layout.marginHeight = 0;
+ layout.numColumns = 1;
+ GridData data = new GridData(GridData.FILL_BOTH);
+ mainComposite.setLayout(layout);
+ mainComposite.setLayoutData(data);
+
+ variableListLabel = new Label(mainComposite, SWT.NONE);
+ variableListLabel.setText(variableListLabelText);
+ data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ data.horizontalSpan = 1;
+ variableListLabel.setLayoutData(data);
+
+ variableList = new List(mainComposite, SWT.SINGLE | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
+ data = new GridData(GridData.FILL_HORIZONTAL);
+ data.heightHint = variableList.getItemHeight() * VISIBLE_ITEM_COUNT;
+ variableList.setLayoutData(data);
+
+ variableComposite = new Composite(mainComposite, SWT.NONE);
+ variableLayout = new StackLayout();
+ variableLayout.marginWidth = 0;
+ variableLayout.marginHeight = 0;
+ data = new GridData(GridData.FILL_BOTH);
+ variableComposite.setLayout(variableLayout);
+ variableComposite.setLayoutData(data);
+
+ createVariableComponents(data);
+
+ populateVariableList();
+
+ variableList.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ updateVariableComposite(null, false);
+ }
+ });
+
+ return mainComposite;
+ }
+
+ /**
+ * Creates the visual component for each variable
+ * and determine the initial size so the form
+ * can be layout properly.
+ */
+ private void createVariableComponents(GridData data) {
+ for (int i = 0; i < variables.length; i++) {
+ ExternalToolVariable var = variables[i];
+ components[i] = var.getComponent();
+ components[i].createContents(variableComposite, var.getTag(), page);
+ Control control = components[i].getControl();
+ if (control != null) {
+ Point newSize = control.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
+ data.widthHint = Math.max(newSize.x, data.widthHint);
+ data.heightHint = Math.max(newSize.y, data.heightHint);
+ }
+ }
+ }
+
+ /**
+ * Returns the formatted variable or <code>null</code> if
+ * none selected.
+ */
+ public String getSelectedVariable() {
+ if (activeComponentIndex != -1) {
+ String varValue = components[activeComponentIndex].getVariableValue();
+ return ToolUtil.buildVariableTag(variables[activeComponentIndex].getTag(), varValue);
+ }
+
+ return null;
+ }
+
+ /**
+ * Returns whether the current variable selection is
+ * valid, including the selected variable value.
+ */
+ public boolean isValid() {
+ if (activeComponentIndex != -1)
+ return components[activeComponentIndex].isValid();
+
+ return true;
+ }
+
+ private void populateVariableList() {
+ String[] items = new String[variables.length];
+ StringBuffer buffer = new StringBuffer(80);
+ for (int i = 0; i < variables.length; i++) {
+ ToolUtil.buildVariableTag(variables[i].getTag(), null, buffer);
+ buffer.append(" - "); //$NON-NLS-1$
+ buffer.append(variables[i].getDescription());
+ items[i] = buffer.toString();
+ buffer.setLength(0);
+ }
+ variableList.setItems(items);
+ }
+
+ public void selectVariable(String varName, String varValue) {
+ if (varName != null && varName.length() > 0) {
+ for (int i = 0; i < variables.length; i++) {
+ if (varName.equals(variables[i].getTag())) {
+ variableList.select(i);
+ updateVariableComposite(varValue, true);
+ return;
+ }
+ }
+ }
+
+ variableList.deselectAll();
+ updateVariableComposite(varValue, false);
+ }
+
+ private void setComponentVisible(int index) {
+ if (index == -1)
+ variableLayout.topControl = null;
+ else
+ variableLayout.topControl = components[index].getControl();
+ variableComposite.layout();
+ }
+
+ /**
+ * Enables or disables the variable form controls.
+ */
+ public void setEnabled(boolean enabled) {
+ variableListLabel.setEnabled(enabled);
+ variableList.setEnabled(enabled);
+ variableComposite.setVisible(enabled);
+ }
+
+ private void updateVariableComposite(String value, boolean setValue) {
+ activeComponentIndex = variableList.getSelectionIndex();
+ setComponentVisible(activeComponentIndex);
+ if (activeComponentIndex != -1 && setValue)
+ components[activeComponentIndex].setVariableValue(value);
+ }
+
+ /**
+ * Validates the current variable selection is and
+ * its value are acceptable.
+ */
+ public void validate() {
+ if (activeComponentIndex != -1)
+ components[activeComponentIndex].validate();
+ }
+}
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/menu/ExternalToolMenuDelegate.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/menu/ExternalToolMenuDelegate.java
new file mode 100644
index 000000000..9e80d407a
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/menu/ExternalToolMenuDelegate.java
@@ -0,0 +1,212 @@
+package org.eclipse.ui.externaltools.internal.menu;
+
+/**********************************************************************
+Copyright (c) 2002 IBM Corp. and others. All rights reserved.
+This file is 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:
+**********************************************************************/
+
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IMenuCreator;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.MenuAdapter;
+import org.eclipse.swt.events.MenuEvent;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.MenuItem;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.IWorkbenchWindowPulldownDelegate2;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.actions.ActionDelegate;
+import org.eclipse.ui.externaltools.action.RunExternalToolAction;
+import org.eclipse.ui.externaltools.internal.model.ExternalToolsPlugin;
+import org.eclipse.ui.externaltools.internal.model.ToolMessages;
+import org.eclipse.ui.externaltools.model.ExternalTool;
+import org.eclipse.ui.externaltools.model.IExternalToolConstants;
+
+/**
+ * This action delegate is responsible for producing the
+ * Run > External Tools sub menu contents, which includes
+ * an items to run last tool, favorite tools, and show the
+ * external tools view. Default action is to run the last tool
+ * if one exist.
+ */
+public class ExternalToolMenuDelegate extends ActionDelegate implements IWorkbenchWindowPulldownDelegate2, IMenuCreator {
+ private IWorkbenchWindow window;
+ private IAction realAction;
+
+ /**
+ * Creates the action delegate
+ */
+ public ExternalToolMenuDelegate() {
+ super();
+ }
+
+ /* (non-Javadoc)
+ * Method declared on IActionDelegate.
+ */
+ public void run(IAction action) {
+ if (action.isEnabled())
+ runLastTool();
+ }
+
+ /* (non-Javadoc)
+ * Method declared on IActionDelegate.
+ */
+ public void selectionChanged(IAction action, ISelection selection) {
+ if (realAction == null) {
+ realAction = action;
+ realAction.setMenuCreator(this);
+ }
+ }
+
+ /* (non-Javadoc)
+ * Method declared on IWorkbenchWindowPulldownDelegate.
+ */
+ public Menu getMenu(Control parent) {
+ Menu menu= new Menu(parent);
+ return createMenu(menu, false);
+ }
+
+ /* (non-Javadoc)
+ * Method declared on IWorkbenchWindowPulldownDelegate2.
+ */
+ public Menu getMenu(Menu parent) {
+ Menu menu= new Menu(parent);
+ return createMenu(menu, true);
+ }
+
+ /* (non-Javadoc)
+ * Method declared on IWorkbenchWindowActionDelegate.
+ */
+ public void dispose() {
+ }
+
+ /* (non-Javadoc)
+ * Method declared on IWorkbenchWindowActionDelegate.
+ */
+ public void init(IWorkbenchWindow window) {
+ this.window = window;
+ }
+
+ /**
+ * Creates the menu for the action
+ */
+ private Menu createMenu(Menu menu, final boolean wantFastAccess) {
+ // Add listener to repopulate the menu each time
+ // it is shown because of dynamic history list
+ menu.addMenuListener(new MenuAdapter() {
+ public void menuShown(MenuEvent e) {
+ Menu m = (Menu)e.widget;
+ MenuItem[] items = m.getItems();
+ for (int i=0; i < items.length; i++)
+ items[i].dispose();
+ populateMenu(m, wantFastAccess);
+ }
+ });
+
+ return menu;
+ }
+
+ /**
+ * Populates the menu with its items
+ */
+ private void populateMenu(Menu menu, boolean wantFastAccess) {
+ // Add a menu item to run the most recent tool.
+ MenuItem runRecent = new MenuItem(menu, SWT.NONE);
+ runRecent.setText(ToolMessages.getString("ExternalToolMenuDelegate.runRecent")); //$NON-NLS-1$
+ runRecent.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ runLastTool();
+ }
+ });
+ // Disable option if no tool has been run yet.
+ runRecent.setEnabled(getLastTool() != null);
+
+ // Add a separator.
+ new MenuItem(menu, SWT.SEPARATOR);
+
+ // Add a menu item for each tool in the favorites list.
+ ExternalTool[] tools = FavoritesManager.getInstance().getFavorites();
+ if (tools.length > 0) {
+ for (int i = 0; i < tools.length; i++) {
+ ExternalTool tool = tools[i];
+ StringBuffer label = new StringBuffer();
+ if (i < 9 && wantFastAccess) {
+ //add the numerical accelerator
+ label.append('&');
+ label.append(i+1);
+ label.append(' ');
+ }
+ label.append(tool.getName());
+ MenuItem item = new MenuItem(menu, SWT.NONE);
+ item.setText(label.toString());
+ item.setData(tool);
+ item.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ runTool((ExternalTool)e.widget.getData());
+ }
+ });
+ }
+
+ // Add a separator.
+ new MenuItem(menu, SWT.SEPARATOR);
+ }
+
+ // Add a menu item to show the external tools view.
+ MenuItem showView = new MenuItem(menu, SWT.NONE);
+ showView.setText(ToolMessages.getString("ExternalToolMenuDelegate.showView")); //$NON-NLS-1$
+ showView.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ showView();
+ }
+ });
+ }
+
+ /**
+ * Runs the specified tool
+ */
+ private void runTool(final ExternalTool tool) {
+ RunExternalToolAction runToolAction;
+ runToolAction = new RunExternalToolAction(window);
+ runToolAction.setTool(tool);
+ runToolAction.run();
+ }
+
+ /**
+ * Shows the external tool view.
+ */
+ private void showView() {
+ try {
+ IWorkbenchPage page = window.getActivePage();
+ if (page != null)
+ page.showView(IExternalToolConstants.VIEW_ID);
+ } catch (PartInitException e) {
+ ExternalToolsPlugin.getDefault().log("Unable to display the External Tools view.", e); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * Run the most recently run external tool.
+ */
+ private void runLastTool() {
+ if (getLastTool() == null)
+ return;
+ runTool(getLastTool());
+ }
+
+ /**
+ * Returns the tool which was run most recently.
+ */
+ private ExternalTool getLastTool() {
+ return FavoritesManager.getInstance().getLastTool();
+ }
+
+}
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/menu/FavoritesManager.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/menu/FavoritesManager.java
new file mode 100644
index 000000000..14f25728b
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/menu/FavoritesManager.java
@@ -0,0 +1,173 @@
+package org.eclipse.ui.externaltools.internal.menu;
+
+/**********************************************************************
+Copyright (c) 2002 IBM Corp. and others. All rights reserved.
+This file is 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:
+**********************************************************************/
+
+import java.util.Comparator;
+import java.util.Set;
+import java.util.TreeSet;
+
+import org.eclipse.ui.externaltools.internal.model.ExternalToolsPlugin;
+import org.eclipse.ui.externaltools.internal.registry.ExternalToolRegistry;
+import org.eclipse.ui.externaltools.internal.registry.ExternalToolType;
+import org.eclipse.ui.externaltools.model.ExternalTool;
+import org.eclipse.ui.externaltools.model.ExternalToolStorage;
+import org.eclipse.ui.externaltools.model.IStorageListener;
+
+/**
+ * This class manages the list of favorite external tools. These
+ * favorites are shown on the Run > External Tools menu.
+ */
+public final class FavoritesManager {
+ private static final FavoritesManager INSTANCE = new FavoritesManager();
+ private final StorageListener storageListener = new StorageListener();
+ private Set favorites = new TreeSet(new ExternalToolComparator());
+ private ExternalTool lastTool;
+
+ // Private constructor to ensure this class is a singleton.
+ private FavoritesManager() {
+ // Add the favorites manager as a storage listener so
+ // it can react to changes in the registry.
+ ExternalToolStorage.addStorageListener(storageListener);
+ updateFavorites();
+ }
+
+ /**
+ * Returns the singleton instance of the favorites manager.
+ *
+ * @return the singleton instance of the favorites manager.
+ */
+ public static FavoritesManager getInstance() {
+ return INSTANCE;
+ }
+
+ /**
+ * Add an external tool to the favorites list,
+ * if it is not already in the list.
+ */
+ private void add(ExternalTool tool) {
+ favorites.add(tool);
+ }
+
+ /**
+ * Removes an external tool from the favorites list,
+ * if it is in the list.
+ */
+ private void remove(ExternalTool tool) {
+ favorites.remove(tool);
+ }
+
+ /**
+ * Returns an array of the favorite external tools.
+ */
+ public ExternalTool[] getFavorites() {
+ return (ExternalTool[])favorites.toArray(new ExternalTool[favorites.size()]);
+ }
+
+ /**
+ * Returns the last run tool if there is one,
+ * <code>null</code> otherwise.
+ */
+ public ExternalTool getLastTool() {
+ return lastTool;
+ }
+
+ /**
+ * Sets the last run tool to be the given tool.
+ */
+ public void setLastTool(ExternalTool tool) {
+ lastTool = tool;
+ }
+
+ /**
+ * Updates the favorites list based on whether
+ * each tool in the registry is a favorite.
+ */
+ private void updateFavorites() {
+ boolean lastToolDeleted = true;
+ favorites.clear();
+
+ ExternalToolType[] types =
+ ExternalToolsPlugin.getDefault().getTypeRegistry().getToolTypes();
+ ExternalToolRegistry registry =
+ ExternalToolsPlugin.getDefault().getToolRegistry(null);
+ for (int i=0; i < types.length; i++) {
+ ExternalTool[] tools = registry.getToolsOfType(types[i].getId());
+ for (int j=0; j < tools.length; j++) {
+ if (tools[j].getShowInMenu())
+ add(tools[j]);
+ if (tools[j] == lastTool)
+ lastToolDeleted = false;
+ }
+ }
+
+ if (lastToolDeleted)
+ lastTool = null;
+ }
+
+ /**
+ * Updates the favorites list based on whether
+ * the given tool is a favorite.
+ */
+ private void updateFavorites(ExternalTool tool) {
+ if (tool.getShowInMenu())
+ add(tool);
+ else
+ remove(tool);
+ }
+
+ /**
+ * A storage listener so the favorites manager can react
+ * to changes in the registry.
+ */
+ private class StorageListener implements IStorageListener {
+ /* (non-Javadoc)
+ * Method declared on IStorageListener.
+ */
+ public void toolDeleted(ExternalTool tool) {
+ remove(tool);
+ if (lastTool == tool)
+ setLastTool(null);
+ }
+
+ /* (non-Javadoc)
+ * Method declared on IStorageListener.
+ */
+ public void toolCreated(ExternalTool tool) {
+ if (tool.getShowInMenu())
+ add(tool);
+ }
+
+ /* (non-Javadoc)
+ * Method declared on IStorageListener.
+ */
+ public void toolModified(ExternalTool tool) {
+ updateFavorites(tool);
+ }
+
+ /* (non-Javadoc)
+ * Method declared on IStorageListener.
+ */
+ public void toolsRefreshed() {
+ updateFavorites();
+ }
+ }
+
+ /**
+ * Compares external tools so they may be stored
+ * in alphabetical order.
+ */
+ private static class ExternalToolComparator implements Comparator {
+ public int compare(Object o1, Object o2) {
+ ExternalTool tool1 = (ExternalTool) o1;
+ ExternalTool tool2 = (ExternalTool) o2;
+ return (tool1.getName().compareTo(tool2.getName()));
+ }
+ }
+}
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/model/DefaultRunnerContext.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/model/DefaultRunnerContext.java
new file mode 100644
index 000000000..e157bceaa
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/model/DefaultRunnerContext.java
@@ -0,0 +1,263 @@
+package org.eclipse.ui.externaltools.internal.model;
+
+/**********************************************************************
+Copyright (c) 2002 IBM Corp. and others. All rights reserved.
+This file is 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:
+**********************************************************************/
+
+import java.io.File;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.MultiStatus;
+import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.ui.externaltools.internal.registry.ExternalToolType;
+import org.eclipse.ui.externaltools.internal.registry.ExternalToolTypeRegistry;
+import org.eclipse.ui.externaltools.internal.registry.RefreshScopeVariable;
+import org.eclipse.ui.externaltools.internal.registry.RefreshScopeVariableRegistry;
+import org.eclipse.ui.externaltools.internal.ui.LogConsoleDocument;
+import org.eclipse.ui.externaltools.model.ExternalTool;
+import org.eclipse.ui.externaltools.model.IExternalToolRunner;
+import org.eclipse.ui.externaltools.model.IRunnerContext;
+import org.eclipse.ui.externaltools.model.IRunnerLog;
+import org.eclipse.ui.externaltools.model.ToolUtil;
+import org.eclipse.ui.externaltools.variable.ExpandVariableContext;
+
+/**
+ * Context to run the external tool in.
+ */
+public final class DefaultRunnerContext implements IRunnerContext {
+ private ExternalTool tool;
+ private ExpandVariableContext expandVarCtx;
+ private String expandedLocation;
+ private String[] expandedArguments;
+ private String expandedDirectory;
+
+ /**
+ * Create a new context
+ *
+ * @param tool the external tool for which the context applies to
+ * @param project the project to run the external tool on, or <code>null</code>
+ * @param buildKind the kind of build being performed
+ * (see <code>IncrementalProjectBuilder</code>).
+ */
+ public DefaultRunnerContext(ExternalTool tool, IProject project, int buildKind) {
+ super();
+ this.tool = tool;
+ this.expandVarCtx = new ExpandVariableContext(project, buildKind);
+ }
+
+ /**
+ * Create a new context. The project will be determine from the
+ * specified selected resource.
+ *
+ * @param tool the external tool for which the context applies to
+ * @param selectedResource the selected resource to run the external
+ * tool on, or <code>null</code>
+ */
+ public DefaultRunnerContext(ExternalTool tool, IResource selectedResource) {
+ super();
+ this.tool = tool;
+ this.expandVarCtx = new ExpandVariableContext(selectedResource);
+ }
+
+ /**
+ * Executes the runner to launch the external tool. A resource refresh
+ * is done if specified.
+ *
+ * @param monitor the monitor to report progress or cancellation to
+ * @param status a multi status to report any problems while running tool
+ */
+ private void executeRunner(IProgressMonitor monitor, MultiStatus status) {
+ try {
+ // Lookup the runner based on the tool's type
+ ExternalToolTypeRegistry registry = ExternalToolsPlugin.getDefault().getTypeRegistry();
+ ExternalToolType toolType = registry.getToolType(tool.getType());
+ IExternalToolRunner runner = null;
+ if (toolType != null)
+ runner = toolType.getRunner();
+ if (runner == null) {
+ String msg = ToolMessages.format("DefaultRunnerContext.noToolRunner", new Object[] {tool.getName()}); //$NON-NLS-1$
+ status.merge(ExternalToolsPlugin.newErrorStatus(msg, null));
+ return;
+ }
+
+ if (monitor.isCanceled())
+ return;
+
+ // Run the tool
+ if (tool.getRefreshScope() == null) {
+ runner.run(monitor, this, status);
+ } else {
+ monitor.beginTask(ToolMessages.getString("DefaultRunnerContext.runningExternalTool"), 100); //$NON-NLS-1$
+ runner.run(new SubProgressMonitor(monitor, 70), this, status);
+ if (status.isOK() && !monitor.isCanceled())
+ refreshResources(new SubProgressMonitor(monitor, 30), status);
+ }
+ } finally {
+ monitor.done();
+ }
+ }
+
+ /* (non-Javadoc)
+ * Method declared on IRunnerContext.
+ */
+ public boolean getCaptureOutput() {
+ return tool.getCaptureOutput();
+ }
+
+ /* (non-Javadoc)
+ * Method declared on IRunnerContext.
+ */
+ public String getExpandedLocation() {
+ return expandedLocation;
+ }
+
+ /* (non-Javadoc)
+ * Method declared on IRunnerContext.
+ */
+ public String[] getExpandedArguments() {
+ return expandedArguments;
+ }
+
+ /* (non-Javadoc)
+ * Method declared on IRunnerContext.
+ */
+ public String getExpandedWorkingDirectory() {
+ return expandedDirectory;
+ }
+
+ /* (non-Javadoc)
+ * Method declared on IRunnerContext.
+ */
+ public String getExtraAttribute(String key) {
+ return tool.getExtraAttribute(key);
+ }
+
+ /* (non-Javadoc)
+ * Method declared on IRunnerContext.
+ */
+ public IRunnerLog getLog() {
+ return LogConsoleDocument.getInstance();
+ }
+
+ /* (non-Javadoc)
+ * Method declared on IRunnerContext.
+ */
+ public String getName() {
+ return tool.getName();
+ }
+
+ /**
+ * Runs the external tool is the context is valid. Once the tool
+ * has run, resources are refreshed based on the scope. Any problems
+ * while validating or running the tool will cause an exception
+ * to be thrown.
+ *
+ * @param monitor the monitor to report progress or cancellation to
+ * @param status a multi status to report any problems while running tool
+ */
+ public void run(IProgressMonitor monitor, MultiStatus status) {
+ validateContext(status);
+ if (status.isOK() && !monitor.isCanceled())
+ executeRunner(monitor, status);
+ }
+
+ /**
+ * Refreshes the resources specified by the tool.
+ *
+ * @param monitor the monitor to report progress or cancellation to
+ * @param status a multi status to report any problems while running tool
+ */
+ private void refreshResources(IProgressMonitor monitor, MultiStatus status) {
+ if (tool.getRefreshScope() == null)
+ return;
+
+ ToolUtil.VariableDefinition varDef = ToolUtil.extractVariableTag(tool.getRefreshScope(), 0);
+ if (varDef.start == -1 || varDef.end == -1 || varDef.name == null) {
+ String msg = ToolMessages.format("DefaultRunnerContext.invalidRefreshVarFormat", new Object[] {tool.getName()}); //$NON-NLS-1$
+ status.merge(ExternalToolsPlugin.newErrorStatus(msg, null));
+ return;
+ }
+
+ RefreshScopeVariableRegistry registry = ExternalToolsPlugin.getDefault().getRefreshVariableRegistry();
+ RefreshScopeVariable variable = registry.getRefreshVariable(varDef.name);
+ if (variable == null) {
+ String msg = ToolMessages.format("DefaultRunnerContext.noRefreshVarNamed", new Object[] {tool.getName(), varDef.name}); //$NON-NLS-1$
+ status.merge(ExternalToolsPlugin.newErrorStatus(msg, null));
+ return;
+ }
+
+ int depth = IResource.DEPTH_ZERO;
+ if (tool.getRefreshRecursive())
+ depth = IResource.DEPTH_INFINITE;
+
+ if (monitor.isCanceled())
+ return;
+
+ IResource[] resources = variable.getExpander().getResources(varDef.name, varDef.argument, expandVarCtx);
+ if (resources == null || resources.length == 0)
+ return;
+
+ monitor.beginTask(
+ ToolMessages.getString("DefaultRunnerContext.refreshResources"), //$NON-NLS-1$
+ resources.length);
+
+ for (int i = 0; i < resources.length; i++) {
+ if (monitor.isCanceled())
+ break;
+ if (resources[i] != null && resources[i].isAccessible()) {
+ try {
+ resources[i].refreshLocal(depth, null);
+ } catch (CoreException e) {
+ status.merge(e.getStatus());
+ }
+ }
+ monitor.worked(1);
+ }
+
+ monitor.done();
+ }
+
+ /**
+ * Validates the context in which to run the external tool.
+ * This will cause the location, arguments, and working
+ * directory to be expanded and verified.
+ *
+ * @param status a multi status to report any problems while running tool
+ */
+ private void validateContext(MultiStatus status) {
+ expandedLocation = ToolUtil.expandFileLocation(tool.getLocation(), expandVarCtx, status);
+ if (status.isOK()) {
+ if (expandedLocation == null || expandedLocation.length() == 0) {
+ String msg = ToolMessages.format("DefaultRunnerContext.invalidLocation", new Object[] {tool.getName()}); //$NON-NLS-1$
+ status.merge(ExternalToolsPlugin.newErrorStatus(msg, null));
+ } else {
+ File file = new File(expandedLocation);
+ if (!file.isFile()) {
+ String msg = ToolMessages.format("DefaultRunnerContext.invalidLocation", new Object[] {tool.getName()}); //$NON-NLS-1$
+ status.merge(ExternalToolsPlugin.newErrorStatus(msg, null));
+ }
+ }
+ }
+
+ expandedDirectory = ToolUtil.expandDirectoryLocation(tool.getWorkingDirectory(), expandVarCtx, status);
+ if (status.isOK()) {
+ if (expandedDirectory != null && expandedDirectory.length() > 0) {
+ File path = new File(expandedDirectory);
+ if (!path.isDirectory()) {
+ String msg = ToolMessages.format("DefaultRunnerContext.invalidDirectory", new Object[] {tool.getName()}); //$NON-NLS-1$
+ status.merge(ExternalToolsPlugin.newErrorStatus(msg, null));
+ }
+ }
+ }
+
+ expandedArguments = ToolUtil.expandArguments(tool.getArguments(), expandVarCtx, status);
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/model/ExternalToolBuilder.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/model/ExternalToolBuilder.java
new file mode 100644
index 000000000..394d2f3df
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/model/ExternalToolBuilder.java
@@ -0,0 +1,74 @@
+package org.eclipse.ui.externaltools.internal.model;
+
+/**********************************************************************
+Copyright (c) 2002 IBM Corp. and others. All rights reserved.
+This file is 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:
+**********************************************************************/
+
+import java.util.Map;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IncrementalProjectBuilder;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.MultiStatus;
+import org.eclipse.ui.externaltools.internal.registry.ExternalToolRegistry;
+import org.eclipse.ui.externaltools.model.ExternalTool;
+import org.eclipse.ui.externaltools.model.IExternalToolConstants;
+
+/**
+ * This project builder implementation will run an external tool during the
+ * build process.
+ * <p>
+ * Note that there is only ever one instance of ExternalToolBuilder per project,
+ * and the external tool to run is specified in the builder's arguments.
+ * </p>
+ */
+public final class ExternalToolBuilder extends IncrementalProjectBuilder {
+ public static final String ID = "org.eclipse.ui.externaltools.ExternalToolBuilder"; //$NON-NLS-1$;
+
+ private static final String NEW_NAME = "ExternalToolBuilderName"; //$NON-NLS-1$;
+
+ /**
+ * Creates an uninitialized external tool builder.
+ */
+ public ExternalToolBuilder() {
+ super();
+ }
+
+ /* (non-Javadoc)
+ * Method declared on IncrementalProjectBuilder.
+ */
+ protected IProject[] build(int kind, Map args, IProgressMonitor monitor) throws CoreException {
+ ExternalTool tool = ExternalToolRegistry.toolFromBuildCommandArgs(args, NEW_NAME);
+ if (tool == null)
+ return null;
+
+ boolean runTool = false;
+ int[] buildKinds = tool.getRunForBuildKinds();
+ for (int i = 0; i < buildKinds.length; i++) {
+ if (kind == buildKinds[i]) {
+ runTool = true;
+ break;
+ }
+ }
+ if (!runTool)
+ return null;
+
+ DefaultRunnerContext context = new DefaultRunnerContext(tool, getProject(), kind);
+ try {
+ MultiStatus status = new MultiStatus(IExternalToolConstants.PLUGIN_ID, 0, "", null); //$NON-NLS-1$
+ context.run(monitor, status);
+ if (!monitor.isCanceled() && !status.isOK())
+ throw new CoreException(status);
+ } finally {
+ forgetLastBuiltState();
+ }
+
+ return null;
+ }
+}
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/model/ExternalToolsPlugin.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/model/ExternalToolsPlugin.java
new file mode 100644
index 000000000..87828373b
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/model/ExternalToolsPlugin.java
@@ -0,0 +1,172 @@
+package org.eclipse.ui.externaltools.internal.model;
+
+/**********************************************************************
+Copyright (c) 2002 IBM Corp. and others. All rights reserved.
+This file is 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:
+**********************************************************************/
+
+import java.net.*;
+
+import org.eclipse.core.runtime.*;
+import org.eclipse.jface.preference.*;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.externaltools.internal.registry.ArgumentVariableRegistry;
+import org.eclipse.ui.externaltools.internal.registry.ExternalToolRegistry;
+import org.eclipse.ui.externaltools.internal.registry.ExternalToolTypeRegistry;
+import org.eclipse.ui.externaltools.internal.registry.PathLocationVariableRegistry;
+import org.eclipse.ui.externaltools.internal.registry.RefreshScopeVariableRegistry;
+import org.eclipse.ui.externaltools.model.IExternalToolConstants;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+
+/**
+ * External tools plug-in class
+ */
+public final class ExternalToolsPlugin extends AbstractUIPlugin {
+ /**
+ * Status representing no problems encountered during operation.
+ */
+ public static final IStatus OK_STATUS = new Status(IStatus.OK, IExternalToolConstants.PLUGIN_ID, 0, "", null); //$NON-NLS-1$
+
+ private static ExternalToolsPlugin plugin;
+
+ private ExternalToolRegistry toolRegistry;
+ private ExternalToolTypeRegistry typeRegistry;
+ private RefreshScopeVariableRegistry refreshVarRegistry;
+ private PathLocationVariableRegistry fileLocVarRegistry;
+ private PathLocationVariableRegistry dirLocVarRegistry;
+ private ArgumentVariableRegistry argumentVarRegistry;
+
+ /**
+ * Create an instance of the External Tools plug-in.
+ */
+ public ExternalToolsPlugin(IPluginDescriptor descriptor) {
+ super(descriptor);
+ plugin = this;
+ }
+
+ /**
+ * Returns the default instance of the receiver.
+ * This represents the runtime plugin.
+ */
+ public static ExternalToolsPlugin getDefault() {
+ return plugin;
+ }
+
+ /**
+ * Returns a new <code>IStatus</code> for this plug-in
+ */
+ public static IStatus newErrorStatus(String message, Throwable exception) {
+ return new Status(Status.ERROR, IExternalToolConstants.PLUGIN_ID, 0, message, exception);
+ }
+
+ /**
+ * Returns a new <code>CoreException</code> for this plug-in
+ */
+ public static CoreException newError(String message, Throwable exception) {
+ return new CoreException(new Status(Status.ERROR, IExternalToolConstants.PLUGIN_ID, 0, message, exception));
+ }
+
+ /**
+ * Returns the registry of refresh scope variables.
+ */
+ public ArgumentVariableRegistry getArgumentVariableRegistry() {
+ if (argumentVarRegistry == null)
+ argumentVarRegistry = new ArgumentVariableRegistry();
+ return argumentVarRegistry;
+ }
+
+ /**
+ * Returns the registry of directory location variables.
+ */
+ public PathLocationVariableRegistry getDirectoryLocationVariableRegistry() {
+ if (dirLocVarRegistry == null)
+ dirLocVarRegistry = new PathLocationVariableRegistry(IExternalToolConstants.PL_DIRECTORY_VARIABLES);
+ return dirLocVarRegistry;
+ }
+
+ /**
+ * Returns the registry of file location variables.
+ */
+ public PathLocationVariableRegistry getFileLocationVariableRegistry() {
+ if (fileLocVarRegistry == null)
+ fileLocVarRegistry = new PathLocationVariableRegistry(IExternalToolConstants.PL_FILE_VARIABLES);
+ return fileLocVarRegistry;
+ }
+
+ /**
+ * Returns the registry of refresh scope variables.
+ */
+ public RefreshScopeVariableRegistry getRefreshVariableRegistry() {
+ if (refreshVarRegistry == null)
+ refreshVarRegistry = new RefreshScopeVariableRegistry();
+ return refreshVarRegistry;
+ }
+
+ /**
+ * Returns the registry of external tools.
+ *
+ * @param shell the shell to use for displaying any errors
+ * when loading external tool definitions from storage
+ * or <code>null</code> to not report these problems.
+ */
+ public ExternalToolRegistry getToolRegistry(Shell shell) {
+ if (toolRegistry == null)
+ toolRegistry = new ExternalToolRegistry(shell);
+ return toolRegistry;
+ }
+
+ /**
+ * Returns the registry of external tool types.
+ */
+ public ExternalToolTypeRegistry getTypeRegistry() {
+ if (typeRegistry == null)
+ typeRegistry = new ExternalToolTypeRegistry();
+ return typeRegistry;
+ }
+
+ /**
+ * Writes the message to the plug-in's log
+ *
+ * @param message the text to write to the log
+ */
+ public void log(String message, Throwable exception) {
+ IStatus status = newErrorStatus(message, exception);
+ getLog().log(status);
+ }
+
+ /**
+ * Returns the ImageDescriptor for the icon with the given path
+ *
+ * @return the ImageDescriptor object
+ */
+ public ImageDescriptor getImageDescriptor(String path) {
+ try {
+ URL installURL = getDescriptor().getInstallURL();
+ URL url = new URL(installURL,path);
+ return ImageDescriptor.createFromURL(url);
+ } catch (MalformedURLException e) {
+ return null;
+ }
+ }
+
+ /* (non-Javadoc)
+ * Method declared in AbstractUIPlugin.
+ */
+ protected void initializeDefaultPreferences(IPreferenceStore prefs) {
+ prefs.setDefault(IPreferenceConstants.INFO_LEVEL, true);
+ prefs.setDefault(IPreferenceConstants.VERBOSE_LEVEL, false);
+ prefs.setDefault(IPreferenceConstants.DEBUG_LEVEL, false);
+
+ PreferenceConverter.setDefault(prefs, IPreferenceConstants.CONSOLE_ERROR_RGB, new RGB(255, 0, 0)); // red - exactly the same as debug Consol
+ PreferenceConverter.setDefault(prefs, IPreferenceConstants.CONSOLE_WARNING_RGB, new RGB(255, 100, 0)); // orange
+ PreferenceConverter.setDefault(prefs, IPreferenceConstants.CONSOLE_INFO_RGB, new RGB(0, 0, 255)); // blue
+ PreferenceConverter.setDefault(prefs, IPreferenceConstants.CONSOLE_VERBOSE_RGB, new RGB(0, 200, 125)); // green
+ PreferenceConverter.setDefault(prefs, IPreferenceConstants.CONSOLE_DEBUG_RGB, new RGB(0, 0, 0)); // black
+ }
+}
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/model/IHelpContextIds.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/model/IHelpContextIds.java
new file mode 100644
index 000000000..92aedbf03
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/model/IHelpContextIds.java
@@ -0,0 +1,58 @@
+package org.eclipse.ui.externaltools.internal.model;
+
+/**********************************************************************
+Copyright (c) 2002 IBM Corp. and others. All rights reserved.
+This file is 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:
+**********************************************************************/
+
+/**
+ * Help context ids for the external tools.
+ * <p>
+ * This interface contains constants only; it is not intended to be implemented
+ * or extended.
+ * </p>
+ */
+public interface IHelpContextIds {
+ public static final String PREFIX = "org.eclipse.ui.externaltools."; //$NON-NLS-1$
+
+ // Actions
+ public static final String NEW_TOOL_ACTION = PREFIX + "new_tool_action_context"; //$NON-NLS-1$
+ public static final String DUPLICATE_TOOL_ACTION = PREFIX + "duplicate_tool_action_context"; //$NON-NLS-1$
+ public static final String DELETE_TOOL_ACTION = PREFIX + "delete_tool_action_context"; //$NON-NLS-1$
+ public static final String RENAME_TOOL_ACTION = PREFIX + "rename_tool_action_context"; //$NON-NLS-1$
+ public static final String REFRESH_VIEW_ACTION = PREFIX + "refresh_view_action_context"; //$NON-NLS-1$
+ public static final String RUN_TOOL_ACTION = PREFIX + "run_tool_action_context"; //$NON-NLS-1$
+ public static final String RUN_WITH_TOOL_ACTION = PREFIX + "run_with_tool_action_context"; //$NON-NLS-1$
+ public static final String EDIT_TOOL_PROPERTIES_ACTION = PREFIX + "edit_tool_properties_action_context"; //$NON-NLS-1$
+ public static final String ANT_ACTION = PREFIX + "ant_action_context"; //$NON-NLS-1$
+
+ // Dialogs
+ public static final String RESOURCE_SELECTION_DIALOG = PREFIX + "resource_selection_dialog_context"; //$NON-NLS-1$
+
+ // Preference Pages
+ public static final String ANT_PREFERENCE_PAGE = PREFIX + "ant_preference_page_context"; //$NON-NLS-1$
+ public static final String ADD_TASK_DIALOG = PREFIX + "add_task_dialog_context"; //$NON-NLS-1$
+
+ // Property Pages
+ public static final String TOOL_MAIN_PROPERTY_PAGE = PREFIX + "tool_main_property_page_context"; //$NON-NLS-1$
+ public static final String TOOL_OPTION_PROPERTY_PAGE = PREFIX + "tool_option_property_page_context"; //$NON-NLS-1$
+ public static final String TOOL_REFRESH_PROPERTY_PAGE = PREFIX + "tool_refresh_property_page_context"; //$NON-NLS-1$
+ public static final String ANT_TARGETS_PROPERTY_PAGE = PREFIX + "ant_targets_property_page_context"; //$NON-NLS-1$
+
+ // Views
+ public static final String EXTERNAL_TOOLS_VIEW = PREFIX + "external_tools_view_context"; //$NON-NLS-1$
+
+ // Wizards
+ public static final String ANT_LAUNCH_WIZARD = PREFIX + "ant_launch_wizard_context"; //$NON-NLS-1$
+
+ // Wizard Pages
+ public static final String TOOL_MAIN_WIZARD_PAGE = PREFIX + "tool_main_wizard_page_context"; //$NON-NLS-1$
+ public static final String TOOL_OPTION_WIZARD_PAGE = PREFIX + "tool_option_wizard_page_context"; //$NON-NLS-1$
+ public static final String TOOL_REFRESH_WIZARD_PAGE = PREFIX + "tool_refresh_wizard_page_context"; //$NON-NLS-1$
+ public static final String ANT_TARGETS_WIZARD_PAGE = PREFIX + "ant_targets_wizard_page_context"; //$NON-NLS-1$
+ public static final String ANT_LAUNCH_WIZARD_PAGE = PREFIX + "ant_launch_wizard_page_context"; //$NON-NLS-1$
+}
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/model/IPreferenceConstants.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/model/IPreferenceConstants.java
new file mode 100644
index 000000000..06988b86c
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/model/IPreferenceConstants.java
@@ -0,0 +1,27 @@
+package org.eclipse.ui.externaltools.internal.model;
+
+/**********************************************************************
+Copyright (c) 2002 IBM Corp. and others. All rights reserved.
+This file is 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:
+**********************************************************************/
+
+/**
+ * Constants used to identify user preferences.
+ */
+public interface IPreferenceConstants {
+ public static final String OUPUT_LEVEL = "externaltools.outputLevel"; // $NON-NLS-1$
+ public static final String INFO_LEVEL = "externaltools.infoLevel"; // $NON-NLS-1$
+ public static final String VERBOSE_LEVEL = "externaltools.verboseLevel"; // $NON-NLS-1$
+ public static final String DEBUG_LEVEL = "externaltools.levelLevel"; // $NON-NLS-1$
+
+ public static final String CONSOLE_ERROR_RGB = "externaltools.console.errorColor"; // $NON-NLS-1$
+ public static final String CONSOLE_WARNING_RGB = "externaltools.console.warningColor"; // $NON-NLS-1$
+ public static final String CONSOLE_INFO_RGB = "externaltools.console.infoColor"; // $NON-NLS-1$
+ public static final String CONSOLE_VERBOSE_RGB = "externaltools.console.verboseColor"; // $NON-NLS-1$
+ public static final String CONSOLE_DEBUG_RGB = "externaltools.console.debugColor"; // $NON-NLS-1$
+ public static final String CONSOLE_FONT = "externaltools.console.font"; // $NON-NLS-1$
+}
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/model/ToolMessages.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/model/ToolMessages.java
new file mode 100644
index 000000000..3d9fcd81a
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/model/ToolMessages.java
@@ -0,0 +1,61 @@
+package org.eclipse.ui.externaltools.internal.model;
+
+/**********************************************************************
+Copyright (c) 2002 IBM Corp. and others. All rights reserved.
+This file is 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:
+**********************************************************************/
+
+import java.text.MessageFormat;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+/**
+ * Utility class which helps managing messages
+ */
+public final class ToolMessages {
+ private static final String RESOURCE_BUNDLE= "org.eclipse.ui.externaltools.internal.model.messages"; //$NON-NLS-1$
+ private static ResourceBundle bundle = ResourceBundle.getBundle(RESOURCE_BUNDLE);
+
+ private ToolMessages(){
+ // prevent instantiation of class
+ }
+
+ /**
+ * Returns the formatted message for the given key in
+ * the resource bundle.
+ *
+ * @param key the message name
+ * @param args the message arguments
+ * @return the formatted message
+ */
+ public static String format(String key, Object[] args) {
+ return MessageFormat.format(getString(key), args);
+ }
+
+ /**
+ * Returns the message with the given key in
+ * the resource bundle. If there isn't any value under
+ * the given key, the key is returned.
+ *
+ * @param key the message name
+ * @return the message
+ */
+ public static String getString(String key) {
+ try {
+ return bundle.getString(key);
+ } catch (MissingResourceException e) {
+ return key;
+ }
+ }
+
+ /**
+ * Returns the resource bundle for the plug-in
+ */
+ public static ResourceBundle getResourceBundle() {
+ return bundle;
+ }
+}
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/model/messages.properties b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/model/messages.properties
new file mode 100644
index 000000000..6ebe5b627
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/model/messages.properties
@@ -0,0 +1,364 @@
+# ======================================================================
+# Copyright (c) 2002 IBM Corp. and others. All rights reserved.
+# This file is 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:
+# ======================================================================
+
+# =======================================================================
+# Base External Tool
+# =======================================================================
+
+ExternalTool.nameMustContainOneChar = The external tool name must contain at least one letter or number.
+ExternalTool.nameContainsInvalidChar = The external tool name must contain only letters, numbers, hyphens, and spaces.
+
+ToolUtil.dirLocVarBetweenText = The variable for the directory location cannot have any other text before or after itself.
+ToolUtil.dirLocVarFormatWrong = The variable for the directory location is not in a valid format.
+ToolUtil.dirLocVarMissing = The variable named ''{0}'' for the directory location does not exist.
+ToolUtil.dirLocVarExpandFailed = The variable named ''{0}'' for the directory location could not be expanded.
+ToolUtil.fileLocVarBetweenText = The variable for the file location cannot have any other text before or after itself.
+ToolUtil.fileLocVarFormatWrong = The variable for the file location is not in a valid format.
+ToolUtil.fileLocVarMissing = The variable named ''{0}'' for the file location does not exist.
+ToolUtil.fileLocVarExpandFailed = The variable named ''{0}'' for the file location could not be expanded.
+ToolUtil.argumentVarFormatWrong = A variable for the arguments is not in a valid format.
+ToolUtil.argumentVarMissing = The variable named ''{0}'' for the arguments does not exist.
+ToolUtil.argumentVarExpandFailed = The variable named ''{0}'' for the arguments could not be expanded.
+
+ExternalToolRegistry.loadToolFailure = Press the Details button for more information.
+ExternalToolRegistry.fileNotFoundError = Could not find external tool storage file.
+ExternalToolRegistry.ioLoadError = Problems reading external tool storage file.
+ExternalToolRegistry.ioSaveError = Problems writing external tool storage file.
+ExternalToolRegistry.loadErrorTitle = Problem Loading External Tools.
+ExternalToolRegistry.loadErrorMessage = Could not load all external tools.
+ExternalToolRegistry.noToolFilename = External tool filename for storage not specified.
+ExternalToolRegistry.deleteToolFileFailed = Could not delete external tool file ''{0}''.
+
+ExternalToolStorage.deleteErrorTitle = Problem Deleting External Tool.
+ExternalToolStorage.deleteErrorMessage = Could not delete external tool. Refresh list and try again.
+ExternalToolStorage.reloadErrorTitle = Problem Refreshing External Tools
+ExternalToolStorage.reloadErrorMessage = Could not load all external tools.
+ExternalToolStorage.saveErrorTitle = Problem Saving External Tool.
+ExternalToolStorage.saveErrorMessage = Could not save external tool. Please try again.
+
+NewExternalToolAction.text = &New
+NewExternalToolAction.toolTip = New External Tool Wizard
+
+CopyExternalToolAction.text = &Copy
+CopyExternalToolAction.toolTip = Copy External Tool
+
+PasteExternalToolAction.text = &Paste
+PasteExternalToolAction.toolTip = Paste External Tool
+
+DeleteExternalToolAction.text = &Delete
+DeleteExternalToolAction.toolTip = Delete External Tool
+DeleteExternalToolAction.confirmToolDeleteTitle = Confirm External Tool Delete
+DeleteExternalToolAction.confirmToolDeleteMsg = Are you sure want to delete ''{0}''?
+
+RenameExternalToolAction.text = Rena&me
+RenameExternalToolAction.toolTip = Rename External Tool
+
+RefreshViewAction.text = Re&fresh
+RefreshViewAction.toolTip = Refresh External Tool View
+
+RunExternalToolAction.text = R&un
+RunExternalToolAction.toolTip = Run External Tool
+
+RunWithExternalToolAction.text = Run &With...
+RunWithExternalToolAction.toolTip = Prompt for Arguments and Run External Tool
+
+EditExternalToolPropertiesAction.text = P&roperties
+EditExternalToolPropertiesAction.toolTip = Edit External Tool Properties
+
+ExternalToolMainGroup.locationLabel = &Location:
+ExternalToolMainGroup.locationBrowseLabel = B&rowse...
+ExternalToolMainGroup.descriptionLabel = D&escription:
+ExternalToolMainGroup.nameLabel = Na&me:
+ExternalToolMainGroup.workDirLabel = &Working Directory:
+ExternalToolMainGroup.workDirBrowseLabel = Br&owse...
+ExternalToolMainGroup.nameRequired = External tool name cannot be empty.
+ExternalToolMainGroup.nameAlreadyExist = Another external tool exists with the same name.
+ExternalToolMainGroup.locationRequired = External tool location cannot be empty.
+ExternalToolMainGroup.invalidLocation = External tool location does not exist or is invalid.
+ExternalToolMainGroup.invalidWorkDir = External tool working directory does not exist or is invalid.
+
+ExternalToolOptionGroup.captureOutputLabel = &Capture output messages from running tool
+ExternalToolOptionGroup.showConsoleLabel = &Show console when tool is run
+ExternalToolOptionGroup.runBackgroundLabel = &Run tool in background
+ExternalToolOptionGroup.openPerspLabel = &Open perspective when tool is run:
+ExternalToolOptionGroup.argumentLabel = Ar&guments:
+ExternalToolOptionGroup.argumentInstruction = Note: Enclose an argument containing spaces using double-quotes ("). Not\napplicable for variables.
+ExternalToolOptionGroup.argumentVariableLabel = &Variables...
+ExternalToolOptionGroup.promptArgLabel = &Prompt for arguments before running tool
+ExternalToolOptionGroup.showInMenuLabel = S&how in Run > External Tools menu
+ExternalToolOptionGroup.saveDirtyEditorsLabel = Save dirty &editors before running tool
+
+ExternalToolRefreshGroup.refreshLabel = &Refresh resources after running tool
+ExternalToolRefreshGroup.recursiveLabel = Recursively &include sub-folders
+ExternalToolRefreshGroup.scopeLabel = Choose &Scope Variable:
+
+ExternalToolNewWizard.shellTitle = New External Tool
+ExternalToolNewWizard.optionPageTitle = Options
+ExternalToolNewWizard.optionPageDescription = Configure the options when the external tool is run.
+ExternalToolNewWizard.refreshPageTitle = Refresh Scope
+ExternalToolNewWizard.refreshPageDescription = Specify which resources to refresh after the external tool is run.
+
+ExternalToolVariable.componentErrorMessage = Problem displaying UI component of selected variable.
+
+ResourceComponent.selectedResLabel = &Use selected resource
+ResourceComponent.specificResLabel = Us&e specific resource:
+ResourceComponent.selectionRequired = A specific resource must be selected from the list.
+
+RunExternalToolAction.openPerspProblem = Failed to open the perspective.
+RunExternalToolAction.openPerspTitle = Open Perspective Problem
+RunExternalToolAction.runProblem = Could not run the external tool.
+RunExternalToolAction.runErrorTitle = Run Tool Problem
+RunExternalToolAction.internalError = External tool runner internal error
+
+DefaultRunnerContext.runningExternalTool = Running external tool...
+DefaultRunnerContext.invalidLocation = The file does not exist for the external tool named {0}.
+DefaultRunnerContext.invalidDirectory = The working directory does not exist for the external tool named {0}.
+DefaultRunnerContext.refreshResources = Refresh resources...
+DefaultRunnerContext.noToolRunner = The no valid runner provided for the external tool named {0}.
+DefaultRunnerContext.invalidRefreshVarFormat = Invalid refresh scope variable format for the external tool named {0}.
+DefaultRunnerContext.noRefreshVarNamed = Could not find refresh scope variable called ''{1}'' for the external tool named {0}.
+
+ExternalToolMenuDelegate.showView = Show External Tools View
+ExternalToolMenuDelegate.runRecent = Run Last Tool
+
+
+# =======================================================================
+# Program External Tool Type
+# =======================================================================
+
+ProgramRunner.runningToolLabel = Running external tool: {0}
+ProgramRunner.internalErrorMessage = Internal error
+ProgramRunner.callingRuntimeExec = Calling runtime exec with:\n
+ProgramRunner.program = Program: {0}\n
+ProgramRunner.argument = Argument: {0}\n
+ProgramRunner.workDir = Working Directory: {0}\n
+
+
+# =======================================================================
+# Ant Build File External Tool Type
+# =======================================================================
+
+AntFileRunner.callingAntRunner = Calling Ant runner with:\n
+AntFileRunner.antFile = Ant build file: {0}\n
+AntFileRunner.argument = Argument: {0}\n
+AntFileRunner.target = Target: {0}\n
+
+AntTargetsGroup.availableTargetsLabel = A&vailable targets:
+AntTargetsGroup.activeTargetsLabel = A&ctive targets:
+AntTargetsGroup.addLabel = >
+AntTargetsGroup.removeLabel = <
+AntTargetsGroup.addAllLabel = >>
+AntTargetsGroup.removeAllLabel = <<
+AntTargetsGroup.descriptionLabel = &Target description:
+AntTargetsGroup.upLabel = U&p
+AntTargetsGroup.downLabel = D&own
+AntTargetsGroup.getTargetsTitle = Problem retrieving targets
+AntTargetsGroup.getTargetsProblem = Could not retrieve targets.
+AntTargetsGroup.runDefaultTargetLabel = R&un default target ({0})
+AntTargetsGroup.runDefaultTargetUnknownLabel = R&un default target
+AntTargetsGroup.showSubTargetsLabel = S&how sub-targets
+
+AntExternalToolNewWizard.antTargetsPageTitle = Ant Targets
+AntExternalToolNewWizard.antTargetsPageDescription = Specify which Ant targets to execute when the external tool is run.
+AntExternalToolNewWizard.promptForArgumentLabel = &Prompt for targets and arguments before running tool
+
+AntOptionGroupPropertyPage.promptForArgumentLabel = &Prompt for targets and arguments before running tool
+
+AntPreferencePage.description = &Customize the classpath, tasks and types used when\nrunning Ant build files from Eclipse.
+
+AntClasspathPage.addFolderButtonTitle = Add &Folder...
+AntClasspathPage.addJarButtonTitle = Add &JAR...
+AntClasspathPage.removeButtonTitle = &Remove
+AntClasspathPage.title = C&lasspath
+
+AntTasksPage.addTaskButtonTitle = Add &Task...
+AntTasksPage.editTaskButtonTitle = &Edit Task...
+AntTasksPage.removeButtonTitle = &Remove
+AntTasksPage.addTaskDialogDescription = Enter a name, java class, and library for your custom task.
+AntTasksPage.addTaskDialogTitle = Add Task
+AntTasksPage.title = Ta&sks
+AntTasksPage.editTaskDialogDescription = Modify the name, java class, and library of your custom task
+AntTasksPage.editTaskDialogTitle = Edit Task
+
+AntTypesPage.removeButtonTitle = &Remove
+AntTypesPage.addTypeButtonTitle = Add &Type...
+AntTypesPage.editTypeButtonTitle = &Edit Type...
+AntTypesPage.typesPageTitle = T&ypes
+AntTypesPage.addTypeDialogDescription = Enter a name, java class, and library for your custom type.
+AntTypesPage.addTypeDialogTitle = Add Type
+AntTypesPage.editTypeDialogDescription = Modify the name, java class, and library of your custom type
+AntTypesPage.editTypeDialogTitle = Edit Type
+
+
+
+# =======================================================================
+# OLD STUFF
+# =======================================================================
+
+ConfigurationDialog.shellTitle = External Tools Configuration
+ConfigurationDialog.dialogTitle = External Tools
+ConfigurationDialog.dialogMessage = Configure an external tool to run a program, batch file, or Ant build file.
+ConfigurationDialog.toolList = &Tools:
+ConfigurationDialog.newButton = &New...
+ConfigurationDialog.editButton = &Edit...
+ConfigurationDialog.removeButton = &Remove
+ConfigurationDialog.upButton = &Up
+ConfigurationDialog.downButton = &Down
+ConfigurationDialog.details = Det&ails:
+ConfigurationDialog.detailMessage = Location: {0}\nArguments: {1}\nDirectory: {2}
+
+EditDialog.newShellTitle = New External Tool
+EditDialog.editShellTitle = Edit External Tool
+EditDialog.dialogTitle = External Tool
+EditDialog.newDialogMessage = Create an external tool to run a program, batch file, or Ant build file.
+EditDialog.editDialogMessage = Edit an external tool to run a program, batch file, or Ant build file.
+EditDialog.howToSelectAntTargets = To choose Ant targets, press the ''Browse Variables'' button and select ''Ant targets''.
+EditDialog.nameLabel = &Name:
+EditDialog.locationLabel = Tool &Location:
+EditDialog.argumentLabel = Tool &Arguments:
+EditDialog.dirLabel = Working &Directory:
+EditDialog.refreshOption = After running, &refresh:
+EditDialog.browseWkspButton1 = Browse &Workspace...
+EditDialog.browseFileSysButton1 = Browse &File System...
+EditDialog.browseVarsButton = Browse &Variables...
+EditDialog.directoryBrowseButton = Browse &Options...
+EditDialog.refreshOptionButton = Browse O&ptions...
+EditDialog.browseWorkspaceTitle = Browse Workspace
+EditDialog.selectTool = &Select the external tool to use:
+EditDialog.selectResource = &Select the resource to use:
+EditDialog.selectContainer = &Select the container to use:
+EditDialog.selectDirectory = &Select the working directory to use:
+EditDialog.selectTargets = &Select the Ant targets to use:
+EditDialog.selectFolder = &Select the folder to use:
+EditDialog.browseVarTitle = Browse Variables
+EditDialog.browseDirTitle = Browse Working Directory Options
+EditDialog.selectVar = &Select a variable to use:
+EditDialog.selectDir = &Select a working directory option:
+EditDialog.dirBrowseWorkspace = Browse workspace
+EditDialog.dirBrowseFileSystem = Browse file system
+EditDialog.varWorkspaceLocLabel = Workspace location
+EditDialog.varProjectLocLabel = Selected resource's project location
+EditDialog.varContainerLocLabel = Selected resource's container location
+EditDialog.varResourceLocLabel = Selected resource location
+EditDialog.varProjectPathLabel = Selected resource's project full path
+EditDialog.varContainerPathLabel = Selected resource's container full path
+EditDialog.varResourcePathLabel = Selected resource full path
+EditDialog.varProjectNameLabel = Selected resource's project name
+EditDialog.varContainerNameLabel = Selected resource's container name
+EditDialog.varResourceNameLabel = Selected resource name
+EditDialog.varProjectXLocLabel = Specific resource's project location
+EditDialog.varContainerXLocLabel = Specific resource's container location
+EditDialog.varResourceXLocLabel = Specific resource location
+EditDialog.varProjectXPathLabel = Specific resource's project full path
+EditDialog.varContainerXPathLabel = Specific resource's container full path
+EditDialog.varResourceXPathLabel = Specific resource full path
+EditDialog.varProjectXNameLabel = Specific resource's project name
+EditDialog.varContainerXNameLabel = Specific resource's container name
+EditDialog.varResourceXNameLabel = Specific resource name
+EditDialog.varBuildTypeNameLabel = Build type
+EditDialog.varAntTargetLabel = Ant targets
+EditDialog.browseProjectTitle = Browse Projects
+EditDialog.selectProject = &Select a project to use:
+EditDialog.noToolName = Enter a name for the tool
+EditDialog.noToolLocation = Enter a location for the tool
+EditDialog.missingToolLocation = Tool location does not exist or is invalid
+EditDialog.missingToolDirectory = Tool working directory does not exist or is invalid
+EditDialog.refreshScopeNone = Nothing
+EditDialog.refreshScopeWorkspace = Workspace
+EditDialog.refreshScopeProject = Current project
+EditDialog.refreshScopeProjectX = Project named {0}
+EditDialog.refreshScopeWorkingSet = Working set named {0}
+EditDialog.browseRefreshTitle = Browse Refresh Scopes
+EditDialog.selectRefresh = &Select the refresh scope to use:
+EditDialog.refreshNothingLabel = Nothing
+EditDialog.refreshWorkspaceLabel = Current workspace
+EditDialog.refreshProjectLabel = Current project
+EditDialog.refreshProjectXLabel = Specific project
+EditDialog.refreshWorkingSetLabel = Specific working set
+EditDialog.showLogLabel = S&how execution log on console
+EditDialog.errorTitle = Edit External Tool Problem
+EditDialog.errorReadAntFile = Problems reading Ant build file: {0}
+EditDialog.noAntTargets = Could not find any targets in Ant build file: {0}
+
+ExternalToolsRegistry.saveStateErrorTitle = Problem Saving External Tool
+ExternalToolsRegistry.saveStateError = Could not write external tool configurations to disk.\n\nPlease try again.
+
+BuilderPropertyPage.description = Add external tools to the build order.
+BuilderPropertyPage.newButton = &New...
+BuilderPropertyPage.editButton = &Edit...
+BuilderPropertyPage.removeButton = &Remove
+BuilderPropertyPage.upButton = &Up
+BuilderPropertyPage.downButton = &Down
+BuilderPropertyPage.statusMessage = Internal error
+BuilderPropertyPage.errorTitle = External Tool Builder Problem
+BuilderPropertyPage.errorMessage = Internal error
+BuilderPropertyPage.invalidBuildTool = Invalid External Tool Builder
+BuilderPropertyPage.missingBuilder = Missing builder ({0})
+
+ExternalToolsAction.configure = &Configure...
+
+LogConsoleDocument.externalTool = External Tool
+
+LogConsoleView.copy = &Copy@Ctrl+C
+LogConsoleView.expandAll = &Expand All
+LogConsoleView.selectAll = Select &All@Ctrl+A
+LogConsoleView.clearOutput = Clear Output
+LogConsoleView.hideOutputStructureTree = Hide Output Structure Tree
+LogConsoleView.showOutputStructureTree = Show Output Structure Tree
+LogConsoleView.showTree = &Show Tree
+LogConsoleView.showSelectedElementOnly = Show Output of Selected Element Only
+LogConsoleView.showCompleteOutput = Show Complete Output
+LogConsoleView.findAction.label = Find/Replace
+
+LogTreeLabelProvider.invalidItemName = Invalid item name
+
+ToolsPreferencePage.errorColor = &Error:
+ToolsPreferencePage.warningColor = &Warning:
+ToolsPreferencePage.infoColor = I&nformation:
+ToolsPreferencePage.verboseColor = Ve&rbose:
+ToolsPreferencePage.debugColor = Deb&ug:
+ToolsPreferencePage.font = Console font setting:
+ToolsPreferencePage.description = Console text color settings.
+ToolsPreferencePage.preferedOutputLevel = Preferred output level
+ToolsPreferencePage.info = &Information (normal)
+ToolsPreferencePage.verbose = &Verbose
+ToolsPreferencePage.debug = De&bug
+
+BuildCanceledException.canceled = Canceled
+
+AntUtil.antFileNotFound = Could not open Ant build file.
+AntUtil.parserConfigError = Internal parser configuration error.
+AntUtil.ioError = Could not read content of Ant build file.
+AntUtil.formatError = Could not parse content of Ant build file.
+AntUtil.invalidAntBuildFile = Invalid content format of Ant build file.
+
+AntAction.runErrorTitle = Run Ant Problem
+AntAction.errorReadAntFile = Problems reading Ant build file: {0}
+AntAction.noAntTargets = Could not find any targets in Ant build file: {0}
+
+AntLaunchWizard.shellTitle = Run Ant
+AntLaunchWizard.dialogTitle = Run
+AntLaunchWizard.dialogDescription = Run an Ant build file
+AntLaunchWizard.runningAnt = Running Ant
+AntLaunchWizard.runAntProblem = A problem occurred executing the Ant file. See the log console for details.
+AntLaunchWizard.runErrorTitle = Run Ant Problem
+AntLaunchWizard.internalAntError = Ant runner internal error
+
+AntLaunchWizardPage.targetLabel = Available &targets:
+AntLaunchWizardPage.argsLabel = &Arguments:
+AntLaunchWizardPage.showLogLabel = S&how execution log in console
+
+AntTargetLabelProvider.defaultTarget = Default
+
+NullBuildLogger.buildException = BUILD FAILED: {0}
+
+AddTaskDialog.name = &Name:
+AddTaskDialog.class = &Class:
+AddTaskDialog.library = &Library:
+
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/registry/ArgumentVariable.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/registry/ArgumentVariable.java
new file mode 100644
index 000000000..80e51c552
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/registry/ArgumentVariable.java
@@ -0,0 +1,65 @@
+package org.eclipse.ui.externaltools.internal.registry;
+
+/**********************************************************************
+Copyright (c) 2002 IBM Corp. and others. All rights reserved.
+This file is 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:
+**********************************************************************/
+
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.ui.externaltools.variable.ExpandVariableContext;
+import org.eclipse.ui.externaltools.variable.IVariableTextExpander;
+
+/**
+ * Represents the variable for the argument
+ */
+public final class ArgumentVariable extends ExternalToolVariable {
+ private static final DefaultTextExpander defaultExpander = new DefaultTextExpander();
+
+ private IVariableTextExpander expander = null;
+
+ /**
+ * Creates an argument variable
+ *
+ * @param tag the variable tag
+ * @param description a short description of what the variable will expand to
+ * @param element the configuration element
+ */
+ /*package*/ ArgumentVariable(String tag, String description, IConfigurationElement element) {
+ super(tag, description, element);
+ }
+
+ /**
+ * Returns the object that can expand the variable
+ * as text.
+ */
+ public IVariableTextExpander getExpander() {
+ if (expander == null) {
+ try {
+ expander = (IVariableTextExpander) createObject(ExternalToolVariableRegistry.TAG_EXPANDER_CLASS);
+ } catch (ClassCastException exception) {
+ }
+ if (expander == null) {
+ expander = defaultExpander;
+ }
+ }
+ return expander;
+ }
+
+
+ /**
+ * Default variable text expander implementation which does
+ * not expand variables, but just returns <code>null</code>.
+ */
+ private static final class DefaultTextExpander implements IVariableTextExpander {
+ /* (non-Javadoc)
+ * Method declared on IVariableTextExpander.
+ */
+ public String getText(String varTag, String varValue, ExpandVariableContext context) {
+ return null;
+ }
+ }
+}
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/registry/ArgumentVariableRegistry.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/registry/ArgumentVariableRegistry.java
new file mode 100644
index 000000000..8a88ce5b7
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/registry/ArgumentVariableRegistry.java
@@ -0,0 +1,50 @@
+package org.eclipse.ui.externaltools.internal.registry;
+
+/**********************************************************************
+Copyright (c) 2002 IBM Corp. and others. All rights reserved.
+This file is 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:
+**********************************************************************/
+
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.ui.externaltools.model.IExternalToolConstants;
+
+/**
+ * Registry of all available argument variables.
+ */
+public class ArgumentVariableRegistry extends ExternalToolVariableRegistry {
+
+ /**
+ * Creates the registry and loads the variables.
+ */
+ public ArgumentVariableRegistry() {
+ super(IExternalToolConstants.PL_ARGUMENT_VARIABLES);
+ }
+
+ /**
+ * Returns the argument variable for the given tag
+ * or <code>null</code> if none.
+ */
+ public ArgumentVariable getArgumentVariable(String tag) {
+ return (ArgumentVariable) findVariable(tag);
+ }
+
+ /**
+ * Returns the list of argument variables in the registry.
+ */
+ public ArgumentVariable[] getArgumentVariables() {
+ ArgumentVariable[] results = new ArgumentVariable[getVariableCount()];
+ copyVariables(results);
+ return results;
+ }
+
+ /* (non-Javadoc)
+ * Method declared on ExternalToolVariableRegistry.
+ */
+ protected ExternalToolVariable newVariable(String tag, String description, IConfigurationElement element) {
+ return new ArgumentVariable(tag, description, element);
+ }
+}
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/registry/ExternalToolMigration.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/registry/ExternalToolMigration.java
new file mode 100644
index 000000000..97fe9bb3c
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/registry/ExternalToolMigration.java
@@ -0,0 +1,252 @@
+package org.eclipse.ui.externaltools.internal.registry;
+
+/**********************************************************************
+Copyright (c) 2002 IBM Corp. and others. All rights reserved.
+This file is 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:
+**********************************************************************/
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.ui.IMemento;
+import org.eclipse.ui.WorkbenchException;
+import org.eclipse.ui.XMLMemento;
+import org.eclipse.ui.externaltools.internal.model.ExternalToolsPlugin;
+import org.eclipse.ui.externaltools.model.ExternalTool;
+import org.eclipse.ui.externaltools.model.IExternalToolConstants;
+import org.eclipse.ui.externaltools.model.ToolUtil;
+
+/**
+ * Responsible reading an old external tool format and creating
+ * and migrating it to create a new external tool.
+ */
+public final class ExternalToolMigration {
+ private static final String SEPERATOR = ";"; //$NON-NLS-1$
+ private static final String STATE_FILE_NAME_OLD = "oldexternaltools.xml"; //$NON-NLS-1$
+ private static final String STATE_FILE_NAME = "externaltools.xml"; //$NON-NLS-1$
+ private static final String TAG_EXTERNALTOOLS = "externaltools"; //$NON-NLS-1$
+ private static final String TAG_TOOL = "tool"; //$NON-NLS-1$
+ private static final String TAG_ENTRY = "entry"; //$NON-NLS-1$
+ private static final String TAG_KEY = "key"; //$NON-NLS-1$
+ private static final String TAG_VALUE = "value"; //$NON-NLS-1$
+
+ // Internal tags for storing tool related information
+ private static final String TAG_TOOL_TYPE = "!{tool_type}"; //$NON-NLS-1$
+ private static final String TAG_TOOL_NAME = "!{tool_name}"; //$NON-NLS-1$
+ private static final String TAG_TOOL_LOCATION = "!{tool_loc}"; //$NON-NLS-1$
+ private static final String TAG_TOOL_ARGUMENTS = "!{tool_args}"; //$NON-NLS-1$
+ private static final String TAG_TOOL_DIRECTORY = "!{tool_dir}"; //$NON-NLS-1$
+ private static final String TAG_TOOL_REFRESH = "!{tool_refresh}"; //$NON-NLS-1$
+ private static final String TAG_TOOL_SHOW_LOG = "!{tool_show_log}"; //$NON-NLS-1$
+ private static final String TAG_TOOL_BUILD_TYPES = "!{tool_build_types}"; //$NON-NLS-1$
+ private static final String TAG_TOOL_BLOCK = "!{tool_block}"; //$NON-NLS-1$
+
+ // Known kind of tools
+ private static final String TOOL_TYPE_PROGRAM = "org.eclipse.ui.externaltools.type.program"; //$NON-NLS-1$
+ private static final String TOOL_TYPE_ANT = "org.eclipse.ui.externaltools.type.ant"; //$NON-NLS-1$
+
+ private static final String TRUE = "true"; //$NON-NLS-1$
+ private static final String FALSE = "false"; //$NON-NLS-1$
+
+ /**
+ * Allows no instances.
+ */
+ private ExternalToolMigration() {
+ super();
+ }
+
+ /**
+ * Loads the external tools from storage and
+ * adds them to the registry.
+ */
+ /*package*/ static ExternalTool[] readInOldTools(ExternalToolRegistry reg) {
+ boolean migrationSuccessful = true;
+ ArrayList externalTools = null;
+ IPath path = ExternalToolsPlugin.getDefault().getStateLocation();
+ File file = path.append(STATE_FILE_NAME).toFile();
+ if (!file.exists())
+ return new ExternalTool[0];
+
+ InputStreamReader reader = null;
+ try {
+ FileInputStream input = new FileInputStream(file);
+ reader = new InputStreamReader(input, "utf-8"); //$NON-NLS-1$
+ XMLMemento memento = XMLMemento.createReadRoot(reader);
+
+ // Get the external tool children element
+ IMemento[] tools = memento.getChildren(TAG_TOOL);
+ externalTools = new ArrayList(tools.length);
+ for (int i = 0; i < tools.length; i++) {
+ HashMap args = new HashMap();
+ IMemento[] entries = tools[i].getChildren(TAG_ENTRY);
+ for (int j = 0; j < entries.length; j++) {
+ String key = entries[j].getString(TAG_KEY);
+ if (key != null) {
+ String value = entries[j].getTextData();
+ args.put(key, value);
+ }
+ }
+ ExternalTool tool = toolFromArgumentMap(args, reg, "ExternalToolNewName" + String.valueOf(i)); //$NON-NLS-1$
+ if (tool != null)
+ externalTools.add(tool);
+ }
+ }
+ catch (FileNotFoundException e) {
+ // Silently ignore this...
+ }
+ catch (IOException e) {
+ ExternalToolsPlugin.getDefault().log("File I/O error with reading old external tools.", e); //$NON-NLS-1$
+ migrationSuccessful = false;
+ }
+ catch (WorkbenchException e) {
+ ExternalToolsPlugin.getDefault().getLog().log(e.getStatus());
+ System.err.println("Error reading old external tools. See .log file for more details"); //$NON-NLS-1$
+ migrationSuccessful = false;
+ }
+ finally {
+ if (reader != null) {
+ try {
+ reader.close();
+ } catch(IOException e) {
+ ExternalToolsPlugin.getDefault().log("Unable to close external tool old state reader.", e); //$NON-NLS-1$
+ }
+ }
+ }
+
+ if (migrationSuccessful) {
+ if (!file.renameTo(path.append(STATE_FILE_NAME_OLD).toFile())) {
+ ExternalToolsPlugin.getDefault().log("Unable to rename old external tool state file. Please rename externaltools.xml to oldexternaltools.xml manually.", null); //$NON-NLS-1$
+ System.err.println("Unable to rename old external tool state file. Please rename externaltools.xml to oldexternaltools.xml manually."); //$NON-NLS-1$
+ }
+ if (externalTools == null || externalTools.size() == 0) {
+ return new ExternalTool[0];
+ } else {
+ ExternalTool[] results = new ExternalTool[externalTools.size()];
+ externalTools.toArray(results);
+ return results;
+ }
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * Creates an external tool from the map.
+ */
+ public static ExternalTool toolFromArgumentMap(Map args, ExternalToolRegistry reg, String newName) {
+ // Update the type...
+ String type = (String)args.get(TAG_TOOL_TYPE);
+ if (TOOL_TYPE_ANT.equals(type))
+ type = IExternalToolConstants.TOOL_TYPE_ANT_BUILD;
+ else
+ type = IExternalToolConstants.TOOL_TYPE_PROGRAM;
+
+ // Update the name...
+ String name = (String)args.get(TAG_TOOL_NAME);
+ name= name.replace('/', '.');
+ if (name.charAt(0) == ('.')) {
+ name= name.substring(1);
+ }
+ if (ExternalTool.validateToolName(name) != null)
+ name = newName;
+ if (reg != null && reg.hasToolNamed(name))
+ name = newName;
+
+ // Update the location...
+ String location = (String)args.get(TAG_TOOL_LOCATION);
+ if (location != null) {
+ ToolUtil.VariableDefinition varDef = ToolUtil.extractVariableTag(location, 0);
+ if (IExternalToolConstants.VAR_WORKSPACE_LOC.equals(varDef.name))
+ location = ToolUtil.buildVariableTag(IExternalToolConstants.VAR_RESOURCE_LOC, varDef.argument);
+ }
+
+ // Update the refresh scope...
+ String refresh = (String)args.get(TAG_TOOL_REFRESH);
+ if (refresh != null) {
+ ToolUtil.VariableDefinition varDef = ToolUtil.extractVariableTag(refresh, 0);
+ if ("none".equals(varDef.name)) //$NON-NLS-1$
+ refresh = null;
+ }
+
+ // Update the arguments
+ String arguments = (String)args.get(TAG_TOOL_ARGUMENTS);
+ String targetNames = null;
+ if (arguments != null) {
+ int start = 0;
+ ArrayList targets = new ArrayList();
+ StringBuffer buffer = new StringBuffer();
+ ToolUtil.VariableDefinition varDef = ToolUtil.extractVariableTag(arguments, start);
+ while (varDef.end != -1) {
+ if ("ant_target".equals(varDef.name) && varDef.argument != null) { //$NON-NLS-1$
+ targets.add(varDef.argument);
+ buffer.append(arguments.substring(start, varDef.start));
+ } else {
+ buffer.append(arguments.substring(start, varDef.end));
+ }
+ start = varDef.end;
+ varDef = ToolUtil.extractVariableTag(arguments, start);
+ }
+ buffer.append(arguments.substring(start, arguments.length()));
+ arguments = buffer.toString();
+
+ buffer.setLength(0);
+ for (int i = 0; i < targets.size(); i++) {
+ String target = (String)targets.get(i);
+ if (target != null && target.length() > 0) {
+ buffer.append(target);
+ buffer.append(","); //$NON-NLS-1$
+ }
+ }
+ targetNames = buffer.toString();
+ }
+
+ // Collect the rest of the information
+ String sShowLog = (String)args.get(TAG_TOOL_SHOW_LOG);
+ boolean showLog = TRUE.equals(sShowLog);
+
+ String sBlock = (String)args.get(TAG_TOOL_BLOCK);
+ boolean block = !(FALSE.equals(sBlock));
+
+ try {
+ ExternalTool tool = new ExternalTool(type, name);
+ tool.setLocation(location);
+ tool.setArguments(arguments);
+ tool.setWorkingDirectory((String)args.get(TAG_TOOL_DIRECTORY));
+ tool.setRefreshScope(refresh);
+ tool.setCaptureOutput(showLog);
+ tool.setShowConsole(showLog);
+ tool.setRunInBackground(!block);
+ tool.setRunForBuildKinds(toBuildTypesArray((String)args.get(TAG_TOOL_BUILD_TYPES)));
+ if (targetNames != null && targetNames.length() > 0) {
+ String key = IExternalToolConstants.TOOL_TYPE_ANT_BUILD + ".runTargets"; //$NON-NLS-1$;
+ tool.setExtraAttribute(key, targetNames);
+ }
+ return tool;
+ } catch (CoreException e) {
+ return null;
+ }
+ }
+
+ /**
+ * Translates a single String representation of build types
+ * used for storage in an argument map to an array of build
+ * types.
+ */
+ private static int[] toBuildTypesArray(String string) {
+ if (string == null)
+ return null;
+ return ExternalToolRegistry.buildTypesToArray(string);
+ }
+}
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
new file mode 100644
index 000000000..99bace7e9
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/registry/ExternalToolRegistry.java
@@ -0,0 +1,692 @@
+package org.eclipse.ui.externaltools.internal.registry;
+
+/**********************************************************************
+Copyright (c) 2002 IBM Corp. and others. All rights reserved.
+This file is 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:
+**********************************************************************/
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.FilenameFilter;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.OutputStreamWriter;
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.StringTokenizer;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IncrementalProjectBuilder;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.MultiStatus;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IMemento;
+import org.eclipse.ui.XMLMemento;
+import org.eclipse.ui.externaltools.internal.model.ExternalToolsPlugin;
+import org.eclipse.ui.externaltools.internal.model.ToolMessages;
+import org.eclipse.ui.externaltools.model.ExternalTool;
+import org.eclipse.ui.externaltools.model.IExternalToolConstants;
+
+/**
+ * The registry of available external tools.
+ */
+public class ExternalToolRegistry {
+ // Format for a tool looks like:
+ // <externalTool
+ // type={string}
+ // name={string}
+ // location={string:path}
+ // workDirectory={string:path}
+ // logMessages={string:true/false}
+ // runInBackground={string:true/false}
+ // promptForArguments={string:true/false}
+ // showInMenu={string:true/false}
+ // openPerspective={string:id}
+ // refreshScope={string}
+ // refreshRecursive={string: true/false}>
+ // <description>{string}</description}
+ // <arguments>{string}</arguments}
+ // <extraAttribute
+ // key={String}>
+ // {String}
+ // </extraAttribute>
+ // </externalTool>
+ //
+ // Element and attribute tags for storing a tool in an XML file.
+ private static final String TAG_EXTERNAL_TOOL = "externalTool"; //$NON-NLS-1$
+ private static final String TAG_TYPE = "type"; //$NON-NLS-1$
+ private static final String TAG_NAME = "name"; //$NON-NLS-1$
+ private static final String TAG_LOCATION = "location"; //$NON-NLS-1$
+ private static final String TAG_WORK_DIR = "workDirectory"; //$NON-NLS-1$
+ private static final String TAG_CAPTURE_OUTPUT = "captureOutput"; //$NON-NLS-1$
+ private static final String TAG_SHOW_CONSOLE = "showConsole"; //$NON-NLS-1$
+ private static final String TAG_RUN_BKGRND = "runInBackground"; //$NON-NLS-1$
+ private static final String TAG_OPEN_PERSP = "openPerspective"; //$NON-NLS-1$
+ private static final String TAG_PROMPT_ARGS = "promptForArguments"; //$NON-NLS-1$
+ private static final String TAG_SHOW_MENU = "showInMenu"; //$NON-NLS-1$
+ private static final String TAG_SAVE_DIRTY = "saveDirtyEditors"; //$NON-NLS-1$
+ private static final String TAG_DESC = "description"; //$NON-NLS-1$
+ private static final String TAG_ARGS = "arguments"; //$NON-NLS-1$
+ private static final String TAG_REFRESH_SCOPE = "refreshScope"; //$NON-NLS-1$
+ private static final String TAG_REFRESH_RECURSIVE = "refreshRecursive"; //$NON-NLS-1$
+ private static final String TAG_RUN_BUILD_KINDS = "runForBuildKinds"; //$NON-NLS-1$
+ private static final String TAG_EXTRA_ATTR = "extraAttribute"; //$NON-NLS-1$
+ private static final String TAG_KEY = "key"; //$NON-NLS-1$
+ private static final String TAG_VERSION = "version"; //$NON-NLS-1$
+
+ // Possible values for boolean type of attributes
+ private static final String TRUE = "true"; //$NON-NLS-1$
+ private static final String FALSE = "false"; //$NON-NLS-1$
+
+ private static final String BUILD_TYPE_SEPARATOR = ","; //$NON-NLS-1$
+ private static final String EXTRA_ATTR_SEPARATOR = "="; //$NON-NLS-1$
+
+ private static final String VERSION_21 = "2.1"; //$NON-NLS-1$;
+
+ private static final ExternalTool[] EMPTY_TOOLS = new ExternalTool[0];
+
+ /**
+ * Path to where the user defined external tools
+ * are stored within the workspace.
+ */
+ private static final IPath TOOLS_PATH =
+ ExternalToolsPlugin.getDefault().getStateLocation().append(".xtools"); //$NON-NLS-1$
+
+ /**
+ * Extension for external tool files stored within
+ * the workspace
+ */
+ private static final String TOOLS_EXTENSION = ".xtool"; //$NON-NLS-1$
+
+ /**
+ * Lookup table of external tools where the key is the
+ * type of tool, and the value is a array list of tools of
+ * that type.
+ */
+ private HashMap tools = new HashMap();
+
+ /**
+ * Lookup table of file names where the key is the external
+ * tool name as <b>lowercase</b>, and the value is the full path
+ * to the file for that tool
+ */
+ private HashMap filenames = new HashMap();
+
+ /**
+ * Creates the registry and loads the external tools
+ * from storage.
+ *
+ * @param shell the shell to use for displaying any errors
+ * when loading external tool definitions from storage
+ * or <code>null</code> to not report these problems.
+ */
+ public ExternalToolRegistry(final Shell shell) {
+ super();
+ final IStatus results = loadTools();
+ if (!results.isOK() && shell != null && !shell.isDisposed()) {
+ shell.getDisplay().syncExec(new Runnable() {
+ public void run() {
+ String title = ToolMessages.getString("ExternalToolRegistry.loadErrorTitle"); //$NON-NLS-1$
+ String msg = ToolMessages.getString("ExternalToolRegistry.loadErrorMessage"); //$NON-NLS-1$
+ ErrorDialog.openError(shell, title, msg, results);
+ }
+ });
+ }
+ ExternalTool[] oldTools = ExternalToolMigration.readInOldTools(this);
+ if (oldTools != null) {
+ for (int i = 0; i < oldTools.length; i++) {
+ saveTool(oldTools[i]);
+ }
+ }
+ }
+
+ /**
+ * Converts the build kinds into a built types
+ * string representation.
+ *
+ * @param buildKinds the array of build kinds to convert
+ * @return the build types string representation
+ */
+ protected static String buildKindsToString(int[] buildKinds) {
+ if (buildKinds.length == 0)
+ return IExternalToolConstants.BUILD_TYPE_NONE;
+
+ StringBuffer buffer = new StringBuffer();
+ for (int i = 0; i < buildKinds.length; i++) {
+ switch (buildKinds[i]) {
+ case IncrementalProjectBuilder.INCREMENTAL_BUILD :
+ buffer.append(IExternalToolConstants.BUILD_TYPE_INCREMENTAL);
+ break;
+ case IncrementalProjectBuilder.FULL_BUILD :
+ buffer.append(IExternalToolConstants.BUILD_TYPE_FULL);
+ break;
+ case IncrementalProjectBuilder.AUTO_BUILD :
+ buffer.append(IExternalToolConstants.BUILD_TYPE_AUTO);
+ break;
+ default :
+ break;
+ }
+ buffer.append(BUILD_TYPE_SEPARATOR);
+ }
+ return buffer.toString();
+ }
+
+ /**
+ * Converts the build types string into an array of
+ * build kinds.
+ *
+ * @param buildTypes the string of built types to convert
+ * @return the array of build kinds.
+ */
+ protected static int[] buildTypesToArray(String buildTypes) {
+ int count = 0;
+ boolean incremental = false;
+ boolean full = false;
+ boolean auto = false;
+
+ StringTokenizer tokenizer = new StringTokenizer(buildTypes, BUILD_TYPE_SEPARATOR);
+ while (tokenizer.hasMoreTokens()) {
+ String token = tokenizer.nextToken();
+ if (IExternalToolConstants.BUILD_TYPE_INCREMENTAL.equals(token)) {
+ if (!incremental) {
+ incremental = true;
+ count++;
+ }
+ }
+ else if (IExternalToolConstants.BUILD_TYPE_FULL.equals(token)) {
+ if (!full) {
+ full = true;
+ count++;
+ }
+ }
+ else if (IExternalToolConstants.BUILD_TYPE_AUTO.equals(token)) {
+ if (!auto) {
+ auto = true;
+ count++;
+ }
+ }
+ }
+
+ int[] results = new int[count];
+ count = 0;
+ if (incremental) {
+ results[count] = IncrementalProjectBuilder.INCREMENTAL_BUILD;
+ count++;
+ }
+ if (full) {
+ results[count] = IncrementalProjectBuilder.FULL_BUILD;
+ count++;
+ }
+ if (auto) {
+ results[count] = IncrementalProjectBuilder.AUTO_BUILD;
+ count++;
+ }
+
+ return results;
+ }
+
+ /**
+ * Creates an external tool from the map.
+ *
+ * @param commandArgs the builder ICommand arguments
+ * @param newName a new name for the tool if the one in the command is invalid
+ * @return the new external tool or <code>null</code> if not possible.
+ */
+ public static ExternalTool toolFromBuildCommandArgs(Map commandArgs, String newName) {
+ String version = (String) commandArgs.get(TAG_VERSION);
+ if (VERSION_21.equals(version)) {
+ String name = (String)commandArgs.get(TAG_NAME);
+ if (ExternalTool.validateToolName(name) != null)
+ name = newName;
+ String type = (String)commandArgs.get(TAG_TYPE);
+
+ try {
+ ExternalTool tool = new ExternalTool(type, name);
+ tool.setLocation((String)commandArgs.get(TAG_LOCATION));
+ tool.setWorkingDirectory((String)commandArgs.get(TAG_WORK_DIR));
+ tool.setCaptureOutput(TRUE.equals((String)commandArgs.get(TAG_CAPTURE_OUTPUT)));
+ tool.setShowConsole(TRUE.equals((String)commandArgs.get(TAG_SHOW_CONSOLE)));
+ tool.setRunInBackground(TRUE.equals((String)commandArgs.get(TAG_RUN_BKGRND)));
+ tool.setPromptForArguments(TRUE.equals((String)commandArgs.get(TAG_PROMPT_ARGS)));
+ tool.setShowInMenu(TRUE.equals((String)commandArgs.get(TAG_SHOW_MENU)));
+ tool.setOpenPerspective((String)commandArgs.get(TAG_OPEN_PERSP));
+ tool.setRefreshScope((String)commandArgs.get(TAG_REFRESH_SCOPE));
+ tool.setRefreshRecursive(TRUE.equals((String)commandArgs.get(TAG_REFRESH_RECURSIVE)));
+ tool.setSaveDirtyEditors(TRUE.equals((String)commandArgs.get(TAG_SAVE_DIRTY)));
+
+ String types = (String)commandArgs.get(TAG_RUN_BUILD_KINDS);
+ if (types != null && types.length() > 0)
+ tool.setRunForBuildKinds(buildTypesToArray(types));
+
+ String desc = (String)commandArgs.get(TAG_DESC);
+ if (desc != null)
+ tool.setDescription(desc);
+
+ String args = (String)commandArgs.get(TAG_ARGS);
+ if (args != null)
+ tool.setArguments(args);
+
+ String extraAttributes = (String)commandArgs.get(TAG_EXTRA_ATTR);
+ if (extraAttributes != null) {
+ StringTokenizer tokenizer = new StringTokenizer(extraAttributes, EXTRA_ATTR_SEPARATOR);
+ while (tokenizer.hasMoreTokens()) {
+ String key = tokenizer.nextToken();
+ if (!tokenizer.hasMoreTokens())
+ break;
+ String value = tokenizer.nextToken();
+ tool.setExtraAttribute(key, value);
+ }
+ }
+
+ return tool;
+ } catch (CoreException e) {
+ return null;
+ }
+ } else {
+ return ExternalToolMigration.toolFromArgumentMap(commandArgs, null, newName);
+ }
+ }
+
+ /**
+ * Creates an builder ICommand argument map for the external tool.
+ *
+ * @param tool the external tool to use
+ * @return the map of arguments representing the external tool.
+ */
+ public static Map toolToBuildCommandArgs(ExternalTool tool) {
+ Map commandArgs = new HashMap();
+ commandArgs.put(TAG_VERSION, VERSION_21);
+ commandArgs.put(TAG_TYPE, tool.getType());
+ commandArgs.put(TAG_NAME, tool.getName());
+ commandArgs.put(TAG_LOCATION, tool.getLocation());
+ commandArgs.put(TAG_WORK_DIR, tool.getWorkingDirectory());
+ commandArgs.put(TAG_CAPTURE_OUTPUT, tool.getCaptureOutput() ? TRUE : FALSE);
+ commandArgs.put(TAG_SHOW_CONSOLE, tool.getShowConsole() ? TRUE : FALSE);
+ commandArgs.put(TAG_RUN_BKGRND, tool.getRunInBackground() ? TRUE : FALSE);
+ commandArgs.put(TAG_PROMPT_ARGS, tool.getPromptForArguments() ? TRUE : FALSE);
+ commandArgs.put(TAG_SHOW_MENU, tool.getShowInMenu() ? TRUE : FALSE);
+ commandArgs.put(TAG_OPEN_PERSP, tool.getOpenPerspective());
+ commandArgs.put(TAG_REFRESH_SCOPE, tool.getRefreshScope());
+ commandArgs.put(TAG_REFRESH_RECURSIVE, tool.getRefreshRecursive() ? TRUE : FALSE);
+ commandArgs.put(TAG_SAVE_DIRTY, tool.getSaveDirtyEditors() ? TRUE : FALSE);
+ commandArgs.put(TAG_RUN_BUILD_KINDS, buildKindsToString(tool.getRunForBuildKinds()));
+ commandArgs.put(TAG_DESC, tool.getDescription());
+ commandArgs.put(TAG_ARGS, tool.getArguments());
+
+ String[] keys = tool.getExtraAttributeKeys();
+ if (keys.length > 0) {
+ StringBuffer buffer = new StringBuffer();
+ String[] values = tool.getExtraAttributeValues();
+ for (int i = 0; i < keys.length; i++) {
+ buffer.append(keys[i]);
+ buffer.append(EXTRA_ATTR_SEPARATOR);
+ buffer.append(values[i]);
+ }
+ commandArgs.put(TAG_EXTRA_ATTR, buffer.toString());
+ }
+
+ return commandArgs;
+ }
+
+ /**
+ * Adds an external tool to the in-memory registry.
+ * Note that no check for an existing tool with the
+ * same name is done.
+ */
+ private void addTool(ExternalTool tool, IPath filePath) {
+ ArrayList list = (ArrayList) tools.get(tool.getType());
+ if (list == null) {
+ list = new ArrayList(10);
+ tools.put(tool.getType(), list);
+ }
+ list.add(tool);
+
+ filenames.put(tool.getName().toLowerCase(), filePath);
+ }
+
+ /**
+ * Performs the necessary work to rename the given external tool
+ * in this tools registry. The tool's storage location is updated
+ * to a new location based on the given tool name and the registry's
+ * cache is updated. Note that this method does NOT update the "name"
+ * attribute of the given tool.
+ *
+ * This method is intended to be called only by ExternalTool.rename(String) */
+ public IStatus renameTool(ExternalTool tool, String newName) {
+ IPath filename= (IPath) filenames.get(tool.getName().toLowerCase());
+ if (filename == null) {
+ 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);
+ 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()});
+ return ExternalToolsPlugin.newErrorStatus(msg, null);
+ }
+ filenames.put(tool.getName().toLowerCase(), newPath);
+ return ExternalToolsPlugin.OK_STATUS;
+ }
+
+ /**
+ * Deletes the external tool from storage and
+ * registry.
+ */
+ public IStatus deleteTool(ExternalTool tool) {
+ IPath filename = (IPath) filenames.get(tool.getName().toLowerCase());
+ if (filename == null) {
+ String msg = ToolMessages.getString("ExternalToolRegistry.noToolFilename"); //$NON-NLS-1$
+ return ExternalToolsPlugin.newErrorStatus(msg, null);
+ }
+
+ if (!filename.toFile().delete()) {
+ String msg = ToolMessages.format("ExternalToolRegistry.deleteToolFileFailed", new Object[] {filename.toOSString()}); //$NON-NLS-1$
+ return ExternalToolsPlugin.newErrorStatus(msg, null);
+ }
+
+ filenames.remove(tool.getName().toLowerCase());
+
+ ArrayList list = (ArrayList) tools.get(tool.getType());
+ if (list != null)
+ list.remove(tool);
+
+ return ExternalToolsPlugin.OK_STATUS;
+ }
+
+
+ /**
+ * Generate a filename path to store the contents
+ * of the external tool of the specified name.
+ *
+ * @param toolName a valid external tool name
+ * @return the <code>IPath</code> for the filename
+ */
+ private IPath generateToolFilename(String toolName) {
+ String filename = toolName.replace(' ', '_');
+ return TOOLS_PATH.append(filename + TOOLS_EXTENSION);
+ }
+
+ /**
+ * Returns the number of external tools of the specified
+ * type.
+ */
+ public int getToolCountOfType(String toolTypeId) {
+ ArrayList list = (ArrayList) tools.get(toolTypeId);
+ if (list == null)
+ return 0;
+ else
+ return list.size();
+ }
+
+ /**
+ * Returns the external tool with the specified name.
+ *
+ * @return the external tool with the specified name or
+ * <code>null</code> if none exist with that name.
+ */
+ public ExternalTool getToolNamed(String name) {
+ Iterator typeEnum = tools.values().iterator();
+ while (typeEnum.hasNext()) {
+ ArrayList list = (ArrayList) typeEnum.next();
+ if (list != null && !list.isEmpty()) {
+ Iterator toolEnum = list.iterator();
+ while (toolEnum.hasNext()) {
+ ExternalTool tool = (ExternalTool)toolEnum.next();
+ if (tool.getName().equalsIgnoreCase(name))
+ return tool;
+ }
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * Returns the external tools of the specified
+ * type.
+ */
+ public ExternalTool[] getToolsOfType(String toolTypeId) {
+ ArrayList list = (ArrayList) tools.get(toolTypeId);
+ if (list == null)
+ return EMPTY_TOOLS;
+ ExternalTool[] results = new ExternalTool[list.size()];
+ list.toArray(results);
+ return results;
+ }
+
+ /**
+ * Returns whether the external tool with the specified name
+ * already exist in the in-memory registry.
+ *
+ * @return <code>true</code> if found, <code>false</code> otherwise
+ */
+ public boolean hasToolNamed(String name) {
+ return filenames.get(name.toLowerCase()) != null;
+ }
+
+ /**
+ * Loads the external tools from storage and
+ * adds them to the registry.
+ *
+ * @return a status containing any problems encountered.
+ */
+ private IStatus loadTools() {
+ String msg = ToolMessages.getString("ExternalToolRegistry.loadToolFailure"); //$NON-NLS-1$
+ MultiStatus results = new MultiStatus(IExternalToolConstants.PLUGIN_ID, 0, msg, null);
+
+ final File toolsPath = TOOLS_PATH.toFile();
+ if (toolsPath.isDirectory()) {
+ FilenameFilter filter = new FilenameFilter() {
+ public boolean accept(File dir, String name) {
+ return dir.equals(toolsPath) && name.endsWith(TOOLS_EXTENSION);
+ }
+ };
+
+ String[] files = toolsPath.list(filter);
+ for (int i = 0; i < files.length; i++) {
+ IStatus status = loadTool(TOOLS_PATH.append(files[i]));
+ if (status != null)
+ results.add(status);
+ }
+ }
+
+ return results;
+ }
+
+ /**
+ * Loads an external tool from storage.
+ */
+ private IStatus loadTool(IPath filePath) {
+ IStatus result = null;
+ InputStreamReader reader = null;
+
+ try {
+ FileInputStream input = new FileInputStream(filePath.toFile());
+ reader = new InputStreamReader(input, "utf-8"); //$NON-NLS-1$
+ IPath basePath = filePath.removeLastSegments(1).addTrailingSeparator();
+ XMLMemento memento = XMLMemento.createReadRoot(reader, basePath.toOSString());
+
+ String type = memento.getString(TAG_TYPE);
+ String name = memento.getString(TAG_NAME);
+ ExternalTool tool = new ExternalTool(type, name);
+
+ tool.setLocation(memento.getString(TAG_LOCATION));
+ tool.setWorkingDirectory(memento.getString(TAG_WORK_DIR));
+ tool.setCaptureOutput(TRUE.equals(memento.getString(TAG_CAPTURE_OUTPUT)));
+ tool.setShowConsole(TRUE.equals(memento.getString(TAG_SHOW_CONSOLE)));
+ tool.setRunInBackground(TRUE.equals(memento.getString(TAG_RUN_BKGRND)));
+ tool.setPromptForArguments(TRUE.equals(memento.getString(TAG_PROMPT_ARGS)));
+ tool.setShowInMenu(TRUE.equals(memento.getString(TAG_SHOW_MENU)));
+ tool.setOpenPerspective(memento.getString(TAG_OPEN_PERSP));
+ tool.setRefreshScope(memento.getString(TAG_REFRESH_SCOPE));
+ tool.setRefreshRecursive(TRUE.equals(memento.getString(TAG_REFRESH_RECURSIVE)));
+ tool.setSaveDirtyEditors(TRUE.equals(memento.getString(TAG_SAVE_DIRTY)));
+
+ String types = memento.getString(TAG_RUN_BUILD_KINDS);
+ if (types != null && types.length() > 0)
+ tool.setRunForBuildKinds(buildTypesToArray(types));
+
+ IMemento child = memento.getChild(TAG_DESC);
+ if (child != null)
+ tool.setDescription(child.getTextData());
+
+ child = memento.getChild(TAG_ARGS);
+ if (child != null)
+ tool.setArguments(child.getTextData());
+
+ IMemento[] attributes = memento.getChildren(TAG_EXTRA_ATTR);
+ for (int i = 0; i < attributes.length; i++) {
+ String key = attributes[i].getString(TAG_KEY);
+ String value = attributes[i].getTextData();
+ tool.setExtraAttribute(key, value);
+ }
+
+ addTool(tool, filePath);
+ } catch (FileNotFoundException e) {
+ String msg = e.getMessage();
+ if (msg == null)
+ msg = ToolMessages.getString("ExternalToolRegistry.fileNotFoundError"); //$NON-NLS-1$
+ result = ExternalToolsPlugin.newErrorStatus(msg, e);
+ } catch (IOException e) {
+ String msg = e.getMessage();
+ if (msg == null)
+ msg = ToolMessages.getString("ExternalToolRegistry.ioLoadError"); //$NON-NLS-1$
+ result = ExternalToolsPlugin.newErrorStatus(msg, e);
+ } catch (CoreException e) {
+ result = e.getStatus();
+ } finally {
+ if (reader != null) {
+ try {
+ reader.close();
+ } catch(IOException e) {
+ ExternalToolsPlugin.getDefault().log("Unable to close external tool storage reader.", e); //$NON-NLS-1$
+ }
+ }
+ }
+
+ return result;
+ }
+
+ /**
+ * Cause the registry to reload all the tools from storage.
+ *
+ * @return a status containing any problems encountered.
+ */
+ public IStatus reloadTools() {
+ tools = new HashMap();
+ return loadTools();
+ }
+
+ /**
+ * Save an external tool to storage. Adds it to the
+ * in-memory registry if new.
+ */
+ public IStatus saveTool(ExternalTool tool) {
+ boolean isNew = false;
+
+ IPath filename = (IPath) filenames.get(tool.getName().toLowerCase());
+ if (filename == null) {
+ filename = generateToolFilename(tool.getName());
+ isNew = true;
+ }
+
+ // Ensure the extenal tool storage directory exist
+ TOOLS_PATH.toFile().mkdirs();
+
+ IStatus results = storeTool(tool, filename);
+ if (results != null)
+ return results;
+
+ if (isNew)
+ addTool(tool, filename);
+
+ return ExternalToolsPlugin.OK_STATUS;
+ }
+
+ /**
+ * Stores an external tool to storage.
+ */
+ private IStatus storeTool(ExternalTool tool, IPath filePath) {
+ IStatus result = null;
+
+ // Populate the memento
+ XMLMemento memento = XMLMemento.createWriteRoot(TAG_EXTERNAL_TOOL);
+ memento.putString(TAG_VERSION, VERSION_21);
+ memento.putString(TAG_TYPE, tool.getType());
+ memento.putString(TAG_NAME, tool.getName());
+ memento.putString(TAG_LOCATION, tool.getLocation());
+ memento.putString(TAG_WORK_DIR, tool.getWorkingDirectory());
+ memento.putString(TAG_CAPTURE_OUTPUT, tool.getCaptureOutput() ? TRUE : FALSE);
+ memento.putString(TAG_SHOW_CONSOLE, tool.getShowConsole() ? TRUE : FALSE);
+ memento.putString(TAG_RUN_BKGRND, tool.getRunInBackground() ? TRUE : FALSE);
+ memento.putString(TAG_PROMPT_ARGS, tool.getPromptForArguments() ? TRUE : FALSE);
+ memento.putString(TAG_SHOW_MENU, tool.getShowInMenu() ? TRUE : FALSE);
+ memento.putString(TAG_OPEN_PERSP, tool.getOpenPerspective());
+ memento.putString(TAG_REFRESH_SCOPE, tool.getRefreshScope());
+ memento.putString(TAG_REFRESH_RECURSIVE, tool.getRefreshRecursive() ? TRUE : FALSE);
+ memento.putString(TAG_SAVE_DIRTY, tool.getSaveDirtyEditors() ? TRUE : FALSE);
+ memento.putString(TAG_RUN_BUILD_KINDS, buildKindsToString(tool.getRunForBuildKinds()));
+
+ IMemento child = memento.createChild(TAG_DESC);
+ if (child != null)
+ child.putTextData(tool.getDescription());
+
+ child = memento.createChild(TAG_ARGS);
+ if (child != null)
+ child.putTextData(tool.getArguments());
+
+ String[] keys = tool.getExtraAttributeKeys();
+ if (keys.length > 0) {
+ String[] values = tool.getExtraAttributeValues();
+ for (int i = 0; i < keys.length; i++) {
+ child = memento.createChild(TAG_EXTRA_ATTR);
+ if (child != null) {
+ child.putString(TAG_KEY, keys[i]);
+ child.putTextData(values[i]);
+ }
+ }
+ }
+
+ // Write the memento to the file
+ File toolFile = filePath.toFile();
+ OutputStreamWriter writer = null;
+ try {
+ FileOutputStream stream = new FileOutputStream(toolFile);
+ writer = new OutputStreamWriter(stream, "utf-8"); //$NON-NLS-1$
+ memento.save(writer);
+ } catch (IOException e) {
+ toolFile.delete();
+ String msg = e.getMessage();
+ if (msg == null)
+ msg = ToolMessages.getString("ExternalToolRegistry.ioSaveError"); //$NON-NLS-1$
+ result = ExternalToolsPlugin.newErrorStatus(msg, e);
+ } finally {
+ if (writer != null) {
+ try {
+ writer.close();
+ } catch(IOException e) {
+ ExternalToolsPlugin.getDefault().log("Unable to close external tool storage writer.", e); //$NON-NLS-1$
+ }
+ }
+ if (result != null)
+ toolFile.delete();
+ }
+
+ return result;
+ }
+}
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/registry/ExternalToolType.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/registry/ExternalToolType.java
new file mode 100644
index 000000000..b00d7f8f1
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/registry/ExternalToolType.java
@@ -0,0 +1,155 @@
+package org.eclipse.ui.externaltools.internal.registry;
+
+/**********************************************************************
+Copyright (c) 2002 IBM Corp. and others. All rights reserved.
+This file is 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:
+**********************************************************************/
+
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IPluginDescriptor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.externaltools.internal.model.ExternalToolsPlugin;
+import org.eclipse.ui.externaltools.model.IExternalToolRunner;
+import org.eclipse.ui.model.IWorkbenchAdapter;
+
+/**
+ * This class represents the definition of an external
+ * tool type.
+ */
+public final class ExternalToolType implements IAdaptable {
+ private ToolTypeWorkbenchAdapter workbenchAdapter;
+
+ private String id;
+ private String name;
+ private IConfigurationElement element;
+ private ImageDescriptor imageDescriptor;
+ private IExternalToolRunner runner;
+
+ /**
+ * Create a new external tool type.
+ *
+ * @param id the unique identifier of this type
+ * @param name a user readable label for this type
+ * @param element the configuration element for the extension
+ */
+ /*package*/ ExternalToolType(String id, String name, IConfigurationElement element) {
+ super();
+ this.id = id;
+ this.name = name;
+ this.element = element;
+ }
+
+ /* (non-Javadoc)
+ * Method declared on IAdaptable.
+ */
+ public Object getAdapter(Class adapter) {
+ if (adapter == IWorkbenchAdapter.class) {
+ if (workbenchAdapter == null)
+ workbenchAdapter = new ToolTypeWorkbenchAdapter();
+ return workbenchAdapter;
+ }
+ return null;
+ }
+
+ /**
+ * Returns a short description of this type.
+ */
+ public String getDescription() {
+ String description = element.getAttribute(ExternalToolTypeRegistry.TAG_DESCRIPTION);
+ if (description == null)
+ description = ""; //$NON-NLS-1$
+ return description;
+ }
+
+ /**
+ * Returns the id.
+ */
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * Returns the name.
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Returns the image descriptor for this tool type icon.
+ */
+ public ImageDescriptor getImageDescriptor() {
+ if (imageDescriptor == null) {
+ IExtension extension = element.getDeclaringExtension();
+ IPluginDescriptor pluginDescriptor = extension.getDeclaringPluginDescriptor();
+ String location = element.getAttribute(ExternalToolTypeRegistry.TAG_ICON);
+ if (location != null && location.length() > 0) {
+ URL fullPath = pluginDescriptor.find(new Path(location));
+ if (fullPath != null) {
+ imageDescriptor = ImageDescriptor.createFromURL(fullPath);
+ } else {
+ try {
+ URL installURL = pluginDescriptor.getInstallURL();
+ fullPath = new URL(installURL, location);
+ imageDescriptor = ImageDescriptor.createFromURL(fullPath);
+ } catch (MalformedURLException e) {
+ }
+ }
+ }
+ if (imageDescriptor == null)
+ imageDescriptor = ImageDescriptor.getMissingImageDescriptor();
+ }
+ return imageDescriptor;
+ }
+
+ /**
+ * Returns the runner to run external tools of this type
+ * or <code>null</code> if none provided by client.
+ */
+ public IExternalToolRunner getRunner() {
+ if (runner == null) {
+ try {
+ runner = (IExternalToolRunner) element.createExecutableExtension(ExternalToolTypeRegistry.TAG_RUN_CLASS);
+ } catch (CoreException e) {
+ ExternalToolsPlugin.getDefault().getLog().log(e.getStatus());
+ }
+ }
+ return runner;
+ }
+
+
+ /**
+ * Internal workbench adapter implementation
+ */
+ private static class ToolTypeWorkbenchAdapter implements IWorkbenchAdapter {
+ public Object[] getChildren(Object o) {
+ ExternalToolType type = (ExternalToolType)o;
+ return ExternalToolsPlugin.getDefault().getToolRegistry(null).getToolsOfType(type.getId());
+ }
+
+ public ImageDescriptor getImageDescriptor(Object o) {
+ return PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_OBJ_FOLDER);
+ }
+
+ public String getLabel(Object o) {
+ return ((ExternalToolType)o).getName();
+ }
+
+ public Object getParent(Object o) {
+ return null;
+ }
+ }
+}
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/registry/ExternalToolTypeRegistry.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/registry/ExternalToolTypeRegistry.java
new file mode 100644
index 000000000..79bb765d8
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/registry/ExternalToolTypeRegistry.java
@@ -0,0 +1,156 @@
+package org.eclipse.ui.externaltools.internal.registry;
+
+/**********************************************************************
+Copyright (c) 2002 IBM Corp. and others. All rights reserved.
+This file is 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:
+**********************************************************************/
+
+import java.util.ArrayList;
+
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IPluginRegistry;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.externaltools.internal.model.ExternalToolsPlugin;
+import org.eclipse.ui.externaltools.model.IExternalToolConstants;
+
+/**
+ * The registry of available external tool types.
+ */
+public class ExternalToolTypeRegistry {
+ // Format of the tool type extension point
+ // <extension point="org.eclipse.ui.externalTools.toolTypes>
+ // <toolType
+ // id={string}
+ // name={string}
+ // description={string}
+ // icon={string:path}
+ // runnerClass={string:IExternalToolRunner}>
+ // </toolType>
+ // </extension>
+ //
+ /**
+ * Element and attribute tags a tool type extension point.
+ */
+ /*package*/ static final String TAG_TOOL_TYPE = "toolType"; //$NON-NLS-1$
+ /*package*/ static final String TAG_ID = "id"; //$NON-NLS-1$
+ /*package*/ static final String TAG_NAME = "name"; //$NON-NLS-1$
+ /*package*/ static final String TAG_ICON = "icon"; //$NON-NLS-1$
+ /*package*/ static final String TAG_RUN_CLASS = "runnerClass"; //$NON-NLS-1$
+ /*package*/ static final String TAG_DESCRIPTION = "description"; //$NON-NLS-1$
+
+ private ArrayList types;
+
+ /**
+ * Creates a new registry and loads the available type
+ * of external tools.
+ */
+ public ExternalToolTypeRegistry() {
+ super();
+ loadTypes();
+ }
+
+ /**
+ * Returns the tool type for the specified id, or
+ * <code>null</code> if none found.
+ */
+ public ExternalToolType getToolType(String toolTypeId) {
+ for (int i = 0; i < types.size(); i++) {
+ ExternalToolType type = (ExternalToolType) types.get(i);
+ if (type.getId().equals(toolTypeId))
+ return type;
+ }
+ return null;
+ }
+
+ /**
+ * Returns the tool type image for the specified id.
+ */
+ public ImageDescriptor getToolTypeImageDescriptor(String toolTypeId) {
+ ExternalToolType type = getToolType(toolTypeId);
+ if (type == null)
+ return ImageDescriptor.getMissingImageDescriptor();
+ else
+ return type.getImageDescriptor();
+ }
+
+ /**
+ * Returns the types in the registry
+ */
+ public ExternalToolType[] getToolTypes() {
+ ExternalToolType[] results = new ExternalToolType[types.size()];
+ types.toArray(results);
+ return results;
+ }
+
+ /**
+ * Returns the number of tool types in the registry.
+ */
+ public int getTypeCount() {
+ return types.size();
+ }
+
+ /**
+ * Returns whether the tool type is known to
+ * the registry.
+ */
+ public boolean hasType(String toolTypeId) {
+ for (int i = 0; i < types.size(); i++) {
+ ExternalToolType type = (ExternalToolType) types.get(i);
+ if (type.getId().equals(toolTypeId))
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Load the available types of external tools.
+ */
+ private void loadTypes() {
+ types = new ArrayList(10);
+ IPluginRegistry registry = Platform.getPluginRegistry();
+ IExtensionPoint point = registry.getExtensionPoint(IExternalToolConstants.PLUGIN_ID, IExternalToolConstants.PL_TOOL_TYPES);
+ if (point != null) {
+ IExtension[] extensions = point.getExtensions();
+ for (int i = 0; i < extensions.length; i++) {
+ IConfigurationElement[] elements = extensions[i].getConfigurationElements();
+ for (int j = 0; j < elements.length; j++) {
+ IConfigurationElement element = elements[j];
+ if (element.getName().equals(TAG_TOOL_TYPE)) {
+ String id = element.getAttribute(TAG_ID);
+ String name = element.getAttribute(TAG_NAME);
+ String iconPath = element.getAttribute(TAG_ICON);
+ String runClassName = element.getAttribute(TAG_RUN_CLASS);
+
+ boolean valid = true;
+ if (id == null || id.length() == 0) {
+ valid = false;
+ ExternalToolsPlugin.getDefault().log("Missing id attribute value for toolType element.", null); //$NON-NLS-1$
+ }
+ if (name == null || name.length() == 0) {
+ valid = false;
+ ExternalToolsPlugin.getDefault().log("Missing name attribute value for toolType element.", null); //$NON-NLS-1$
+ }
+ if (iconPath == null || iconPath.length() == 0) {
+ valid = false;
+ ExternalToolsPlugin.getDefault().log("Missing icon attribute value for toolType element.", null); //$NON-NLS-1$
+ }
+ if (runClassName == null || runClassName.length() == 0) {
+ valid = false;
+ ExternalToolsPlugin.getDefault().log("Missing class attribute value for toolType element.", null); //$NON-NLS-1$
+ }
+
+ if (valid)
+ types.add(new ExternalToolType(id, name, element));
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/registry/ExternalToolVariable.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/registry/ExternalToolVariable.java
new file mode 100644
index 000000000..df04fae4a
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/registry/ExternalToolVariable.java
@@ -0,0 +1,154 @@
+package org.eclipse.ui.externaltools.internal.registry;
+
+/**********************************************************************
+Copyright (c) 2002 IBM Corp. and others. All rights reserved.
+This file is 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:
+**********************************************************************/
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.jface.resource.JFaceColors;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.ui.externaltools.group.IGroupDialogPage;
+import org.eclipse.ui.externaltools.internal.model.ExternalToolsPlugin;
+import org.eclipse.ui.externaltools.internal.model.ToolMessages;
+import org.eclipse.ui.externaltools.variable.IVariableComponent;
+
+/**
+ * Abtract representation of the different variables.
+ */
+public abstract class ExternalToolVariable {
+ private static final IVariableComponent defaultComponent = new DefaultVariableComponent(false);
+
+ private String tag;
+ private String description;
+ private IConfigurationElement element;
+
+ /**
+ * Creates an variable definition
+ *
+ * @param tag the variable tag
+ * @param description a short description of what the variable will expand to
+ * @param element the configuration element
+ */
+ /*package*/ ExternalToolVariable(String tag, String description, IConfigurationElement element) {
+ super();
+ this.tag = tag;
+ this.description = description;
+ this.element = element;
+ }
+
+ /**
+ * Creates an instance of the class specified by
+ * the given element attribute name. Can return
+ * <code>null</code> if none or if problems creating
+ * the instance.
+ */
+ protected final Object createObject(String attributeName) {
+ try {
+ return element.createExecutableExtension(attributeName);
+ } catch (CoreException e) {
+ ExternalToolsPlugin.getDefault().getLog().log(e.getStatus());
+ return null;
+ }
+ }
+
+ /**
+ * Returns the component class to allow
+ * visual editing of the variable's value.
+ */
+ public final IVariableComponent getComponent() {
+ String className = element.getAttribute(ExternalToolVariableRegistry.TAG_COMPONENT_CLASS);
+ if (className == null || className.trim().length() == 0)
+ return defaultComponent;
+
+ Object component = createObject(ExternalToolVariableRegistry.TAG_COMPONENT_CLASS);
+ if (component == null)
+ return new DefaultVariableComponent(true);
+ else
+ return (IVariableComponent)component;
+ }
+
+ /**
+ * Returns the variable's description
+ */
+ public final String getDescription() {
+ return description;
+ }
+
+ /**
+ * Returns the variable's tag
+ */
+ public final String getTag() {
+ return tag;
+ }
+
+
+ /**
+ * Default variable component implementation which does not
+ * allow variable value editing visually.
+ */
+ private static final class DefaultVariableComponent implements IVariableComponent {
+ private boolean showError = false;
+ private Label message = null;
+
+ public DefaultVariableComponent(boolean showError) {
+ super();
+ this.showError = showError;
+ }
+
+ /* (non-Javadoc)
+ * Method declared on IVariableComponent.
+ */
+ public Control getControl() {
+ return message;
+ }
+
+ /* (non-Javadoc)
+ * Method declared on IVariableComponent.
+ */
+ public void createContents(Composite parent, String varTag, IGroupDialogPage page) {
+ if (showError) {
+ message = new Label(parent, SWT.NONE);
+ GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ message.setLayoutData(data);
+ message.setText(ToolMessages.getString("ExternalToolVariable.componentErrorMessage")); //$NON-NLS-1$
+ message.setForeground(JFaceColors.getErrorText(message.getDisplay()));
+ }
+ }
+
+ /* (non-Javadoc)
+ * Method declared on IVariableComponent.
+ */
+ public String getVariableValue() {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * Method declared on IVariableComponent.
+ */
+ public boolean isValid() {
+ return true;
+ }
+
+ /* (non-Javadoc)
+ * Method declared on IVariableComponent.
+ */
+ public void setVariableValue(String varValue) {
+ }
+
+ /* (non-Javadoc)
+ * Method declared on IVariableComponent.
+ */
+ public void validate() {
+ }
+ }
+}
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/registry/ExternalToolVariableRegistry.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/registry/ExternalToolVariableRegistry.java
new file mode 100644
index 000000000..b66bf565a
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/registry/ExternalToolVariableRegistry.java
@@ -0,0 +1,135 @@
+package org.eclipse.ui.externaltools.internal.registry;
+
+/**********************************************************************
+Copyright (c) 2002 IBM Corp. and others. All rights reserved.
+This file is 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:
+**********************************************************************/
+
+import java.util.HashMap;
+
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IPluginRegistry;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.ui.externaltools.internal.model.ExternalToolsPlugin;
+import org.eclipse.ui.externaltools.model.IExternalToolConstants;
+
+/**
+ * General registry reader for external tool variables.
+ */
+public abstract class ExternalToolVariableRegistry {
+ // Format of the variable extension points
+ // <extension point="org.eclipse.ui.externalTools.***Variables>
+ // <variable
+ // tag={string}
+ // description={string}
+ // componentClass={string:IVariableComponent}
+ // expanderClass={string:IVariable***Expander}>
+ // </variable>
+ // </extension>
+ //
+
+ /**
+ * Element and attribute tags of a variable extension.
+ */
+ /*package*/ static final String TAG_VARIABLE = "variable"; //$NON-NLS-1$
+ /*package*/ static final String TAG_TAG = "tag"; //$NON-NLS-1$
+ /*package*/ static final String TAG_DESCRIPTION = "description"; //$NON-NLS-1$
+ /*package*/ static final String TAG_COMPONENT_CLASS = "componentClass"; //$NON-NLS-1$
+ /*package*/ static final String TAG_EXPANDER_CLASS = "expanderClass"; //$NON-NLS-1$
+
+
+ /**
+ * Table of variables where the key is the variable tag
+ * and the value is the corresponding variable.
+ */
+ private HashMap variables;
+
+ /**
+ * The extension point id to read the variables from
+ */
+ private String extensionPointId;
+
+ /**
+ * The
+ /**
+ * Creates a new registry and loads the variables.
+ */
+ public ExternalToolVariableRegistry(String extensionPointId) {
+ super();
+ this.extensionPointId = extensionPointId;
+ loadVariables();
+ }
+
+ /**
+ * Returns the variables in the registry
+ */
+ protected final void copyVariables(Object[] results) {
+ variables.values().toArray(results);
+ }
+
+ /**
+ * Returns the variable for the specified tag, or
+ * <code>null</code> if none found.
+ */
+ protected final ExternalToolVariable findVariable(String tag) {
+ return (ExternalToolVariable) variables.get(tag);
+ }
+
+ /**
+ * Returns the number of variables in the registry.
+ */
+ public final int getVariableCount() {
+ return variables.size();
+ }
+
+ /**
+ * Load the available variables
+ */
+ private void loadVariables() {
+ variables = new HashMap();
+ IPluginRegistry registry = Platform.getPluginRegistry();
+ IExtensionPoint point = registry.getExtensionPoint(IExternalToolConstants.PLUGIN_ID, extensionPointId);
+ if (point != null) {
+ IExtension[] extensions = point.getExtensions();
+ for (int i = 0; i < extensions.length; i++) {
+ IConfigurationElement[] elements = extensions[i].getConfigurationElements();
+ for (int j = 0; j < elements.length; j++) {
+ IConfigurationElement element = elements[j];
+ if (element.getName().equals(TAG_VARIABLE)) {
+ String tag = element.getAttribute(TAG_TAG);
+ String description = element.getAttribute(TAG_DESCRIPTION);
+ String className = element.getAttribute(TAG_EXPANDER_CLASS);
+
+ boolean valid = true;
+ if (tag == null || tag.length() == 0) {
+ valid = false;
+ ExternalToolsPlugin.getDefault().log("Missing tag attribute value for variable element.", null); //$NON-NLS-1$
+ }
+ if (description == null || description.length() == 0) {
+ valid = false;
+ ExternalToolsPlugin.getDefault().log("Missing description attribute value for variable element.", null); //$NON-NLS-1$
+ }
+ if (className == null || className.length() == 0) {
+ valid = false;
+ ExternalToolsPlugin.getDefault().log("Missing expander class attribute value for variable element.", null); //$NON-NLS-1$
+ }
+
+ if (valid)
+ variables.put(tag, newVariable(tag, description, element));
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Creates a new variable from the specified information.
+ */
+ protected abstract ExternalToolVariable newVariable(String tag, String description, IConfigurationElement element);
+}
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/registry/PathLocationVariable.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/registry/PathLocationVariable.java
new file mode 100644
index 000000000..2d9c5b9e8
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/registry/PathLocationVariable.java
@@ -0,0 +1,62 @@
+package org.eclipse.ui.externaltools.internal.registry;
+
+/**********************************************************************
+Copyright (c) 2002 IBM Corp. and others. All rights reserved.
+This file is 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:
+**********************************************************************/
+
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.ui.externaltools.variable.IVariableLocationExpander;
+import org.eclipse.ui.externaltools.variable.ExpandVariableContext;
+
+/**
+ * Represents the variable for the path location
+ */
+public final class PathLocationVariable extends ExternalToolVariable {
+ private static final DefaultLocationExpander defaultExpander = new DefaultLocationExpander();
+
+ private IVariableLocationExpander expander = null;
+
+ /**
+ * Creates a path location variable
+ *
+ * @param tag the variable tag
+ * @param description a short description of what the variable will expand to
+ * @param element the configuration element
+ */
+ /*package*/ PathLocationVariable(String tag, String description, IConfigurationElement element) {
+ super(tag, description, element);
+ }
+
+ /**
+ * Returns the object that can expand the variable
+ * into a path location.
+ */
+ public IVariableLocationExpander getExpander() {
+ if (expander == null) {
+ expander = (IVariableLocationExpander) createObject(ExternalToolVariableRegistry.TAG_EXPANDER_CLASS);
+ if (expander == null)
+ expander = defaultExpander;
+ }
+ return expander;
+ }
+
+
+ /**
+ * Default variable location implementation which does
+ * not expand variables, but just returns <code>null</code>.
+ */
+ private static final class DefaultLocationExpander implements IVariableLocationExpander {
+ /* (non-Javadoc)
+ * Method declared on IVariableLocationExpander.
+ */
+ public IPath getPath(String varTag, String varValue, ExpandVariableContext context) {
+ return null;
+ }
+ }
+}
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/registry/PathLocationVariableRegistry.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/registry/PathLocationVariableRegistry.java
new file mode 100644
index 000000000..557f0a356
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/registry/PathLocationVariableRegistry.java
@@ -0,0 +1,49 @@
+package org.eclipse.ui.externaltools.internal.registry;
+
+/**********************************************************************
+Copyright (c) 2002 IBM Corp. and others. All rights reserved.
+This file is 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:
+**********************************************************************/
+
+import org.eclipse.core.runtime.IConfigurationElement;
+
+/**
+ * Registry of all available path location variables.
+ */
+public class PathLocationVariableRegistry extends ExternalToolVariableRegistry {
+
+ /**
+ * Creates the registry and loads the variables.
+ */
+ public PathLocationVariableRegistry(String extensionPointId) {
+ super(extensionPointId);
+ }
+
+ /**
+ * Returns the path location variable for the given tag
+ * or <code>null</code> if none.
+ */
+ public PathLocationVariable getPathLocationVariable(String tag) {
+ return (PathLocationVariable) findVariable(tag);
+ }
+
+ /**
+ * Returns the list of path location variables in the registry.
+ */
+ public PathLocationVariable[] getPathLocationVariables() {
+ PathLocationVariable[] results = new PathLocationVariable[getVariableCount()];
+ copyVariables(results);
+ return results;
+ }
+
+ /* (non-Javadoc)
+ * Method declared on ExternalToolVariableRegistry.
+ */
+ protected ExternalToolVariable newVariable(String tag, String description, IConfigurationElement element) {
+ return new PathLocationVariable(tag, description, element);
+ }
+}
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/registry/RefreshScopeVariable.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/registry/RefreshScopeVariable.java
new file mode 100644
index 000000000..bd8578076
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/registry/RefreshScopeVariable.java
@@ -0,0 +1,62 @@
+package org.eclipse.ui.externaltools.internal.registry;
+
+/**********************************************************************
+Copyright (c) 2002 IBM Corp. and others. All rights reserved.
+This file is 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:
+**********************************************************************/
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.ui.externaltools.variable.ExpandVariableContext;
+import org.eclipse.ui.externaltools.variable.IVariableResourceExpander;
+
+/**
+ * Represents the variable for a refresh scope.
+ */
+public final class RefreshScopeVariable extends ExternalToolVariable {
+ private static final DefaultResourceExpander defaultExpander = new DefaultResourceExpander();
+
+ private IVariableResourceExpander expander = null;
+
+ /**
+ * Creates a refresh scope variable
+ *
+ * @param tag the variable tag
+ * @param description a short description of what the variable will expand to
+ * @param element the configuration element
+ */
+ /*package*/ RefreshScopeVariable(String tag, String description, IConfigurationElement element) {
+ super(tag, description, element);
+ }
+
+ /**
+ * Returns the object that can expand the variable
+ * as resources.
+ */
+ public IVariableResourceExpander getExpander() {
+ if (expander == null) {
+ expander = (IVariableResourceExpander) createObject(ExternalToolVariableRegistry.TAG_EXPANDER_CLASS);
+ if (expander == null)
+ expander = defaultExpander;
+ }
+ return expander;
+ }
+
+
+ /**
+ * Default variable resource expander implementation which does
+ * not expand variables, but just returns <code>null</code>.
+ */
+ private static final class DefaultResourceExpander implements IVariableResourceExpander {
+ /* (non-Javadoc)
+ * Method declared on IVariableResourceExpander.
+ */
+ public IResource[] getResources(String varTag, String varValue, ExpandVariableContext context) {
+ return null;
+ }
+ }
+}
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/registry/RefreshScopeVariableRegistry.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/registry/RefreshScopeVariableRegistry.java
new file mode 100644
index 000000000..afaa57845
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/registry/RefreshScopeVariableRegistry.java
@@ -0,0 +1,50 @@
+package org.eclipse.ui.externaltools.internal.registry;
+
+/**********************************************************************
+Copyright (c) 2002 IBM Corp. and others. All rights reserved.
+This file is 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:
+**********************************************************************/
+
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.ui.externaltools.model.IExternalToolConstants;
+
+/**
+ * Registry of all available refresh scope variables.
+ */
+public class RefreshScopeVariableRegistry extends ExternalToolVariableRegistry {
+
+ /**
+ * Creates the registry and loads the variables.
+ */
+ public RefreshScopeVariableRegistry() {
+ super(IExternalToolConstants.PL_REFRESH_VARIABLES);
+ }
+
+ /**
+ * Returns the refresh scope variable for the given tag
+ * or <code>null</code> if none.
+ */
+ public RefreshScopeVariable getRefreshVariable(String tag) {
+ return (RefreshScopeVariable) findVariable(tag);
+ }
+
+ /**
+ * Returns the list of refresh scope variables in the registry.
+ */
+ public RefreshScopeVariable[] getRefreshVariables() {
+ RefreshScopeVariable[] results = new RefreshScopeVariable[getVariableCount()];
+ copyVariables(results);
+ return results;
+ }
+
+ /* (non-Javadoc)
+ * Method declared on ExternalToolVariableRegistry.
+ */
+ protected ExternalToolVariable newVariable(String tag, String description, IConfigurationElement element) {
+ return new RefreshScopeVariable(tag, description, element);
+ }
+}
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/AntAction.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/AntAction.java
new file mode 100644
index 000000000..900f7ff30
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/AntAction.java
@@ -0,0 +1,166 @@
+package org.eclipse.ui.externaltools.internal.ui;
+
+/**********************************************************************
+Copyright (c) 2002 IBM Corp. and others.
+All rights reserved.   This program and the accompanying materials
+are made available under the terms of the Common Public License v0.5
+which accompanies this distribution, and is available at
+http://www.eclipse.org/legal/cpl-v05.html
+Contributors:
+**********************************************************************/
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.MultiStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.swt.custom.BusyIndicator;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.dialogs.ElementListSelectionDialog;
+import org.eclipse.ui.externaltools.internal.ant.dialog.AntExternalToolNewWizard;
+import org.eclipse.ui.externaltools.internal.model.DefaultRunnerContext;
+import org.eclipse.ui.externaltools.internal.model.ExternalToolsPlugin;
+import org.eclipse.ui.externaltools.internal.model.IHelpContextIds;
+import org.eclipse.ui.externaltools.internal.registry.ExternalToolRegistry;
+import org.eclipse.ui.externaltools.internal.view.ExternalToolLabelProvider;
+import org.eclipse.ui.externaltools.model.ExternalTool;
+import org.eclipse.ui.externaltools.model.ExternalToolStorage;
+import org.eclipse.ui.externaltools.model.IExternalToolConstants;
+import org.eclipse.ui.externaltools.model.IStorageListener;
+import org.eclipse.ui.externaltools.model.ToolUtil;
+import org.eclipse.ui.externaltools.variable.ExpandVariableContext;
+import org.eclipse.ui.help.WorkbenchHelp;
+
+/**
+ * Action to run an ant build file.
+ */
+public class AntAction extends Action {
+ private IFile file;
+ private IWorkbenchWindow window;
+
+ /**
+ * Creates an initialize action to run an
+ * Ant build file
+ *
+ * @param file the ant build file to run
+ */
+ public AntAction(IFile file, IWorkbenchWindow window) {
+ super();
+ this.file = file;
+ this.window = window;
+ setText(file.getName());
+ setToolTipText(file.getFullPath().toOSString());
+ WorkbenchHelp.setHelp(this, IHelpContextIds.ANT_ACTION);
+ }
+
+ private Shell getShell() {
+ return PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
+ }
+
+ private ExternalTool chooseTool(List tools) {
+ ILabelProvider labelProvider = new ExternalToolLabelProvider();
+ ElementListSelectionDialog dialog= new ElementListSelectionDialog(getShell(), labelProvider);
+ dialog.setElements((ExternalTool[]) tools.toArray(new ExternalTool[tools.size()]));
+ dialog.setTitle("Ant Tool Selection");
+ dialog.setMessage("Choose an ant tool to run");
+ dialog.setMultipleSelection(false);
+ int result = dialog.open();
+ labelProvider.dispose();
+ if (result == ElementListSelectionDialog.OK) {
+ return (ExternalTool) dialog.getFirstResult();
+ }
+ return null;
+ }
+
+ public void runTool(final ExternalTool tool) {
+ final MultiStatus status = new MultiStatus(IExternalToolConstants.PLUGIN_ID, 0, "", null);
+ BusyIndicator.showWhile(getShell().getDisplay(), new Runnable() {
+ public void run() {
+ new DefaultRunnerContext(tool, file).run(new NullProgressMonitor(), status);
+ }
+ });
+ if (!status.isOK()) {
+ StringBuffer message= new StringBuffer("An exception occurred while running ant: ");
+ IStatus[] errors= status.getChildren();
+ IStatus error;
+ for (int i= 0, numErrors= errors.length; i < numErrors; i++) {
+ error= errors[i];
+ if (error.getSeverity() == IStatus.ERROR) {
+ Throwable exception= error.getException();
+ message.append('\n');
+ if (exception != null) {
+ message.append(exception.getClass().getName()).append(' ');
+ }
+ message.append(error.getMessage());
+ }
+ }
+ MessageDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "Ant Error", message.toString());
+ }
+ }
+
+ /* (non-Javadoc)
+ * Method declared on IAction.
+ */
+ public void run() {
+ if (file == null) {
+ return;
+ }
+
+ ExternalTool tool= null;
+ ExternalToolRegistry registry= ExternalToolsPlugin.getDefault().getToolRegistry(getShell());
+ ExternalTool[] antTools= registry.getToolsOfType(IExternalToolConstants.TOOL_TYPE_ANT_BUILD);
+ MultiStatus status = new MultiStatus(IExternalToolConstants.PLUGIN_ID, 0, "An error occurred while expanding the location of one or more ant tools: ", null);
+ List tools= new ArrayList();
+ String toolLocation;
+ for (int i= 0, numTools= antTools.length; i < numTools; i++) {
+ toolLocation= ToolUtil.expandFileLocation(antTools[i].getLocation(), ExpandVariableContext.EMPTY_CONTEXT, status);
+ if (toolLocation != null && toolLocation.equals(file.getLocation().toString())) {
+ tools.add(antTools[i]);
+ }
+ }
+ if (tools.size() == 1) {
+ tool= (ExternalTool)tools.get(0);
+ } else if (tools.size() > 1) {
+ tool= chooseTool(tools);
+ if (tool == null) {
+ // User cancelled.
+ return;
+ }
+ }
+
+ if (tool != null) {
+ runTool(tool);
+ return;
+ }
+ WizardDialog dialog= new WizardDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), new AntExternalToolNewWizard(file));
+ dialog.open();
+ if (dialog.getReturnCode() == WizardDialog.CANCEL) {
+ return;
+ }
+ ExternalToolStorage.addStorageListener(new IStorageListener() {
+ public void toolDeleted(ExternalTool tool) {
+ }
+
+ public void toolCreated(ExternalTool tool) {
+ if (tool.getLocation().equals(file.getLocation().toString())) { // Is this the tool we're expecting?
+ runTool(tool);
+ }
+ ExternalToolStorage.removeStorageListener(this);
+ }
+
+ public void toolModified(ExternalTool tool) {
+ }
+
+ public void toolsRefreshed() {
+ }
+ });
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/AntLaunchWizard.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/AntLaunchWizard.java
new file mode 100644
index 000000000..8711353cc
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/AntLaunchWizard.java
@@ -0,0 +1,176 @@
+package org.eclipse.ui.externaltools.internal.ui;
+
+/**********************************************************************
+Copyright (c) 2002 IBM Corp. and others.
+All rights reserved.   This program and the accompanying materials
+are made available under the terms of the Common Public License v0.5
+which accompanies this distribution, and is available at
+http://www.eclipse.org/legal/cpl-v05.html
+Contributors:
+**********************************************************************/
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.eclipse.ant.core.TargetInfo;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.MultiStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.externaltools.internal.ant.model.AntUtil;
+import org.eclipse.ui.externaltools.internal.model.DefaultRunnerContext;
+import org.eclipse.ui.externaltools.internal.model.ExternalToolsPlugin;
+import org.eclipse.ui.externaltools.internal.model.ToolMessages;
+import org.eclipse.ui.externaltools.model.ExternalTool;
+import org.eclipse.ui.externaltools.model.IExternalToolConstants;
+import org.eclipse.ui.externaltools.model.ToolUtil;
+
+/**
+ * The wizard to run an Ant file when the Run Ant...
+ * context menu action is choosen by the user.
+ * <p>
+ * Note: Currently there is only one page in this wizard.
+ * </p>
+ */
+public class AntLaunchWizard extends Wizard {
+ /**
+ * The file that contains the Ant file.
+ */
+ private IFile antFile = null;
+
+ /**
+ * The Ant project described in the xml file.
+ */
+ private TargetInfo[] targetList = null;
+
+ /**
+ * The external tool representing the Ant file
+ */
+ private ExternalTool antTool = null;
+
+ /**
+ * Whether the external tool is new for this wizard
+ */
+ private boolean isNewTool = false;
+
+ /**
+ * The workbench window that the action launch
+ * this wizard.
+ */
+ private IWorkbenchWindow window = null;
+
+ /**
+ * The first page of the wizard.
+ */
+ private AntLaunchWizardPage page1 = null;
+
+ /**
+ * Creates a new wizard, given the project described in the
+ * file and the file itself.
+ *
+ * @param antProject
+ * @param antFile
+ */
+ public AntLaunchWizard(TargetInfo[] targetList, IFile antFile, IWorkbenchWindow window) {
+ super();
+ this.targetList = targetList;
+ this.antFile = antFile;
+ this.window = window;
+ String antPath = antFile.getFullPath().toString();
+ this.antTool = ExternalToolsPlugin.getDefault().getToolRegistry(getShell()).getToolNamed(antPath);
+ if (this.antTool == null) {
+ try {
+ this.antTool = new ExternalTool(IExternalToolConstants.TOOL_TYPE_ANT_BUILD, antPath);
+ } catch (CoreException exception) {
+ MessageDialog.openError(getShell(), "Ant Error", "An exception occurred launching ant file");
+ return;
+ }
+ this.antTool.setLocation(ToolUtil.buildVariableTag(IExternalToolConstants.VAR_WORKSPACE_LOC, antPath));
+ this.isNewTool = true;
+ }
+ setWindowTitle(ToolMessages.getString("AntLaunchWizard.shellTitle")); //$NON-NLS-1$;
+ }
+
+ /* (non-Javadoc)
+ * Method declared on IWizard.
+ */
+ public void addPages() {
+ page1 = new AntLaunchWizardPage(targetList);
+ addPage(page1);
+
+ StringBuffer buf = new StringBuffer();
+ String[] targets = AntUtil.parseRunTargets(antTool.getExtraAttribute(AntUtil.RUN_TARGETS_ATTRIBUTE));
+
+ page1.setInitialTargets(targets);
+ page1.setInitialArguments(buf.toString());
+ page1.setInitialDisplayLog(antTool.getShowConsole());
+ }
+
+ /* (non-Javadoc)
+ * Method declared on IWizard.
+ */
+ public boolean performFinish() {
+ updateTool();
+// ToolUtil.saveDirtyEditors(window);
+// if (antTool.getShowConsole()) {
+// ToolUtil.showLogConsole(window);
+// ToolUtil.clearLogDocument();
+// }
+
+ IRunnableWithProgress runnable = new IRunnableWithProgress() {
+ public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+ DefaultRunnerContext context = new DefaultRunnerContext(antTool, antFile); //new DefaultRunnerContext(antTool, antFile.getProject(), window.getWorkbench().getWorkingSetManager());
+ MultiStatus status = new MultiStatus(IExternalToolConstants.PLUGIN_ID, 0, "", null); //$NON-NLS-1$
+ context.run(monitor, status);
+ if (!status.isOK()) {
+ MessageDialog.openError(getShell(), "Ant Error", "An exception occurred while running ant");
+ }
+ };
+ };
+
+ try {
+ getContainer().run(true, true, runnable);
+ } catch (InterruptedException e) {
+ return false;
+ } catch (InvocationTargetException e) {
+ IStatus status = null;
+ if (e.getTargetException() instanceof CoreException)
+ status = ((CoreException)e.getTargetException()).getStatus();
+ else
+ status = new Status(IStatus.ERROR, IExternalToolConstants.PLUGIN_ID, 0, ToolMessages.getString("AntLaunchWizard.internalAntError"), e.getTargetException()); //$NON-NLS-1$;
+ ErrorDialog.openError(
+ getShell(),
+ ToolMessages.getString("AntLaunchWizard.runErrorTitle"), //$NON-NLS-1$;
+ ToolMessages.getString("AntLaunchWizard.runAntProblem"), //$NON-NLS-1$;
+ status);
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * Method updateTool.
+ */
+ private void updateTool() {
+ StringBuffer buf = new StringBuffer(page1.getArguments());
+ String[] targets = page1.getSelectedTargets();
+ ToolUtil.buildVariableTag(AntUtil.RUN_TARGETS_ATTRIBUTE, AntUtil.combineRunTargets(targets), buf);
+
+ antTool.setArguments(buf.toString());
+ antTool.setShowConsole(page1.getShowLog());
+
+ if (isNewTool) {
+ ExternalToolsPlugin.getDefault().getToolRegistry(getShell()).saveTool(antTool);
+ isNewTool = false;
+ }
+
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/AntLaunchWizardPage.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/AntLaunchWizardPage.java
new file mode 100644
index 000000000..9e32241f8
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/AntLaunchWizardPage.java
@@ -0,0 +1,246 @@
+package org.eclipse.ui.externaltools.internal.ui;
+
+/**********************************************************************
+Copyright (c) 2002 IBM Corp. and others.
+All rights reserved.   This program and the accompanying materials
+are made available under the terms of the Common Public License v0.5
+which accompanies this distribution, and is available at
+http://www.eclipse.org/legal/cpl-v05.html
+Contributors:
+**********************************************************************/
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+
+import org.eclipse.ant.core.TargetInfo;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.CheckStateChangedEvent;
+import org.eclipse.jface.viewers.CheckboxTableViewer;
+import org.eclipse.jface.viewers.ICheckStateListener;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerSorter;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+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.help.WorkbenchHelp;
+
+/**
+ * First page of the run Ant wizard. Allows the user to pick
+ * the targets, supply extra arguments, and decide to show
+ * output to the console.
+ */
+public class AntLaunchWizardPage extends WizardPage {
+ private static final int SIZING_SELECTION_WIDGET_HEIGHT = 200;
+ private static final int SIZING_SELECTION_WIDGET_WIDTH = 200;
+
+ private TargetInfo[] targetList;
+ private String initialTargets[];
+ private String initialArguments;
+ private boolean initialDisplayLog = true;
+ private ArrayList selectedTargets = new ArrayList();
+
+ private CheckboxTableViewer listViewer;
+ private AntTargetLabelProvider labelProvider = new AntTargetLabelProvider();
+ private Button showLog;
+ private Text argumentsField;
+
+ public AntLaunchWizardPage(TargetInfo[] targetList) {
+ super("AntScriptPage"); //$NON-NLS-1$;
+ this.targetList = targetList;
+ setTitle(ToolMessages.getString("AntLaunchWizard.dialogTitle")); //$NON-NLS-1$;
+ setDescription(ToolMessages.getString("AntLaunchWizard.dialogDescription")); //$NON-NLS-1$;
+ setImageDescriptor(getImageDescriptor("icons/full/wizban/ant_wiz.gif")); //$NON-NLS-1$;
+ }
+
+ /**
+ * Returns the image descriptor for the banner
+ */
+ private ImageDescriptor getImageDescriptor(String relativePath) {
+ try {
+ URL installURL = ExternalToolsPlugin.getDefault().getDescriptor().getInstallURL();
+ URL url = new URL(installURL, relativePath);
+ return ImageDescriptor.createFromURL(url);
+ } catch (MalformedURLException e) {
+ return null;
+ }
+ }
+
+ /* (non-Javadoc)
+ * Method declared on IWizardPage.
+ */
+ public void createControl(Composite parent) {
+ Composite composite = new Composite(parent, SWT.NULL);
+ composite.setLayout(new GridLayout());
+ composite.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_FILL | GridData.HORIZONTAL_ALIGN_FILL));
+
+ // The list of targets
+ Label label = new Label(composite, SWT.NONE);
+ label.setText(ToolMessages.getString("AntLaunchWizardPage.targetLabel")); //$NON-NLS-1$;
+
+ listViewer = CheckboxTableViewer.newCheckList(composite, SWT.BORDER);
+ GridData data = new GridData(GridData.FILL_BOTH);
+ data.heightHint = SIZING_SELECTION_WIDGET_HEIGHT;
+ data.widthHint = SIZING_SELECTION_WIDGET_WIDTH;
+ listViewer.getTable().setLayoutData(data);
+ listViewer.setSorter(new ViewerSorter() {
+ public int compare(Viewer viewer, Object o1, Object o2) {
+ return ((String)o1).compareTo((String) o2);
+ }
+ });
+ for (int i= 0, numTargets= targetList.length; i < numTargets; i++) {
+ if (targetList[i].isDefault()) {
+ labelProvider.setDefaultTargetName(targetList[i].getName());
+ break;
+ }
+ }
+ listViewer.setLabelProvider(labelProvider);
+ listViewer.setContentProvider(new AntTargetContentProvider());
+ listViewer.setInput(targetList);
+
+ // The arguments field
+ label = new Label(composite, SWT.NONE);
+ label.setText(ToolMessages.getString("AntLaunchWizardPage.argsLabel")); //$NON-NLS-1$;
+
+ argumentsField = new Text(composite, SWT.BORDER);
+ argumentsField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ argumentsField.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ validatePageComplete();
+ }
+ });
+
+ // The show log option
+ showLog = new Button(composite, SWT.CHECK);
+ showLog.setText(ToolMessages.getString("AntLaunchWizardPage.showLogLabel")); //$NON-NLS-1$;
+
+ // Setup initial field values
+ if (initialArguments != null)
+ argumentsField.setText(initialArguments);
+ showLog.setSelection(initialDisplayLog);
+ selectInitialTargets();
+
+ validatePageComplete();
+
+ listViewer.addCheckStateListener(new TargetCheckListener());
+ listViewer.refresh();
+ argumentsField.setFocus();
+
+ setControl(composite);
+
+ WorkbenchHelp.setHelp(composite, IHelpContextIds.ANT_LAUNCH_WIZARD_PAGE);
+ }
+
+ /**
+ * Returns the arguments that the user has entered
+ * to run the ant file.
+ *
+ * @return String the arguments
+ */
+ public String getArguments() {
+ return argumentsField.getText().trim();
+ }
+
+ /**
+ * Returns the targets selected by the user
+ */
+ public String[] getSelectedTargets() {
+ String[] names = new String[selectedTargets.size()];
+ selectedTargets.toArray(names);
+ return names;
+ }
+
+ /**
+ * Returns whether the users wants messages from running
+ * the tool displayed in the console
+ */
+ public boolean getShowLog() {
+ return showLog.getSelection();
+ }
+
+ /**
+ * Setup the initial selected targets in the viewer
+ */
+ private void selectInitialTargets() {
+ if (initialTargets != null && initialTargets.length > 0) {
+ for (int i = 0; i < initialTargets.length; i++) {
+ for (int j = 0; j < targetList.length; j++) {
+ if (targetList[j].equals(initialTargets[i])) {
+ String target = targetList[j].getName();
+ listViewer.setChecked(target, true);
+ selectedTargets.add(target);
+ break;
+ }
+ }
+ }
+ } else {
+ for (int i= 0, numTargets= targetList.length; i < numTargets; i++) {
+ if (targetList[i].isDefault()) {
+ listViewer.setChecked(targetList[i], true);
+ selectedTargets.add(targetList[i]);
+ }
+ }
+ }
+
+ labelProvider.setSelectedTargets(selectedTargets);
+ }
+
+ /**
+ * Sets the initial contents of the target list field.
+ * Ignored if controls already created.
+ */
+ public void setInitialTargets(String value[]) {
+ initialTargets = value;
+ }
+
+ /**
+ * Sets the initial contents of the arguments text field.
+ * Ignored if controls already created.
+ */
+ public void setInitialArguments(String value) {
+ initialArguments = value;
+ }
+
+ /**
+ * Sets the initial contents of the display to log option field.
+ * Ignored if controls already created.
+ */
+ public void setInitialDisplayLog(boolean value) {
+ initialDisplayLog = value;
+ }
+
+ /**
+ * Validates the page is complete
+ */
+ private void validatePageComplete() {
+ setPageComplete(selectedTargets.size() > 0 || getArguments().length() > 0);
+ }
+
+
+ /**
+ * Inner class for checkbox listener
+ */
+ private class TargetCheckListener implements ICheckStateListener {
+ public void checkStateChanged(CheckStateChangedEvent e) {
+ String checkedTarget = (String) e.getElement();
+ if (e.getChecked())
+ selectedTargets.add(checkedTarget);
+ else
+ selectedTargets.remove(checkedTarget);
+
+ labelProvider.setSelectedTargets(selectedTargets);
+ listViewer.refresh();
+ validatePageComplete();
+ }
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/AntRunActionDelegate.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/AntRunActionDelegate.java
new file mode 100644
index 000000000..aada60d79
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/AntRunActionDelegate.java
@@ -0,0 +1,56 @@
+package org.eclipse.ui.externaltools.internal.ui;
+
+/**********************************************************************
+Copyright (c) 2002 IBM Corp. and others.
+All rights reserved.   This program and the accompanying materials
+are made available under the terms of the Common Public License v0.5
+which accompanies this distribution, and is available at
+http://www.eclipse.org/legal/cpl-v05.html
+Contributors:
+**********************************************************************/
+import org.eclipse.core.resources.IFile;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.IObjectActionDelegate;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.actions.ActionDelegate;
+
+/**
+ * Action delegate to launch Ant on a build file.
+ */
+public class AntRunActionDelegate extends ActionDelegate implements IObjectActionDelegate {
+ private IFile selectedFile;
+ private IWorkbenchPart part;
+
+ /* (non-Javadoc)
+ * Method declared on IActionDelegate.
+ */
+ public void run(IAction action) {
+ if (part != null)
+ new AntAction(selectedFile, part.getSite().getWorkbenchWindow()).run();
+ }
+
+ /* (non-Javadoc)
+ * Method declared on IActionDelegate.
+ */
+ public void selectionChanged(IAction action, ISelection selection) {
+ selectedFile = null;
+ if (selection instanceof IStructuredSelection) {
+ IStructuredSelection structuredSelection = (IStructuredSelection) selection;
+ if (structuredSelection.size() == 1) {
+ Object selectedResource = structuredSelection.getFirstElement();
+ if (selectedResource instanceof IFile)
+ selectedFile = (IFile) selectedResource;
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * Method declared on IObjectActionDelegate.
+ */
+ public void setActivePart(IAction action, IWorkbenchPart targetPart) {
+ this.part = targetPart;
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/AntTargetContentProvider.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/AntTargetContentProvider.java
new file mode 100644
index 000000000..21d143c38
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/AntTargetContentProvider.java
@@ -0,0 +1,45 @@
+package org.eclipse.ui.externaltools.internal.ui;
+
+/**********************************************************************
+Copyright (c) 2002 IBM Corp. and others.
+All rights reserved.   This program and the accompanying materials
+are made available under the terms of the Common Public License v0.5
+which accompanies this distribution, and is available at
+http://www.eclipse.org/legal/cpl-v05.html
+Contributors:
+**********************************************************************/
+import org.eclipse.ant.core.TargetInfo;
+import org.eclipse.jface.viewers.*;
+
+/**
+ * Content provider for targets within an Ant file
+ */
+public class AntTargetContentProvider implements IStructuredContentProvider {
+ /**
+ * Creates a default instance of the content provider.
+ */
+ public AntTargetContentProvider() {
+ super();
+ }
+
+ /* (non-Javadoc)
+ * Method declared on IStructuredContentProvider.
+ */
+ public Object[] getElements(Object input) {
+ TargetInfo[] targetList = (TargetInfo[]) input;
+ return targetList;
+ }
+
+ /* (non-Javadoc)
+ * Method declared on IContentProvider.
+ */
+ public void dispose() {
+ }
+
+ /* (non-Javadoc)
+ * Method declared on IContentProvider.
+ */
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/AntTargetLabelProvider.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/AntTargetLabelProvider.java
new file mode 100644
index 000000000..fe3d61595
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/AntTargetLabelProvider.java
@@ -0,0 +1,64 @@
+package org.eclipse.ui.externaltools.internal.ui;
+
+/**********************************************************************
+Copyright (c) 2002 IBM Corp. and others.
+All rights reserved.   This program and the accompanying materials
+are made available under the terms of the Common Public License v0.5
+which accompanies this distribution, and is available at
+http://www.eclipse.org/legal/cpl-v05.html
+Contributors:
+**********************************************************************/
+import java.util.ArrayList;
+
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.ui.externaltools.internal.model.ToolMessages;
+
+/**
+ * Ant target label provider
+ */
+public class AntTargetLabelProvider extends LabelProvider {
+ private ArrayList selectedTargets = null;
+ private String defaultTargetName = null;
+
+ /* (non-Javadoc)
+ * Method declared on ILabelProvider.
+ */
+ public String getText(Object model) {
+ String targetToDisplay = (String) model;
+ if (targetToDisplay != null) {
+ StringBuffer result = new StringBuffer(targetToDisplay);
+ if (targetToDisplay.equals(defaultTargetName)) {
+ result.append(" ("); //$NON-NLS-1$;
+ result.append(ToolMessages.getString("AntTargetLabelProvider.defaultTarget")); //$NON-NLS-1$;
+ result.append(")"); //$NON-NLS-1$;
+ }
+ if (selectedTargets != null) {
+ int targetIndex = selectedTargets.indexOf(targetToDisplay);
+ if (targetIndex >= 0) {
+ result.append(" ["); //$NON-NLS-1$;
+ result.append(targetIndex + 1);
+ result.append("]"); //$NON-NLS-1$;
+ }
+ }
+ return result.toString();
+ } else {
+ return "";
+ }
+ }
+
+ /**
+ * Sets the targets selected in the viewer.
+ */
+ public void setSelectedTargets(ArrayList value) {
+ selectedTargets = value;
+ }
+
+ /**
+ * Sets the name of the default target
+ */
+ public void setDefaultTargetName(String name) {
+ defaultTargetName = name;
+ }
+
+} \ No newline at end of file
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/BuilderPropertyPage.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/BuilderPropertyPage.java
new file mode 100644
index 000000000..d22c15877
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/BuilderPropertyPage.java
@@ -0,0 +1,542 @@
+package org.eclipse.ui.externaltools.internal.ui;
+
+/**********************************************************************
+Copyright (c) 2002 IBM Corp. and others.
+All rights reserved.   This program and the accompanying materials
+are made available under the terms of the Common Public License v0.5
+which accompanies this distribution, and is available at
+http://www.eclipse.org/legal/cpl-v05.html
+Contributors:
+**********************************************************************/
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.resources.ICommand;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectDescription;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableItem;
+import org.eclipse.ui.dialogs.PropertyDialogAction;
+import org.eclipse.ui.dialogs.PropertyPage;
+import org.eclipse.ui.externaltools.internal.model.ExternalToolBuilder;
+import org.eclipse.ui.externaltools.internal.model.ExternalToolsPlugin;
+import org.eclipse.ui.externaltools.internal.model.ToolMessages;
+import org.eclipse.ui.externaltools.internal.registry.ExternalToolRegistry;
+import org.eclipse.ui.externaltools.internal.view.NewExternalToolAction;
+import org.eclipse.ui.externaltools.model.ExternalTool;
+import org.eclipse.ui.externaltools.model.ExternalToolStorage;
+import org.eclipse.ui.externaltools.model.IExternalToolConstants;
+import org.eclipse.ui.externaltools.model.IStorageListener;
+
+/**
+ * Property page to add external tools in between builders.
+ */
+public final class BuilderPropertyPage extends PropertyPage {
+ private static final int BUILDER_TABLE_WIDTH = 250;
+ private static final String NEW_NAME= "BuilderPropertyPageName"; //$NON-NLS-1$
+ private static final String IMG_BUILDER= "icons/full/obj16/builder.gif"; //$NON-NLS-1$;
+ private static final String IMG_INVALID_BUILD_TOOL = "icons/full/obj16/invalid_build_tool.gif"; //$NON-NLS-1$
+
+ private Table builderTable;
+ private Button upButton, downButton, newButton, editButton, removeButton;
+ private ArrayList imagesToDispose = new ArrayList();
+ private Image builderImage, invalidBuildToolImage;
+ private IStorageListener storageListener= new StorageListener();
+
+ /**
+ * Creates an initialized property page
+ */
+ public BuilderPropertyPage() {
+ super();
+ noDefaultAndApplyButton();
+ }
+
+ /**
+ * Add the project's build to the table viewer.
+ */
+ private void addBuildersToTable() {
+ IProject project = getInputProject();
+ if (project == null) {
+ return;
+ }
+ //add build spec entries to the table
+ try {
+ ICommand[] commands = project.getDescription().getBuildSpec();
+ ExternalToolRegistry registry= ExternalToolsPlugin.getDefault().getToolRegistry(getShell());
+ for (int i = 0; i < commands.length; i++) {
+ ExternalTool tool = ExternalToolRegistry.toolFromBuildCommandArgs(commands[i].getArguments(), NEW_NAME);
+ if (registry.hasToolNamed(tool.getName())) {
+ addTool(tool, -1, false);
+ } else {
+ // If the tool generated from the command is not in the registry, it's
+ // just a command, not a tool.
+ addCommand(commands[i], -1, false);
+ }
+ }
+ } catch (CoreException e) {
+ handleException(e);
+ }
+ }
+
+ /**
+ * Adds a build command to the table viewer.
+ *
+ * @param command the command to be added
+ * @param position the insertion position, or -1 to add at the end
+ * @param select whether to select the newly created item.
+ */
+ private void addCommand(ICommand command, int position, boolean select) {
+ TableItem newItem;
+ if (position < 0) {
+ newItem = new TableItem(builderTable, SWT.NONE);
+ } else {
+ newItem = new TableItem(builderTable, SWT.NONE, position);
+ }
+ newItem.setData(command);
+ updateCommandItem(newItem, command);
+ if (select) builderTable.setSelection(position);
+ }
+
+ private void addTool(ExternalTool tool, int position, boolean select) {
+ TableItem newItem;
+ if (position < 0) {
+ newItem = new TableItem(builderTable, SWT.NONE);
+ } else {
+ newItem = new TableItem(builderTable, SWT.NONE, position);
+ }
+ newItem.setData(tool);
+ updateToolItem(newItem, tool);
+ if (select) builderTable.setSelection(position);
+ }
+
+ private void updateToolItem(TableItem item, ExternalTool tool) {
+ item.setText(tool.getName());
+ Image toolImage= ExternalToolsPlugin.getDefault().getTypeRegistry().getToolType(tool.getType()).getImageDescriptor().createImage();
+ imagesToDispose.add(toolImage);
+ item.setImage(toolImage);
+ }
+
+ /**
+ * Configures and creates a new build command
+ * that invokes an external tool. Returns the new command,
+ * or <code>null</code> if no command was created.
+ */
+// private ICommand createTool() {
+// try {
+// EditDialog dialog;
+// dialog = new EditDialog(getShell(), null);
+// if (dialog.open() == Window.OK) {
+// ExternalTool tool = dialog.getExternalTool();
+// ICommand command = getInputProject().getDescription().newCommand();
+// return tool.toBuildCommand(command);
+// } else {
+// return null;
+// }
+// } catch(CoreException e) {
+// handleException(e);
+// return null;
+// }
+// }
+
+ public ICommand toBuildCommand(ExternalTool tool, ICommand command) {
+ Map args= ExternalToolRegistry.toolToBuildCommandArgs(tool);
+ command.setBuilderName(ExternalToolBuilder.ID);
+ command.setArguments(args);
+
+ return command;
+ }
+
+ /**
+ * Edits an exisiting build command that invokes an external tool.
+ */
+// private void editTool(ICommand command) {
+// ExternalTool tool = ExternalToolRegistry.toolFromBuildCommandArgs(command.getArguments(), NEW_NAME);
+// if (tool == null)
+// return;
+// EditDialog dialog;
+// dialog = new EditDialog(getShell(), tool);
+// if (dialog.open() == Window.OK) {
+// tool = dialog.getExternalTool();
+// tool.toBuildCommand(command);
+// }
+// }
+
+ /**
+ * Creates and returns a button with the given label, id, and enablement.
+ */
+ private Button createButton(Composite parent, String label) {
+ Button button = new Button(parent, SWT.PUSH);
+ GridData data = new GridData();
+ data.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
+ data.heightHint = convertVerticalDLUsToPixels(IDialogConstants.BUTTON_HEIGHT);
+ button.setLayoutData(data);
+ button.setText(label);
+ button.setEnabled(false);
+ button.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ handleButtonPressed((Button)e.widget);
+ }
+ });
+ return button;
+ }
+
+ /* (non-Javadoc)
+ * Method declared on PreferencePage.
+ */
+ protected Control createContents(Composite parent) {
+ builderImage = ExternalToolsPlugin.getDefault().getImageDescriptor(IMG_BUILDER).createImage();
+ invalidBuildToolImage = ExternalToolsPlugin.getDefault().getImageDescriptor(IMG_INVALID_BUILD_TOOL).createImage();
+
+ imagesToDispose.add(builderImage);
+ imagesToDispose.add(invalidBuildToolImage);
+
+ Composite topLevel = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
+ topLevel.setLayout(layout);
+ topLevel.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+ Label description = new Label(topLevel, SWT.WRAP);
+ description.setText(ToolMessages.getString("BuilderPropertyPage.description")); //$NON-NLS-1$
+ description.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ Composite tableAndButtons = new Composite(topLevel, SWT.NONE);
+ tableAndButtons.setLayoutData(new GridData(GridData.FILL_BOTH));
+ layout = new GridLayout();
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
+ layout.numColumns = 2;
+ tableAndButtons.setLayout(layout);
+
+ // table of builders and tools
+ builderTable = new Table(tableAndButtons, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);
+ GridData data = new GridData(GridData.FILL_BOTH);
+ data.widthHint = BUILDER_TABLE_WIDTH;
+ builderTable.setLayoutData(data);
+ builderTable.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ handleTableSelectionChanged();
+ }
+ });
+
+ //button area
+ Composite buttonArea = new Composite(tableAndButtons, SWT.NONE);
+ layout = new GridLayout();
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
+ buttonArea.setLayout(layout);
+ buttonArea.setLayoutData(new GridData(GridData.FILL_VERTICAL));
+ newButton = createButton(buttonArea, ToolMessages.getString("BuilderPropertyPage.newButton")); //$NON-NLS-1$
+ editButton = createButton(buttonArea, ToolMessages.getString("BuilderPropertyPage.editButton")); //$NON-NLS-1$
+ removeButton = createButton(buttonArea, ToolMessages.getString("BuilderPropertyPage.removeButton")); //$NON-NLS-1$
+ new Label(buttonArea, SWT.LEFT);
+ upButton = createButton(buttonArea, ToolMessages.getString("BuilderPropertyPage.upButton")); //$NON-NLS-1$
+ downButton = createButton(buttonArea, ToolMessages.getString("BuilderPropertyPage.downButton")); //$NON-NLS-1$
+
+ newButton.setEnabled(true);
+
+ //populate widget contents
+ addBuildersToTable();
+ initializeStorageListener();
+
+ return topLevel;
+ }
+
+ private void initializeStorageListener() {
+ ExternalToolStorage.addStorageListener(storageListener);
+ }
+
+ /* (non-Javadoc)
+ * Method declared on DialogPage.
+ */
+ public void dispose() {
+ super.dispose();
+ for (Iterator i = imagesToDispose.iterator(); i.hasNext();) {
+ Image image = (Image) i.next();
+ image.dispose();
+ }
+ imagesToDispose.clear();
+ ExternalToolStorage.removeStorageListener(storageListener);
+ }
+
+ /**
+ * Returns the project that is the input for this property page,
+ * or <code>null</code>.
+ */
+ private IProject getInputProject() {
+ IAdaptable element = getElement();
+ if (element instanceof IProject) {
+ return (IProject)element;
+ }
+ Object resource = element.getAdapter(IResource.class);
+ if (resource instanceof IProject) {
+ return (IProject)resource;
+ }
+ return null;
+ }
+
+ /**
+ * One of the buttons has been pressed, act accordingly.
+ */
+ private void handleButtonPressed(Button button) {
+ if (button == newButton) {
+ new NewExternalToolAction().run();
+ } else if (button == editButton) {
+ TableItem[] selection = builderTable.getSelection();
+ if (selection != null) {
+ new PropertyDialogAction(getShell(), new ISelectionProvider() {
+ public void addSelectionChangedListener(ISelectionChangedListener listener) {
+ }
+
+ public ISelection getSelection() {
+ TableItem[] items= builderTable.getSelection();
+ List list= new ArrayList(items.length);
+ for (int i= 0, numItems= items.length; i < numItems; i++) {
+ list.add(items[i].getData());
+ }
+ return new StructuredSelection(list);
+ }
+
+ public void removeSelectionChangedListener(ISelectionChangedListener listener) {
+ }
+
+ public void setSelection(ISelection selection) {
+ }
+ }).run();
+ Object data= selection[0].getData();
+ if (data instanceof ExternalTool) {
+ // The table contains ExternalTools and ICommands,
+ // but we only edit ExternalTools
+ updateToolItem(selection[0], (ExternalTool) data);
+ }
+ }
+ } else if (button == removeButton) {
+ TableItem[] selection = builderTable.getSelection();
+ if (selection != null) {
+ for (int i = 0; i < selection.length; i++) {
+ selection[i].dispose();
+ }
+ }
+ } else if (button == upButton) {
+ moveSelectionUp();
+ } else if (button == downButton) {
+ moveSelectionDown();
+ }
+ handleTableSelectionChanged();
+ builderTable.setFocus();
+ }
+
+ /**
+ * Handles unexpected internal exceptions
+ */
+ private void handleException(Exception e) {
+ IStatus status;
+ if (e instanceof CoreException) {
+ status = ((CoreException)e).getStatus();
+ } else {
+ status = new Status(IStatus.ERROR, IExternalToolConstants.PLUGIN_ID, 0, ToolMessages.getString("BuilderPropertyPage.statusMessage"), e); //$NON-NLS-1$
+ }
+ ErrorDialog.openError(
+ getShell(),
+ ToolMessages.getString("BuilderPropertyPage.errorTitle"), //$NON-NLS-1$
+ ToolMessages.getString("BuilderPropertyPage.errorMessage"), //$NON-NLS-1$
+ status);
+ }
+
+ /**
+ * The user has selected a different builder in table.
+ * Update button enablement.
+ */
+ private void handleTableSelectionChanged() {
+ newButton.setEnabled(true);
+ TableItem[] items = builderTable.getSelection();
+ if (items != null && items.length == 1) {
+ TableItem item = items[0];
+ Object data= item.getData();
+ if (data instanceof ExternalTool) {
+ editButton.setEnabled(true);
+ removeButton.setEnabled(true);
+ int selection = builderTable.getSelectionIndex();
+ int max = builderTable.getItemCount();
+ upButton.setEnabled(selection != 0);
+ downButton.setEnabled(selection < max-1);
+ return;
+ }
+ }
+ //in all other cases we can't do any of these.
+ editButton.setEnabled(false);
+ removeButton.setEnabled(false);
+ upButton.setEnabled(false);
+ downButton.setEnabled(false);
+ }
+
+ /**
+ * Moves an entry in the builder table to the given index.
+ */
+ private void move(TableItem item, int index) {
+ Object data = item.getData();
+ String text = item.getText();
+ Image image= item.getImage();
+ item.dispose();
+ TableItem newItem = new TableItem(builderTable, SWT.NONE, index);
+ newItem.setData(data);
+ newItem.setText(text);
+ newItem.setImage(image);
+ }
+
+ /**
+ * Move the current selection in the build list down.
+ */
+ private void moveSelectionDown() {
+ // Only do this operation on a single selection
+ if (builderTable.getSelectionCount() == 1) {
+ int currentIndex = builderTable.getSelectionIndex();
+ if (currentIndex < builderTable.getItemCount() - 1) {
+ move(builderTable.getItem(currentIndex), currentIndex+1);
+ builderTable.setSelection(currentIndex+1);
+ }
+ }
+ }
+
+ /**
+ * Move the current selection in the build list up.
+ */
+ private void moveSelectionUp() {
+ int currentIndex = builderTable.getSelectionIndex();
+ // Only do this operation on a single selection
+ if (currentIndex > 0 && builderTable.getSelectionCount() == 1) {
+ move(builderTable.getItem(currentIndex), currentIndex-1);
+ builderTable.setSelection(currentIndex-1);
+ }
+ }
+
+ /* (non-Javadoc)
+ * Method declared on IPreferencePage.
+ */
+ public boolean performOk() {
+ IProject project = getInputProject();
+ //get all the build commands
+ int numCommands = builderTable.getItemCount();
+ ICommand[] commands = new ICommand[numCommands];
+ for (int i = 0; i < numCommands; i++) {
+ Object data= builderTable.getItem(i).getData();
+ if (data instanceof ICommand) {
+ } else if (data instanceof ExternalTool) {
+ // Translate ExternalTools to ICommands for storage
+ ICommand newCommand= null;
+ try {
+ newCommand= project.getDescription().newCommand();
+ } catch (CoreException exception) {
+ MessageDialog.openError(getShell(), "Command error", "An error occurred while saving the project's build commands");
+ return true;
+ }
+ data= toBuildCommand(((ExternalTool)data), newCommand);
+ }
+ commands[i] = (ICommand)data;
+ }
+ //set the build spec
+ try {
+ IProjectDescription desc = project.getDescription();
+ desc.setBuildSpec(commands);
+ project.setDescription(desc, null);
+ } catch(CoreException e) {
+ handleException(e);
+ }
+ return super.performOk();
+ }
+
+ /**
+ * Update the table item with the given build command
+ */
+ private void updateCommandItem(TableItem item, ICommand command) {
+ String builderID = command.getBuilderName();
+ if (builderID.equals(ExternalToolBuilder.ID)) {
+ ExternalTool tool = ExternalToolRegistry.toolFromBuildCommandArgs(command.getArguments(), NEW_NAME);
+ if (tool == null) {
+ item.setText(ToolMessages.getString("BuilderPropertyPage.invalidBuildTool")); //$NON-NLS-1$
+ item.setImage(invalidBuildToolImage);
+ return;
+ }
+ item.setText(tool.getName());
+ Image toolImage= ExternalToolsPlugin.getDefault().getTypeRegistry().getToolType(tool.getType()).getImageDescriptor().createImage();
+ imagesToDispose.add(toolImage);
+ item.setImage(toolImage);
+ } else {
+ // Get the human-readable name of the builder
+ IExtension extension = Platform.getPluginRegistry().getExtension(ResourcesPlugin.PI_RESOURCES, ResourcesPlugin.PT_BUILDERS, builderID);
+ String builderName;
+ if (extension != null)
+ builderName = extension.getLabel();
+ else
+ builderName = ToolMessages.format("BuilderPropertyPage.missingBuilder", new Object[] {builderID}); //$NON-NLS-1$
+ item.setText(builderName);
+ item.setImage(builderImage);
+ }
+ }
+
+ private class StorageListener implements IStorageListener {
+ /**
+ * @see IStorageListener#toolDeleted(ExternalTool)
+ */
+ public void toolDeleted(ExternalTool tool) {
+ }
+ /**
+ * @see IStorageListener#toolCreated(ExternalTool)
+ */
+ public void toolCreated(ExternalTool tool) {
+ try {
+ final ICommand newCommand;
+ newCommand= getInputProject().getDescription().newCommand();
+ toBuildCommand(tool, newCommand);
+ if (newCommand != null) {
+ getShell().getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ int insertPosition = builderTable.getSelectionIndex() + 1;
+ addCommand(newCommand, insertPosition, true);
+ }
+ });
+ }
+ } catch (CoreException e) {
+ }
+ }
+ /**
+ * @see IStorageListener#toolModified(ExternalTool)
+ */
+ public void toolModified(ExternalTool tool) {
+ }
+ /**
+ * @see IStorageListener#toolsRefreshed()
+ */
+ public void toolsRefreshed() {
+ }
+ }
+}
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/LogConsoleDocument.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/LogConsoleDocument.java
new file mode 100644
index 000000000..f1236c156
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/LogConsoleDocument.java
@@ -0,0 +1,334 @@
+package org.eclipse.ui.externaltools.internal.ui;
+
+/**********************************************************************
+Copyright (c) 2002 IBM Corp. and others.
+All rights reserved.   This program and the accompanying materials
+are made available under the terms of the Common Public License v0.5
+which accompanies this distribution, and is available at
+http://www.eclipse.org/legal/cpl-v05.html
+Contributors:
+**********************************************************************/
+import java.util.*;
+
+import org.eclipse.jface.preference.PreferenceConverter;
+import org.eclipse.jface.text.*;
+import org.eclipse.jface.util.*;
+import org.eclipse.swt.custom.StyleRange;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.externaltools.internal.model.*;
+import org.eclipse.ui.externaltools.model.IRunnerLog;
+
+/**
+ * Holds onto messages generated by the execution on an
+ * external tool.
+ */
+public class LogConsoleDocument implements IRunnerLog {
+ // class variables that handle the colors and the font
+ private static Color ERROR_COLOR;
+ private static Color WARN_COLOR;
+ private static Color INFO_COLOR;
+ private static Color VERBOSE_COLOR;
+ private static Color DEBUG_COLOR;
+ /*package*/ static Font ANT_FONT;
+
+ public static final int MSG_ERR = 0;
+ public static final int MSG_WARN = 10;
+ public static final int MSG_INFO = 20;
+ public static final int MSG_VERBOSE = 30;
+ public static final int MSG_DEBUG = 40;
+
+ private static final LogConsoleDocument instance = new LogConsoleDocument();
+
+ private LogPropertyChangeListener changeListener;
+
+ /*package*/ ArrayList views = new ArrayList();
+ private Document document;
+ private ArrayList styleRanges;
+
+ // Structure to store the textwidget index information
+ private OutputStructureElement root = null;
+ private OutputStructureElement currentElement = null;
+
+ private LogConsoleDocument() {
+ changeListener = new LogPropertyChangeListener();
+ document = new Document();
+ styleRanges = new ArrayList(5);
+ initializeOutputStructure();
+ }
+
+ public int getFilterLevel() {
+ return IRunnerLog.LEVEL_DEBUG;
+ }
+
+ public void append(final String message, final int priority) {
+ if (views.size() == 0)
+ return;
+ ((LogConsoleView)views.get(0)).getViewSite().getShell().getDisplay().syncExec(new Runnable() {
+ public void run() {
+ int start = getDocument().getLength();
+ try {
+ // Append new message to the end of the document. This
+ // avoids console flicker when messages are appended.
+ getDocument().replace(start, 0, message);
+ } catch (BadLocationException e) {
+ }
+ setOutputLevelColor(priority, start, message.length());
+ }
+ });
+ for (int i=0; i < views.size(); i++) {
+ ((LogConsoleView)views.get(i)).append(message, priority);
+ }
+ }
+
+ private void addRangeStyle(int start, int length, Color color) {
+ // Don't add a StyleRange if the length is 0.
+ if (length == 0)
+ return;
+ if (styleRanges.size() != 0) {
+ StyleRange lastStyle = (StyleRange) styleRanges.get(styleRanges.size()-1);
+ if (color.equals(lastStyle.foreground))
+ lastStyle.length += length;
+ else
+ styleRanges.add(new StyleRange(start, length, color, null));
+ } else
+ styleRanges.add(new StyleRange(start, length, color, null));
+ StyleRange[] styleArray = (StyleRange[]) styleRanges.toArray(new StyleRange[styleRanges.size()]);
+ for (int i = 0; i < views.size(); i++) {
+ TextViewer tv = ((LogConsoleView)views.get(i)).getTextViewer();
+ if (tv != null)
+ tv.getTextWidget().setStyleRanges(styleArray);
+ }
+ }
+
+ public void clearOutput() {
+ document.set("");
+ styleRanges.clear();
+ // the tree can be null if #createPartControl has not called yet,
+ // i.e. if the console exists but has never been shown so far
+ initializeOutputStructure();
+ refreshTree();
+ }
+
+ public void refreshTree() {
+ for(int i=0; i<views.size(); i++) {
+ ((LogConsoleView)views.get(i)).refreshTree();
+ }
+ }
+
+ /**
+ * Returns the color used for error messages on the log console.
+ */
+ private static Color getErrorColor() {
+ if (ERROR_COLOR == null || ERROR_COLOR.isDisposed())
+ ERROR_COLOR = new Color(null, PreferenceConverter.getColor(ExternalToolsPlugin.getDefault().getPreferenceStore(),IPreferenceConstants.CONSOLE_ERROR_RGB));
+ return ERROR_COLOR;
+ }
+ /**
+ * Returns the color used for warning messages on the log console.
+ */
+ private static Color getWarnColor() {
+ if (WARN_COLOR == null || WARN_COLOR.isDisposed())
+ WARN_COLOR = new Color(null, PreferenceConverter.getColor(ExternalToolsPlugin.getDefault().getPreferenceStore(),IPreferenceConstants.CONSOLE_WARNING_RGB));
+ return WARN_COLOR;
+ }
+ /**
+ * Returns the color used for info (normal) messages on the log console.
+ */
+ private static Color getInfoColor() {
+ if (INFO_COLOR == null || INFO_COLOR.isDisposed())
+ INFO_COLOR = new Color(null, PreferenceConverter.getColor(ExternalToolsPlugin.getDefault().getPreferenceStore(),IPreferenceConstants.CONSOLE_INFO_RGB));
+ return INFO_COLOR;
+ }
+ /**
+ * Returns the color used for verbose messages on the log console.
+ */
+ private static Color getVerboseColor() {
+ if (VERBOSE_COLOR == null || VERBOSE_COLOR.isDisposed())
+ VERBOSE_COLOR = new Color(null, PreferenceConverter.getColor(ExternalToolsPlugin.getDefault().getPreferenceStore(),IPreferenceConstants.CONSOLE_VERBOSE_RGB));
+ return VERBOSE_COLOR;
+ }
+ /**
+ * Returns the color used for debug messages on the log console.
+ */
+ private static Color getDebugColor() {
+ if (DEBUG_COLOR == null || DEBUG_COLOR.isDisposed())
+ DEBUG_COLOR = new Color(null, PreferenceConverter.getColor(ExternalToolsPlugin.getDefault().getPreferenceStore(),IPreferenceConstants.CONSOLE_DEBUG_RGB));
+ return DEBUG_COLOR;
+ }
+
+ public Display getDisplay() {
+ if (!hasViews())
+ return null;
+ return ((LogConsoleView)views.get(0)).getSite().getShell().getDisplay();
+ }
+
+ /*package*/ Document getDocument() {
+ return document;
+ }
+
+ /*package*/ ArrayList getStyleRanges() {
+ return styleRanges;
+ }
+
+ public ArrayList getViews() {
+ return views;
+ }
+
+ /*package*/ OutputStructureElement getRoot() {
+ return root;
+ }
+
+ public boolean hasViews() {
+ return (views.size() > 0);
+ }
+
+ public void initializeOutputStructure() {
+ // root is the first element of the structure: it is a fake so it doesn't need a real name
+ root = new OutputStructureElement("-- root --"); // $NON-NLS-1$
+ currentElement = new OutputStructureElement(ToolMessages.getString("LogConsoleDocument.externalTool"), root, 0); // $NON-NLS-1$
+
+ for (int i=0; i < views.size(); i++) {
+ LogConsoleView view = (LogConsoleView)views.get(i);
+ if (view.getTreeViewer() != null)
+ view.initializeTreeInput();
+ }
+ }
+
+ public void registerView(LogConsoleView view) {
+ if (!hasViews()) {
+ // first time there is an instance of this class: intantiate the font and register the listener
+ ANT_FONT = new Font(null, PreferenceConverter.getFontData(ExternalToolsPlugin.getDefault().getPreferenceStore(),IPreferenceConstants.CONSOLE_FONT));
+ ExternalToolsPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(changeListener);
+ }
+ views.add(view);
+ }
+
+ public void unregisterView(LogConsoleView view) {
+ views.remove(view);
+ if (! hasViews()) {
+ // all the consoles are diposed: we can dispose the font and remove the property listener
+ ANT_FONT.dispose();
+ ExternalToolsPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(changeListener);
+ }
+ }
+
+ public static LogConsoleDocument getInstance() {
+ return instance;
+ }
+
+ public OutputStructureElement getCurrentOutputStructureElement() {
+ return currentElement;
+ }
+ public void setCurrentOutputStructureElement(OutputStructureElement output) {
+ this.currentElement = output;
+ }
+ /*package*/ void setOutputLevelColor(int level, int start, int end) {
+ switch (level) {
+ case LogConsoleDocument.MSG_ERR:
+ addRangeStyle(start, end, getErrorColor());
+ break;
+ case LogConsoleDocument.MSG_WARN:
+ addRangeStyle(start, end, getWarnColor());
+ break;
+ case LogConsoleDocument.MSG_INFO:
+ addRangeStyle(start, end, getInfoColor());
+ break;
+ case LogConsoleDocument.MSG_VERBOSE:
+ addRangeStyle(start, end, getVerboseColor());
+ break;
+ case LogConsoleDocument.MSG_DEBUG:
+ addRangeStyle(start, end, getDebugColor());
+ break;
+ default:
+ addRangeStyle(start, end, getInfoColor());
+ }
+ }
+
+ /**
+ * Replaces the old color with the new one in all style ranges,
+ */
+ private void updateStyleRanges(Color oldColor, Color newColor) {
+ for (int i=0; i<styleRanges.size(); i++) {
+ StyleRange range = (StyleRange)styleRanges.get(i);
+ if (range.foreground == oldColor)
+ range.foreground = newColor;
+ }
+ }
+
+ private class LogPropertyChangeListener implements IPropertyChangeListener {
+
+ // private constructor to ensure the singleton
+ private LogPropertyChangeListener() {
+ }
+
+ /**
+ * @see IPropertyChangeListener#propertyChange(PropertyChangeEvent)
+ */
+ public void propertyChange(PropertyChangeEvent event) {
+ String propertyName= event.getProperty();
+
+ if (propertyName.equals(IPreferenceConstants.CONSOLE_ERROR_RGB)) {
+ if (LogConsoleDocument.ERROR_COLOR == null)
+ return;
+ Color temp = getErrorColor();
+ LogConsoleDocument.ERROR_COLOR = ToolsPreferencePage.getPreferenceColor(IPreferenceConstants.CONSOLE_ERROR_RGB);
+ updateStyleRanges(temp, getErrorColor());
+ temp.dispose();
+ } else if (propertyName.equals(IPreferenceConstants.CONSOLE_WARNING_RGB)) {
+ if (LogConsoleDocument.WARN_COLOR == null)
+ return;
+ Color temp = getWarnColor();
+ LogConsoleDocument.WARN_COLOR = ToolsPreferencePage.getPreferenceColor(IPreferenceConstants.CONSOLE_WARNING_RGB);
+ updateStyleRanges(temp, getWarnColor());
+ temp.dispose();
+ } else if (propertyName.equals(IPreferenceConstants.CONSOLE_INFO_RGB)) {
+ if (LogConsoleDocument.INFO_COLOR == null)
+ return;
+ Color temp = getInfoColor();
+ LogConsoleDocument.INFO_COLOR = ToolsPreferencePage.getPreferenceColor(IPreferenceConstants.CONSOLE_INFO_RGB);
+ updateStyleRanges(temp, getInfoColor());
+ temp.dispose();
+ } else if (propertyName.equals(IPreferenceConstants.CONSOLE_VERBOSE_RGB)) {
+ if (LogConsoleDocument.VERBOSE_COLOR == null)
+ return;
+ Color temp = getVerboseColor();
+ LogConsoleDocument.VERBOSE_COLOR = ToolsPreferencePage.getPreferenceColor(IPreferenceConstants.CONSOLE_VERBOSE_RGB);
+ updateStyleRanges(temp, getVerboseColor());
+ temp.dispose();
+ } else if (propertyName.equals(IPreferenceConstants.CONSOLE_DEBUG_RGB)) {
+ if (LogConsoleDocument.DEBUG_COLOR == null)
+ return;
+ Color temp = getDebugColor();
+ LogConsoleDocument.DEBUG_COLOR = ToolsPreferencePage.getPreferenceColor(IPreferenceConstants.CONSOLE_DEBUG_RGB);
+ updateStyleRanges(temp, getDebugColor());
+ temp.dispose();
+ } else if (propertyName.equals(IPreferenceConstants.CONSOLE_FONT)) {
+ FontData data= ToolsPreferencePage.getConsoleFontData();
+ Font temp= LogConsoleDocument.ANT_FONT;
+ LogConsoleDocument.ANT_FONT = new Font(Display.getCurrent(), data);
+ temp.dispose();
+ updateFont();
+ } else
+ return;
+ }
+
+ /**
+ * Clears the output of all the consoles
+ */
+ private void clearOutput() {
+ LogConsoleDocument.getInstance().clearOutput();
+ }
+
+ /**
+ * Updates teh font in all the consoles
+ */
+ private void updateFont() {
+ for (Iterator iterator = LogConsoleDocument.getInstance().getViews().iterator(); iterator.hasNext();)
+ ((LogConsoleView) iterator.next()).updateFont();
+ }
+ }
+
+
+}
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/LogConsoleView.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/LogConsoleView.java
new file mode 100644
index 000000000..d03095b16
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/LogConsoleView.java
@@ -0,0 +1 @@
+package org.eclipse.ui.externaltools.internal.ui; /********************************************************************** Copyright (c) 2002 IBM Corp. and others. All rights reserved.   This program and the accompanying materials are made available under the terms of the Common Public License v0.5 which accompanies this distribution, and is available at http://www.eclipse.org/legal/cpl-v05.html   Contributors: **********************************************************************/ import java.net.MalformedURLException; import java.net.URL; import java.util.ArrayList; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IMenuListener; import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.action.IToolBarManager; import org.eclipse.jface.action.MenuManager; import org.eclipse.jface.action.Separator; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.text.Document; import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.IFindReplaceTarget; import org.eclipse.jface.text.ITextOperationTarget; import org.eclipse.jface.text.TextViewer; import org.eclipse.jface.viewers.AbstractTreeViewer; import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.SelectionChangedEvent; import org.eclipse.jface.viewers.TreeViewer; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.SashForm; import org.eclipse.swt.custom.StyleRange; import org.eclipse.swt.custom.StyledText; import org.eclipse.swt.events.ControlAdapter; import org.eclipse.swt.events.ControlEvent; import org.eclipse.swt.events.KeyAdapter; import org.eclipse.swt.events.KeyEvent; import org.eclipse.swt.events.MouseAdapter; import org.eclipse.swt.events.MouseEvent; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Menu; import org.eclipse.swt.widgets.TreeItem; import org.eclipse.ui.IActionBars; import org.eclipse.ui.IMemento; import org.eclipse.ui.IViewSite; import org.eclipse.ui.PartInitException; import org.eclipse.ui.externaltools.internal.model.ExternalToolsPlugin; import org.eclipse.ui.externaltools.internal.model.ToolMessages; import org.eclipse.ui.part.ViewPart; import org.eclipse.ui.texteditor.FindReplaceAction; import org.eclipse.ui.texteditor.ITextEditorActionConstants; public class LogConsoleView extends ViewPart { public final static String PROPERTY_PREFIX_FIND = "LogConsoleView.findAction."; // $NON-NLS-1$ private final static int SASH_WIDTH = 3; // regular width for a sash // strings for the memento private final static String TREE_WIDTH_PROPERTY = "tree_width"; private final static String SHOW_ONLY_SELECTED_ITEM_PROPERTY = "wasShowOnlySelectedTreeItemsTurnedOn"; // $NON-NLS-1$ private final static String SHOW_TREE_PROPERTY = "hideOrShowTreeAction"; // $NON-NLS-1$ // UI objects private SashForm sash; private TreeViewer treeViewer; private TextViewer textViewer; private Action copyAction; private Action selectAllAction; private Action clearOutputAction; private Action findAction; private Action expandTreeItemAction; private Action showTreeAction; private Action showSelectedItemAction; private LogTreeLabelProvider labelprovider; private LogTreeContentProvider contentProvider; // lastWidth is used to store the width of the tree that the user set private int lastTreeWidth = 30; private boolean showOnlySelectedItems = false; private boolean showTree = false; /** * Constructor for AntConsole */ public LogConsoleView() { super(); LogConsoleDocument.getInstance().registerView(this); labelprovider = new LogTreeLabelProvider(this); contentProvider = new LogTreeContentProvider(this); } /** * @see IViewPart */ public void init(IViewSite site, IMemento memento) throws PartInitException { super.init(site, memento); if (memento != null) { // retrieve the values of the previous session lastTreeWidth = memento.getInteger(TREE_WIDTH_PROPERTY).intValue(); showOnlySelectedItems = memento.getInteger(SHOW_ONLY_SELECTED_ITEM_PROPERTY).intValue() != 0; showTree = memento.getInteger(SHOW_TREE_PROPERTY).intValue() != 0; } } protected void addContributions() { // In order for the clipboard actions to be accessible via their shortcuts // (e.g., Ctrl-C, Ctrl-V), we *must* set a global action handler for // each action IActionBars actionBars = getViewSite().getActionBars(); actionBars.setGlobalActionHandler(ITextEditorActionConstants.COPY, copyAction); actionBars.setGlobalActionHandler(ITextEditorActionConstants.FIND, findAction); actionBars.setGlobalActionHandler(ITextEditorActionConstants.SELECT_ALL, selectAllAction); MenuManager textViewerMgr = new MenuManager(); textViewerMgr.setRemoveAllWhenShown(true); textViewerMgr.addMenuListener(new IMenuListener() { public void menuAboutToShow(IMenuManager textViewerMgr) { fillTextViewerContextMenu(textViewerMgr); } }); Menu textViewerMenu = textViewerMgr.createContextMenu(textViewer.getControl()); textViewer.getControl().setMenu(textViewerMenu); MenuManager treeViewerMgr = new MenuManager(); treeViewerMgr.setRemoveAllWhenShown(true); treeViewerMgr.addMenuListener(new IMenuListener() { public void menuAboutToShow(IMenuManager treeViewerMgr) { fillTreeViewerContextMenu(treeViewerMgr); } }); Menu treeViewerMenu = treeViewerMgr.createContextMenu(treeViewer.getControl()); treeViewer.getControl().setMenu(treeViewerMenu); //add toolbar actions IToolBarManager tbm = getViewSite().getActionBars().getToolBarManager(); tbm.add(showTreeAction); tbm.add(showSelectedItemAction); tbm.add(clearOutputAction); getViewSite().getActionBars().updateActionBars(); } private void createHideOrShowTreeAction() { showTreeAction = new Action() { public void run() { showTree = isChecked(); if (showTree) { // the tree is hidden, let's show it sash.SASH_WIDTH = SASH_WIDTH; sash.setWeights(new int[] { lastTreeWidth, 100 - lastTreeWidth }); setToolTipText(ToolMessages.getString("LogConsoleView.hideOutputStructureTree")); // $NON-NLS-1$ // the "ShowOnlySelectedElement" functionality can be turned on showSelectedItemAction.setEnabled(true); showSelectedItemAction.setChecked(showOnlySelectedItems); showSelectedItemAction.run(); } else { // let's hide the tree sash.SASH_WIDTH = 0; sash.setWeights(new int[] { 0, 100 }); setToolTipText(ToolMessages.getString("LogConsoleView.showOutputStructureTree")); // $NON-NLS-1$ // show the whole document showCompleteOutput(); // disable the show selected item action showSelectedItemAction.setEnabled(false); } } }; showTreeAction.setImageDescriptor(getImageDescriptor("icons/full/clcl16/hide_show_tree.gif")); // $NON-NLS-1$ showTreeAction.setChecked(showTree); showTreeAction.setText(ToolMessages.getString("LogConsoleView.showTree")); // $NON-NLS-1$ String tooltip = showTree ? "LogConsoleView.hideOutputStructureTree" : "LogConsoleView.showOutputStructureTree"; // $NON-NLS-1$ showTreeAction.setToolTipText(ToolMessages.getString(tooltip)); } private boolean isTreeHidden() { return sash.getWeights()[0] == 0; } public void append(String value) { append(value, LogConsoleDocument.MSG_INFO); } public void append(final String value, final int ouputLevel) { getViewSite().getShell().getDisplay().syncExec(new Runnable() { public void run() { if (value.length() > 0 && textViewer != null) { revealEndOfDocument(); // XXX If this is not done, then the colors don't appear --> bug of #setVisibleRegion ? // See "1GHQC7Q: ITPUI:WIN2000 - TextViewer#setVisibleRegion doesn't take into account the colors" textViewer.getTextWidget().setStyleRanges((StyleRange[]) getStyleRanges().toArray(new StyleRange[getStyleRanges().size()])); } } }); } private void setOutputLevelColor(int level, int start, int end) { LogConsoleDocument.getInstance().setOutputLevelColor(level, start, end); } protected void copySelectionToClipboard() { textViewer.doOperation(ITextOperationTarget.COPY); } /** * Creates the actions that will appear in this view's toolbar and popup menus. */ protected void createActions() { // Create the actions for the text viewer. copyAction = new Action(ToolMessages.getString("LogConsoleView.copy")) { // $NON-NLS-1$ public void run() { copySelectionToClipboard(); } }; selectAllAction = new Action(ToolMessages.getString("LogConsoleView.selectAll")) { // $NON-NLS-1$ public void run() { selectAllText(); } }; clearOutputAction = new Action(ToolMessages.getString("LogConsoleView.clearOutput")) {// $NON-NLS-1$ public void run() { LogConsoleDocument.getInstance().clearOutput(); } }; clearOutputAction.setImageDescriptor(getImageDescriptor("icons/full/clcl16/clear.gif")); // $NON-NLS-1$ clearOutputAction.setToolTipText(ToolMessages.getString("LogConsoleView.clearOutput")); // $NON-NLS-1$ findAction = new FindReplaceAction(ToolMessages.getResourceBundle(), PROPERTY_PREFIX_FIND, this); findAction.setEnabled(true); // Create the actions for the tree viewer. createHideOrShowTreeAction(); expandTreeItemAction = new Action(ToolMessages.getString("LogConsoleView.expandAll")) {// $NON-NLS-1$ public void run() { OutputStructureElement selectedElement = (OutputStructureElement) ((IStructuredSelection) treeViewer.getSelection()).getFirstElement(); treeViewer.expandToLevel(selectedElement, AbstractTreeViewer.ALL_LEVELS); } }; //create the toolbar actions showSelectedItemAction = new Action() { public void run() { showOnlySelectedItems = isChecked(); if (showOnlySelectedItems) { // we want to show only the selected tree items showSelectedElementOnly(); // changes the labels setToolTipText(ToolMessages.getString("LogConsoleView.showCompleteOutput")); // $NON-NLS-1$ } else { // we want to show the whole document now showCompleteOutput(); // changes the labels setToolTipText(ToolMessages.getString("LogConsoleView.showSelectedElementOnly")); // $NON-NLS-1$ } } }; showSelectedItemAction.setImageDescriptor(getImageDescriptor("icons/full/clcl16/show_selected_text.gif")); // $NON-NLS-1$ showSelectedItemAction.setChecked(showOnlySelectedItems); showSelectedItemAction.setEnabled(showTreeAction.isChecked()); showSelectedItemAction.setText(ToolMessages.getString("LogConsoleView.showSelectedElementOnly")); // $NON-NLS-1$ String tooltip = showOnlySelectedItems ? "LogConsoleView.showCompleteOutput" : "LogConsoleView.showSelectedElementOnly"; // $NON-NLS-1$ showSelectedItemAction.setToolTipText(ToolMessages.getString(tooltip)); } /* * Shows the output of the selected item only */ protected void showSelectedElementOnly() { IStructuredSelection selection = (IStructuredSelection) treeViewer.getSelection(); if (selection.isEmpty()) textViewer.setVisibleRegion(0, 0); else { OutputStructureElement selectedElement = (OutputStructureElement) selection.getFirstElement(); // XXX NOTE: #setVisibleRegion doesn't keep the color information... See "1GHQC7Q: ITPUI:WIN2000 - TextViewer#setVisibleRegion doesn't take into account the colors" textViewer.setVisibleRegion(selectedElement.getStartIndex(), selectedElement.getLength()); } } /* * Shows the output of the whole docuent, and reveals the range of the selected item */ protected void showCompleteOutput() { // show all the document textViewer.setVisibleRegion(0, getDocument().get().length()); // XXX should I have to do that? If this is not done, then the colors don't appear --> bug of #setVisibleRegion ? --> See "1GHQC7Q: ITPUI:WIN2000 - TextViewer#setVisibleRegion doesn't take into account the colors" textViewer.getTextWidget().setStyleRanges((StyleRange[]) getStyleRanges().toArray(new StyleRange[getStyleRanges().size()])); // and then reveal the range of the selected item revealRangeOfSelectedItem(); } private void revealRangeOfSelectedItem() { IStructuredSelection selection = (IStructuredSelection) treeViewer.getSelection(); if (!selection.isEmpty()) { // then show the reveal the range of the output accordingly OutputStructureElement selectedElement = (OutputStructureElement) selection.getFirstElement(); textViewer.revealRange(selectedElement.getStartIndex(), selectedElement.getLength()); textViewer.setSelectedRange(selectedElement.getStartIndex(), selectedElement.getLength()); } } private void revealEndOfDocument() { IDocument doc= getDocument(); int docLength= doc.getLength(); if (docLength > 0) { StyledText widget= textViewer.getTextWidget(); widget.setCaretOffset(docLength); widget.showSelection(); } } public void initializeTreeInput() { getSite().getShell().getDisplay().syncExec(new Runnable() { public void run() { if (treeViewer != null) treeViewer.setInput(LogConsoleDocument.getInstance().getRoot()); } }); } public void refreshTree() { // if the tree is null, it means that the view hasn't been shown yet, so we don't need to refresh it. if (treeViewer != null) { getSite().getShell().getDisplay().syncExec(new Runnable() { public void run() { treeViewer.refresh(); treeViewer.expandAll(); } }); } } public void updateFont() { if (textViewer != null) textViewer.getTextWidget().setFont(LogConsoleDocument.ANT_FONT); } protected void fillTextViewerContextMenu(IMenuManager manager) { copyAction.setEnabled(textViewer.canDoOperation(ITextOperationTarget.COPY)); selectAllAction.setEnabled(textViewer.canDoOperation(ITextOperationTarget.SELECT_ALL)); manager.add(copyAction); manager.add(findAction); manager.add(selectAllAction); manager.add(new Separator()); manager.add(showTreeAction); manager.add(clearOutputAction); } protected void fillTreeViewerContextMenu(IMenuManager manager) { manager.add(showSelectedItemAction); manager.add(expandTreeItemAction); manager.add(new Separator()); manager.add(showTreeAction); manager.add(clearOutputAction); } public Object getAdapter(Class required) { if (IFindReplaceTarget.class.equals(required)) return textViewer.getFindReplaceTarget(); return super.getAdapter(required); } private Document getDocument() { return LogConsoleDocument.getInstance().getDocument(); } private ArrayList getStyleRanges() { return LogConsoleDocument.getInstance().getStyleRanges(); } public TextViewer getTextViewer() { return textViewer; } public TreeViewer getTreeViewer() { return treeViewer; } protected ImageDescriptor getImageDescriptor(String relativePath) { try { URL installURL = ExternalToolsPlugin.getDefault().getDescriptor().getInstallURL(); URL url = new URL(installURL, relativePath); return ImageDescriptor.createFromURL(url); } catch (MalformedURLException e) { return null; } } protected void selectAllText() { textViewer.doOperation(ITextOperationTarget.SELECT_ALL); } /** * @see WorkbenchPart#setFocus() */ public void setFocus() { sash.setFocus(); } /** * @see WorkbenchPart#createPartControl(Composite) */ public void createPartControl(Composite parent) { sash = new SashForm(parent, SWT.HORIZONTAL); GridLayout sashLayout = new GridLayout(); sashLayout.marginHeight = 0; sashLayout.marginWidth = 0; sash.setLayout(sashLayout); sash.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_FILL | GridData.HORIZONTAL_ALIGN_FILL)); treeViewer = new TreeViewer(sash, SWT.V_SCROLL | SWT.H_SCROLL); GridData treeData = new GridData(GridData.FILL_BOTH); treeViewer.getControl().setLayoutData(treeData); treeViewer.setContentProvider(contentProvider); treeViewer.setLabelProvider(labelprovider); treeViewer.setInput(LogConsoleDocument.getInstance().getRoot()); treeViewer.expandAll(); addTreeViewerListeners(); textViewer = new TextViewer(sash, SWT.WRAP | SWT.V_SCROLL | SWT.H_SCROLL); GridData viewerData = new GridData(GridData.FILL_BOTH); textViewer.getControl().setLayoutData(viewerData); textViewer.setEditable(false); textViewer.setDocument(getDocument()); textViewer.getTextWidget().setFont(LogConsoleDocument.ANT_FONT); textViewer.getTextWidget().setStyleRanges((StyleRange[]) getStyleRanges().toArray(new StyleRange[getStyleRanges().size()])); addTextViewerListeners(); // sets the ratio tree/textViewer for the sashForm if (showTree) { sash.setWeights(new int[] { lastTreeWidth, 100 - lastTreeWidth }); } else { // the "hideOrShowTree" action wasn't checked: this means that the user didn't want to have the tree sash.SASH_WIDTH = 0; sash.setWeights(new int[] { 0, 100 }); } createActions(); addContributions(); // WorkbenchHelp.setHelp(parent, IHelpContextIds.LOG_CONSOLE_VIEW); } protected void addTreeViewerListeners() { treeViewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent e) { if (textViewer != null) if (showSelectedItemAction.isChecked()) showSelectedElementOnly(); else revealRangeOfSelectedItem(); } }); // to remember the place of the sash when we hide the tree treeViewer.getControl().addControlListener(new ControlAdapter() { public void controlResized(ControlEvent e) { if (treeViewer.getControl().getSize().x != 0) // we don't want the width to be stored when the tree is getting hidden // (because it equals zero and we want to have the previous value) lastTreeWidth = new Float((float) treeViewer.getControl().getSize().x / sash.getSize().x * 100).intValue(); } }); } protected void addTextViewerListeners() { textViewer.getTextWidget().addMouseListener(new MouseAdapter() { public void mouseDown(MouseEvent e) { if (!showSelectedItemAction.isChecked()) selectTreeItem(textViewer.getTextWidget().getCaretOffset()); } }); textViewer.getTextWidget().addKeyListener(new KeyAdapter() { public void keyReleased(KeyEvent e) { if (!showSelectedItemAction.isChecked()) selectTreeItem(textViewer.getTextWidget().getCaretOffset()); } }); } protected void selectTreeItem(int caretPosition) { // tree.getTree().getItems()[1] returns the root of the tree that contains the project // it may not exist if there is no output (in this case, there is only one item: the "External Tool" one) if (treeViewer.getTree().getItems().length != 1) { TreeItem itemToSelect = null; if (findItem(treeViewer.getTree().getItems()[0], caretPosition) != null) // the first item is the good one itemToSelect = treeViewer.getTree().getItems()[0]; else // the first item is not the good one, let's check the second one and its children itemToSelect = findItem(treeViewer.getTree().getItems()[1], caretPosition); treeViewer.getTree().setSelection(new TreeItem[] { itemToSelect }); } } private TreeItem findItem(TreeItem item, int position) { if (!(((OutputStructureElement) item.getData()).getStartIndex() <= position && ((OutputStructureElement) item.getData()).getEndIndex() > position)) return null; for (int i = 0; i < item.getItems().length; i++) { TreeItem child = findItem(item.getItems()[i], position); if (child != null) return child; } return item; } /** * @see IViewPart */ public void saveState(IMemento memento) { memento.putInteger(TREE_WIDTH_PROPERTY, lastTreeWidth); // it is not possible to put a boolean in a memento, so we use integers memento.putInteger(SHOW_ONLY_SELECTED_ITEM_PROPERTY, showOnlySelectedItems ? 1 : 0); memento.putInteger(SHOW_TREE_PROPERTY, showTree ? 1 : 0); } public void dispose() { LogConsoleDocument.getInstance().unregisterView(this); super.dispose(); } } \ No newline at end of file
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/LogTreeContentProvider.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/LogTreeContentProvider.java
new file mode 100644
index 000000000..5d3a51be9
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/LogTreeContentProvider.java
@@ -0,0 +1,67 @@
+package org.eclipse.ui.externaltools.internal.ui;
+
+/**********************************************************************
+Copyright (c) 2002 IBM Corp. and others.
+All rights reserved.   This program and the accompanying materials
+are made available under the terms of the Common Public License v0.5
+which accompanies this distribution, and is available at
+http://www.eclipse.org/legal/cpl-v05.html
+Contributors:
+**********************************************************************/
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+
+/**
+ * Content provider for the tree viewer of the Ant Console.
+ */
+
+public class LogTreeContentProvider implements ITreeContentProvider {
+
+ private LogConsoleView console;
+
+ public LogTreeContentProvider(LogConsoleView console) {
+ this.console = console;
+ }
+
+ /**
+ * @see ITreeContentProvider#getChildren(Object)
+ */
+ public Object[] getChildren(Object parent) {
+ return ((OutputStructureElement) parent).getChildren();
+ }
+
+ /**
+ * @see ITreeContentProvider#getParent(Object)
+ */
+ public Object getParent(Object element) {
+ return ((OutputStructureElement) element).getParent();
+ }
+
+ /**
+ * @see ITreeContentProvider#hasChildren(Object)
+ */
+ public boolean hasChildren(Object element) {
+ return ((OutputStructureElement) element).hasChildren();
+ }
+
+ /**
+ * @see IStructuredContentProvider#getElements(Object)
+ */
+ public Object[] getElements(Object parent) {
+ return ((OutputStructureElement) parent).getChildren();
+ }
+
+ /**
+ * @see IContentProvider#dispose()
+ */
+ public void dispose() {
+ }
+
+ /**
+ * @see IContentProvider#inputChanged(Viewer, Object, Object)
+ */
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ }
+
+} \ No newline at end of file
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/LogTreeLabelProvider.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/LogTreeLabelProvider.java
new file mode 100644
index 000000000..2ec6bd080
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/LogTreeLabelProvider.java
@@ -0,0 +1,72 @@
+package org.eclipse.ui.externaltools.internal.ui;
+
+/**********************************************************************
+Copyright (c) 2002 IBM Corp. and others.
+All rights reserved.   This program and the accompanying materials
+are made available under the terms of the Common Public License v0.5
+which accompanies this distribution, and is available at
+http://www.eclipse.org/legal/cpl-v05.html
+Contributors:
+**********************************************************************/
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.externaltools.internal.model.ToolMessages;
+
+/**
+ * Label provider for the tree viewer of the Log Console.
+ */
+public class LogTreeLabelProvider implements ILabelProvider {
+
+ private LogConsoleView console;
+
+ public LogTreeLabelProvider(LogConsoleView console) {
+ this.console = console;
+ }
+
+ /**
+ * @see ILabelProvider#getImage(Object)
+ */
+ public Image getImage(Object element) {
+ return null;
+ }
+
+ /**
+ * @see ILabelProvider#getText(Object)
+ */
+ public String getText(Object element) {
+ String text = ((OutputStructureElement) element).getName();
+ if (text == null)
+ // this can happen if the user writes a task name that doesn't exist => the #taskStarted will be triggered
+ // but null will be given as a name to the current task, and then only, the exception will be raised
+ return ToolMessages.getString("LogTreeLabelProvider.invalidItemName"); // $NON-NLS-1$
+ return text;
+ }
+
+ /**
+ * @see IBaseLabelProvider#addListener(ILabelProviderListener)
+ */
+ public void addListener(ILabelProviderListener listener) {
+ }
+
+ /**
+ * @see IBaseLabelProvider#dispose()
+ */
+ public void dispose() {
+ }
+
+ /**
+ * @see IBaseLabelProvider#isLabelProperty(Object, String)
+ */
+ public boolean isLabelProperty(Object arg0, String arg1) {
+ return false;
+ }
+
+ /**
+ * @see IBaseLabelProvider#removeListener(ILabelProviderListener)
+ */
+ public void removeListener(ILabelProviderListener listener) {
+ }
+
+} \ No newline at end of file
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/OutputStructureElement.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/OutputStructureElement.java
new file mode 100644
index 000000000..76b53979f
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/OutputStructureElement.java
@@ -0,0 +1,102 @@
+/**********************************************************************
+ * Copyright (c) 2002 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v0.5
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v05.html
+ *
+ * Contributors:
+ * IBM - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.ui.externaltools.internal.ui;
+
+import java.util.ArrayList;
+
+/**
+ * Object which stores the index and the length of the output for a given
+ * target or task (represented by a string)
+ */
+
+public class OutputStructureElement {
+
+ private OutputStructureElement parent = null;
+ private ArrayList children;
+ private String name;
+ private int startIndex = 0;
+ private int length = 0;
+
+
+/**
+ * This constructor is intended to be used only by the first element of the structure (the root element)
+ */
+public OutputStructureElement(String name) {
+ // there's at least one target as it is the root which may be instantiated via this constructor
+ children = new ArrayList(1);
+ this.name = name;
+}
+
+/**
+ * This constructor is used for any element but the first element of the structure (the root element)
+ */
+public OutputStructureElement(String name, OutputStructureElement parent, int startIndex) {
+ children = new ArrayList(0);
+ this.name = name;
+ this.startIndex = startIndex;
+ parent.addChild(this);
+}
+
+public void addChild(OutputStructureElement child) {
+ children.add(child);
+ child.setParent(this);
+}
+
+public boolean hasChildren() {
+ return !children.isEmpty();
+}
+
+public String getName() {
+ return name;
+}
+
+public void setName(String name) {
+ this.name = name;
+}
+
+public void setParent(OutputStructureElement parent) {
+ this.parent = parent;
+}
+
+public OutputStructureElement getParent() {
+ return parent;
+}
+
+public OutputStructureElement[] getChildren() {
+ return (OutputStructureElement[]) children.toArray(new OutputStructureElement[children.size()]);
+}
+
+public void setStartIndex(int index) {
+ startIndex = index;
+}
+
+public void setEndIndex(int index) {
+ length = index - startIndex;
+}
+
+public int getStartIndex() {
+ return startIndex;
+}
+
+public int getEndIndex() {
+ return startIndex + length;
+}
+
+public int getLength() {
+ return length;
+}
+
+public String toString() {
+ return name;
+}
+
+}
+
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/ToolsPreferencePage.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/ToolsPreferencePage.java
new file mode 100644
index 000000000..99d588e81
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/ToolsPreferencePage.java
@@ -0,0 +1 @@
+package org.eclipse.ui.externaltools.internal.ui; /********************************************************************** Copyright (c) 2002 IBM Corp. and others. All rights reserved. This file is 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: **********************************************************************/ import org.eclipse.jface.preference.ColorFieldEditor; import org.eclipse.jface.preference.FieldEditorPreferencePage; import org.eclipse.jface.preference.FontFieldEditor; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.preference.PreferenceConverter; import org.eclipse.jface.preference.RadioGroupFieldEditor; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.FontData; import org.eclipse.swt.graphics.RGB; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbenchPreferencePage; import org.eclipse.ui.externaltools.internal.model.ExternalToolsPlugin; import org.eclipse.ui.externaltools.internal.model.IPreferenceConstants; import org.eclipse.ui.externaltools.internal.model.ToolMessages; /** * Preference page applicable to all external tools */ public class ToolsPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage { public ToolsPreferencePage() { super(GRID); setPreferenceStore(ExternalToolsPlugin.getDefault().getPreferenceStore()); } /* (non-Javadoc) * Method declared on FieldEditorPreferencePage. */ public void createControl(Composite parent) { super.createControl(parent); // should do something here with the help.. /* FIXME WorkbenchHelp.setHelp( parent, new Object[] { IAntHelpContextIds.ANT_PREFERENCE_PAGE }); */ } /* (non-Javadoc) * Method declared on FieldEditorPreferencePage. */ protected void createFieldEditors() { RadioGroupFieldEditor outputLevel = new RadioGroupFieldEditor( IPreferenceConstants.OUPUT_LEVEL, ToolMessages.getString("ToolsPreferencePage.preferedOutputLevel"), // $NON-NLS-1$ 1, new String[][] { {ToolMessages.getString("ToolsPreferencePage.info"), // $NON-NLS-1$ IPreferenceConstants.INFO_LEVEL }, {ToolMessages.getString("ToolsPreferencePage.verbose"), // $NON-NLS-1$ IPreferenceConstants.VERBOSE_LEVEL }, {ToolMessages.getString("ToolsPreferencePage.debug"), // $NON-NLS-1$ IPreferenceConstants.DEBUG_LEVEL }}, getFieldEditorParent(), true); addField(outputLevel); ColorFieldEditor errOut = new ColorFieldEditor( IPreferenceConstants.CONSOLE_ERROR_RGB, ToolMessages.getString("ToolsPreferencePage.errorColor"), // $NON-NLS-1$ getFieldEditorParent()); ColorFieldEditor warnOut = new ColorFieldEditor( IPreferenceConstants.CONSOLE_WARNING_RGB, ToolMessages.getString("ToolsPreferencePage.warningColor"), // $NON-NLS-1$ getFieldEditorParent()); ColorFieldEditor infoOut = new ColorFieldEditor( IPreferenceConstants.CONSOLE_INFO_RGB, ToolMessages.getString("ToolsPreferencePage.infoColor"), // $NON-NLS-1$ getFieldEditorParent()); ColorFieldEditor verbOut = new ColorFieldEditor( IPreferenceConstants.CONSOLE_VERBOSE_RGB, ToolMessages.getString("ToolsPreferencePage.verboseColor"), // $NON-NLS-1$ getFieldEditorParent()); ColorFieldEditor debugOut = new ColorFieldEditor( IPreferenceConstants.CONSOLE_DEBUG_RGB, ToolMessages.getString("ToolsPreferencePage.debugColor"), // $NON-NLS-1$ getFieldEditorParent()); FontFieldEditor font = new FontFieldEditor( IPreferenceConstants.CONSOLE_FONT, ToolMessages.getString("ToolsPreferencePage.font"), // $NON-NLS-1$ getFieldEditorParent()); addField(errOut); addField(warnOut); addField(infoOut); addField(verbOut); addField(debugOut); addField(font); } /** * Returns the font data that describes the font to use for the console */ protected static FontData getConsoleFontData() { IPreferenceStore pstore= ExternalToolsPlugin.getDefault().getPreferenceStore(); FontData fontData= PreferenceConverter.getFontData(pstore, IPreferenceConstants.CONSOLE_FONT); return fontData; } /** * Returns the a color based on the type. */ protected static Color getPreferenceColor(String type) { IPreferenceStore pstore= ExternalToolsPlugin.getDefault().getPreferenceStore(); RGB outRGB= PreferenceConverter.getColor(pstore, type); return new Color(Display.getCurrent() ,outRGB); } /* (non-Javadoc) * Method declared on IWorkbenchPreferencePage. */ public void init(IWorkbench workbench) { } } \ No newline at end of file
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/view/DeleteExternalToolAction.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/view/DeleteExternalToolAction.java
new file mode 100644
index 000000000..4e86bcd2f
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/view/DeleteExternalToolAction.java
@@ -0,0 +1,78 @@
+package org.eclipse.ui.externaltools.internal.view;
+
+/**********************************************************************
+Copyright (c) 2002 IBM Corp. and others. All rights reserved.
+This file is 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:
+**********************************************************************/
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IWorkbenchPage;
+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;
+
+/**
+ * Action that will delete the currently selected
+ * external tool in the view.
+ */
+public class DeleteExternalToolAction extends Action {
+ private IWorkbenchPage page;
+ private ExternalTool selectedTool;
+
+ /**
+ * Create an action to delete the selected external tool
+ */
+ public DeleteExternalToolAction(IWorkbenchPage page) {
+ super();
+ this.page = page;
+ setText(ToolMessages.getString("DeleteExternalToolAction.text")); //$NON-NLS-1$
+ setToolTipText(ToolMessages.getString("DeleteExternalToolAction.toolTip")); //$NON-NLS-1$
+ setHoverImageDescriptor(ExternalToolsPlugin.getDefault().getImageDescriptor("icons/full/clcl16/del_tool.gif")); //$NON-NLS-1$
+ setImageDescriptor(ExternalToolsPlugin.getDefault().getImageDescriptor("icons/full/elcl16/del_tool.gif")); //$NON-NLS-1$
+ setDisabledImageDescriptor(ExternalToolsPlugin.getDefault().getImageDescriptor("icons/full/dlcl16/del_tool.gif")); //$NON-NLS-1$
+ WorkbenchHelp.setHelp(this, IHelpContextIds.DELETE_TOOL_ACTION);
+ }
+
+ /**
+ * Returns the selected external tool.
+ */
+ public ExternalTool getSelectedTool() {
+ return selectedTool;
+ }
+
+ /* (non-Javadoc)
+ * Method declared on Action.
+ */
+ public void run() {
+ if (selectedTool == null)
+ return;
+
+ // Get user confirmation first
+ Shell shell = page.getWorkbenchWindow().getShell();
+ String title = ToolMessages.getString("DeleteExternalToolAction.confirmToolDeleteTitle"); //$NON-NLS-1$
+ String msg = ToolMessages.format("DeleteExternalToolAction.confirmToolDeleteMsg", new Object[] {selectedTool.getName()}); //$NON-NLS-1$
+ boolean deleteOk = MessageDialog.openQuestion(shell, title, msg);
+ if (!deleteOk)
+ return;
+
+ // Delete the external tool
+ ExternalToolStorage.deleteTool(selectedTool, shell);
+ }
+
+ /**
+ * Sets the selected external tool.
+ */
+ public void setSelectedTool(ExternalTool tool) {
+ selectedTool = tool;
+ setEnabled(tool != null);
+ }
+}
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/view/DuplicateExternalToolAction.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/view/DuplicateExternalToolAction.java
new file mode 100644
index 000000000..c62ca5cc3
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/view/DuplicateExternalToolAction.java
@@ -0,0 +1,63 @@
+package org.eclipse.ui.externaltools.internal.view;
+
+/**********************************************************************
+Copyright (c) 2002 IBM Corp. and others. All rights reserved.
+This file is 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:
+**********************************************************************/
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.externaltools.internal.model.ExternalToolsPlugin;
+import org.eclipse.ui.externaltools.internal.model.IHelpContextIds;
+import org.eclipse.ui.externaltools.model.ExternalTool;
+import org.eclipse.ui.help.WorkbenchHelp;
+
+/**
+ * Action that will duplicate the currently selected
+ * external tool.
+ */
+public class DuplicateExternalToolAction extends Action {
+ private IWorkbenchPage page;
+ private ExternalTool selectedTool;
+
+ /**
+ * Create an action to copy the selected external
+ * tool to the clipboard
+ */
+ public DuplicateExternalToolAction(IWorkbenchPage page) {
+ super();
+ this.page = page;
+ setText("Duplicate");
+ setToolTipText("Duplicate the selected tool");
+ setHoverImageDescriptor(ExternalToolsPlugin.getDefault().getImageDescriptor("icons/full/clcl16/copy_tool.gif")); //$NON-NLS-1$
+ setImageDescriptor(ExternalToolsPlugin.getDefault().getImageDescriptor("icons/full/elcl16/copy_tool.gif")); //$NON-NLS-1$
+ setDisabledImageDescriptor(ExternalToolsPlugin.getDefault().getImageDescriptor("icons/full/dlcl16/copy_tool.gif")); //$NON-NLS-1$
+ WorkbenchHelp.setHelp(this, IHelpContextIds.DUPLICATE_TOOL_ACTION);
+ }
+
+ /**
+ * Returns the selected external tool.
+ */
+ public ExternalTool getSelectedTool() {
+ return selectedTool;
+ }
+
+ /* (non-Javadoc)
+ * Method declared on Action.
+ */
+ public void run() {
+ org.eclipse.jface.dialogs.MessageDialog.openInformation(page.getWorkbenchWindow().getShell(), "Action", "This action is not yet implemented");
+ }
+
+ /**
+ * Sets the selected external tool.
+ */
+ public void setSelectedTool(ExternalTool tool) {
+ selectedTool = tool;
+ setEnabled(tool != null);
+ }
+}
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/view/EditExternalToolPropertiesAction.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/view/EditExternalToolPropertiesAction.java
new file mode 100644
index 000000000..cf1b02791
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/view/EditExternalToolPropertiesAction.java
@@ -0,0 +1,64 @@
+package org.eclipse.ui.externaltools.internal.view;
+
+/**********************************************************************
+Copyright (c) 2002 IBM Corp. and others. All rights reserved.
+This file is 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:
+**********************************************************************/
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.ui.dialogs.PropertyDialogAction;
+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.help.WorkbenchHelp;
+
+/**
+ * Action that will open a properties dialog to edit
+ * the selected external tool.
+ */
+public class EditExternalToolPropertiesAction extends Action {
+ private ExternalTool selectedTool;
+ private PropertyDialogAction propAction;
+
+ /**
+ * Create an action to edit the selected external tool.
+ */
+ public EditExternalToolPropertiesAction(ExternalToolView view) {
+ super();
+ setText(ToolMessages.getString("EditExternalToolPropertiesAction.text")); //$NON-NLS-1$
+ setToolTipText(ToolMessages.getString("EditExternalToolPropertiesAction.toolTip")); //$NON-NLS-1$
+ setHoverImageDescriptor(ExternalToolsPlugin.getDefault().getImageDescriptor("icons/full/clcl16/prop_tool.gif")); //$NON-NLS-1$
+ setImageDescriptor(ExternalToolsPlugin.getDefault().getImageDescriptor("icons/full/elcl16/prop_tool.gif")); //$NON-NLS-1$
+ setDisabledImageDescriptor(ExternalToolsPlugin.getDefault().getImageDescriptor("icons/full/dlcl16/prop_tool.gif")); //$NON-NLS-1$
+ WorkbenchHelp.setHelp(this, IHelpContextIds.EDIT_TOOL_PROPERTIES_ACTION);
+ propAction = new PropertyDialogAction(view.getSite().getShell(), view.getTreeViewer());
+ }
+
+ /**
+ * Returns the selected external tool.
+ */
+ public ExternalTool getSelectedTool() {
+ return selectedTool;
+ }
+
+ /* (non-Javadoc)
+ * Method declared on Action.
+ */
+ public void run() {
+ if (propAction.isEnabled())
+ propAction.run();
+ }
+
+ /**
+ * Sets the selected external tool.
+ */
+ public void setSelectedTool(ExternalTool tool) {
+ selectedTool = tool;
+ setEnabled(tool != null);
+ }
+}
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/view/ExternalToolActionGroup.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/view/ExternalToolActionGroup.java
new file mode 100644
index 000000000..fce7efaba
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/view/ExternalToolActionGroup.java
@@ -0,0 +1,179 @@
+package org.eclipse.ui.externaltools.internal.view;
+
+/**********************************************************************
+Copyright (c) 2002 IBM Corp. and others. All rights reserved.
+This file is 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:
+**********************************************************************/
+
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.IWorkbenchActionConstants;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.actions.ActionGroup;
+import org.eclipse.ui.actions.TextActionHandler;
+import org.eclipse.ui.externaltools.action.RunExternalToolAction;
+import org.eclipse.ui.externaltools.action.RunWithExternalToolAction;
+import org.eclipse.ui.externaltools.model.ExternalTool;
+
+/**
+ * The action group for all of the external tools view actions.
+ */
+public class ExternalToolActionGroup extends ActionGroup {
+ private ExternalToolView view;
+ private TextActionHandler textActionHandler;
+ private NewExternalToolAction newAction;
+ private DuplicateExternalToolAction copyAction;
+ private DeleteExternalToolAction delAction;
+ private RenameExternalToolAction renameAction;
+ private RefreshViewAction refreshAction;
+ private RunExternalToolAction runAction;
+ private RunWithExternalToolAction runWithAction;
+ private EditExternalToolPropertiesAction editAction;
+
+ public ExternalToolActionGroup(ExternalToolView view) {
+ super();
+ this.view = view;
+ makeActions();
+ }
+
+ /* (non-Javadoc)
+ * Method declared on ActionGroup.
+ */
+ public void fillActionBars(IActionBars actionBars) {
+ IToolBarManager toolBar = actionBars.getToolBarManager();
+ toolBar.add(runAction);
+ toolBar.add(newAction);
+ toolBar.add(delAction);
+ toolBar.add(refreshAction);
+
+ textActionHandler = new TextActionHandler(actionBars); // hooks handlers
+ textActionHandler.setCopyAction(copyAction);
+ textActionHandler.setDeleteAction(delAction);
+ renameAction.setTextActionHandler(textActionHandler);
+
+ actionBars.setGlobalActionHandler(
+ IWorkbenchActionConstants.REFRESH,
+ refreshAction);
+ actionBars.setGlobalActionHandler(
+ IWorkbenchActionConstants.RENAME,
+ renameAction);
+ actionBars.setGlobalActionHandler(
+ IWorkbenchActionConstants.PROPERTIES,
+ editAction);
+ }
+
+ /* (non-Javadoc)
+ * Method declared on ActionGroup.
+ */
+ public void fillContextMenu(IMenuManager menu) {
+ updateActionEnablement();
+
+ menu.add(newAction);
+ menu.add(new Separator());
+
+ menu.add(copyAction);
+ menu.add(delAction);
+ menu.add(renameAction);
+ menu.add(new Separator());
+
+ menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
+ menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS + "-end")); //$NON-NLS-1$
+ menu.add(new Separator());
+
+ menu.add(refreshAction);
+ menu.add(new Separator());
+
+ menu.add(runAction);
+ menu.add(runWithAction);
+ menu.add(new Separator());
+
+ menu.add(editAction);
+ }
+
+ /**
+ * Returns the external tool if found in the selection,
+ * or <code>null</code> if none.
+ */
+ private ExternalTool getSelectedTool(IStructuredSelection selection) {
+ Object element = selection.getFirstElement();
+ if (element instanceof ExternalTool)
+ return (ExternalTool)element;
+ return null;
+ }
+
+ /**
+ * Handles a key pressed event by invoking the appropriate action.
+ */
+ public void handleKeyPressed(KeyEvent event) {
+ if (event.character == SWT.DEL && event.stateMask == 0) {
+ delAction.run();
+ return;
+ }
+
+ if (event.keyCode == SWT.F2 && event.stateMask == 0) {
+ renameAction.run();
+ return;
+ }
+
+ if (event.keyCode == SWT.F5 && event.stateMask == 0) {
+ refreshAction.run();
+ return;
+ }
+ }
+
+ /**
+ * Runs the default action by invoking the appropriate action
+ */
+ public void runDefaultAction(IStructuredSelection selection) {
+ ExternalTool tool = getSelectedTool(selection);
+ runAction.setTool(tool);
+ runAction.run();
+ }
+
+ /**
+ * Create the actions contained in this group.
+ */
+ protected void makeActions() {
+ IWorkbenchPage page = view.getSite().getPage();
+ newAction = new NewExternalToolAction();
+ copyAction = new DuplicateExternalToolAction(page);
+ delAction = new DeleteExternalToolAction(page);
+ renameAction = new RenameExternalToolAction(view);
+ refreshAction = new RefreshViewAction(page);
+ runAction = new RunExternalToolAction(page.getWorkbenchWindow());
+ runWithAction = new RunWithExternalToolAction(page.getWorkbenchWindow());
+ editAction = new EditExternalToolPropertiesAction(view);
+ }
+
+ /* (non-Javadoc)
+ * Method declared on ActionGroup.
+ */
+ public void updateActionBars() {
+ updateActionEnablement();
+ }
+
+ /**
+ * Updates the enabled state of the group's actions
+ * based on the current context selection
+ */
+ private void updateActionEnablement() {
+ ExternalTool selectedTool = getSelectedTool(
+ (IStructuredSelection) getContext().getSelection());
+
+ copyAction.setSelectedTool(selectedTool);
+ delAction.setSelectedTool(selectedTool);
+ renameAction.setSelectedTool(selectedTool);
+ runAction.setTool(selectedTool);
+ runWithAction.setTool(selectedTool);
+ editAction.setSelectedTool(selectedTool);
+ }
+}
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/view/ExternalToolContentProvider.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/view/ExternalToolContentProvider.java
new file mode 100644
index 000000000..0cde730e2
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/view/ExternalToolContentProvider.java
@@ -0,0 +1,178 @@
+package org.eclipse.ui.externaltools.internal.view;
+
+/**********************************************************************
+Copyright (c) 2002 IBM Corp. and others. All rights reserved.
+This file is 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:
+**********************************************************************/
+
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.externaltools.internal.model.ExternalToolsPlugin;
+import org.eclipse.ui.externaltools.internal.registry.ExternalToolRegistry;
+import org.eclipse.ui.externaltools.internal.registry.ExternalToolType;
+import org.eclipse.ui.externaltools.internal.registry.ExternalToolTypeRegistry;
+import org.eclipse.ui.externaltools.model.ExternalTool;
+import org.eclipse.ui.externaltools.model.ExternalToolStorage;
+import org.eclipse.ui.externaltools.model.IStorageListener;
+
+/**
+ * Provides the external tools and types as content.
+ */
+public class ExternalToolContentProvider implements ITreeContentProvider {
+ private static final Object[] EMPTY_LIST = new Object[0];
+
+ private ExternalToolTypeRegistry typeRegistry;
+ private ExternalToolRegistry toolRegistry;
+ private StorageListener listener;
+
+ /**
+ * Create a new external tools content provider.
+ *
+ * @param shell the shell to use for displaying any errors
+ * when loading external tool definitions from storage.
+ */
+ public ExternalToolContentProvider(Shell shell) {
+ super();
+ typeRegistry = ExternalToolsPlugin.getDefault().getTypeRegistry();
+ toolRegistry = ExternalToolsPlugin.getDefault().getToolRegistry(shell);
+ listener = new StorageListener();
+ listener.provider = this;
+ }
+
+ /* (non-Javadoc)
+ * Method declared on ITreeContentProvider.
+ */
+ public Object[] getChildren(Object parentElement) {
+ if (parentElement instanceof ExternalToolTypeRegistry) {
+ return typeRegistry.getToolTypes();
+ }
+
+ if (parentElement instanceof ExternalToolType) {
+ ExternalToolType type = (ExternalToolType) parentElement;
+ return toolRegistry.getToolsOfType(type.getId());
+ }
+
+ return EMPTY_LIST;
+ }
+
+ /* (non-Javadoc)
+ * Method declared on ITreeContentProvider.
+ */
+ public Object getParent(Object element) {
+ if (element instanceof ExternalTool) {
+ ExternalTool tool = (ExternalTool) element;
+ return typeRegistry.getToolType(tool.getType());
+ }
+
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * Method declared on ITreeContentProvider.
+ */
+ public boolean hasChildren(Object element) {
+ if (element instanceof ExternalToolTypeRegistry) {
+ return typeRegistry.getTypeCount() > 0;
+ }
+
+ if (element instanceof ExternalToolType) {
+ ExternalToolType type = (ExternalToolType) element;
+ return toolRegistry.getToolCountOfType(type.getId()) > 0;
+ }
+
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * Method declared on IStructuredContentProvider.
+ */
+ public Object[] getElements(Object inputElement) {
+ return getChildren(inputElement);
+ }
+
+ /* (non-Javadoc)
+ * Method declared on IContentProvider.
+ */
+ public void dispose() {
+ typeRegistry = null;
+ toolRegistry = null;
+ ExternalToolStorage.removeStorageListener(listener);
+ listener.viewer = null;
+ listener.provider = null;
+ }
+
+ /* (non-Javadoc)
+ * Method declared on IContentProvider.
+ */
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ if (oldInput == null && newInput != null) {
+ listener.viewer = (TreeViewer)viewer;
+ listener.provider = this;
+ ExternalToolStorage.addStorageListener(listener);
+ }
+ if (oldInput != null && newInput == null) {
+ ExternalToolStorage.removeStorageListener(listener);
+ listener.viewer = null;
+ listener.provider = null;
+ }
+ }
+
+
+ /**
+ * Internal listener for changes in the tool storage.
+ */
+ private static class StorageListener implements IStorageListener {
+ public TreeViewer viewer = null;
+ public ITreeContentProvider provider = null;
+
+ public void toolDeleted(ExternalTool tool) {
+ if (provider == null)
+ return;
+
+ Object parentElement = provider.getParent(tool);
+ refresh(parentElement, false);
+ }
+
+ public void toolCreated(ExternalTool tool) {
+ if (provider == null)
+ return;
+
+ Object parentElement = provider.getParent(tool);
+ refresh(parentElement, false);
+ }
+
+ public void toolModified(ExternalTool tool) {
+ if (provider == null)
+ return;
+
+ refresh(tool, true);
+ }
+
+ public void toolsRefreshed() {
+ refresh(null, true);
+ }
+
+ private void refresh(final Object element, final boolean allLabels) {
+ if (viewer == null)
+ return;
+ Control control = viewer.getControl();
+ if (control != null && !control.isDisposed()) {
+ control.getDisplay().syncExec(new Runnable() {
+ public void run() {
+ if (element == null)
+ viewer.refresh();
+ else
+ viewer.refresh(element, allLabels);
+ }
+ });
+ }
+ }
+ }
+}
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/view/ExternalToolLabelProvider.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/view/ExternalToolLabelProvider.java
new file mode 100644
index 000000000..2d55a205c
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/view/ExternalToolLabelProvider.java
@@ -0,0 +1,108 @@
+package org.eclipse.ui.externaltools.internal.view;
+
+/**********************************************************************
+Copyright (c) 2002 IBM Corp. and others. All rights reserved.
+This file is 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:
+**********************************************************************/
+
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.externaltools.internal.model.ExternalToolsPlugin;
+import org.eclipse.ui.externaltools.internal.registry.ExternalToolType;
+import org.eclipse.ui.externaltools.internal.registry.ExternalToolTypeRegistry;
+import org.eclipse.ui.externaltools.model.ExternalTool;
+
+/**
+ * Provides the label for external tools and types.
+ */
+public class ExternalToolLabelProvider extends LabelProvider {
+ /**
+ * The cache of images that have been dispensed by this provider.
+ * Maps a tool type to an Image. These images will be
+ * disposed when provider no longer needed.
+ */
+ private Map imageTable;
+
+ /**
+ * The shared workbench supplied folder image. Never disposed
+ * by provider.
+ */
+ private Image folderImage;
+
+ /**
+ * Create a new external tools label provider
+ */
+ public ExternalToolLabelProvider() {
+ super();
+ folderImage = PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FOLDER);
+ }
+
+ /* (non-Javadoc)
+ * Method declared on IBaseLabelProvider
+ */
+ public final void dispose() {
+ // Dispose images created by this provider
+ if (imageTable != null) {
+ Iterator enum = imageTable.values().iterator();
+ while (enum.hasNext()) {
+ ((Image) enum.next()).dispose();
+ }
+ imageTable = null;
+ }
+
+ // Do not dispose this shared workbench image
+ folderImage = null;
+ }
+
+ /* (non-Javadoc)
+ * Method declared on ILabelProvider.
+ */
+ public Image getImage(Object element) {
+ if (element instanceof ExternalToolType) {
+ return folderImage;
+ }
+
+ if (element instanceof ExternalTool) {
+ ExternalTool tool = (ExternalTool) element;
+ if (imageTable == null)
+ imageTable = new Hashtable(10);
+ Image image = (Image) imageTable.get(tool.getType());
+ if (image == null) {
+ ExternalToolTypeRegistry registry = ExternalToolsPlugin.getDefault().getTypeRegistry();
+ ExternalToolType type = registry.getToolType(tool.getType());
+ if (type == null)
+ image = ImageDescriptor.getMissingImageDescriptor().createImage();
+ else
+ image = type.getImageDescriptor().createImage();
+ imageTable.put(tool.getType(), image);
+ }
+ return image;
+ }
+
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * Method declared on ILabelProvider.
+ */
+ public String getText(Object element) {
+ if (element instanceof ExternalToolType)
+ return ((ExternalToolType)element).getName();
+
+ if (element instanceof ExternalTool)
+ return ((ExternalTool)element).getName();
+
+ return ""; //$NON-NLS-1$;
+ }
+}
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/view/ExternalToolView.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/view/ExternalToolView.java
new file mode 100644
index 000000000..3312fa4ae
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/view/ExternalToolView.java
@@ -0,0 +1,333 @@
+package org.eclipse.ui.externaltools.internal.view;
+
+/**********************************************************************
+Copyright (c) 2002 IBM Corp. and others. All rights reserved.
+This file is 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:
+**********************************************************************/
+
+import org.eclipse.jface.action.IMenuListener;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.IOpenListener;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.OpenEvent;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.events.KeyListener;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.actions.ActionContext;
+import org.eclipse.ui.externaltools.internal.model.ExternalToolsPlugin;
+import org.eclipse.ui.externaltools.internal.model.IHelpContextIds;
+import org.eclipse.ui.externaltools.internal.registry.ExternalToolType;
+import org.eclipse.ui.externaltools.model.ExternalTool;
+import org.eclipse.ui.help.WorkbenchHelp;
+import org.eclipse.ui.part.ViewPart;
+
+/**
+ * The view to display all the external tools available to
+ * the user. From this view, a user can create a new external
+ * tool, delete an existing external tool, run an external
+ * tool, or edit the properties of an existing external tool.
+ */
+public class ExternalToolView extends ViewPart {
+ private TreeViewer viewer;
+ private ExternalToolActionGroup actionGroup;
+
+ /**
+ * Creates a new instance of the external tools view
+ */
+ public ExternalToolView() {
+ super();
+ }
+
+ /* (non-Javadoc)
+ * Method declared on IWorkbenchPart.
+ */
+ public void createPartControl(Composite parent) {
+ viewer = createViewer(parent);
+ initContextMenu();
+ makeActions();
+ viewer.setInput(getInitialInput());
+
+ // Fill the action bars and update the global action handlers'
+ // enabled state to match the current selection.
+ actionGroup.fillActionBars(getViewSite().getActionBars());
+ updateActionBars((IStructuredSelection) viewer.getSelection());
+
+ getSite().setSelectionProvider(viewer);
+ WorkbenchHelp.setHelp(viewer.getControl(), getHelpContextId());
+ }
+
+ /**
+ * Creates the viewer control for the view.
+ *
+ * @param parent the parent composite
+ * @return the tree viewer for the view
+ */
+ protected TreeViewer createViewer(Composite parent) {
+ TreeViewer treeViewer = new TreeViewer(parent, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL);
+ treeViewer.setUseHashlookup(true);
+ initContentProvider(treeViewer);
+ initLabelProvider(treeViewer);
+ initFilters(treeViewer);
+ initListeners(treeViewer);
+
+ return treeViewer;
+ }
+
+ /* (non-Javadoc)
+ * Method declared on IWorkbenchPart.
+ */
+ public void dispose() {
+ if (actionGroup != null)
+ actionGroup.dispose();
+
+ super.dispose();
+ }
+
+ /**
+ * Called when the context menu is about to open.
+ * Delegates to the action group using the
+ * viewer's selection as the action context.
+ */
+ protected void fillContextMenu(IMenuManager menu) {
+ IStructuredSelection selection =
+ (IStructuredSelection) viewer.getSelection();
+ actionGroup.setContext(new ActionContext(selection));
+ actionGroup.fillContextMenu(menu);
+ }
+
+ /**
+ * Returns the action group.
+ *
+ * @return the action group
+ */
+ protected final ExternalToolActionGroup getActionGroup() {
+ return actionGroup;
+ }
+
+ /**
+ * Returns the help context id to use for this view.
+ */
+ protected String getHelpContextId() {
+ return IHelpContextIds.EXTERNAL_TOOLS_VIEW;
+ }
+
+ /**
+ * Returns the initial input for the viewer.
+ */
+ protected Object getInitialInput() {
+ return ExternalToolsPlugin.getDefault().getTypeRegistry();
+ }
+
+ /**
+ * Returns the message to show in the status line.
+ *
+ * @param selection the current selection
+ * @return the status line message
+ */
+ protected String getStatusLineMessage(IStructuredSelection selection) {
+ if (selection.size() == 1) {
+ Object element = selection.getFirstElement();
+ if (element instanceof ExternalToolType)
+ return ((ExternalToolType)element).getDescription();
+ if (element instanceof ExternalTool)
+ return ((ExternalTool)element).getDescription();
+ }
+ return ""; //$NON-NLS-1$
+ }
+
+ /**
+ * Returns the tree viewer which shows the external tools.
+ */
+ public final TreeViewer getTreeViewer() {
+ return viewer;
+ }
+
+ /**
+ * Handles a double-click event from the viewer.
+ * Expands or collapses a type when double-clicked.
+ *
+ * @param event the double-click event
+ */
+ protected void handleDoubleClick(DoubleClickEvent event) {
+ IStructuredSelection selection = (IStructuredSelection) event.getSelection();
+ Object element = selection.getFirstElement();
+ if (viewer.isExpandable(element))
+ viewer.setExpandedState(element, !viewer.getExpandedState(element));
+ }
+
+ /**
+ * Handles a key press event from the viewer.
+ * Delegates to the action group.
+ *
+ * @param event the key event
+ */
+ protected void handleKeyPressed(KeyEvent event) {
+ actionGroup.handleKeyPressed(event);
+ }
+
+ /**
+ * Handles a key release in the viewer. Does
+ * nothing by default.
+ *
+ * @param event the key event
+ */
+ protected void handleKeyReleased(KeyEvent event) {
+ }
+
+ /**
+ * Handles an open event from the viewer.
+ * Causes the selected external tool to be run.
+ *
+ * @param event the open event
+ */
+ protected void handleOpen(OpenEvent event) {
+ IStructuredSelection selection = (IStructuredSelection) event.getSelection();
+ actionGroup.runDefaultAction(selection);
+ }
+
+ /**
+ * Handles a selection changed event from the viewer.
+ * Updates the status line and the action bars.
+ *
+ * @param event the selection event
+ */
+ protected void handleSelectionChanged(SelectionChangedEvent event) {
+ IStructuredSelection sel = (IStructuredSelection) event.getSelection();
+ updateStatusLine(sel);
+ updateActionBars(sel);
+ }
+
+ /**
+ * Initializes and registers the context menu.
+ */
+ protected void initContextMenu() {
+ MenuManager menuMgr = new MenuManager(); //$NON-NLS-1$
+ menuMgr.setRemoveAllWhenShown(true);
+ menuMgr.addMenuListener(new IMenuListener() {
+ public void menuAboutToShow(IMenuManager manager) {
+ fillContextMenu(manager);
+ }
+ });
+ Menu menu = menuMgr.createContextMenu(viewer.getTree());
+ viewer.getTree().setMenu(menu);
+ getSite().registerContextMenu(menuMgr, viewer);
+ }
+
+ /**
+ * Sets the content provider for the viewer.
+ *
+ * @param treeViewer the tree viewer
+ */
+ protected void initContentProvider(TreeViewer treeViewer) {
+ Shell shell = getSite().getShell();
+ treeViewer.setContentProvider(new ExternalToolContentProvider(shell));
+ }
+
+ /**
+ * Sets the label provider for the viewer.
+ *
+ * @param treeViewer the tree viewer
+ */
+ protected void initLabelProvider(TreeViewer treeViewer) {
+ treeViewer.setLabelProvider(new ExternalToolLabelProvider());
+ }
+
+ /**
+ * Adds the filters to the viewer.
+ *
+ * @param treeViewer the tree viewer
+ */
+ protected void initFilters(TreeViewer treeViewer) {
+ }
+
+ /**
+ * Adds the listeners to the viewer.
+ *
+ * @param treeViewer the tree viewer
+ */
+ protected void initListeners(TreeViewer treeViewer) {
+ treeViewer.addSelectionChangedListener(new ISelectionChangedListener() {
+ public void selectionChanged(SelectionChangedEvent event) {
+ handleSelectionChanged(event);
+ }
+ });
+
+ treeViewer.addDoubleClickListener(new IDoubleClickListener() {
+ public void doubleClick(DoubleClickEvent event) {
+ handleDoubleClick(event);
+ }
+ });
+
+ treeViewer.addOpenListener(new IOpenListener() {
+ public void open(OpenEvent event) {
+ handleOpen(event);
+ }
+ });
+
+ treeViewer.getControl().addKeyListener(new KeyListener() {
+ public void keyPressed(KeyEvent event) {
+ handleKeyPressed(event);
+ }
+ public void keyReleased(KeyEvent event) {
+ handleKeyReleased(event);
+ }
+ });
+ }
+
+ /**
+ * Creates the action group, which encapsulates all actions
+ * for the view.
+ */
+ protected void makeActions() {
+ setActionGroup(new ExternalToolActionGroup(this));
+ }
+
+ /**
+ * Sets the action group.
+ *
+ * @param actionGroup the action group
+ */
+ protected void setActionGroup(ExternalToolActionGroup actionGroup) {
+ this.actionGroup = actionGroup;
+ }
+
+ /* (non-Javadoc)
+ * Method declared on IWorkbenchPart.
+ */
+ public void setFocus() {
+ viewer.getTree().setFocus();
+ }
+
+ /**
+ * Updates the action bar actions.
+ *
+ * @param selection the current selection
+ */
+ protected void updateActionBars(IStructuredSelection selection) {
+ actionGroup.setContext(new ActionContext(selection));
+ actionGroup.updateActionBars();
+ }
+
+ /**
+ * Updates the message shown in the status line.
+ *
+ * @param selection the current selection
+ */
+ protected void updateStatusLine(IStructuredSelection selection) {
+ String msg = getStatusLineMessage(selection);
+ getViewSite().getActionBars().getStatusLineManager().setMessage(msg);
+ }
+}
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/view/NewExternalToolAction.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/view/NewExternalToolAction.java
new file mode 100644
index 000000000..2fcf18d0f
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/view/NewExternalToolAction.java
@@ -0,0 +1,48 @@
+package org.eclipse.ui.externaltools.internal.view;
+
+/**********************************************************************
+Copyright (c) 2002 IBM Corp. and others. All rights reserved.
+This file is 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:
+**********************************************************************/
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.ui.actions.NewWizardAction;
+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.help.WorkbenchHelp;
+
+/**
+ * Action that will launch a wizard to create a new
+ * external tool.
+ */
+public class NewExternalToolAction extends Action {
+ private static final String CATEGORY_ID = "org.eclipse.ui.externaltools.newWizards"; //$NON-NLS-1$
+
+ /**
+ * Create an action to launch a new
+ * external tool wizard.
+ */
+ public NewExternalToolAction() {
+ super();
+ setText(ToolMessages.getString("NewExternalToolAction.text")); //$NON-NLS-1$
+ setToolTipText(ToolMessages.getString("NewExternalToolAction.toolTip")); //$NON-NLS-1$
+ setHoverImageDescriptor(ExternalToolsPlugin.getDefault().getImageDescriptor("icons/full/clcl16/new_tool.gif")); //$NON-NLS-1$
+ setImageDescriptor(ExternalToolsPlugin.getDefault().getImageDescriptor("icons/full/elcl16/new_tool.gif")); //$NON-NLS-1$
+ setDisabledImageDescriptor(ExternalToolsPlugin.getDefault().getImageDescriptor("icons/full/dlcl16/new_tool.gif")); //$NON-NLS-1$
+ WorkbenchHelp.setHelp(this, IHelpContextIds.NEW_TOOL_ACTION);
+ }
+
+ /* (non-Javadoc)
+ * Method declared on Action.
+ */
+ public void run() {
+ NewWizardAction action = new NewWizardAction();
+ action.setCategoryId(CATEGORY_ID);
+ action.run();
+ }
+}
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/view/RefreshViewAction.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/view/RefreshViewAction.java
new file mode 100644
index 000000000..9ee6d5f85
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/view/RefreshViewAction.java
@@ -0,0 +1,49 @@
+package org.eclipse.ui.externaltools.internal.view;
+
+/**********************************************************************
+Copyright (c) 2002 IBM Corp. and others. All rights reserved.
+This file is 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:
+**********************************************************************/
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IWorkbenchPage;
+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.ExternalToolStorage;
+import org.eclipse.ui.help.WorkbenchHelp;
+
+/**
+ * Action that will refresh the contents of the
+ * external tool view.
+ */
+public class RefreshViewAction extends Action {
+ private IWorkbenchPage page;
+
+ /**
+ * Create an action to refresh the view
+ */
+ public RefreshViewAction(IWorkbenchPage page) {
+ super();
+ this.page = page;
+ setText(ToolMessages.getString("RefreshViewAction.text")); //$NON-NLS-1$
+ setToolTipText(ToolMessages.getString("RefreshViewAction.toolTip")); //$NON-NLS-1$
+ setHoverImageDescriptor(ExternalToolsPlugin.getDefault().getImageDescriptor("icons/full/clcl16/refresh.gif")); //$NON-NLS-1$
+ setImageDescriptor(ExternalToolsPlugin.getDefault().getImageDescriptor("icons/full/elcl16/refresh.gif")); //$NON-NLS-1$
+ setDisabledImageDescriptor(ExternalToolsPlugin.getDefault().getImageDescriptor("icons/full/dlcl16/refresh.gif")); //$NON-NLS-1$
+ WorkbenchHelp.setHelp(this, IHelpContextIds.REFRESH_VIEW_ACTION);
+ }
+
+ /* (non-Javadoc)
+ * Method declared on Action.
+ */
+ public void run() {
+ Shell shell = page.getWorkbenchWindow().getShell();
+ ExternalToolStorage.refreshTools(shell);
+ }
+}
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
new file mode 100644
index 000000000..9cdccf5ea
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/view/RenameExternalToolAction.java
@@ -0,0 +1,71 @@
+package org.eclipse.ui.externaltools.internal.view;
+
+/**********************************************************************
+Copyright (c) 2002 IBM Corp. and others. All rights reserved.
+This file is 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:
+**********************************************************************/
+
+import org.eclipse.jface.action.Action;
+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.help.WorkbenchHelp;
+
+/**
+ * Action that will rename the external tool selected
+ * in the the view.
+ */
+public class RenameExternalToolAction extends Action {
+ private ExternalToolView view;
+ private TextActionHandler textActionHandler;
+ private ExternalTool selectedTool;
+
+ /**
+ * Create an action to rename the external tool.
+ */
+ public RenameExternalToolAction(ExternalToolView view) {
+ super();
+ this.view = view;
+ setText(ToolMessages.getString("RenameExternalToolAction.text")); //$NON-NLS-1$
+ setToolTipText(ToolMessages.getString("RenameExternalToolAction.toolTip")); //$NON-NLS-1$
+ setHoverImageDescriptor(ExternalToolsPlugin.getDefault().getImageDescriptor("icons/full/clcl16/rename_tool.gif")); //$NON-NLS-1$
+ setImageDescriptor(ExternalToolsPlugin.getDefault().getImageDescriptor("icons/full/elcl16/rename_tool.gif")); //$NON-NLS-1$
+ setDisabledImageDescriptor(ExternalToolsPlugin.getDefault().getImageDescriptor("icons/full/dlcl16/rename_tool.gif")); //$NON-NLS-1$
+ WorkbenchHelp.setHelp(this, IHelpContextIds.RENAME_TOOL_ACTION);
+ }
+
+ /**
+ * Returns the selected external tool.
+ */
+ public ExternalTool getSelectedTool() {
+ return selectedTool;
+ }
+
+ /* (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");
+ }
+
+ /**
+ * Sets the selected external tool.
+ */
+ public void setSelectedTool(ExternalTool tool) {
+ selectedTool = tool;
+ setEnabled(tool != null);
+ }
+
+ /**
+ * Sets the text action handler
+ */
+ public void setTextActionHandler(TextActionHandler handler) {
+ textActionHandler = handler;
+ }
+}
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/model/ExternalTool.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/model/ExternalTool.java
new file mode 100644
index 000000000..9ad2ca6aa
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/model/ExternalTool.java
@@ -0,0 +1,543 @@
+package org.eclipse.ui.externaltools.model;
+
+/**********************************************************************
+Copyright (c) 2002 IBM Corp. and others. All rights reserved.
+This file is 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:
+**********************************************************************/
+
+import java.text.MessageFormat;
+import java.util.ArrayList;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IncrementalProjectBuilder;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.IActionFilter;
+import org.eclipse.ui.externaltools.internal.model.ExternalToolsPlugin;
+import org.eclipse.ui.model.IWorkbenchAdapter;
+
+/**
+ * This class represents an external tool that can be run. The tool
+ * can be inside or outside the workspace.
+ * <p>
+ * An external tool consist of a user defined name, the location
+ * of the tool, optional arguments for the tool, and the working
+ * directory.
+ * </p><p>
+ * After the tool has run, part or all of the workspace can be
+ * refreshed to pickup changes made by the tool. This is optional
+ * and does nothing by default
+ * </p><p>
+ * This class is not intended to be extended by clients
+ * </p>
+ */
+public final class ExternalTool implements IAdaptable {
+ private static final String EMPTY_STRING = ""; //$NON-NLS-1$
+ private static final int[] DEFAULT_BUILD_KINDS =
+ {IncrementalProjectBuilder.INCREMENTAL_BUILD,
+ IncrementalProjectBuilder.FULL_BUILD,
+ IncrementalProjectBuilder.AUTO_BUILD};
+
+ private static final ToolWorkbenchAdapter workbenchAdapter = new ToolWorkbenchAdapter();
+ private static final ToolFilterAdapter filterAdapter = new ToolFilterAdapter();
+
+ private String type = EMPTY_STRING;
+ private String name = EMPTY_STRING;
+ private String location = EMPTY_STRING;
+ private String arguments = EMPTY_STRING;
+ private String workDirectory = EMPTY_STRING;
+ private String description = EMPTY_STRING;
+ private String openPerspective = null;
+ private String refreshScope = null;
+ private boolean refreshRecursive = true;
+ private boolean captureOutput = true;
+ private boolean showConsole = true;
+ private boolean runInBackground = true;
+ private boolean promptForArguments = false;
+ private boolean showInMenu = false;
+ private boolean saveDirtyEditors = false;
+ private int[] runForBuildKinds = DEFAULT_BUILD_KINDS;
+ private ArrayList extraAttributes = null;
+
+ /**
+ * Creates a fully initialized external tool.
+ *
+ * @param type the type of external tool.
+ * @param name the name given to the external tool. Must only
+ * contain letters, numbers, hyphens, and spaces.
+ */
+ public ExternalTool(String type, String name) throws CoreException {
+ super();
+
+ if (type != null)
+ this.type = type;
+
+ String errorText = validateToolName(name);
+ if (errorText == null)
+ this.name = name.trim();
+ else
+ throw ExternalToolsPlugin.newError(errorText, null);
+ }
+
+ /**
+ * Validates the specified tool name only includes letters,
+ * numbers, hyphens, and spaces. Must contain at least one
+ * letter or number.
+ *
+ * @param name the proposed name for the external tool
+ * @return a string indicating the invalid format or <code>null</code> if valid.
+ */
+ public static String validateToolName(String name) {
+ IStatus status = ResourcesPlugin.getWorkspace().validateName(name, IResource.FILE);
+ if (status.getCode() != IStatus.OK) {
+ return status.getMessage();
+ }
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * Method declared on IAdaptable.
+ */
+ public Object getAdapter(Class adapter) {
+ if (adapter == IWorkbenchAdapter.class)
+ return workbenchAdapter;
+
+ if (adapter == IActionFilter.class)
+ return filterAdapter;
+
+ return null;
+ }
+
+ /**
+ * Returns the extra attribute value
+ *
+ * @param key the unique attribute name
+ * @return the value of the attribute, or <code>null</code>
+ * if not such attribute name.
+ */
+ public String getExtraAttribute(String key) {
+ if (key == null || key.length() == 0)
+ return null;
+ if (extraAttributes == null)
+ return null;
+
+ for (int i = 0; i < extraAttributes.size(); i++) {
+ Attribute attr = (Attribute)extraAttributes.get(i);
+ if (attr.key.equals(key))
+ return attr.value;
+ }
+
+ return null;
+ }
+
+ /**
+ * Returns all the extra attribute keys
+ */
+ public String[] getExtraAttributeKeys() {
+ if (extraAttributes == null)
+ return new String[0];
+
+ String[] results = new String[extraAttributes.size()];
+ for (int i = 0; i < extraAttributes.size(); i++) {
+ Attribute attr = (Attribute)extraAttributes.get(i);
+ results[i] = attr.key;
+ }
+
+ return results;
+ }
+
+ /**
+ * Returns all the extra attribute values
+ */
+ public String[] getExtraAttributeValues() {
+ if (extraAttributes == null)
+ return new String[0];
+
+ String[] results = new String[extraAttributes.size()];
+ for (int i = 0; i < extraAttributes.size(); i++) {
+ Attribute attr = (Attribute)extraAttributes.get(i);
+ results[i] = attr.value;
+ }
+
+ return results;
+ }
+
+ /**
+ * Sets an extra attribute to the tool.
+ *
+ * @param key the unique attribute name
+ * @param value the value for the attribute. If <code>null</code>,
+ * then the existing attribute is removed.
+ */
+ public void setExtraAttribute(String key, String value) {
+ // Exit on invalid key
+ if (key == null || key.length() == 0)
+ return;
+
+ // Init the list but only if not attempting to remove
+ // an extra attribute
+ if (extraAttributes == null) {
+ if (value == null)
+ return;
+ else
+ extraAttributes = new ArrayList(4);
+ }
+
+ // If the extra attribute exist, update it with the
+ // new value, or remove it if the value is null
+ for (int i = 0; i < extraAttributes.size(); i++) {
+ Attribute attr = (Attribute)extraAttributes.get(i);
+ if (attr.key.equals(key)) {
+ if (value == null)
+ extraAttributes.remove(i);
+ else
+ attr.value = value.trim();
+ return;
+ }
+ }
+
+ // Otherwise add the new extra attribute
+ if (value != null)
+ extraAttributes.add(new Attribute(key, value.trim()));
+ }
+
+ /**
+ * Returns the type of external tool.
+ */
+ public String getType() {
+ return type;
+ }
+
+ /**
+ * Returns the name of the external tool.
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Returns the location of the external tool.
+ */
+ public String getLocation() {
+ return location;
+ }
+
+ /**
+ * Returns the arguments for the external tool.
+ */
+ public String getArguments() {
+ return arguments;
+ }
+
+ /**
+ * Returns the working directory to run the external tool in.
+ */
+ public String getWorkingDirectory() {
+ return workDirectory;
+ }
+
+ /**
+ * Returns whether the refresh will be recursive.
+ */
+ public boolean getRefreshRecursive() {
+ return refreshRecursive;
+ }
+
+ /**
+ * Returns the scope of resources to refresh after
+ * the external tool is run, or <code>null</code> if
+ * not specified. The value is in an variable
+ * format.
+ */
+ public String getRefreshScope() {
+ return refreshScope;
+ }
+
+ /**
+ * Returns whether to capture output messages from the
+ * running tool.
+ */
+ public boolean getCaptureOutput() {
+ return captureOutput;
+ }
+
+ /**
+ * Returns whether to show the log console when
+ * the tool is run.
+ */
+ public boolean getShowConsole() {
+ return showConsole;
+ }
+
+ /**
+ * Returns whether to run the external tool in the
+ * background so as not to block the UI.
+ */
+ public boolean getRunInBackground() {
+ return runInBackground;
+ }
+
+ /**
+ * Returns whether to prompt for arguments before
+ * the tool is run.
+ */
+ public boolean getPromptForArguments() {
+ return promptForArguments;
+ }
+
+ /**
+ * Returns whether to show this tool in the
+ * Run > External Tools menu.
+ */
+ public boolean getShowInMenu() {
+ return showInMenu;
+ }
+
+ /**
+ * Returns whether to save all dirty editors before
+ * running this tool.
+ */
+ public boolean getSaveDirtyEditors() {
+ return saveDirtyEditors;
+ }
+
+ /**
+ * Returns the perspective ID to open when this
+ * tool is run, or <code>null</code> if not specified.
+ */
+ public String getOpenPerspective() {
+ return openPerspective;
+ }
+
+ /**
+ * Returns a description of this external tool
+ */
+ public String getDescription() {
+ return description;
+ }
+
+ /**
+ * Returns the list of build kinds that this
+ * tool wants to run when used as a builder.
+ * The list of valid build kinds is defined
+ * on <code>IncrementalProjectBuilder</code>.
+ */
+ public int[] getRunForBuildKinds() {
+ return runForBuildKinds;
+ }
+
+ /**
+ * Sets the name of the external tool.
+ */
+ public void rename(String name) throws CoreException {
+ IStatus status= ExternalToolsPlugin.getDefault().getToolRegistry(null).renameTool(this, name);
+ if (!status.isOK()) {
+ // Throw an exception
+ ExternalToolsPlugin.newError(MessageFormat.format("An exception occurred attempting to rename the tool: ", new Object[] {this.getName()}), null);
+ }
+ if (name == null) {
+ this.name = EMPTY_STRING;
+ } else {
+ this.name = name;
+ }
+ }
+
+ /**
+ * Sets the location of the external tool.
+ */
+ public void setLocation(String location) {
+ if (location == null)
+ this.location = EMPTY_STRING;
+ else
+ this.location = location.trim();
+ }
+
+ /**
+ * Sets the arguments for the external tool.
+ */
+ public void setArguments(String arguments) {
+ if (arguments == null)
+ this.arguments = EMPTY_STRING;
+ else
+ this.arguments = arguments.trim();
+ }
+
+ /**
+ * Sets the working directory to run the external tool in.
+ */
+ public void setWorkingDirectory(String workDirectory) {
+ if (workDirectory == null)
+ this.workDirectory = EMPTY_STRING;
+ else
+ this.workDirectory = workDirectory.trim();
+ }
+
+ /**
+ * Sets whether the refresh will be recursive.
+ */
+ public void setRefreshRecursive(boolean refreshRecursive) {
+ this.refreshRecursive = refreshRecursive;
+ }
+
+ /**
+ * Sets the scope of resources to refresh after
+ * the external tool is run, or <code>null</code>
+ * if none. The value is in a variable format.
+ */
+ public void setRefreshScope(String refreshScope) {
+ if (refreshScope == null)
+ this.refreshScope = null;
+ else {
+ this.refreshScope = refreshScope.trim();
+ if (this.refreshScope.length() == 0)
+ this.refreshScope = null;
+ }
+ }
+
+ /**
+ * Sets whether to capture output messages from the
+ * running tool.
+ */
+ public void setCaptureOutput(boolean captureOutput) {
+ this.captureOutput = captureOutput;
+ }
+
+ /**
+ * Sets whether to show the log console when
+ * the tool is run.
+ */
+ public void setShowConsole(boolean showConsole) {
+ this.showConsole = showConsole;
+ }
+
+ /**
+ * Sets whether to run the external tool in the
+ * background so as not to block the UI.
+ */
+ public void setRunInBackground(boolean runInBackground) {
+ this.runInBackground = runInBackground;
+ }
+
+ /**
+ * Sets whether to prompt for arguments before
+ * the tool is run.
+ */
+ public void setPromptForArguments(boolean promptForArguments) {
+ this.promptForArguments = promptForArguments;
+ }
+
+ /**
+ * Sets whether to show this tool in the
+ * Run > External Tools menu.
+ */
+ public void setShowInMenu(boolean showInMenu) {
+ this.showInMenu = showInMenu;
+ }
+
+ /**
+ * Sets whether all dirty editors will be saved
+ * before running this tool.
+ */
+ public void setSaveDirtyEditors(boolean saveDirtyEditors) {
+ this.saveDirtyEditors = saveDirtyEditors;
+ }
+
+ /**
+ * Sets the perspective ID to open when this
+ * tool is run, or <code>null</code> if not specified.
+ */
+ public void setOpenPerspective(String openPerspective) {
+ if (openPerspective == null)
+ this.openPerspective = null;
+ else {
+ this.openPerspective = openPerspective.trim();
+ if (this.openPerspective.length() == 0)
+ this.openPerspective = null;
+ }
+ }
+
+ /**
+ * Sets a description of this external tool
+ */
+ public void setDescription(String description) {
+ if (description == null)
+ this.description = EMPTY_STRING;
+ else
+ this.description = description.trim();
+ }
+
+ /**
+ * Sets the list of build kinds that this
+ * tool wants to run when used as a builder.
+ * The list of valid build kinds is defined
+ * on <code>IncrementalProjectBuilder</code>.
+ */
+ public void setRunForBuildKinds(int[] kinds) {
+ if (kinds == null)
+ this.runForBuildKinds = DEFAULT_BUILD_KINDS;
+ else
+ this.runForBuildKinds = kinds;
+ }
+
+ /**
+ * Internal representation of extra attributes.
+ */
+ private static class Attribute {
+ public String key;
+ public String value;
+
+ public Attribute(String key, String value) {
+ super();
+ this.key = key;
+ this.value = value;
+ }
+ }
+
+ /**
+ * Internal workbench adapter implementation.
+ */
+ private static class ToolWorkbenchAdapter implements IWorkbenchAdapter {
+ public Object[] getChildren(Object o) {
+ return new Object[0];
+ }
+
+ public ImageDescriptor getImageDescriptor(Object o) {
+ String type = ((ExternalTool)o).getType();
+ return ExternalToolsPlugin.getDefault().getTypeRegistry().getToolTypeImageDescriptor(type);
+ }
+
+ public String getLabel(Object o) {
+ return ((ExternalTool)o).getName();
+ }
+
+ public Object getParent(Object o) {
+ String type = ((ExternalTool)o).getType();
+ return ExternalToolsPlugin.getDefault().getTypeRegistry().getToolType(type);
+ }
+ }
+
+ /**
+ * Internal action filter adapter implementation.
+ */
+ private static class ToolFilterAdapter implements IExternalToolFilter {
+ public boolean testAttribute(Object target, String name, String value) {
+ ExternalTool tool = (ExternalTool) target;
+
+ if (IExternalToolFilter.TYPE.equals(name))
+ return tool.getType().equals(value);
+
+ String attrValue = tool.getExtraAttribute(name);
+ if (attrValue != null)
+ return attrValue.equals(value);
+
+ return false;
+ }
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/model/ExternalToolStorage.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/model/ExternalToolStorage.java
new file mode 100644
index 000000000..a22e2278c
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/model/ExternalToolStorage.java
@@ -0,0 +1,153 @@
+package org.eclipse.ui.externaltools.model;
+
+/**********************************************************************
+Copyright (c) 2002 IBM Corp. and others. All rights reserved.
+This file is 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:
+**********************************************************************/
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.util.ListenerList;
+import org.eclipse.swt.custom.BusyIndicator;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.externaltools.internal.model.ExternalToolsPlugin;
+import org.eclipse.ui.externaltools.internal.model.ToolMessages;
+import org.eclipse.ui.externaltools.internal.registry.ExternalToolRegistry;
+
+/**
+ * Provides utility methods to manager the storage
+ * of external tools.
+ */
+public final class ExternalToolStorage {
+ private static ListenerList listeners = new ListenerList();
+
+ /**
+ * Allows no instance to be created
+ */
+ private ExternalToolStorage() {
+ super();
+ }
+
+ /**
+ * Adds a tool storage listener.
+ *
+ * @param listener the tool storage listener to add
+ */
+ public static void addStorageListener(IStorageListener listener) {
+ listeners.add(listener);
+ }
+
+ /**
+ * Deletes the external tool from storage and from
+ * the tools registry.
+ *
+ * @param tool the external tool to be deleted
+ * @param shell the shell to parent any error dialogs,
+ * of <code>null</code> to operate quietly.
+ */
+ public static void deleteTool(ExternalTool tool, Shell shell) {
+ if (tool == null)
+ return;
+
+ ExternalToolRegistry registry = ExternalToolsPlugin.getDefault().getToolRegistry(shell);
+ IStatus results = registry.deleteTool(tool);
+
+ if (handleResults(results, shell, "ExternalToolStorage.deleteErrorTitle", "ExternalToolStorage.deleteErrorMessage")) //$NON-NLS-2$//$NON-NLS-1$
+ return;
+
+ Object list[] = listeners.getListeners();
+ for (int i = 0; i < list.length; i++) {
+ ((IStorageListener)list[i]).toolDeleted(tool);
+ }
+ }
+
+ /**
+ * Handles the display of any error message if the
+ * results were not ok.
+ *
+ * @return <code>true</code> if an error was displayed, <code>false</code> otherwise
+ */
+ private static boolean handleResults(final IStatus results, final Shell shell, final String titleKey, final String msgKey) {
+ if (!results.isOK() && shell != null && !shell.isDisposed()) {
+ shell.getDisplay().syncExec(new Runnable() {
+ public void run() {
+ String title = ToolMessages.getString(titleKey);
+ String msg = ToolMessages.getString(msgKey);
+ ErrorDialog.openError(shell, title, msg, results);
+ }
+ });
+
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
+ * Reloads the tools from storage into the registry.
+ *
+ * @param shell the shell to parent any error dialogs,
+ * of <code>null</code> to operate quietly.
+ */
+ public static void refreshTools(final Shell shell) {
+ final IStatus[] results = new IStatus[1];
+
+ BusyIndicator.showWhile(shell.getDisplay(), new Runnable() {
+ public void run() {
+ results[0] = ExternalToolsPlugin.getDefault().getToolRegistry(shell).reloadTools();
+ }
+ });
+
+ if (handleResults(results[0], shell, "ExternalToolStorage.reloadErrorTitle", "ExternalToolStorage.reloadErrorMessage")) //$NON-NLS-2$//$NON-NLS-1$
+ return;
+
+ Object list[] = listeners.getListeners();
+ for (int i = 0; i < list.length; i++) {
+ ((IStorageListener)list[i]).toolsRefreshed();
+ }
+ }
+
+ /**
+ * Removes a tool storage listener.
+ *
+ * @param listener the tool storage listener to remove
+ */
+ public static void removeStorageListener(IStorageListener listener) {
+ listeners.remove(listener);
+ }
+
+ /**
+ * Saves the external tool to storage and to
+ * the tools registry.
+ *
+ * @param tool the external tool to be saved
+ * @param shell the shell to parent any error dialogs,
+ * of <code>null</code> to operate quietly.
+ * @return <code>true</code> if save successful, <code>false</code> otherwise.
+ */
+ public static boolean saveTool(ExternalTool tool, Shell shell) {
+ if (tool == null)
+ return false;
+
+ ExternalToolRegistry registry = ExternalToolsPlugin.getDefault().getToolRegistry(shell);
+ boolean exists = registry.hasToolNamed(tool.getName());
+
+ IStatus results = registry.saveTool(tool);
+ if (handleResults(results, shell, "ExternalToolStorage.saveErrorTitle", "ExternalToolStorage.saveErrorMessage")) //$NON-NLS-2$//$NON-NLS-1$
+ return false;
+
+ Object list[] = listeners.getListeners();
+ for (int i = 0; i < list.length; i++) {
+ if (exists)
+ ((IStorageListener)list[i]).toolModified(tool);
+ else
+ ((IStorageListener)list[i]).toolCreated(tool);
+ }
+
+ return true;
+ }
+}
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/model/IExternalToolConstants.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/model/IExternalToolConstants.java
new file mode 100644
index 000000000..8469d3a80
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/model/IExternalToolConstants.java
@@ -0,0 +1,210 @@
+package org.eclipse.ui.externaltools.model;
+
+/**********************************************************************
+Copyright (c) 2002 IBM Corp. and others. All rights reserved.
+This file is 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:
+**********************************************************************/
+
+/**
+ * Defines the constants available for client use.
+ * <p>
+ * This interface is not intended to be extended or implemented by clients.
+ * </p>
+ */
+public interface IExternalToolConstants {
+ // ------- Extensions -------
+ /**
+ * Plugin identifier for external tools (value <code>org.eclipse.ui.externaltools</code>).
+ */
+ public static final String PLUGIN_ID = "org.eclipse.ui.externaltools"; //$NON-NLS-1$;
+
+ /**
+ * Extension point to declare types of external tools
+ * (value <code>toolTypes</code>).
+ */
+ public static final String PL_TOOL_TYPES = "toolTypes"; //$NON-NLS-1$
+
+ /**
+ * Extension point to declare argument variables
+ * (value <code>argumentVariables</code>).
+ */
+ public static final String PL_ARGUMENT_VARIABLES = "argumentVariables"; //$NON-NLS-1$
+
+ /**
+ * Extension point to declare file variables
+ * (value <code>fileVariables</code>).
+ */
+ public static final String PL_FILE_VARIABLES = "fileVariables"; //$NON-NLS-1$
+
+ /**
+ * Extension point to declare directory variables
+ * (value <code>directoryVariables</code>).
+ */
+ public static final String PL_DIRECTORY_VARIABLES = "directoryVariables"; //$NON-NLS-1$
+
+ /**
+ * Extension point to declare refresh scope variables
+ * (value <code>refreshVariables</code>).
+ */
+ public static final String PL_REFRESH_VARIABLES = "refreshVariables"; //$NON-NLS-1$
+
+
+ // ------- Views -------
+ /**
+ * External tool view identifier (value <code>org.eclipse.ui.externaltools.ExternalToolView</code>).
+ */
+ public static final String VIEW_ID = PLUGIN_ID + ".ExternalToolView"; //$NON-NLS-1$
+
+ /**
+ * Log Console view identifier (value <code>org.eclipse.ui.externaltools.LogConsoleView</code>).
+ */
+ public static final String LOG_CONSOLE_VIEW_ID = PLUGIN_ID + ".LogConsoleView"; //$NON-NLS-1$
+
+
+ // ------- Tool Types -------
+ /**
+ * External tool type for programs such as executables, batch files,
+ * shell scripts, etc (value <code>programType</code>).
+ */
+ public static final String TOOL_TYPE_PROGRAM = "programType"; //$NON-NLS-1$;
+
+ /**
+ * External tool type for Ant build files (value <code>antBuildType</code>).
+ */
+ public static final String TOOL_TYPE_ANT_BUILD = "antBuildType"; //$NON-NLS-1$;
+
+
+ // ------- Variables -------
+ /**
+ * Variable that expands to the workspace root object (value <code>workspace</code>).
+ */
+ public static final String VAR_WORKSPACE = "workspace"; //$NON-NLS-1$
+
+ /**
+ * Variable that expands to the absolute path on the system's hard drive
+ * to the workspace directory (value <code>workspace_loc</code>).
+ */
+ public static final String VAR_WORKSPACE_LOC = "workspace_loc"; //$NON-NLS-1$
+
+ /**
+ * Variable that expands to the project resource (value <code>project</code>).
+ */
+ public static final String VAR_PROJECT = "project"; //$NON-NLS-1$
+
+ /**
+ * Variable that expands to the absolute path on the system's hard drive
+ * to a project's directory (value <code>project_loc</code>).
+ */
+ public static final String VAR_PROJECT_LOC = "project_loc"; //$NON-NLS-1$
+
+ /**
+ * Variable that expands to the full path, relative to the workspace root,
+ * of a project (value <code>project_path</code>).
+ */
+ public static final String VAR_PROJECT_PATH = "project_path"; //$NON-NLS-1$
+
+ /**
+ * Variable that expands to the name of a project (value <code>project_name</code>).
+ */
+ public static final String VAR_PROJECT_NAME = "project_name"; //$NON-NLS-1$
+
+ /**
+ * Variable that expands to a resource (value <code>resource</code>).
+ */
+ public static final String VAR_RESOURCE = "resource"; //$NON-NLS-1$
+
+ /**
+ * Variable that expands to the absolute path on the system's hard drive
+ * to a resource's location (value <code>resource_loc</code>).
+ */
+ public static final String VAR_RESOURCE_LOC = "resource_loc"; //$NON-NLS-1$
+
+ /**
+ * Variable that expands to the full path, relative to the workspace root,
+ * of a resource (value <code>resource_path</code>).
+ */
+ public static final String VAR_RESOURCE_PATH = "resource_path"; //$NON-NLS-1$
+
+ /**
+ * Variable that expands to the name of a resource (value <code>resource_name</code>).
+ */
+ public static final String VAR_RESOURCE_NAME = "resource_name"; //$NON-NLS-1$
+
+ /**
+ * Variable that expands to the container resource (value <code>container</code>).
+ */
+ public static final String VAR_CONTAINER = "container"; //$NON-NLS-1$
+
+ /**
+ * Variable that expands to the absolute path on the system's hard drive
+ * to a resource's containing directory (value <code>container_loc</code>).
+ */
+ public static final String VAR_CONTAINER_LOC = "container_loc"; //$NON-NLS-1$
+
+ /**
+ * Variable that expands to the full path, relative to the workspace root,
+ * of a resource's parent (value <code>container_path</code>).
+ */
+ public static final String VAR_CONTAINER_PATH = "container_path"; //$NON-NLS-1$
+
+ /**
+ * Variable that expands to the name of a resource's parent (value <code>container_name</code>).
+ */
+ public static final String VAR_CONTAINER_NAME = "container_name"; //$NON-NLS-1$
+
+ /**
+ * Variable that expands to the type of build (value <code>build_type</code>). See
+ * <code>BUILD_TYPE_*</code> constants for possible values.
+ */
+ public static final String VAR_BUILD_TYPE = "build_type"; //$NON-NLS-1$
+
+ /**
+ * Variable that expands to the working set object (value <code>working_set</code>).
+ */
+ public static final String VAR_WORKING_SET = "working_set"; //$NON-NLS-1$
+
+ /**
+ * Variable that expands to the current editor cursor column (value <code>editor_cur_col</code>).
+ */
+ public static final String VAR_EDITOR_CUR_COL = "editor_cur_col"; //$NON-NLS-1$
+
+ /**
+ * Variable that expands to the current editor cursor line (value <code>editor_cur_line</code>).
+ */
+ public static final String VAR_EDITOR_CUR_LINE = "editor_cur_line"; //$NON-NLS-1$
+
+ /**
+ * Variable that expands to the current editor selected text (value <code>editor_sel_text</code>).
+ */
+ public static final String VAR_EDITOR_SEL_TEXT = "editor_sel_text"; //$NON-NLS-1$
+
+
+ // ------- Build Types -------
+ /**
+ * Build type indicating an incremental project build request for
+ * the external tool running as a builder (value <code>incremental</code>).
+ */
+ public static final String BUILD_TYPE_INCREMENTAL = "incremental"; //$NON-NLS-1$
+
+ /**
+ * Build type indicating a full project build request for
+ * the external tool running as a builder (value <code>full</code>).
+ */
+ public static final String BUILD_TYPE_FULL = "full"; //$NON-NLS-1$
+
+ /**
+ * Build type indicating an automatic project build request for
+ * the external tool running as a builder (value <code>incremental</code>).
+ */
+ public static final String BUILD_TYPE_AUTO = "auto"; //$NON-NLS-1$
+
+ /**
+ * Build type indicating an no project build request for
+ * the external tool running as a builder (value <code>none</code>).
+ */
+ public static final String BUILD_TYPE_NONE = "none"; //$NON-NLS-1$
+}
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/model/IExternalToolFilter.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/model/IExternalToolFilter.java
new file mode 100644
index 000000000..5ec00651f
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/model/IExternalToolFilter.java
@@ -0,0 +1,34 @@
+package org.eclipse.ui.externaltools.model;
+
+/**********************************************************************
+Copyright (c) 2002 IBM Corp. and others. All rights reserved.
+This file is 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:
+**********************************************************************/
+
+import org.eclipse.ui.IActionFilter;
+
+/**
+ * Describes the public attributes for an external tool and the acceptables values
+ * each may have.
+ * <p>
+ * Beside the attributes defined below, all of the extra attribute keys are
+ * also available. Only use extra attribute keys which have been made public
+ * by clients.
+ * </p><p>
+ * This interface is not to be extended or implemented by clients
+ * </p>
+ *
+ * @see IActionFilter
+ */
+public interface IExternalToolFilter extends IActionFilter {
+ /**
+ * An attribute indicating the external tool type (value <code>"type"</code>).
+ * The attribute value should match one of the external tool types defined in
+ * the external tool's type extension point.
+ */
+ public static final String TYPE = "type"; //$NON-NLS-1$
+}
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/model/IExternalToolRunner.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/model/IExternalToolRunner.java
new file mode 100644
index 000000000..5014e0f4d
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/model/IExternalToolRunner.java
@@ -0,0 +1,38 @@
+package org.eclipse.ui.externaltools.model;
+
+/**********************************************************************
+Copyright (c) 2002 IBM Corp. and others. All rights reserved.
+This file is 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:
+**********************************************************************/
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.MultiStatus;
+
+/**
+ * The implementation of this interface is responsible for running
+ * an external tool within the specified context.
+ * <p>
+ * Clients using the extension point to define a new external
+ * tool type must provide an implementation of this interface.
+ * </p><p>
+ * The implementation of this interface will be treated like
+ * a singleton. That is, only one instance will be created
+ * per tool type.
+ * </p><p>
+ * This interface is not intended to be extended by clients.
+ * </p>
+ */
+public interface IExternalToolRunner {
+ /**
+ * Runs an external tool using the specified context.
+ *
+ * @param monitor the monitor to report progress or cancellation to
+ * @param runnerContext the context representing the tool to run
+ * @param status a multi status to report any problems while running tool
+ */
+ public void run(IProgressMonitor monitor, IRunnerContext runnerContext, MultiStatus status);
+}
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/model/IRunnerContext.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/model/IRunnerContext.java
new file mode 100644
index 000000000..1b12e298c
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/model/IRunnerContext.java
@@ -0,0 +1,67 @@
+package org.eclipse.ui.externaltools.model;
+
+/**********************************************************************
+Copyright (c) 2002 IBM Corp. and others. All rights reserved.
+This file is 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:
+**********************************************************************/
+
+/**
+ * Represents the context of the external tool to run. An implementation
+ * of this interface is provided to the <code>IExternalToolRunner</code>.
+ * <p>
+ * This interface is not be extended nor implemented by clients.
+ * </p>
+ */
+public interface IRunnerContext {
+ /**
+ * Returns whether the external tool runner should capture
+ * output messages from the running tool and log these
+ * messages.
+ */
+ public boolean getCaptureOutput();
+
+ /**
+ * Returns the arguments for the external tool. All
+ * variables embedded in the arguments have been fully
+ * expanded.
+ */
+ public String[] getExpandedArguments();
+
+ /**
+ * Returns the path where the external tool is located. All
+ * variables embedded in the path have been fully
+ * expanded.
+ */
+ public String getExpandedLocation();
+
+ /**
+ * Returns the working directory to run the external tool in.
+ * All variables embedded in the path have been fully
+ * expanded.
+ */
+ public String getExpandedWorkingDirectory();
+
+ /**
+ * Returns the extra attribute value of the external tool.
+ *
+ * @param key the unique attribute name
+ * @return the value of the attribute, or <code>null</code>
+ * if not such attribute name.
+ */
+ public String getExtraAttribute(String key);
+
+ /**
+ * Returns the log the runner can used to log
+ * messages captured from the running tool's output.
+ */
+ public IRunnerLog getLog();
+
+ /**
+ * Returns the name of the external tool.
+ */
+ public String getName();
+}
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/model/IRunnerLog.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/model/IRunnerLog.java
new file mode 100644
index 000000000..4245d2d66
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/model/IRunnerLog.java
@@ -0,0 +1,43 @@
+package org.eclipse.ui.externaltools.model;
+
+/**********************************************************************
+Copyright (c) 2002 IBM Corp. and others. All rights reserved.
+This file is 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:
+**********************************************************************/
+
+/**
+ * Provides an API for <code>IExternalToolRunner</code> implementors
+ * to log messages captured from the running tool's output.
+ * <p>
+ * This interface is not be extended nor implemented by clients.
+ * </p>
+ */
+public interface IRunnerLog {
+ public static final int LEVEL_ERROR = 0;
+ public static final int LEVEL_WARNING = 10;
+ public static final int LEVEL_INFO = 20;
+ public static final int LEVEL_VERBOSE = 30;
+ public static final int LEVEL_DEBUG = 40;
+
+ /**
+ * Places the specified message text into the log. Ignored
+ * if the specified message level is higher than the
+ * current filter level.
+ *
+ * @param message the text to add to the log
+ * @param level the message priority
+ */
+ public void append(String message, int level);
+
+ /**
+ * Returns the current level used for filtering
+ * messages. Any calls to <code>append</code> with
+ * a level greater than this filter value will be
+ * ignored.
+ */
+ public int getFilterLevel();
+}
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/model/IStorageListener.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/model/IStorageListener.java
new file mode 100644
index 000000000..84c502b76
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/model/IStorageListener.java
@@ -0,0 +1,50 @@
+package org.eclipse.ui.externaltools.model;
+
+/**********************************************************************
+Copyright (c) 2002 IBM Corp. and others. All rights reserved.
+This file is 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:
+**********************************************************************/
+
+/**
+ * Defines the changes within the external tool storage that
+ * a listeners can be notified of.
+ * <p>
+ * This interface is not to be extended by clients, but can be
+ * implemented by clients.
+ * </p>
+ */
+public interface IStorageListener {
+ /**
+ * Notifies this listener that an external tool has
+ * been removed from the registry and storage.
+ *
+ * @param tool the external tool that was removed
+ */
+ public void toolDeleted(ExternalTool tool);
+
+ /**
+ * Notifies this listener that a new external tool has
+ * been added to the registry and storage.
+ *
+ * @param tool the external tool that was created
+ */
+ public void toolCreated(ExternalTool tool);
+
+ /**
+ * Notifies this listener that an existing external tool
+ * in the registry has been modified and saved to storage.
+ *
+ * @param tool the external tool that was modified
+ */
+ public void toolModified(ExternalTool tool);
+
+ /**
+ * Notifies this listener that the entire external tool
+ * registry was refreshed from storage.
+ */
+ public void toolsRefreshed();
+}
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/model/ToolUtil.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/model/ToolUtil.java
new file mode 100644
index 000000000..fbb883868
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/model/ToolUtil.java
@@ -0,0 +1,450 @@
+package org.eclipse.ui.externaltools.model;
+
+/**********************************************************************
+Copyright (c) 2002 IBM Corp. and others. All rights reserved.
+This file is 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:
+**********************************************************************/
+
+import java.util.ArrayList;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.MultiStatus;
+import org.eclipse.ui.externaltools.internal.model.ExternalToolsPlugin;
+import org.eclipse.ui.externaltools.internal.model.ToolMessages;
+import org.eclipse.ui.externaltools.internal.registry.ArgumentVariable;
+import org.eclipse.ui.externaltools.internal.registry.ArgumentVariableRegistry;
+import org.eclipse.ui.externaltools.internal.registry.PathLocationVariable;
+import org.eclipse.ui.externaltools.internal.registry.PathLocationVariableRegistry;
+import org.eclipse.ui.externaltools.variable.ExpandVariableContext;
+
+/**
+ * General utility class dealing with external tools
+ */
+public final class ToolUtil {
+ /**
+ * Argument parsing constants
+ */
+ private static final char ARG_DELIMITER = ' '; //$NON-NLS-1$
+ private static final char ARG_DBL_QUOTE = '"'; //$NON-NLS-1$
+
+ /**
+ * Variable tag indentifiers
+ */
+ private static final char VAR_TAG_START_CHAR1 = '$'; //$NON-NLS-1$
+ private static final char VAR_TAG_START_CHAR2 = '{'; //$NON-NLS-1$
+ private static final char VAR_TAG_END_CHAR1 = '}'; //$NON-NLS-1$
+ private static final String VAR_TAG_START = "${"; //$NON-NLS-1$
+ private static final String VAR_TAG_END = "}"; //$NON-NLS-1$
+ private static final String VAR_TAG_SEP = ":"; //$NON-NLS-1$
+
+ /**
+ * No instances allowed
+ */
+ private ToolUtil() {
+ super();
+ }
+
+ /**
+ * Builds a variable tag that will be auto-expanded before
+ * the tool is run.
+ *
+ * @param varName the name of a known variable (one of the VAR_* constants for instance)
+ * @param varArgument an optional argument for the variable, <code>null</code> if none
+ */
+ public static String buildVariableTag(String varName, String varArgument) {
+ StringBuffer buf = new StringBuffer();
+ buildVariableTag(varName,varArgument, buf);
+ return buf.toString();
+ }
+
+ /**
+ * Builds a variable tag that will be auto-expanded before
+ * the tool is run.
+ *
+ * @param varName the name of a known variable (one of the VAR_* constants for instance)
+ * @param varArgument an optional argument for the variable, <code>null</code> if none
+ * @param buffer the buffer to write the constructed variable tag
+ */
+ public static void buildVariableTag(String varName, String varArgument, StringBuffer buffer) {
+ buffer.append(VAR_TAG_START);
+ buffer.append(varName);
+ if (varArgument != null && varArgument.length() > 0) {
+ buffer.append(VAR_TAG_SEP);
+ buffer.append(varArgument);
+ }
+ buffer.append(VAR_TAG_END);
+ }
+
+ /**
+ * Expands all the variables found in an individual
+ * argument text.
+ *
+ * @param argument one of the argument text in the list of arguments
+ * @param context the context to use for expanding variables
+ * @param status multi status to report any problems expanding variables
+ * @return the argument text with all variables expanded, or <code>null</code> if not possible
+ */
+ public static String expandArgument(String argument, ExpandVariableContext context, MultiStatus status) {
+ StringBuffer buffer = new StringBuffer();
+
+ int start = 0;
+ while (true) {
+ VariableDefinition varDef = extractVariableTag(argument, start);
+
+ // No more variables found...
+ if (varDef.start == -1) {
+ if (start == 0)
+ buffer.append(argument);
+ else
+ buffer.append(argument.substring(start));
+ break;
+ }
+
+ // Invalid variable format
+ if (varDef.end == -1 || varDef.name == null || varDef.name.length() == 0) {
+ String msg = ToolMessages.getString("ToolUtil.argumentVarFormatWrong"); //$NON-NLS-1$
+ status.merge(ExternalToolsPlugin.newErrorStatus(msg, null));
+ return null;
+ }
+
+ // Copy text between start and variable.
+ if (varDef.start > start)
+ buffer.append(argument.substring(start, varDef.start));
+ start = varDef.end;
+
+ // Lookup the variable if it exist
+ ArgumentVariableRegistry registry;
+ registry = ExternalToolsPlugin.getDefault().getArgumentVariableRegistry();
+ ArgumentVariable variable = registry.getArgumentVariable(varDef.name);
+ if (variable == null) {
+ String msg = ToolMessages.format("ToolUtil.argumentVarMissing", new Object[] {varDef.name}); //$NON-NLS-1$
+ status.merge(ExternalToolsPlugin.newErrorStatus(msg, null));
+ return null;
+ }
+
+ // Expand the variable as text if possible
+ String text = variable.getExpander().getText(varDef.name, varDef.argument, context);
+ if (text == null) {
+ String msg = ToolMessages.format("ToolUtil.argumentVarExpandFailed", new Object[] {varDef.name}); //$NON-NLS-1$
+ status.merge(ExternalToolsPlugin.newErrorStatus(msg, null));
+ return null;
+ }
+ buffer.append(text);
+ }
+
+ return buffer.toString();
+ }
+
+ /**
+ * Returns a list of individual arguments where all
+ * variables have been expanded.
+ *
+ * @param arguments the arguments with leading and trailing
+ * spaces already removed.
+ * @param context the context used to expand the variable(s)
+ * @param status multi status to report any problems expanding variables
+ * @return the list of individual arguments where some elements in the
+ * list maybe <code>null</code> if problems expanding variable(s).
+ */
+ public static String[] expandArguments(String arguments, ExpandVariableContext context, MultiStatus status) {
+ if (arguments == null || arguments.length() == 0)
+ return new String[0];
+
+ String[] argList = parseArgumentsIntoList(arguments);
+ for (int i = 0; i < argList.length; i++)
+ argList[i] = expandArgument(argList[i], context, status);
+
+ return argList;
+ }
+
+ /**
+ * Returns the expanded directory location if represented by a
+ * directory variable. Otherwise, the directory location given is
+ * return unless an unknown variable was detected.
+ *
+ * @param dirLocation a directory location either as a path or a variable
+ * with leading and trailing spaces already removed.
+ * @param context the context used to expand the variable
+ * @param status multi status to report any problems expanding variables
+ * @return the directory location as a string or <code>null</code> if not possible
+ */
+ public static String expandDirectoryLocation(String dirLocation, ExpandVariableContext context, MultiStatus status) {
+ if (dirLocation == null || dirLocation.length() == 0)
+ return ""; //$NON-NLS-1$
+
+ VariableDefinition varDef = extractVariableTag(dirLocation, 0);
+ // Return if no variable found
+ if (varDef.start < 0)
+ return dirLocation;
+
+ // Disallow text before/after variable
+ if (varDef.start != 0 || (varDef.end < dirLocation.length() && varDef.end != -1)) {
+ String msg = ToolMessages.getString("ToolUtil.dirLocVarBetweenText"); //$NON-NLS-1$
+ status.merge(ExternalToolsPlugin.newErrorStatus(msg, null));
+ return null;
+ }
+
+ // Invalid variable format
+ if (varDef.name == null || varDef.name.length() == 0 || varDef.end == -1) {
+ String msg = ToolMessages.getString("ToolUtil.dirLocVarFormatWrong"); //$NON-NLS-1$
+ status.merge(ExternalToolsPlugin.newErrorStatus(msg, null));
+ return null;
+ }
+
+ // Lookup the variable if it exist
+ PathLocationVariableRegistry registry;
+ registry = ExternalToolsPlugin.getDefault().getDirectoryLocationVariableRegistry();
+ PathLocationVariable variable = registry.getPathLocationVariable(varDef.name);
+ if (variable == null) {
+ String msg = ToolMessages.format("ToolUtil.dirLocVarMissing", new Object[] {varDef.name}); //$NON-NLS-1$
+ status.merge(ExternalToolsPlugin.newErrorStatus(msg, null));
+ return null;
+ }
+
+ // Expand the variable into a IPath if possible
+ IPath path = variable.getExpander().getPath(varDef.name, varDef.argument, context);
+ if (path == null) {
+ String msg = ToolMessages.format("ToolUtil.dirLocVarExpandFailed", new Object[] {varDef.name}); //$NON-NLS-1$
+ status.merge(ExternalToolsPlugin.newErrorStatus(msg, null));
+ return null;
+ }
+
+ return path.toOSString();
+ }
+
+ /**
+ * Returns the expanded file location if represented by a
+ * file variable. Otherwise, the file location given is
+ * return unless an unknown variable was detected.
+ *
+ * @param fileLocation a file location either as a path or a variable
+ * with leading and trailing spaces already removed.
+ * @param context the context used to expand the variable
+ * @param status multi status to report any problems expanding variables
+ * @return the file location as a string or <code>null</code> if not possible
+ */
+ public static String expandFileLocation(String fileLocation, ExpandVariableContext context, MultiStatus status) {
+ if (fileLocation == null || fileLocation.length() == 0)
+ return ""; //$NON-NLS-1$
+
+ VariableDefinition varDef = extractVariableTag(fileLocation, 0);
+ // Return if no variable found
+ if (varDef.start < 0)
+ return fileLocation;
+
+ // Disallow text before/after variable
+ if (varDef.start != 0 || (varDef.end < fileLocation.length() && varDef.end != -1)) {
+ String msg = ToolMessages.getString("ToolUtil.fileLocVarBetweenText"); //$NON-NLS-1$
+ status.merge(ExternalToolsPlugin.newErrorStatus(msg, null));
+ return null;
+ }
+
+ // Invalid variable format
+ if (varDef.name == null || varDef.name.length() == 0 || varDef.end == -1) {
+ String msg = ToolMessages.getString("ToolUtil.fileLocVarFormatWrong"); //$NON-NLS-1$
+ status.merge(ExternalToolsPlugin.newErrorStatus(msg, null));
+ return null;
+ }
+
+ // Lookup the variable if it exist
+ PathLocationVariableRegistry registry;
+ registry = ExternalToolsPlugin.getDefault().getFileLocationVariableRegistry();
+ PathLocationVariable variable = registry.getPathLocationVariable(varDef.name);
+ if (variable == null) {
+ String msg = ToolMessages.format("ToolUtil.fileLocVarMissing", new Object[] {varDef.name}); //$NON-NLS-1$
+ status.merge(ExternalToolsPlugin.newErrorStatus(msg, null));
+ return null;
+ }
+
+ // Expand the variable into a IPath if possible
+ IPath path = variable.getExpander().getPath(varDef.name, varDef.argument, context);
+ if (path == null) {
+ String msg = ToolMessages.format("The variable {0} with argument {1} could not be expanded to a valid path.", new Object[] {varDef.name, varDef.argument});
+ status.merge(ExternalToolsPlugin.newErrorStatus(msg, null));
+ return null;
+ }
+
+ return path.toString();
+ }
+
+ /**
+ * Extracts from the source text the variable tag's name
+ * and argument.
+ *
+ * @param text the source text to parse for a variable tag
+ * @param start the index in the string to start the search
+ * @return the variable definition
+ */
+ public static VariableDefinition extractVariableTag(String text, int start) {
+ VariableDefinition varDef = new VariableDefinition();
+
+ varDef.start = text.indexOf(VAR_TAG_START, start);
+ if (varDef.start < 0)
+ return varDef;
+ start = varDef.start + VAR_TAG_START.length();
+
+ int end = text.indexOf(VAR_TAG_END, start);
+ if (end < 0)
+ return varDef;
+ varDef.end = end + VAR_TAG_END.length();
+ if (end == start)
+ return varDef;
+
+ int mid = text.indexOf(VAR_TAG_SEP, start);
+ if (mid < 0 || mid > end) {
+ varDef.name = text.substring(start, end);
+ } else {
+ if (mid > start)
+ varDef.name = text.substring(start, mid);
+ mid = mid + VAR_TAG_SEP.length();
+ if (mid < end)
+ varDef.argument = text.substring(mid, end);
+ }
+
+ return varDef;
+ }
+
+ /**
+ * Parses the argument text into an array of individual
+ * arguments using the space character as the delimiter.
+ * An individual argument containing spaces must have a
+ * double quote (") at the start and end. Two double
+ * quotes together is taken to mean an embedded double
+ * quote in the argument text. Variables are treated as
+ * a single unit and therefore spaces and double quotes
+ * inside a variable are copied as is and not parsed.
+ *
+ * @param arguments the arguments as one string
+ * @return the array of arguments
+ */
+ public static String[] parseArgumentsIntoList(String arguments) {
+ if (arguments == null || arguments.length() == 0)
+ return new String[0];
+
+ ArrayList list = new ArrayList(10);
+ boolean inQuotes = false;
+ boolean inVar = false;
+ int start = 0;
+ int end = arguments.length();
+ StringBuffer buffer = new StringBuffer(end);
+
+ while (start < end) {
+ char ch = arguments.charAt(start);
+ start++;
+
+ switch (ch) {
+ case ARG_DELIMITER :
+ if (inQuotes || inVar) {
+ buffer.append(ch);
+ } else {
+ if (buffer.length() > 0) {
+ list.add(buffer.toString());
+ buffer.setLength(0);
+ }
+ }
+ break;
+
+ case ARG_DBL_QUOTE :
+ if (inVar) {
+ buffer.append(ch);
+ } else {
+ if (start < end) {
+ if (arguments.charAt(start) == ARG_DBL_QUOTE) {
+ // Two quotes together represents one quote
+ buffer.append(ch);
+ start++;
+ } else {
+ inQuotes = !inQuotes;
+ }
+ } else {
+ // A lone quote at the end, just drop it.
+ inQuotes = false;
+ }
+ }
+ break;
+
+ case VAR_TAG_START_CHAR1 :
+ buffer.append(ch);
+ if (!inVar && start < end) {
+ if (arguments.charAt(start) == VAR_TAG_START_CHAR2) {
+ buffer.append(VAR_TAG_START_CHAR2);
+ inVar = true;
+ start++;
+ }
+ }
+ break;
+
+ case VAR_TAG_END_CHAR1 :
+ buffer.append(ch);
+ inVar = false;
+ break;
+
+ default :
+ buffer.append(ch);
+ break;
+ }
+
+ }
+
+ if (buffer.length() > 0)
+ list.add(buffer.toString());
+
+ String[] results = new String[list.size()];
+ list.toArray(results);
+ return results;
+ }
+
+
+ /**
+ * Structure to represent a variable definition within a
+ * source string.
+ */
+ public static final class VariableDefinition {
+ /**
+ * Index in the source text where the variable started
+ * or <code>-1</code> if no valid variable start tag
+ * identifier found.
+ */
+ public int start = -1;
+
+ /**
+ * Index in the source text of the character following
+ * the end of the variable or <code>-1</code> if no
+ * valid variable end tag found.
+ */
+ public int end = -1;
+
+ /**
+ * The variable's name found in the source text, or
+ * <code>null</code> if no valid variable found.
+ */
+ public String name = null;
+
+ /**
+ * The variable's argument found in the source text, or
+ * <code>null</code> if no valid variable found or if
+ * the variable did not specify an argument
+ */
+ public String argument = null;
+
+ /**
+ * Create an initialized variable definition.
+ */
+ private VariableDefinition() {
+ super();
+ }
+
+ /**
+ * Create an initialized variable definition.
+ */
+ private VariableDefinition(int start, int end) {
+ super();
+ this.start = start;
+ this.end = end;
+ }
+ }
+}
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/variable/ExpandVariableContext.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/variable/ExpandVariableContext.java
new file mode 100644
index 000000000..d6f11aa33
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/variable/ExpandVariableContext.java
@@ -0,0 +1,101 @@
+package org.eclipse.ui.externaltools.variable;
+
+/**********************************************************************
+Copyright (c) 2002 IBM Corp. and others. All rights reserved.
+This file is 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:
+**********************************************************************/
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IncrementalProjectBuilder;
+import org.eclipse.ui.externaltools.model.IExternalToolConstants;
+
+/**
+ * Represents the context the external tool is running in
+ * that a variable uses to expand itself.
+ */
+public final class ExpandVariableContext {
+ public static final ExpandVariableContext EMPTY_CONTEXT = new ExpandVariableContext(null);
+
+ private IProject project = null;
+ private IResource selectedResource = null;
+ private String buildType = IExternalToolConstants.BUILD_TYPE_NONE;
+
+ /**
+ * Create a context for an external tool running
+ * as a builder on the given project.
+ *
+ * @param project the <code>IProject</code> being built.
+ * @param buildKind the kind of build being performed
+ * (see <code>IncrementalProjectBuilder</code>).
+ */
+ public ExpandVariableContext(IProject project, int buildKind) {
+ super();
+ this.project = project;
+ switch (buildKind) {
+ case IncrementalProjectBuilder.INCREMENTAL_BUILD :
+ this.buildType = IExternalToolConstants.BUILD_TYPE_INCREMENTAL;
+ break;
+ case IncrementalProjectBuilder.FULL_BUILD :
+ this.buildType = IExternalToolConstants.BUILD_TYPE_FULL;
+ break;
+ case IncrementalProjectBuilder.AUTO_BUILD :
+ this.buildType = IExternalToolConstants.BUILD_TYPE_AUTO;
+ break;
+ default :
+ this.buildType = IExternalToolConstants.BUILD_TYPE_NONE;
+ break;
+ }
+ }
+
+ /**
+ * Create a context for an external tool running
+ * with the given resource selected.
+ *
+ * @param selectedResource the <code>IResource</code> selected
+ * or <code>null</code> if none.
+ */
+ public ExpandVariableContext(IResource selectedResource) {
+ super();
+ if (selectedResource != null) {
+ this.selectedResource = selectedResource;
+ this.project = selectedResource.getProject();
+ }
+ }
+
+ /**
+ * Returns the build type being performed if the
+ * external tool is being run as a project builder.
+ *
+ * @return one of the <code>IExternalToolConstants.BUILD_TYPE_*</code> constants.
+ */
+ public String getBuildType() {
+ return buildType;
+ }
+
+ /**
+ * Returns the project which the variable can use. This
+ * will the the project being built if the tool is being
+ * run as a builder. Otherwise, it is the project of the
+ * selected resource, or <code>null</code> if none.
+ *
+ * @return the <code>IProject</code> or <code>null</code> if none
+ */
+ public IProject getProject() {
+ return project;
+ }
+
+ /**
+ * Returns the resource selected at the time the tool
+ * is run, or <code>null</code> if none selected.
+ *
+ * @return the <code>IResource</code> selected, or <code>null</code> if none
+ */
+ public IResource getSelectedResource() {
+ return selectedResource;
+ }
+}
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/variable/IVariableComponent.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/variable/IVariableComponent.java
new file mode 100644
index 000000000..13a5e3150
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/variable/IVariableComponent.java
@@ -0,0 +1,76 @@
+package org.eclipse.ui.externaltools.variable;
+
+/**********************************************************************
+Copyright (c) 2002 IBM Corp. and others. All rights reserved.
+This file is 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:
+**********************************************************************/
+
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.externaltools.group.IGroupDialogPage;
+
+/**
+ * Represents the API for a client extending one of the
+ * variable extension points to provide visual editing
+ * of the variable.
+ * <p>
+ * This interface is not to be extended by clients. Clients
+ * may implement this interface.
+ * </p>
+ */
+public interface IVariableComponent {
+ /**
+ * Returns the control to edit the variable
+ * value, otherwise <code>null</code> if no editing
+ * supported or if <code>createContents</code> has
+ * not been called yet
+ *
+ * @return the main control for the variable component
+ * or <code>null</code> if none
+ */
+ public Control getControl();
+
+ /**
+ * Creates the control to edit the variable. Does nothing
+ * if no editing supported.
+ *
+ * @param parent the composite to parent all controls to
+ * @param varTag the variable tag name to create the controls for
+ * @param page the dialog page this visual component will be part of
+ */
+ public void createContents(Composite parent, String varTag, IGroupDialogPage page);
+
+ /**
+ * Returns the variable value as specified by
+ * the user thru the visual component.
+ *
+ * @return the variable value as indicated by the visual component
+ */
+ public String getVariableValue();
+
+ /**
+ * Returns whether the variable's visual component has an
+ * acceptable value.
+ *
+ * @return <code>true</code> if all value acceptable, or <code>false</code> otherwise
+ */
+ public boolean isValid();
+
+ /**
+ * Sets the visual component to represent the
+ * given variable value.
+ *
+ * @param varValue the variable value the visual component should indicate
+ */
+ public void setVariableValue(String varValue);
+
+ /**
+ * Validates visual component current values entered by the
+ * user and updates it's valid state if needed
+ */
+ public void validate();
+}
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/variable/IVariableLocationExpander.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/variable/IVariableLocationExpander.java
new file mode 100644
index 000000000..d816f5b4f
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/variable/IVariableLocationExpander.java
@@ -0,0 +1,39 @@
+package org.eclipse.ui.externaltools.variable;
+
+/**********************************************************************
+Copyright (c) 2002 IBM Corp. and others. All rights reserved.
+This file is 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:
+**********************************************************************/
+
+import org.eclipse.core.runtime.IPath;
+
+/**
+ * Responsible for expanding a variable into the location
+ * path of a file or directory.
+ * <p>
+ * Implementation of this interface will be treated like
+ * a singleton. That is, only one instance will be created
+ * per variable extension.
+ * </p><p>
+ * This interface is not to be extended by clients. Clients
+ * may implement this interface.
+ * </p>
+ */
+public interface IVariableLocationExpander {
+ /**
+ * Returns the path location to a file or directory
+ * for the given variable tag and value. The path does
+ * not need to exist.
+ *
+ * @param varTag the variable tag name
+ * @param varValue the value for the variable
+ * @param context the context the variable should use to expand itself
+ * @return the <code>IPath</code> to a file/directory
+ * or <code>null</code> if not possible
+ */
+ public IPath getPath(String varTag, String varValue, ExpandVariableContext context);
+}
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/variable/IVariableResourceExpander.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/variable/IVariableResourceExpander.java
new file mode 100644
index 000000000..a2b79ce6c
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/variable/IVariableResourceExpander.java
@@ -0,0 +1,38 @@
+package org.eclipse.ui.externaltools.variable;
+
+/**********************************************************************
+Copyright (c) 2002 IBM Corp. and others. All rights reserved.
+This file is 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:
+**********************************************************************/
+
+import org.eclipse.core.resources.IResource;
+
+/**
+ * Responsible for expanding a variable into a list of
+ * <code>IResource</code>.
+ * <p>
+ * Implementation of this interface will be treated like
+ * a singleton. That is, only one instance will be created
+ * per variable extension.
+ * </p><p>
+ * This interface is not to be extended by clients. Clients
+ * may implement this interface.
+ * </p>
+ */
+public interface IVariableResourceExpander {
+ /**
+ * Returns the <code>IResource</code> list
+ * for the given variable tag and value.
+ *
+ * @param varTag the variable tag name
+ * @param varValue the value for the variable
+ * @param context the context the variable should use to expand itself
+ * @return the list of <code>IResource</code> or <code>null</code> if not
+ * possible (note, elements of the list can be <code>null</code>)
+ */
+ public IResource[] getResources(String varTag, String varValue, ExpandVariableContext context);
+}
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/variable/IVariableTextExpander.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/variable/IVariableTextExpander.java
new file mode 100644
index 000000000..59c4512fd
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/variable/IVariableTextExpander.java
@@ -0,0 +1,35 @@
+package org.eclipse.ui.externaltools.variable;
+
+/**********************************************************************
+Copyright (c) 2002 IBM Corp. and others. All rights reserved.
+This file is 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:
+**********************************************************************/
+
+/**
+ * Responsible for expanding a variable into text format.
+ * <p>
+ * Implementation of this interface will be treated like
+ * a singleton. That is, only one instance will be created
+ * per variable extension.
+ * </p><p>
+ * This interface is not to be extended by clients. Clients
+ * may implement this interface.
+ * </p>
+ */
+public interface IVariableTextExpander {
+ /**
+ * Returns the expanded text for the given variable
+ * tag and value.
+ *
+ * @param varTag the variable tag name
+ * @param varValue the value for the variable
+ * @param context the context the variable should use to expand itself
+ * @return the text of the expanded variable
+ * or <code>null</code> if not possible
+ */
+ public String getText(String varTag, String varValue, ExpandVariableContext context);
+}
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/variable/ResourceComponent.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/variable/ResourceComponent.java
new file mode 100644
index 000000000..9f97e8fb2
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/variable/ResourceComponent.java
@@ -0,0 +1,260 @@
+package org.eclipse.ui.externaltools.variable;
+
+/**********************************************************************
+Copyright (c) 2002 IBM Corp. and others. All rights reserved.
+This file is 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:
+**********************************************************************/
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.jface.dialogs.IMessageProvider;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.ui.externaltools.group.IGroupDialogPage;
+import org.eclipse.ui.externaltools.internal.model.ToolMessages;
+import org.eclipse.ui.externaltools.model.ToolUtil;
+import org.eclipse.ui.model.WorkbenchContentProvider;
+import org.eclipse.ui.model.WorkbenchLabelProvider;
+
+/**
+ * Visual component to edit the resource type variable
+ * value.
+ * <p>
+ * This class is not intended to be extended by clients.
+ * </p>
+ */
+public class ResourceComponent implements IVariableComponent {
+ private IGroupDialogPage page;
+ private boolean isValid = true;
+
+ protected Group mainGroup;
+ protected Button selectedResourceButton;
+ protected Button specificResourceButton;
+ protected TreeViewer resourceList;
+
+ /**
+ * Creates the component
+ */
+ public ResourceComponent() {
+ super();
+ }
+
+ /* (non-Javadoc)
+ * Method declared on IVariableComponent.
+ */
+ public void createContents(Composite parent, String varTag, IGroupDialogPage page) {
+ this.page = page;
+
+ // main composite
+ mainGroup = new Group(parent, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.marginWidth = 0;
+ layout.marginHeight = 0;
+ layout.numColumns = 1;
+ GridData gridData = new GridData(GridData.FILL_BOTH);
+ mainGroup.setLayout(layout);
+ mainGroup.setLayoutData(gridData);
+ mainGroup.setText(ToolUtil.buildVariableTag(varTag, null));
+
+ createSelectedResourceOption();
+ createSpecificResourceOption();
+ createResourceList();
+
+ updateResourceListEnablement();
+ }
+
+ /**
+ * Creates the list of resources.
+ */
+ protected void createResourceList() {
+ Tree tree = new Tree(mainGroup, SWT.SINGLE | SWT.BORDER);
+ GridData data = new GridData(GridData.FILL_BOTH);
+ data.heightHint = tree.getItemHeight() * getInitialVisibleItemCount();
+ tree.setLayoutData(data);
+
+ resourceList = new TreeViewer(tree);
+ resourceList.addSelectionChangedListener(new ISelectionChangedListener() {
+ public void selectionChanged(SelectionChangedEvent event) {
+ validateResourceListSelection();
+ }
+ });
+ resourceList.setContentProvider(new WorkbenchContentProvider());
+ resourceList.setLabelProvider(new WorkbenchLabelProvider());
+ resourceList.setInput(ResourcesPlugin.getWorkspace().getRoot());
+ }
+
+ /**
+ * Creates the option button for using the selected
+ * resource.
+ */
+ protected void createSelectedResourceOption() {
+ selectedResourceButton = new Button(mainGroup, SWT.RADIO);
+ selectedResourceButton.setText(ToolMessages.getString("ResourceComponent.selectedResLabel")); //$NON-NLS-1$
+ GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ selectedResourceButton.setLayoutData(data);
+ selectedResourceButton.setSelection(true);
+ }
+
+ /**
+ * Creates the option button for using a specific
+ * resource.
+ */
+ protected void createSpecificResourceOption() {
+ specificResourceButton = new Button(mainGroup, SWT.RADIO);
+ specificResourceButton.setText(ToolMessages.getString("ResourceComponent.specificResLabel")); //$NON-NLS-1$
+ GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ specificResourceButton.setLayoutData(data);
+ specificResourceButton.setSelection(false);
+
+ specificResourceButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ updateResourceListEnablement();
+ }
+ });
+ }
+
+ /* (non-Javadoc)
+ * Method declared on IVariableComponent.
+ */
+ public Control getControl() {
+ return mainGroup;
+ }
+
+ /**
+ * Returns the dialog page this component is part of
+ */
+ protected final IGroupDialogPage getPage() {
+ return page;
+ }
+
+ /* (non-Javadoc)
+ * Method declared on IVariableComponent.
+ */
+ public String getVariableValue() {
+ if (selectedResourceButton != null && selectedResourceButton.getSelection())
+ return null;
+
+ if (resourceList != null) {
+ IStructuredSelection sel = (IStructuredSelection) resourceList.getSelection();
+ IResource resource = (IResource) sel.getFirstElement();
+ if (resource != null)
+ return resource.getFullPath().toString();
+ }
+
+ return null;
+ }
+
+ /**
+ * Returns the number of items to be visible in the
+ * resource list. This will determine the initial height.
+ */
+ protected int getInitialVisibleItemCount() {
+ return 10;
+ }
+
+ /* (non-Javadoc)
+ * Method declared on IVariableComponent.
+ */
+ public boolean isValid() {
+ return isValid;
+ }
+
+ /**
+ * Sets whether the component's values are all valid.
+ * Updates the components's page valid state. No action
+ * taken if new valid state same as current one.
+ *
+ * @param isValid <code>true</code> if all values valid,
+ * <code>false</code> otherwise
+ */
+ protected final void setIsValid(boolean isValid) {
+ if (this.isValid != isValid) {
+ this.isValid = isValid;
+ this.page.updateValidState();
+ }
+ }
+
+ /**
+ * Updates the enablement of the resource list if needed
+ */
+ protected void updateResourceListEnablement() {
+ if (specificResourceButton != null && resourceList != null)
+ resourceList.getTree().setEnabled(specificResourceButton.getSelection());
+ }
+
+ /* (non-Javadoc)
+ * Method declared on IVariableComponent.
+ */
+ public void setVariableValue(String varValue) {
+ if (varValue == null || varValue.length() == 0) {
+ if (selectedResourceButton != null)
+ selectedResourceButton.setSelection(true);
+ if (specificResourceButton != null)
+ specificResourceButton.setSelection(false);
+ if (resourceList != null)
+ resourceList.getTree().setEnabled(false);
+ } else {
+ if (selectedResourceButton != null)
+ selectedResourceButton.setSelection(false);
+ if (specificResourceButton != null)
+ specificResourceButton.setSelection(true);
+ if (resourceList != null) {
+ resourceList.getTree().setEnabled(true);
+ IResource member = ResourcesPlugin.getWorkspace().getRoot().findMember(varValue);
+ if (member != null)
+ resourceList.setSelection(new StructuredSelection(member), true);
+ else
+ resourceList.setSelection(StructuredSelection.EMPTY);
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * Method declared on IVariableComponent.
+ */
+ public void validate() {
+ if (specificResourceButton != null && specificResourceButton.getSelection()) {
+ validateResourceListSelection();
+ }
+
+ getPage().setMessage(null, IMessageProvider.NONE);
+ setIsValid(true);
+ }
+
+ /**
+ * Returns whether that the resource list selection is valid.
+ * If the list was not created, returns <code>true</code>.
+ *
+ * @return <code>true</code> to continue validating other
+ * fields, <code>false</code> to stop.
+ */
+ protected boolean validateResourceListSelection() {
+ if (resourceList == null)
+ return true;
+
+ if (resourceList.getSelection().isEmpty()) {
+ getPage().setMessage(ToolMessages.getString("ResourceComponent.selectionRequired"), IMessageProvider.WARNING); //$NON-NLS-1$
+ setIsValid(false);
+ return false;
+ }
+
+ return true;
+ }
+}
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/variable/ResourceContainerExpander.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/variable/ResourceContainerExpander.java
new file mode 100644
index 000000000..b125ed6a2
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/variable/ResourceContainerExpander.java
@@ -0,0 +1,40 @@
+package org.eclipse.ui.externaltools.variable;
+
+/**********************************************************************
+Copyright (c) 2002 IBM Corp. and others. All rights reserved.
+This file is 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:
+**********************************************************************/
+
+import org.eclipse.core.resources.IResource;
+
+/**
+ * Expands a resource's container type variable into the desired
+ * result format.
+ * <p>
+ * This class is not intended to be extended by clients.
+ * </p>
+ */
+public class ResourceContainerExpander extends ResourceExpander {
+
+ /**
+ * Create an instance
+ */
+ public ResourceContainerExpander() {
+ super();
+ }
+
+ /* (non-Javadoc)
+ * Method declared on ResourceExpander.
+ */
+ /*package*/ IResource expand(String varValue, ExpandVariableContext context) {
+ IResource resource = super.expand(varValue, context);
+ if (resource != null)
+ return resource.getParent();
+ else
+ return null;
+ }
+}
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/variable/ResourceExpander.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/variable/ResourceExpander.java
new file mode 100644
index 000000000..63c9123be
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/variable/ResourceExpander.java
@@ -0,0 +1,89 @@
+package org.eclipse.ui.externaltools.variable;
+
+/**********************************************************************
+Copyright (c) 2002 IBM Corp. and others. All rights reserved.
+This file is 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:
+**********************************************************************/
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IPath;
+
+/**
+ * Expands a resource type variable into the desired
+ * result format.
+ * <p>
+ * This class is not intended to be extended by clients.
+ * </p>
+ */
+public class ResourceExpander implements IVariableLocationExpander, IVariableResourceExpander {
+
+ /**
+ * Create an instance
+ */
+ public ResourceExpander() {
+ super();
+ }
+
+ /**
+ * Expands the variable to a resource.
+ */
+ /*package*/ IResource expand(String varValue, ExpandVariableContext context) {
+ if (varValue != null && varValue.length() > 0)
+ return expandToMember(varValue);
+ else
+ return expandUsingContext(context);
+ }
+
+ /**
+ * Expands using the current context information.
+ * By default, return the selected resource of the
+ * context.
+ */
+ /*package*/ IResource expandUsingContext(ExpandVariableContext context) {
+ return context.getSelectedResource();
+ }
+
+ /**
+ * Expands the variable value to a resource. The value
+ * will not be <code>null</code> nor empty. By default,
+ * lookup the member from the workspace root.
+ */
+ /*package*/ IResource expandToMember(String varValue) {
+ return getWorkspaceRoot().findMember(varValue);
+ }
+
+ /* (non-Javadoc)
+ * Method declared on IVariableLocationExpander.
+ */
+ public IPath getPath(String varTag, String varValue, ExpandVariableContext context) {
+ IResource resource = expand(varValue, context);
+ if (resource != null)
+ return resource.getLocation();
+ else
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * Method declared on IVariableResourceExpander.
+ */
+ public IResource[] getResources(String varTag, String varValue, ExpandVariableContext context) {
+ IResource resource = expand(varValue, context);
+ if (resource != null)
+ return new IResource[] {resource};
+ else
+ return null;
+ }
+
+ /**
+ * Returns the workspace root resource.
+ */
+ protected final IWorkspaceRoot getWorkspaceRoot() {
+ return ResourcesPlugin.getWorkspace().getRoot();
+ }
+}
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/variable/ResourceProjectExpander.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/variable/ResourceProjectExpander.java
new file mode 100644
index 000000000..38d156371
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/variable/ResourceProjectExpander.java
@@ -0,0 +1,47 @@
+package org.eclipse.ui.externaltools.variable;
+
+/**********************************************************************
+Copyright (c) 2002 IBM Corp. and others. All rights reserved.
+This file is 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:
+**********************************************************************/
+
+import org.eclipse.core.resources.IResource;
+
+/**
+ * Expands a resource's project type variable into the desired
+ * result format.
+ * <p>
+ * This class is not intended to be extended by clients.
+ * </p>
+ */
+public class ResourceProjectExpander extends ResourceExpander {
+
+ /**
+ * Create an instance
+ */
+ public ResourceProjectExpander() {
+ super();
+ }
+
+ /* (non-Javadoc)
+ * Method declared on ResourceExpander.
+ */
+ /*package*/ IResource expandUsingContext(ExpandVariableContext context) {
+ return context.getProject();
+ }
+
+ /* (non-Javadoc)
+ * Method declared on ResourceExpander.
+ */
+ /*package*/ IResource expandToMember(String varValue) {
+ IResource member = super.expandToMember(varValue);
+ if (member != null)
+ return member.getProject();
+ else
+ return null;
+ }
+}
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/variable/SpecificFileResourceComponent.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/variable/SpecificFileResourceComponent.java
new file mode 100644
index 000000000..1d385fed5
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/variable/SpecificFileResourceComponent.java
@@ -0,0 +1,71 @@
+package org.eclipse.ui.externaltools.variable;
+
+/**********************************************************************
+Copyright (c) 2002 IBM Corp. and others. All rights reserved.
+This file is 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:
+**********************************************************************/
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.jface.dialogs.IMessageProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.ui.externaltools.internal.model.ToolMessages;
+
+/**
+ * Visual component to edit the resource type variable
+ * value for the file location. Variable is limited to a specific
+ * <code>IFile</code> resource.
+ * <p>
+ * This class is not intended to be extended by clients.
+ * </p>
+ */
+public class SpecificFileResourceComponent extends ResourceComponent {
+
+ /**
+ * Creates an instance
+ */
+ public SpecificFileResourceComponent() {
+ super();
+ }
+
+ /* (non-Javadoc)
+ * Method declared on ResourceComponent.
+ */
+ protected void createSelectedResourceOption() {
+ // Do not present this option...
+ }
+
+ /* (non-Javadoc)
+ * Method declared on ResourceComponent.
+ */
+ protected void createSpecificResourceOption() {
+ Label label = new Label(mainGroup, SWT.NONE);
+ GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ label.setLayoutData(data);
+ label.setText(ToolMessages.getString("ResourceComponent.specificResLabel")); //$NON-NLS-1$
+ }
+
+ /* (non-Javadoc)
+ * Method declared on ResourceComponent.
+ */
+ protected boolean validateResourceListSelection() {
+ if (resourceList == null)
+ return true;
+
+ IStructuredSelection sel = (IStructuredSelection) resourceList.getSelection();
+ IResource resource = (IResource) sel.getFirstElement();
+ if (resource == null || resource.getType() != IResource.FILE) {
+ getPage().setMessage(ToolMessages.getString("ResourceComponent.selectionRequired"), IMessageProvider.WARNING); //$NON-NLS-1$
+ setIsValid(false);
+ return false;
+ }
+
+ return true;
+ }
+}
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/variable/SpecificFolderResourceComponent.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/variable/SpecificFolderResourceComponent.java
new file mode 100644
index 000000000..d2c701612
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/variable/SpecificFolderResourceComponent.java
@@ -0,0 +1,109 @@
+package org.eclipse.ui.externaltools.variable;
+
+/**********************************************************************
+Copyright (c) 2002 IBM Corp. and others. All rights reserved.
+This file is 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:
+**********************************************************************/
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.jface.dialogs.IMessageProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.ui.externaltools.internal.model.ToolMessages;
+
+/**
+ * Visual component to edit the resource type variable
+ * value for the working directory. Variable is limited to a specific
+ * <code>IContainer</code> resource.
+ * <p>
+ * This class is not intended to be extended by clients.
+ * </p>
+ */
+public class SpecificFolderResourceComponent extends ResourceComponent {
+
+ /**
+ * Creates an instance
+ */
+ public SpecificFolderResourceComponent() {
+ super();
+ }
+
+ /* (non-Javadoc)
+ * Method declared on ResourceComponent.
+ */
+ protected void createSelectedResourceOption() {
+ // Do not present this option...
+ }
+
+ /* (non-Javadoc)
+ * Method declared on ResourceComponent.
+ */
+ protected void createResourceList() {
+ super.createResourceList();
+ if (resourceList != null)
+ resourceList.addFilter(new FileFilter());
+ }
+
+ /* (non-Javadoc)
+ * Method declared on ResourceComponent.
+ */
+ protected void createSpecificResourceOption() {
+ Label label = new Label(mainGroup, SWT.NONE);
+ GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ label.setLayoutData(data);
+ label.setText(ToolMessages.getString("ResourceComponent.specificResLabel")); //$NON-NLS-1$
+ }
+
+ /* (non-Javadoc)
+ * Method declared on ResourceComponent.
+ */
+ protected boolean validateResourceListSelection() {
+ if (resourceList == null)
+ return true;
+
+ IStructuredSelection sel = (IStructuredSelection) resourceList.getSelection();
+ IResource resource = (IResource) sel.getFirstElement();
+ if (resource == null || resource.getType() == IResource.FILE) {
+ getPage().setMessage(ToolMessages.getString("ResourceComponent.selectionRequired"), IMessageProvider.WARNING); //$NON-NLS-1$
+ setIsValid(false);
+ return false;
+ }
+
+ return true;
+ }
+
+
+ /**
+ * Filter to remove any IFile resources.
+ */
+ private static final class FileFilter extends ViewerFilter {
+ /* (non-Javadoc)
+ * Method declared on ViewerFilter.
+ */
+ public boolean select(Viewer viewer, Object parentElement, Object element) {
+ IResource resource = null;
+ if (element instanceof IResource) {
+ resource = (IResource) element;
+ } else {
+ if (element instanceof IAdaptable) {
+ IAdaptable adaptable = (IAdaptable) element;
+ resource = (IResource) adaptable.getAdapter(IResource.class);
+ }
+ }
+
+ if (resource != null)
+ return resource.getType() != IResource.FILE;
+ else
+ return false;
+ }
+ }
+}
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/variable/WorkingSetExpander.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/variable/WorkingSetExpander.java
new file mode 100644
index 000000000..4dd97e2e2
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/variable/WorkingSetExpander.java
@@ -0,0 +1,56 @@
+package org.eclipse.ui.externaltools.variable;
+
+/**********************************************************************
+Copyright (c) 2002 IBM Corp. and others. All rights reserved.
+This file is 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:
+**********************************************************************/
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.ui.IWorkingSet;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * Expands a working set type variable into the desired
+ * result format.
+ * <p>
+ * This class is not intended to be extended by clients.
+ * </p>
+ */
+public class WorkingSetExpander implements IVariableResourceExpander {
+
+ /**
+ * Create an instance
+ */
+ public WorkingSetExpander() {
+ super();
+ }
+
+ /* (non-Javadoc)
+ * Method declared on IVariableResourceExpander.
+ */
+ public IResource[] getResources(String varTag, String varValue, ExpandVariableContext context) {
+ if (varValue == null || varValue.length() == 0)
+ return null;
+
+ IWorkingSet set = PlatformUI.getWorkbench().getWorkingSetManager().getWorkingSet(varValue);
+ if (set == null)
+ return null;
+
+ IAdaptable[] elements = set.getElements();
+ IResource[] resources = new IResource[elements.length];
+ for (int i = 0; i < elements.length; i++) {
+ IAdaptable adaptable = elements[i];
+ if (adaptable instanceof IResource)
+ resources[i] = (IResource) adaptable;
+ else
+ resources[i] = (IResource) adaptable.getAdapter(IResource.class);
+ }
+
+ return resources;
+ }
+}
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/variable/WorkspaceExpander.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/variable/WorkspaceExpander.java
new file mode 100644
index 000000000..b199a3eed
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/variable/WorkspaceExpander.java
@@ -0,0 +1,36 @@
+package org.eclipse.ui.externaltools.variable;
+
+/**********************************************************************
+Copyright (c) 2002 IBM Corp. and others. All rights reserved.
+This file is 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:
+**********************************************************************/
+
+import org.eclipse.core.resources.IResource;
+
+/**
+ * Expands a workspace variable into the desired
+ * result format.
+ * <p>
+ * This class is not intended to be extended by clients.
+ * </p>
+ */
+public class WorkspaceExpander extends ResourceExpander {
+
+ /**
+ * Create an instance
+ */
+ public WorkspaceExpander() {
+ super();
+ }
+
+ /* (non-Javadoc)
+ * Method declared on ResourceExpander.
+ */
+ /*package*/ IResource expandUsingContext(ExpandVariableContext context) {
+ return getWorkspaceRoot();
+ }
+}
diff --git a/org.eclipse.ui.externaltools/Program Tools Support/org/eclipse/ui/externaltools/internal/program/dialog/ProgramExternalToolNewWizard.java b/org.eclipse.ui.externaltools/Program Tools Support/org/eclipse/ui/externaltools/internal/program/dialog/ProgramExternalToolNewWizard.java
new file mode 100644
index 000000000..fa170b7c8
--- /dev/null
+++ b/org.eclipse.ui.externaltools/Program Tools Support/org/eclipse/ui/externaltools/internal/program/dialog/ProgramExternalToolNewWizard.java
@@ -0,0 +1,44 @@
+package org.eclipse.ui.externaltools.internal.program.dialog;
+
+/**********************************************************************
+Copyright (c) 2002 IBM Corp. and others. All rights reserved.
+This file is 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:
+**********************************************************************/
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.externaltools.dialog.ExternalToolNewWizard;
+import org.eclipse.ui.externaltools.internal.model.ExternalToolsPlugin;
+import org.eclipse.ui.externaltools.model.IExternalToolConstants;
+
+/**
+ * Wizard that will create a new external tool of type program.
+ */
+public class ProgramExternalToolNewWizard extends ExternalToolNewWizard {
+
+ /**
+ * Creates the wizard for a new external tool
+ */
+ public ProgramExternalToolNewWizard() {
+ super(IExternalToolConstants.TOOL_TYPE_PROGRAM);
+ }
+
+ /* (non-Javadoc)
+ * Method declared on IWizard.
+ */
+ public void addPages() {
+ addMainPage();
+ addOptionPage();
+ addRefreshPage();
+ }
+
+ /* (non-Javadoc)
+ * Method declared on ExternalToolNewWizard.
+ */
+ protected ImageDescriptor getDefaultImageDescriptor() {
+ return ExternalToolsPlugin.getDefault().getImageDescriptor("icons/full/wizban/program_wiz.gif"); //$NON-NLS-1$
+ }
+}
diff --git a/org.eclipse.ui.externaltools/Program Tools Support/org/eclipse/ui/externaltools/internal/program/model/ProgramRunner.java b/org.eclipse.ui.externaltools/Program Tools Support/org/eclipse/ui/externaltools/internal/program/model/ProgramRunner.java
new file mode 100644
index 000000000..c9e6e80a8
--- /dev/null
+++ b/org.eclipse.ui.externaltools/Program Tools Support/org/eclipse/ui/externaltools/internal/program/model/ProgramRunner.java
@@ -0,0 +1,174 @@
+package org.eclipse.ui.externaltools.internal.program.model;
+
+/**********************************************************************
+Copyright (c) 2002 IBM Corp. and others. All rights reserved.
+This file is 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:
+**********************************************************************/
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.MultiStatus;
+import org.eclipse.ui.externaltools.internal.model.ExternalToolsPlugin;
+import org.eclipse.ui.externaltools.internal.model.ToolMessages;
+import org.eclipse.ui.externaltools.model.IExternalToolRunner;
+import org.eclipse.ui.externaltools.model.IRunnerContext;
+import org.eclipse.ui.externaltools.model.IRunnerLog;
+
+/**
+ * Runs all external tools of type program.
+ */
+public final class ProgramRunner implements IExternalToolRunner {
+
+ /**
+ * Creates a program runner
+ */
+ public ProgramRunner() {
+ super();
+ }
+
+ /**
+ * Handles exceptions that may occur while running.
+ */
+ private void handleException(Exception e, MultiStatus status) {
+ String msg = e.getMessage();
+ if (msg == null)
+ msg = ToolMessages.getString("ProgramRunner.internalErrorMessage"); //$NON-NLS-1$;
+ status.merge(ExternalToolsPlugin.newErrorStatus(msg, e));
+ }
+
+ /* (non-Javadoc)
+ * Method declared in IExternalToolsRunner.
+ */
+ public void run(IProgressMonitor monitor, IRunnerContext runnerContext, MultiStatus status) {
+ // Runtime exec requires an array where the first element is
+ // the file to run, and the remaining elements are the
+ // arguments to past along.
+ String[] args = runnerContext.getExpandedArguments();
+ String[] commands = new String[args.length + 1];
+
+ commands[0] = runnerContext.getExpandedLocation();
+ System.arraycopy(args, 0, commands, 1, args.length);
+
+ try {
+ // Determine the working directory to use, if any
+ File workingDirectory = null;
+ if (runnerContext.getExpandedWorkingDirectory().length() > 0)
+ workingDirectory = new File(runnerContext.getExpandedWorkingDirectory());
+
+ startMonitor(monitor, runnerContext, IProgressMonitor.UNKNOWN);
+ if (monitor.isCanceled())
+ return;
+
+ // Print out the command used to run the program.
+ if (IRunnerLog.LEVEL_VERBOSE <= runnerContext.getLog().getFilterLevel()) {
+ runnerContext.getLog().append(
+ ToolMessages.getString("ProgramRunner.callingRuntimeExec"), //$NON-NLS-1$;
+ IRunnerLog.LEVEL_VERBOSE);
+ runnerContext.getLog().append(
+ ToolMessages.format("ProgramRunner.program", new Object[] {commands[0]}), //$NON-NLS-1$;
+ IRunnerLog.LEVEL_VERBOSE);
+ for (int i = 1; i < commands.length; i++) {
+ runnerContext.getLog().append(
+ ToolMessages.format("ProgramRunner.argument", new Object[] {commands[i]}), //$NON-NLS-1$;
+ IRunnerLog.LEVEL_VERBOSE);
+ }
+ if (workingDirectory != null) {
+ runnerContext.getLog().append(
+ ToolMessages.format("ProgramRunner.workDir", new Object[] {workingDirectory.toString()}), //$NON-NLS-1$;
+ IRunnerLog.LEVEL_VERBOSE);
+ }
+ }
+
+ // Run the program
+ boolean[] finished = new boolean[] {false};
+ Process p;
+ if (workingDirectory != null)
+ p = Runtime.getRuntime().exec(commands, null, workingDirectory);
+ else
+ p = Runtime.getRuntime().exec(commands);
+
+ // Collect the program's output in the background
+ if (runnerContext.getCaptureOutput()) {
+ startThread(
+ p.getInputStream(),
+ runnerContext.getLog(),
+ IRunnerLog.LEVEL_INFO,
+ finished);
+ startThread(
+ p.getErrorStream(),
+ runnerContext.getLog(),
+ IRunnerLog.LEVEL_ERROR,
+ finished);
+ }
+
+ if (monitor.isCanceled()) {
+ p.destroy();
+ } else {
+ p.waitFor();
+
+ // Sleep to allow the two new threads to begin reading
+ // the program-running process's input and error streams
+ // before finished[0] is set to true. This is especially
+ // necessary with short programs that execute quickly. If
+ // finished[0] is set to true before the threads run,
+ // nothing will be read from the input and error streams.
+ Thread.sleep(300);
+ }
+
+ finished[0] = true;
+ } catch (IOException e) {
+ handleException(e, status);
+ } catch (InterruptedException e) {
+ handleException(e, status);
+ } finally {
+ monitor.done();
+ }
+ }
+
+ /**
+ * Starts a thread to capture the specified stream contents
+ * and log it.
+ */
+ private void startThread(final InputStream input, final IRunnerLog log, final int level, final boolean[] finished) {
+ Thread t = new Thread(new Runnable() {
+ public void run() {
+ try {
+ StringBuffer sb;
+ while (!finished[0]) {
+ sb = new StringBuffer();
+ int c = input.read();
+ while (c != -1) {
+ sb.append((char)c);
+ c = input.read();
+ }
+ log.append(sb.toString(), level);
+ try {
+ Thread.sleep(100);
+ } catch (InterruptedException e) {
+ }
+ }
+ input.close();
+ } catch (IOException e) {
+ e.printStackTrace(System.out);
+ }
+ }
+ });
+
+ t.start();
+ }
+
+ /**
+ * Starts the monitor to show progress while running.
+ */
+ private void startMonitor(IProgressMonitor monitor, IRunnerContext runnerContext, int workAmount) {
+ String label = ToolMessages.format("ProgramRunner.runningToolLabel", new Object[] {runnerContext.getName()}); //$NON-NLS-1$;
+ monitor.beginTask(label, workAmount);
+ }
+}
diff --git a/org.eclipse.ui.externaltools/icons/full/clcl16/copy_tool.gif b/org.eclipse.ui.externaltools/icons/full/clcl16/copy_tool.gif
new file mode 100644
index 000000000..4274b070a
--- /dev/null
+++ b/org.eclipse.ui.externaltools/icons/full/clcl16/copy_tool.gif
Binary files differ
diff --git a/org.eclipse.ui.externaltools/icons/full/clcl16/del_tool.gif b/org.eclipse.ui.externaltools/icons/full/clcl16/del_tool.gif
new file mode 100644
index 000000000..6f647666d
--- /dev/null
+++ b/org.eclipse.ui.externaltools/icons/full/clcl16/del_tool.gif
Binary files differ
diff --git a/org.eclipse.ui.externaltools/icons/full/clcl16/new_tool.gif b/org.eclipse.ui.externaltools/icons/full/clcl16/new_tool.gif
new file mode 100644
index 000000000..dad726088
--- /dev/null
+++ b/org.eclipse.ui.externaltools/icons/full/clcl16/new_tool.gif
Binary files differ
diff --git a/org.eclipse.ui.externaltools/icons/full/clcl16/paste_tool.gif b/org.eclipse.ui.externaltools/icons/full/clcl16/paste_tool.gif
new file mode 100644
index 000000000..75e0ab235
--- /dev/null
+++ b/org.eclipse.ui.externaltools/icons/full/clcl16/paste_tool.gif
Binary files differ
diff --git a/org.eclipse.ui.externaltools/icons/full/clcl16/prop_tool.gif b/org.eclipse.ui.externaltools/icons/full/clcl16/prop_tool.gif
new file mode 100644
index 000000000..ec0cba1aa
--- /dev/null
+++ b/org.eclipse.ui.externaltools/icons/full/clcl16/prop_tool.gif
Binary files differ
diff --git a/org.eclipse.ui.externaltools/icons/full/clcl16/refresh.gif b/org.eclipse.ui.externaltools/icons/full/clcl16/refresh.gif
new file mode 100644
index 000000000..a063c230a
--- /dev/null
+++ b/org.eclipse.ui.externaltools/icons/full/clcl16/refresh.gif
Binary files differ
diff --git a/org.eclipse.ui.externaltools/icons/full/clcl16/rename_tool.gif b/org.eclipse.ui.externaltools/icons/full/clcl16/rename_tool.gif
new file mode 100644
index 000000000..25b1325e5
--- /dev/null
+++ b/org.eclipse.ui.externaltools/icons/full/clcl16/rename_tool.gif
Binary files differ
diff --git a/org.eclipse.ui.externaltools/icons/full/clcl16/run_tool.gif b/org.eclipse.ui.externaltools/icons/full/clcl16/run_tool.gif
new file mode 100644
index 000000000..2088548a4
--- /dev/null
+++ b/org.eclipse.ui.externaltools/icons/full/clcl16/run_tool.gif
Binary files differ
diff --git a/org.eclipse.ui.externaltools/icons/full/clcl16/runwith_tool.gif b/org.eclipse.ui.externaltools/icons/full/clcl16/runwith_tool.gif
new file mode 100644
index 000000000..2088548a4
--- /dev/null
+++ b/org.eclipse.ui.externaltools/icons/full/clcl16/runwith_tool.gif
Binary files differ
diff --git a/org.eclipse.ui.externaltools/icons/full/cview16/external_tools.gif b/org.eclipse.ui.externaltools/icons/full/cview16/external_tools.gif
new file mode 100644
index 000000000..2133b4582
--- /dev/null
+++ b/org.eclipse.ui.externaltools/icons/full/cview16/external_tools.gif
Binary files differ
diff --git a/org.eclipse.ui.externaltools/icons/full/dlcl16/copy_tool.gif b/org.eclipse.ui.externaltools/icons/full/dlcl16/copy_tool.gif
new file mode 100644
index 000000000..c7a98e852
--- /dev/null
+++ b/org.eclipse.ui.externaltools/icons/full/dlcl16/copy_tool.gif
Binary files differ
diff --git a/org.eclipse.ui.externaltools/icons/full/dlcl16/del_tool.gif b/org.eclipse.ui.externaltools/icons/full/dlcl16/del_tool.gif
new file mode 100644
index 000000000..a6bfcfd98
--- /dev/null
+++ b/org.eclipse.ui.externaltools/icons/full/dlcl16/del_tool.gif
Binary files differ
diff --git a/org.eclipse.ui.externaltools/icons/full/dlcl16/new_tool.gif b/org.eclipse.ui.externaltools/icons/full/dlcl16/new_tool.gif
new file mode 100644
index 000000000..813cb2f7b
--- /dev/null
+++ b/org.eclipse.ui.externaltools/icons/full/dlcl16/new_tool.gif
Binary files differ
diff --git a/org.eclipse.ui.externaltools/icons/full/dlcl16/paste_tool.gif b/org.eclipse.ui.externaltools/icons/full/dlcl16/paste_tool.gif
new file mode 100644
index 000000000..0dd5d216d
--- /dev/null
+++ b/org.eclipse.ui.externaltools/icons/full/dlcl16/paste_tool.gif
Binary files differ
diff --git a/org.eclipse.ui.externaltools/icons/full/dlcl16/prop_tool.gif b/org.eclipse.ui.externaltools/icons/full/dlcl16/prop_tool.gif
new file mode 100644
index 000000000..eb165ffca
--- /dev/null
+++ b/org.eclipse.ui.externaltools/icons/full/dlcl16/prop_tool.gif
Binary files differ
diff --git a/org.eclipse.ui.externaltools/icons/full/dlcl16/refresh.gif b/org.eclipse.ui.externaltools/icons/full/dlcl16/refresh.gif
new file mode 100644
index 000000000..b2281b40c
--- /dev/null
+++ b/org.eclipse.ui.externaltools/icons/full/dlcl16/refresh.gif
Binary files differ
diff --git a/org.eclipse.ui.externaltools/icons/full/dlcl16/rename_tool.gif b/org.eclipse.ui.externaltools/icons/full/dlcl16/rename_tool.gif
new file mode 100644
index 000000000..99f30921c
--- /dev/null
+++ b/org.eclipse.ui.externaltools/icons/full/dlcl16/rename_tool.gif
Binary files differ
diff --git a/org.eclipse.ui.externaltools/icons/full/dlcl16/run_tool.gif b/org.eclipse.ui.externaltools/icons/full/dlcl16/run_tool.gif
new file mode 100644
index 000000000..a281bc119
--- /dev/null
+++ b/org.eclipse.ui.externaltools/icons/full/dlcl16/run_tool.gif
Binary files differ
diff --git a/org.eclipse.ui.externaltools/icons/full/dlcl16/runwith_tool.gif b/org.eclipse.ui.externaltools/icons/full/dlcl16/runwith_tool.gif
new file mode 100644
index 000000000..a281bc119
--- /dev/null
+++ b/org.eclipse.ui.externaltools/icons/full/dlcl16/runwith_tool.gif
Binary files differ
diff --git a/org.eclipse.ui.externaltools/icons/full/elcl16/copy_tool.gif b/org.eclipse.ui.externaltools/icons/full/elcl16/copy_tool.gif
new file mode 100644
index 000000000..41bf445a9
--- /dev/null
+++ b/org.eclipse.ui.externaltools/icons/full/elcl16/copy_tool.gif
Binary files differ
diff --git a/org.eclipse.ui.externaltools/icons/full/elcl16/del_tool.gif b/org.eclipse.ui.externaltools/icons/full/elcl16/del_tool.gif
new file mode 100644
index 000000000..34643b8b6
--- /dev/null
+++ b/org.eclipse.ui.externaltools/icons/full/elcl16/del_tool.gif
Binary files differ
diff --git a/org.eclipse.ui.externaltools/icons/full/elcl16/new_tool.gif b/org.eclipse.ui.externaltools/icons/full/elcl16/new_tool.gif
new file mode 100644
index 000000000..234594a0d
--- /dev/null
+++ b/org.eclipse.ui.externaltools/icons/full/elcl16/new_tool.gif
Binary files differ
diff --git a/org.eclipse.ui.externaltools/icons/full/elcl16/paste_tool.gif b/org.eclipse.ui.externaltools/icons/full/elcl16/paste_tool.gif
new file mode 100644
index 000000000..6e761529a
--- /dev/null
+++ b/org.eclipse.ui.externaltools/icons/full/elcl16/paste_tool.gif
Binary files differ
diff --git a/org.eclipse.ui.externaltools/icons/full/elcl16/prop_tool.gif b/org.eclipse.ui.externaltools/icons/full/elcl16/prop_tool.gif
new file mode 100644
index 000000000..eb165ffca
--- /dev/null
+++ b/org.eclipse.ui.externaltools/icons/full/elcl16/prop_tool.gif
Binary files differ
diff --git a/org.eclipse.ui.externaltools/icons/full/elcl16/refresh.gif b/org.eclipse.ui.externaltools/icons/full/elcl16/refresh.gif
new file mode 100644
index 000000000..919423d43
--- /dev/null
+++ b/org.eclipse.ui.externaltools/icons/full/elcl16/refresh.gif
Binary files differ
diff --git a/org.eclipse.ui.externaltools/icons/full/elcl16/rename_tool.gif b/org.eclipse.ui.externaltools/icons/full/elcl16/rename_tool.gif
new file mode 100644
index 000000000..8337ba9a7
--- /dev/null
+++ b/org.eclipse.ui.externaltools/icons/full/elcl16/rename_tool.gif
Binary files differ
diff --git a/org.eclipse.ui.externaltools/icons/full/elcl16/run_tool.gif b/org.eclipse.ui.externaltools/icons/full/elcl16/run_tool.gif
new file mode 100644
index 000000000..053738cf6
--- /dev/null
+++ b/org.eclipse.ui.externaltools/icons/full/elcl16/run_tool.gif
Binary files differ
diff --git a/org.eclipse.ui.externaltools/icons/full/elcl16/runwith_tool.gif b/org.eclipse.ui.externaltools/icons/full/elcl16/runwith_tool.gif
new file mode 100644
index 000000000..053738cf6
--- /dev/null
+++ b/org.eclipse.ui.externaltools/icons/full/elcl16/runwith_tool.gif
Binary files differ
diff --git a/org.eclipse.ui.externaltools/icons/full/eview16/external_tools.gif b/org.eclipse.ui.externaltools/icons/full/eview16/external_tools.gif
new file mode 100644
index 000000000..f7472c985
--- /dev/null
+++ b/org.eclipse.ui.externaltools/icons/full/eview16/external_tools.gif
Binary files differ
diff --git a/org.eclipse.ui.externaltools/icons/full/obj16/ttype_ant.gif b/org.eclipse.ui.externaltools/icons/full/obj16/ttype_ant.gif
new file mode 100644
index 000000000..f3e45a460
--- /dev/null
+++ b/org.eclipse.ui.externaltools/icons/full/obj16/ttype_ant.gif
Binary files differ
diff --git a/org.eclipse.ui.externaltools/icons/full/obj16/ttype_program.gif b/org.eclipse.ui.externaltools/icons/full/obj16/ttype_program.gif
new file mode 100644
index 000000000..2133b4582
--- /dev/null
+++ b/org.eclipse.ui.externaltools/icons/full/obj16/ttype_program.gif
Binary files differ
diff --git a/org.eclipse.ui.externaltools/icons/full/wizban/program_wiz.gif b/org.eclipse.ui.externaltools/icons/full/wizban/program_wiz.gif
new file mode 100644
index 000000000..1a863bf53
--- /dev/null
+++ b/org.eclipse.ui.externaltools/icons/full/wizban/program_wiz.gif
Binary files differ

Back to the top