Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsarsenau2002-05-10 19:25:15 -0400
committersarsenau2002-05-10 19:25:15 -0400
commit3160ed0e1218aaa5b73da33130bbd9d4757730f7 (patch)
tree98fd12bce57bb69a00e026b3b07c3c0fc5113ed9
parent982bfa5f22446782107d7f99e9fa4d689f33bef4 (diff)
downloadeclipse.platform.debug-3160ed0e1218aaa5b73da33130bbd9d4757730f7.tar.gz
eclipse.platform.debug-3160ed0e1218aaa5b73da33130bbd9d4757730f7.tar.xz
eclipse.platform.debug-3160ed0e1218aaa5b73da33130bbd9d4757730f7.zip
Initial port to External Tools plug-in
-rw-r--r--org.eclipse.ui.externaltools/.classpath12
-rw-r--r--org.eclipse.ui.externaltools/.cvsignore1
-rw-r--r--org.eclipse.ui.externaltools/.options1
-rw-r--r--org.eclipse.ui.externaltools/.project24
-rw-r--r--org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/core/AntFileRunner.java53
-rw-r--r--org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/core/AntUtil.java70
-rw-r--r--org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/core/DefaultRunnerContext.java331
-rw-r--r--org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/core/ExternalTool.java281
-rw-r--r--org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/core/ExternalToolsBuilder.java52
-rw-r--r--org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/core/ExternalToolsPlugin.java85
-rw-r--r--org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/core/ExternalToolsRegistry.java178
-rw-r--r--org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/core/ExternalToolsRunner.java55
-rw-r--r--org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/core/IPreferenceConstants.java30
-rw-r--r--org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/core/IRunnerContext.java56
-rw-r--r--org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/core/ProgramRunner.java92
-rw-r--r--org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/core/ToolMessages.java61
-rw-r--r--org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/core/ToolUtil.java252
-rw-r--r--org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/core/messages.properties128
-rw-r--r--org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/ui/AntAction.java87
-rw-r--r--org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/ui/AntLaunchWizard.java167
-rw-r--r--org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/ui/AntLaunchWizardPage.java238
-rw-r--r--org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/ui/AntPropertyChangeListener.java1
-rw-r--r--org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/ui/AntRunActionDelegate.java56
-rw-r--r--org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/ui/AntTargetContentProvider.java46
-rw-r--r--org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/ui/AntTargetLabelProvider.java65
-rw-r--r--org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/ui/AntTreeContentProvider.java67
-rw-r--r--org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/ui/AntTreeLabelProvider.java72
-rw-r--r--org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/ui/BuildCanceledException.java23
-rw-r--r--org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/ui/BuilderPropertyPage.java425
-rw-r--r--org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/ui/ConfigurationDialog.java324
-rw-r--r--org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/ui/EditDialog.java889
-rw-r--r--org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/ui/ExternalToolsAction.java179
-rw-r--r--org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/ui/IHelpContextIds.java26
-rw-r--r--org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/ui/LogConsoleDocument.java195
-rw-r--r--org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/ui/LogConsoleView.java1
-rw-r--r--org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/ui/OutputStructureElement.java103
-rw-r--r--org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/ui/ant/AntBuildLogger.java178
-rw-r--r--org.eclipse.ui.externaltools/about.html42
-rw-r--r--org.eclipse.ui.externaltools/build.properties9
-rw-r--r--org.eclipse.ui.externaltools/buildnotes.html39
-rw-r--r--org.eclipse.ui.externaltools/icons/full/clcl16/clear.gifbin0 -> 162 bytes
-rw-r--r--org.eclipse.ui.externaltools/icons/full/clcl16/hide_show_tree.gifbin0 -> 145 bytes
-rw-r--r--org.eclipse.ui.externaltools/icons/full/clcl16/show_selected_text.gifbin0 -> 158 bytes
-rw-r--r--org.eclipse.ui.externaltools/icons/full/obj16/ant_file.gifbin0 -> 136 bytes
-rw-r--r--org.eclipse.ui.externaltools/icons/full/obj16/builder.gifbin0 -> 157 bytes
-rw-r--r--org.eclipse.ui.externaltools/icons/full/wizban/ant_wiz.gifbin0 -> 2494 bytes
-rw-r--r--org.eclipse.ui.externaltools/plugin.properties9
-rw-r--r--org.eclipse.ui.externaltools/plugin.xml83
48 files changed, 5086 insertions, 0 deletions
diff --git a/org.eclipse.ui.externaltools/.classpath b/org.eclipse.ui.externaltools/.classpath
new file mode 100644
index 000000000..15d402936
--- /dev/null
+++ b/org.eclipse.ui.externaltools/.classpath
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="External Tools"/>
+ <classpathentry kind="var" path="JRE_LIB" rootpath="JRE_SRCROOT" sourcepath="JRE_SRC"/>
+ <classpathentry kind="src" path="/org.apache.ant"/>
+ <classpathentry kind="src" path="/org.eclipse.ant.core"/>
+ <classpathentry kind="src" path="/org.eclipse.core.resources"/>
+ <classpathentry kind="src" path="/org.eclipse.ui"/>
+ <classpathentry kind="src" path="/org.eclipse.core.runtime"/>
+ <classpathentry kind="src" path="/org.eclipse.core.boot"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/org.eclipse.ui.externaltools/.cvsignore b/org.eclipse.ui.externaltools/.cvsignore
new file mode 100644
index 000000000..ba077a403
--- /dev/null
+++ b/org.eclipse.ui.externaltools/.cvsignore
@@ -0,0 +1 @@
+bin
diff --git a/org.eclipse.ui.externaltools/.options b/org.eclipse.ui.externaltools/.options
new file mode 100644
index 000000000..d127194c3
--- /dev/null
+++ b/org.eclipse.ui.externaltools/.options
@@ -0,0 +1 @@
+# Debugging options for the org.eclipse.ui.externaltools plugin.
diff --git a/org.eclipse.ui.externaltools/.project b/org.eclipse.ui.externaltools/.project
new file mode 100644
index 000000000..b525c11d5
--- /dev/null
+++ b/org.eclipse.ui.externaltools/.project
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.ui.externaltools</name>
+ <comment></comment>
+ <projects>
+ <project>org.apache.ant</project>
+ <project>org.eclipse.ant.core</project>
+ <project>org.eclipse.core.boot</project>
+ <project>org.eclipse.core.resources</project>
+ <project>org.eclipse.core.runtime</project>
+ <project>org.eclipse.ui</project>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.team.cvs.core.cvsnature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/core/AntFileRunner.java b/org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/core/AntFileRunner.java
new file mode 100644
index 000000000..07da66d05
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/core/AntFileRunner.java
@@ -0,0 +1,53 @@
+package org.eclipse.ui.externaltools.internal.core;
+
+/**********************************************************************
+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.apache.tools.ant.BuildListener;
+import org.eclipse.ant.core.AntRunner;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+
+/**
+ * Responsible for running ant files.
+ */
+public class AntFileRunner extends ExternalToolsRunner {
+ private static final String LOGGER_CLASS = "org.eclipse.ui.externaltools.internal.ui.ant.AntBuildLogger"; //$NON-NLS-1$
+
+ /**
+ * Creates an empty ant file runner
+ */
+ public AntFileRunner() {
+ super();
+ }
+
+ /* (non-Javadoc)
+ * Method declared in ExternalToolsRunner.
+ */
+ public void execute(IProgressMonitor monitor, IRunnerContext scriptContext) throws CoreException {
+ try {
+ String[] targets = scriptContext.getAntTargets();
+ startMonitor(monitor, scriptContext, targets.length);
+ AntUtil.setCurrentProgressMonitor(monitor);
+ AntRunner runner = new AntRunner();
+ runner.setArguments(scriptContext.getExpandedArguments());
+ runner.setBuildFileLocation(scriptContext.getExpandedLocation());
+ if (targets.length > 0)
+ runner.setExecutionTargets(targets);
+ if (scriptContext.getShowLog())
+ runner.addBuildLogger(LOGGER_CLASS);
+ runner.run();
+ } catch (Exception e) {
+ handleException(e);
+ } finally {
+ monitor.done();
+ AntUtil.setCurrentProgressMonitor(null);
+ }
+ }
+}
diff --git a/org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/core/AntUtil.java b/org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/core/AntUtil.java
new file mode 100644
index 000000000..accaba201
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/core/AntUtil.java
@@ -0,0 +1,70 @@
+package org.eclipse.ui.externaltools.internal.core;
+
+/**********************************************************************
+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.io.File;
+
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.ProjectHelper;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+
+/**
+ * General utility class dealing with Ant files
+ */
+public final class AntUtil {
+ // Holds the current monitor that the Ant build logger can access
+ private static IProgressMonitor monitor;
+
+ /**
+ * No instances allowed
+ */
+ private AntUtil() {
+ super();
+ }
+
+ /**
+ * Creates an intialized Ant project for the given
+ * Ant file. Returns <code>null</code> if file
+ * is invalid Ant format.
+ */
+ public static Project createAntProject(IPath path) {
+ // create an ant project and initialize it
+ Project antProject = new Project();
+ antProject.init();
+ antProject.setProperty("ant.file", path.toOSString()); //$NON-NLS-1$;
+
+ try {
+ ProjectHelper.configureProject(antProject, new File(path.toOSString()));
+ } catch (VirtualMachineError e) {
+ throw e; // Let others handle this
+ } catch (Throwable t) {
+ return null; // Assume invalid format problems
+ }
+
+ return antProject;
+ }
+
+ /**
+ * Returns the last known progress monitor that the
+ * Ant build logger can use
+ */
+ public static IProgressMonitor getCurrentProgressMonitor() {
+ return AntUtil.monitor;
+ }
+
+ /**
+ * Sets the last known progress monitor that the
+ * Ant build logger can use
+ */
+ public static void setCurrentProgressMonitor(IProgressMonitor monitor) {
+ AntUtil.monitor = monitor;
+ }
+}
diff --git a/org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/core/DefaultRunnerContext.java b/org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/core/DefaultRunnerContext.java
new file mode 100644
index 000000000..58033f6a3
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/core/DefaultRunnerContext.java
@@ -0,0 +1,331 @@
+package org.eclipse.ui.externaltools.internal.core;
+
+/**********************************************************************
+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.io.File;
+import java.util.ArrayList;
+
+import org.eclipse.core.resources.IProject;
+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.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IWorkingSet;
+import org.eclipse.ui.IWorkingSetManager;
+
+/**
+ * Context to run the external tool in.
+ */
+public final class DefaultRunnerContext implements IRunnerContext {
+ private ExternalTool tool;
+ private IProject currentProject;
+ private IWorkingSetManager workingSetManager;
+ private ArrayList antTargets = new ArrayList();
+ 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 currentProject the project to run the external tool on, or <code>null</code>
+ * @param manager the working set manager
+ */
+ public DefaultRunnerContext(ExternalTool tool, IProject currentProject, IWorkingSetManager manager) {
+ super();
+ this.tool = tool;
+ this.currentProject = currentProject;
+ this.workingSetManager = manager;
+ }
+
+ /* (non-Javadoc)
+ * Method declared on IRunnerContext.
+ */
+ public String getName() {
+ return tool.getName();
+ }
+
+ /* (non-Javadoc)
+ * Method declared on IRunnerContext.
+ */
+ public String[] getAntTargets() {
+ // Required because ant target variable tags
+ // are embedded in the tool's arguments and
+ // must be expanded beforehand.
+ getExpandedArguments();
+
+ String[] results = new String[antTargets.size()];
+ antTargets.toArray(results);
+ return results;
+ }
+
+ /* (non-Javadoc)
+ * Method declared on IRunnerContext.
+ */
+ public String getExpandedLocation() {
+ if (expandedLocation == null)
+ expandedLocation = expandVariables(tool.getLocation());
+ return expandedLocation;
+ }
+
+ /* (non-Javadoc)
+ * Method declared on IRunnerContext.
+ */
+ public String getExpandedArguments() {
+ if (expandedArguments == null)
+ expandedArguments = expandVariables(tool.getArguments());
+ return expandedArguments;
+ }
+
+ /* (non-Javadoc)
+ * Method declared on IRunnerContext.
+ */
+ public String getExpandedWorkingDirectory() {
+ if (expandedDirectory == null)
+ expandedDirectory = expandVariables(tool.getWorkingDirectory());
+ return expandedDirectory;
+ }
+
+ /**
+ * Returns whether or not the execution log should appear
+ * on the log console.
+ */
+ public boolean getShowLog() {
+ return tool.getShowLog();
+ }
+
+ /**
+ * Expands the variables found in the text.
+ */
+ private String expandVariables(String text) {
+ StringBuffer buffer = new StringBuffer();
+
+ int start = 0;
+ while (true) {
+ ToolUtil.VariableDefinition varDef = ToolUtil.extractVariableTag(text, start);
+
+ if (varDef.start == -1) {
+ if (start == 0)
+ buffer.append(text);
+ else
+ buffer.append(text.substring(start));
+ break;
+ } else if (varDef.start > start) {
+ buffer.append(text.substring(start, varDef.start));
+ }
+
+ if (varDef.end == -1) {
+ buffer.append(text.substring(varDef.start));
+ break;
+ } else {
+ start = varDef.end;
+ }
+
+ if (varDef.name != null)
+ expandVariable(varDef, buffer);
+ }
+
+ return buffer.toString();
+ }
+
+ /**
+ * Expands the variable
+ */
+ private void expandVariable(ToolUtil.VariableDefinition varDef, StringBuffer buf) {
+ if (tool.VAR_DIR_WORKSPACE.equals(varDef.name)) {
+ buf.append(Platform.getLocation().toString());
+ return;
+ }
+
+ if (tool.VAR_DIR_PROJECT.equals(varDef.name)) {
+ IPath location = null;
+ if (varDef.argument != null && varDef.argument.length() > 0) {
+ IProject namedProject = ResourcesPlugin.getWorkspace().getRoot().getProject(varDef.argument);
+ location = namedProject.getLocation();
+ } else {
+ if (currentProject != null)
+ location = currentProject.getLocation();
+ }
+ if (location != null)
+ buf.append(location.toString());
+ return;
+ }
+
+ if (tool.VAR_ANT_TARGET.equals(varDef.name)) {
+ if (varDef.argument != null && varDef.argument.length() > 0)
+ antTargets.add(varDef.argument);
+ return;
+ }
+ }
+
+ /**
+ * Executes the runner to launch the external tool. A resource refresh
+ * is done if specified.
+ *
+ * @param monitor the monitor to report progress to, or <code>null</code>.
+ */
+ private void executeRunner(IProgressMonitor monitor) throws CoreException {
+ if (monitor == null)
+ monitor = new NullProgressMonitor();
+ try {
+ ToolUtil.VariableDefinition scope = ToolUtil.extractVariableTag(tool.getRefreshScope(), 0);
+ ExternalToolsRunner runner = ToolUtil.getRunner(tool.getType());
+ if (runner != null) {
+ if (scope.name == null || tool.REFRESH_SCOPE_NONE.equals(scope.name)) {
+ runner.execute(monitor, this);
+ } else {
+ monitor.beginTask(ToolMessages.getString("DefaultRunnerContext.runningToolScript"), 100); //$NON-NLS-1$
+ runner.execute(new SubProgressMonitor(monitor, 70), this);
+ refreshResources(new SubProgressMonitor(monitor, 30), scope.name, scope.argument);
+ }
+ }
+ } finally {
+ monitor.done();
+ }
+ }
+
+ /**
+ * Runs the external tool and does a resource refresh if specified.
+ * The tool is validated within this context before being
+ * runned. Any problems will cause an exception to be thrown.
+ *
+ * @param monitor the monitor to report progress to, or <code>null</code>.
+ */
+ public void run(IProgressMonitor monitor) throws CoreException {
+ String problem = validateInContext();
+ if (problem != null) {
+ IStatus status = new Status(IStatus.WARNING, ExternalToolsPlugin.PLUGIN_ID, 0, problem, null);
+ throw new CoreException(status);
+ }
+
+ executeRunner(monitor);
+ }
+
+ /**
+ * Runs the external tool and does a resource refresh if specified.
+ * The tool is validated within this context before being
+ * runned. Any problems are displayed to the user in a dialog box.
+ * <p>
+ * <b>Note:</b> Only call this method if running within the UI thread
+ * </p>
+ *
+ * @param monitor the monitor to report progress to, or <code>null</code>.
+ * @param shell the shell to parent the error message dialog
+ */
+ public void run(IProgressMonitor monitor, Shell shell) {
+ try {
+ String problem = validateInContext();
+ if (problem != null) {
+ MessageDialog.openWarning(
+ shell,
+ ToolMessages.getString("DefaultRunnerContext.errorShellTitle"), //$NON-NLS-1$
+ problem);
+ }
+
+ executeRunner(monitor);
+ } catch(CoreException e) {
+ ErrorDialog.openError(
+ shell,
+ ToolMessages.getString("DefaultRunnerContext.errorShellTitle"), //$NON-NLS-1$
+ ToolMessages.getString("DefaultRunnerContext.errorMessage"), //$NON-NLS-1$
+ e.getStatus());
+ }
+ }
+
+ /**
+ * Causes the specified resources to be refreshed.
+ */
+ private void refreshResources(IProgressMonitor monitor, String scope, String argument) throws CoreException {
+ if (tool.REFRESH_SCOPE_WORKSPACE.equals(scope)) {
+ ResourcesPlugin.getWorkspace().getRoot().refreshLocal(IResource.DEPTH_INFINITE, monitor);
+ return;
+ }
+
+ if (tool.REFRESH_SCOPE_PROJECT.equals(scope)) {
+ IProject container = null;
+ if (argument == null) {
+ container = currentProject;
+ } else {
+ container = ResourcesPlugin.getWorkspace().getRoot().getProject(argument);
+ }
+ if (container != null && container.isAccessible())
+ container.refreshLocal(IResource.DEPTH_INFINITE, monitor);
+ return;
+ }
+
+ if (tool.REFRESH_SCOPE_WORKING_SET.equals(scope)) {
+ if (argument == null)
+ return;
+ IWorkingSet set = workingSetManager.getWorkingSet(argument);
+ if (set == null)
+ return;
+ try {
+ IAdaptable[] elements = set.getElements();
+ monitor.beginTask(
+ ToolMessages.getString("DefaultRunnerContext.refreshWorkingSet"), //$NON-NLS-1$
+ elements.length);
+ for (int i = 0; i < elements.length; i++) {
+ IAdaptable adaptable = elements[i];
+ IResource resource;
+
+ if (adaptable instanceof IResource)
+ resource = (IResource) adaptable;
+ else
+ resource = (IResource) adaptable.getAdapter(IResource.class);
+ if (resource != null)
+ resource.refreshLocal(IResource.DEPTH_INFINITE, null);
+
+ monitor.worked(1);
+ }
+ }
+ finally {
+ monitor.done();
+ }
+
+ return;
+ }
+ }
+
+ /**
+ * Validates the external tool to ensure the external tool location and
+ * working directory exist in the file system.
+ *
+ * @return the problem text is validate fails, or <code>null</code>
+ * if all seems valid.
+ */
+ private String validateInContext() {
+ String loc = getExpandedLocation();
+ if (loc == null || loc.length() == 0)
+ return ToolMessages.format("DefaultRunnerContext.invalidLocation", new Object[] {tool.getName()}); //$NON-NLS-1$
+ File file = new File(loc);
+ if (!file.isFile())
+ return ToolMessages.format("DefaultRunnerContext.invalidLocation", new Object[] {tool.getName()}); //$NON-NLS-1$
+
+ String dir = getExpandedWorkingDirectory();
+ if (dir != null && dir.length() > 0) {
+ File path = new File(dir);
+ if (!path.isDirectory())
+ return ToolMessages.format("DefaultRunnerContext.invalidDirectory", new Object[] {tool.getName()}); //$NON-NLS-1$
+ }
+
+ return null;
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/core/ExternalTool.java b/org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/core/ExternalTool.java
new file mode 100644
index 000000000..ab97d8bff
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/core/ExternalTool.java
@@ -0,0 +1,281 @@
+package org.eclipse.ui.externaltools.internal.core;
+
+/**********************************************************************
+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.HashMap;
+import java.util.Map;
+
+import org.eclipse.core.resources.ICommand;
+
+/**
+ * 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, a path to the location
+ * of the file, optional arguments for the file, 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>
+ */
+public class ExternalTool {
+ // 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$
+
+ // Known kind of tools
+ public static final String TOOL_TYPE_PROGRAM = "org.eclipse.ui.externaltools.type.program"; //$NON-NLS-1$
+ public static final String TOOL_TYPE_ANT = "org.eclipse.ui.externaltools.type.ant"; //$NON-NLS-1$
+
+ // Variable names the tool will expand
+ public static final String VAR_DIR_WORKSPACE = "workspace_dir"; //$NON-NLS-1$
+ public static final String VAR_DIR_PROJECT = "project_dir"; //$NON-NLS-1$
+ public static final String VAR_ANT_TARGET = "ant_target"; //$NON-NLS-1$
+
+ // Known refresh scopes
+ public static final String REFRESH_SCOPE_NONE = "none"; //$NON-NLS-1$;
+ public static final String REFRESH_SCOPE_WORKSPACE = "workspace"; //$NON-NLS-1$;
+ public static final String REFRESH_SCOPE_PROJECT = "project"; //$NON-NLS-1$;
+ public static final String REFRESH_SCOPE_WORKING_SET = "working_set"; //$NON-NLS-1$;
+
+ private static final String EMPTY_VALUE = ""; //$NON-NLS-1$;
+ private static final String TRUE = "true"; //$NON-NLS-1$
+ private static final String FALSE = "false"; //$NON-NLS-1$
+
+ private String type = TOOL_TYPE_PROGRAM;
+ private String name = EMPTY_VALUE;
+ private String location = EMPTY_VALUE;
+ private String arguments = EMPTY_VALUE;
+ private String directory = EMPTY_VALUE;
+ private String refreshScope = EMPTY_VALUE;
+ private boolean showLog = true;
+
+ /**
+ * Creates an empty initialized external tool.
+ */
+ public ExternalTool() {
+ super();
+ this.refreshScope = ToolUtil.buildVariableTag(REFRESH_SCOPE_NONE, null);
+ }
+
+ /**
+ * Creates a fully initialized external tool.
+ */
+ public ExternalTool(String type, String name, String location, String arguments, String directory, String refreshScope, boolean showLog) {
+ this();
+ if (type != null)
+ this.type = type;
+ if (name != null)
+ this.name = name;
+ if (location != null)
+ this.location = location;
+ if (arguments != null)
+ this.arguments = arguments;
+ if (directory != null)
+ this.directory = directory;
+ if (refreshScope != null)
+ this.refreshScope = refreshScope;
+ this.showLog = showLog;
+ }
+
+ /**
+ * Creates an external tool based on specified arguments.
+ * Returns null if no corresponding external tool could be created.
+ */
+ public static ExternalTool fromArgumentMap(Map args) {
+ // Validate the critical information.
+ String type = (String)args.get(TAG_TOOL_TYPE);
+ String name = (String)args.get(TAG_TOOL_NAME);
+ String location = (String)args.get(TAG_TOOL_LOCATION);
+ if (type == null || name == null || location == null)
+ return null;
+ if (type.length() == 0 || name.length() == 0 || location.length() == 0)
+ return null;
+ String sShowLog = (String)args.get(TAG_TOOL_SHOW_LOG);
+ boolean showLog;
+ if (FALSE.equals(sShowLog))
+ showLog = false;
+ else
+ showLog = true;
+
+ return new ExternalTool(
+ type,
+ name,
+ location,
+ (String)args.get(TAG_TOOL_ARGUMENTS),
+ (String)args.get(TAG_TOOL_DIRECTORY),
+ (String)args.get(TAG_TOOL_REFRESH),
+ showLog);
+ }
+
+ /**
+ * 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 path where the external tool is located.
+ */
+ 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 directory;
+ }
+
+ /**
+ * Returns the scope of resources to refresh after
+ * the external tool is run
+ */
+ public String getRefreshScope() {
+ return refreshScope;
+ }
+
+ /**
+ * Returns whether or not the execution log of the external tool
+ * will be shown on the log console.
+ */
+ public boolean getShowLog() {
+ return showLog;
+ }
+
+ /**
+ * Sets the type of external tool.
+ */
+ public void setType(String type) {
+ if (type == null)
+ this.type = EMPTY_VALUE;
+ else
+ this.type = type;
+ }
+
+ /**
+ * Sets the name of the external tool.
+ */
+ public void setName(String name) {
+ if (name == null)
+ this.name = EMPTY_VALUE;
+ else
+ this.name = name;
+ }
+
+ /**
+ * Sets the path where the external tool is located.
+ */
+ public void setLocation(String location) {
+ if (location == null)
+ this.location = EMPTY_VALUE;
+ else
+ this.location = location;
+ }
+
+ /**
+ * Sets the arguments for the external tool.
+ */
+ public void setArguments(String arguments) {
+ if (arguments == null)
+ this.arguments = EMPTY_VALUE;
+ else
+ this.arguments = arguments;
+ }
+
+ /**
+ * Sets the working directory to run the external tool in.
+ */
+ public void setWorkingDirectory(String directory) {
+ if (directory == null)
+ this.directory = EMPTY_VALUE;
+ else
+ this.directory = directory;
+ }
+
+ /**
+ * Sets the scope of resources to refresh after
+ * the external tool is run
+ */
+ public void setRefreshScope(String refreshScope) {
+ if (refreshScope == null || refreshScope.length() < 1)
+ this.refreshScope = ToolUtil.buildVariableTag(REFRESH_SCOPE_NONE, null);
+ else
+ this.refreshScope = refreshScope;
+ }
+
+ /**
+ * Sets whether or not the execution log of the external tool should
+ * be shown on the log console.
+ */
+ public void setShowLog(boolean showLog) {
+ this.showLog = showLog;
+ }
+
+ /**
+ * Stores the external tool as an argument map that can be
+ * used later on to recreate this external tool.
+ *
+ * @return the argument map
+ */
+ public Map toArgumentMap() {
+ HashMap args = new HashMap();
+ args.put(TAG_TOOL_TYPE, type);
+ args.put(TAG_TOOL_NAME, name);
+ args.put(TAG_TOOL_LOCATION, location);
+ args.put(TAG_TOOL_ARGUMENTS, arguments);
+ args.put(TAG_TOOL_DIRECTORY, directory);
+ args.put(TAG_TOOL_REFRESH, refreshScope);
+ if (showLog)
+ args.put(TAG_TOOL_SHOW_LOG, TRUE);
+ else
+ args.put(TAG_TOOL_SHOW_LOG, FALSE);
+
+ return args;
+ }
+
+ /**
+ * Configures the given build command to invoke this
+ * external tool.
+ *
+ * @param command the build command to configure
+ * @return the configured command.
+ */
+ public ICommand toBuildCommand(ICommand command) {
+ Map args = toArgumentMap();
+ command.setBuilderName(ExternalToolsBuilder.ID);
+ command.setArguments(args);
+
+ return command;
+ }
+}
diff --git a/org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/core/ExternalToolsBuilder.java b/org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/core/ExternalToolsBuilder.java
new file mode 100644
index 000000000..52eb4eca4
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/core/ExternalToolsBuilder.java
@@ -0,0 +1,52 @@
+package org.eclipse.ui.externaltools.internal.core;
+
+/**********************************************************************
+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.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.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * The external tool builder can be added to the build spec of a project to run
+ * external tools inside the incremental build process.
+ * <p>
+ * Note that there is only ever one instance of ExternalToolsBuilder per project,
+ * and the external tool to run is specified in the builder's arguments.
+ * </p>
+ */
+public final class ExternalToolsBuilder extends IncrementalProjectBuilder {
+ public static final String ID = "org.eclipse.ui.externaltools.ExternalToolBuilder";
+
+ /**
+ * Creates an uninitialized external tool builder.
+ */
+ public ExternalToolsBuilder() {
+ super();
+ }
+
+ /* (non-Javadoc)
+ * Method declared on IncrementalProjectBuilder.
+ */
+ protected IProject[] build(int kind, Map args, IProgressMonitor monitor) throws CoreException {
+ ExternalTool script = ExternalTool.fromArgumentMap(args);
+ if (script != null) {
+ DefaultRunnerContext context = new DefaultRunnerContext(script, getProject(), PlatformUI.getWorkbench().getWorkingSetManager());
+ context.run(monitor);
+ }
+
+ return null;
+ }
+}
diff --git a/org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/core/ExternalToolsPlugin.java b/org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/core/ExternalToolsPlugin.java
new file mode 100644
index 000000000..9530e8bd3
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/core/ExternalToolsPlugin.java
@@ -0,0 +1,85 @@
+package org.eclipse.ui.externaltools.internal.core;
+
+/**********************************************************************
+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 org.eclipse.core.runtime.IPluginDescriptor;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+
+/**
+ * External tools plug-in class
+ */
+public final class ExternalToolsPlugin extends AbstractUIPlugin {
+ public static final String PLUGIN_ID = "org.eclipse.ui.externaltools"; //$NON-NLS-1$;
+ /*package*/ static final String LOG_CONSOLE_ID = PLUGIN_ID + ".LogConsoleView"; //$NON-NLS-1$;
+
+ public static final String IMG_ANT_SCRIPT= "icons/full/obj16/ant_file.gif"; //$NON-NLS-1$;
+ public static final String IMG_BUILDER= "icons/full/obj16/builder.gif"; //$NON-NLS-1$;
+
+ private static ExternalToolsPlugin plugin;
+ private ExternalToolsRegistry registry;
+
+ /**
+ * 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 the registry of external tools that the
+ * user can run using the external tools menu. Does
+ * not include external tools part of the build process.
+ */
+ public ExternalToolsRegistry getRegistry() {
+ if (registry == null)
+ registry = new ExternalToolsRegistry();
+ return registry;
+ }
+
+ /**
+ * 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) {
+ Status status = new Status(Status.ERROR, PLUGIN_ID, 0, message, exception);
+ getLog().log(status);
+ System.err.println(message);
+ }
+
+ /**
+ * 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;
+ }
+ }
+}
diff --git a/org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/core/ExternalToolsRegistry.java b/org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/core/ExternalToolsRegistry.java
new file mode 100644
index 000000000..157ff0f53
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/core/ExternalToolsRegistry.java
@@ -0,0 +1,178 @@
+package org.eclipse.ui.externaltools.internal.core;
+
+/**********************************************************************
+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.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.OutputStreamWriter;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.ui.IMemento;
+import org.eclipse.ui.XMLMemento;
+
+/**
+ * The registry of user defined external tools that can
+ * be run using the external tool menu. It does not include
+ * any external tools that are assigned as builders on a
+ * project.
+ */
+public final class ExternalToolsRegistry {
+ 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$
+
+ private ArrayList externalTools;
+
+ /**
+ * Creates the registry and loads the saved
+ * external tools.
+ */
+ /*package*/ ExternalToolsRegistry() {
+ super();
+ loadExternalTools();
+ }
+
+ /**
+ * Returns the named external tool or <code>null</code>
+ * if not found.
+ */
+ public ExternalTool getExternalTool(String name) {
+ Iterator enum = externalTools.iterator();
+ while (enum.hasNext()) {
+ ExternalTool script = (ExternalTool)enum.next();
+ if (script.getName().equals(name))
+ return script;
+ }
+ return null;
+ }
+
+ /**
+ * Returns the external tools of the registry
+ */
+ public ArrayList getExternalTools() {
+ return externalTools;
+ }
+
+ /**
+ * Sets the external tools for the registry.
+ * Causes them to be saved to disk.
+ */
+ public boolean setExternalTools(ArrayList scripts) {
+ this.externalTools = scripts;
+ return saveExternalTools();
+ }
+
+ /**
+ * Loads the external tools from storage and
+ * adds them to the registry.
+ */
+ private void loadExternalTools() {
+ IPath path = ExternalToolsPlugin.getDefault().getStateLocation();
+ path = path.append(STATE_FILE_NAME);
+ InputStreamReader reader = null;
+ try {
+ FileInputStream input = new FileInputStream(path.toFile());
+ reader = new InputStreamReader(input, "utf-8"); //$NON-NLS-1$
+ XMLMemento memento = XMLMemento.createReadRoot(reader);
+
+ // Get the tool script children element
+ IMemento[] scripts = memento.getChildren(TAG_TOOL);
+ externalTools = new ArrayList(scripts.length);
+ for (int i = 0; i < scripts.length; i++) {
+ HashMap args = new HashMap();
+ IMemento[] entries = scripts[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 script = ExternalTool.fromArgumentMap(args);
+ if (script != null)
+ externalTools.add(script);
+ }
+ }
+ catch (FileNotFoundException e) {
+ // Silently ignore this...
+ }
+ catch (IOException e) {
+ ExternalToolsPlugin.getDefault().log("File I/O error with external tool state reader.", e); //$NON-NLS-1$
+ }
+ finally {
+ if (reader != null) {
+ try {
+ reader.close();
+ } catch(IOException e) {
+ ExternalToolsPlugin.getDefault().log("Unable to close external tool state reader.", e); //$NON-NLS-1$
+ }
+ }
+ if (externalTools == null)
+ externalTools = new ArrayList(0);
+ }
+ }
+
+ /**
+ * Saves the external tool to storage.
+ *
+ * @return true if save is successful, false otherwise.
+ */
+ /*package*/ boolean saveExternalTools() {
+ boolean successful = true;
+
+ // Populate the memento
+ XMLMemento memento = XMLMemento.createWriteRoot(TAG_EXTERNALTOOLS);
+ Iterator enum = externalTools.iterator();
+ while (enum.hasNext()) {
+ IMemento scriptMemento = memento.createChild(TAG_TOOL);
+ ExternalTool script = (ExternalTool)enum.next();
+ Map args = script.toArgumentMap();
+ Iterator entries = args.entrySet().iterator();
+ while (entries.hasNext()) {
+ Map.Entry entry = (Map.Entry)entries.next();
+ IMemento entryMemento = scriptMemento.createChild(TAG_ENTRY);
+ entryMemento.putString(TAG_KEY, (String)entry.getKey());
+ entryMemento.putTextData((String)entry.getValue());
+ }
+ }
+
+ // Write the memento to the state file
+ IPath path = ExternalToolsPlugin.getDefault().getStateLocation();
+ path = path.append(STATE_FILE_NAME);
+ File stateFile = path.toFile();
+ try {
+ FileOutputStream stream = new FileOutputStream(stateFile);
+ OutputStreamWriter writer = new OutputStreamWriter(stream, "utf-8"); //$NON-NLS-1$
+ memento.save(writer);
+ writer.close();
+ } catch (IOException e) {
+ stateFile.delete();
+ MessageDialog.openError(
+ null,
+ ToolMessages.getString("ExternalToolsRegistry.saveStateErrorTitle"), //$NON-NLS-1$
+ ToolMessages.getString("ExternalToolsRegistry.saveStateError")); //$NON-NLS-1$
+ successful = false;
+ }
+
+ return successful;
+ }
+}
diff --git a/org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/core/ExternalToolsRunner.java b/org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/core/ExternalToolsRunner.java
new file mode 100644
index 000000000..4b34f5522
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/core/ExternalToolsRunner.java
@@ -0,0 +1,55 @@
+package org.eclipse.ui.externaltools.internal.core;
+
+/**********************************************************************
+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.apache.tools.ant.BuildListener;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+
+/**
+ * Responsible for executing the external tool. Clients
+ * must provide a public no-argument constructor
+ */
+public abstract class ExternalToolsRunner {
+
+ /**
+ * Creates an empty external tool runner
+ */
+ public ExternalToolsRunner() {
+ super();
+ }
+
+ /**
+ * Execute the external tool within the given context. Subclasses
+ * are responsible for showing the execution log if
+ * specified in the context.
+ */
+ public abstract void execute(IProgressMonitor monitor, IRunnerContext scriptContext) throws CoreException;
+
+ /**
+ * Handles exceptions that may occur while running.
+ */
+ protected final void handleException(Exception e) throws CoreException {
+ String msg = e.getMessage();
+ if (msg == null)
+ msg = ToolMessages.getString("ExternalToolsRunner.internalErrorMessage"); //$NON-NLS-1$;
+ throw new CoreException(new Status(IStatus.ERROR, ExternalToolsPlugin.PLUGIN_ID, 0, msg, e));
+ }
+
+ /**
+ * Starts the monitor to show progress while running.
+ */
+ protected final void startMonitor(IProgressMonitor monitor, IRunnerContext scriptContext, int workAmount) {
+ String label = ToolMessages.format("ExternalToolsRunner.runningScriptLabel", new Object[] {scriptContext.getName()}); //$NON-NLS-1$;
+ monitor.beginTask(label, workAmount);
+ }
+}
diff --git a/org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/core/IPreferenceConstants.java b/org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/core/IPreferenceConstants.java
new file mode 100644
index 000000000..f30433d05
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/core/IPreferenceConstants.java
@@ -0,0 +1,30 @@
+package org.eclipse.ui.externaltools.internal.core;
+
+/**********************************************************************
+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:
+**********************************************************************/
+
+/**
+ * Constants used to identify user preferences.
+ */
+public interface IPreferenceConstants {
+ public static final String AUTO_SAVE = "externaltools.auto_save";
+
+// public static final String OUPUT_LEVEL = "externaltools.outputLevel";
+ public static final String INFO_LEVEL = "externaltools.infoLevel";
+ public static final String VERBOSE_LEVEL = "externaltools.verboseLevel";
+ public static final String DEBUG_LEVEL = "externaltools.levelLevel";
+
+ public static final String CONSOLE_ERROR_RGB = "externaltools.console.errorColor";
+ public static final String CONSOLE_WARNING_RGB = "externaltools.console.warningColor";
+ public static final String CONSOLE_INFO_RGB = "externaltools.console.infoColor";
+ public static final String CONSOLE_VERBOSE_RGB = "externaltools.console.verboseColor";
+ public static final String CONSOLE_DEBUG_RGB = "externaltools.console.debugColor";
+ public static final String CONSOLE_FONT = "externaltools.console.font";
+}
diff --git a/org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/core/IRunnerContext.java b/org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/core/IRunnerContext.java
new file mode 100644
index 000000000..1ebd197a0
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/core/IRunnerContext.java
@@ -0,0 +1,56 @@
+package org.eclipse.ui.externaltools.internal.core;
+
+/**********************************************************************
+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:
+**********************************************************************/
+
+/**
+ * Represents the context in which to run the
+ * external tools.
+ */
+public interface IRunnerContext {
+ /**
+ * Returns the name of the external tool.
+ */
+ public String getName();
+
+ /**
+ * Returns the path where the external tool is located. All
+ * variables embedded in the path have been fully
+ * expanded.
+ */
+ public String getExpandedLocation();
+
+ /**
+ * Returns the targets for an Ant file. The
+ * targets are collected from the corresponding
+ * variable tags in the external tool's arguments.
+ */
+ public String[] getAntTargets();
+
+ /**
+ * Returns the arguments for the external tool. All
+ * variables embedded in the arguments have been fully
+ * expanded.
+ */
+ public String getExpandedArguments();
+
+ /**
+ * Returns the working directory to run the external tool in.
+ * All variables embedded in the path have been fully
+ * expanded.
+ */
+ public String getExpandedWorkingDirectory();
+
+ /**
+ * Returns whether or not the execution log for the
+ * external tool should appear on the log console.
+ */
+ public boolean getShowLog();
+}
diff --git a/org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/core/ProgramRunner.java b/org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/core/ProgramRunner.java
new file mode 100644
index 000000000..9b1317a9a
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/core/ProgramRunner.java
@@ -0,0 +1,92 @@
+package org.eclipse.ui.externaltools.internal.core;
+
+/**********************************************************************
+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.io.IOException;
+import java.io.InputStream;
+
+import org.apache.tools.ant.BuildEvent;
+import org.apache.tools.ant.BuildListener;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.Task;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+
+/**
+ * Execute external tools that represent programs in the file
+ * system.
+ */
+public class ProgramRunner extends ExternalToolsRunner {
+
+ /**
+ * Creates an empty program runner
+ */
+ public ProgramRunner() {
+ super();
+ }
+
+ /* (non-Javadoc)
+ * Method declared in ExternalToolsRunner.
+ */
+ public void execute(IProgressMonitor monitor, IRunnerContext scriptContext) throws CoreException {
+ String commandLine = scriptContext.getExpandedLocation() + " " + scriptContext.getExpandedArguments(); //$NON-NLS-1$;
+ try {
+ startMonitor(monitor, scriptContext, monitor.UNKNOWN);
+ Process p = Runtime.getRuntime().exec(commandLine);
+ boolean[] finished = new boolean[1];
+
+ //
+ // DO TO: This needs to be updated to use log document support
+ //
+// finished[0] = false;
+// new Thread(getRunnable(p.getInputStream(), null, Project.MSG_INFO, finished)).start();
+// new Thread(getRunnable(p.getErrorStream(), null, Project.MSG_ERR, finished)).start();
+
+ p.waitFor();
+ finished[0] = true;
+ } catch (Exception e) {
+ handleException(e);
+ } finally {
+ monitor.done();
+ }
+ }
+
+ /**
+ * Returns a runnable that is used to capture and print out a stream
+ * from another process.
+ */
+ private Runnable getRunnable(final InputStream input, final BuildListener listener, final int severity, final boolean[] finished) {
+ return new Runnable() {
+ public void run() {
+ try {
+ StringBuffer sb;
+ BuildEvent event = new BuildEvent((Task)null);
+ while (!finished[0]) {
+ sb = new StringBuffer();
+ int c = input.read();
+ while (c != -1) {
+ sb.append((char)c);
+ c = input.read();
+ }
+ event.setMessage(sb.toString(), severity);
+ listener.messageLogged(event);
+ try {
+ Thread.currentThread().sleep(100);
+ } catch (InterruptedException e) {
+ }
+ }
+ input.close();
+ } catch (IOException e) {
+ e.printStackTrace(System.out);
+ }
+ }
+ };
+ }
+}
diff --git a/org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/core/ToolMessages.java b/org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/core/ToolMessages.java
new file mode 100644
index 000000000..28d2383cc
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/core/ToolMessages.java
@@ -0,0 +1,61 @@
+package org.eclipse.ui.externaltools.internal.core;
+
+/**********************************************************************
+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.text.MessageFormat;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+/**
+ * Utility class which helps managing messages
+ */
+public class ToolMessages {
+ private static final String RESOURCE_BUNDLE= "org.eclipse.ui.externaltools.internal.core.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/org/eclipse/ui/externaltools/internal/core/ToolUtil.java b/org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/core/ToolUtil.java
new file mode 100644
index 000000000..902b05fec
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/core/ToolUtil.java
@@ -0,0 +1,252 @@
+package org.eclipse.ui.externaltools.internal.core;
+
+/**********************************************************************
+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.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.externaltools.internal.ui.LogConsoleDocument;
+import org.eclipse.ui.externaltools.internal.ui.LogConsoleView;
+
+/**
+ * General utility class dealing with external tools
+ */
+public final class ToolUtil {
+ /**
+ * Variable tag indentifiers
+ */
+ /*package*/ static final String VAR_TAG_START = "${"; //$NON-NLS-1$
+ /*package*/ static final String VAR_TAG_END = "}"; //$NON-NLS-1$
+ /*package*/ static final String VAR_TAG_SEP = ":"; //$NON-NLS-1$
+
+ private static final ToolUtil instance = new ToolUtil();
+
+ /**
+ * No instances allowed
+ */
+ private ToolUtil() {
+ super();
+ }
+
+ /**
+ * Builds a variable tag that will be auto-expanded before
+ * the script is run.
+ *
+ * @param varName the name of a known variable (one of the VAR_* constants)
+ * @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 script is run.
+ *
+ * @param varName the name of a known variable (one of the VAR_* constants)
+ * @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);
+ }
+
+ /**
+ * Builds a variable tag for each argument that will be auto-expanded before
+ * the script is run.
+ *
+ * @param varName the name of a known variable (one of the VAR_* constants)
+ * @param varArguments a list of arguments for each variable
+ * @param buffer the buffer to write the constructed variable tags
+ */
+ public static void buildVariableTags(String varName, String[] varArguments, StringBuffer buffer) {
+ for (int i = 0; i < varArguments.length; i++) {
+ buffer.append(" "); // $NON-NLS-1$
+ buildVariableTag(varName, varArguments[i], buffer);
+ }
+ }
+
+ /**
+ * 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 = instance.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;
+ }
+
+ /**
+ * Extracts all arguments of the specified variable tag name.
+ * Places the remaining text on the buffer.
+ *
+ * @param text the text to parse for variable tags of the specified name
+ * @param varName the name of the variable tag to extract its argument
+ * @param buffer the buffer to write the rest of the text
+ * @return an array of arguments for the variable tag name specified
+ */
+ public static String[] extractVariableArguments(String text, String varName, StringBuffer buffer) {
+ ArrayList results = new ArrayList();
+
+ int start = 0;
+ while (true) {
+ VariableDefinition varDef = extractVariableTag(text, start);
+
+ if (varDef.start == -1) {
+ if (start == 0)
+ buffer.append(text);
+ else
+ buffer.append(text.substring(start));
+ break;
+ } else if (varDef.start > start) {
+ buffer.append(text.substring(start, varDef.start));
+ }
+
+ if (varDef.end == -1) {
+ buffer.append(text.substring(varDef.start));
+ break;
+ }
+
+ if (varName.equals(varDef.name)) {
+ if (varDef.argument != null)
+ results.add(varDef.argument);
+ } else {
+ buffer.append(text.substring(varDef.start, varDef.end));
+ }
+
+ start = varDef.end;
+ }
+
+ String[] args = new String[results.size()];
+ results.toArray(args);
+ return args;
+ }
+
+ /**
+ * Clears the log messages recorded so far.
+ */
+ public static void clearLogDocument() {
+ LogConsoleDocument.getInstance().clearOutput();
+ }
+
+ /**
+ * Returns the tool script runner for the specified
+ * type, or <code>null</code> if none registered.
+ */
+ public static ExternalToolsRunner getRunner(String type) {
+ if (ExternalTool.TOOL_TYPE_PROGRAM.equals(type))
+ return new ProgramRunner();
+ if (ExternalTool.TOOL_TYPE_ANT.equals(type))
+ return new AntFileRunner();
+ return null;
+ }
+
+ /**
+ * Forces the log console view to open. Returns the view
+ * part if successful, otherwise <code>null</code>.
+ */
+ public static LogConsoleView showLogConsole(IWorkbenchWindow window) {
+ IWorkbenchPage page = window.getActivePage();
+ LogConsoleView console = null;
+ try {
+ if (page != null)
+ console = (LogConsoleView) page.showView(ExternalToolsPlugin.LOG_CONSOLE_ID);
+ } catch (PartInitException e) {
+ ExternalToolsPlugin.getDefault().getLog().log(e.getStatus());
+ }
+ return console;
+ }
+
+ /**
+ * Structure to represent a variable definition within a
+ * source string.
+ */
+ public 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/org/eclipse/ui/externaltools/internal/core/messages.properties b/org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/core/messages.properties
new file mode 100644
index 000000000..4e879a3ad
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/core/messages.properties
@@ -0,0 +1,128 @@
+# ======================================================================
+# 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:
+# ======================================================================
+
+ConfigurationDialog.shellTitle = External Tools Configuration
+ConfigurationDialog.dialogTitle = External Tools
+ConfigurationDialog.dialogMessage = Configure external tools
+ConfigurationDialog.scriptList = &Tools:
+ConfigurationDialog.newButton = &New...
+ConfigurationDialog.editButton = &Edit...
+ConfigurationDialog.removeButton = &Remove
+ConfigurationDialog.upButton = &Up
+ConfigurationDialog.downButton = &Down
+ConfigurationDialog.details = De&tails:
+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 configuration
+EditDialog.editDialogMessage = Edit an external tool configuration
+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.browseWkspButton2 = Browse Wor&kspace...
+EditDialog.browseFileSysButton2 = Browse File &System...
+EditDialog.refreshOptionButton = Browse &Options...
+EditDialog.browseWorkspaceTitle = Browse Workspace
+EditDialog.selectResource = &Select the external tool 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.selectVar = &Select a variable to use:
+EditDialog.varWorkspaceDirLabel = Current workspace directory
+EditDialog.varProjectDirLabel = Current project directory
+EditDialog.varProjectXDirLabel = Specific project directory
+EditDialog.varAntTargetLabel = Ant targets
+EditDialog.browseProjectTitle = Browse Projects
+EditDialog.selectProject = &Select a project to use:
+EditDialog.noScriptName = Enter a name for the tool
+EditDialog.noScriptLocation = Enter a location for the tool
+EditDialog.missingScriptLocation = Tool location does not exist
+EditDialog.missingScriptDirectory = Tool working directory does not exist
+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
+
+ExternalToolsRegistry.saveStateErrorTitle = Problem Saving External Tool
+ExternalToolsRegistry.saveStateError = Could not write external tool configurations to disk.\n\nPlease try again.
+
+BuilderPropertyPage.description = Add external tool 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
+
+DefaultRunnerContext.runningToolScript = Running external tool...
+DefaultRunnerContext.invalidLocation = The tool''s file does not exist for the external tool named {0}.
+DefaultRunnerContext.invalidDirectory = The tool''s working directory does note exist for the external tool named {0}.
+DefaultRunnerContext.refreshWorkingSet = Refreshing...
+DefaultRunnerContext.errorShellTitle = Problem Running External Tool
+DefaultRunnerContext.errorMessage = External tool failed to run because of an internal error.
+
+ExternalToolsRunner.runningScriptLabel = Running external tool: {0}
+ExternalToolsRunner.internalErrorMessage = Internal error
+
+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 = S&how Output of Selected Element Only
+LogConsoleView.showCompleteOutput = Show &Complete Output
+
+BuildCanceledException.canceled = Canceled
+
+
+AntAction.runErrorTitle = Run Ant Problem
+AntAction.runInvalidFile = Could not parse Ant file.
+
+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
+
+AntTreeLabelProvider.invalidTaskName = Invalid task name
+
+AntBuildLogger.buildException = Build exception: {0} \ No newline at end of file
diff --git a/org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/ui/AntAction.java b/org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/ui/AntAction.java
new file mode 100644
index 000000000..350ee8c61
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/ui/AntAction.java
@@ -0,0 +1,87 @@
+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.io.File;
+
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.ProjectHelper;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.externaltools.internal.core.AntUtil;
+import org.eclipse.ui.externaltools.internal.core.ExternalToolsPlugin;
+import org.eclipse.ui.externaltools.internal.core.IPreferenceConstants;
+import org.eclipse.ui.externaltools.internal.core.ToolMessages;
+
+/**
+ * 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());
+ }
+
+ /* (non-Javadoc)
+ * Method declared on IAction.
+ */
+ public void run() {
+ if (file == null)
+ return;
+
+ saveDirtyEditors();
+
+ Project project = AntUtil.createAntProject(file.getLocation());
+ if (project == null) {
+ MessageDialog.openError(
+ window.getShell(),
+ ToolMessages.getString("AntAction.runErrorTitle"), //$NON-NLS-1$;
+ ToolMessages.getString("AntAction.runInvalidFile")); //$NON-NLS-1$;
+ return;
+ }
+
+ AntLaunchWizard wizard = new AntLaunchWizard(project, file, window);
+ wizard.setNeedsProgressMonitor(true);
+ WizardDialog dialog = new WizardDialog(window.getShell(), wizard);
+ dialog.create();
+ dialog.open();
+ }
+
+ /**
+ * Saves any dirty editors if user preference
+ */
+ private void saveDirtyEditors() {
+ IPreferenceStore store = ExternalToolsPlugin.getDefault().getPreferenceStore();
+ boolean autoSave = store.getBoolean(IPreferenceConstants.AUTO_SAVE);
+ if (autoSave)
+ window.getActivePage().saveAllEditors(false);
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/ui/AntLaunchWizard.java b/org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/ui/AntLaunchWizard.java
new file mode 100644
index 000000000..22f89859d
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/ui/AntLaunchWizard.java
@@ -0,0 +1,167 @@
+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 java.util.ArrayList;
+
+import org.apache.tools.ant.Project;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.externaltools.internal.core.DefaultRunnerContext;
+import org.eclipse.ui.externaltools.internal.core.ExternalTool;
+import org.eclipse.ui.externaltools.internal.core.ExternalToolsPlugin;
+import org.eclipse.ui.externaltools.internal.core.ToolMessages;
+import org.eclipse.ui.externaltools.internal.core.ToolUtil;
+
+/**
+ * The wizard to run an Ant script 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 script.
+ */
+ private IFile antFile = null;
+
+ /**
+ * The Ant project described in the xml file.
+ */
+ private Project antProject = null;
+
+ /**
+ * The tool script representing Ant script
+ */
+ private ExternalTool antTool = null;
+
+ /**
+ * Whether the tool script 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(Project antProject, IFile antFile, IWorkbenchWindow window) {
+ super();
+ this.antProject = antProject;
+ this.antFile = antFile;
+ this.window = window;
+ String name = antFile.getFullPath().toString();
+ this.antTool = ExternalToolsPlugin.getDefault().getRegistry().getExternalTool(name);
+ if (this.antTool == null) {
+ this.antTool = new ExternalTool();
+ this.antTool.setName(name);
+ this.antTool.setType(ExternalTool.TOOL_TYPE_ANT);
+ this.antTool.setLocation(antFile.getLocation().toString());
+ this.isNewTool = true;
+ }
+ setWindowTitle(ToolMessages.getString("AntLaunchWizard.shellTitle")); //$NON-NLS-1$;
+ }
+
+ /* (non-Javadoc)
+ * Method declared on IWizard.
+ */
+ public void addPages() {
+ page1 = new AntLaunchWizardPage(antProject);
+ addPage(page1);
+
+ String args = antTool.getArguments();
+ StringBuffer buf = new StringBuffer();
+ String[] targets = ToolUtil.extractVariableArguments(args, ExternalTool.VAR_ANT_TARGET, buf);
+
+ page1.setInitialTargets(targets);
+ page1.setInitialArguments(buf.toString());
+ page1.setInitialDisplayLog(antTool.getShowLog());
+ }
+
+ /* (non-Javadoc)
+ * Method declared on IWizard.
+ */
+ public boolean performFinish() {
+ updateScript();
+ if (antTool.getShowLog()) {
+ ToolUtil.showLogConsole(window);
+ ToolUtil.clearLogDocument();
+ }
+
+ IRunnableWithProgress runnable = new IRunnableWithProgress() {
+ public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+ try {
+ DefaultRunnerContext context = new DefaultRunnerContext(antTool, antFile.getProject(), window.getWorkbench().getWorkingSetManager());
+ context.run(monitor, window.getShell());
+ } catch (BuildCanceledException e) {
+ throw new InterruptedException();
+ } catch (Exception e) {
+ throw new InvocationTargetException(e, e.getMessage());
+ }
+ };
+ };
+
+ try {
+ getContainer().run(true, true, runnable);
+ } catch (InterruptedException e) {
+ return false;
+ } catch (InvocationTargetException e) {
+ IStatus status = new Status(IStatus.ERROR, ExternalToolsPlugin.PLUGIN_ID, 0, ToolMessages.getString("AntLaunchWizard.internalAntError"), e); //$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 updateScript.
+ */
+ private void updateScript() {
+ StringBuffer buf = new StringBuffer(page1.getArguments());
+ String[] targets = page1.getSelectedTargets();
+ ToolUtil.buildVariableTags(ExternalTool.VAR_ANT_TARGET, targets, buf);
+
+ antTool.setArguments(buf.toString());
+ antTool.setShowLog(page1.getShowLog());
+
+ ArrayList scripts = ExternalToolsPlugin.getDefault().getRegistry().getExternalTools();
+ if (isNewTool) {
+ scripts.add(antTool);
+ isNewTool = false;
+ }
+ ExternalToolsPlugin.getDefault().getRegistry().setExternalTools(scripts);
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/ui/AntLaunchWizardPage.java b/org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/ui/AntLaunchWizardPage.java
new file mode 100644
index 000000000..dfa6fc327
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/ui/AntLaunchWizardPage.java
@@ -0,0 +1,238 @@
+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 java.util.Iterator;
+
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.Target;
+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.core.ExternalToolsPlugin;
+import org.eclipse.ui.externaltools.internal.core.ToolMessages;
+
+/**
+ * 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 Project project;
+ 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(Project project) {
+ super("AntScriptPage"); //$NON-NLS-1$;
+ this.project = project;
+ 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 ((Target) o1).getName().compareTo(((Target) o2).getName());
+ }
+ });
+ if (project.getDefaultTarget() != null)
+ labelProvider.setDefaultTargetName(project.getDefaultTarget());
+ listViewer.setLabelProvider(labelProvider);
+ listViewer.setContentProvider(new AntTargetContentProvider());
+ listViewer.setInput(project);
+
+ // 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);
+ }
+
+ /**
+ * 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()];
+ for (int i = 0; i < selectedTargets.size(); i++) {
+ names[i] = ((Target)selectedTargets.get(i)).getName();
+ }
+ return names;
+ }
+
+ /**
+ * Returns whether the users wants messages from running
+ * the script 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++) {
+ Target target = (Target)project.getTargets().get(initialTargets[i]);
+ if (target != null && !selectedTargets.contains(target)) {
+ listViewer.setChecked(target, true);
+ selectedTargets.add(target);
+ }
+ }
+ } else {
+ Target target = (Target)project.getTargets().get(project.getDefaultTarget());
+ if (target != null) {
+ listViewer.setChecked(target, true);
+ selectedTargets.add(target);
+ }
+ }
+
+ 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) {
+ Target checkedTarget = (Target) 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/org/eclipse/ui/externaltools/internal/ui/AntPropertyChangeListener.java b/org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/ui/AntPropertyChangeListener.java
new file mode 100644
index 000000000..31baab720
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/ui/AntPropertyChangeListener.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.util.Iterator; import org.eclipse.jface.util.IPropertyChangeListener; import org.eclipse.jface.util.PropertyChangeEvent; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Font; import org.eclipse.swt.graphics.FontData; import org.eclipse.swt.widgets.Display; /** * Property change listener */ public class AntPropertyChangeListener implements IPropertyChangeListener { // unique instance private static AntPropertyChangeListener instance = new AntPropertyChangeListener(); // private constructor to ensure the singleton private AntPropertyChangeListener() { } // access to the singleton public static AntPropertyChangeListener getInstance() { return instance; } /** * @see IPropertyChangeListener#propertyChange(PropertyChangeEvent) */ public void propertyChange(PropertyChangeEvent event) { // String propertyName= event.getProperty(); // // if (propertyName.equals(IPreferenceConstants.CONSOLE_ERROR_RGB)) { // Color temp = AntConsole.ERROR_COLOR; // AntConsole.ERROR_COLOR = AntConsolePreferencePage.getPreferenceColor(IPreferenceConstants.CONSOLE_ERROR_RGB); // temp.dispose(); // clearOutput(); // } else if (propertyName.equals(IPreferenceConstants.CONSOLE_WARNING_RGB)) { // Color temp = AntConsole.WARN_COLOR; // AntConsole.WARN_COLOR = AntConsolePreferencePage.getPreferenceColor(IPreferenceConstants.CONSOLE_WARNING_RGB); // temp.dispose(); // clearOutput(); // } else if (propertyName.equals(IPreferenceConstants.CONSOLE_INFO_RGB)) { // Color temp = AntConsole.INFO_COLOR; // AntConsole.INFO_COLOR = AntConsolePreferencePage.getPreferenceColor(IPreferenceConstants.CONSOLE_INFO_RGB); // temp.dispose(); // clearOutput(); // } else if (propertyName.equals(IPreferenceConstants.CONSOLE_VERBOSE_RGB)) { // Color temp = AntConsole.VERBOSE_COLOR; // AntConsole.VERBOSE_COLOR = AntConsolePreferencePage.getPreferenceColor(IPreferenceConstants.CONSOLE_VERBOSE_RGB); // temp.dispose(); // clearOutput(); // } else if (propertyName.equals(IPreferenceConstants.CONSOLE_DEBUG_RGB)) { // Color temp = AntConsole.DEBUG_COLOR; // AntConsole.DEBUG_COLOR = AntConsolePreferencePage.getPreferenceColor(IPreferenceConstants.CONSOLE_DEBUG_RGB); // temp.dispose(); // clearOutput(); // } else if (propertyName.equals(IPreferenceConstants.CONSOLE_FONT)) { // FontData data= AntConsolePreferencePage.getConsoleFontData(); // Font temp= AntConsole.ANT_FONT; // AntConsole.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(); } } \ No newline at end of file
diff --git a/org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/ui/AntRunActionDelegate.java b/org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/ui/AntRunActionDelegate.java
new file mode 100644
index 000000000..aada60d79
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools/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/org/eclipse/ui/externaltools/internal/ui/AntTargetContentProvider.java b/org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/ui/AntTargetContentProvider.java
new file mode 100644
index 000000000..20e166048
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/ui/AntTargetContentProvider.java
@@ -0,0 +1,46 @@
+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.apache.tools.ant.Project;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+
+/**
+ * Content provider for targets within an Ant script
+ */
+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 inputElement) {
+ Project project = (Project) inputElement;
+ return project.getTargets().values().toArray();
+ }
+
+ /* (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/org/eclipse/ui/externaltools/internal/ui/AntTargetLabelProvider.java b/org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/ui/AntTargetLabelProvider.java
new file mode 100644
index 000000000..ae5c37448
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/ui/AntTargetLabelProvider.java
@@ -0,0 +1,65 @@
+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.apache.tools.ant.Target;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.ui.externaltools.internal.core.ToolMessages;
+
+/**
+ * Ant script 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) {
+ Target targetToDisplay = (Target) model;
+ if (targetToDisplay != null) {
+ StringBuffer result = new StringBuffer(targetToDisplay.getName());
+ if (targetToDisplay.getName().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/org/eclipse/ui/externaltools/internal/ui/AntTreeContentProvider.java b/org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/ui/AntTreeContentProvider.java
new file mode 100644
index 000000000..29dae3a9e
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/ui/AntTreeContentProvider.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 AntTreeContentProvider implements ITreeContentProvider {
+
+ private LogConsoleView console;
+
+ public AntTreeContentProvider(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/org/eclipse/ui/externaltools/internal/ui/AntTreeLabelProvider.java b/org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/ui/AntTreeLabelProvider.java
new file mode 100644
index 000000000..40c37a8db
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/ui/AntTreeLabelProvider.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.core.ToolMessages;
+
+/**
+ * Label provider for the tree viewer of the Ant Console.
+ */
+public class AntTreeLabelProvider implements ILabelProvider {
+
+ private LogConsoleView console;
+
+ public AntTreeLabelProvider(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("AntTreeLabelProvider.invalidTaskName");
+ 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/org/eclipse/ui/externaltools/internal/ui/BuildCanceledException.java b/org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/ui/BuildCanceledException.java
new file mode 100644
index 000000000..bf074ce9c
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/ui/BuildCanceledException.java
@@ -0,0 +1,23 @@
+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.apache.tools.ant.BuildException;
+import org.eclipse.ui.externaltools.internal.core.ToolMessages;
+
+/**
+ * Exception to indicate the build was canceled.
+ */
+public class BuildCanceledException extends BuildException {
+
+ public BuildCanceledException() {
+ super(ToolMessages.getString("BuildCanceledException.canceled")); //$NON-NLS-1$;
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/ui/BuilderPropertyPage.java b/org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/ui/BuilderPropertyPage.java
new file mode 100644
index 000000000..39324251c
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/ui/BuilderPropertyPage.java
@@ -0,0 +1,425 @@
+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 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.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.viewers.ColumnWeightData;
+import org.eclipse.jface.viewers.TableLayout;
+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.graphics.ImageData;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.program.Program;
+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.TableColumn;
+import org.eclipse.swt.widgets.TableItem;
+import org.eclipse.ui.dialogs.PropertyPage;
+import org.eclipse.ui.externaltools.internal.core.ExternalTool;
+import org.eclipse.ui.externaltools.internal.core.ExternalToolsBuilder;
+import org.eclipse.ui.externaltools.internal.core.ExternalToolsPlugin;
+import org.eclipse.ui.externaltools.internal.core.ToolMessages;
+
+/**
+ * Property page to add tool scripts in between builders.
+ */
+public final class BuilderPropertyPage extends PropertyPage {
+ private Table builderTable;
+ private Button upButton, downButton, newButton, editButton, removeButton;
+ private ArrayList imagesToDispose = new ArrayList();
+ private Image antImage, builderImage;
+
+ /**
+ * 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();
+ for (int i = 0; i < commands.length; i++) {
+ 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);
+ }
+
+ /**
+ * 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);
+ dialog.open();
+ ExternalTool script = dialog.getExternalTool();
+ if (script == null) {
+ return null;
+ }
+ ICommand command = getInputProject().getDescription().newCommand();
+ return script.toBuildCommand(command);
+ } catch(CoreException e) {
+ handleException(e);
+ return null;
+ }
+ }
+
+ /**
+ * Edits an exisiting build command that invokes an external tool.
+ */
+ private void editTool(ICommand command) {
+ ExternalTool script = ExternalTool.fromArgumentMap(command.getArguments());
+ if (script == null)
+ return;
+ EditDialog dialog;
+ dialog = new EditDialog(getShell(), script);
+ dialog.open();
+ script = dialog.getExternalTool();
+ script.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.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) {
+ antImage = ExternalToolsPlugin.getDefault().getImageDescriptor(ExternalToolsPlugin.IMG_ANT_SCRIPT).createImage();
+ builderImage = ExternalToolsPlugin.getDefault().getImageDescriptor(ExternalToolsPlugin.IMG_BUILDER).createImage();
+ imagesToDispose.add(antImage);
+ imagesToDispose.add(builderImage);
+
+ 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 scripts
+ builderTable = new Table(tableAndButtons, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);
+ builderTable.setLayoutData(new GridData(GridData.FILL_BOTH));
+ TableLayout tableLayout = new TableLayout();
+ builderTable.setLayout(tableLayout);
+ TableColumn tc = new TableColumn(builderTable, SWT.NONE);
+ tc.setResizable(false);
+ tableLayout.addColumnData(new ColumnWeightData(100));
+ 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$
+ Label buttonSpacer = 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$
+
+ //populate widget contents
+ addBuildersToTable();
+
+ return topLevel;
+ }
+
+ /* (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();
+ }
+
+ /**
+ * 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) {
+ ICommand newCommand = createTool();
+ if (newCommand != null) {
+ int insertPosition = builderTable.getSelectionIndex() + 1;
+ addCommand(newCommand, insertPosition, true);
+ }
+ } else if (button == editButton) {
+ TableItem[] selection = builderTable.getSelection();
+ if (selection != null) {
+ editTool((ICommand)selection[0].getData());
+ updateCommandItem(selection[0],(ICommand)selection[0].getData());
+ }
+ } 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, ExternalToolsPlugin.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];
+ ICommand buildCommand = (ICommand)item.getData();
+ if (buildCommand.getBuilderName().equals(ExternalToolsBuilder.ID)) {
+ 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);
+ }
+
+ /**
+ * Returns the image to use for the given command line
+ * string. Returns a default image if none could be computed.
+ */
+ private Image imageForProgram(String commandLine) {
+ Image image = antImage;
+ int lastDot = commandLine.lastIndexOf('.');
+ String name = ""; //$NON-NLS-1$
+ if (lastDot > 0)
+ name = commandLine.substring(lastDot);
+ Program program = Program.findProgram(name);
+ if (program != null) {
+ ImageData data = program.getImageData();
+ if (data != null) {
+ image = new Image(getShell().getDisplay(), data);
+ imagesToDispose.add(image);
+ }
+ }
+ return image;
+ }
+
+ /**
+ * 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() {
+ //get all the build commands
+ int numCommands = builderTable.getItemCount();
+ ICommand[] commands = new ICommand[numCommands];
+ for (int i = 0; i < numCommands; i++) {
+ commands[i] = (ICommand)builderTable.getItem(i).getData();
+ }
+ //set the build spec
+ IProject project = getInputProject();
+ 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 builderName = command.getBuilderName();
+ if (builderName.equals(ExternalToolsBuilder.ID)) {
+ ExternalTool script = ExternalTool.fromArgumentMap(command.getArguments());
+ item.setText(script.getName());
+ if (script.TOOL_TYPE_ANT.equals(script.getType())) {
+ item.setImage(antImage);
+ } else {
+ Image image = imageForProgram(script.getLocation());
+ item.setImage(image);
+ }
+ } else {
+ item.setText(builderName);
+ item.setImage(builderImage);
+ }
+ }
+}
diff --git a/org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/ui/ConfigurationDialog.java b/org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/ui/ConfigurationDialog.java
new file mode 100644
index 000000000..bab72672a
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/ui/ConfigurationDialog.java
@@ -0,0 +1,324 @@
+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.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.TitleAreaDialog;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.ListViewer;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+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.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.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.externaltools.internal.core.ExternalTool;
+import org.eclipse.ui.externaltools.internal.core.ExternalToolsPlugin;
+import org.eclipse.ui.externaltools.internal.core.ToolMessages;
+import org.eclipse.ui.help.WorkbenchHelp;
+
+/**
+ * Dialog box to add, remove, and edit external tools.
+ */
+public class ConfigurationDialog extends TitleAreaDialog {
+ private ListViewer listViewer;
+ private Button newButton;
+ private Button editButton;
+ private Button removeButton;
+ private Button upButton;
+ private Button downButton;
+ private Text detailText;
+ private ExternalTool currentSelection;
+ private ArrayList tools;
+
+ /**
+ * Instantiate a new external tool configuration dialog.
+ *
+ * @param parentShell the parent SWT shell
+ */
+ public ConfigurationDialog(Shell parentShell) {
+ super(parentShell);
+ }
+
+ /* (non-Javadoc)
+ * Method declared in Window.
+ */
+ protected void configureShell(Shell shell) {
+ super.configureShell(shell);
+ shell.setText(ToolMessages.getString("ConfigurationDialog.shellTitle")); //$NON-NLS-1$
+ WorkbenchHelp.setHelp(
+ shell,
+ IHelpContextIds.CONFIGURE_DIALOG);
+ }
+
+ /* (non-Javadoc)
+ * Method declared on Dialog.
+ */
+ protected void createButtonsForButtonBar(Composite parent) {
+ createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
+ createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
+ }
+
+ /* (non-Javadoc)
+ * Method declared on Dialog.
+ */
+ protected Control createDialogArea(Composite parent) {
+ tools = new ArrayList(ExternalToolsPlugin.getDefault().getRegistry().getExternalTools());
+
+ Composite dialogComp = (Composite)super.createDialogArea(parent);
+
+ // Set title and message now that the controls exist
+ setTitle(ToolMessages.getString("ConfigurationDialog.dialogTitle")); //$NON-NLS-1$
+ setMessage(ToolMessages.getString("ConfigurationDialog.dialogMessage")); //$NON-NLS-1$
+
+ // Build the top container
+ Composite topComp = new Composite(dialogComp, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.marginHeight = 5;
+ layout.marginWidth = 5;
+ topComp.setLayout(layout);
+ GridData data = new GridData(GridData.FILL_BOTH);
+ topComp.setLayoutData(data);
+
+ // Build middle container with 2 columns
+ Composite midComp = new Composite(topComp, SWT.NONE);
+ layout = new GridLayout();
+ layout.numColumns = 2;
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
+ midComp.setLayout(layout);
+ data = new GridData(GridData.FILL_BOTH);
+ midComp.setLayoutData(data);
+
+ // Build the tools list
+ Composite listComp = new Composite(midComp, SWT.NONE);
+ layout = new GridLayout();
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
+ listComp.setLayout(layout);
+ data = new GridData(GridData.FILL_BOTH);
+ listComp.setLayoutData(data);
+
+ Label label = new Label(listComp, SWT.LEFT);
+ label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ label.setText(ToolMessages.getString("ConfigurationDialog.scriptList")); //$NON-NLS-1$
+
+ listViewer = new ListViewer(listComp, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
+ listViewer.getList().setLayoutData(new GridData(GridData.FILL_BOTH));
+ listViewer.setContentProvider(new ToolContentProvider());
+ listViewer.setLabelProvider(new ToolLabelProvider());
+ listViewer.setInput(tools);
+
+ // Build the button list
+ Composite buttonComp = new Composite(midComp, SWT.NONE);
+ layout = new GridLayout();
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
+ buttonComp.setLayout(layout);
+ data = new GridData(GridData.FILL_VERTICAL);
+ buttonComp.setLayoutData(data);
+
+ label = new Label(buttonComp, SWT.LEFT); // spacer
+ label.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
+ newButton = createPushButton(buttonComp, "ConfigurationDialog.newButton", true); //$NON-NLS-1$
+ editButton = createPushButton(buttonComp, "ConfigurationDialog.editButton", false); //$NON-NLS-1$
+ removeButton = createPushButton(buttonComp, "ConfigurationDialog.removeButton", false); //$NON-NLS-1$
+ label = new Label(buttonComp, SWT.LEFT); // spacer
+ label.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
+ upButton = createPushButton(buttonComp, "ConfigurationDialog.upButton", false); //$NON-NLS-1$
+ downButton = createPushButton(buttonComp, "ConfigurationDialog.downButton", false); //$NON-NLS-1$
+
+ // Build the details field
+ label = new Label(topComp, SWT.LEFT);
+ label.setText(ToolMessages.getString("ConfigurationDialog.details")); //$NON-NLS-1$
+ label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ detailText = new Text(topComp, SWT.WRAP | SWT.MULTI | SWT.V_SCROLL | SWT.BORDER);
+ detailText.setEditable(false);
+ detailText.setText("\n\n\n\n\n"); //$NON-NLS-1$
+ detailText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ // Build the separator line
+ Label separator = new Label(topComp, SWT.HORIZONTAL | SWT.SEPARATOR);
+ separator.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ // Finish setup
+ hookButtonActions();
+ hookStateUpdates();
+
+ return dialogComp;
+ }
+
+ private Button createPushButton(Composite parent, String labelKey, boolean enabled) {
+ Button button = new Button(parent, SWT.PUSH);
+ button.setText(ToolMessages.getString(labelKey));
+ button.setEnabled(enabled);
+
+ 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 button;
+ }
+
+ /**
+ * Adds the listeners required to handle the button
+ * actions
+ */
+ private void hookButtonActions() {
+ newButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ EditDialog dialog;
+ dialog = new EditDialog(getShell(), null);
+ dialog.open();
+ ExternalTool tool = dialog.getExternalTool();
+ tools.add(tool);
+ listViewer.add(tool);
+ listViewer.setSelection(new StructuredSelection(tool), true);
+ }
+ });
+
+ editButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ EditDialog dialog;
+ dialog = new EditDialog(getShell(), currentSelection);
+ dialog.open();
+ listViewer.update(currentSelection, null);
+ updateDetails();
+ }
+ });
+
+ removeButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ tools.remove(currentSelection);
+ listViewer.remove(currentSelection);
+ }
+ });
+
+ upButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ int index = tools.indexOf(currentSelection);
+ if (index < 1)
+ return;
+ Object tool = tools.get(index - 1);
+ tools.set(index - 1, currentSelection);
+ tools.set(index, tool);
+ listViewer.refresh(false);
+ updateUpDownButtons();
+ }
+ });
+
+ downButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ int index = tools.indexOf(currentSelection);
+ if (index < 0 || index >= tools.size() - 1)
+ return;
+ Object tool = tools.get(index + 1);
+ tools.set(index + 1, currentSelection);
+ tools.set(index, tool);
+ listViewer.refresh(false);
+ updateUpDownButtons();
+ }
+ });
+ }
+
+ /**
+ * Adds a listener to control button enablement based on
+ * the current selection.
+ */
+ private void hookStateUpdates() {
+ listViewer.addSelectionChangedListener(new ISelectionChangedListener() {
+ public void selectionChanged(SelectionChangedEvent event) {
+ currentSelection = null;
+ if (event.getSelection() instanceof IStructuredSelection) {
+ IStructuredSelection sel = (IStructuredSelection) event.getSelection() ;
+ currentSelection = (ExternalTool)sel.getFirstElement();
+ }
+
+ editButton.setEnabled(currentSelection != null);
+ removeButton.setEnabled(currentSelection != null);
+ updateUpDownButtons();
+ updateDetails();
+ }
+ });
+ }
+
+ /**
+ * Update the enable state of the up/down buttons
+ */
+ private void updateUpDownButtons() {
+ int selIndex = listViewer.getList().getSelectionIndex();
+ int itemCount = listViewer.getList().getItemCount();
+ upButton.setEnabled(currentSelection != null && selIndex > 0);
+ downButton.setEnabled(currentSelection != null && selIndex < itemCount - 1);
+ }
+
+ /**
+ * Update the detail field
+ */
+ private void updateDetails() {
+ if (currentSelection == null)
+ detailText.setText(""); //$NON-NLS-1$
+ else
+ detailText.setText(ToolMessages.format("ConfigurationDialog.detailMessage", new Object[] {currentSelection.getLocation(), currentSelection.getArguments(), currentSelection.getWorkingDirectory()})); //$NON-NLS-1$
+ }
+
+ /* (non-Javadoc)
+ * Method declared on Dialog.
+ */
+ protected void okPressed() {
+ ExternalToolsPlugin.getDefault().getRegistry().setExternalTools(tools);
+ super.okPressed();
+ }
+
+
+ /**
+ * Internal content provider of existing tool tools
+ */
+ private class ToolContentProvider implements IStructuredContentProvider {
+ public Object[] getElements(Object inputElement) {
+ return tools.toArray();
+ }
+
+ public void dispose() {
+ }
+
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ }
+ }
+
+ /**
+ * Internal label provider of existing tool tools
+ */
+ private class ToolLabelProvider extends LabelProvider {
+ public String getText(Object element) {
+ if (element instanceof ExternalTool)
+ return ((ExternalTool)element).getName();
+ else
+ return "";//$NON-NLS-1$
+ }
+ }
+}
diff --git a/org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/ui/EditDialog.java b/org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/ui/EditDialog.java
new file mode 100644
index 000000000..14e7bcb35
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/ui/EditDialog.java
@@ -0,0 +1,889 @@
+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.io.File;
+import java.util.*;
+
+import org.apache.tools.ant.*;
+import org.eclipse.core.resources.*;
+import org.eclipse.core.runtime.*;
+import org.eclipse.jface.dialogs.*;
+import org.eclipse.jface.viewers.*;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.ui.externaltools.internal.core.*;
+import org.eclipse.ui.*;
+import org.eclipse.ui.dialogs.*;
+import org.eclipse.ui.help.WorkbenchHelp;
+import org.eclipse.ui.model.*;
+import org.eclipse.swt.widgets.List;
+
+/**
+ * Dialog box to enter the required information for running
+ * an external tool.
+ */
+public class EditDialog extends TitleAreaDialog {
+ // The width of most text fields in the dialog.
+ // Fields that have labels on the same line are shorter.
+ // As such, all fields end in the same vertical position.
+ private static final int FIELD_WIDTH = 300;
+ // The spacing used to seperate groups in the dialog.
+ private static final int GROUP_SPACE = 20;
+ // The spacing used to seperate widgets in a group
+ private static final int WIDGET_SPACE = 5;
+ // The spacing of margins in the dialog
+ private static final int MARGIN_SPACE = 5;
+
+ // dialog sizing constants
+ private static final int SIZING_SELECTION_PANE_HEIGHT = 250;
+ private static final int SIZING_SELECTION_PANE_WIDTH = 300;
+
+ private static final boolean INITIAL_SHOW_LOG = true;
+
+ private Text nameField;
+ private Text locationField;
+ private Text argumentsField;
+ private Text directoryField;
+ private Text refreshField;
+ private Button locationBrowseWorkspace;
+ private Button locationBrowseFileSystem;
+ private Button argumentsBrowseVariable;
+ private Button directoryBrowseWorkspace;
+ private Button directoryBrowseFileSystem;
+ private Button refreshOptionButton;
+ private Button showLog;
+
+ private boolean editMode = false;
+ private ExternalTool tool;
+ private String refreshScope;
+
+ private int maxButtonWidth = 0;
+ // The difference between the height of a button and
+ // the height of a label.
+ private int buttonLabelHeightDiff;
+
+ /**
+ * Instantiate a new tool tool edit dialog.
+ *
+ * @param parentShell the parent SWT shell
+ * @param tool the tool tool to edit, <code>null</code> if new
+ */
+ public EditDialog(Shell parentShell, ExternalTool tool) {
+ super(parentShell);
+ if (tool == null) {
+ this.tool = new ExternalTool();
+ this.editMode = false;
+ } else {
+ this.tool = tool;
+ this.editMode = true;
+ }
+ }
+
+ /* (non-Javadoc)
+ * Method declared in Window.
+ */
+ protected void configureShell(Shell shell) {
+ super.configureShell(shell);
+ if (editMode)
+ shell.setText(ToolMessages.getString("EditDialog.editShellTitle")); //$NON-NLS-1$
+ else
+ shell.setText(ToolMessages.getString("EditDialog.newShellTitle")); //$NON-NLS-1$
+ WorkbenchHelp.setHelp(
+ shell,
+ IHelpContextIds.EDIT_DIALOG);
+ }
+
+ /* (non-Javadoc)
+ * Method declared on Dialog.
+ */
+ protected void createButtonsForButtonBar(Composite parent) {
+ createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
+ createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
+
+ if (!editMode)
+ getButton(IDialogConstants.OK_ID).setEnabled(false);
+ }
+
+ /* (non-Javadoc)
+ * Method declared on Dialog.
+ */
+ protected Control createDialogArea(Composite parent) {
+ Composite dialogComp = (Composite)super.createDialogArea(parent);
+
+ // Set title and message now that the controls exist
+ setTitle(ToolMessages.getString("EditDialog.dialogTitle")); //$NON-NLS-1$
+ if (editMode)
+ setMessage(ToolMessages.getString("EditDialog.editDialogMessage")); //$NON-NLS-1$
+ else
+ setMessage(ToolMessages.getString("EditDialog.newDialogMessage")); //$NON-NLS-1$
+
+ // Build the top container
+ Composite topComp = new Composite(dialogComp, SWT.NONE);
+ FormLayout layout = new FormLayout();
+ topComp.setLayout(layout);
+ layout.marginHeight = MARGIN_SPACE;
+ layout.marginWidth = MARGIN_SPACE;
+
+ // Need to keep track of the FormData's for the buttons to set
+ // the width of all the buttons to be the same as the largest
+ // button width
+ FormData[] buttonData = new FormData[6];
+
+ // Create name label
+ Label nameLabel = new Label(topComp, SWT.NONE);
+ nameLabel.setText(ToolMessages.getString("EditDialog.nameLabel")); //$NON-NLS-1$
+ FormData data = new FormData();
+ data.top = new FormAttachment(0, MARGIN_SPACE);
+ nameLabel.setLayoutData(data);
+
+ // Create name text field
+ nameField = new Text(topComp, SWT.BORDER);
+ data = new FormData();
+ data.left = new FormAttachment(nameLabel, MARGIN_SPACE, SWT.RIGHT);
+ data.top = new FormAttachment(nameLabel, 0, SWT.CENTER);
+ data.width = FIELD_WIDTH - MARGIN_SPACE - nameLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT, false).x;
+ nameField.setLayoutData(data);
+
+ // Create location browse workspace button
+ locationBrowseWorkspace = new Button(topComp, SWT.PUSH);
+ locationBrowseWorkspace.setText(ToolMessages.getString("EditDialog.browseWkspButton1")); //$NON-NLS-1$
+ buttonData[0] = new FormData();
+ buttonData[0].left = new FormAttachment(nameField, MARGIN_SPACE, SWT.RIGHT);
+ buttonData[0].top = new FormAttachment(nameField, GROUP_SPACE, SWT.BOTTOM);
+ locationBrowseWorkspace.setLayoutData(buttonData[0]);
+ checkForMaxWidth(locationBrowseWorkspace);
+
+ // Calculate the difference in height between a label and a button.
+ // This variable will be used to ensure equal spacing between groups.
+ buttonLabelHeightDiff = locationBrowseWorkspace.computeSize(SWT.DEFAULT, SWT.DEFAULT, false).y - nameLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT, false).y;
+
+ // Create label for location text field.
+ Label locationLabel = new Label(topComp, SWT.NONE);
+ locationLabel.setText(ToolMessages.getString("EditDialog.locationLabel")); //$NON-NLS-1$
+ data = new FormData();
+ data.bottom = new FormAttachment(locationBrowseWorkspace, 0, SWT.BOTTOM);
+ locationLabel.setLayoutData(data);
+
+ // Create location text field.
+ locationField = new Text(topComp, SWT.BORDER);
+ data = new FormData();
+ data.left = new FormAttachment(0, 0);
+ data.right = new FormAttachment(locationBrowseWorkspace, -MARGIN_SPACE, SWT.LEFT);
+ data.top = new FormAttachment(locationBrowseWorkspace, WIDGET_SPACE, SWT.BOTTOM);
+ data.width = FIELD_WIDTH;
+ locationField.setLayoutData(data);
+
+ // Create location browse file system button.
+ locationBrowseFileSystem = new Button(topComp, SWT.PUSH);
+ locationBrowseFileSystem.setText(ToolMessages.getString("EditDialog.browseFileSysButton1")); //$NON-NLS-1$
+ buttonData[1] = new FormData();
+ buttonData[1].left = new FormAttachment(locationBrowseWorkspace, 0, SWT.LEFT);
+ buttonData[1].top = new FormAttachment(locationBrowseWorkspace, WIDGET_SPACE, SWT.BOTTOM);
+ locationBrowseFileSystem.setLayoutData(buttonData[1]);
+ checkForMaxWidth(locationBrowseFileSystem);
+
+ // Create label for arguments text field.
+ Label argumentsLabel = new Label(topComp, SWT.NONE);
+ argumentsLabel.setText(ToolMessages.getString("EditDialog.argumentLabel")); //$NON-NLS-1$
+ data = new FormData();
+ data.top = new FormAttachment(locationField, GROUP_SPACE+buttonLabelHeightDiff, SWT.BOTTOM);
+ argumentsLabel.setLayoutData(data);
+
+ // Create arguments text field.
+ argumentsField = new Text(topComp, SWT.BORDER);
+ data = new FormData ();
+ data.left = new FormAttachment(0, 0);
+ data.right = new FormAttachment(locationBrowseFileSystem, -MARGIN_SPACE, SWT.LEFT);
+ data.top = new FormAttachment(argumentsLabel, WIDGET_SPACE, SWT.BOTTOM);
+ data.width = FIELD_WIDTH;
+ argumentsField.setLayoutData(data);
+
+ // Create argument browse variable button.
+ argumentsBrowseVariable = new Button(topComp, SWT.PUSH);
+ argumentsBrowseVariable.setText(ToolMessages.getString("EditDialog.browseVarsButton")); //$NON-NLS-1$
+ buttonData[2] = new FormData();
+ buttonData[2].left = new FormAttachment(locationBrowseFileSystem, 0, SWT.LEFT);
+ buttonData[2].bottom = new FormAttachment(argumentsField, 0, SWT.BOTTOM);
+ argumentsBrowseVariable.setLayoutData(buttonData[2]);
+ checkForMaxWidth(argumentsBrowseVariable);
+
+ // Create directory browse workspace button.
+ directoryBrowseWorkspace = new Button(topComp, SWT.PUSH);
+ directoryBrowseWorkspace.setText(ToolMessages.getString("EditDialog.browseWkspButton2")); //$NON-NLS-1$
+ buttonData[3] = new FormData();
+ buttonData[3].left = new FormAttachment(argumentsBrowseVariable, 0, SWT.LEFT);
+ buttonData[3].top = new FormAttachment(argumentsBrowseVariable, GROUP_SPACE, SWT.BOTTOM);
+ directoryBrowseWorkspace.setLayoutData(buttonData[3]);
+ checkForMaxWidth(directoryBrowseWorkspace);
+
+ // Create label for directory text field.
+ Label dirLabel = new Label(topComp, SWT.NONE);
+ dirLabel.setText(ToolMessages.getString("EditDialog.dirLabel")); //$NON-NLS-1$
+ data = new FormData();
+ data.bottom = new FormAttachment(directoryBrowseWorkspace, 0, SWT.BOTTOM);
+ dirLabel.setLayoutData(data);
+
+ // Create directory text field.
+ directoryField = new Text(topComp, SWT.BORDER);
+ data = new FormData();
+ data.left = new FormAttachment(0, 0);
+ data.right = new FormAttachment(directoryBrowseWorkspace, -MARGIN_SPACE, SWT.LEFT);
+ data.top = new FormAttachment(directoryBrowseWorkspace, WIDGET_SPACE, SWT.BOTTOM);
+ data.width = FIELD_WIDTH;
+ directoryField.setLayoutData(data);
+
+ // Create directory browse file system button.
+ directoryBrowseFileSystem = new Button(topComp, SWT.PUSH);
+ directoryBrowseFileSystem.setText(ToolMessages.getString("EditDialog.browseFileSysButton2")); //$NON-NLS-1$
+ buttonData[4] = new FormData();
+ buttonData[4].left = new FormAttachment(argumentsField, MARGIN_SPACE, SWT.RIGHT);
+ buttonData[4].bottom = new FormAttachment(directoryField, 0, SWT.BOTTOM);
+ directoryBrowseFileSystem.setLayoutData(buttonData[4]);
+ checkForMaxWidth(directoryBrowseFileSystem);
+
+ // Create refresh check box and label.
+ Label refreshLabel = new Label(topComp, SWT.NONE);
+ refreshLabel.setText(ToolMessages.getString("EditDialog.refreshOption")); //$NON-NLS-1$
+ data = new FormData();
+ data.left = new FormAttachment(0,0);
+ data.top = new FormAttachment(directoryField, GROUP_SPACE+buttonLabelHeightDiff, SWT.BOTTOM);
+ refreshLabel.setLayoutData(data);
+
+ // Create refresh text field.
+ refreshField = new Text(topComp, SWT.SINGLE | SWT.H_SCROLL | SWT.BORDER);
+ refreshField.setEditable(false);
+ data = new FormData();
+ data.left = new FormAttachment(refreshLabel, MARGIN_SPACE, SWT.RIGHT);
+ data.top = new FormAttachment(refreshLabel, 0, SWT.CENTER);
+ data.width = FIELD_WIDTH - MARGIN_SPACE - refreshLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT, false).x;
+ refreshField.setLayoutData(data);
+
+ // Create refresh scope.
+ refreshOptionButton = new Button(topComp, SWT.PUSH);
+ refreshOptionButton.setText(ToolMessages.getString("EditDialog.refreshOptionButton")); //$NON-NLS-1$
+ buttonData[5] = new FormData();
+ buttonData[5].left = new FormAttachment(directoryBrowseFileSystem, 0, SWT.LEFT);
+ buttonData[5].top = new FormAttachment(refreshField, 0, SWT.TOP);
+ refreshOptionButton.setLayoutData(buttonData[5]);
+
+ // Create show log checkbox
+ showLog = new Button(topComp, SWT.CHECK);
+ showLog.setText(ToolMessages.getString("EditDialog.showLogLabel")); //$NON-NLS-1$
+ showLog.setSelection(INITIAL_SHOW_LOG);
+ data = new FormData();
+ data.left = new FormAttachment(0,0);
+ data.top = new FormAttachment(refreshField, GROUP_SPACE, SWT.BOTTOM);
+ showLog.setLayoutData(data);
+
+ // give all the buttons the same width
+ for (int i=0; i<buttonData.length; i++) {
+ buttonData[i].width = maxButtonWidth;
+ }
+
+ // Build the separator line
+ Label separator = new Label(dialogComp, SWT.HORIZONTAL | SWT.SEPARATOR);
+ separator.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ // Init field values
+ if (editMode) {
+ nameField.setText(tool.getName());
+ locationField.setText(tool.getLocation());
+ argumentsField.setText(tool.getArguments());
+ directoryField.setText(tool.getWorkingDirectory());
+ showLog.setSelection(tool.getShowLog());
+ }
+ refreshScope = tool.getRefreshScope();
+ updateRefreshField();
+
+ // Set the proper tab order
+ Control[] tabList = new Control[] {
+ nameField,
+ locationField,
+ locationBrowseWorkspace,
+ locationBrowseFileSystem,
+ argumentsField,
+ argumentsBrowseVariable,
+ directoryField,
+ directoryBrowseWorkspace,
+ directoryBrowseFileSystem,
+ refreshField,
+ refreshOptionButton};
+ topComp.setTabList(tabList);
+
+ // Finish setup
+ hookButtonActions();
+ hookFieldValidation();
+ nameField.setFocus();
+
+ return dialogComp;
+ }
+
+ /**
+ * Check to see if the supplied button has the maximum width of
+ * all the buttons so far. If it is, store the width in
+ * the integer variable <code>maxButtonWidth</code>.
+ */
+ private void checkForMaxWidth(Button button) {
+ Point size = button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
+ if (size.x > maxButtonWidth)
+ maxButtonWidth = size.x;
+ }
+
+ /**
+ * Returns the tool tool applicable to this dialog.
+ */
+ public ExternalTool getExternalTool() {
+ return tool;
+ }
+
+ /**
+ * Hooks the action handler for when a button is pressed
+ */
+ private void hookButtonActions() {
+ locationBrowseWorkspace.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ ResourceSelectionDialog dialog;
+ dialog = new ResourceSelectionDialog(getShell(), ResourcesPlugin.getWorkspace().getRoot());
+ dialog.open();
+ Object[] results = dialog.getResult();
+ if (results == null || results.length < 1)
+ return;
+ IResource resource = (IResource)results[0];
+ String var = ToolUtil.buildVariableTag(ExternalTool.VAR_DIR_WORKSPACE, null);
+ locationField.setText(var + resource.getFullPath());
+ }
+ });
+
+ locationBrowseFileSystem.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ FileDialog dialog = new FileDialog(getShell(), SWT.NONE);
+ dialog.setFileName(locationField.getText());
+ String filename = dialog.open();
+ if (filename != null) {
+ locationField.setText(filename);
+ }
+ }
+ });
+
+ argumentsBrowseVariable.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ VariableSelectionDialog dialog;
+ dialog = new VariableSelectionDialog(getShell());
+ dialog.open();
+ Object[] results = dialog.getResult();
+ if (results == null || results.length < 1)
+ return;
+ String args = argumentsField.getText();
+ args = args + (String)results[0];
+ argumentsField.setText(args);
+ }
+ });
+
+ directoryBrowseWorkspace.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ ContainerSelectionDialog dialog = new ContainerSelectionDialog(
+ getShell(),
+ ResourcesPlugin.getWorkspace().getRoot(),
+ false,
+ ToolMessages.getString("EditDialog.selectFolder")); //$NON-NLS-1$
+ dialog.showClosedProjects(false);
+ dialog.setTitle(ToolMessages.getString("EditDialog.browseWorkspaceTitle")); //$NON-NLS-1$
+ dialog.open();
+ Object[] result = dialog.getResult();
+ if (result != null && result.length == 1) {
+ StringBuffer buf = new StringBuffer();
+ ToolUtil.buildVariableTag(ExternalTool.VAR_DIR_WORKSPACE, null, buf);
+ buf.append(result[0].toString());
+ directoryField.setText(buf.toString());
+ }
+ }
+ });
+
+ directoryBrowseFileSystem.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ DirectoryDialog dialog = new DirectoryDialog(getShell(), SWT.SAVE);
+ dialog.setMessage(ToolMessages.getString("EditDialog.selectDirectory")); //$NON-NLS-1$
+ dialog.setFilterPath(directoryField.getText());
+ String selectedDirectory = dialog.open();
+ if (selectedDirectory != null) {
+ directoryField.setText(selectedDirectory);
+ }
+ }
+ });
+
+ refreshOptionButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ RefreshSelectionDialog dialog;
+ dialog = new RefreshSelectionDialog(getShell());
+ dialog.open();
+ Object[] results = dialog.getResult();
+ if (results == null || results.length < 1)
+ return;
+ refreshScope = (String)results[0];
+ updateRefreshField();
+ }
+ });
+ }
+
+ /**
+ * Hooks the necessary field validation
+ */
+ private void hookFieldValidation() {
+ nameField.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ validateFields();
+ }
+ });
+
+ locationField.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ validateFields();
+ }
+ });
+
+ directoryField.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ validateFields();
+ }
+ });
+ }
+
+ /**
+ * Validate the fields for acceptable values
+ */
+ private void validateFields() {
+ String value = nameField.getText().trim();
+ if (value.length() < 1) {
+ setMessage(ToolMessages.getString("EditDialog.noScriptName"), IMessageProvider.NONE); //$NON-NLS-1$
+ getButton(IDialogConstants.OK_ID).setEnabled(false);
+ return;
+ }
+
+ value = locationField.getText().trim();
+ if (value.length() < 1) {
+ setMessage(ToolMessages.getString("EditDialog.noScriptLocation"), IMessageProvider.NONE); //$NON-NLS-1$
+ getButton(IDialogConstants.OK_ID).setEnabled(false);
+ return;
+ }
+
+ getButton(IDialogConstants.OK_ID).setEnabled(true);
+
+ File file = new File(value);
+ if (!file.exists()) {
+ setMessage(ToolMessages.getString("EditDialog.missingScriptLocation"), IMessageProvider.WARNING); //$NON-NLS-1$
+ return;
+ }
+
+ value = directoryField.getText().trim();
+ if (value.length() > 0) {
+ file = new File(value);
+ if (!file.exists()) {
+ setMessage(ToolMessages.getString("EditDialog.missingScriptDirectory"), IMessageProvider.WARNING); //$NON-NLS-1$
+ return;
+ }
+ }
+
+ if (editMode)
+ setMessage(ToolMessages.getString("EditDialog.editDialogMessage")); //$NON-NLS-1$
+ else
+ setMessage(ToolMessages.getString("EditDialog.newDialogMessage")); //$NON-NLS-1$
+ }
+
+ /* (non-Javadoc)
+ * Method declared on Dialog.
+ */
+ protected void okPressed() {
+ String command = locationField.getText().trim();
+ if (command.endsWith(".xml")) //$NON-NLS-1$
+ tool.setType(tool.TOOL_TYPE_ANT);
+ else
+ tool.setType(tool.TOOL_TYPE_PROGRAM);
+ tool.setName(nameField.getText().trim());
+ tool.setLocation(command);
+ tool.setArguments(argumentsField.getText().trim());
+ tool.setWorkingDirectory(directoryField.getText().trim());
+ tool.setRefreshScope(refreshScope);
+ tool.setShowLog(showLog.getSelection());
+
+ super.okPressed();
+ }
+
+ /**
+ * Update the refresh scope field
+ */
+ private void updateRefreshField() {
+ ToolUtil.VariableDefinition result = ToolUtil.extractVariableTag(refreshScope, 0);
+ if (result.name == null) {
+ refreshScope = ToolUtil.buildVariableTag(tool.REFRESH_SCOPE_NONE, null);
+ result.name = tool.REFRESH_SCOPE_NONE;
+ }
+
+ if (tool.REFRESH_SCOPE_NONE.equals(result.name)) {
+ refreshField.setText(ToolMessages.getString("EditDialog.refreshScopeNone")); //$NON-NLS-1$
+ return;
+ }
+ if (tool.REFRESH_SCOPE_WORKSPACE.equals(result.name)) {
+ refreshField.setText(ToolMessages.getString("EditDialog.refreshScopeWorkspace")); //$NON-NLS-1$
+ return;
+ }
+ if (tool.REFRESH_SCOPE_PROJECT.equals(result.name)) {
+ if (result.argument == null)
+ refreshField.setText(ToolMessages.getString("EditDialog.refreshScopeProject")); //$NON-NLS-1$
+ else
+ refreshField.setText(ToolMessages.format("EditDialog.refreshScopeProjectX", new Object[] {result.argument})); //$NON-NLS-1$
+ return;
+ }
+ if (tool.REFRESH_SCOPE_WORKING_SET.equals(result.name)) {
+ if (result.argument == null) {
+ refreshScope = ToolUtil.buildVariableTag(tool.REFRESH_SCOPE_NONE, null);
+ refreshField.setText(ToolMessages.getString("EditDialog.refreshScopeNone")); //$NON-NLS-1$
+ }
+ else
+ refreshField.setText(ToolMessages.format("EditDialog.refreshScopeWorkingSet", new Object[] {result.argument})); //$NON-NLS-1$
+ return;
+ }
+ }
+
+ /**
+ * Internal dialog to show available resources from which
+ * the user can select one
+ */
+ private class ResourceSelectionDialog extends SelectionDialog {
+ IContainer root;
+ TreeViewer wsTree;
+
+ public ResourceSelectionDialog(Shell parent, IContainer root) {
+ super(parent);
+ this.root = root;
+ setShellStyle(getShellStyle() | SWT.RESIZE);
+ setTitle(ToolMessages.getString("EditDialog.browseWorkspaceTitle")); //$NON-NLS-1$
+ }
+
+ /* (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(ToolMessages.getString("EditDialog.selectResource")); //$NON-NLS-1$
+
+ Tree tree = new Tree(dialogArea, SWT.H_SCROLL | SWT.V_SCROLL | SWT.SINGLE | SWT.BORDER);
+ GridData data = new GridData(GridData.FILL_BOTH);
+ data.heightHint = SIZING_SELECTION_PANE_HEIGHT;
+ data.widthHint = SIZING_SELECTION_PANE_WIDTH;
+ 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();
+ }
+ }
+
+
+ /**
+ * Internal dialog to show available variables from which
+ * the user can select one.
+ */
+ private class VariableSelectionDialog extends SelectionDialog {
+ List list;
+
+ public VariableSelectionDialog(Shell parent) {
+ super(parent);
+ setTitle(ToolMessages.getString("EditDialog.browseVarTitle")); //$NON-NLS-1$
+ }
+
+ /* (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(ToolMessages.getString("EditDialog.selectVar")); //$NON-NLS-1$
+
+ list = new List(dialogArea, SWT.H_SCROLL | SWT.V_SCROLL | SWT.SINGLE | SWT.BORDER);
+ GridData data = new GridData(GridData.FILL_BOTH);
+ data.heightHint = SIZING_SELECTION_PANE_HEIGHT;
+ data.widthHint = SIZING_SELECTION_PANE_WIDTH;
+ list.setLayoutData(data);
+
+ list.add(ToolMessages.getString("EditDialog.varWorkspaceDirLabel")); //$NON-NLS-1$
+ list.add(ToolMessages.getString("EditDialog.varProjectDirLabel")); //$NON-NLS-1$
+ list.add(ToolMessages.getString("EditDialog.varProjectXDirLabel")); //$NON-NLS-1$
+
+ Path path = new Path(locationField.getText().trim());
+ Project project = AntUtil.createAntProject(path);
+ if (project != null)
+ list.add(ToolMessages.getString("EditDialog.varAntTargetLabel")); //$NON-NLS-1$
+
+ return dialogArea;
+ }
+
+ /* (non-Javadoc)
+ * Method declared on Dialog.
+ */
+ protected void okPressed() {
+ int sel = list.getSelectionIndex();
+ String result = null;
+
+ switch (sel) {
+ case 0 :
+ result = ToolUtil.buildVariableTag(ExternalTool.VAR_DIR_WORKSPACE, null);
+ break;
+
+ case 1 :
+ result = ToolUtil.buildVariableTag(ExternalTool.VAR_DIR_PROJECT, null);
+ break;
+
+ case 2 :
+ ProjectSelectionDialog dialog;
+ dialog = new ProjectSelectionDialog(getShell());
+ dialog.open();
+ Object[] name = dialog.getResult();
+ if (name != null && name.length > 0)
+ result = ToolUtil.buildVariableTag(ExternalTool.VAR_DIR_PROJECT, (String)name[0]);
+ break;
+
+ case 3 :
+ TargetSelectionDialog targetDialog;
+ targetDialog = new TargetSelectionDialog(getShell(), locationField.getText().trim());
+ targetDialog.open();
+ Object[] targets = targetDialog.getResult();
+ if (targets != null && targets.length > 0) {
+ StringBuffer buf = new StringBuffer();
+ ToolUtil.buildVariableTags(ExternalTool.VAR_ANT_TARGET, (String[])targets, buf);
+ result = buf.toString().trim();
+ }
+ break;
+ }
+
+ if (result != null)
+ setSelectionResult(new Object[] {result});
+ super.okPressed();
+ }
+ }
+
+ /**
+ * Internal dialog to show available refresh scope from which
+ * the user can select one.
+ */
+ private class RefreshSelectionDialog extends SelectionDialog {
+ List list;
+
+ public RefreshSelectionDialog(Shell parent) {
+ super(parent);
+ setTitle(ToolMessages.getString("EditDialog.browseRefreshTitle")); //$NON-NLS-1$
+ }
+
+ /* (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(ToolMessages.getString("EditDialog.selectRefresh")); //$NON-NLS-1$
+
+ list = new List(dialogArea, SWT.H_SCROLL | SWT.V_SCROLL | SWT.SINGLE | SWT.BORDER);
+ GridData data = new GridData(GridData.FILL_BOTH);
+ data.heightHint = SIZING_SELECTION_PANE_HEIGHT;
+ data.widthHint = SIZING_SELECTION_PANE_WIDTH;
+ list.setLayoutData(data);
+
+ list.add(ToolMessages.getString("EditDialog.refreshNothingLabel")); //$NON-NLS-1$
+ list.add(ToolMessages.getString("EditDialog.refreshWorkspaceLabel")); //$NON-NLS-1$
+ list.add(ToolMessages.getString("EditDialog.refreshProjectLabel")); //$NON-NLS-1$
+ list.add(ToolMessages.getString("EditDialog.refreshProjectXLabel")); //$NON-NLS-1$
+ list.add(ToolMessages.getString("EditDialog.refreshWorkingSetLabel")); //$NON-NLS-1$
+
+ return dialogArea;
+ }
+
+ /* (non-Javadoc)
+ * Method declared on Dialog.
+ */
+ protected void okPressed() {
+ int sel = list.getSelectionIndex();
+ String result = null;
+
+ switch (sel) {
+ case 0 :
+ result = ToolUtil.buildVariableTag(ExternalTool.REFRESH_SCOPE_NONE, null);
+ break;
+
+ case 1 :
+ result = ToolUtil.buildVariableTag(ExternalTool.REFRESH_SCOPE_WORKSPACE, null);
+ break;
+
+ case 2 :
+ result = ToolUtil.buildVariableTag(ExternalTool.REFRESH_SCOPE_PROJECT, null);
+ break;
+
+ case 3 :
+ ProjectSelectionDialog prjDialog;
+ prjDialog = new ProjectSelectionDialog(getShell());
+ prjDialog.open();
+ Object[] name = prjDialog.getResult();
+ if (name != null && name.length > 0)
+ result = ToolUtil.buildVariableTag(ExternalTool.REFRESH_SCOPE_PROJECT, (String)name[0]);
+ break;
+
+ case 4 :
+ IWorkingSetSelectionDialog setDialog;
+ setDialog = PlatformUI.getWorkbench().getWorkingSetManager().createWorkingSetSelectionDialog(getShell(), false);
+ setDialog.open();
+ IWorkingSet[] sets = setDialog.getSelection();
+ if (sets != null && sets.length > 0)
+ result = ToolUtil.buildVariableTag(ExternalTool.REFRESH_SCOPE_WORKING_SET, sets[0].getName());
+ break;
+ }
+
+ if (result != null)
+ setSelectionResult(new Object[] {result});
+ super.okPressed();
+ }
+ }
+
+ /**
+ * Internal dialog to show available projects from which
+ * the user can select one.
+ */
+ private class ProjectSelectionDialog extends SelectionDialog {
+ List list;
+
+ public ProjectSelectionDialog(Shell parent) {
+ super(parent);
+ setTitle(ToolMessages.getString("EditDialog.browseProjectTitle")); //$NON-NLS-1$
+ }
+
+ /* (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(ToolMessages.getString("EditDialog.selectProject")); //$NON-NLS-1$
+
+ list = new List(dialogArea, SWT.H_SCROLL | SWT.V_SCROLL | SWT.SINGLE | SWT.BORDER);
+ GridData data = new GridData(GridData.FILL_BOTH);
+ data.heightHint = SIZING_SELECTION_PANE_HEIGHT;
+ data.widthHint = SIZING_SELECTION_PANE_WIDTH;
+ list.setLayoutData(data);
+
+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+ IProject[] projects = root.getProjects();
+ for (int i = 0; i < projects.length; i++) {
+ list.add(projects[i].getName());
+ }
+
+ return dialogArea;
+ }
+
+ /* (non-Javadoc)
+ * Method declared on Dialog.
+ */
+ protected void okPressed() {
+ setSelectionResult(list.getSelection());
+ super.okPressed();
+ }
+ }
+
+ private class TargetSelectionDialog extends SelectionDialog implements ICheckStateListener {
+ private ArrayList selectedTargets = new ArrayList();
+ private CheckboxTableViewer listViewer;
+ private Project project;
+ private AntTargetLabelProvider labelProvider = new AntTargetLabelProvider();
+
+ public TargetSelectionDialog(Shell parent, String location) {
+ super(parent);
+ IPath path = new Path(location);
+ project = AntUtil.createAntProject(path);
+ setTitle(ToolMessages.getString("EditDialog.varAntTargetLabel")); //$NON-NLS-1$
+ }
+
+ public void checkStateChanged(CheckStateChangedEvent e) {
+ Target checkedTarget = (Target)e.getElement();
+ if (e.getChecked())
+ selectedTargets.add(checkedTarget);
+ else
+ selectedTargets.remove(checkedTarget);
+
+ labelProvider.setSelectedTargets(selectedTargets);
+ listViewer.refresh();
+ }
+
+ protected Control createDialogArea(Composite parent) {
+ Composite dialogArea = (Composite)super.createDialogArea(parent);
+
+ Label label = new Label(dialogArea, SWT.LEFT);
+ label.setText(ToolMessages.getString("EditDialog.selectTargets")); //$NON-NLS-1$
+
+ listViewer = CheckboxTableViewer.newCheckList(dialogArea, SWT.BORDER);
+ GridData data = new GridData(GridData.FILL_BOTH);
+ data.heightHint = SIZING_SELECTION_PANE_HEIGHT;
+ data.widthHint = SIZING_SELECTION_PANE_WIDTH;
+ listViewer.getTable().setLayoutData(data);
+ listViewer.setSorter(new ViewerSorter() {
+ public int compare(Viewer viewer,Object o1,Object o2) {
+ return ((Target)o1).getName().compareTo(((Target)o2).getName());
+ }
+ });
+
+ if (project != null && project.getDefaultTarget() != null)
+ labelProvider.setDefaultTargetName(project.getDefaultTarget());
+ listViewer.setLabelProvider(labelProvider);
+ listViewer.setContentProvider(new AntTargetContentProvider());
+ listViewer.setInput(project);
+
+ listViewer.addCheckStateListener(this);
+ listViewer.refresh();
+
+ return dialogArea;
+ }
+
+ /* (non-Javadoc)
+ * Method declared on Dialog.
+ */
+ protected void okPressed() {
+ setSelectionResult(getTargetNames());
+ super.okPressed();
+ }
+
+ protected String[] getTargetNames() {
+ String[] result = new String[selectedTargets.size()];
+ for (int i = 0; i < selectedTargets.size(); i++)
+ result[i] = ((Target) selectedTargets.get(i)).getName();
+ return result;
+ }
+ }
+
+}
diff --git a/org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/ui/ExternalToolsAction.java b/org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/ui/ExternalToolsAction.java
new file mode 100644
index 000000000..202b5f72c
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/ui/ExternalToolsAction.java
@@ -0,0 +1,179 @@
+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.apache.tools.ant.BuildListener;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IMenuCreator;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.dialogs.MessageDialog;
+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.IWorkbenchWindow;
+import org.eclipse.ui.IWorkbenchWindowPulldownDelegate2;
+import org.eclipse.ui.actions.ActionDelegate;
+import org.eclipse.ui.externaltools.internal.core.DefaultRunnerContext;
+import org.eclipse.ui.externaltools.internal.core.ExternalTool;
+import org.eclipse.ui.externaltools.internal.core.ExternalToolsPlugin;
+import org.eclipse.ui.externaltools.internal.core.ToolMessages;
+
+/**
+ * This action will display the external tool configuration dialog.
+ * In addition, as a tool bar item, it's drop down list will include
+ * tools to run directly.
+ */
+public class ExternalToolsAction extends ActionDelegate implements IWorkbenchWindowPulldownDelegate2, IMenuCreator {
+ private IWorkbenchWindow window;
+ private IAction realAction;
+
+ /**
+ * Creates the external tool configure action
+ */
+ public ExternalToolsAction() {
+ super();
+ }
+
+ /* (non-Javadoc)
+ * Method declared on IActionDelegate.
+ */
+ public void run(IAction action) {
+ if (action.isEnabled())
+ showConfigurationDialog();
+ }
+
+ /* (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 for each tool in the history
+ ArrayList tools = ExternalToolsPlugin.getDefault().getRegistry().getExternalTools();
+ if (tools.size() > 0) {
+ for (int i = 0; i < tools.size(); i++) {
+ ExternalTool tool = (ExternalTool)tools.get(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 to edit the configurations
+ MenuItem item = new MenuItem(menu, SWT.NONE);
+ item.setText(ToolMessages.getString("ExternalToolsAction.configure")); //$NON-NLS-1$
+ item.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ showConfigurationDialog();
+ }
+ });
+ }
+
+ /**
+ * Runs the specified tool
+ */
+ private void runTool(ExternalTool tool) {
+ if (tool == null)
+ return;
+
+ DefaultRunnerContext context = new DefaultRunnerContext(tool, null, window.getWorkbench().getWorkingSetManager());
+ context.run(null, window.getShell());
+ }
+
+ /**
+ * Shows the tool configuration dialog
+ */
+ private void showConfigurationDialog() {
+ ConfigurationDialog dialog;
+ dialog = new ConfigurationDialog(window.getShell());
+ dialog.open();
+ }
+}
diff --git a/org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/ui/IHelpContextIds.java b/org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/ui/IHelpContextIds.java
new file mode 100644
index 000000000..f5e44e773
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/ui/IHelpContextIds.java
@@ -0,0 +1,26 @@
+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:
+**********************************************************************/
+
+/**
+ * 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$
+
+ // Dialogs
+ public static final String CONFIGURE_DIALOG = PREFIX + "configure_dialog_context"; //$NON-NLS-1$
+ public static final String EDIT_DIALOG = PREFIX + "edit_dialog_context"; //$NON-NLS-1$
+}
diff --git a/org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/ui/LogConsoleDocument.java b/org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/ui/LogConsoleDocument.java
new file mode 100644
index 000000000..ab90e8380
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/ui/LogConsoleDocument.java
@@ -0,0 +1,195 @@
+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.apache.tools.ant.Project;
+import org.eclipse.jface.preference.PreferenceConverter;
+import org.eclipse.jface.text.*;
+import org.eclipse.jface.text.Document;
+import org.eclipse.swt.custom.StyleRange;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.externaltools.internal.core.ExternalToolsPlugin;
+import org.eclipse.ui.externaltools.internal.core.IPreferenceConstants;
+import org.eclipse.ui.externaltools.internal.core.ToolMessages;
+
+/**
+ * Holds onto messages generated by the execution on an
+ * external tool.
+ */
+public class LogConsoleDocument {
+ // class variables that handle the colors and the font
+ static Color ERROR_COLOR;
+ static Color WARN_COLOR;
+ static Color INFO_COLOR;
+ static Color VERBOSE_COLOR;
+ static Color DEBUG_COLOR;
+ static Font ANT_FONT;
+
+ // class variables that handle the colors and the font;
+ private static AntPropertyChangeListener changeListener = AntPropertyChangeListener.getInstance();
+ private static LogConsoleDocument instance = null;
+
+ /*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() {
+ document = new Document();
+ styleRanges = new ArrayList(5);
+ initializeOutputStructure();
+ }
+
+ public void append(String message, int priority) {
+
+ for (int i=0; i < views.size(); i++) {
+ ((LogConsoleView)views.get(i)).append(message, priority);
+ }
+ }
+
+ private void addRangeStyle(int start, int length, Color color) {
+ 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() {
+ //
+ }
+
+ 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.isEmpty();
+ }
+
+ 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 colors and register the listener
+ ERROR_COLOR = new Color(null, PreferenceConverter.getColor(ExternalToolsPlugin.getDefault().getPreferenceStore(),IPreferenceConstants.CONSOLE_ERROR_RGB));
+ WARN_COLOR = new Color(null, PreferenceConverter.getColor(ExternalToolsPlugin.getDefault().getPreferenceStore(),IPreferenceConstants.CONSOLE_WARNING_RGB));
+ INFO_COLOR = new Color(null, PreferenceConverter.getColor(ExternalToolsPlugin.getDefault().getPreferenceStore(),IPreferenceConstants.CONSOLE_INFO_RGB));
+ VERBOSE_COLOR = new Color(null, PreferenceConverter.getColor(ExternalToolsPlugin.getDefault().getPreferenceStore(),IPreferenceConstants.CONSOLE_VERBOSE_RGB));
+ DEBUG_COLOR = new Color(null, PreferenceConverter.getColor(ExternalToolsPlugin.getDefault().getPreferenceStore(),IPreferenceConstants.CONSOLE_DEBUG_RGB));
+ 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 colors as well and remove the property listener
+ ERROR_COLOR.dispose();
+ WARN_COLOR.dispose();
+ INFO_COLOR.dispose();
+ VERBOSE_COLOR.dispose();
+ DEBUG_COLOR.dispose();
+ ANT_FONT.dispose();
+
+ ExternalToolsPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(changeListener);
+ }
+ }
+
+ public static LogConsoleDocument getInstance() {
+ if (instance == null)
+ instance = new LogConsoleDocument();
+ 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 Project.MSG_ERR:
+ addRangeStyle(start, end, LogConsoleDocument.ERROR_COLOR);
+ break;
+ case Project.MSG_WARN:
+ addRangeStyle(start, end, LogConsoleDocument.WARN_COLOR);
+ break;
+ case Project.MSG_INFO:
+ addRangeStyle(start, end, LogConsoleDocument.INFO_COLOR);
+ break;
+ case Project.MSG_VERBOSE:
+ addRangeStyle(start, end, LogConsoleDocument.VERBOSE_COLOR);
+ break;
+ case Project.MSG_DEBUG:
+ addRangeStyle(start, end, LogConsoleDocument.DEBUG_COLOR);
+ break;
+ default:
+ addRangeStyle(start, end, LogConsoleDocument.INFO_COLOR);
+ }
+}
+
+}
diff --git a/org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/ui/LogConsoleView.java b/org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/ui/LogConsoleView.java
new file mode 100644
index 000000000..0f32437d5
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools/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.*; import java.util.*; import java.util.Vector; import org.apache.tools.ant.Project; import org.eclipse.jface.action.*; import org.eclipse.jface.preference.PreferenceConverter; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.text.*; import org.eclipse.jface.viewers.*; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.*; import org.eclipse.swt.events.*; import org.eclipse.swt.graphics.*; import org.eclipse.swt.layout.*; import org.eclipse.swt.widgets.*; import org.eclipse.ui.*; import org.eclipse.ui.externaltools.internal.core.ExternalToolsPlugin; import org.eclipse.ui.externaltools.internal.core.ToolMessages; import org.eclipse.ui.part.ViewPart; import org.eclipse.ui.texteditor.*; public class LogConsoleView extends ViewPart { public final static String PROPERTY_PREFIX_FIND = "find_action."; // $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 AntTreeLabelProvider labelprovider; private AntTreeContentProvider 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 AntTreeLabelProvider(this); contentProvider = new AntTreeContentProvider(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, Project.MSG_INFO); } public void append(final String value, final int ouputLevel) { getViewSite().getShell().getDisplay().syncExec(new Runnable() { public void run() { int start = getDocument().get().length(); getDocument().set(getDocument().get() + value); setOutputLevelColor(ouputLevel, start, value.length()); if (value.length() > 0 && textViewer != null) textViewer.revealRange(getDocument().get().length() - 1, 1); } }); } private void setOutputLevelColor(int level, int start, int end) { LogConsoleDocument.getInstance().setOutputLevelColor(level, start, end); } protected void copySelectionToClipboard() { textViewer.doOperation(textViewer.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, treeViewer.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.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()); } } 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(textViewer.COPY)); selectAllAction.setEnabled(textViewer.canDoOperation(textViewer.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(textViewer.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.setWeights(new int[] { 0, 100 }); createActions(); addContributions(); } 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 "Ant Script" 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/org/eclipse/ui/externaltools/internal/ui/OutputStructureElement.java b/org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/ui/OutputStructureElement.java
new file mode 100644
index 000000000..f63e8c119
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/ui/OutputStructureElement.java
@@ -0,0 +1,103 @@
+/**********************************************************************
+ * 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.*;
+import java.util.Vector;
+
+/**
+ * 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/org/eclipse/ui/externaltools/internal/ui/ant/AntBuildLogger.java b/org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/ui/ant/AntBuildLogger.java
new file mode 100644
index 000000000..f3533b769
--- /dev/null
+++ b/org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/ui/ant/AntBuildLogger.java
@@ -0,0 +1,178 @@
+package org.eclipse.ui.externaltools.internal.ui.ant;
+
+/**********************************************************************
+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.io.PrintStream;
+
+import org.apache.tools.ant.BuildEvent;
+import org.apache.tools.ant.BuildLogger;
+import org.apache.tools.ant.Project;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.externaltools.internal.core.ToolMessages;
+import org.eclipse.ui.externaltools.internal.ui.BuildCanceledException;
+import org.eclipse.ui.externaltools.internal.ui.LogConsoleDocument;
+import org.eclipse.ui.externaltools.internal.ui.OutputStructureElement;
+
+public class AntBuildLogger implements BuildLogger {
+
+ protected int priorityFilter = Project.MSG_INFO;
+ protected IProgressMonitor monitor = new NullProgressMonitor();
+ private int logLength = 0;
+ private int lastTargetEndIndex = 0;
+
+ public AntBuildLogger() {
+ /* AntUIPlugin plugin = AntUIPlugin.getPlugin();
+ if (plugin != null) {
+ this.monitor = monitorFor(plugin.getCurrentProgressMonitor());
+ } else {
+ this.monitor = new NullProgressMonitor();
+ }
+ */
+ }
+
+ /**
+ * @see BuildListener#buildStarted(BuildEvent)
+ */
+ public void buildStarted(BuildEvent event) {
+ checkCanceled();
+ }
+
+ /**
+ * @see BuildListener#buildFinished(BuildEvent)
+ */
+ public void buildFinished(BuildEvent event) {
+ checkCanceled();
+ monitor.done();
+ handleException(event);
+ }
+
+ protected void handleException(BuildEvent event) {
+ Throwable exception = event.getException();
+ if (exception == null)
+ return;
+ logMessage(ToolMessages.format("AntBuildLogger.buildException", new String[] { exception.toString()}), Project.MSG_ERR);
+ }
+
+ /**
+ * @see BuildListener#targetStarted(BuildEvent)
+ */
+ public void targetStarted(BuildEvent event) {
+ checkCanceled();
+ createNewOutputStructureElement(event.getTarget().getName(), logLength);
+ }
+
+ protected void refreshConsoleTrees() {
+ final LogConsoleDocument doc = LogConsoleDocument.getInstance();
+ if (!doc.hasViews())
+ return;
+ // we get the display from the console #0 (that exists for sure because consoles!=null)
+ Display display = doc.getDisplay();
+ // create a new thread for synchronizing all the refresh operations
+ display.syncExec(new Runnable() {
+ public void run() {
+ doc.refreshTree();
+ }
+ });
+ }
+
+ protected void createNewOutputStructureElement(String name, int index) {
+ LogConsoleDocument doc = LogConsoleDocument.getInstance();
+ OutputStructureElement newElement = new OutputStructureElement(name, doc.getCurrentOutputStructureElement(), index);
+ doc.setCurrentOutputStructureElement(newElement);
+ }
+
+ /**
+ * @see BuildListener#targetFinished(BuildEvent)
+ */
+ public void targetFinished(BuildEvent event) {
+ checkCanceled();
+ monitor.worked(1);
+ handleException(event);
+ finishCurrentOutputStructureElement();
+ // store the end index of this target's log (so that we can use it later)
+ lastTargetEndIndex = logLength;
+ refreshConsoleTrees();
+ }
+
+ /**
+ * @see BuildListener#taskStarted(BuildEvent)
+ */
+ public void taskStarted(BuildEvent event) {
+ checkCanceled();
+ createNewOutputStructureElement(event.getTask().getTaskName());
+ }
+
+ /**
+ * @see BuildListener#taskFinished(BuildEvent)
+ */
+ public void taskFinished(BuildEvent event) {
+ checkCanceled();
+ handleException(event);
+ finishCurrentOutputStructureElement();
+ refreshConsoleTrees();
+ }
+
+ /**
+ * @see BuildListener#messageLogged(BuildEvent)
+ */
+ public void messageLogged(BuildEvent event) {
+ checkCanceled();
+ logMessage(event.getMessage(), event.getPriority());
+ }
+
+ protected void logMessage(String message, int priority) {
+ if (priority > priorityFilter)
+ return;
+ message += '\n';
+ LogConsoleDocument doc = LogConsoleDocument.getInstance();
+ doc.append(message, priority);
+ logLength += message.length();
+ }
+
+ protected void finishCurrentOutputStructureElement() {
+ LogConsoleDocument doc = LogConsoleDocument.getInstance();
+ // sets the index that indicates the end of the log part linked to this element
+ OutputStructureElement output = doc.getCurrentOutputStructureElement();
+ output.setEndIndex(logLength);
+ // and sets the current element to the parent of the element
+ doc.setCurrentOutputStructureElement(output.getParent());
+ }
+
+ protected void checkCanceled() {
+ if (monitor == null)
+ return;
+ if (monitor.isCanceled())
+ throw new BuildCanceledException();
+ }
+
+ protected void createNewOutputStructureElement(String name) {
+ createNewOutputStructureElement(name, logLength);
+ }
+
+ public void setMessageOutputLevel(int level) {
+ this.priorityFilter = level;
+ }
+
+ public void setEmacsMode(boolean emacsMode) {
+ }
+
+ public void setErrorPrintStream(PrintStream err) {
+ }
+
+ public void setOutputPrintStream(PrintStream output) {
+ }
+ private IProgressMonitor monitorFor(IProgressMonitor monitor) {
+ if (monitor == null)
+ return new NullProgressMonitor();
+ return monitor;
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.ui.externaltools/about.html b/org.eclipse.ui.externaltools/about.html
new file mode 100644
index 000000000..441774f92
--- /dev/null
+++ b/org.eclipse.ui.externaltools/about.html
@@ -0,0 +1,42 @@
+<html>
+<head>
+<title>About</title>
+<style type="text/css">
+p, table, td, th { font-family: arial, helvetica, geneva; font-size: 10pt}
+pre { font-family: "Courier New", Courier, mono; font-size: 10pt}
+h2 { font-family: arial, helvetica, geneva; font-size: 18pt; font-weight: bold ; line-height: 14px}
+code { font-family: "Courier New", Courier, mono; font-size: 10pt}
+sup { font-family: arial,helvetica,geneva; font-size: 10px}
+h3 { font-family: arial, helvetica, geneva; font-size: 14pt; font-weight: bold}
+li { font-family: arial, helvetica, geneva; font-size: 10pt}
+h1 { font-family: arial, helvetica, geneva; font-size: 28px; font-weight: bold}
+body { font-family: arial, helvetica, geneva; font-size: 10pt; clip: rect( ); margin-top: 5mm; margin-left: 3mm}
+</style>
+</head>
+<body lang="EN-US" link="blue" vlink="purple">
+<table border="0" cellspacing="5" cellpadding="2" width="100%" >
+ <tr>
+ <td align="LEFT" valign="TOP" colspan="2" bgcolor="#0080C0"><b><font color="#FFFFFF">About This Content</font></b></td>
+ </tr>
+ <tr>
+ <td>
+<p>11th December, 2001</p>
+<h3>License</h3>
+<p>Eclipse.org makes available all content in this plug-in &quot;Content&quot;. Unless otherwise indicated below, the Content is provided to you under the terms and conditions of the
+<a href="http://www.eclipse.org/legal/cpl-v05.html">Common Public License Version 0.5</a> &quot;CPL&quot;. For purposes of the CPL, &quot;Program&quot; will mean the Content.</p>
+
+<h3>Contributions</h3>
+
+<p>If this Content is licensed to you under the terms and conditions of the CPL, any Contributions, as defined in the CPL, uploaded, submitted, or otherwise
+made available to Eclipse.org, members of Eclipse.org and/or the host of Eclipse.org web site, by you that relate to such
+Content are provided under the terms and conditions of the CPL and can be made available to others under the terms of the CPL.</p>
+
+<p>If this Content is licensed to you under license terms and conditions other than the CPL &quot;Other License&quot;, any modifications, enhancements and/or
+other code and/or documentation &quot;Modifications&quot; uploaded, submitted, or otherwise made available to Eclipse.org, members of Eclipse.org and/or the
+host of Eclipse.org, by you that relate to such Content are provided under terms and conditions of the Other License and can be made available
+to others under the terms of the Other License. In addition, with regard to Modifications for which you are the copyright holder, you are also
+providing the Modifications under the terms and conditions of the CPL and such Modifications can be made available to others under the terms of
+the CPL.</p>
+</td></tr></table>
+</body>
+</html> \ No newline at end of file
diff --git a/org.eclipse.ui.externaltools/build.properties b/org.eclipse.ui.externaltools/build.properties
new file mode 100644
index 000000000..14c775561
--- /dev/null
+++ b/org.eclipse.ui.externaltools/build.properties
@@ -0,0 +1,9 @@
+source.externaltools.jar = External Tools/
+
+bin.includes = icons/,\
+ .options,\
+ plugin.properties,\
+ plugin.xml,\
+ about.html,\
+ *.jar
+
diff --git a/org.eclipse.ui.externaltools/buildnotes.html b/org.eclipse.ui.externaltools/buildnotes.html
new file mode 100644
index 000000000..545a618cf
--- /dev/null
+++ b/org.eclipse.ui.externaltools/buildnotes.html
@@ -0,0 +1,39 @@
+<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <meta name="Author" content="Build">
+ <meta name="GENERATOR" content="Mozilla/4.75 [en] (Windows NT 5.0; U) [Netscape]">
+ <title>Eclipse Platform Release Notes - Workbench</title>
+</head>
+<body>
+
+<h1>
+Eclipse Platform Build Notes<br>
+External Tools</h1>
+Eclipse Integration Build 20020507
+<h2>
+What's new in this drop</h2>
+
+<h3>
+API changes</h3>
+
+<h3>
+API additions</h3>
+
+<h3>
+Other highlights</h3>
+
+<h2>
+Known deficiencies</h2>
+
+<h2>
+Problem reports fixed</h2>
+<a href="http://dev.eclipse.org/bugs/buglist.cgi?bug_status=RESOLVED&bug_status=VERIFIED&bug_status=CLOSED&chfield=bug_status&chfieldfrom=2002%2F04%2F30&chfieldto=2002%2F05%2F07&product=Platform&component=UI&cmdtype=doit&&order=Bug+Number">Click
+here</a> to see PRs which have been marked as RESOLVED, VERIFIED or CLOSED
+between 2002/04/30 and 2002/05/07.
+<p>
+<hr SIZE=0 WIDTH="100%">
+<br>&nbsp;
+</body>
+</html>
diff --git a/org.eclipse.ui.externaltools/icons/full/clcl16/clear.gif b/org.eclipse.ui.externaltools/icons/full/clcl16/clear.gif
new file mode 100644
index 000000000..255832653
--- /dev/null
+++ b/org.eclipse.ui.externaltools/icons/full/clcl16/clear.gif
Binary files differ
diff --git a/org.eclipse.ui.externaltools/icons/full/clcl16/hide_show_tree.gif b/org.eclipse.ui.externaltools/icons/full/clcl16/hide_show_tree.gif
new file mode 100644
index 000000000..5a8c7ea96
--- /dev/null
+++ b/org.eclipse.ui.externaltools/icons/full/clcl16/hide_show_tree.gif
Binary files differ
diff --git a/org.eclipse.ui.externaltools/icons/full/clcl16/show_selected_text.gif b/org.eclipse.ui.externaltools/icons/full/clcl16/show_selected_text.gif
new file mode 100644
index 000000000..be9eb9215
--- /dev/null
+++ b/org.eclipse.ui.externaltools/icons/full/clcl16/show_selected_text.gif
Binary files differ
diff --git a/org.eclipse.ui.externaltools/icons/full/obj16/ant_file.gif b/org.eclipse.ui.externaltools/icons/full/obj16/ant_file.gif
new file mode 100644
index 000000000..eba5891dc
--- /dev/null
+++ b/org.eclipse.ui.externaltools/icons/full/obj16/ant_file.gif
Binary files differ
diff --git a/org.eclipse.ui.externaltools/icons/full/obj16/builder.gif b/org.eclipse.ui.externaltools/icons/full/obj16/builder.gif
new file mode 100644
index 000000000..20e7baed1
--- /dev/null
+++ b/org.eclipse.ui.externaltools/icons/full/obj16/builder.gif
Binary files differ
diff --git a/org.eclipse.ui.externaltools/icons/full/wizban/ant_wiz.gif b/org.eclipse.ui.externaltools/icons/full/wizban/ant_wiz.gif
new file mode 100644
index 000000000..42754e59e
--- /dev/null
+++ b/org.eclipse.ui.externaltools/icons/full/wizban/ant_wiz.gif
Binary files differ
diff --git a/org.eclipse.ui.externaltools/plugin.properties b/org.eclipse.ui.externaltools/plugin.properties
new file mode 100644
index 000000000..c53ca4bbf
--- /dev/null
+++ b/org.eclipse.ui.externaltools/plugin.properties
@@ -0,0 +1,9 @@
+Plugin.name = External Tools
+PopupMenu.runAnt = Run &Ant...
+PopupMenu.runAntTip = Run Ant With The Selected File
+ActionSet.externalTools = External Tools
+Action.externalTools = &External Tools
+Action.externalToolsTip = Run or Configure External Tools
+PropertyPage.externalToolsBuilders = External Tools Builders
+Category.externalTools = External Tools
+View.logConsole = Log Console
diff --git a/org.eclipse.ui.externaltools/plugin.xml b/org.eclipse.ui.externaltools/plugin.xml
new file mode 100644
index 000000000..23cfe27b6
--- /dev/null
+++ b/org.eclipse.ui.externaltools/plugin.xml
@@ -0,0 +1,83 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<plugin
+ id="org.eclipse.ui.externaltools"
+ name="%Plugin.name"
+ version="1.9.0"
+ provider-name="Object Technology International, Inc."
+ class="org.eclipse.ui.externaltools.internal.core.ExternalToolsPlugin">
+
+ <runtime>
+ <library name="externaltools.jar">
+ </library>
+ </runtime>
+ <requires>
+ <import plugin="org.apache.ant"/>
+ <import plugin="org.eclipse.ant.core"/>
+ <import plugin="org.eclipse.core.resources"/>
+ <import plugin="org.eclipse.ui"/>
+ </requires>
+
+
+<!-- extension point definitions -->
+
+<!-- Extensions -->
+ <extension point="org.eclipse.ui.popupMenus">
+ <objectContribution
+ id="org.eclipse.ui.externaltools.RunAnt"
+ objectClass="org.eclipse.core.resources.IResource"
+ adaptable="true"
+ nameFilter="*.xml">
+ <action
+ id="org.eclipse.ui.externaltools.RunAntAction"
+ label="%PopupMenu.runAnt"
+ tooltip="%PopupMenu.runAntTip"
+ menubarPath="additions"
+ enablesFor="1"
+ class="org.eclipse.ui.externaltools.internal.ui.AntRunActionDelegate">
+ </action>
+ </objectContribution>
+ </extension>
+
+ <extension point="org.eclipse.ui.actionSets">
+ <actionSet
+ id="org.eclipse.ui.externaltools.ExternalToolsSet"
+ label="%ActionSet.externalTools"
+ visible="true">
+ <action
+ id="org.eclipse.ui.externaltools.ExternalToolAction"
+ label="%Action.externalTools"
+ menubarPath="file/additions"
+ toolbarPath="Normal/additions"
+ icon="icons/externaltools.gif"
+ tooltip="%Action.externalToolsTip"
+ pulldown="true"
+ class="org.eclipse.ui.externaltools.internal.ui.ExternalToolsAction">
+ </action>
+ </actionSet>
+ </extension>
+
+ <extension point="org.eclipse.ui.propertyPages">
+ <page
+ id="org.eclipse.ui.externaltools.propertypages.BuilderPropertyPage"
+ objectClass="org.eclipse.core.resources.IProject"
+ adaptable="true"
+ name="%PropertyPage.externalToolsBuilders"
+ class="org.eclipse.ui.externaltools.internal.ui.BuilderPropertyPage">
+ </page>
+ </extension>
+
+ <extension point="org.eclipse.ui.views">
+ <category
+ id="org.eclipse.ui.externaltools.views"
+ name="%Category.externalTools">
+ </category>
+ <view
+ id="org.eclipse.ui.externaltools.LogConsoleView"
+ name="%View.logConsole"
+ icon="icons/full/cview16/log_console.gif"
+ category="org.eclipse.ui.externaltools.views"
+ class="org.eclipse.ui.externaltools.internal.ui.LogConsoleView">
+ </view>
+ </extension>
+
+</plugin>

Back to the top