Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJared Burns2002-11-22 21:54:30 +0000
committerJared Burns2002-11-22 21:54:30 +0000
commit3fe0c9d0ecfa4b223efabd042c453cf858ad429b (patch)
treeab1b7d5aad65101f2f83630bf333a47c5ced4cd8 /org.eclipse.ui.externaltools
parentd474ffef7aca3e05929f36ffa3076e794686b5d8 (diff)
downloadeclipse.platform.debug-3fe0c9d0ecfa4b223efabd042c453cf858ad429b.tar.gz
eclipse.platform.debug-3fe0c9d0ecfa4b223efabd042c453cf858ad429b.tar.xz
eclipse.platform.debug-3fe0c9d0ecfa4b223efabd042c453cf858ad429b.zip
Bug 26705 - Remove "ExternalTool" UI code
Diffstat (limited to 'org.eclipse.ui.externaltools')
-rw-r--r--org.eclipse.ui.externaltools/Ant Tools Support/org/eclipse/ui/externaltools/internal/ant/dialog/AntExternalToolNewWizard.java134
-rw-r--r--org.eclipse.ui.externaltools/Ant Tools Support/org/eclipse/ui/externaltools/internal/ant/dialog/AntOptionGroupPropertyPage.java29
-rw-r--r--org.eclipse.ui.externaltools/Ant Tools Support/org/eclipse/ui/externaltools/internal/ant/dialog/AntTargetsGroup.java743
-rw-r--r--org.eclipse.ui.externaltools/Ant Tools Support/org/eclipse/ui/externaltools/internal/ant/dialog/AntTargetsGroupPropertyPage.java45
-rw-r--r--org.eclipse.ui.externaltools/Ant Tools Support/org/eclipse/ui/externaltools/internal/ant/dialog/AntTargetsGroupWizardPage.java46
-rw-r--r--org.eclipse.ui.externaltools/Ant Tools Support/org/eclipse/ui/externaltools/internal/ant/model/AntFileRunner.java104
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/action/RunExternalToolAction.java304
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/action/RunWithExternalToolAction.java45
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/dialog/ExternalToolGroupPropertyPage.java160
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/dialog/ExternalToolGroupWizardPage.java102
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/dialog/ExternalToolMainGroupPropertyPage.java26
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/dialog/ExternalToolNewWizard.java280
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/dialog/ExternalToolOptionGroupPropertyPage.java26
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/dialog/ExternalToolRefreshGroupPropertyPage.java26
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/group/ExternalToolGroup.java146
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/group/ExternalToolMainGroup.java640
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/group/ExternalToolOptionGroup.java697
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/group/ExternalToolRefreshGroup.java279
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/group/IExternalToolGroup.java72
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/menu/ExternalToolMenuDelegate.java95
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/menu/FavoritesManager.java173
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/registry/ExternalToolRegistry.java689
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/registry/ExternalToolType.java155
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/registry/ExternalToolTypeRegistry.java156
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/AntAction.java166
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/AntLaunchWizard.java176
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/AntLaunchWizardPage.java246
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/LogConsoleDocument.java334
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/LogConsoleView.java1
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/LogTreeContentProvider.java67
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/LogTreeLabelProvider.java72
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/OutputStructureElement.java102
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/WorkInProgressPreferencePage.java55
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/view/DeleteExternalToolAction.java78
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/view/DuplicateExternalToolAction.java63
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/view/EditExternalToolPropertiesAction.java64
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/view/ExternalToolActionGroup.java179
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/view/ExternalToolContentProvider.java178
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/view/ExternalToolLabelProvider.java108
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/view/ExternalToolView.java333
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/view/NewExternalToolAction.java48
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/view/RefreshViewAction.java49
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/view/RenameExternalToolAction.java108
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/model/ExternalTool.java543
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/model/ExternalToolStorage.java153
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/model/IExternalToolFilter.java34
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/model/IExternalToolRunner.java38
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/model/IRunnerContext.java67
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/model/IStorageListener.java50
-rw-r--r--org.eclipse.ui.externaltools/Program Tools Support/org/eclipse/ui/externaltools/internal/program/dialog/ProgramExternalToolNewWizard.java44
-rw-r--r--org.eclipse.ui.externaltools/Program Tools Support/org/eclipse/ui/externaltools/internal/program/model/ProgramRunner.java174
51 files changed, 1 insertions, 8701 deletions
diff --git a/org.eclipse.ui.externaltools/Ant Tools Support/org/eclipse/ui/externaltools/internal/ant/dialog/AntExternalToolNewWizard.java b/org.eclipse.ui.externaltools/Ant Tools Support/org/eclipse/ui/externaltools/internal/ant/dialog/AntExternalToolNewWizard.java
deleted file mode 100644
index 593283944..000000000
--- a/org.eclipse.ui.externaltools/Ant Tools Support/org/eclipse/ui/externaltools/internal/ant/dialog/AntExternalToolNewWizard.java
+++ /dev/null
@@ -1,134 +0,0 @@
-package org.eclipse.ui.externaltools.internal.ant.dialog;
-
-/**********************************************************************
-Copyright (c) 2002 IBM Corp. and others. All rights reserved.
-This file is made available under the terms of the Common Public License v1.0
-which accompanies this distribution, and is available at
-http://www.eclipse.org/legal/cpl-v10.html
-Contributors:
-**********************************************************************/
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.wizard.IWizardPage;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.externaltools.dialog.ExternalToolGroupWizardPage;
-import org.eclipse.ui.externaltools.dialog.ExternalToolNewWizard;
-import org.eclipse.ui.externaltools.internal.model.ExternalToolsPlugin;
-import org.eclipse.ui.externaltools.internal.model.IHelpContextIds;
-import org.eclipse.ui.externaltools.internal.model.ToolMessages;
-import org.eclipse.ui.externaltools.model.ExternalTool;
-import org.eclipse.ui.externaltools.model.IExternalToolConstants;
-import org.eclipse.ui.externaltools.model.ToolUtil;
-
-/**
- * Wizard that will create a new external tool of type Ant build.
- */
-public class AntExternalToolNewWizard extends ExternalToolNewWizard {
- private AntTargetsGroup antTargetsGroup;
- private IFile xmlFile;
-
- /**
- * Creates the wizard for a new external tool
- */
- public AntExternalToolNewWizard() {
- super(IExternalToolConstants.TOOL_TYPE_ANT_BUILD);
- }
-
- public AntExternalToolNewWizard(IFile file) {
- super(IExternalToolConstants.TOOL_TYPE_ANT_BUILD);
- xmlFile= validateXMLFile(file);
- }
-
- /* (non-Javadoc)
- * Method declared on IWizard.
- */
- public void addPages() {
- addMainPage();
- addAntTargetsPage();
- addOptionPage();
- addRefreshPage();
-
- optionGroup.setPromptForArgumentLabel(ToolMessages.getString("AntExternalToolNewWizard.promptForArgumentLabel")); //$NON-NLS-1$
- }
-
- /**
- * Returns whether the given resource is an XML file
- * based on the resource's file extension
- * * @param resource the resource to examine * @return whether the given resource is an XML file */
- private IFile validateXMLFile(IFile file) {
- if ("xml".equals(file.getFileExtension().toLowerCase())) {
- return file;
- }
- return null;
- }
-
- /* (non-Javadoc)
- * Method declared on ExternalToolNewWizard.
- */
- protected ImageDescriptor getDefaultImageDescriptor() {
- return ExternalToolsPlugin.getDefault().getImageDescriptor("icons/full/wizban/ant_wiz.gif"); //$NON-NLS-1$
- }
-
- /*
- * (non-Javadoc)
- * Method declared on ExternalToolNewWizard.
- */
- protected boolean updateTool(ExternalTool tool) {
- if (super.updateTool(tool))
- return updateToolFromGroup(tool, antTargetsGroup);
- return false;
- }
-
- /**
- * Creates a wizard page to contain the ant build tool
- * targets component and adds it to the wizard page
- * list.
- */
- private void addAntTargetsPage() {
- createAntTargetsGroup();
- if (antTargetsGroup == null)
- return;
- ExternalToolGroupWizardPage page;
- page = new AntTargetsGroupWizardPage("antGroupPage", antTargetsGroup, mainGroup, IHelpContextIds.ANT_TARGETS_WIZARD_PAGE); //$NON-NLS-1$
- page.setTitle(ToolMessages.getString("AntExternalToolNewWizard.antTargetsPageTitle")); //$NON-NLS-1$
- page.setDescription(ToolMessages.getString("AntExternalToolNewWizard.antTargetsPageDescription")); //$NON-NLS-1$
- addPage(page);
- }
-
- /**
- * Creates and initializes the group for selecting
- * which Ant targets to run.
- */
- private void createAntTargetsGroup() {
- if (antTargetsGroup != null)
- return;
- antTargetsGroup = new AntTargetsGroup();
- }
- public IWizardPage getStartingPage() {
- return super.getStartingPage();
- }
-
- public void createPageControls(Composite pageContainer) {
- String fileLocation= null;
- if (xmlFile != null) {
- StringBuffer buffer = new StringBuffer();
- ToolUtil.buildVariableTag(IExternalToolConstants.VAR_RESOURCE_LOC, xmlFile.getFullPath().toString(), buffer);
- fileLocation= buffer.toString();
- String baseName= xmlFile.getName() + " [" + xmlFile.getProject().getName() + "]" ;
- String name= baseName;
- int index= 0;
- while (ExternalToolsPlugin.getDefault().getToolRegistry(getShell()).hasToolNamed(name)) {
- name= baseName + "_" + index;
- }
- mainGroup.setInitialName(name);
- mainGroup.setInitialLocation(fileLocation);
- }
- super.createPageControls(pageContainer);
- if (fileLocation != null) {
- antTargetsGroup.setFileLocation(fileLocation);
- }
- }
-
-}
diff --git a/org.eclipse.ui.externaltools/Ant Tools Support/org/eclipse/ui/externaltools/internal/ant/dialog/AntOptionGroupPropertyPage.java b/org.eclipse.ui.externaltools/Ant Tools Support/org/eclipse/ui/externaltools/internal/ant/dialog/AntOptionGroupPropertyPage.java
deleted file mode 100644
index 91c892d41..000000000
--- a/org.eclipse.ui.externaltools/Ant Tools Support/org/eclipse/ui/externaltools/internal/ant/dialog/AntOptionGroupPropertyPage.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package org.eclipse.ui.externaltools.internal.ant.dialog;
-
-/**********************************************************************
-Copyright (c) 2002 IBM Corp. and others. All rights reserved.
-This file is made available under the terms of the Common Public License v1.0
-which accompanies this distribution, and is available at
-http://www.eclipse.org/legal/cpl-v10.html
-Contributors:
-**********************************************************************/
-
-import org.eclipse.ui.externaltools.dialog.ExternalToolOptionGroupPropertyPage;
-import org.eclipse.ui.externaltools.group.ExternalToolOptionGroup;
-import org.eclipse.ui.externaltools.internal.model.ToolMessages;
-
-/**
- * Property page to show the options group. Sets the
- * appropriate label to prompt for targets and arguments.
- */
-public class AntOptionGroupPropertyPage extends ExternalToolOptionGroupPropertyPage {
-
- /**
- * Creates the option group property page.
- */
- public AntOptionGroupPropertyPage() {
- super();
- ((ExternalToolOptionGroup) getGroup()).setPromptForArgumentLabel(ToolMessages.getString("AntOptionGroupPropertyPage.promptForArgumentLabel")); //$NON-NLS-1$
- }
-}
diff --git a/org.eclipse.ui.externaltools/Ant Tools Support/org/eclipse/ui/externaltools/internal/ant/dialog/AntTargetsGroup.java b/org.eclipse.ui.externaltools/Ant Tools Support/org/eclipse/ui/externaltools/internal/ant/dialog/AntTargetsGroup.java
deleted file mode 100644
index dcad01d52..000000000
--- a/org.eclipse.ui.externaltools/Ant Tools Support/org/eclipse/ui/externaltools/internal/ant/dialog/AntTargetsGroup.java
+++ /dev/null
@@ -1,743 +0,0 @@
-package org.eclipse.ui.externaltools.internal.ant.dialog;
-
-/**********************************************************************
-Copyright (c) 2002 IBM Corp. and others. All rights reserved.
-This file is made available under the terms of the Common Public License v1.0
-which accompanies this distribution, and is available at
-http://www.eclipse.org/legal/cpl-v10.html
-Contributors:
-**********************************************************************/
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import org.eclipse.ant.core.TargetInfo;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.MultiStatus;
-import org.eclipse.jface.dialogs.ErrorDialog;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.List;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.externaltools.group.ExternalToolGroup;
-import org.eclipse.ui.externaltools.internal.ant.model.AntUtil;
-import org.eclipse.ui.externaltools.internal.model.ToolMessages;
-import org.eclipse.ui.externaltools.model.ExternalTool;
-import org.eclipse.ui.externaltools.model.IExternalToolConstants;
-import org.eclipse.ui.externaltools.model.ToolUtil;
-import org.eclipse.ui.externaltools.variable.ExpandVariableContext;
-
-/**
- * Group for selecting the targets of an Ant build tool.
- */
-public class AntTargetsGroup extends ExternalToolGroup {
- private static final int DESCRIPTION_FIELD_HEIGHT = 3;
-
- private String fileLocation = null;
- private TargetInfo defaultTarget = null;
- private Map mapTargetNamesToTargetInfos = new HashMap();
- private ArrayList subTargets = new ArrayList();
-
- private Button runDefaultTargetButton;
- private Button showSubTargetsButton;
- private List availableTargetsList;
- private List activeTargetsList;
- private Button addButton;
- private Button removeButton;
- private Button addAll;
- private Button removeAll;
- private Button upButton;
- private Button downButton;
- private Text descriptionField;
- private Label descriptionLabel;
- private Label availableLabel;
- private Label activeLabel;
-
- /**
- * Creates the group
- */
- public AntTargetsGroup() {
- super();
- }
-
- /* (non-Javadoc)
- * Method declared on ExternalToolGroup.
- */
- protected Control createGroupContents(Composite parent, ExternalTool tool) {
- // main composite
- Composite mainComposite = new Composite(parent, SWT.NONE);
- GridLayout layout = new GridLayout();
- layout.marginWidth = 0;
- layout.marginHeight = 0;
- mainComposite.setLayout(layout);
- GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
- mainComposite.setLayoutData(gridData);
-
- Composite upperComposite = new Composite(mainComposite, SWT.NONE);
- layout = new GridLayout();
- layout.marginWidth = 0;
- layout.marginHeight = 0;
- gridData = new GridData(GridData.FILL_HORIZONTAL);
- upperComposite.setLayout(layout);
- upperComposite.setLayoutData(gridData);
-
- createRunDefaultTargetButton(upperComposite);
-
- Composite middleComposite = new Composite(mainComposite, SWT.NONE);
- layout = new GridLayout();
- layout.marginWidth = 0;
- layout.marginHeight = 0;
- layout.numColumns = 4;
- gridData = new GridData(GridData.FILL_HORIZONTAL);
- middleComposite.setLayout(layout);
- middleComposite.setLayoutData(gridData);
-
- createAvailableTargetsList(middleComposite);
- createAddRemoveComposite(middleComposite);
- createActiveTargetsList(middleComposite);
- createUpDownComposite(middleComposite);
-
- Composite lowerComposite = new Composite(mainComposite, SWT.NONE);
- layout = new GridLayout();
- layout.marginWidth = 0;
- layout.marginHeight = 0;
- gridData = new GridData(GridData.FILL_HORIZONTAL);
- lowerComposite.setLayout(layout);
- lowerComposite.setLayoutData(gridData);
-
- createDescriptionField(lowerComposite);
- createShowSubTargetsButton(lowerComposite);
-
- if (tool != null) {
- setFileLocation(tool.getLocation());
- restoreValues(tool);
- }
- allowSelectTargets(!runDefaultTargetButton.getSelection());
-
- return mainComposite;
- }
-
- /*
- * Creates the checkbox button for the
- * "Run default target" preference.
- */
- private void createRunDefaultTargetButton(Composite parent) {
- runDefaultTargetButton = new Button(parent, SWT.CHECK);
- // The label that is applied if the default target is unknown
- runDefaultTargetButton.setText(ToolMessages.getString("AntTargetsGroup.runDefaultTargetUnknownLabel")); //$NON-NLS-1$
- runDefaultTargetButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- runDefaultTargetSelected();
- }
- });
- runDefaultTargetButton.setSelection(true);
- }
-
- /*
- * Creates the checkbox button for the
- * "Show sub-targets" preference.
- */
- private void createShowSubTargetsButton(Composite parent) {
- showSubTargetsButton = new Button(parent, SWT.CHECK);
- showSubTargetsButton.setText(ToolMessages.getString("AntTargetsGroup.showSubTargetsLabel")); //$NON-NLS-1$
- showSubTargetsButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- if (showSubTargetsButton.getSelection()) {
- showSubTargets();
- } else {
- hideSubTargets();
- }
- }
- });
- showSubTargetsButton.setSelection(false);
- }
-
- /*
- * Creates the list of targets provided by the ant build tool.
- */
- private void createAvailableTargetsList(Composite parent) {
- Composite listComposite = new Composite(parent, SWT.NONE);
-
- GridData gridData = new GridData(GridData.FILL_BOTH);
- listComposite.setLayoutData(gridData);
-
- GridLayout layout = new GridLayout();
- layout.marginWidth = 0;
- layout.marginHeight = 0;
- listComposite.setLayout(layout);
-
- availableLabel = new Label(listComposite, SWT.LEFT);
- availableLabel.setText(ToolMessages.getString("AntTargetsGroup.availableTargetsLabel")); //$NON-NLS-1$
-
- availableTargetsList = new List(listComposite, SWT.BORDER | SWT.MULTI);
- gridData = new GridData(GridData.FILL_BOTH);
- availableTargetsList.setLayoutData(gridData);
-
- availableTargetsList.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- int index = availableTargetsList.getSelectionIndex();
- if (index >= 0) {
- targetsSelected(availableTargetsList.getItem(index), availableTargetsList);
- } else {
- deselectAll();
- }
- }
- });
- }
-
- /*
- * Creates the list of targets that will be used when the tool is run.
- */
- private void createActiveTargetsList(Composite parent) {
- Composite listComposite = new Composite(parent, SWT.NONE);
-
- GridData gridData = new GridData(GridData.FILL_BOTH);
- listComposite.setLayoutData(gridData);
-
- GridLayout layout = new GridLayout();
- layout.marginWidth = 0;
- layout.marginHeight = 0;
- listComposite.setLayout(layout);
-
- activeLabel = new Label(listComposite, SWT.LEFT);
- activeLabel.setText(ToolMessages.getString("AntTargetsGroup.activeTargetsLabel")); //$NON-NLS-1$
-
- activeTargetsList = new List(listComposite, SWT.BORDER | SWT.MULTI);
- gridData = new GridData(GridData.FILL_BOTH);
- activeTargetsList.setLayoutData(gridData);
-
- activeTargetsList.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- int index = activeTargetsList.getSelectionIndex();
- if (index >= 0) {
- targetsSelected(activeTargetsList.getItem(index), activeTargetsList);
- } else {
- deselectAll();
- }
- }
- });
- }
-
- /*
- * Creates the bank of buttons that allow the user to
- * addButton and removeButton targets from the active list.
- */
- private void createAddRemoveComposite(Composite parent) {
- Composite addRemoveComposite = new Composite(parent, SWT.NONE);
-
- GridData gridData = new GridData();
- addRemoveComposite.setLayoutData(gridData);
-
- GridLayout layout = new GridLayout();
- layout.marginWidth = 0;
- layout.marginHeight = 0;
- addRemoveComposite.setLayout(layout);
-
- new Label(addRemoveComposite, SWT.NONE);
-
- addButton = createButton(
- addRemoveComposite,
- ToolMessages.getString("AntTargetsGroup.addLabel"), //$NON-NLS-1$
- new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- addTargets();
- }
- },
- false);
-
- removeButton = createButton(
- addRemoveComposite,
- ToolMessages.getString("AntTargetsGroup.removeLabel"), //$NON-NLS-1$
- new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- removeTargets();
- }
- },
- false);
-
- new Label(addRemoveComposite, SWT.NONE);
-
- addAll = createButton(
- addRemoveComposite,
- ToolMessages.getString("AntTargetsGroup.addAllLabel"), //$NON-NLS-1$
- new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- addAllTargets();
- }
- },
- false);
-
- removeAll = createButton(
- addRemoveComposite,
- ToolMessages.getString("AntTargetsGroup.removeAllLabel"), //$NON-NLS-1$
- new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- removeAllTargets();
- }
- },
- false);
- }
-
- /*
- * Creates a button bank containing the buttons for moving
- * targets in the active list upButton and downButton.
- */
- private void createUpDownComposite(Composite parent) {
- Composite upDownComposite = new Composite(parent, SWT.NONE);
-
- GridData gridData = new GridData();
- upDownComposite.setLayoutData(gridData);
-
- GridLayout layout = new GridLayout();
- layout.marginWidth = 0;
- layout.marginHeight = 0;
- upDownComposite.setLayout(layout);
-
- new Label(upDownComposite, SWT.NONE);
-
- upButton = createButton(
- upDownComposite,
- ToolMessages.getString("AntTargetsGroup.upLabel"), //$NON-NLS-1$
- new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- moveTargetUp();
- }
- },
- true);
-
- downButton = createButton(
- upDownComposite,
- ToolMessages.getString("AntTargetsGroup.downLabel"), //$NON-NLS-1$
- new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- moveTargetDown();
- }
- },
- true);
- }
-
- /*
- * Creates a button in the given composite with the given label and selection adapter.
- * minWidth specifies whether the button should be at minimum IDialogConstants.BUTTON_WIDTH
- * wide.
- */
- private Button createButton(Composite parent, String label, SelectionAdapter adapter, boolean minWidth) {
- Button button = new Button(parent, SWT.PUSH);
- button.setText(label);
- GridData data = getPage().setButtonGridData(button);
- if (!minWidth) {
- data.widthHint = button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x;
- }
- button.addSelectionListener(adapter);
-
- return button;
- }
-
- /*
- * Creates the text field which displays the descriptionField of the selected target.
- */
- private void createDescriptionField(Composite parent) {
- descriptionLabel = new Label(parent, SWT.NONE);
- descriptionLabel.setText(ToolMessages.getString("AntTargetsGroup.descriptionLabel")); //$NON-NLS-1$
-
- descriptionField = new Text(parent, SWT.READ_ONLY | SWT.BORDER);
- GridData data = new GridData(GridData.FILL_HORIZONTAL);
- data.heightHint = getPage().convertHeightHint(DESCRIPTION_FIELD_HEIGHT);
- descriptionField.setLayoutData(data);
- }
-
- /* (non-Javadoc)
- * Method declared on IExternalToolGroup.
- */
- public void restoreValues(ExternalTool tool) {
- if (activeTargetsList != null) {
- activeTargetsList.setItems(toArray(tool.getExtraAttribute(AntUtil.RUN_TARGETS_ATTRIBUTE)));
-
- if (activeTargetsList.getItemCount() == 0) {
- runDefaultTargetButton.setSelection(true);
- } else {
- runDefaultTargetButton.setSelection(false);
- }
- runDefaultTargetSelected();
- }
- }
-
- /* (non-Javadoc)
- * Method declared on IExternalToolGroup.
- */
- public void updateTool(ExternalTool tool) {
- if (runDefaultTargetButton == null) {
- return;
- }
- if (runDefaultTargetButton.getSelection()) {
- tool.setExtraAttribute(AntUtil.RUN_TARGETS_ATTRIBUTE, null);
- } else if (activeTargetsList != null) {
- tool.setExtraAttribute(AntUtil.RUN_TARGETS_ATTRIBUTE, toString(activeTargetsList.getItems()));
- }
- }
-
- /* (non-Javadoc)
- * Method declared on IExternalToolGroup.
- */
- public void validate() {
- }
-
- /**
- * Informs the group of the current external tool
- * file location.
- */
- public void setFileLocation(String newLocation) {
- if (((newLocation == null) && (fileLocation != null)) || !newLocation.equals(fileLocation)) {
- fileLocation= newLocation;
- resetAvailableTargets();
- }
- }
-
- /*
- * Translates an array of target names into a
- * single string for storage.
- */
- private String toString(String[] targetArray) {
- return AntUtil.combineRunTargets(targetArray);
- }
-
- /*
- * Translates a single string of target names into
- * an array of target names.
- */
- private String[] toArray(String targetString) {
- return AntUtil.parseRunTargets(targetString);
- }
-
- /*
- * The "run default target" preference has been selected.
- */
- private void runDefaultTargetSelected() {
- allowSelectTargets(! runDefaultTargetButton.getSelection());
- }
-
- /*
- * Adds the current selection in the available list
- * to the active list.
- */
- private void addTargets() {
- String[] targets = availableTargetsList.getSelection();
- for (int i=0; i < targets.length; i++) {
- activeTargetsList.add(targets[i]);
- }
- updateButtonEnablement();
- }
-
- /*
- * Removes the current selection in the active list.
- */
- private void removeTargets() {
- String[] targets = activeTargetsList.getSelection();
- for (int i=0; i < targets.length; i++) {
- activeTargetsList.remove(targets[i]);
- }
- deselectAll();
- }
-
- /*
- * Adds all the available targets to the active list.
- */
- private void addAllTargets() {
- String[] targets = availableTargetsList.getItems();
- for (int i=0; i < targets.length; i++) {
- activeTargetsList.add(targets[i]);
- }
- updateButtonEnablement();
- }
-
- /*
- * Removes all the active targets.
- */
- private void removeAllTargets() {
- activeTargetsList.removeAll();
- deselectAll();
- }
-
- /*
- * Moves the current selection in the active list upButton.
- */
- private void moveTargetUp() {
- int index = activeTargetsList.getSelectionIndex();
- // Action only works if selected element is not first element.
- if (index > 0) {
- String target = activeTargetsList.getItem(index);
- activeTargetsList.remove(index);
- activeTargetsList.add(target, index - 1);
- activeTargetsList.setSelection(index - 1);
- }
-
- updateUpDownButtonEnablement();
- }
-
- /*
- * Moves the current selection in the active list downButton.
- */
- private void moveTargetDown() {
- int index = activeTargetsList.getSelectionIndex();
- if (index < 0) {
- return;
- }
- // Action only works if selected element is not last element.
- if (index < activeTargetsList.getItemCount() - 1) {
- String target = activeTargetsList.getItem(index);
- activeTargetsList.remove(index);
- activeTargetsList.add(target, index + 1);
- activeTargetsList.setSelection(index + 1);
- }
-
- updateUpDownButtonEnablement();
- }
-
- /*
- * Resets the available targets list based on the tool location
- * for this tool.
- */
- private void resetAvailableTargets() {
- // Clear the map of target names to target infos.
- mapTargetNamesToTargetInfos.clear();
- subTargets.clear();
- availableTargetsList.removeAll();
- activeTargetsList.removeAll();
-
- if (fileLocation == null) {
- return;
- }
-
- try {
- MultiStatus status = new MultiStatus(IExternalToolConstants.PLUGIN_ID, 0, "", null); //$NON-NLS-1$
- String expandedLocation = ToolUtil.expandFileLocation(fileLocation, ExpandVariableContext.EMPTY_CONTEXT, status);
- if (expandedLocation != null && status.isOK()) {
- TargetInfo[] targets = AntUtil.getTargets(expandedLocation);
- ArrayList targetNameList = new ArrayList();
- for (int i=0; i < targets.length; i++) {
- if (! AntUtil.isInternalTarget(targets[i])) {
- // Add the target to the map of target names to target infos.
- mapTargetNamesToTargetInfos.put(targets[i].getName(), targets[i]);
-
- if (targets[i].isDefault()) {
- defaultTarget = targets[i];
- runDefaultTargetButton.setText(ToolMessages.format("AntTargetsGroup.runDefaultTargetLabel", new Object[] {targets[i].getName()})); //NON-NLS-1$
- }
-
- if (AntUtil.isSubTarget(targets[i])) {
- subTargets.add(targets[i].getName());
- } else {
- targetNameList.add(targets[i].getName());
- }
- }
- }
- if (showSubTargetsButton.getSelection()) {
- targetNameList.addAll(subTargets);
- }
-
- String[] targetNames = (String[]) targetNameList.toArray(new String[targetNameList.size()]);
- availableTargetsList.setItems(targetNames);
- } else {
- displayErrorStatus(status);
- }
- } catch (CoreException e) {
- displayErrorStatus(e.getStatus());
- }
- }
-
- /*
- * Displays an error dialog with the given status.
- */
- private void displayErrorStatus(IStatus status) {
- ErrorDialog.openError(
- null,
- ToolMessages.getString("AntTargetsGroup.getTargetsTitle"), //$NON-NLS-1$;
- ToolMessages.getString("AntTargetsGroup.getTargetsProblem"), //$NON-NLS-1$;
- status);
- }
-
- /*
- * A target was selected in one of the lists.
- */
- private void targetsSelected(String targetName, List list) {
- updateButtonEnablement();
-
- if (targetName == null) {
- return;
- }
- if (list == availableTargetsList) {
- activeTargetsList.deselectAll();
- } else {
- availableTargetsList.deselectAll();
- }
-
- showDescription(targetName);
- }
-
- /*
- * Updates the enablement of all the buttons in the group.
- */
- private void updateButtonEnablement() {
- updateUpDownButtonEnablement();
- updateAddRemoveButtonEnablement();
- }
-
- /*
- * Updates the enabled state of the upButton and downButton buttons based
- * on the current list selection.
- */
- private void updateUpDownButtonEnablement() {
- if (activeTargetsList.getEnabled() == false) {
- disableUpDownButtons();
- return;
- }
- // Disable upButton and downButton buttons if there is not one
- // target selected in the active list.
- if (activeTargetsList.getSelectionCount() != 1) {
- disableUpDownButtons();
- return;
- }
-
- int index = activeTargetsList.getSelectionIndex();
- if (index > 0) {
- upButton.setEnabled(true);
- } else {
- upButton.setEnabled(false);
- }
-
- if (index >= 0 && index < activeTargetsList.getItemCount() - 1) {
- downButton.setEnabled(true);
- } else {
- downButton.setEnabled(false);
- }
- }
-
- /*
- * Updates the enabled state of the addButton, removeButton, addAll, and
- * removeAll buttons based on the current list selection.
- */
- private void updateAddRemoveButtonEnablement() {
- if (runDefaultTargetButton.getSelection()) {
- disableAddRemoveButtons();
- return;
- }
- int availableIndex = availableTargetsList.getSelectionIndex();
- int activeIndex = activeTargetsList.getSelectionIndex();
- addButton.setEnabled(availableIndex >= 0);
- removeButton.setEnabled(activeIndex >= 0);
- addAll.setEnabled(availableTargetsList.getItemCount() > 0);
- removeAll.setEnabled(activeTargetsList.getItemCount() > 0);
- }
-
- /*
- * Deselects all targets in both lists.
- */
- private void deselectAll() {
- availableTargetsList.deselectAll();
- activeTargetsList.deselectAll();
- updateButtonEnablement();
- clearDescriptionField();
- }
-
- /*
- * Enables all the appropriate controls.
- */
- private void allowSelectTargets(boolean enabled) {
- if (! enabled) {
- deselectAll();
- if (defaultTarget != null && defaultTarget.getDescription() != null)
- descriptionField.setText(defaultTarget.getDescription());
- } else {
- descriptionField.setText(""); //$NON-NLS-1$
- }
-
- availableLabel.setEnabled(enabled);
- availableTargetsList.setEnabled(enabled);
- activeLabel.setEnabled(enabled);
- activeTargetsList.setEnabled(enabled);
- descriptionLabel.setEnabled(enabled);
- descriptionField.setEnabled(enabled);
- showSubTargetsButton.setEnabled(enabled);
- updateButtonEnablement();
- }
-
- /*
- * Disables all buttons in the group.
- */
- private void disableAllButtons() {
- disableAddRemoveButtons();
- disableUpDownButtons();
- }
-
- /*
- * Disables the addButton, removeButton, addAll, and
- * removeAll buttons.
- */
- private void disableAddRemoveButtons() {
- addButton.setEnabled(false);
- removeButton.setEnabled(false);
- addAll.setEnabled(false);
- removeAll.setEnabled(false);
- }
-
- /*
- * Disables the upButton and downButton buttons.
- */
- private void disableUpDownButtons() {
- upButton.setEnabled(false);
- downButton.setEnabled(false);
- }
-
- /*
- * Shows the descriptionField of the given target in the
- * descriptionField field.
- */
- private void showDescription(String targetName) {
- clearDescriptionField();
- if (targetName == null) {
- return;
- }
- TargetInfo targetInfo = (TargetInfo) mapTargetNamesToTargetInfos.get(targetName);
- if (targetInfo != null && targetInfo.getDescription() != null) {
- descriptionField.setText(targetInfo.getDescription());
- }
- }
-
- /*
- * Clears the descriptionField field.
- */
- private void clearDescriptionField() {
- descriptionField.setText(""); //$NON-NLS-1$
- }
-
- /*
- * Shows sub-targets in the available targets list.
- */
- private void showSubTargets() {
- Iterator i = subTargets.iterator();
- while (i.hasNext()) {
- String target = (String) i.next();
- availableTargetsList.add(target);
- }
- }
-
- /*
- * Hides sub-targets in the available targets list.
- */
- private void hideSubTargets() {
- int startOfSubTargets = availableTargetsList.getItemCount() - subTargets.size();
- int endOfSubTargets = availableTargetsList.getItemCount() - 1;
- availableTargetsList.remove(startOfSubTargets, endOfSubTargets);
- }
-}
diff --git a/org.eclipse.ui.externaltools/Ant Tools Support/org/eclipse/ui/externaltools/internal/ant/dialog/AntTargetsGroupPropertyPage.java b/org.eclipse.ui.externaltools/Ant Tools Support/org/eclipse/ui/externaltools/internal/ant/dialog/AntTargetsGroupPropertyPage.java
deleted file mode 100644
index a5fba3a36..000000000
--- a/org.eclipse.ui.externaltools/Ant Tools Support/org/eclipse/ui/externaltools/internal/ant/dialog/AntTargetsGroupPropertyPage.java
+++ /dev/null
@@ -1,45 +0,0 @@
-package org.eclipse.ui.externaltools.internal.ant.dialog;
-
-/**********************************************************************
-Copyright (c) 2002 IBM Corp. and others. All rights reserved.
-This file is made available under the terms of the Common Public License v1.0
-which accompanies this distribution, and is available at
-http://www.eclipse.org/legal/cpl-v10.html
-Contributors:
-**********************************************************************/
-
-import org.eclipse.ui.externaltools.dialog.ExternalToolGroupPropertyPage;
-import org.eclipse.ui.externaltools.internal.model.IHelpContextIds;
-import org.eclipse.ui.externaltools.model.ExternalTool;
-
-/**
- * Property page to show the Ant targets group.
- */
-public class AntTargetsGroupPropertyPage extends ExternalToolGroupPropertyPage {
-
- /**
- * Creates the Ant targets group property page.
- */
- public AntTargetsGroupPropertyPage() {
- super(new AntTargetsGroup(), IHelpContextIds.ANT_TARGETS_PROPERTY_PAGE);
- }
-
- /*
- * (non-Javadoc)
- * Method declared on DialogPage.
- *
- * When the page is brought up, reset the file location. This makes
- * sure the page can reinitialize itself if the file location has changed.
- */
- public void setVisible(boolean visible) {
- super.setVisible(visible);
-
- ExternalTool tool = getExternalTool();
- if (tool != null) {
- AntTargetsGroup group = (AntTargetsGroup) getGroup();
- if (group != null)
- group.setFileLocation(tool.getLocation());
- }
- }
-}
diff --git a/org.eclipse.ui.externaltools/Ant Tools Support/org/eclipse/ui/externaltools/internal/ant/dialog/AntTargetsGroupWizardPage.java b/org.eclipse.ui.externaltools/Ant Tools Support/org/eclipse/ui/externaltools/internal/ant/dialog/AntTargetsGroupWizardPage.java
deleted file mode 100644
index cfb241842..000000000
--- a/org.eclipse.ui.externaltools/Ant Tools Support/org/eclipse/ui/externaltools/internal/ant/dialog/AntTargetsGroupWizardPage.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package org.eclipse.ui.externaltools.internal.ant.dialog;
-
-/**********************************************************************
-Copyright (c) 2002 IBM Corp. and others. All rights reserved.
-This file is made available under the terms of the Common Public License v1.0
-which accompanies this distribution, and is available at
-http://www.eclipse.org/legal/cpl-v10.html
-Contributors:
-**********************************************************************/
-
-import org.eclipse.ui.externaltools.dialog.ExternalToolGroupWizardPage;
-import org.eclipse.ui.externaltools.group.ExternalToolMainGroup;
-
-/**
- * Wizard page that will display an <code>AntTargetsGroup</code>
- * as its content.
- */
-public class AntTargetsGroupWizardPage extends ExternalToolGroupWizardPage {
- private ExternalToolMainGroup mainGroup;
-
- /**
- * Creates a wizard page for the specified group.
- *
- * @param pageName name given to the page
- * @param group the ant targets group to display
- * @param mainGroup the main group for access to the location
- * @param helpContextId the help context id for this page
- */
- public AntTargetsGroupWizardPage(String pageName, AntTargetsGroup group, ExternalToolMainGroup mainGroup, String helpContextId) {
- super(pageName, group, helpContextId);
- this.mainGroup = mainGroup;
- }
-
- /*
- * (non-Javadoc)
- * Method declared on DialogPage.
- */
- public void setVisible(boolean visible) {
- super.setVisible(visible);
- AntTargetsGroup group = (AntTargetsGroup) getGroup();
- if (group != null && mainGroup != null) {
- group.setFileLocation(mainGroup.getLocationFieldValue());
- }
- }
-}
diff --git a/org.eclipse.ui.externaltools/Ant Tools Support/org/eclipse/ui/externaltools/internal/ant/model/AntFileRunner.java b/org.eclipse.ui.externaltools/Ant Tools Support/org/eclipse/ui/externaltools/internal/ant/model/AntFileRunner.java
deleted file mode 100644
index bbc6bd6e8..000000000
--- a/org.eclipse.ui.externaltools/Ant Tools Support/org/eclipse/ui/externaltools/internal/ant/model/AntFileRunner.java
+++ /dev/null
@@ -1,104 +0,0 @@
-package org.eclipse.ui.externaltools.internal.ant.model;
-
-/**********************************************************************
-Copyright (c) 2002 IBM Corp. and others. All rights reserved.
-This file is made available under the terms of the Common Public License v1.0
-which accompanies this distribution, and is available at
-http://www.eclipse.org/legal/cpl-v10.html
-Contributors:
-**********************************************************************/
-
-import org.eclipse.ant.core.AntRunner;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.MultiStatus;
-import org.eclipse.core.runtime.OperationCanceledException;
-import org.eclipse.ui.externaltools.internal.model.ToolMessages;
-import org.eclipse.ui.externaltools.model.IExternalToolRunner;
-import org.eclipse.ui.externaltools.model.IRunnerContext;
-import org.eclipse.ui.externaltools.model.IRunnerLog;
-
-/**
- * Responsible for running ant build files.
- */
-public class AntFileRunner implements IExternalToolRunner {
- private static final String ANT_LOGGER_CLASS = "org.eclipse.ui.externaltools.internal.ant.logger.AntBuildLogger"; //$NON-NLS-1$
- private static final String BASE_DIR_PREFIX = "-Dbasedir="; //$NON-NLS-1$
-
- private static final String INPUT_HANDLER_CLASS = "org.eclipse.ui.externaltools.internal.ant.inputhandler.AntInputHandler"; //$NON-NLS-1$
-
- /**
- * Creates an ant build file runner
- */
- public AntFileRunner() {
- super();
- }
-
- /* (non-Javadoc)
- * Method declared in IExternalToolsRunner.
- */
- public void run(IProgressMonitor monitor, IRunnerContext runnerContext, MultiStatus status) {
- try {
- // Determine the targets to run.
- String value = runnerContext.getExtraAttribute(AntUtil.RUN_TARGETS_ATTRIBUTE);
- String[] targets = AntUtil.parseRunTargets(value);
-
- AntRunner runner = new AntRunner();
-
- // Setup the arguments
- String[] args = runnerContext.getExpandedArguments();
- String[] runnerArgs = args;
- String baseDir = runnerContext.getExpandedWorkingDirectory();
- if (baseDir.length() > 0) {
- // Ant requires the working directory to be specified
- // as one of the arguments, so it needs to be appended.
- runnerArgs = new String[args.length + 1];
- System.arraycopy(args, 0, runnerArgs, 0, args.length);
- runnerArgs[args.length] = BASE_DIR_PREFIX + baseDir;
- }
- runner.setArguments(runnerArgs);
-
- runner.setBuildFileLocation(runnerContext.getExpandedLocation());
- if (targets.length > 0) {
- runner.setExecutionTargets(targets);
- }
- if (runnerContext.getCaptureOutput()) {
- runner.addBuildLogger(ANT_LOGGER_CLASS);
- }
-
- // Print out the command used to run the ant build file.
- if (IRunnerLog.LEVEL_VERBOSE <= runnerContext.getLog().getFilterLevel()) {
- runnerContext.getLog().append(
- ToolMessages.getString("AntFileRunner.callingAntRunner"), //$NON-NLS-1$;
- IRunnerLog.LEVEL_VERBOSE);
- runnerContext.getLog().append(
- ToolMessages.format("AntFileRunner.antFile", new Object[] {runnerContext.getExpandedLocation()}), //$NON-NLS-1$;
- IRunnerLog.LEVEL_VERBOSE);
- for (int i = 1; i < runnerArgs.length; i++) {
- runnerContext.getLog().append(
- ToolMessages.format("AntFileRunner.argument", new Object[] {runnerArgs[i]}), //$NON-NLS-1$;
- IRunnerLog.LEVEL_VERBOSE);
- }
- for (int i = 0; i < targets.length; i++) {
- runnerContext.getLog().append(
- ToolMessages.format("AntFileRunner.target", new Object[] {targets[i]}), //$NON-NLS-1$;
- IRunnerLog.LEVEL_VERBOSE);
- }
- }
- runner.setInputHandler(INPUT_HANDLER_CLASS);
- if (!monitor.isCanceled()) {
- runner.run(monitor);
- }
- } catch (CoreException e) {
- Throwable carriedException = e.getStatus().getException();
- if (carriedException instanceof OperationCanceledException) {
- monitor.setCanceled(true);
- } else {
- status.merge(e.getStatus());
- }
- } finally {
- monitor.done();
- }
- }
-}
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/action/RunExternalToolAction.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/action/RunExternalToolAction.java
deleted file mode 100644
index fdeac7baf..000000000
--- a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/action/RunExternalToolAction.java
+++ /dev/null
@@ -1,304 +0,0 @@
-package org.eclipse.ui.externaltools.action;
-
-/**********************************************************************
-Copyright (c) 2002 IBM Corp. and others. All rights reserved.
-This file is made available under the terms of the Common Public License v1.0
-which accompanies this distribution, and is available at
-http://www.eclipse.org/legal/cpl-v10.html
-Contributors:
-**********************************************************************/
-
-import java.lang.reflect.InvocationTargetException;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.MultiStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.dialogs.ErrorDialog;
-import org.eclipse.jface.dialogs.ProgressMonitorDialog;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.WorkbenchException;
-import org.eclipse.ui.externaltools.internal.menu.FavoritesManager;
-import org.eclipse.ui.externaltools.internal.model.DefaultRunnerContext;
-import org.eclipse.ui.externaltools.internal.model.ExternalToolsPlugin;
-import org.eclipse.ui.externaltools.internal.model.IHelpContextIds;
-import org.eclipse.ui.externaltools.internal.model.ToolMessages;
-import org.eclipse.ui.externaltools.internal.ui.LogConsoleDocument;
-import org.eclipse.ui.externaltools.model.ExternalTool;
-import org.eclipse.ui.externaltools.model.IExternalToolConstants;
-import org.eclipse.ui.help.WorkbenchHelp;
-
-/**
- * Action to run an external tool.
- * <p>
- * This class is not intended to be extended by clients.
- * </p>
- */
-public class RunExternalToolAction extends Action {
- private boolean alwaysPromptForArguments = false;
- private IWorkbenchWindow window;
- private ExternalTool tool;
-
- /**
- * Create an action to run an external tool
- */
- public RunExternalToolAction(IWorkbenchWindow window) {
- this(window, false);
- setText(ToolMessages.getString("RunExternalToolAction.text")); //$NON-NLS-1$
- setToolTipText(ToolMessages.getString("RunExternalToolAction.toolTip")); //$NON-NLS-1$
- setHoverImageDescriptor(ExternalToolsPlugin.getDefault().getImageDescriptor("icons/full/clcl16/run_tool.gif")); //$NON-NLS-1$
- setImageDescriptor(ExternalToolsPlugin.getDefault().getImageDescriptor("icons/full/elcl16/run_tool.gif")); //$NON-NLS-1$
- setDisabledImageDescriptor(ExternalToolsPlugin.getDefault().getImageDescriptor("icons/full/dlcl16/run_tool.gif")); //$NON-NLS-1$
- WorkbenchHelp.setHelp(this, IHelpContextIds.RUN_TOOL_ACTION);
- }
-
- /**
- * Create an action to run an external tool
- */
- protected RunExternalToolAction(IWorkbenchWindow window, boolean alwaysPromptForArguments) {
- super();
- this.window = window;
- this.alwaysPromptForArguments = alwaysPromptForArguments;
- }
-
- /**
- * Returns the last external tool to be run
- * or <code>null</code> if none.
- */
- public static final ExternalTool getLastTool() {
- return FavoritesManager.getInstance().getLastTool();
- }
-
- /**
- * Returns the external tool that will be run
- * or <code>null</code> if none.
- */
- public final ExternalTool getTool() {
- return tool;
- }
-
- /**
- * Returns the workbench window this action
- * is to be run in.
- */
- protected final IWorkbenchWindow getWindow() {
- return window;
- }
-
- /**
- * Opens the console to which messages captured
- * from the running tool's output will be logged
- * to.
- */
- protected final void openLogConsole() {
- IWorkbenchPage page = window.getActivePage();
- try {
- if (page != null) {
- page.showView(IExternalToolConstants.LOG_CONSOLE_VIEW_ID);
- }
- } catch (PartInitException e) {
- ExternalToolsPlugin.getDefault().getLog().log(e.getStatus());
- }
- LogConsoleDocument.getInstance().clearOutput();
- }
-
-
- /**
- * Opens the perspective as spedified by the id.
- *
- * @param perspectiveId the perspective id to open
- */
- protected final void openPerspective(String perspectiveId) {
- try {
- window.getWorkbench().showPerspective(perspectiveId, window);
- } catch (WorkbenchException e) {
- ErrorDialog.openError(
- window.getShell(),
- ToolMessages.getString("RunExternalToolAction.openPerspTitle"), //$NON-NLS-1$;
- ToolMessages.getString("RunExternalToolAction.openPerspProblem"), //$NON-NLS-1$;
- e.getStatus());
- ExternalToolsPlugin.getDefault().log(ToolMessages.getString("RunExternalToolAction.openPerspProblem"), e);
- }
- }
-
- /**
- * Prompts the user to change the tool's arguments before
- * running the tool.
- *
- * @return <code>true</code> to continue, or <code>false</code> to stop
- */
- protected final boolean promptForArguments() {
- return true;
- }
-
- /* (non-Javadoc)
- * Method declared on Action.
- */
- public void run() {
- if (tool == null)
- return;
-
- // Get the selection now to avoid invalid thread access and current
- // active part changes when perspective and/or console is shown.
- ISelection sel = window.getSelectionService().getSelection();
- IWorkbenchPart activePart = window.getPartService().getActivePart();
-
- if (alwaysPromptForArguments || tool.getPromptForArguments()) {
- if (!promptForArguments())
- return;
- }
-
- if (tool.getSaveDirtyEditors())
- saveDirtyEditors();
-
- if (tool.getOpenPerspective() != null)
- openPerspective(tool.getOpenPerspective());
-
- if (tool.getShowConsole())
- openLogConsole();
-
- try {
- ToolRunnable runnable = new ToolRunnable(tool, window);
- runnable.selection = sel;
- runnable.activePart = activePart;
- ProgressMonitorDialog dialog = new ProgressMonitorDialog(window.getShell());
- dialog.run(true, true, runnable);
- } catch (InterruptedException e) {
- // Do nothing.
- } catch (InvocationTargetException e) {
- IStatus status = null;
- if (e.getTargetException() instanceof CoreException) {
- status = ((CoreException)e.getTargetException()).getStatus();
- } else {
- String msg = ToolMessages.getString("RunExternalToolAction.internalError"); //$NON-NLS-1$;
- status = ExternalToolsPlugin.newErrorStatus(msg, e.getTargetException());
- }
- ErrorDialog.openError(
- window.getShell(),
- ToolMessages.getString("RunExternalToolAction.runErrorTitle"), //$NON-NLS-1$;
- ToolMessages.getString("RunExternalToolAction.runProblem"), //$NON-NLS-1$;
- status);
- }
-
- // Keep track of the most recently run tool.
- FavoritesManager.getInstance().setLastTool(tool);
- }
-
- /**
- * Saves all dirty editors.
- */
- protected final void saveDirtyEditors() {
- IWorkbenchWindow[] windows = window.getWorkbench().getWorkbenchWindows();
- for (int i = 0; i < windows.length; i++) {
- IWorkbenchPage[] pages = windows[i].getPages();
- for (int j = 0; j < pages.length; j++) {
- pages[j].saveAllEditors(false);
- }
- }
- }
-
- /**
- * Sets the external tool to run or
- * <code>null</code> to not run any tool.
- */
- public final void setTool(ExternalTool tool) {
- this.tool = tool;
- setEnabled(tool != null);
- }
-
-
- /**
- * Helper class that implements the runnable interface
- * and will run the external tool.
- */
- private static final class ToolRunnable implements IRunnableWithProgress {
- private IWorkbenchWindow window;
- private ExternalTool tool;
- private IResource selectedResource = null;
- private DefaultRunnerContext context;
- private MultiStatus status;
- protected ISelection selection;
- protected IWorkbenchPart activePart;
-
- public ToolRunnable(ExternalTool tool, IWorkbenchWindow window) {
- super();
- this.tool = tool;
- this.window = window;
- }
-
- private void determineSelectedResource() {
- if (selection instanceof IStructuredSelection) {
- Object result = ((IStructuredSelection)selection).getFirstElement();
- if (result instanceof IResource) {
- selectedResource = (IResource) result;
- } else if (result instanceof IAdaptable) {
- selectedResource = (IResource)((IAdaptable) result).getAdapter(IResource.class);
- }
- }
-
- if (selectedResource == null) {
- // If the active part is an editor, get the file resource used as input.
- if (activePart instanceof IEditorPart) {
- IEditorPart editorPart = (IEditorPart) activePart;
- IEditorInput input = editorPart.getEditorInput();
- selectedResource = (IResource) input.getAdapter(IResource.class);
- }
- }
- }
-
- private void displayErrorStatus() {
- ErrorDialog.openError(
- window.getShell(),
- ToolMessages.getString("RunExternalToolAction.runErrorTitle"), //$NON-NLS-1$;
- null,
- status);
- }
-
- public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
- determineSelectedResource();
- context = new DefaultRunnerContext(tool, selectedResource);
- status = new MultiStatus(IExternalToolConstants.PLUGIN_ID, 0, ToolMessages.getString("RunExternalToolAction.runProblem"), null); //$NON-NLS-1$;
-
- if (tool.getRunInBackground()) {
- Thread thread = new Thread(new Runnable() {
- public void run() {
- context.run(new NullProgressMonitor(), status);
- if (!status.isOK()) {
- if (window.getShell() != null && !window.getShell().isDisposed()) {
- window.getShell().getDisplay().syncExec(new Runnable() {
- public void run() {
- displayErrorStatus();
- }
- });
- }
- }
- }
- });
- thread.start();
- } else {
- context.run(monitor, status);
- if (!status.isOK())
- if (window.getShell() != null && !window.getShell().isDisposed()) {
- window.getShell().getDisplay().syncExec(new Runnable() {
- public void run() {
- displayErrorStatus();
- }
- });
- }
- }
- };
- }
-}
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/action/RunWithExternalToolAction.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/action/RunWithExternalToolAction.java
deleted file mode 100644
index 11ec414f1..000000000
--- a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/action/RunWithExternalToolAction.java
+++ /dev/null
@@ -1,45 +0,0 @@
-package org.eclipse.ui.externaltools.action;
-
-/**********************************************************************
-Copyright (c) 2002 IBM Corp. and others. All rights reserved.
-This file is made available under the terms of the Common Public License v1.0
-which accompanies this distribution, and is available at
-http://www.eclipse.org/legal/cpl-v10.html
-Contributors:
-**********************************************************************/
-
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.externaltools.internal.model.ExternalToolsPlugin;
-import org.eclipse.ui.externaltools.internal.model.IHelpContextIds;
-import org.eclipse.ui.externaltools.internal.model.ToolMessages;
-import org.eclipse.ui.help.WorkbenchHelp;
-
-/**
- * Action to run an external tool and prompt the
- * user for arguments beforehand.
- * <p>
- * This class is not intended to be extended by clients.
- * </p>
- */
-public class RunWithExternalToolAction extends RunExternalToolAction {
-
- /**
- * Create an action to run an external tool.
- */
- public RunWithExternalToolAction(IWorkbenchWindow window) {
- super(window, true);
- setText(ToolMessages.getString("RunWithExternalToolAction.text")); //$NON-NLS-1$
- setToolTipText(ToolMessages.getString("RunWithExternalToolAction.toolTip")); //$NON-NLS-1$
- setHoverImageDescriptor(ExternalToolsPlugin.getDefault().getImageDescriptor("icons/full/clcl16/runwith_tool.gif")); //$NON-NLS-1$
- setImageDescriptor(ExternalToolsPlugin.getDefault().getImageDescriptor("icons/full/elcl16/runwith_tool.gif")); //$NON-NLS-1$
- setDisabledImageDescriptor(ExternalToolsPlugin.getDefault().getImageDescriptor("icons/full/dlcl16/runwith_tool.gif")); //$NON-NLS-1$
- WorkbenchHelp.setHelp(this, IHelpContextIds.RUN_WITH_TOOL_ACTION);
- }
-
- public void run() {
- MessageDialog.openInformation(Display.getCurrent().getActiveShell(), "Run With", "This action is not yet implemented.");
- }
-}
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/dialog/ExternalToolGroupPropertyPage.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/dialog/ExternalToolGroupPropertyPage.java
deleted file mode 100644
index 796cc7040..000000000
--- a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/dialog/ExternalToolGroupPropertyPage.java
+++ /dev/null
@@ -1,160 +0,0 @@
-package org.eclipse.ui.externaltools.dialog;
-
-/**********************************************************************
-Copyright (c) 2002 IBM Corp. and others. All rights reserved.
-This file is made available under the terms of the Common Public License v1.0
-which accompanies this distribution, and is available at
-http://www.eclipse.org/legal/cpl-v10.html
-Contributors:
-**********************************************************************/
-
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.ui.dialogs.PropertyPage;
-import org.eclipse.ui.externaltools.group.IExternalToolGroup;
-import org.eclipse.ui.externaltools.group.IGroupDialogPage;
-import org.eclipse.ui.externaltools.model.ExternalTool;
-import org.eclipse.ui.externaltools.model.ExternalToolStorage;
-import org.eclipse.ui.help.WorkbenchHelp;
-
-/**
- * Generic property page that will display an <code>IExternalToolGroup</code>
- * as its content.
- * <p>
- * Client can extend this class.
- * </p>
- */
-public class ExternalToolGroupPropertyPage extends PropertyPage implements IGroupDialogPage {
- private IExternalToolGroup group;
- private String helpContextId;
-
- /**
- * Creates a property page for the specified group.
- *
- * @param group the external tool group component to display
- * @param helpContextId the help context id for this page
- */
- protected ExternalToolGroupPropertyPage(IExternalToolGroup group, String helpContextId) {
- super();
- this.group = group;
- this.helpContextId = helpContextId;
- }
-
- /*
- * (non-Javadoc)
- * Method declared on IGroupDialogPage.
- */
- public int convertHeightHint(int chars) {
- return convertHeightInCharsToPixels(chars);
- }
-
- /* (non-Javadoc)
- * Method declared on PreferencePage.
- */
- protected Control createContents(Composite parent) {
- Composite composite = new Composite(parent, SWT.NULL);
- composite.setLayout(new GridLayout());
- composite.setLayoutData(new GridData(GridData.FILL_BOTH));
- if (helpContextId != null)
- WorkbenchHelp.setHelp(composite, helpContextId);
-
- if (group != null) {
- initializeDialogUnits(parent);
- group.createContents(composite, getExternalTool(), this);
- }
-
- return composite;
- }
-
- /* (non-Javadoc)
- * Method declared on IDialogPage.
- */
- public void dispose() {
- super.dispose();
- if (group != null)
- group.dispose();
- }
-
- /**
- * Returns the external tool using the property
- * page element, or <code>null</code> if not possible.
- */
- protected ExternalTool getExternalTool() {
- IAdaptable element = getElement();
- if (element instanceof ExternalTool)
- return (ExternalTool)element;
- return (ExternalTool) element.getAdapter(ExternalTool.class);
- }
-
- /**
- * Returns the external tool group component.
- */
- public IExternalToolGroup getGroup() {
- return group;
- }
-
- /* (non-Javadoc)
- * Method declared on PreferencePage.
- */
- protected void performDefaults() {
- if (group != null) {
- ExternalTool tool = getExternalTool();
- if (tool != null)
- group.restoreValues(tool);
- }
-
- super.performDefaults();
- }
-
- /* (non-Javadoc)
- * Method declared on IPreferencePage.
- */
- public boolean performOk() {
- if (group != null) {
- if (!group.isValid())
- return false;
- ExternalTool tool = getExternalTool();
- if (tool != null) {
- group.updateTool(tool);
- return ExternalToolStorage.saveTool(tool, getShell());
- }
- }
-
- return super.performOk();
- }
-
- /* (non-Javadoc)
- * Method declared on IGroupDialogPage.
- */
- public GridData setButtonGridData(Button button) {
- return setButtonLayoutData(button);
- }
-
- /* (non-Javadoc)
- * Method declared on IWorkbenchPropertyPage.
- */
- public void setElement(IAdaptable element) {
- super.setElement(element);
- if (group != null) {
- ExternalTool tool = getExternalTool();
- if (tool != null)
- group.restoreValues(tool);
- }
- }
-
- /* (non-Javadoc)
- * Method declared on IGroupDialogPage.
- */
- public void updateValidState() {
- if (group != null)
- setValid(group.isValid());
- else
- setValid(true);
- }
-}
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/dialog/ExternalToolGroupWizardPage.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/dialog/ExternalToolGroupWizardPage.java
deleted file mode 100644
index 6b219d0e5..000000000
--- a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/dialog/ExternalToolGroupWizardPage.java
+++ /dev/null
@@ -1,102 +0,0 @@
-package org.eclipse.ui.externaltools.dialog;
-
-/**********************************************************************
-Copyright (c) 2002 IBM Corp. and others. All rights reserved.
-This file is made available under the terms of the Common Public License v1.0
-which accompanies this distribution, and is available at
-http://www.eclipse.org/legal/cpl-v10.html
-Contributors:
-**********************************************************************/
-
-import org.eclipse.jface.wizard.WizardPage;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.externaltools.group.IExternalToolGroup;
-import org.eclipse.ui.externaltools.group.IGroupDialogPage;
-import org.eclipse.ui.help.WorkbenchHelp;
-
-/**
- * Generic wizard page that will display an <code>IExternalToolGroup</code>
- * as its content. Client is responsible to set the page's title,
- * description, and image descriptor.
- * <p>
- * This class can be used as is by clients.
- * </p>
- */
-public class ExternalToolGroupWizardPage extends WizardPage implements IGroupDialogPage {
- private IExternalToolGroup group;
- private String helpContextId;
-
- /**
- * Creates a wizard page for the specified group.
- *
- * @param pageName name given to the page
- * @param group the external tool group component to display
- */
- public ExternalToolGroupWizardPage(String pageName, IExternalToolGroup group, String helpContextId) {
- super(pageName);
- this.group = group;
- this.helpContextId = helpContextId;
- }
-
- /*
- * (non-Javadoc)
- * Method declared on IGroupDialogPage.
- */
- public int convertHeightHint(int chars) {
- return convertHeightInCharsToPixels(chars);
- }
-
- /* (non-Javadoc)
- * Method declared on IDialogPage.
- */
- public void createControl(Composite parent) {
- if (group != null && getControl() == null) {
- initializeDialogUnits(parent);
- Composite composite = new Composite(parent, SWT.NULL);
- composite.setLayout(new GridLayout());
- composite.setLayoutData(new GridData(GridData.FILL_BOTH));
- if (helpContextId != null)
- WorkbenchHelp.setHelp(composite, helpContextId);
- group.createContents(composite, null, this);
- setControl(composite);
- }
- }
-
- /* (non-Javadoc)
- * Method declared on IDialogPage.
- */
- public void dispose() {
- super.dispose();
- if (group != null)
- group.dispose();
- }
-
- /**
- * Returns the external tool group component.
- */
- public IExternalToolGroup getGroup() {
- return group;
- }
-
- /* (non-Javadoc)
- * Method declared on IGroupDialogPage.
- */
- public GridData setButtonGridData(Button button) {
- return setButtonLayoutData(button);
- }
-
- /* (non-Javadoc)
- * Method declared on IGroupDialogPage.
- */
- public void updateValidState() {
- if (group != null)
- setPageComplete(group.isValid());
- else
- setPageComplete(true);
- }
-}
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/dialog/ExternalToolMainGroupPropertyPage.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/dialog/ExternalToolMainGroupPropertyPage.java
deleted file mode 100644
index b4887fa8f..000000000
--- a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/dialog/ExternalToolMainGroupPropertyPage.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package org.eclipse.ui.externaltools.dialog;
-
-/**********************************************************************
-Copyright (c) 2002 IBM Corp. and others. All rights reserved.
-This file is made available under the terms of the Common Public License v1.0
-which accompanies this distribution, and is available at
-http://www.eclipse.org/legal/cpl-v10.html
-Contributors:
-**********************************************************************/
-
-import org.eclipse.ui.externaltools.group.ExternalToolMainGroup;
-import org.eclipse.ui.externaltools.internal.model.IHelpContextIds;
-
-/**
- * Property page to show the main group.
- */
-public class ExternalToolMainGroupPropertyPage extends ExternalToolGroupPropertyPage {
-
- /**
- * Creates the main group property page.
- */
- public ExternalToolMainGroupPropertyPage() {
- super(new ExternalToolMainGroup(), IHelpContextIds.TOOL_MAIN_PROPERTY_PAGE);
- }
-}
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/dialog/ExternalToolNewWizard.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/dialog/ExternalToolNewWizard.java
deleted file mode 100644
index 7f5530f3c..000000000
--- a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/dialog/ExternalToolNewWizard.java
+++ /dev/null
@@ -1,280 +0,0 @@
-package org.eclipse.ui.externaltools.dialog;
-
-/**********************************************************************
-Copyright (c) 2002 IBM Corp. and others. All rights reserved.
-This file is made available under the terms of the Common Public License v1.0
-which accompanies this distribution, and is available at
-http://www.eclipse.org/legal/cpl-v10.html
-Contributors:
-**********************************************************************/
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.wizard.Wizard;
-import org.eclipse.ui.INewWizard;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.externaltools.group.ExternalToolMainGroup;
-import org.eclipse.ui.externaltools.group.ExternalToolOptionGroup;
-import org.eclipse.ui.externaltools.group.ExternalToolRefreshGroup;
-import org.eclipse.ui.externaltools.group.IExternalToolGroup;
-import org.eclipse.ui.externaltools.internal.model.ExternalToolsPlugin;
-import org.eclipse.ui.externaltools.internal.model.IHelpContextIds;
-import org.eclipse.ui.externaltools.internal.model.ToolMessages;
-import org.eclipse.ui.externaltools.internal.registry.ExternalToolType;
-import org.eclipse.ui.externaltools.model.ExternalTool;
-import org.eclipse.ui.externaltools.model.ExternalToolStorage;
-import org.eclipse.ui.externaltools.model.IExternalToolConstants;
-import org.eclipse.ui.externaltools.model.ToolUtil;
-
-/**
-
-
-/**
- * Abstract wizard to create new external tools of a specified type.
- * <p>
- * This class can be extended by clients.
- * </p>
- */
-public abstract class ExternalToolNewWizard extends Wizard implements INewWizard {
- private ExternalToolType toolType;
- private IResource selectedResource;
- private IWorkbench workbench;
- protected ExternalToolMainGroup mainGroup;
- protected ExternalToolOptionGroup optionGroup;
- protected ExternalToolRefreshGroup refreshGroup;
-
- /**
- * Creates the wizard for a new external tool
- */
- public ExternalToolNewWizard(String toolTypeId) {
- super();
- setWindowTitle(ToolMessages.getString("ExternalToolNewWizard.shellTitle")); //$NON-NLS-1$
- setDefaultPageImageDescriptor(getDefaultImageDescriptor());
- setNeedsProgressMonitor(true);
- toolType = ExternalToolsPlugin.getDefault().getTypeRegistry().getToolType(toolTypeId);
- }
-
- /**
- * Creates a wizard page to contain the external tool
- * main group component and adds it to the wizard page
- * list.
- */
- protected void addMainPage() {
- createMainGroup();
- if (mainGroup == null)
- return;
- ExternalToolGroupWizardPage page;
- page = new ExternalToolGroupWizardPage("mainGroupPage", mainGroup, IHelpContextIds.TOOL_MAIN_WIZARD_PAGE); //$NON-NLS-1$
- if (toolType != null) {
- page.setTitle(toolType.getName());
- page.setDescription(toolType.getDescription());
- }
- addPage(page);
- }
-
- /**
- * Creates a wizard page to contain the external tool
- * option group component and adds it to the wizard page
- * list.
- */
- protected void addOptionPage() {
- createOptionGroup();
- if (optionGroup == null)
- return;
- ExternalToolGroupWizardPage page;
- page = new ExternalToolGroupWizardPage("optionGroupPage", optionGroup, IHelpContextIds.TOOL_OPTION_WIZARD_PAGE); //$NON-NLS-1$
- page.setTitle(ToolMessages.getString("ExternalToolNewWizard.optionPageTitle")); //$NON-NLS-1$
- page.setDescription(ToolMessages.getString("ExternalToolNewWizard.optionPageDescription")); //$NON-NLS-1$
- addPage(page);
- }
-
- /**
- * Creates a wizard page to contain the external tool
- * refresh scope group component and adds it to the wizard page
- * list.
- */
- protected void addRefreshPage() {
- createRefreshGroup();
- if (refreshGroup == null)
- return;
- ExternalToolGroupWizardPage page;
- page = new ExternalToolGroupWizardPage("refreshGroupPage", refreshGroup, IHelpContextIds.TOOL_REFRESH_WIZARD_PAGE); //$NON-NLS-1$
- page.setTitle(ToolMessages.getString("ExternalToolNewWizard.refreshPageTitle")); //$NON-NLS-1$
- page.setDescription(ToolMessages.getString("ExternalToolNewWizard.refreshPageDescription")); //$NON-NLS-1$
- addPage(page);
- }
-
- /**
- * Creates the main group and initializes it using
- * the information from the selected resource.
- */
- protected void createMainGroup() {
- if (mainGroup != null)
- return;
- mainGroup = new ExternalToolMainGroup();
- if (selectedResource != null) {
- String path = selectedResource.getFullPath().toString();
- String loc = ToolUtil.buildVariableTag(
- IExternalToolConstants.VAR_RESOURCE_LOC,
- path);
- mainGroup.setInitialLocation(loc);
-
- String name = path.replace(IPath.SEPARATOR, '-');
- int start = 0;
- while (name.charAt(start) == '-' && start < name.length())
- start++;
- int end = name.lastIndexOf('.');
- if (end == -1)
- end = name.length();
- name = name.substring(start, end);
- mainGroup.setInitialName(name);
- }
- }
-
- /**
- * Creates the option group and initializes it.
- */
- protected void createOptionGroup() {
- if (optionGroup != null)
- return;
- optionGroup = new ExternalToolOptionGroup();
- }
-
- /**
- * Creates the refresh scope group and initializes it.
- */
- protected void createRefreshGroup() {
- if (refreshGroup != null)
- return;
- refreshGroup = new ExternalToolRefreshGroup();
- }
-
- /* (non-Javadoc)
- * Method declared on IWizard.
- */
- public void dispose() {
- super.dispose();
- selectedResource = null;
- }
-
- /**
- * Returns the selected resource.
- */
- protected final IResource getSelectedResource() {
- return selectedResource;
- }
-
- /**
- * Returns the default image descriptor for this wizard.
- *
- * @return the image descriptor or <code>null</code> if
- * none required.
- */
- protected abstract ImageDescriptor getDefaultImageDescriptor();
-
- /**
- * Returns the workbench.
- */
- protected final IWorkbench getWorkbench() {
- return workbench;
- }
-
- /* (non-Javadoc)
- * Method declared on IWorkbenchWizard.
- */
- public void init(IWorkbench workbench, IStructuredSelection selection) {
- this.workbench = workbench;
-
- Object sel = selection.getFirstElement();
- if (sel != null) {
- if (sel instanceof IResource)
- selectedResource = (IResource) sel;
- else if (sel instanceof IAdaptable)
- selectedResource = (IResource)((IAdaptable)sel).getAdapter(IResource.class);
- }
- }
-
- /**
- * Returns a new external tool object that is not yet
- * initialized with the information collected by the
- * wizard.
- * <p>
- * By default, return a new external tool using the name
- * specified in the main page and the tool type of the wizard.
- * </p>
- *
- * @return a new external tool or <code>null</code> if not possible
- */
- protected ExternalTool newTool() {
- if (mainGroup == null)
- return null;
- String name = mainGroup.getNameFieldValue();
- if (name == null || name.length() == 0)
- return null;
- if (toolType == null)
- return null;
- try {
- return new ExternalTool(toolType.getId(), name);
- } catch (CoreException e) {
- return null;
- }
- }
-
- /* (non-Javadoc)
- * Method declared on IWizard.
- */
- public final boolean performFinish() {
- ExternalTool tool = newTool();
- if (tool == null)
- return false;
- if (!updateTool(tool))
- return false;
- return ExternalToolStorage.saveTool(tool, getShell());
- }
-
- /**
- * Update the new external tool with the information
- * collected from the user.
- * <p>
- * By default, ask each group to update the tool.
- * </p>
- *
- * @param tool the new external tool to update
- * @return <code>true</code> if the tool was updated properly,
- * or <code>false</code> if the tool could not be updated
- * and the wiard should remain open.
- */
- protected boolean updateTool(ExternalTool tool) {
- if (!updateToolFromGroup(tool, mainGroup))
- return false;
- if (!updateToolFromGroup(tool, optionGroup))
- return false;
- if (!updateToolFromGroup(tool, refreshGroup))
- return false;
- return true;
- }
-
- /**
- * Update the new external tool with the information
- * collected from the user via an external tool group.
- *
- * @param tool the new external tool to update
- * @param group the external tool group of visual component (<code>null</code> is ignored)
- * @return <code>true</code> if the tool was updated properly,
- * or <code>false</code> if the tool could not be updated
- * because the group was in an invalid state.
- */
- protected final boolean updateToolFromGroup(ExternalTool tool, IExternalToolGroup group) {
- if (group == null)
- return true;
- if (!group.isValid())
- return false;
- group.updateTool(tool);
- return true;
- }
-}
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/dialog/ExternalToolOptionGroupPropertyPage.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/dialog/ExternalToolOptionGroupPropertyPage.java
deleted file mode 100644
index 62314b206..000000000
--- a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/dialog/ExternalToolOptionGroupPropertyPage.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package org.eclipse.ui.externaltools.dialog;
-
-/**********************************************************************
-Copyright (c) 2002 IBM Corp. and others. All rights reserved.
-This file is made available under the terms of the Common Public License v1.0
-which accompanies this distribution, and is available at
-http://www.eclipse.org/legal/cpl-v10.html
-Contributors:
-**********************************************************************/
-
-import org.eclipse.ui.externaltools.group.ExternalToolOptionGroup;
-import org.eclipse.ui.externaltools.internal.model.IHelpContextIds;
-
-/**
- * Property page to show the main group.
- */
-public class ExternalToolOptionGroupPropertyPage extends ExternalToolGroupPropertyPage {
-
- /**
- * Creates the main group property page.
- */
- public ExternalToolOptionGroupPropertyPage() {
- super(new ExternalToolOptionGroup(), IHelpContextIds.TOOL_OPTION_PROPERTY_PAGE);
- }
-}
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/dialog/ExternalToolRefreshGroupPropertyPage.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/dialog/ExternalToolRefreshGroupPropertyPage.java
deleted file mode 100644
index 94e7a6c60..000000000
--- a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/dialog/ExternalToolRefreshGroupPropertyPage.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package org.eclipse.ui.externaltools.dialog;
-
-/**********************************************************************
-Copyright (c) 2002 IBM Corp. and others. All rights reserved.
-This file is made available under the terms of the Common Public License v1.0
-which accompanies this distribution, and is available at
-http://www.eclipse.org/legal/cpl-v10.html
-Contributors:
-**********************************************************************/
-
-import org.eclipse.ui.externaltools.group.ExternalToolRefreshGroup;
-import org.eclipse.ui.externaltools.internal.model.IHelpContextIds;
-
-/**
- * Property page to show the main group.
- */
-public class ExternalToolRefreshGroupPropertyPage extends ExternalToolGroupPropertyPage {
-
- /**
- * Creates the main group property page.
- */
- public ExternalToolRefreshGroupPropertyPage() {
- super(new ExternalToolRefreshGroup(), IHelpContextIds.TOOL_REFRESH_PROPERTY_PAGE);
- }
-}
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/group/ExternalToolGroup.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/group/ExternalToolGroup.java
deleted file mode 100644
index ba6d519ff..000000000
--- a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/group/ExternalToolGroup.java
+++ /dev/null
@@ -1,146 +0,0 @@
-package org.eclipse.ui.externaltools.group;
-
-/**********************************************************************
-Copyright (c) 2002 IBM Corp. and others. All rights reserved.
-This file is made available under the terms of the Common Public License v1.0
-which accompanies this distribution, and is available at
-http://www.eclipse.org/legal/cpl-v10.html
-Contributors:
-**********************************************************************/
-
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.ui.externaltools.model.ExternalTool;
-
-/**
- * The standard abstract implementation of an <code>IExternalToolGroup</code>.
- */
-public abstract class ExternalToolGroup implements IExternalToolGroup {
- /**
- * Recommended initial size for a text field within a group.
- */
- public static final int SIZING_TEXT_FIELD_WIDTH = 250;
-
- /**
- * Dialog page this group is part of.
- */
- private IGroupDialogPage page;
-
- /**
- * Whether the group is working with an existing external
- * tool, or a, yet to be created, new external tool.
- */
- private boolean isEditMode = true;
-
- /**
- * Whether the group's values are all valid.
- */
- private boolean isValid = true;
-
- /**
- * Creates the group.
- */
- public ExternalToolGroup() {
- super();
- }
-
- /* (non-Javadoc)
- * Method declared on IExternalToolGroup.
- */
- public final Control createContents(Composite parent, ExternalTool tool, IGroupDialogPage page) {
- this.page = page;
- this.isEditMode = tool != null;
- return createGroupContents(parent, tool);
- }
-
- /**
- * Creates this group's visual components.
- *
- * @param parent the composite to parent the group's control
- * @param tool the external tool to be edited, or <code>null</code> for a new tool
- * @return the control for the group
- */
- protected abstract Control createGroupContents(Composite parent, ExternalTool tool);
-
- /* (non-Javadoc)
- * Method declared on IExternalToolGroup.
- */
- public void dispose() {
- page = null;
- }
-
- /**
- * Returns the dialog page this group is part of.
- *
- * @return the dialog page this group is part of
- */
- protected final IGroupDialogPage getPage() {
- return page;
- }
-
- /**
- * Returns <code>true</code> if the group is editing an existing
- * external tool, or <code>false</code> if the external tool is new
- * and yet to be created.
- *
- * @return <code>true</code> if the external tool exist already, or
- * <code>false</code> if the external tool is yet to be created.
- */
- protected final boolean isEditMode() {
- return isEditMode;
- }
-
- /* (non-Javadoc)
- * Method declared on IExternalToolGroup.
- */
- public boolean isValid() {
- return isValid;
- }
-
- /**
- * Sets whether the group's values are all valid.
- * Updates the group's page valid state. No action
- * taken if new valid state same as current one.
- *
- * @param isValid <code>true</code> if all values valid,
- * <code>false</code> otherwise
- */
- protected final void setIsValid(boolean isValid) {
- if (this.isValid != isValid) {
- this.isValid = isValid;
- this.page.updateValidState();
- }
- }
-
- /* (non-Javadoc)
- * Method declared on IExternalToolGroup.
- */
- public abstract void restoreValues(ExternalTool tool);
-
- /* (non-Javadoc)
- * Method declared on IExternalToolGroup.
- */
- public void setVisible(boolean visible) {
- }
-
- /* (non-Javadoc)
- * Method declared on IExternalToolGroup.
- */
- public abstract void updateTool(ExternalTool tool);
-
- /* (non-Javadoc)
- * Method declared on IExternalToolGroup.
- */
- public abstract void validate();
-
-
- /**
- * Helper class to report group validation information.
- */
- protected static final class ValidationStatus {
- public boolean isValid = true;
- public String message = null;
- public int messageType = IGroupDialogPage.NONE;
- }
-}
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/group/ExternalToolMainGroup.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/group/ExternalToolMainGroup.java
deleted file mode 100644
index 6cd594404..000000000
--- a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/group/ExternalToolMainGroup.java
+++ /dev/null
@@ -1,640 +0,0 @@
-package org.eclipse.ui.externaltools.group;
-
-/**********************************************************************
-Copyright (c) 2002 IBM Corp. and others. All rights reserved.
-This file is made available under the terms of the Common Public License v1.0
-which accompanies this distribution, and is available at
-http://www.eclipse.org/legal/cpl-v10.html
-Contributors:
-**********************************************************************/
-
-import java.io.File;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.MultiStatus;
-import org.eclipse.jface.dialogs.IMessageProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.DirectoryDialog;
-import org.eclipse.swt.widgets.FileDialog;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.dialogs.ContainerSelectionDialog;
-import org.eclipse.ui.dialogs.SelectionDialog;
-import org.eclipse.ui.externaltools.internal.dialog.ExternalToolVariableForm;
-import org.eclipse.ui.externaltools.internal.model.ExternalToolsPlugin;
-import org.eclipse.ui.externaltools.internal.model.IHelpContextIds;
-import org.eclipse.ui.externaltools.internal.model.ToolMessages;
-import org.eclipse.ui.externaltools.model.ExternalTool;
-import org.eclipse.ui.externaltools.model.IExternalToolConstants;
-import org.eclipse.ui.externaltools.model.ToolUtil;
-import org.eclipse.ui.externaltools.variable.ExpandVariableContext;
-import org.eclipse.ui.help.WorkbenchHelp;
-import org.eclipse.ui.model.WorkbenchContentProvider;
-import org.eclipse.ui.model.WorkbenchLabelProvider;
-
-/**
- * Group of components applicable to most external tools. This group
- * will collect from the user the location, working directory,
- * name, and description for the tool.
- * <p>
- * This group can be used or extended by clients.
- * </p>
- */
-public class ExternalToolMainGroup extends ExternalToolGroup {
- private String initialLocation = ""; //$NON-NLS-1$
- private String initialName = ""; //$NON-NLS-1$
- private String initialWorkDirectory = ""; //$NON-NLS-1$
- protected Text locationField;
- protected Text workDirectoryField;
- protected Text nameField;
- protected Text descriptionField;
- private Button fileLocationButton;
- private Button workspaceLocationButton;
- private Button fileWorkingDirectoryButton;
- private Button workspaceWorkingDirectoryButton;
-
- private ModifyListener modifyListener = new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- validate();
- }
- };
-
- /**
- * Creates the group
- */
- public ExternalToolMainGroup() {
- super();
- }
-
- /* (non-Javadoc)
- * Method declared on ExternalToolGroup.
- */
- protected Control createGroupContents(Composite parent, ExternalTool tool) {
- // main composite
- Composite mainComposite = new Composite(parent, SWT.NONE);
- GridLayout layout = new GridLayout();
- layout.marginWidth = 0;
- layout.marginHeight = 0;
- layout.numColumns = 2;
- GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
- mainComposite.setLayout(layout);
- mainComposite.setLayoutData(gridData);
-
- createLocationComponent(mainComposite);
- createWorkDirectoryComponent(mainComposite);
- createNameComponent(mainComposite);
- createDescriptionComponent(mainComposite);
-
- if (locationField != null) {
- locationField.setText(isEditMode() ? tool.getLocation() : initialLocation);
- locationField.addModifyListener(modifyListener);
- }
-
- if (workDirectoryField != null) {
- workDirectoryField.setText(isEditMode() ? tool.getWorkingDirectory() : initialWorkDirectory);
- workDirectoryField.addModifyListener(modifyListener);
- }
-
- if (nameField != null) {
- nameField.setText(isEditMode() ? tool.getName() : initialName);
- if (isEditMode())
- nameField.setEditable(false);
- else
- nameField.addModifyListener(modifyListener);
- }
-
- validate();
-
- return mainComposite;
- }
-
- /**
- * Creates the controls needed to edit the description
- * attribute of an external tool
- *
- * @param parent the composite to create the controls in
- */
- protected void createDescriptionComponent(Composite parent) {
- Label label = new Label(parent, SWT.NONE);
- label.setText(ToolMessages.getString("ExternalToolMainGroup.descriptionLabel")); //$NON-NLS-1$
- GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- data.horizontalSpan = 2;
- label.setLayoutData(data);
-
- descriptionField = new Text(parent, SWT.BORDER);
- data = new GridData(GridData.FILL_HORIZONTAL);
- data.widthHint = SIZING_TEXT_FIELD_WIDTH;
- descriptionField.setLayoutData(data);
-
- createSpacer(parent);
- }
-
- /**
- * Creates the controls needed to edit the location
- * attribute of an external tool
- *
- * @param parent the composite to create the controls in
- */
- protected void createLocationComponent(Composite parent) {
- Label label = new Label(parent, SWT.NONE);
- label.setText(ToolMessages.getString("ExternalToolMainGroup.locationLabel")); //$NON-NLS-1$
- GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- data.horizontalSpan = 2;
- label.setLayoutData(data);
-
- locationField = new Text(parent, SWT.BORDER);
- data = new GridData(GridData.FILL_HORIZONTAL);
- data.widthHint = SIZING_TEXT_FIELD_WIDTH;
- data.verticalSpan= 2;
- locationField.setLayoutData(data);
-
- workspaceLocationButton= createPushButton(parent, "Browse Workspace...");
- fileLocationButton= createPushButton(parent, "Browse File System...");
-
- createSpacer(parent);
- }
-
- private Button createPushButton(Composite parent, String label) {
- Button button= new Button(parent, SWT.PUSH );
- button.setText(ToolMessages.getString(label));
- button.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- handleButtonPressed((Button)e.widget);
- }
- });
- getPage().setButtonGridData(button);
- return button;
- }
-
- private void handleButtonPressed(Button button) {
- String text= null;
- Text field= null;
- if (button == fileLocationButton) {
- text= getFileLocation();
- field= locationField;
- } else if (button == workspaceLocationButton) {
- text= getWorkspaceLocation();
- field= locationField;
- } else if (button == fileWorkingDirectoryButton) {
- DirectoryDialog dialog = new DirectoryDialog(getShell(), SWT.SAVE);
- dialog.setMessage("Select a directory");
- dialog.setFilterPath(workDirectoryField.getText());
- text= dialog.open();
- field= workDirectoryField;
- } else if (button == workspaceWorkingDirectoryButton) {
- ContainerSelectionDialog containerDialog;
- containerDialog = new ContainerSelectionDialog(
- getShell(),
- ResourcesPlugin.getWorkspace().getRoot(),
- false,
- "Select a directory");
- containerDialog.open();
- Object[] resource = containerDialog.getResult();
- if (resource != null && resource.length > 0) {
- text= ToolUtil.buildVariableTag(IExternalToolConstants.VAR_RESOURCE_LOC, ((IPath)resource[0]).toString());
- }
- field= workDirectoryField;
- }
- if (text != null && field != null) {
- field.setText(text);
- }
- }
-
- private String getFileLocation() {
- FileDialog fileDialog = new FileDialog(getShell(), SWT.NONE);
- fileDialog.setFileName(locationField.getText());
- return fileDialog.open();
- }
-
- /**
- * Prompts the user for a workspace location and returns the location
- * as a String containing the workspace_loc variable or <code>null</code>
- * if no location was obtained from the user. */
- private String getWorkspaceLocation() {
- ResourceSelectionDialog dialog;
- dialog = new ResourceSelectionDialog(getShell(), ResourcesPlugin.getWorkspace().getRoot(), "Select a resource");
- dialog.open();
- Object[] results = dialog.getResult();
- if (results == null || results.length < 1) {
- return null;
- }
- IResource resource = (IResource)results[0];
- StringBuffer buf = new StringBuffer();
- ToolUtil.buildVariableTag(IExternalToolConstants.VAR_WORKSPACE_LOC, resource.getFullPath().toString(), buf);
- return buf.toString();
- }
-
- /**
- * Internal dialog to show available resources from which
- * the user can select one
- */
- private class ResourceSelectionDialog extends SelectionDialog {
- String labelText;
- IContainer root;
- TreeViewer wsTree;
-
- public ResourceSelectionDialog(Shell parent, IContainer root, String labelText) {
- super(parent);
- this.root = root;
- this.labelText = labelText;
- setShellStyle(getShellStyle() | SWT.RESIZE);
- setTitle(ToolMessages.getString("EditDialog.browseWorkspaceTitle")); //$NON-NLS-1$
- WorkbenchHelp.setHelp(parent, IHelpContextIds.RESOURCE_SELECTION_DIALOG);
- }
-
- /* (non-Javadoc)
- * Method declared on Dialog.
- */
- protected Control createDialogArea(Composite parent) {
- // create composite
- Composite dialogArea = (Composite)super.createDialogArea(parent);
-
- Label label = new Label(dialogArea, SWT.LEFT);
- label.setText(labelText);
-
- Tree tree = new Tree(dialogArea, SWT.H_SCROLL | SWT.V_SCROLL | SWT.SINGLE | SWT.BORDER);
- GridData data = new GridData(GridData.FILL_BOTH);
- data.heightHint = 300;
- data.widthHint = 300;
- tree.setLayoutData(data);
- wsTree = new TreeViewer(tree);
- wsTree.setContentProvider(new WorkbenchContentProvider());
- wsTree.setLabelProvider(new WorkbenchLabelProvider());
- wsTree.setInput(root);
-
- return dialogArea;
- }
-
- /* (non-Javadoc)
- * Method declared on Dialog.
- */
- protected void okPressed() {
- IStructuredSelection sel = (IStructuredSelection)wsTree.getSelection();
- if (sel != null)
- setSelectionResult(sel.toArray());
- super.okPressed();
- }
- }
-
- private class WorkspaceSelectionDialog extends SelectionDialog {
- public WorkspaceSelectionDialog() {
- super(ExternalToolMainGroup.this.getShell());
- }
- protected Control createDialogArea(Composite parent) {
- Composite composite= (Composite)super.createDialogArea(parent);
- ExternalToolVariableForm form= new ExternalToolVariableForm("Select from workspace", ExternalToolsPlugin.getDefault().getDirectoryLocationVariableRegistry().getPathLocationVariables());
- form.createContents(composite, new IGroupDialogPage() {
- public GridData setButtonGridData(Button button) {
- return null;
- }
-
- public void setMessage(String newMessage, int newType) {
- }
-
- public void updateValidState() {
- }
-
- public int convertHeightHint(int chars) {
- return 0;
- }
-
- public String getMessage() {
- return null;
- }
-
- public int getMessageType() {
- return 0;
- }
- });
- return composite;
- }
-
- }
-
- private Shell getShell() {
- return PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
- }
-
- /**
- * Creates the controls needed to edit the name
- * attribute of an external tool
- *
- * @param parent the composite to create the controls in
- */
- protected void createNameComponent(Composite parent) {
- Label label = new Label(parent, SWT.NONE);
- label.setText(ToolMessages.getString("ExternalToolMainGroup.nameLabel")); //$NON-NLS-1$
- GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- data.horizontalSpan = 2;
- label.setLayoutData(data);
-
- nameField = new Text(parent, SWT.BORDER);
- data = new GridData(GridData.FILL_HORIZONTAL);
- data.widthHint = SIZING_TEXT_FIELD_WIDTH;
- nameField.setLayoutData(data);
-
- createSpacer(parent);
- }
-
- /**
- * Creates a vertical space between controls.
- */
- protected void createSpacer(Composite parent) {
- Label label = new Label(parent, SWT.NONE);
- GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- data.horizontalSpan = 2;
- label.setLayoutData(data);
- }
-
- /**
- * Creates the controls needed to edit the working directory
- * attribute of an external tool
- *
- * @param parent the composite to create the controls in
- */
- protected void createWorkDirectoryComponent(Composite parent) {
- Label label = new Label(parent, SWT.NONE);
- label.setText(ToolMessages.getString("ExternalToolMainGroup.workDirLabel")); //$NON-NLS-1$
- GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- data.horizontalSpan = 2;
- label.setLayoutData(data);
-
- workDirectoryField = new Text(parent, SWT.BORDER);
- data = new GridData(GridData.FILL_HORIZONTAL);
- data.widthHint = SIZING_TEXT_FIELD_WIDTH;
- data.verticalSpan= 2;
- workDirectoryField.setLayoutData(data);
-
- workspaceWorkingDirectoryButton= createPushButton(parent, "Browse Workspace...");
- fileWorkingDirectoryButton= createPushButton(parent, "Browse File System...");
-
- createSpacer(parent);
- }
-
- /**
- * Returns the proposed initial location for the external
- * tool if no tool provided in the createContents.
- *
- * @return the proposed initial location when editing new tool.
- */
- public final String getInitialLocation() {
- return initialLocation;
- }
-
- /**
- * Returns the proposed initial name for the external
- * tool if no tool provided in the createContents.
- *
- * @return the proposed initial name when editing new tool.
- */
- public final String getInitialName() {
- return initialName;
- }
-
- /**
- * Returns the proposed initial working directory for the external
- * tool if no tool provided in the createContents.
- *
- * @return the proposed initial working directory when editing new tool.
- */
- public final String getInitialWorkDirectory() {
- return initialWorkDirectory;
- }
-
- /**
- * Returns the name given to the external tool as
- * found in the text field, or <code>null</code> if
- * field does not exist
- */
- public String getNameFieldValue() {
- if (nameField != null)
- return nameField.getText().trim();
- else
- return null;
- }
-
- /**
- * Returns the location of the external tool as
- * found in the text field, or <code>null</code> if
- * field does not exist.
- */
- public String getLocationFieldValue() {
- if (locationField != null)
- return locationField.getText().trim();
- else
- return null;
- }
-
- /* (non-Javadoc)
- * Method declared on IExternalToolGroup.
- */
- public void restoreValues(ExternalTool tool) {
- if (locationField != null)
- locationField.setText(tool.getLocation());
- if (workDirectoryField != null)
- workDirectoryField.setText(tool.getWorkingDirectory());
- if (nameField != null)
- nameField.setText(tool.getName());
- if (descriptionField != null)
- descriptionField.setText(tool.getDescription());
- }
-
- /**
- * Sets the proposed initial location for the external
- * tool if no tool provided in the createContents.
- *
- * @param initialLocation the proposed initial location when editing new tool.
- */
- public final void setInitialLocation(String initialLocation) {
- if (initialLocation != null)
- this.initialLocation = initialLocation;
- }
-
- /**
- * Sets the proposed initial name for the external
- * tool if no tool provided in the createContents.
- *
- * @param initialName the proposed initial name when editing new tool.
- */
- public final void setInitialName(String initialName) {
- if (initialName != null)
- this.initialName = initialName;
- }
-
- /**
- * Sets the proposed initial working directory for the external
- * tool if no tool provided in the createContents.
- *
- * @param initialWorkDirectory the proposed initial working directory when editing new tool.
- */
- public final void setInitialWorkDirectory(String initialWorkDirectory) {
- if (initialWorkDirectory != null)
- this.initialWorkDirectory = initialWorkDirectory;
- }
-
- /* (non-Javadoc)
- * Method declared on IExternalToolGroup.
- */
- public void updateTool(ExternalTool tool) {
- if (locationField != null)
- tool.setLocation(locationField.getText().trim());
- if (workDirectoryField != null)
- tool.setWorkingDirectory(workDirectoryField.getText().trim());
- if (descriptionField != null)
- tool.setDescription(descriptionField.getText().trim());
- }
-
- /* (non-Javadoc)
- * Method declared on IExternalToolGroup.
- */
- public void validate() {
- ValidationStatus status = new ValidationStatus();
- validateLocation(status);
- validateWorkDirectory(status);
- validateName(status);
-
- getPage().setMessage(status.message, status.messageType);
- setIsValid(status.isValid);
- }
-
- /**
- * Validates the content of the location field, and
- * updates the validation status. Does nothing if the
- * validation status is already invalid.
- */
- protected void validateLocation(ValidationStatus status) {
- if (locationField == null || !status.isValid)
- return;
-
- String value = locationField.getText().trim();
- if (value.length() < 1) {
- status.message = ToolMessages.getString("ExternalToolMainGroup.locationRequired"); //$NON-NLS-1$
- status.messageType = IMessageProvider.NONE;
- status.isValid = false;
- return;
- }
-
- // Translate field contents to the actual file location so we
- // can check to ensure the file actually exists.
- MultiStatus multiStatus = new MultiStatus(IExternalToolConstants.PLUGIN_ID, 0, "", null); //$NON-NLS-1$
- value = ToolUtil.expandFileLocation(value, ExpandVariableContext.EMPTY_CONTEXT, multiStatus);
- if (!multiStatus.isOK()) {
- IStatus[] children = multiStatus.getChildren();
- if (children.length > 0) {
- status.message = children[0].getMessage();
- status.messageType = IMessageProvider.WARNING;
- }
- status.isValid = false;
- return;
- }
-
- if (value == null) { // The resource could not be found.
- status.message = ToolMessages.getString("ExternalToolMainGroup.invalidLocation"); //$NON-NLS-1$
- status.messageType = IMessageProvider.INFORMATION;
- status.isValid = true;
- return;
- }
-
- File file = new File(value);
- if (!file.exists()) { // The file does not exist.
- status.message = ToolMessages.getString("ExternalToolMainGroup.invalidLocation"); //$NON-NLS-1$
- status.messageType = IMessageProvider.INFORMATION;
- status.isValid = true;
- return;
- }
- }
-
- /**
- * Validates the content of the name field, and
- * updates the validation status. Does nothing if the
- * validation status is already invalid.
- */
- protected void validateName(ValidationStatus status) {
- if (isEditMode() || nameField == null || !status.isValid)
- return;
-
- String value = nameField.getText().trim();
- if (value.length() < 1) {
- status.message = ToolMessages.getString("ExternalToolMainGroup.nameRequired"); //$NON-NLS-1$
- status.messageType = IMessageProvider.WARNING;
- status.isValid = false;
- return;
- }
-
- String errorText = ExternalTool.validateToolName(value);
- if (errorText != null) {
- status.message = errorText;
- status.messageType = IMessageProvider.WARNING;
- status.isValid = false;
- return;
- }
-
- boolean exists = ExternalToolsPlugin.getDefault().getToolRegistry(nameField.getShell()).hasToolNamed(value);
- if (exists) {
- status.message = ToolMessages.getString("ExternalToolMainGroup.nameAlreadyExist"); //$NON-NLS-1$
- status.messageType = IMessageProvider.WARNING;
- status.isValid = false;
- return;
- }
- }
-
- /**
- * Validates the content of the working directory field, and
- * updates the validation status. Does nothing if the
- * validation status is already invalid.
- */
- protected void validateWorkDirectory(ValidationStatus status) {
- if (workDirectoryField == null || !status.isValid)
- return;
-
- String value = workDirectoryField.getText().trim();
- if (value.length() > 0) {
- // Translate field contents to the actual directory location so we
- // can check to ensure the directory actually exists.
- MultiStatus multiStatus = new MultiStatus(IExternalToolConstants.PLUGIN_ID, 0, "", null); //$NON-NLS-1$
- value = ToolUtil.expandDirectoryLocation(value, ExpandVariableContext.EMPTY_CONTEXT, multiStatus);
- if (!multiStatus.isOK()) {
- IStatus[] children = multiStatus.getChildren();
- if (children.length > 0) {
- status.message = children[0].getMessage();
- status.messageType = IMessageProvider.WARNING;
- }
- status.isValid = false;
- return;
- }
-
- if (value == null) { // The resource could not be found.
- status.message = ToolMessages.getString("ExternalToolMainGroup.invalidWorkDir"); //$NON-NLS-1$
- status.messageType = IMessageProvider.INFORMATION;
- status.isValid = true;
- return;
- }
- File file = new File(value);
- if (!file.exists()) { // The directory does not exist.
- status.message = ToolMessages.getString("ExternalToolMainGroup.invalidWorkDir"); //$NON-NLS-1$
- status.messageType = IMessageProvider.INFORMATION;
- status.isValid = true;
- return;
- }
- }
- }
-}
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/group/ExternalToolOptionGroup.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/group/ExternalToolOptionGroup.java
deleted file mode 100644
index 72443d5b0..000000000
--- a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/group/ExternalToolOptionGroup.java
+++ /dev/null
@@ -1,697 +0,0 @@
-package org.eclipse.ui.externaltools.group;
-
-/**********************************************************************
-Copyright (c) 2002 IBM Corp. and others. All rights reserved.
-This file is made available under the terms of the Common Public License v1.0
-which accompanies this distribution, and is available at
-http://www.eclipse.org/legal/cpl-v10.html
-Contributors:
-**********************************************************************/
-
-import java.text.Collator;
-import java.util.Arrays;
-import java.util.Comparator;
-
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.IMessageProvider;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.IPerspectiveDescriptor;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.dialogs.SelectionDialog;
-import org.eclipse.ui.externaltools.internal.dialog.ExternalToolVariableForm;
-import org.eclipse.ui.externaltools.internal.model.ExternalToolsPlugin;
-import org.eclipse.ui.externaltools.internal.model.ToolMessages;
-import org.eclipse.ui.externaltools.internal.registry.ExternalToolVariable;
-import org.eclipse.ui.externaltools.model.ExternalTool;
-
-/**
- * Group of components applicable to most external tools. This group
- * will collect from the user the options:
- * <ul>
- * <li>log tool messages to console</li>
- * <li>run tool in background</li>
- * <li>open perspective on run</li>
- * <li>tool arguments</li>
- * <li>prompt for arguments on run</li>
- * </ul>
- * <p>
- * This group can be used or extended by clients.
- * </p>
- */
-public class ExternalToolOptionGroup extends ExternalToolGroup {
- private boolean initialCaptureOutput = true;
- private boolean initialShowConsole = true;
- private boolean initialRunBackground = true;
- private String initialOpenPersp = null;
- private String initialArgument = ""; //$NON-NLS-1$
- private boolean initialPromptArg = false;
- private boolean initialShowInMenu = false;
- private boolean initialSaveDirtyEditors = false;
-
- private String promptArgLabel = null;
-
- protected Button captureOutputButton;
- protected Button showConsoleButton;
- protected Button runBackgroundButton;
- protected Button openPerspButton;
- protected Combo openPerspNameField;
- protected Text argumentField;
- protected Button promptArgButton;
- protected Button showInMenuButton;
- protected Button saveDirtyEditorsButton;
- private Button variableButton;
-
- private IPerspectiveDescriptor[] perspectives;
-
- /**
- * Creates the group
- */
- public ExternalToolOptionGroup() {
- super();
- }
-
- /* (non-Javadoc)
- * Method declared on ExternalToolGroup.
- */
- protected Control createGroupContents(Composite parent, ExternalTool tool) {
- // main composite
- Composite mainComposite = new Composite(parent, SWT.NONE);
- GridLayout layout = new GridLayout();
- layout.marginWidth = 0;
- layout.marginHeight = 0;
- GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
- mainComposite.setLayout(layout);
- mainComposite.setLayoutData(gridData);
-
- createRunBackgroundComponent(mainComposite);
- createCaptureOutputComponent(mainComposite);
- createShowConsoleComponent(mainComposite);
- createOpenPerspComponent(mainComposite);
- createShowInMenuComponent(mainComposite);
- createSaveDirtyEditorsComponent(mainComposite);
- createSpacer(parent);
- createArgumentComponent(mainComposite);
- createPromptForArgumentComponent(mainComposite);
- createSpacer(parent);
-
- if (runBackgroundButton != null) {
- runBackgroundButton.setSelection(isEditMode() ? tool.getRunInBackground() : initialRunBackground);
- }
-
- if (captureOutputButton != null) {
- captureOutputButton.setSelection(isEditMode() ? tool.getCaptureOutput() : initialCaptureOutput);
- }
-
- if (showConsoleButton != null) {
- showConsoleButton.setSelection(isEditMode() ? tool.getShowConsole() : initialShowConsole);
- }
-
- if (openPerspButton != null) {
- String perspId = isEditMode() ? tool.getOpenPerspective() : initialOpenPersp;
- openPerspButton.setSelection(perspId != null);
- }
-
- if (openPerspNameField != null) {
- int index = -1;
- if (isEditMode())
- index = getPerspectiveIndex(tool.getOpenPerspective());
- else
- index = getPerspectiveIndex(initialOpenPersp);
- if (index != -1)
- openPerspNameField.select(index);
- updateOpenPerspNameField();
- }
-
- if (showInMenuButton != null) {
- showInMenuButton.setSelection(isEditMode() ? tool.getShowInMenu() : initialShowInMenu);
- }
-
- if (saveDirtyEditorsButton != null) {
- saveDirtyEditorsButton.setSelection(isEditMode() ? tool.getSaveDirtyEditors() : initialSaveDirtyEditors);
- }
-
- if (argumentField != null) {
- argumentField.setText(isEditMode() ? tool.getArguments() : initialArgument);
- }
-
- if (promptArgButton != null) {
- promptArgButton.setSelection(isEditMode() ? tool.getPromptForArguments() : initialPromptArg);
- }
-
- validate();
-
- return mainComposite;
- }
-
- /**
- * Creates the controls needed to edit the argument and
- * prompt for argument attributes of an external tool
- *
- * @param parent the composite to create the controls in
- */
- protected void createArgumentComponent(Composite parent) {
- Composite comp = new Composite(parent, SWT.NONE);
- GridLayout layout = new GridLayout();
- layout.marginWidth = 0;
- layout.marginHeight = 0;
- layout.numColumns = 2;
- GridData data = new GridData(GridData.FILL_HORIZONTAL);
- comp.setLayout(layout);
- comp.setLayoutData(data);
-
- Label label = new Label(comp, SWT.NONE);
- label.setText(ToolMessages.getString("ExternalToolOptionGroup.argumentLabel")); //$NON-NLS-1$
- data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- data.horizontalSpan = 2;
- label.setLayoutData(data);
-
- argumentField = new Text(comp, SWT.BORDER);
- data = new GridData(GridData.FILL_HORIZONTAL);
- data.widthHint = SIZING_TEXT_FIELD_WIDTH;
- argumentField.setLayoutData(data);
-
- variableButton= new Button(comp, SWT.PUSH);
- variableButton.setText(ToolMessages.getString("ExternalToolOptionGroup.argumentVariableLabel")); //$NON-NLS-1$
- variableButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- handleButtonPressed((Button)e.getSource());
- }
- });
- getPage().setButtonGridData(variableButton);
-
- Label instruction = new Label(comp, SWT.NONE);
- instruction.setText(ToolMessages.getString("ExternalToolOptionGroup.argumentInstruction")); //$NON-NLS-1$
- data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- data.horizontalSpan = 2;
- instruction.setLayoutData(data);
- }
-
- private void handleButtonPressed(Button button) {
- if (button == variableButton) {
- VariableSelectionDialog dialog= new VariableSelectionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
- if (dialog.open() == SelectionDialog.OK) {
- argumentField.append(dialog.getForm().getSelectedVariable());
- }
- }
- }
-
- private class VariableSelectionDialog extends SelectionDialog {
- private ExternalToolVariableForm form;
- private VariableSelectionDialog(Shell parent) {
- super(parent);
- setTitle("Select variable");
- }
- protected Control createDialogArea(Composite parent) {
- // Create the dialog area
- Composite composite= (Composite)super.createDialogArea(parent);
- ExternalToolVariable[] variables= ExternalToolsPlugin.getDefault().getArgumentVariableRegistry().getArgumentVariables();
- form= new ExternalToolVariableForm("Choose a variable", variables);
- form.createContents(composite, new IGroupDialogPage() {
- public GridData setButtonGridData(Button button) {
- GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- data.heightHint = convertVerticalDLUsToPixels(IDialogConstants.BUTTON_HEIGHT);
- int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
- data.widthHint = Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
- button.setLayoutData(data);
- return data;
- }
-
- public void setMessage(String newMessage, int newType) {
- VariableSelectionDialog.this.setMessage(newMessage);
- }
-
- public void updateValidState() {
- }
-
- public int convertHeightHint(int chars) {
- return convertHeightInCharsToPixels(chars);
- }
-
- public String getMessage() {
- if (!form.isValid()) {
- return "Invalid selection";
- }
- return null;
- }
-
- public int getMessageType() {
- if (!form.isValid()) {
- return IMessageProvider.ERROR;
- }
- return 0;
- }
- });
- return composite;
- }
- private ExternalToolVariableForm getForm() {
- return form;
- }
-
- }
-
- /**
- * Creates the controls needed to edit the show console
- * attribute of an external tool
- *
- * @param parent the composite to create the controls in
- */
- protected void createCaptureOutputComponent(Composite parent) {
- captureOutputButton = new Button(parent, SWT.CHECK);
- captureOutputButton.setText(ToolMessages.getString("ExternalToolOptionGroup.captureOutputLabel")); //$NON-NLS-1$
- GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- captureOutputButton.setLayoutData(data);
- }
-
- /**
- * Creates the controls needed to edit the prompt for argument
- * attribute of an external tool
- *
- * @param parent the composite to create the controls in
- */
- protected void createPromptForArgumentComponent(Composite parent) {
- promptArgButton = new Button(parent, SWT.CHECK);
- if (promptArgLabel != null)
- promptArgButton.setText(promptArgLabel);
- else
- promptArgButton.setText(ToolMessages.getString("ExternalToolOptionGroup.promptArgLabel")); //$NON-NLS-1$
- GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- promptArgButton.setLayoutData(data);
- }
-
- /**
- * Creates the controls needed to edit the open perspective
- * attribute of an external tool
- *
- * @param parent the composite to create the controls in
- */
- protected void createOpenPerspComponent(Composite parent) {
- Composite comp = new Composite(parent, SWT.NONE);
- GridLayout layout = new GridLayout();
- layout.marginWidth = 0;
- layout.marginHeight = 0;
- layout.numColumns = 2;
- GridData data = new GridData(GridData.FILL_HORIZONTAL);
- comp.setLayout(layout);
- comp.setLayoutData(data);
-
- openPerspButton = new Button(comp, SWT.CHECK);
- openPerspButton.setText(ToolMessages.getString("ExternalToolOptionGroup.openPerspLabel")); //$NON-NLS-1$
- data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- openPerspButton.setLayoutData(data);
- openPerspButton.addSelectionListener(new SelectionListener() {
- public void widgetSelected(SelectionEvent e) {
- updateOpenPerspNameField();
- }
- public void widgetDefaultSelected(SelectionEvent e) {
- }
- });
-
- openPerspNameField = new Combo(comp, (SWT.DROP_DOWN | SWT.READ_ONLY));
- openPerspNameField.setItems(getOpenPerspectiveNames());
- data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- openPerspNameField.setLayoutData(data);
- }
-
- /**
- * Creates the controls needed to edit the run in background
- * attribute of an external tool
- *
- * @param parent the composite to create the controls in
- */
- protected void createRunBackgroundComponent(Composite parent) {
- runBackgroundButton = new Button(parent, SWT.CHECK);
- runBackgroundButton.setText(ToolMessages.getString("ExternalToolOptionGroup.runBackgroundLabel")); //$NON-NLS-1$
- GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- runBackgroundButton.setLayoutData(data);
- }
-
- /**
- * Creates the controls needed to edit the save dirty editors
- * attribute of an external tool.
- *
- * @param parent the composite to create the controls in
- */
- protected void createSaveDirtyEditorsComponent(Composite parent) {
- saveDirtyEditorsButton = new Button(parent, SWT.CHECK);
- saveDirtyEditorsButton.setText(ToolMessages.getString("ExternalToolOptionGroup.saveDirtyEditorsLabel")); //$NON-NLS-1$
- GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- saveDirtyEditorsButton.setLayoutData(data);
- }
-
- /**
- * Creates the controls needed to edit the show console
- * attribute of an external tool
- *
- * @param parent the composite to create the controls in
- */
- protected void createShowConsoleComponent(Composite parent) {
- showConsoleButton = new Button(parent, SWT.CHECK);
- showConsoleButton.setText(ToolMessages.getString("ExternalToolOptionGroup.showConsoleLabel")); //$NON-NLS-1$
- GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- showConsoleButton.setLayoutData(data);
- }
-
- /**
- * Creates the controls needed to edit the show in menu
- * attribute of an external tool.
- *
- * @param parent the composite to create the controls in
- */
- protected void createShowInMenuComponent(Composite parent) {
- showInMenuButton = new Button(parent, SWT.CHECK);
- showInMenuButton.setText(ToolMessages.getString("ExternalToolOptionGroup.showInMenuLabel")); //$NON-NLS-1$
- GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- showInMenuButton.setLayoutData(data);
- }
-
- /**
- * Creates a vertical space between controls.
- */
- protected final void createSpacer(Composite parent) {
- Label label = new Label(parent, SWT.NONE);
- GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- data.horizontalSpan = 1;
- label.setLayoutData(data);
- }
-
- /**
- * Returns the proposed initial argument for the external
- * tool if no tool provided in the createContents.
- *
- * @return the proposed initial argument when editing new tool.
- */
- public final String getInitialArgument() {
- return initialArgument;
- }
-
- /**
- * Returns the proposed initial capture output for the external
- * tool if no tool provided in the createContents.
- *
- * @return the proposed initial capture output when editing new tool.
- */
- public final boolean getInitialCaptureOutput() {
- return initialCaptureOutput;
- }
-
- /**
- * Returns the proposed initial open perspective id for the external
- * tool if no tool provided in the createContents.
- *
- * @return the proposed initial open perspective id when editing new tool.
- */
- public final String getInitialOpenPerspective() {
- return initialOpenPersp;
- }
-
- /**
- * Returns the proposed initial prompt for argument for the external
- * tool if no tool provided in the createContents.
- *
- * @return the proposed initial prompt for argument when editing new tool.
- */
- public final boolean getInitialPromptForArgument() {
- return initialPromptArg;
- }
-
- /**
- * Returns the proposed initial run in background for the external
- * tool if no tool provided in the createContents.
- *
- * @return the proposed initial run in background when editing new tool.
- */
- public final boolean getInitialRunInBackground() {
- return initialRunBackground;
- }
-
- /**
- * Returns the proposed initial save dirty editors for the external
- * tool if no tool provided in the createContents.
- *
- * @return the proposed initial save dirty editors when editing new tool.
- */
- public final boolean getInitialSaveDirtyEditors() {
- return initialSaveDirtyEditors;
- }
-
- /**
- * Returns the proposed initial show console for the external
- * tool if no tool provided in the createContents.
- *
- * @return the proposed initial show console when editing new tool.
- */
- public final boolean getInitialShowConsole() {
- return initialShowConsole;
- }
-
- /**
- * Returns the proposed initial show in menu for the external
- * tool if no tool provided in the createContents.
- *
- * @return the proposed initial show in menu when editing new tool.
- */
- public final boolean getInitialShowInMenu() {
- return initialShowInMenu;
- }
-
- /**
- * Returns the list of perspective names to place in
- * the open perspective combo box. This list contains
- * all the available perspectives in the workbench.
- */
- protected final String[] getOpenPerspectiveNames() {
- String[] names = new String[getPerspectives().length];
-
- for (int i = 0; i < getPerspectives().length; i++) {
- names[i] = getPerspectives()[i].getLabel();
- }
-
- return names;
- }
-
- /**
- * Returns the ID for the perspective in the combo box
- * at the specified index, or <code>null</code> if
- * none.
- */
- protected final String getPerspectiveId(int index) {
- if (index < 0 || index > getPerspectives().length)
- return null;
- return getPerspectives()[index].getId();
- }
-
- /**
- * Returns the index in the perspective combo that
- * matches the specified perspective ID, or -1 if
- * none found.
- */
- protected final int getPerspectiveIndex(String perspId) {
- if (perspId == null)
- return -1;
-
- for (int i = 0; i < getPerspectives().length; i++) {
- if (perspId.equals(getPerspectives()[i].getId()))
- return i;
- }
-
- return -1;
- }
-
- /**
- * Returns the list of perspectives known to the workbench.
- * The list is also sorted by name in alphabetical order.
- */
- protected final IPerspectiveDescriptor[] getPerspectives() {
- if (perspectives == null) {
- perspectives = PlatformUI.getWorkbench().getPerspectiveRegistry().getPerspectives();
- Arrays.sort(perspectives, new Comparator() {
- private Collator collator = Collator.getInstance();
-
- public int compare(Object o1, Object o2) {
- String name1 = ((IPerspectiveDescriptor)o1).getLabel();
- String name2 = ((IPerspectiveDescriptor)o2).getLabel();
- return collator.compare(name1, name2);
- }
- });
- }
- return perspectives;
- }
-
- /* (non-Javadoc)
- * Method declared on IExternalToolGroup.
- */
- public void restoreValues(ExternalTool tool) {
- if (runBackgroundButton != null)
- runBackgroundButton.setSelection(tool.getRunInBackground());
- if (captureOutputButton != null)
- captureOutputButton.setSelection(tool.getCaptureOutput());
- if (showConsoleButton != null)
- showConsoleButton.setSelection(tool.getShowConsole());
- if (showInMenuButton != null)
- showInMenuButton.setSelection(tool.getShowInMenu());
- if (saveDirtyEditorsButton != null)
- saveDirtyEditorsButton.setSelection(tool.getSaveDirtyEditors());
- if (openPerspButton != null)
- openPerspButton.setSelection(tool.getOpenPerspective() != null);
- if (openPerspNameField != null) {
- int index = getPerspectiveIndex(tool.getOpenPerspective());
- if (index != -1)
- openPerspNameField.select(index);
- }
- updateOpenPerspNameField();
- if (argumentField != null)
- argumentField.setText(tool.getArguments());
- if (promptArgButton != null)
- promptArgButton.setSelection(tool.getPromptForArguments());
- }
-
- /**
- * Sets the proposed initial argument for the external
- * tool if no tool provided in the createContents.
- *
- * @param initialArgument the proposed initial argument when editing new tool.
- */
- public final void setInitialArgument(String initialArgument) {
- if (initialArgument != null)
- this.initialArgument = initialArgument;
- }
-
- /**
- * Sets the proposed initial capture output for the external
- * tool if no tool provided in the createContents.
- *
- * @param initialCaptureOutput the proposed initial capture output when editing new tool.
- */
- public final void setInitialCaptureOutput(boolean initialCaptureOutput) {
- this.initialCaptureOutput = initialCaptureOutput;
- }
-
- /**
- * Sets the proposed initial open perspective id for the external
- * tool if no tool provided in the createContents.
- *
- * @param initialOpenPersp the proposed initial open perspective id when editing new tool.
- */
- public final void setInitialOpenPerspective(String initialOpenPersp) {
- this.initialOpenPersp = initialOpenPersp;
- }
-
- /**
- * Sets the proposed initial prompt for argument for the external
- * tool if no tool provided in the createContents.
- *
- * @param initialPromptArg the proposed initial prompt for argument when editing new tool.
- */
- public final void setInitialPromptForArgument(boolean initialPromptArg) {
- this.initialPromptArg = initialPromptArg;
- }
-
- /**
- * Sets the proposed initial run in background for the external
- * tool if no tool provided in the createContents.
- *
- * @param initialRunBackground the proposed initial run in background when editing new tool.
- */
- public final void setInitialRunInBackground(boolean initialRunBackground) {
- this.initialRunBackground = initialRunBackground;
- }
-
- /**
- * Sets the proposed initial save dirty editors for the external
- * tool if no tool provided in the createContents.
- *
- * @param initialSaveDirtyEditors the proposed save dirty editors when editing new tool.
- */
- public final void setInitialSaveDirtyEditors(boolean initialSaveDirtyEditors) {
- this.initialSaveDirtyEditors = initialSaveDirtyEditors;
- }
-
- /**
- * Sets the proposed initial show console for the external
- * tool if no tool provided in the createContents.
- *
- * @param initialShowConsole the proposed initial show console when editing new tool.
- */
- public final void setInitialShowConsole(boolean initialShowConsole) {
- this.initialShowConsole = initialShowConsole;
- }
-
- /**
- * Sets the proposed initial show in menu for the external
- * tool if no tool provided in the createContents.
- *
- * @param initialShowInMenu the proposed show in menu when editing new tool.
- */
- public final void setInitialShowInMenu(boolean initialShowInMenu) {
- this.initialShowInMenu = initialShowInMenu;
- }
-
- /**
- * Sets the label for the prompt for argument option
- * of the tool. Does nothing if passed <code>null</code>.
- */
- public final void setPromptForArgumentLabel(String label) {
- if (label == null)
- promptArgLabel = null;
- else {
- promptArgLabel = label.trim();
- if (promptArgLabel.length() == 0)
- promptArgLabel = null;
- }
- }
-
- /**
- * Updates the enablement state of the open perspective
- * combo box if required.
- */
- protected void updateOpenPerspNameField() {
- if (openPerspNameField != null && openPerspButton != null)
- openPerspNameField.setEnabled(openPerspButton.getSelection());
- }
-
- /* (non-Javadoc)
- * Method declared on IExternalToolGroup.
- */
- public void updateTool(ExternalTool tool) {
- if (runBackgroundButton != null)
- tool.setRunInBackground(runBackgroundButton.getSelection());
- if (captureOutputButton != null)
- tool.setCaptureOutput(captureOutputButton.getSelection());
- if (showConsoleButton != null)
- tool.setShowConsole(showConsoleButton.getSelection());
- if (showInMenuButton != null)
- tool.setShowInMenu(showInMenuButton.getSelection());
- if (saveDirtyEditorsButton != null)
- tool.setSaveDirtyEditors(saveDirtyEditorsButton.getSelection());
- if (openPerspButton != null && openPerspNameField != null) {
- if (openPerspButton.getSelection())
- tool.setOpenPerspective(getPerspectiveId(openPerspNameField.getSelectionIndex()));
- else
- tool.setOpenPerspective(null);
- }
- if (argumentField != null)
- tool.setArguments(argumentField.getText().trim());
- if (promptArgButton != null)
- tool.setPromptForArguments(promptArgButton.getSelection());
- }
-
- /* (non-Javadoc)
- * Method declared on IExternalToolGroup.
- */
- public void validate() {
- // do nothing
- }
-}
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/group/ExternalToolRefreshGroup.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/group/ExternalToolRefreshGroup.java
deleted file mode 100644
index f0f47ce12..000000000
--- a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/group/ExternalToolRefreshGroup.java
+++ /dev/null
@@ -1,279 +0,0 @@
-package org.eclipse.ui.externaltools.group;
-
-/**********************************************************************
-Copyright (c) 2002 IBM Corp. and others. All rights reserved.
-This file is made available under the terms of the Common Public License v1.0
-which accompanies this distribution, and is available at
-http://www.eclipse.org/legal/cpl-v10.html
-Contributors:
-**********************************************************************/
-
-import org.eclipse.jface.dialogs.IMessageProvider;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.ui.externaltools.internal.dialog.ExternalToolVariableForm;
-import org.eclipse.ui.externaltools.internal.model.ExternalToolsPlugin;
-import org.eclipse.ui.externaltools.internal.model.ToolMessages;
-import org.eclipse.ui.externaltools.internal.registry.ExternalToolVariable;
-import org.eclipse.ui.externaltools.model.ExternalTool;
-import org.eclipse.ui.externaltools.model.ToolUtil;
-
-/**
- * Group of components applicable to most external tools. This group
- * will collect from the user the refresh scope to perform after
- * the external tool is done.
- * <p>
- * This group can be used or extended by clients.
- * </p>
- */
-public class ExternalToolRefreshGroup extends ExternalToolGroup {
- private String initialScope = null;
- private boolean initialRecursive = true;
-
- private ExternalToolVariableForm variableForm;
-
- protected Button refreshField;
- protected Button recursiveField;
-
- /**
- * Creates the group
- */
- public ExternalToolRefreshGroup() {
- super();
- }
-
- /* (non-Javadoc)
- * Method declared on ExternalToolGroup.
- */
- protected Control createGroupContents(Composite parent, ExternalTool tool) {
- // main composite
- Composite mainComposite = new Composite(parent, SWT.NONE);
- GridLayout layout = new GridLayout();
- layout.marginWidth = 0;
- layout.marginHeight = 0;
- layout.numColumns = 1;
- GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
- mainComposite.setLayout(layout);
- mainComposite.setLayoutData(gridData);
-
- createRefreshComponent(mainComposite);
- createRecursiveComponent(mainComposite);
- createScopeComponent(mainComposite);
-
- if (refreshField != null) {
- refreshField.setSelection(isEditMode() ? tool.getRefreshScope() != null : initialScope != null);
- refreshField.addSelectionListener(new SelectionListener() {
- public void widgetSelected(SelectionEvent e) {
- updateEnabledState();
- }
- public void widgetDefaultSelected(SelectionEvent e) {
- }
- });
- updateEnabledState();
- }
-
- if (recursiveField != null) {
- recursiveField.setSelection(isEditMode() ? tool.getRefreshRecursive() : initialRecursive);
- }
-
- if (variableForm != null) {
- String scope = isEditMode() ? tool.getRefreshScope() : initialScope;
- updateForm(scope);
- }
-
- validate();
-
- return mainComposite;
- }
-
- /**
- * Creates the controls needed to edit the refresh recursive
- * attribute of an external tool
- *
- * @param parent the composite to create the controls in
- */
- protected void createRecursiveComponent(Composite parent) {
- recursiveField = new Button(parent, SWT.CHECK);
- recursiveField.setText(ToolMessages.getString("ExternalToolRefreshGroup.recursiveLabel")); //$NON-NLS-1$
- GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- recursiveField.setLayoutData(data);
-
- createSpacer(parent);
- }
-
- /**
- * Creates the controls needed to edit the refresh scope
- * attribute of an external tool
- *
- * @param parent the composite to create the controls in
- */
- protected void createRefreshComponent(Composite parent) {
- refreshField = new Button(parent, SWT.CHECK);
- refreshField.setText(ToolMessages.getString("ExternalToolRefreshGroup.refreshLabel")); //$NON-NLS-1$
- GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- refreshField.setLayoutData(data);
- }
-
- /**
- * Creates the controls needed to edit the refresh scope variable
- * attribute of an external tool
- *
- * @param parent the composite to create the controls in
- */
- protected void createScopeComponent(Composite parent) {
- String label = ToolMessages.getString("ExternalToolRefreshGroup.scopeLabel"); //$NON-NLS-1$
- ExternalToolVariable[] vars = ExternalToolsPlugin.getDefault().getRefreshVariableRegistry().getRefreshVariables();
- variableForm = new ExternalToolVariableForm(label, vars);
- variableForm.createContents(parent, getPage());
- }
-
- /**
- * Creates a vertical space between controls.
- */
- protected void createSpacer(Composite parent) {
- Label label = new Label(parent, SWT.NONE);
- GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- data.horizontalSpan = 2;
- label.setLayoutData(data);
- }
-
- /**
- * Returns the proposed initial refresh scope for the external
- * tool if no tool provided in the createContents.
- *
- * @return the proposed initial refresh scope when editing new tool.
- */
- public final String getInitialScope() {
- return initialScope;
- }
-
- /**
- * Returns the proposed initial refresh recursive for the external
- * tool if no tool provided in the createContents.
- *
- * @return the proposed initial refresh recursive when editing new tool.
- */
- public final boolean getInitialRecursive() {
- return initialRecursive;
- }
-
- /* (non-Javadoc)
- * Method declared on IExternalToolGroup.
- */
- public boolean isValid() {
- if (!super.isValid())
- return false;
-
- if (variableForm != null)
- return variableForm.isValid();
- else
- return true;
- }
-
- /* (non-Javadoc)
- * Method declared on IExternalToolGroup.
- */
- public void restoreValues(ExternalTool tool) {
- if (refreshField != null) {
- refreshField.setSelection(tool.getRefreshScope() != null);
- updateEnabledState();
- }
- if (recursiveField != null) {
- recursiveField.setSelection(tool.getRefreshRecursive());
- }
- if (variableForm != null) {
- updateForm(tool.getRefreshScope());
- }
- }
-
- /**
- * Sets the proposed initial refresh scope for the external
- * tool if no tool provided in the createContents.
- *
- * @param initialLocation the proposed initial refresh scope when editing new tool.
- */
- public final void setInitialScope(String initialScope) {
- this.initialScope = initialScope;
- }
-
- /**
- * Sets the proposed initial refresh recursive for the external
- * tool if no tool provided in the createContents.
- *
- * @param initialName the proposed initial refresh recursive when editing new tool.
- */
- public final void setInitialRecursive(boolean initialRecursive) {
- this.initialRecursive = initialRecursive;
- }
-
- /**
- * Updates the enablement state of the fields.
- */
- protected void updateEnabledState() {
- if (refreshField != null) {
- if (recursiveField != null)
- recursiveField.setEnabled(refreshField.getSelection());
- if (variableForm != null)
- variableForm.setEnabled(refreshField.getSelection());
- }
- }
-
- /**
- * Update the variable form to match the specified
- * refresh scope.
- */
- protected final void updateForm(String refreshScope) {
- if (variableForm == null)
- return;
-
- String varName = null;
- String varValue = null;
- if (refreshScope != null) {
- ToolUtil.VariableDefinition varDef = ToolUtil.extractVariableTag(refreshScope, 0);
- varName = varDef.name;
- varValue = varDef.argument;
- }
- variableForm.selectVariable(varName, varValue);
- }
-
- /* (non-Javadoc)
- * Method declared on IExternalToolGroup.
- */
- public void updateTool(ExternalTool tool) {
- if (refreshField != null) {
- if (refreshField.getSelection()) {
- if (variableForm != null)
- tool.setRefreshScope(variableForm.getSelectedVariable());
- else
- tool.setRefreshScope(null);
- }
- else
- tool.setRefreshScope(null);
- }
- if (recursiveField != null)
- tool.setRefreshRecursive(recursiveField.getSelection());
- }
-
-
- /**
- * @see org.eclipse.ui.externaltools.group.IExternalToolGroup#validate()
- */
- public void validate() {
- if (variableForm != null) {
- variableForm.validate();
- if (!variableForm.isValid())
- return;
- }
-
- getPage().setMessage(null, IMessageProvider.NONE);
- setIsValid(true);
- }
-}
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/group/IExternalToolGroup.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/group/IExternalToolGroup.java
deleted file mode 100644
index a82367988..000000000
--- a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/group/IExternalToolGroup.java
+++ /dev/null
@@ -1,72 +0,0 @@
-package org.eclipse.ui.externaltools.group;
-
-/**********************************************************************
-Copyright (c) 2002 IBM Corp. and others. All rights reserved.
-This file is made available under the terms of the Common Public License v1.0
-which accompanies this distribution, and is available at
-http://www.eclipse.org/legal/cpl-v10.html
-Contributors:
-**********************************************************************/
-
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.ui.externaltools.model.ExternalTool;
-
-/**
- * Represents the API for a group of controls to edit
- * a number of attributes of an external tool.
- * <p>
- * This interface is not intended to be extended
- * nor implemented by clients. Clients should subclass
- * <code>ExternalToolGroup</code> instead.
- * </p>
- */
-public interface IExternalToolGroup {
-
- /**
- * Creates this group's visual components.
- *
- * @param parent the composite to parent the group's control
- * @param tool the external tool to be edited, or <code>null</code> for a new tool
- * @param page the dialog page this group will be part of
- * @return the control for the group
- */
- public Control createContents(Composite parent, ExternalTool tool, IGroupDialogPage page);
-
- /**
- * Disposed of the group's resources. This can be called
- * even if <code>createContents</code> was never called.
- */
- public void dispose();
-
- /**
- * Returns whether the group's components have acceptable
- * values.
- *
- * @return <code>true</code> if all values acceptable, or <code>false</code> otherwise
- */
- public boolean isValid();
-
- /**
- * Restores the group's components values from the
- * specified external tool.
- *
- * @param tool the external tool to retrieve values from
- */
- public void restoreValues(ExternalTool tool);
-
- /**
- * Updates the external tool with the information
- * collected by the group's visual components.
- *
- * @param tool the external tool to update
- */
- public void updateTool(ExternalTool tool);
-
- /**
- * Validates this group's current values entered by the
- * user and updates it's valid state if needed
- */
- public void validate();
-}
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/menu/ExternalToolMenuDelegate.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/menu/ExternalToolMenuDelegate.java
index 817634009..0a3efbcf0 100644
--- a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/menu/ExternalToolMenuDelegate.java
+++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/menu/ExternalToolMenuDelegate.java
@@ -21,14 +21,10 @@ import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.MenuItem;
-import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.IWorkbenchWindowPulldownDelegate2;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.externaltools.action.RunExternalToolAction;
import org.eclipse.ui.externaltools.internal.model.ExternalToolsPlugin;
import org.eclipse.ui.externaltools.internal.model.ToolMessages;
-import org.eclipse.ui.externaltools.model.ExternalTool;
import org.eclipse.ui.externaltools.model.IExternalToolConstants;
/**
@@ -86,57 +82,7 @@ public class ExternalToolMenuDelegate extends AbstractLaunchHistoryAction implem
/**
* Populates the menu with its items
*/
- private void populateMenu(Menu menu, boolean wantFastAccess) {
- // Add a menu item to run the most recent tool.
- MenuItem runRecent = new MenuItem(menu, SWT.NONE);
- runRecent.setText(ToolMessages.getString("ExternalToolMenuDelegate.runRecent")); //$NON-NLS-1$
- runRecent.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- runLastTool();
- }
- });
- // Disable option if no tool has been run yet.
- runRecent.setEnabled(getLastTool() != null);
-
- // Add a separator.
- new MenuItem(menu, SWT.SEPARATOR);
-
- // Add a menu item for each tool in the favorites list.
- ExternalTool[] tools = FavoritesManager.getInstance().getFavorites();
- if (tools.length > 0) {
- for (int i = 0; i < tools.length; i++) {
- ExternalTool tool = tools[i];
- StringBuffer label = new StringBuffer();
- if (i < 9 && wantFastAccess) {
- //add the numerical accelerator
- label.append('&');
- label.append(i+1);
- label.append(' ');
- }
- label.append(tool.getName());
- MenuItem item = new MenuItem(menu, SWT.NONE);
- item.setText(label.toString());
- item.setData(tool);
- item.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- runTool((ExternalTool)e.widget.getData());
- }
- });
- }
-
- // Add a separator.
- new MenuItem(menu, SWT.SEPARATOR);
- }
-
- // Add a menu item to show the external tools view.
- MenuItem showView = new MenuItem(menu, SWT.NONE);
- showView.setText(ToolMessages.getString("ExternalToolMenuDelegate.showView")); //$NON-NLS-1$
- showView.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- showView();
- }
- });
-
+ private void populateMenu(Menu menu, boolean wantFastAccess) {
// Add a menu item to show the external tools dialog
MenuItem configure = new MenuItem(menu, SWT.NONE);
configure.setText(ToolMessages.getString("ExternalToolMenuDelegate.configure")); //$NON-NLS-1$
@@ -146,44 +92,5 @@ public class ExternalToolMenuDelegate extends AbstractLaunchHistoryAction implem
}
});
}
-
- /**
- * Runs the specified tool
- */
- private void runTool(final ExternalTool tool) {
- RunExternalToolAction runToolAction;
- runToolAction = new RunExternalToolAction(window);
- runToolAction.setTool(tool);
- runToolAction.run();
- }
-
- /**
- * Shows the external tool view.
- */
- private void showView() {
- try {
- IWorkbenchPage page = window.getActivePage();
- if (page != null)
- page.showView(IExternalToolConstants.VIEW_ID);
- } catch (PartInitException e) {
- ExternalToolsPlugin.getDefault().log("Unable to display the External Tools view.", e); //$NON-NLS-1$
- }
- }
-
- /**
- * Run the most recently run external tool.
- */
- private void runLastTool() {
- if (getLastTool() == null)
- return;
- runTool(getLastTool());
- }
-
- /**
- * Returns the tool which was run most recently.
- */
- private ExternalTool getLastTool() {
- return FavoritesManager.getInstance().getLastTool();
- }
}
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/menu/FavoritesManager.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/menu/FavoritesManager.java
deleted file mode 100644
index 14f25728b..000000000
--- a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/menu/FavoritesManager.java
+++ /dev/null
@@ -1,173 +0,0 @@
-package org.eclipse.ui.externaltools.internal.menu;
-
-/**********************************************************************
-Copyright (c) 2002 IBM Corp. and others. All rights reserved.
-This file is made available under the terms of the Common Public License v1.0
-which accompanies this distribution, and is available at
-http://www.eclipse.org/legal/cpl-v10.html
-Contributors:
-**********************************************************************/
-
-import java.util.Comparator;
-import java.util.Set;
-import java.util.TreeSet;
-
-import org.eclipse.ui.externaltools.internal.model.ExternalToolsPlugin;
-import org.eclipse.ui.externaltools.internal.registry.ExternalToolRegistry;
-import org.eclipse.ui.externaltools.internal.registry.ExternalToolType;
-import org.eclipse.ui.externaltools.model.ExternalTool;
-import org.eclipse.ui.externaltools.model.ExternalToolStorage;
-import org.eclipse.ui.externaltools.model.IStorageListener;
-
-/**
- * This class manages the list of favorite external tools. These
- * favorites are shown on the Run > External Tools menu.
- */
-public final class FavoritesManager {
- private static final FavoritesManager INSTANCE = new FavoritesManager();
- private final StorageListener storageListener = new StorageListener();
- private Set favorites = new TreeSet(new ExternalToolComparator());
- private ExternalTool lastTool;
-
- // Private constructor to ensure this class is a singleton.
- private FavoritesManager() {
- // Add the favorites manager as a storage listener so
- // it can react to changes in the registry.
- ExternalToolStorage.addStorageListener(storageListener);
- updateFavorites();
- }
-
- /**
- * Returns the singleton instance of the favorites manager.
- *
- * @return the singleton instance of the favorites manager.
- */
- public static FavoritesManager getInstance() {
- return INSTANCE;
- }
-
- /**
- * Add an external tool to the favorites list,
- * if it is not already in the list.
- */
- private void add(ExternalTool tool) {
- favorites.add(tool);
- }
-
- /**
- * Removes an external tool from the favorites list,
- * if it is in the list.
- */
- private void remove(ExternalTool tool) {
- favorites.remove(tool);
- }
-
- /**
- * Returns an array of the favorite external tools.
- */
- public ExternalTool[] getFavorites() {
- return (ExternalTool[])favorites.toArray(new ExternalTool[favorites.size()]);
- }
-
- /**
- * Returns the last run tool if there is one,
- * <code>null</code> otherwise.
- */
- public ExternalTool getLastTool() {
- return lastTool;
- }
-
- /**
- * Sets the last run tool to be the given tool.
- */
- public void setLastTool(ExternalTool tool) {
- lastTool = tool;
- }
-
- /**
- * Updates the favorites list based on whether
- * each tool in the registry is a favorite.
- */
- private void updateFavorites() {
- boolean lastToolDeleted = true;
- favorites.clear();
-
- ExternalToolType[] types =
- ExternalToolsPlugin.getDefault().getTypeRegistry().getToolTypes();
- ExternalToolRegistry registry =
- ExternalToolsPlugin.getDefault().getToolRegistry(null);
- for (int i=0; i < types.length; i++) {
- ExternalTool[] tools = registry.getToolsOfType(types[i].getId());
- for (int j=0; j < tools.length; j++) {
- if (tools[j].getShowInMenu())
- add(tools[j]);
- if (tools[j] == lastTool)
- lastToolDeleted = false;
- }
- }
-
- if (lastToolDeleted)
- lastTool = null;
- }
-
- /**
- * Updates the favorites list based on whether
- * the given tool is a favorite.
- */
- private void updateFavorites(ExternalTool tool) {
- if (tool.getShowInMenu())
- add(tool);
- else
- remove(tool);
- }
-
- /**
- * A storage listener so the favorites manager can react
- * to changes in the registry.
- */
- private class StorageListener implements IStorageListener {
- /* (non-Javadoc)
- * Method declared on IStorageListener.
- */
- public void toolDeleted(ExternalTool tool) {
- remove(tool);
- if (lastTool == tool)
- setLastTool(null);
- }
-
- /* (non-Javadoc)
- * Method declared on IStorageListener.
- */
- public void toolCreated(ExternalTool tool) {
- if (tool.getShowInMenu())
- add(tool);
- }
-
- /* (non-Javadoc)
- * Method declared on IStorageListener.
- */
- public void toolModified(ExternalTool tool) {
- updateFavorites(tool);
- }
-
- /* (non-Javadoc)
- * Method declared on IStorageListener.
- */
- public void toolsRefreshed() {
- updateFavorites();
- }
- }
-
- /**
- * Compares external tools so they may be stored
- * in alphabetical order.
- */
- private static class ExternalToolComparator implements Comparator {
- public int compare(Object o1, Object o2) {
- ExternalTool tool1 = (ExternalTool) o1;
- ExternalTool tool2 = (ExternalTool) o2;
- return (tool1.getName().compareTo(tool2.getName()));
- }
- }
-}
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/registry/ExternalToolRegistry.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/registry/ExternalToolRegistry.java
deleted file mode 100644
index adb0ca086..000000000
--- a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/registry/ExternalToolRegistry.java
+++ /dev/null
@@ -1,689 +0,0 @@
-package org.eclipse.ui.externaltools.internal.registry;
-
-/**********************************************************************
-Copyright (c) 2002 IBM Corp. and others. All rights reserved.
-This file is made available under the terms of the Common Public License v1.0
-which accompanies this distribution, and is available at
-http://www.eclipse.org/legal/cpl-v10.html
-Contributors:
-**********************************************************************/
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.FilenameFilter;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.OutputStreamWriter;
-import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.StringTokenizer;
-
-import org.eclipse.core.resources.IncrementalProjectBuilder;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.MultiStatus;
-import org.eclipse.jface.dialogs.ErrorDialog;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IMemento;
-import org.eclipse.ui.XMLMemento;
-import org.eclipse.ui.externaltools.internal.model.ExternalToolsPlugin;
-import org.eclipse.ui.externaltools.internal.model.ToolMessages;
-import org.eclipse.ui.externaltools.model.ExternalTool;
-import org.eclipse.ui.externaltools.model.IExternalToolConstants;
-
-/**
- * The registry of available external tools.
- */
-public class ExternalToolRegistry {
- // Format for a tool looks like:
- // <externalTool
- // type={string}
- // name={string}
- // location={string:path}
- // workDirectory={string:path}
- // logMessages={string:true/false}
- // runInBackground={string:true/false}
- // promptForArguments={string:true/false}
- // showInMenu={string:true/false}
- // openPerspective={string:id}
- // refreshScope={string}
- // refreshRecursive={string: true/false}>
- // <description>{string}</description}
- // <arguments>{string}</arguments}
- // <extraAttribute
- // key={String}>
- // {String}
- // </extraAttribute>
- // </externalTool>
- //
- // Element and attribute tags for storing a tool in an XML file.
- private static final String TAG_EXTERNAL_TOOL = "externalTool"; //$NON-NLS-1$
- private static final String TAG_TYPE = "type"; //$NON-NLS-1$
- private static final String TAG_NAME = "name"; //$NON-NLS-1$
- private static final String TAG_LOCATION = "location"; //$NON-NLS-1$
- private static final String TAG_WORK_DIR = "workDirectory"; //$NON-NLS-1$
- private static final String TAG_CAPTURE_OUTPUT = "captureOutput"; //$NON-NLS-1$
- private static final String TAG_SHOW_CONSOLE = "showConsole"; //$NON-NLS-1$
- private static final String TAG_RUN_BKGRND = "runInBackground"; //$NON-NLS-1$
- private static final String TAG_OPEN_PERSP = "openPerspective"; //$NON-NLS-1$
- private static final String TAG_PROMPT_ARGS = "promptForArguments"; //$NON-NLS-1$
- private static final String TAG_SHOW_MENU = "showInMenu"; //$NON-NLS-1$
- private static final String TAG_SAVE_DIRTY = "saveDirtyEditors"; //$NON-NLS-1$
- private static final String TAG_DESC = "description"; //$NON-NLS-1$
- private static final String TAG_ARGS = "arguments"; //$NON-NLS-1$
- private static final String TAG_REFRESH_SCOPE = "refreshScope"; //$NON-NLS-1$
- private static final String TAG_REFRESH_RECURSIVE = "refreshRecursive"; //$NON-NLS-1$
- private static final String TAG_RUN_BUILD_KINDS = "runForBuildKinds"; //$NON-NLS-1$
- private static final String TAG_EXTRA_ATTR = "extraAttribute"; //$NON-NLS-1$
- private static final String TAG_KEY = "key"; //$NON-NLS-1$
- private static final String TAG_VERSION = "version"; //$NON-NLS-1$
-
- // Possible values for boolean type of attributes
- private static final String TRUE = "true"; //$NON-NLS-1$
- private static final String FALSE = "false"; //$NON-NLS-1$
-
- private static final String BUILD_TYPE_SEPARATOR = ","; //$NON-NLS-1$
- private static final String EXTRA_ATTR_SEPARATOR = "="; //$NON-NLS-1$
-
- private static final String VERSION_21 = "2.1"; //$NON-NLS-1$;
-
- private static final ExternalTool[] EMPTY_TOOLS = new ExternalTool[0];
-
- /**
- * Path to where the user defined external tools
- * are stored within the workspace.
- */
- private static final IPath TOOLS_PATH =
- ExternalToolsPlugin.getDefault().getStateLocation().append(".xtools"); //$NON-NLS-1$
-
- /**
- * Extension for external tool files stored within
- * the workspace
- */
- private static final String TOOLS_EXTENSION = ".xtool"; //$NON-NLS-1$
-
- /**
- * Lookup table of external tools where the key is the
- * type of tool, and the value is a array list of tools of
- * that type.
- */
- private HashMap tools = new HashMap();
-
- /**
- * Lookup table of file names where the key is the external
- * tool name as <b>lowercase</b>, and the value is the full path
- * to the file for that tool
- */
- private HashMap filenames = new HashMap();
-
- /**
- * Creates the registry and loads the external tools
- * from storage.
- *
- * @param shell the shell to use for displaying any errors
- * when loading external tool definitions from storage
- * or <code>null</code> to not report these problems.
- */
- public ExternalToolRegistry(final Shell shell) {
- super();
- final IStatus results = loadTools();
- if (!results.isOK() && shell != null && !shell.isDisposed()) {
- shell.getDisplay().syncExec(new Runnable() {
- public void run() {
- String title = ToolMessages.getString("ExternalToolRegistry.loadErrorTitle"); //$NON-NLS-1$
- String msg = ToolMessages.getString("ExternalToolRegistry.loadErrorMessage"); //$NON-NLS-1$
- ErrorDialog.openError(shell, title, msg, results);
- }
- });
- }
- ExternalTool[] oldTools = ExternalToolMigration.readInOldTools(this);
- if (oldTools != null) {
- for (int i = 0; i < oldTools.length; i++) {
- saveTool(oldTools[i]);
- }
- }
- }
-
- /**
- * Converts the build kinds into a built types
- * string representation.
- *
- * @param buildKinds the array of build kinds to convert
- * @return the build types string representation
- */
- protected static String buildKindsToString(int[] buildKinds) {
- if (buildKinds.length == 0)
- return IExternalToolConstants.BUILD_TYPE_NONE;
-
- StringBuffer buffer = new StringBuffer();
- for (int i = 0; i < buildKinds.length; i++) {
- switch (buildKinds[i]) {
- case IncrementalProjectBuilder.INCREMENTAL_BUILD :
- buffer.append(IExternalToolConstants.BUILD_TYPE_INCREMENTAL);
- break;
- case IncrementalProjectBuilder.FULL_BUILD :
- buffer.append(IExternalToolConstants.BUILD_TYPE_FULL);
- break;
- case IncrementalProjectBuilder.AUTO_BUILD :
- buffer.append(IExternalToolConstants.BUILD_TYPE_AUTO);
- break;
- default :
- break;
- }
- buffer.append(BUILD_TYPE_SEPARATOR);
- }
- return buffer.toString();
- }
-
- /**
- * Converts the build types string into an array of
- * build kinds.
- *
- * @param buildTypes the string of built types to convert
- * @return the array of build kinds.
- */
- protected static int[] buildTypesToArray(String buildTypes) {
- int count = 0;
- boolean incremental = false;
- boolean full = false;
- boolean auto = false;
-
- StringTokenizer tokenizer = new StringTokenizer(buildTypes, BUILD_TYPE_SEPARATOR);
- while (tokenizer.hasMoreTokens()) {
- String token = tokenizer.nextToken();
- if (IExternalToolConstants.BUILD_TYPE_INCREMENTAL.equals(token)) {
- if (!incremental) {
- incremental = true;
- count++;
- }
- }
- else if (IExternalToolConstants.BUILD_TYPE_FULL.equals(token)) {
- if (!full) {
- full = true;
- count++;
- }
- }
- else if (IExternalToolConstants.BUILD_TYPE_AUTO.equals(token)) {
- if (!auto) {
- auto = true;
- count++;
- }
- }
- }
-
- int[] results = new int[count];
- count = 0;
- if (incremental) {
- results[count] = IncrementalProjectBuilder.INCREMENTAL_BUILD;
- count++;
- }
- if (full) {
- results[count] = IncrementalProjectBuilder.FULL_BUILD;
- count++;
- }
- if (auto) {
- results[count] = IncrementalProjectBuilder.AUTO_BUILD;
- count++;
- }
-
- return results;
- }
-
- /**
- * Creates an external tool from the map.
- *
- * @param commandArgs the builder ICommand arguments
- * @param newName a new name for the tool if the one in the command is invalid
- * @return the new external tool or <code>null</code> if not possible.
- */
- public static ExternalTool toolFromBuildCommandArgs(Map commandArgs, String newName) {
- String version = (String) commandArgs.get(TAG_VERSION);
- if (VERSION_21.equals(version)) {
- String name = (String)commandArgs.get(TAG_NAME);
- if (ExternalTool.validateToolName(name) != null)
- name = newName;
- String type = (String)commandArgs.get(TAG_TYPE);
-
- try {
- ExternalTool tool = new ExternalTool(type, name);
- tool.setLocation((String)commandArgs.get(TAG_LOCATION));
- tool.setWorkingDirectory((String)commandArgs.get(TAG_WORK_DIR));
- tool.setCaptureOutput(TRUE.equals((String)commandArgs.get(TAG_CAPTURE_OUTPUT)));
- tool.setShowConsole(TRUE.equals((String)commandArgs.get(TAG_SHOW_CONSOLE)));
- tool.setRunInBackground(TRUE.equals((String)commandArgs.get(TAG_RUN_BKGRND)));
- tool.setPromptForArguments(TRUE.equals((String)commandArgs.get(TAG_PROMPT_ARGS)));
- tool.setShowInMenu(TRUE.equals((String)commandArgs.get(TAG_SHOW_MENU)));
- tool.setOpenPerspective((String)commandArgs.get(TAG_OPEN_PERSP));
- tool.setRefreshScope((String)commandArgs.get(TAG_REFRESH_SCOPE));
- tool.setRefreshRecursive(TRUE.equals((String)commandArgs.get(TAG_REFRESH_RECURSIVE)));
- tool.setSaveDirtyEditors(TRUE.equals((String)commandArgs.get(TAG_SAVE_DIRTY)));
-
- String types = (String)commandArgs.get(TAG_RUN_BUILD_KINDS);
- if (types != null && types.length() > 0)
- tool.setRunForBuildKinds(buildTypesToArray(types));
-
- String desc = (String)commandArgs.get(TAG_DESC);
- if (desc != null)
- tool.setDescription(desc);
-
- String args = (String)commandArgs.get(TAG_ARGS);
- if (args != null)
- tool.setArguments(args);
-
- String extraAttributes = (String)commandArgs.get(TAG_EXTRA_ATTR);
- if (extraAttributes != null) {
- StringTokenizer tokenizer = new StringTokenizer(extraAttributes, EXTRA_ATTR_SEPARATOR);
- while (tokenizer.hasMoreTokens()) {
- String key = tokenizer.nextToken();
- if (!tokenizer.hasMoreTokens())
- break;
- String value = tokenizer.nextToken();
- tool.setExtraAttribute(key, value);
- }
- }
-
- return tool;
- } catch (CoreException e) {
- return null;
- }
- } else {
- return ExternalToolMigration.toolFromArgumentMap(commandArgs, null, newName);
- }
- }
-
- /**
- * Creates an builder ICommand argument map for the external tool.
- *
- * @param tool the external tool to use
- * @return the map of arguments representing the external tool.
- */
- public static Map toolToBuildCommandArgs(ExternalTool tool) {
- Map commandArgs = new HashMap();
- commandArgs.put(TAG_VERSION, VERSION_21);
- commandArgs.put(TAG_TYPE, tool.getType());
- commandArgs.put(TAG_NAME, tool.getName());
- commandArgs.put(TAG_LOCATION, tool.getLocation());
- commandArgs.put(TAG_WORK_DIR, tool.getWorkingDirectory());
- commandArgs.put(TAG_CAPTURE_OUTPUT, tool.getCaptureOutput() ? TRUE : FALSE);
- commandArgs.put(TAG_SHOW_CONSOLE, tool.getShowConsole() ? TRUE : FALSE);
- commandArgs.put(TAG_RUN_BKGRND, tool.getRunInBackground() ? TRUE : FALSE);
- commandArgs.put(TAG_PROMPT_ARGS, tool.getPromptForArguments() ? TRUE : FALSE);
- commandArgs.put(TAG_SHOW_MENU, tool.getShowInMenu() ? TRUE : FALSE);
- commandArgs.put(TAG_OPEN_PERSP, tool.getOpenPerspective());
- commandArgs.put(TAG_REFRESH_SCOPE, tool.getRefreshScope());
- commandArgs.put(TAG_REFRESH_RECURSIVE, tool.getRefreshRecursive() ? TRUE : FALSE);
- commandArgs.put(TAG_SAVE_DIRTY, tool.getSaveDirtyEditors() ? TRUE : FALSE);
- commandArgs.put(TAG_RUN_BUILD_KINDS, buildKindsToString(tool.getRunForBuildKinds()));
- commandArgs.put(TAG_DESC, tool.getDescription());
- commandArgs.put(TAG_ARGS, tool.getArguments());
-
- String[] keys = tool.getExtraAttributeKeys();
- if (keys.length > 0) {
- StringBuffer buffer = new StringBuffer();
- String[] values = tool.getExtraAttributeValues();
- for (int i = 0; i < keys.length; i++) {
- buffer.append(keys[i]);
- buffer.append(EXTRA_ATTR_SEPARATOR);
- buffer.append(values[i]);
- }
- commandArgs.put(TAG_EXTRA_ATTR, buffer.toString());
- }
-
- return commandArgs;
- }
-
- /**
- * Adds an external tool to the in-memory registry.
- * Note that no check for an existing tool with the
- * same name is done.
- */
- private void addTool(ExternalTool tool, IPath filePath) {
- ArrayList list = (ArrayList) tools.get(tool.getType());
- if (list == null) {
- list = new ArrayList(10);
- tools.put(tool.getType(), list);
- }
- list.add(tool);
-
- filenames.put(tool.getName().toLowerCase(), filePath);
- }
-
- /**
- * Performs the necessary work to rename the given external tool
- * in this tools registry. The tool's storage location is updated
- * to a new location based on the given tool name and the registry's
- * cache is updated. Note that this method does NOT update the "name"
- * attribute of the given tool.
- *
- * This method is intended to be called only by ExternalTool.rename(String) */
- public IStatus renameTool(ExternalTool tool, String newName) {
- IPath filename= (IPath) filenames.get(tool.getName().toLowerCase());
- if (filename == null) {
- String msg = MessageFormat.format("The file for tool {0} could not be found", new Object[] {tool.getName()});
- return ExternalToolsPlugin.newErrorStatus(msg, null);
- }
- File file= new File(filename.toOSString());
- IPath newPath= generateToolFilename(newName);
- if (!file.renameTo(new File(newPath.toOSString()))) {
- String msg = MessageFormat.format("Failed to create new file for external tool: {0}", new Object[] {newPath.toString()});
- return ExternalToolsPlugin.newErrorStatus(msg, null);
- }
- filenames.remove(tool.getName().toLowerCase());
- filenames.put(newName.toLowerCase(), newPath);
- return ExternalToolsPlugin.OK_STATUS;
- }
-
- /**
- * Deletes the external tool from storage and
- * registry.
- */
- public IStatus deleteTool(ExternalTool tool) {
- IPath filename = (IPath) filenames.get(tool.getName().toLowerCase());
- if (filename == null) {
- String msg = ToolMessages.getString("ExternalToolRegistry.noToolFilename"); //$NON-NLS-1$
- return ExternalToolsPlugin.newErrorStatus(msg, null);
- }
-
- if (!filename.toFile().delete()) {
- String msg = ToolMessages.format("ExternalToolRegistry.deleteToolFileFailed", new Object[] {filename.toOSString()}); //$NON-NLS-1$
- return ExternalToolsPlugin.newErrorStatus(msg, null);
- }
-
- filenames.remove(tool.getName().toLowerCase());
-
- ArrayList list = (ArrayList) tools.get(tool.getType());
- if (list != null)
- list.remove(tool);
-
- return ExternalToolsPlugin.OK_STATUS;
- }
-
-
- /**
- * Generate a filename path to store the contents
- * of the external tool of the specified name.
- *
- * @param toolName a valid external tool name
- * @return the <code>IPath</code> for the filename
- */
- private IPath generateToolFilename(String toolName) {
- String filename = toolName.replace(' ', '_');
- return TOOLS_PATH.append(filename + TOOLS_EXTENSION);
- }
-
- /**
- * Returns the number of external tools of the specified
- * type.
- */
- public int getToolCountOfType(String toolTypeId) {
- ArrayList list = (ArrayList) tools.get(toolTypeId);
- if (list == null)
- return 0;
- else
- return list.size();
- }
-
- /**
- * Returns the external tool with the specified name.
- *
- * @return the external tool with the specified name or
- * <code>null</code> if none exist with that name.
- */
- public ExternalTool getToolNamed(String name) {
- Iterator typeEnum = tools.values().iterator();
- while (typeEnum.hasNext()) {
- ArrayList list = (ArrayList) typeEnum.next();
- if (list != null && !list.isEmpty()) {
- Iterator toolEnum = list.iterator();
- while (toolEnum.hasNext()) {
- ExternalTool tool = (ExternalTool)toolEnum.next();
- if (tool.getName().equalsIgnoreCase(name))
- return tool;
- }
- }
- }
-
- return null;
- }
-
- /**
- * Returns the external tools of the specified
- * type.
- */
- public ExternalTool[] getToolsOfType(String toolTypeId) {
- ArrayList list = (ArrayList) tools.get(toolTypeId);
- if (list == null)
- return EMPTY_TOOLS;
- ExternalTool[] results = new ExternalTool[list.size()];
- list.toArray(results);
- return results;
- }
-
- /**
- * Returns whether the external tool with the specified name
- * already exist in the in-memory registry.
- *
- * @return <code>true</code> if found, <code>false</code> otherwise
- */
- public boolean hasToolNamed(String name) {
- return filenames.get(name.toLowerCase()) != null;
- }
-
- /**
- * Loads the external tools from storage and
- * adds them to the registry.
- *
- * @return a status containing any problems encountered.
- */
- private IStatus loadTools() {
- String msg = ToolMessages.getString("ExternalToolRegistry.loadToolFailure"); //$NON-NLS-1$
- MultiStatus results = new MultiStatus(IExternalToolConstants.PLUGIN_ID, 0, msg, null);
-
- final File toolsPath = TOOLS_PATH.toFile();
- if (toolsPath.isDirectory()) {
- FilenameFilter filter = new FilenameFilter() {
- public boolean accept(File dir, String name) {
- return dir.equals(toolsPath) && name.endsWith(TOOLS_EXTENSION);
- }
- };
-
- String[] files = toolsPath.list(filter);
- for (int i = 0; i < files.length; i++) {
- IStatus status = loadTool(TOOLS_PATH.append(files[i]));
- if (status != null)
- results.add(status);
- }
- }
-
- return results;
- }
-
- /**
- * Loads an external tool from storage.
- */
- private IStatus loadTool(IPath filePath) {
- IStatus result = null;
- InputStreamReader reader = null;
-
- try {
- FileInputStream input = new FileInputStream(filePath.toFile());
- reader = new InputStreamReader(input, "utf-8"); //$NON-NLS-1$
- IPath basePath = filePath.removeLastSegments(1).addTrailingSeparator();
- XMLMemento memento = XMLMemento.createReadRoot(reader, basePath.toOSString());
-
- String type = memento.getString(TAG_TYPE);
- String name = memento.getString(TAG_NAME);
- ExternalTool tool = new ExternalTool(type, name);
-
- tool.setLocation(memento.getString(TAG_LOCATION));
- tool.setWorkingDirectory(memento.getString(TAG_WORK_DIR));
- tool.setCaptureOutput(TRUE.equals(memento.getString(TAG_CAPTURE_OUTPUT)));
- tool.setShowConsole(TRUE.equals(memento.getString(TAG_SHOW_CONSOLE)));
- tool.setRunInBackground(TRUE.equals(memento.getString(TAG_RUN_BKGRND)));
- tool.setPromptForArguments(TRUE.equals(memento.getString(TAG_PROMPT_ARGS)));
- tool.setShowInMenu(TRUE.equals(memento.getString(TAG_SHOW_MENU)));
- tool.setOpenPerspective(memento.getString(TAG_OPEN_PERSP));
- tool.setRefreshScope(memento.getString(TAG_REFRESH_SCOPE));
- tool.setRefreshRecursive(TRUE.equals(memento.getString(TAG_REFRESH_RECURSIVE)));
- tool.setSaveDirtyEditors(TRUE.equals(memento.getString(TAG_SAVE_DIRTY)));
-
- String types = memento.getString(TAG_RUN_BUILD_KINDS);
- if (types != null && types.length() > 0)
- tool.setRunForBuildKinds(buildTypesToArray(types));
-
- IMemento child = memento.getChild(TAG_DESC);
- if (child != null)
- tool.setDescription(child.getTextData());
-
- child = memento.getChild(TAG_ARGS);
- if (child != null)
- tool.setArguments(child.getTextData());
-
- IMemento[] attributes = memento.getChildren(TAG_EXTRA_ATTR);
- for (int i = 0; i < attributes.length; i++) {
- String key = attributes[i].getString(TAG_KEY);
- String value = attributes[i].getTextData();
- tool.setExtraAttribute(key, value);
- }
-
- addTool(tool, filePath);
- } catch (FileNotFoundException e) {
- String msg = e.getMessage();
- if (msg == null)
- msg = ToolMessages.getString("ExternalToolRegistry.fileNotFoundError"); //$NON-NLS-1$
- result = ExternalToolsPlugin.newErrorStatus(msg, e);
- } catch (IOException e) {
- String msg = e.getMessage();
- if (msg == null)
- msg = ToolMessages.getString("ExternalToolRegistry.ioLoadError"); //$NON-NLS-1$
- result = ExternalToolsPlugin.newErrorStatus(msg, e);
- } catch (CoreException e) {
- result = e.getStatus();
- } finally {
- if (reader != null) {
- try {
- reader.close();
- } catch(IOException e) {
- ExternalToolsPlugin.getDefault().log("Unable to close external tool storage reader.", e); //$NON-NLS-1$
- }
- }
- }
-
- return result;
- }
-
- /**
- * Cause the registry to reload all the tools from storage.
- *
- * @return a status containing any problems encountered.
- */
- public IStatus reloadTools() {
- tools = new HashMap();
- return loadTools();
- }
-
- /**
- * Save an external tool to storage. Adds it to the
- * in-memory registry if new.
- */
- public IStatus saveTool(ExternalTool tool) {
- boolean isNew = false;
-
- IPath filename = (IPath) filenames.get(tool.getName().toLowerCase());
- if (filename == null) {
- filename = generateToolFilename(tool.getName());
- isNew = true;
- }
-
- // Ensure the extenal tool storage directory exist
- TOOLS_PATH.toFile().mkdirs();
-
- IStatus results = storeTool(tool, filename);
- if (results != null)
- return results;
-
- if (isNew)
- addTool(tool, filename);
-
- return ExternalToolsPlugin.OK_STATUS;
- }
-
- /**
- * Stores an external tool to storage.
- */
- private IStatus storeTool(ExternalTool tool, IPath filePath) {
- IStatus result = null;
-
- // Populate the memento
- XMLMemento memento = XMLMemento.createWriteRoot(TAG_EXTERNAL_TOOL);
- memento.putString(TAG_VERSION, VERSION_21);
- memento.putString(TAG_TYPE, tool.getType());
- memento.putString(TAG_NAME, tool.getName());
- memento.putString(TAG_LOCATION, tool.getLocation());
- memento.putString(TAG_WORK_DIR, tool.getWorkingDirectory());
- memento.putString(TAG_CAPTURE_OUTPUT, tool.getCaptureOutput() ? TRUE : FALSE);
- memento.putString(TAG_SHOW_CONSOLE, tool.getShowConsole() ? TRUE : FALSE);
- memento.putString(TAG_RUN_BKGRND, tool.getRunInBackground() ? TRUE : FALSE);
- memento.putString(TAG_PROMPT_ARGS, tool.getPromptForArguments() ? TRUE : FALSE);
- memento.putString(TAG_SHOW_MENU, tool.getShowInMenu() ? TRUE : FALSE);
- memento.putString(TAG_OPEN_PERSP, tool.getOpenPerspective());
- memento.putString(TAG_REFRESH_SCOPE, tool.getRefreshScope());
- memento.putString(TAG_REFRESH_RECURSIVE, tool.getRefreshRecursive() ? TRUE : FALSE);
- memento.putString(TAG_SAVE_DIRTY, tool.getSaveDirtyEditors() ? TRUE : FALSE);
- memento.putString(TAG_RUN_BUILD_KINDS, buildKindsToString(tool.getRunForBuildKinds()));
-
- IMemento child = memento.createChild(TAG_DESC);
- if (child != null)
- child.putTextData(tool.getDescription());
-
- child = memento.createChild(TAG_ARGS);
- if (child != null)
- child.putTextData(tool.getArguments());
-
- String[] keys = tool.getExtraAttributeKeys();
- if (keys.length > 0) {
- String[] values = tool.getExtraAttributeValues();
- for (int i = 0; i < keys.length; i++) {
- child = memento.createChild(TAG_EXTRA_ATTR);
- if (child != null) {
- child.putString(TAG_KEY, keys[i]);
- child.putTextData(values[i]);
- }
- }
- }
-
- // Write the memento to the file
- File toolFile = filePath.toFile();
- OutputStreamWriter writer = null;
- try {
- FileOutputStream stream = new FileOutputStream(toolFile);
- writer = new OutputStreamWriter(stream, "utf-8"); //$NON-NLS-1$
- memento.save(writer);
- } catch (IOException e) {
- toolFile.delete();
- String msg = e.getMessage();
- if (msg == null)
- msg = ToolMessages.getString("ExternalToolRegistry.ioSaveError"); //$NON-NLS-1$
- result = ExternalToolsPlugin.newErrorStatus(msg, e);
- } finally {
- if (writer != null) {
- try {
- writer.close();
- } catch(IOException e) {
- ExternalToolsPlugin.getDefault().log("Unable to close external tool storage writer.", e); //$NON-NLS-1$
- }
- }
- if (result != null)
- toolFile.delete();
- }
-
- return result;
- }
-}
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/registry/ExternalToolType.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/registry/ExternalToolType.java
deleted file mode 100644
index b00d7f8f1..000000000
--- a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/registry/ExternalToolType.java
+++ /dev/null
@@ -1,155 +0,0 @@
-package org.eclipse.ui.externaltools.internal.registry;
-
-/**********************************************************************
-Copyright (c) 2002 IBM Corp. and others. All rights reserved.
-This file is made available under the terms of the Common Public License v1.0
-which accompanies this distribution, and is available at
-http://www.eclipse.org/legal/cpl-v10.html
-Contributors:
-**********************************************************************/
-
-import java.net.MalformedURLException;
-import java.net.URL;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtension;
-import org.eclipse.core.runtime.IPluginDescriptor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.ui.ISharedImages;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.externaltools.internal.model.ExternalToolsPlugin;
-import org.eclipse.ui.externaltools.model.IExternalToolRunner;
-import org.eclipse.ui.model.IWorkbenchAdapter;
-
-/**
- * This class represents the definition of an external
- * tool type.
- */
-public final class ExternalToolType implements IAdaptable {
- private ToolTypeWorkbenchAdapter workbenchAdapter;
-
- private String id;
- private String name;
- private IConfigurationElement element;
- private ImageDescriptor imageDescriptor;
- private IExternalToolRunner runner;
-
- /**
- * Create a new external tool type.
- *
- * @param id the unique identifier of this type
- * @param name a user readable label for this type
- * @param element the configuration element for the extension
- */
- /*package*/ ExternalToolType(String id, String name, IConfigurationElement element) {
- super();
- this.id = id;
- this.name = name;
- this.element = element;
- }
-
- /* (non-Javadoc)
- * Method declared on IAdaptable.
- */
- public Object getAdapter(Class adapter) {
- if (adapter == IWorkbenchAdapter.class) {
- if (workbenchAdapter == null)
- workbenchAdapter = new ToolTypeWorkbenchAdapter();
- return workbenchAdapter;
- }
- return null;
- }
-
- /**
- * Returns a short description of this type.
- */
- public String getDescription() {
- String description = element.getAttribute(ExternalToolTypeRegistry.TAG_DESCRIPTION);
- if (description == null)
- description = ""; //$NON-NLS-1$
- return description;
- }
-
- /**
- * Returns the id.
- */
- public String getId() {
- return id;
- }
-
- /**
- * Returns the name.
- */
- public String getName() {
- return name;
- }
-
- /**
- * Returns the image descriptor for this tool type icon.
- */
- public ImageDescriptor getImageDescriptor() {
- if (imageDescriptor == null) {
- IExtension extension = element.getDeclaringExtension();
- IPluginDescriptor pluginDescriptor = extension.getDeclaringPluginDescriptor();
- String location = element.getAttribute(ExternalToolTypeRegistry.TAG_ICON);
- if (location != null && location.length() > 0) {
- URL fullPath = pluginDescriptor.find(new Path(location));
- if (fullPath != null) {
- imageDescriptor = ImageDescriptor.createFromURL(fullPath);
- } else {
- try {
- URL installURL = pluginDescriptor.getInstallURL();
- fullPath = new URL(installURL, location);
- imageDescriptor = ImageDescriptor.createFromURL(fullPath);
- } catch (MalformedURLException e) {
- }
- }
- }
- if (imageDescriptor == null)
- imageDescriptor = ImageDescriptor.getMissingImageDescriptor();
- }
- return imageDescriptor;
- }
-
- /**
- * Returns the runner to run external tools of this type
- * or <code>null</code> if none provided by client.
- */
- public IExternalToolRunner getRunner() {
- if (runner == null) {
- try {
- runner = (IExternalToolRunner) element.createExecutableExtension(ExternalToolTypeRegistry.TAG_RUN_CLASS);
- } catch (CoreException e) {
- ExternalToolsPlugin.getDefault().getLog().log(e.getStatus());
- }
- }
- return runner;
- }
-
-
- /**
- * Internal workbench adapter implementation
- */
- private static class ToolTypeWorkbenchAdapter implements IWorkbenchAdapter {
- public Object[] getChildren(Object o) {
- ExternalToolType type = (ExternalToolType)o;
- return ExternalToolsPlugin.getDefault().getToolRegistry(null).getToolsOfType(type.getId());
- }
-
- public ImageDescriptor getImageDescriptor(Object o) {
- return PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_OBJ_FOLDER);
- }
-
- public String getLabel(Object o) {
- return ((ExternalToolType)o).getName();
- }
-
- public Object getParent(Object o) {
- return null;
- }
- }
-}
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/registry/ExternalToolTypeRegistry.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/registry/ExternalToolTypeRegistry.java
deleted file mode 100644
index 79bb765d8..000000000
--- a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/registry/ExternalToolTypeRegistry.java
+++ /dev/null
@@ -1,156 +0,0 @@
-package org.eclipse.ui.externaltools.internal.registry;
-
-/**********************************************************************
-Copyright (c) 2002 IBM Corp. and others. All rights reserved.
-This file is made available under the terms of the Common Public License v1.0
-which accompanies this distribution, and is available at
-http://www.eclipse.org/legal/cpl-v10.html
-Contributors:
-**********************************************************************/
-
-import java.util.ArrayList;
-
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtension;
-import org.eclipse.core.runtime.IExtensionPoint;
-import org.eclipse.core.runtime.IPluginRegistry;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.ui.externaltools.internal.model.ExternalToolsPlugin;
-import org.eclipse.ui.externaltools.model.IExternalToolConstants;
-
-/**
- * The registry of available external tool types.
- */
-public class ExternalToolTypeRegistry {
- // Format of the tool type extension point
- // <extension point="org.eclipse.ui.externalTools.toolTypes>
- // <toolType
- // id={string}
- // name={string}
- // description={string}
- // icon={string:path}
- // runnerClass={string:IExternalToolRunner}>
- // </toolType>
- // </extension>
- //
- /**
- * Element and attribute tags a tool type extension point.
- */
- /*package*/ static final String TAG_TOOL_TYPE = "toolType"; //$NON-NLS-1$
- /*package*/ static final String TAG_ID = "id"; //$NON-NLS-1$
- /*package*/ static final String TAG_NAME = "name"; //$NON-NLS-1$
- /*package*/ static final String TAG_ICON = "icon"; //$NON-NLS-1$
- /*package*/ static final String TAG_RUN_CLASS = "runnerClass"; //$NON-NLS-1$
- /*package*/ static final String TAG_DESCRIPTION = "description"; //$NON-NLS-1$
-
- private ArrayList types;
-
- /**
- * Creates a new registry and loads the available type
- * of external tools.
- */
- public ExternalToolTypeRegistry() {
- super();
- loadTypes();
- }
-
- /**
- * Returns the tool type for the specified id, or
- * <code>null</code> if none found.
- */
- public ExternalToolType getToolType(String toolTypeId) {
- for (int i = 0; i < types.size(); i++) {
- ExternalToolType type = (ExternalToolType) types.get(i);
- if (type.getId().equals(toolTypeId))
- return type;
- }
- return null;
- }
-
- /**
- * Returns the tool type image for the specified id.
- */
- public ImageDescriptor getToolTypeImageDescriptor(String toolTypeId) {
- ExternalToolType type = getToolType(toolTypeId);
- if (type == null)
- return ImageDescriptor.getMissingImageDescriptor();
- else
- return type.getImageDescriptor();
- }
-
- /**
- * Returns the types in the registry
- */
- public ExternalToolType[] getToolTypes() {
- ExternalToolType[] results = new ExternalToolType[types.size()];
- types.toArray(results);
- return results;
- }
-
- /**
- * Returns the number of tool types in the registry.
- */
- public int getTypeCount() {
- return types.size();
- }
-
- /**
- * Returns whether the tool type is known to
- * the registry.
- */
- public boolean hasType(String toolTypeId) {
- for (int i = 0; i < types.size(); i++) {
- ExternalToolType type = (ExternalToolType) types.get(i);
- if (type.getId().equals(toolTypeId))
- return true;
- }
- return false;
- }
-
- /**
- * Load the available types of external tools.
- */
- private void loadTypes() {
- types = new ArrayList(10);
- IPluginRegistry registry = Platform.getPluginRegistry();
- IExtensionPoint point = registry.getExtensionPoint(IExternalToolConstants.PLUGIN_ID, IExternalToolConstants.PL_TOOL_TYPES);
- if (point != null) {
- IExtension[] extensions = point.getExtensions();
- for (int i = 0; i < extensions.length; i++) {
- IConfigurationElement[] elements = extensions[i].getConfigurationElements();
- for (int j = 0; j < elements.length; j++) {
- IConfigurationElement element = elements[j];
- if (element.getName().equals(TAG_TOOL_TYPE)) {
- String id = element.getAttribute(TAG_ID);
- String name = element.getAttribute(TAG_NAME);
- String iconPath = element.getAttribute(TAG_ICON);
- String runClassName = element.getAttribute(TAG_RUN_CLASS);
-
- boolean valid = true;
- if (id == null || id.length() == 0) {
- valid = false;
- ExternalToolsPlugin.getDefault().log("Missing id attribute value for toolType element.", null); //$NON-NLS-1$
- }
- if (name == null || name.length() == 0) {
- valid = false;
- ExternalToolsPlugin.getDefault().log("Missing name attribute value for toolType element.", null); //$NON-NLS-1$
- }
- if (iconPath == null || iconPath.length() == 0) {
- valid = false;
- ExternalToolsPlugin.getDefault().log("Missing icon attribute value for toolType element.", null); //$NON-NLS-1$
- }
- if (runClassName == null || runClassName.length() == 0) {
- valid = false;
- ExternalToolsPlugin.getDefault().log("Missing class attribute value for toolType element.", null); //$NON-NLS-1$
- }
-
- if (valid)
- types.add(new ExternalToolType(id, name, element));
- }
- }
- }
- }
- }
-}
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/AntAction.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/AntAction.java
deleted file mode 100644
index 900f7ff30..000000000
--- a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/AntAction.java
+++ /dev/null
@@ -1,166 +0,0 @@
-package org.eclipse.ui.externaltools.internal.ui;
-
-/**********************************************************************
-Copyright (c) 2002 IBM Corp. and others.
-All rights reserved.   This program and the accompanying materials
-are made available under the terms of the Common Public License v0.5
-which accompanies this distribution, and is available at
-http://www.eclipse.org/legal/cpl-v05.html
-Contributors:
-**********************************************************************/
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.MultiStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.wizard.WizardDialog;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.dialogs.ElementListSelectionDialog;
-import org.eclipse.ui.externaltools.internal.ant.dialog.AntExternalToolNewWizard;
-import org.eclipse.ui.externaltools.internal.model.DefaultRunnerContext;
-import org.eclipse.ui.externaltools.internal.model.ExternalToolsPlugin;
-import org.eclipse.ui.externaltools.internal.model.IHelpContextIds;
-import org.eclipse.ui.externaltools.internal.registry.ExternalToolRegistry;
-import org.eclipse.ui.externaltools.internal.view.ExternalToolLabelProvider;
-import org.eclipse.ui.externaltools.model.ExternalTool;
-import org.eclipse.ui.externaltools.model.ExternalToolStorage;
-import org.eclipse.ui.externaltools.model.IExternalToolConstants;
-import org.eclipse.ui.externaltools.model.IStorageListener;
-import org.eclipse.ui.externaltools.model.ToolUtil;
-import org.eclipse.ui.externaltools.variable.ExpandVariableContext;
-import org.eclipse.ui.help.WorkbenchHelp;
-
-/**
- * Action to run an ant build file.
- */
-public class AntAction extends Action {
- private IFile file;
- private IWorkbenchWindow window;
-
- /**
- * Creates an initialize action to run an
- * Ant build file
- *
- * @param file the ant build file to run
- */
- public AntAction(IFile file, IWorkbenchWindow window) {
- super();
- this.file = file;
- this.window = window;
- setText(file.getName());
- setToolTipText(file.getFullPath().toOSString());
- WorkbenchHelp.setHelp(this, IHelpContextIds.ANT_ACTION);
- }
-
- private Shell getShell() {
- return PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
- }
-
- private ExternalTool chooseTool(List tools) {
- ILabelProvider labelProvider = new ExternalToolLabelProvider();
- ElementListSelectionDialog dialog= new ElementListSelectionDialog(getShell(), labelProvider);
- dialog.setElements((ExternalTool[]) tools.toArray(new ExternalTool[tools.size()]));
- dialog.setTitle("Ant Tool Selection");
- dialog.setMessage("Choose an ant tool to run");
- dialog.setMultipleSelection(false);
- int result = dialog.open();
- labelProvider.dispose();
- if (result == ElementListSelectionDialog.OK) {
- return (ExternalTool) dialog.getFirstResult();
- }
- return null;
- }
-
- public void runTool(final ExternalTool tool) {
- final MultiStatus status = new MultiStatus(IExternalToolConstants.PLUGIN_ID, 0, "", null);
- BusyIndicator.showWhile(getShell().getDisplay(), new Runnable() {
- public void run() {
- new DefaultRunnerContext(tool, file).run(new NullProgressMonitor(), status);
- }
- });
- if (!status.isOK()) {
- StringBuffer message= new StringBuffer("An exception occurred while running ant: ");
- IStatus[] errors= status.getChildren();
- IStatus error;
- for (int i= 0, numErrors= errors.length; i < numErrors; i++) {
- error= errors[i];
- if (error.getSeverity() == IStatus.ERROR) {
- Throwable exception= error.getException();
- message.append('\n');
- if (exception != null) {
- message.append(exception.getClass().getName()).append(' ');
- }
- message.append(error.getMessage());
- }
- }
- MessageDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "Ant Error", message.toString());
- }
- }
-
- /* (non-Javadoc)
- * Method declared on IAction.
- */
- public void run() {
- if (file == null) {
- return;
- }
-
- ExternalTool tool= null;
- ExternalToolRegistry registry= ExternalToolsPlugin.getDefault().getToolRegistry(getShell());
- ExternalTool[] antTools= registry.getToolsOfType(IExternalToolConstants.TOOL_TYPE_ANT_BUILD);
- MultiStatus status = new MultiStatus(IExternalToolConstants.PLUGIN_ID, 0, "An error occurred while expanding the location of one or more ant tools: ", null);
- List tools= new ArrayList();
- String toolLocation;
- for (int i= 0, numTools= antTools.length; i < numTools; i++) {
- toolLocation= ToolUtil.expandFileLocation(antTools[i].getLocation(), ExpandVariableContext.EMPTY_CONTEXT, status);
- if (toolLocation != null && toolLocation.equals(file.getLocation().toString())) {
- tools.add(antTools[i]);
- }
- }
- if (tools.size() == 1) {
- tool= (ExternalTool)tools.get(0);
- } else if (tools.size() > 1) {
- tool= chooseTool(tools);
- if (tool == null) {
- // User cancelled.
- return;
- }
- }
-
- if (tool != null) {
- runTool(tool);
- return;
- }
- WizardDialog dialog= new WizardDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), new AntExternalToolNewWizard(file));
- dialog.open();
- if (dialog.getReturnCode() == WizardDialog.CANCEL) {
- return;
- }
- ExternalToolStorage.addStorageListener(new IStorageListener() {
- public void toolDeleted(ExternalTool tool) {
- }
-
- public void toolCreated(ExternalTool tool) {
- if (tool.getLocation().equals(file.getLocation().toString())) { // Is this the tool we're expecting?
- runTool(tool);
- }
- ExternalToolStorage.removeStorageListener(this);
- }
-
- public void toolModified(ExternalTool tool) {
- }
-
- public void toolsRefreshed() {
- }
- });
- }
-} \ No newline at end of file
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/AntLaunchWizard.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/AntLaunchWizard.java
deleted file mode 100644
index 8711353cc..000000000
--- a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/AntLaunchWizard.java
+++ /dev/null
@@ -1,176 +0,0 @@
-package org.eclipse.ui.externaltools.internal.ui;
-
-/**********************************************************************
-Copyright (c) 2002 IBM Corp. and others.
-All rights reserved.   This program and the accompanying materials
-are made available under the terms of the Common Public License v0.5
-which accompanies this distribution, and is available at
-http://www.eclipse.org/legal/cpl-v05.html
-Contributors:
-**********************************************************************/
-
-import java.lang.reflect.InvocationTargetException;
-
-import org.eclipse.ant.core.TargetInfo;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.MultiStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.dialogs.ErrorDialog;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.wizard.Wizard;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.externaltools.internal.ant.model.AntUtil;
-import org.eclipse.ui.externaltools.internal.model.DefaultRunnerContext;
-import org.eclipse.ui.externaltools.internal.model.ExternalToolsPlugin;
-import org.eclipse.ui.externaltools.internal.model.ToolMessages;
-import org.eclipse.ui.externaltools.model.ExternalTool;
-import org.eclipse.ui.externaltools.model.IExternalToolConstants;
-import org.eclipse.ui.externaltools.model.ToolUtil;
-
-/**
- * The wizard to run an Ant file when the Run Ant...
- * context menu action is choosen by the user.
- * <p>
- * Note: Currently there is only one page in this wizard.
- * </p>
- */
-public class AntLaunchWizard extends Wizard {
- /**
- * The file that contains the Ant file.
- */
- private IFile antFile = null;
-
- /**
- * The Ant project described in the xml file.
- */
- private TargetInfo[] targetList = null;
-
- /**
- * The external tool representing the Ant file
- */
- private ExternalTool antTool = null;
-
- /**
- * Whether the external tool is new for this wizard
- */
- private boolean isNewTool = false;
-
- /**
- * The workbench window that the action launch
- * this wizard.
- */
- private IWorkbenchWindow window = null;
-
- /**
- * The first page of the wizard.
- */
- private AntLaunchWizardPage page1 = null;
-
- /**
- * Creates a new wizard, given the project described in the
- * file and the file itself.
- *
- * @param antProject
- * @param antFile
- */
- public AntLaunchWizard(TargetInfo[] targetList, IFile antFile, IWorkbenchWindow window) {
- super();
- this.targetList = targetList;
- this.antFile = antFile;
- this.window = window;
- String antPath = antFile.getFullPath().toString();
- this.antTool = ExternalToolsPlugin.getDefault().getToolRegistry(getShell()).getToolNamed(antPath);
- if (this.antTool == null) {
- try {
- this.antTool = new ExternalTool(IExternalToolConstants.TOOL_TYPE_ANT_BUILD, antPath);
- } catch (CoreException exception) {
- MessageDialog.openError(getShell(), "Ant Error", "An exception occurred launching ant file");
- return;
- }
- this.antTool.setLocation(ToolUtil.buildVariableTag(IExternalToolConstants.VAR_WORKSPACE_LOC, antPath));
- this.isNewTool = true;
- }
- setWindowTitle(ToolMessages.getString("AntLaunchWizard.shellTitle")); //$NON-NLS-1$;
- }
-
- /* (non-Javadoc)
- * Method declared on IWizard.
- */
- public void addPages() {
- page1 = new AntLaunchWizardPage(targetList);
- addPage(page1);
-
- StringBuffer buf = new StringBuffer();
- String[] targets = AntUtil.parseRunTargets(antTool.getExtraAttribute(AntUtil.RUN_TARGETS_ATTRIBUTE));
-
- page1.setInitialTargets(targets);
- page1.setInitialArguments(buf.toString());
- page1.setInitialDisplayLog(antTool.getShowConsole());
- }
-
- /* (non-Javadoc)
- * Method declared on IWizard.
- */
- public boolean performFinish() {
- updateTool();
-// ToolUtil.saveDirtyEditors(window);
-// if (antTool.getShowConsole()) {
-// ToolUtil.showLogConsole(window);
-// ToolUtil.clearLogDocument();
-// }
-
- IRunnableWithProgress runnable = new IRunnableWithProgress() {
- public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
- DefaultRunnerContext context = new DefaultRunnerContext(antTool, antFile); //new DefaultRunnerContext(antTool, antFile.getProject(), window.getWorkbench().getWorkingSetManager());
- MultiStatus status = new MultiStatus(IExternalToolConstants.PLUGIN_ID, 0, "", null); //$NON-NLS-1$
- context.run(monitor, status);
- if (!status.isOK()) {
- MessageDialog.openError(getShell(), "Ant Error", "An exception occurred while running ant");
- }
- };
- };
-
- try {
- getContainer().run(true, true, runnable);
- } catch (InterruptedException e) {
- return false;
- } catch (InvocationTargetException e) {
- IStatus status = null;
- if (e.getTargetException() instanceof CoreException)
- status = ((CoreException)e.getTargetException()).getStatus();
- else
- status = new Status(IStatus.ERROR, IExternalToolConstants.PLUGIN_ID, 0, ToolMessages.getString("AntLaunchWizard.internalAntError"), e.getTargetException()); //$NON-NLS-1$;
- ErrorDialog.openError(
- getShell(),
- ToolMessages.getString("AntLaunchWizard.runErrorTitle"), //$NON-NLS-1$;
- ToolMessages.getString("AntLaunchWizard.runAntProblem"), //$NON-NLS-1$;
- status);
- return false;
- }
-
- return true;
- }
-
- /**
- * Method updateTool.
- */
- private void updateTool() {
- StringBuffer buf = new StringBuffer(page1.getArguments());
- String[] targets = page1.getSelectedTargets();
- ToolUtil.buildVariableTag(AntUtil.RUN_TARGETS_ATTRIBUTE, AntUtil.combineRunTargets(targets), buf);
-
- antTool.setArguments(buf.toString());
- antTool.setShowConsole(page1.getShowLog());
-
- if (isNewTool) {
- ExternalToolsPlugin.getDefault().getToolRegistry(getShell()).saveTool(antTool);
- isNewTool = false;
- }
-
- }
-} \ No newline at end of file
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/AntLaunchWizardPage.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/AntLaunchWizardPage.java
deleted file mode 100644
index 9e32241f8..000000000
--- a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/AntLaunchWizardPage.java
+++ /dev/null
@@ -1,246 +0,0 @@
-package org.eclipse.ui.externaltools.internal.ui;
-
-/**********************************************************************
-Copyright (c) 2002 IBM Corp. and others.
-All rights reserved.   This program and the accompanying materials
-are made available under the terms of the Common Public License v0.5
-which accompanies this distribution, and is available at
-http://www.eclipse.org/legal/cpl-v05.html
-Contributors:
-**********************************************************************/
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.ArrayList;
-
-import org.eclipse.ant.core.TargetInfo;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.CheckStateChangedEvent;
-import org.eclipse.jface.viewers.CheckboxTableViewer;
-import org.eclipse.jface.viewers.ICheckStateListener;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerSorter;
-import org.eclipse.jface.wizard.WizardPage;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.externaltools.internal.model.ExternalToolsPlugin;
-import org.eclipse.ui.externaltools.internal.model.IHelpContextIds;
-import org.eclipse.ui.externaltools.internal.model.ToolMessages;
-import org.eclipse.ui.help.WorkbenchHelp;
-
-/**
- * First page of the run Ant wizard. Allows the user to pick
- * the targets, supply extra arguments, and decide to show
- * output to the console.
- */
-public class AntLaunchWizardPage extends WizardPage {
- private static final int SIZING_SELECTION_WIDGET_HEIGHT = 200;
- private static final int SIZING_SELECTION_WIDGET_WIDTH = 200;
-
- private TargetInfo[] targetList;
- private String initialTargets[];
- private String initialArguments;
- private boolean initialDisplayLog = true;
- private ArrayList selectedTargets = new ArrayList();
-
- private CheckboxTableViewer listViewer;
- private AntTargetLabelProvider labelProvider = new AntTargetLabelProvider();
- private Button showLog;
- private Text argumentsField;
-
- public AntLaunchWizardPage(TargetInfo[] targetList) {
- super("AntScriptPage"); //$NON-NLS-1$;
- this.targetList = targetList;
- setTitle(ToolMessages.getString("AntLaunchWizard.dialogTitle")); //$NON-NLS-1$;
- setDescription(ToolMessages.getString("AntLaunchWizard.dialogDescription")); //$NON-NLS-1$;
- setImageDescriptor(getImageDescriptor("icons/full/wizban/ant_wiz.gif")); //$NON-NLS-1$;
- }
-
- /**
- * Returns the image descriptor for the banner
- */
- private ImageDescriptor getImageDescriptor(String relativePath) {
- try {
- URL installURL = ExternalToolsPlugin.getDefault().getDescriptor().getInstallURL();
- URL url = new URL(installURL, relativePath);
- return ImageDescriptor.createFromURL(url);
- } catch (MalformedURLException e) {
- return null;
- }
- }
-
- /* (non-Javadoc)
- * Method declared on IWizardPage.
- */
- public void createControl(Composite parent) {
- Composite composite = new Composite(parent, SWT.NULL);
- composite.setLayout(new GridLayout());
- composite.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_FILL | GridData.HORIZONTAL_ALIGN_FILL));
-
- // The list of targets
- Label label = new Label(composite, SWT.NONE);
- label.setText(ToolMessages.getString("AntLaunchWizardPage.targetLabel")); //$NON-NLS-1$;
-
- listViewer = CheckboxTableViewer.newCheckList(composite, SWT.BORDER);
- GridData data = new GridData(GridData.FILL_BOTH);
- data.heightHint = SIZING_SELECTION_WIDGET_HEIGHT;
- data.widthHint = SIZING_SELECTION_WIDGET_WIDTH;
- listViewer.getTable().setLayoutData(data);
- listViewer.setSorter(new ViewerSorter() {
- public int compare(Viewer viewer, Object o1, Object o2) {
- return ((String)o1).compareTo((String) o2);
- }
- });
- for (int i= 0, numTargets= targetList.length; i < numTargets; i++) {
- if (targetList[i].isDefault()) {
- labelProvider.setDefaultTargetName(targetList[i].getName());
- break;
- }
- }
- listViewer.setLabelProvider(labelProvider);
- listViewer.setContentProvider(new AntTargetContentProvider());
- listViewer.setInput(targetList);
-
- // The arguments field
- label = new Label(composite, SWT.NONE);
- label.setText(ToolMessages.getString("AntLaunchWizardPage.argsLabel")); //$NON-NLS-1$;
-
- argumentsField = new Text(composite, SWT.BORDER);
- argumentsField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- argumentsField.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- validatePageComplete();
- }
- });
-
- // The show log option
- showLog = new Button(composite, SWT.CHECK);
- showLog.setText(ToolMessages.getString("AntLaunchWizardPage.showLogLabel")); //$NON-NLS-1$;
-
- // Setup initial field values
- if (initialArguments != null)
- argumentsField.setText(initialArguments);
- showLog.setSelection(initialDisplayLog);
- selectInitialTargets();
-
- validatePageComplete();
-
- listViewer.addCheckStateListener(new TargetCheckListener());
- listViewer.refresh();
- argumentsField.setFocus();
-
- setControl(composite);
-
- WorkbenchHelp.setHelp(composite, IHelpContextIds.ANT_LAUNCH_WIZARD_PAGE);
- }
-
- /**
- * Returns the arguments that the user has entered
- * to run the ant file.
- *
- * @return String the arguments
- */
- public String getArguments() {
- return argumentsField.getText().trim();
- }
-
- /**
- * Returns the targets selected by the user
- */
- public String[] getSelectedTargets() {
- String[] names = new String[selectedTargets.size()];
- selectedTargets.toArray(names);
- return names;
- }
-
- /**
- * Returns whether the users wants messages from running
- * the tool displayed in the console
- */
- public boolean getShowLog() {
- return showLog.getSelection();
- }
-
- /**
- * Setup the initial selected targets in the viewer
- */
- private void selectInitialTargets() {
- if (initialTargets != null && initialTargets.length > 0) {
- for (int i = 0; i < initialTargets.length; i++) {
- for (int j = 0; j < targetList.length; j++) {
- if (targetList[j].equals(initialTargets[i])) {
- String target = targetList[j].getName();
- listViewer.setChecked(target, true);
- selectedTargets.add(target);
- break;
- }
- }
- }
- } else {
- for (int i= 0, numTargets= targetList.length; i < numTargets; i++) {
- if (targetList[i].isDefault()) {
- listViewer.setChecked(targetList[i], true);
- selectedTargets.add(targetList[i]);
- }
- }
- }
-
- labelProvider.setSelectedTargets(selectedTargets);
- }
-
- /**
- * Sets the initial contents of the target list field.
- * Ignored if controls already created.
- */
- public void setInitialTargets(String value[]) {
- initialTargets = value;
- }
-
- /**
- * Sets the initial contents of the arguments text field.
- * Ignored if controls already created.
- */
- public void setInitialArguments(String value) {
- initialArguments = value;
- }
-
- /**
- * Sets the initial contents of the display to log option field.
- * Ignored if controls already created.
- */
- public void setInitialDisplayLog(boolean value) {
- initialDisplayLog = value;
- }
-
- /**
- * Validates the page is complete
- */
- private void validatePageComplete() {
- setPageComplete(selectedTargets.size() > 0 || getArguments().length() > 0);
- }
-
-
- /**
- * Inner class for checkbox listener
- */
- private class TargetCheckListener implements ICheckStateListener {
- public void checkStateChanged(CheckStateChangedEvent e) {
- String checkedTarget = (String) e.getElement();
- if (e.getChecked())
- selectedTargets.add(checkedTarget);
- else
- selectedTargets.remove(checkedTarget);
-
- labelProvider.setSelectedTargets(selectedTargets);
- listViewer.refresh();
- validatePageComplete();
- }
- }
-} \ No newline at end of file
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/LogConsoleDocument.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/LogConsoleDocument.java
deleted file mode 100644
index f1236c156..000000000
--- a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/LogConsoleDocument.java
+++ /dev/null
@@ -1,334 +0,0 @@
-package org.eclipse.ui.externaltools.internal.ui;
-
-/**********************************************************************
-Copyright (c) 2002 IBM Corp. and others.
-All rights reserved.   This program and the accompanying materials
-are made available under the terms of the Common Public License v0.5
-which accompanies this distribution, and is available at
-http://www.eclipse.org/legal/cpl-v05.html
-Contributors:
-**********************************************************************/
-import java.util.*;
-
-import org.eclipse.jface.preference.PreferenceConverter;
-import org.eclipse.jface.text.*;
-import org.eclipse.jface.util.*;
-import org.eclipse.swt.custom.StyleRange;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.externaltools.internal.model.*;
-import org.eclipse.ui.externaltools.model.IRunnerLog;
-
-/**
- * Holds onto messages generated by the execution on an
- * external tool.
- */
-public class LogConsoleDocument implements IRunnerLog {
- // class variables that handle the colors and the font
- private static Color ERROR_COLOR;
- private static Color WARN_COLOR;
- private static Color INFO_COLOR;
- private static Color VERBOSE_COLOR;
- private static Color DEBUG_COLOR;
- /*package*/ static Font ANT_FONT;
-
- public static final int MSG_ERR = 0;
- public static final int MSG_WARN = 10;
- public static final int MSG_INFO = 20;
- public static final int MSG_VERBOSE = 30;
- public static final int MSG_DEBUG = 40;
-
- private static final LogConsoleDocument instance = new LogConsoleDocument();
-
- private LogPropertyChangeListener changeListener;
-
- /*package*/ ArrayList views = new ArrayList();
- private Document document;
- private ArrayList styleRanges;
-
- // Structure to store the textwidget index information
- private OutputStructureElement root = null;
- private OutputStructureElement currentElement = null;
-
- private LogConsoleDocument() {
- changeListener = new LogPropertyChangeListener();
- document = new Document();
- styleRanges = new ArrayList(5);
- initializeOutputStructure();
- }
-
- public int getFilterLevel() {
- return IRunnerLog.LEVEL_DEBUG;
- }
-
- public void append(final String message, final int priority) {
- if (views.size() == 0)
- return;
- ((LogConsoleView)views.get(0)).getViewSite().getShell().getDisplay().syncExec(new Runnable() {
- public void run() {
- int start = getDocument().getLength();
- try {
- // Append new message to the end of the document. This
- // avoids console flicker when messages are appended.
- getDocument().replace(start, 0, message);
- } catch (BadLocationException e) {
- }
- setOutputLevelColor(priority, start, message.length());
- }
- });
- for (int i=0; i < views.size(); i++) {
- ((LogConsoleView)views.get(i)).append(message, priority);
- }
- }
-
- private void addRangeStyle(int start, int length, Color color) {
- // Don't add a StyleRange if the length is 0.
- if (length == 0)
- return;
- if (styleRanges.size() != 0) {
- StyleRange lastStyle = (StyleRange) styleRanges.get(styleRanges.size()-1);
- if (color.equals(lastStyle.foreground))
- lastStyle.length += length;
- else
- styleRanges.add(new StyleRange(start, length, color, null));
- } else
- styleRanges.add(new StyleRange(start, length, color, null));
- StyleRange[] styleArray = (StyleRange[]) styleRanges.toArray(new StyleRange[styleRanges.size()]);
- for (int i = 0; i < views.size(); i++) {
- TextViewer tv = ((LogConsoleView)views.get(i)).getTextViewer();
- if (tv != null)
- tv.getTextWidget().setStyleRanges(styleArray);
- }
- }
-
- public void clearOutput() {
- document.set("");
- styleRanges.clear();
- // the tree can be null if #createPartControl has not called yet,
- // i.e. if the console exists but has never been shown so far
- initializeOutputStructure();
- refreshTree();
- }
-
- public void refreshTree() {
- for(int i=0; i<views.size(); i++) {
- ((LogConsoleView)views.get(i)).refreshTree();
- }
- }
-
- /**
- * Returns the color used for error messages on the log console.
- */
- private static Color getErrorColor() {
- if (ERROR_COLOR == null || ERROR_COLOR.isDisposed())
- ERROR_COLOR = new Color(null, PreferenceConverter.getColor(ExternalToolsPlugin.getDefault().getPreferenceStore(),IPreferenceConstants.CONSOLE_ERROR_RGB));
- return ERROR_COLOR;
- }
- /**
- * Returns the color used for warning messages on the log console.
- */
- private static Color getWarnColor() {
- if (WARN_COLOR == null || WARN_COLOR.isDisposed())
- WARN_COLOR = new Color(null, PreferenceConverter.getColor(ExternalToolsPlugin.getDefault().getPreferenceStore(),IPreferenceConstants.CONSOLE_WARNING_RGB));
- return WARN_COLOR;
- }
- /**
- * Returns the color used for info (normal) messages on the log console.
- */
- private static Color getInfoColor() {
- if (INFO_COLOR == null || INFO_COLOR.isDisposed())
- INFO_COLOR = new Color(null, PreferenceConverter.getColor(ExternalToolsPlugin.getDefault().getPreferenceStore(),IPreferenceConstants.CONSOLE_INFO_RGB));
- return INFO_COLOR;
- }
- /**
- * Returns the color used for verbose messages on the log console.
- */
- private static Color getVerboseColor() {
- if (VERBOSE_COLOR == null || VERBOSE_COLOR.isDisposed())
- VERBOSE_COLOR = new Color(null, PreferenceConverter.getColor(ExternalToolsPlugin.getDefault().getPreferenceStore(),IPreferenceConstants.CONSOLE_VERBOSE_RGB));
- return VERBOSE_COLOR;
- }
- /**
- * Returns the color used for debug messages on the log console.
- */
- private static Color getDebugColor() {
- if (DEBUG_COLOR == null || DEBUG_COLOR.isDisposed())
- DEBUG_COLOR = new Color(null, PreferenceConverter.getColor(ExternalToolsPlugin.getDefault().getPreferenceStore(),IPreferenceConstants.CONSOLE_DEBUG_RGB));
- return DEBUG_COLOR;
- }
-
- public Display getDisplay() {
- if (!hasViews())
- return null;
- return ((LogConsoleView)views.get(0)).getSite().getShell().getDisplay();
- }
-
- /*package*/ Document getDocument() {
- return document;
- }
-
- /*package*/ ArrayList getStyleRanges() {
- return styleRanges;
- }
-
- public ArrayList getViews() {
- return views;
- }
-
- /*package*/ OutputStructureElement getRoot() {
- return root;
- }
-
- public boolean hasViews() {
- return (views.size() > 0);
- }
-
- public void initializeOutputStructure() {
- // root is the first element of the structure: it is a fake so it doesn't need a real name
- root = new OutputStructureElement("-- root --"); // $NON-NLS-1$
- currentElement = new OutputStructureElement(ToolMessages.getString("LogConsoleDocument.externalTool"), root, 0); // $NON-NLS-1$
-
- for (int i=0; i < views.size(); i++) {
- LogConsoleView view = (LogConsoleView)views.get(i);
- if (view.getTreeViewer() != null)
- view.initializeTreeInput();
- }
- }
-
- public void registerView(LogConsoleView view) {
- if (!hasViews()) {
- // first time there is an instance of this class: intantiate the font and register the listener
- ANT_FONT = new Font(null, PreferenceConverter.getFontData(ExternalToolsPlugin.getDefault().getPreferenceStore(),IPreferenceConstants.CONSOLE_FONT));
- ExternalToolsPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(changeListener);
- }
- views.add(view);
- }
-
- public void unregisterView(LogConsoleView view) {
- views.remove(view);
- if (! hasViews()) {
- // all the consoles are diposed: we can dispose the font and remove the property listener
- ANT_FONT.dispose();
- ExternalToolsPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(changeListener);
- }
- }
-
- public static LogConsoleDocument getInstance() {
- return instance;
- }
-
- public OutputStructureElement getCurrentOutputStructureElement() {
- return currentElement;
- }
- public void setCurrentOutputStructureElement(OutputStructureElement output) {
- this.currentElement = output;
- }
- /*package*/ void setOutputLevelColor(int level, int start, int end) {
- switch (level) {
- case LogConsoleDocument.MSG_ERR:
- addRangeStyle(start, end, getErrorColor());
- break;
- case LogConsoleDocument.MSG_WARN:
- addRangeStyle(start, end, getWarnColor());
- break;
- case LogConsoleDocument.MSG_INFO:
- addRangeStyle(start, end, getInfoColor());
- break;
- case LogConsoleDocument.MSG_VERBOSE:
- addRangeStyle(start, end, getVerboseColor());
- break;
- case LogConsoleDocument.MSG_DEBUG:
- addRangeStyle(start, end, getDebugColor());
- break;
- default:
- addRangeStyle(start, end, getInfoColor());
- }
- }
-
- /**
- * Replaces the old color with the new one in all style ranges,
- */
- private void updateStyleRanges(Color oldColor, Color newColor) {
- for (int i=0; i<styleRanges.size(); i++) {
- StyleRange range = (StyleRange)styleRanges.get(i);
- if (range.foreground == oldColor)
- range.foreground = newColor;
- }
- }
-
- private class LogPropertyChangeListener implements IPropertyChangeListener {
-
- // private constructor to ensure the singleton
- private LogPropertyChangeListener() {
- }
-
- /**
- * @see IPropertyChangeListener#propertyChange(PropertyChangeEvent)
- */
- public void propertyChange(PropertyChangeEvent event) {
- String propertyName= event.getProperty();
-
- if (propertyName.equals(IPreferenceConstants.CONSOLE_ERROR_RGB)) {
- if (LogConsoleDocument.ERROR_COLOR == null)
- return;
- Color temp = getErrorColor();
- LogConsoleDocument.ERROR_COLOR = ToolsPreferencePage.getPreferenceColor(IPreferenceConstants.CONSOLE_ERROR_RGB);
- updateStyleRanges(temp, getErrorColor());
- temp.dispose();
- } else if (propertyName.equals(IPreferenceConstants.CONSOLE_WARNING_RGB)) {
- if (LogConsoleDocument.WARN_COLOR == null)
- return;
- Color temp = getWarnColor();
- LogConsoleDocument.WARN_COLOR = ToolsPreferencePage.getPreferenceColor(IPreferenceConstants.CONSOLE_WARNING_RGB);
- updateStyleRanges(temp, getWarnColor());
- temp.dispose();
- } else if (propertyName.equals(IPreferenceConstants.CONSOLE_INFO_RGB)) {
- if (LogConsoleDocument.INFO_COLOR == null)
- return;
- Color temp = getInfoColor();
- LogConsoleDocument.INFO_COLOR = ToolsPreferencePage.getPreferenceColor(IPreferenceConstants.CONSOLE_INFO_RGB);
- updateStyleRanges(temp, getInfoColor());
- temp.dispose();
- } else if (propertyName.equals(IPreferenceConstants.CONSOLE_VERBOSE_RGB)) {
- if (LogConsoleDocument.VERBOSE_COLOR == null)
- return;
- Color temp = getVerboseColor();
- LogConsoleDocument.VERBOSE_COLOR = ToolsPreferencePage.getPreferenceColor(IPreferenceConstants.CONSOLE_VERBOSE_RGB);
- updateStyleRanges(temp, getVerboseColor());
- temp.dispose();
- } else if (propertyName.equals(IPreferenceConstants.CONSOLE_DEBUG_RGB)) {
- if (LogConsoleDocument.DEBUG_COLOR == null)
- return;
- Color temp = getDebugColor();
- LogConsoleDocument.DEBUG_COLOR = ToolsPreferencePage.getPreferenceColor(IPreferenceConstants.CONSOLE_DEBUG_RGB);
- updateStyleRanges(temp, getDebugColor());
- temp.dispose();
- } else if (propertyName.equals(IPreferenceConstants.CONSOLE_FONT)) {
- FontData data= ToolsPreferencePage.getConsoleFontData();
- Font temp= LogConsoleDocument.ANT_FONT;
- LogConsoleDocument.ANT_FONT = new Font(Display.getCurrent(), data);
- temp.dispose();
- updateFont();
- } else
- return;
- }
-
- /**
- * Clears the output of all the consoles
- */
- private void clearOutput() {
- LogConsoleDocument.getInstance().clearOutput();
- }
-
- /**
- * Updates teh font in all the consoles
- */
- private void updateFont() {
- for (Iterator iterator = LogConsoleDocument.getInstance().getViews().iterator(); iterator.hasNext();)
- ((LogConsoleView) iterator.next()).updateFont();
- }
- }
-
-
-}
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/LogConsoleView.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/LogConsoleView.java
deleted file mode 100644
index d03095b16..000000000
--- a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/LogConsoleView.java
+++ /dev/null
@@ -1 +0,0 @@
-package org.eclipse.ui.externaltools.internal.ui; /********************************************************************** Copyright (c) 2002 IBM Corp. and others. All rights reserved.   This program and the accompanying materials are made available under the terms of the Common Public License v0.5 which accompanies this distribution, and is available at http://www.eclipse.org/legal/cpl-v05.html   Contributors: **********************************************************************/ import java.net.MalformedURLException; import java.net.URL; import java.util.ArrayList; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IMenuListener; import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.action.IToolBarManager; import org.eclipse.jface.action.MenuManager; import org.eclipse.jface.action.Separator; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.text.Document; import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.IFindReplaceTarget; import org.eclipse.jface.text.ITextOperationTarget; import org.eclipse.jface.text.TextViewer; import org.eclipse.jface.viewers.AbstractTreeViewer; import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.SelectionChangedEvent; import org.eclipse.jface.viewers.TreeViewer; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.SashForm; import org.eclipse.swt.custom.StyleRange; import org.eclipse.swt.custom.StyledText; import org.eclipse.swt.events.ControlAdapter; import org.eclipse.swt.events.ControlEvent; import org.eclipse.swt.events.KeyAdapter; import org.eclipse.swt.events.KeyEvent; import org.eclipse.swt.events.MouseAdapter; import org.eclipse.swt.events.MouseEvent; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Menu; import org.eclipse.swt.widgets.TreeItem; import org.eclipse.ui.IActionBars; import org.eclipse.ui.IMemento; import org.eclipse.ui.IViewSite; import org.eclipse.ui.PartInitException; import org.eclipse.ui.externaltools.internal.model.ExternalToolsPlugin; import org.eclipse.ui.externaltools.internal.model.ToolMessages; import org.eclipse.ui.part.ViewPart; import org.eclipse.ui.texteditor.FindReplaceAction; import org.eclipse.ui.texteditor.ITextEditorActionConstants; public class LogConsoleView extends ViewPart { public final static String PROPERTY_PREFIX_FIND = "LogConsoleView.findAction."; // $NON-NLS-1$ private final static int SASH_WIDTH = 3; // regular width for a sash // strings for the memento private final static String TREE_WIDTH_PROPERTY = "tree_width"; private final static String SHOW_ONLY_SELECTED_ITEM_PROPERTY = "wasShowOnlySelectedTreeItemsTurnedOn"; // $NON-NLS-1$ private final static String SHOW_TREE_PROPERTY = "hideOrShowTreeAction"; // $NON-NLS-1$ // UI objects private SashForm sash; private TreeViewer treeViewer; private TextViewer textViewer; private Action copyAction; private Action selectAllAction; private Action clearOutputAction; private Action findAction; private Action expandTreeItemAction; private Action showTreeAction; private Action showSelectedItemAction; private LogTreeLabelProvider labelprovider; private LogTreeContentProvider contentProvider; // lastWidth is used to store the width of the tree that the user set private int lastTreeWidth = 30; private boolean showOnlySelectedItems = false; private boolean showTree = false; /** * Constructor for AntConsole */ public LogConsoleView() { super(); LogConsoleDocument.getInstance().registerView(this); labelprovider = new LogTreeLabelProvider(this); contentProvider = new LogTreeContentProvider(this); } /** * @see IViewPart */ public void init(IViewSite site, IMemento memento) throws PartInitException { super.init(site, memento); if (memento != null) { // retrieve the values of the previous session lastTreeWidth = memento.getInteger(TREE_WIDTH_PROPERTY).intValue(); showOnlySelectedItems = memento.getInteger(SHOW_ONLY_SELECTED_ITEM_PROPERTY).intValue() != 0; showTree = memento.getInteger(SHOW_TREE_PROPERTY).intValue() != 0; } } protected void addContributions() { // In order for the clipboard actions to be accessible via their shortcuts // (e.g., Ctrl-C, Ctrl-V), we *must* set a global action handler for // each action IActionBars actionBars = getViewSite().getActionBars(); actionBars.setGlobalActionHandler(ITextEditorActionConstants.COPY, copyAction); actionBars.setGlobalActionHandler(ITextEditorActionConstants.FIND, findAction); actionBars.setGlobalActionHandler(ITextEditorActionConstants.SELECT_ALL, selectAllAction); MenuManager textViewerMgr = new MenuManager(); textViewerMgr.setRemoveAllWhenShown(true); textViewerMgr.addMenuListener(new IMenuListener() { public void menuAboutToShow(IMenuManager textViewerMgr) { fillTextViewerContextMenu(textViewerMgr); } }); Menu textViewerMenu = textViewerMgr.createContextMenu(textViewer.getControl()); textViewer.getControl().setMenu(textViewerMenu); MenuManager treeViewerMgr = new MenuManager(); treeViewerMgr.setRemoveAllWhenShown(true); treeViewerMgr.addMenuListener(new IMenuListener() { public void menuAboutToShow(IMenuManager treeViewerMgr) { fillTreeViewerContextMenu(treeViewerMgr); } }); Menu treeViewerMenu = treeViewerMgr.createContextMenu(treeViewer.getControl()); treeViewer.getControl().setMenu(treeViewerMenu); //add toolbar actions IToolBarManager tbm = getViewSite().getActionBars().getToolBarManager(); tbm.add(showTreeAction); tbm.add(showSelectedItemAction); tbm.add(clearOutputAction); getViewSite().getActionBars().updateActionBars(); } private void createHideOrShowTreeAction() { showTreeAction = new Action() { public void run() { showTree = isChecked(); if (showTree) { // the tree is hidden, let's show it sash.SASH_WIDTH = SASH_WIDTH; sash.setWeights(new int[] { lastTreeWidth, 100 - lastTreeWidth }); setToolTipText(ToolMessages.getString("LogConsoleView.hideOutputStructureTree")); // $NON-NLS-1$ // the "ShowOnlySelectedElement" functionality can be turned on showSelectedItemAction.setEnabled(true); showSelectedItemAction.setChecked(showOnlySelectedItems); showSelectedItemAction.run(); } else { // let's hide the tree sash.SASH_WIDTH = 0; sash.setWeights(new int[] { 0, 100 }); setToolTipText(ToolMessages.getString("LogConsoleView.showOutputStructureTree")); // $NON-NLS-1$ // show the whole document showCompleteOutput(); // disable the show selected item action showSelectedItemAction.setEnabled(false); } } }; showTreeAction.setImageDescriptor(getImageDescriptor("icons/full/clcl16/hide_show_tree.gif")); // $NON-NLS-1$ showTreeAction.setChecked(showTree); showTreeAction.setText(ToolMessages.getString("LogConsoleView.showTree")); // $NON-NLS-1$ String tooltip = showTree ? "LogConsoleView.hideOutputStructureTree" : "LogConsoleView.showOutputStructureTree"; // $NON-NLS-1$ showTreeAction.setToolTipText(ToolMessages.getString(tooltip)); } private boolean isTreeHidden() { return sash.getWeights()[0] == 0; } public void append(String value) { append(value, LogConsoleDocument.MSG_INFO); } public void append(final String value, final int ouputLevel) { getViewSite().getShell().getDisplay().syncExec(new Runnable() { public void run() { if (value.length() > 0 && textViewer != null) { revealEndOfDocument(); // XXX If this is not done, then the colors don't appear --> bug of #setVisibleRegion ? // See "1GHQC7Q: ITPUI:WIN2000 - TextViewer#setVisibleRegion doesn't take into account the colors" textViewer.getTextWidget().setStyleRanges((StyleRange[]) getStyleRanges().toArray(new StyleRange[getStyleRanges().size()])); } } }); } private void setOutputLevelColor(int level, int start, int end) { LogConsoleDocument.getInstance().setOutputLevelColor(level, start, end); } protected void copySelectionToClipboard() { textViewer.doOperation(ITextOperationTarget.COPY); } /** * Creates the actions that will appear in this view's toolbar and popup menus. */ protected void createActions() { // Create the actions for the text viewer. copyAction = new Action(ToolMessages.getString("LogConsoleView.copy")) { // $NON-NLS-1$ public void run() { copySelectionToClipboard(); } }; selectAllAction = new Action(ToolMessages.getString("LogConsoleView.selectAll")) { // $NON-NLS-1$ public void run() { selectAllText(); } }; clearOutputAction = new Action(ToolMessages.getString("LogConsoleView.clearOutput")) {// $NON-NLS-1$ public void run() { LogConsoleDocument.getInstance().clearOutput(); } }; clearOutputAction.setImageDescriptor(getImageDescriptor("icons/full/clcl16/clear.gif")); // $NON-NLS-1$ clearOutputAction.setToolTipText(ToolMessages.getString("LogConsoleView.clearOutput")); // $NON-NLS-1$ findAction = new FindReplaceAction(ToolMessages.getResourceBundle(), PROPERTY_PREFIX_FIND, this); findAction.setEnabled(true); // Create the actions for the tree viewer. createHideOrShowTreeAction(); expandTreeItemAction = new Action(ToolMessages.getString("LogConsoleView.expandAll")) {// $NON-NLS-1$ public void run() { OutputStructureElement selectedElement = (OutputStructureElement) ((IStructuredSelection) treeViewer.getSelection()).getFirstElement(); treeViewer.expandToLevel(selectedElement, AbstractTreeViewer.ALL_LEVELS); } }; //create the toolbar actions showSelectedItemAction = new Action() { public void run() { showOnlySelectedItems = isChecked(); if (showOnlySelectedItems) { // we want to show only the selected tree items showSelectedElementOnly(); // changes the labels setToolTipText(ToolMessages.getString("LogConsoleView.showCompleteOutput")); // $NON-NLS-1$ } else { // we want to show the whole document now showCompleteOutput(); // changes the labels setToolTipText(ToolMessages.getString("LogConsoleView.showSelectedElementOnly")); // $NON-NLS-1$ } } }; showSelectedItemAction.setImageDescriptor(getImageDescriptor("icons/full/clcl16/show_selected_text.gif")); // $NON-NLS-1$ showSelectedItemAction.setChecked(showOnlySelectedItems); showSelectedItemAction.setEnabled(showTreeAction.isChecked()); showSelectedItemAction.setText(ToolMessages.getString("LogConsoleView.showSelectedElementOnly")); // $NON-NLS-1$ String tooltip = showOnlySelectedItems ? "LogConsoleView.showCompleteOutput" : "LogConsoleView.showSelectedElementOnly"; // $NON-NLS-1$ showSelectedItemAction.setToolTipText(ToolMessages.getString(tooltip)); } /* * Shows the output of the selected item only */ protected void showSelectedElementOnly() { IStructuredSelection selection = (IStructuredSelection) treeViewer.getSelection(); if (selection.isEmpty()) textViewer.setVisibleRegion(0, 0); else { OutputStructureElement selectedElement = (OutputStructureElement) selection.getFirstElement(); // XXX NOTE: #setVisibleRegion doesn't keep the color information... See "1GHQC7Q: ITPUI:WIN2000 - TextViewer#setVisibleRegion doesn't take into account the colors" textViewer.setVisibleRegion(selectedElement.getStartIndex(), selectedElement.getLength()); } } /* * Shows the output of the whole docuent, and reveals the range of the selected item */ protected void showCompleteOutput() { // show all the document textViewer.setVisibleRegion(0, getDocument().get().length()); // XXX should I have to do that? If this is not done, then the colors don't appear --> bug of #setVisibleRegion ? --> See "1GHQC7Q: ITPUI:WIN2000 - TextViewer#setVisibleRegion doesn't take into account the colors" textViewer.getTextWidget().setStyleRanges((StyleRange[]) getStyleRanges().toArray(new StyleRange[getStyleRanges().size()])); // and then reveal the range of the selected item revealRangeOfSelectedItem(); } private void revealRangeOfSelectedItem() { IStructuredSelection selection = (IStructuredSelection) treeViewer.getSelection(); if (!selection.isEmpty()) { // then show the reveal the range of the output accordingly OutputStructureElement selectedElement = (OutputStructureElement) selection.getFirstElement(); textViewer.revealRange(selectedElement.getStartIndex(), selectedElement.getLength()); textViewer.setSelectedRange(selectedElement.getStartIndex(), selectedElement.getLength()); } } private void revealEndOfDocument() { IDocument doc= getDocument(); int docLength= doc.getLength(); if (docLength > 0) { StyledText widget= textViewer.getTextWidget(); widget.setCaretOffset(docLength); widget.showSelection(); } } public void initializeTreeInput() { getSite().getShell().getDisplay().syncExec(new Runnable() { public void run() { if (treeViewer != null) treeViewer.setInput(LogConsoleDocument.getInstance().getRoot()); } }); } public void refreshTree() { // if the tree is null, it means that the view hasn't been shown yet, so we don't need to refresh it. if (treeViewer != null) { getSite().getShell().getDisplay().syncExec(new Runnable() { public void run() { treeViewer.refresh(); treeViewer.expandAll(); } }); } } public void updateFont() { if (textViewer != null) textViewer.getTextWidget().setFont(LogConsoleDocument.ANT_FONT); } protected void fillTextViewerContextMenu(IMenuManager manager) { copyAction.setEnabled(textViewer.canDoOperation(ITextOperationTarget.COPY)); selectAllAction.setEnabled(textViewer.canDoOperation(ITextOperationTarget.SELECT_ALL)); manager.add(copyAction); manager.add(findAction); manager.add(selectAllAction); manager.add(new Separator()); manager.add(showTreeAction); manager.add(clearOutputAction); } protected void fillTreeViewerContextMenu(IMenuManager manager) { manager.add(showSelectedItemAction); manager.add(expandTreeItemAction); manager.add(new Separator()); manager.add(showTreeAction); manager.add(clearOutputAction); } public Object getAdapter(Class required) { if (IFindReplaceTarget.class.equals(required)) return textViewer.getFindReplaceTarget(); return super.getAdapter(required); } private Document getDocument() { return LogConsoleDocument.getInstance().getDocument(); } private ArrayList getStyleRanges() { return LogConsoleDocument.getInstance().getStyleRanges(); } public TextViewer getTextViewer() { return textViewer; } public TreeViewer getTreeViewer() { return treeViewer; } protected ImageDescriptor getImageDescriptor(String relativePath) { try { URL installURL = ExternalToolsPlugin.getDefault().getDescriptor().getInstallURL(); URL url = new URL(installURL, relativePath); return ImageDescriptor.createFromURL(url); } catch (MalformedURLException e) { return null; } } protected void selectAllText() { textViewer.doOperation(ITextOperationTarget.SELECT_ALL); } /** * @see WorkbenchPart#setFocus() */ public void setFocus() { sash.setFocus(); } /** * @see WorkbenchPart#createPartControl(Composite) */ public void createPartControl(Composite parent) { sash = new SashForm(parent, SWT.HORIZONTAL); GridLayout sashLayout = new GridLayout(); sashLayout.marginHeight = 0; sashLayout.marginWidth = 0; sash.setLayout(sashLayout); sash.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_FILL | GridData.HORIZONTAL_ALIGN_FILL)); treeViewer = new TreeViewer(sash, SWT.V_SCROLL | SWT.H_SCROLL); GridData treeData = new GridData(GridData.FILL_BOTH); treeViewer.getControl().setLayoutData(treeData); treeViewer.setContentProvider(contentProvider); treeViewer.setLabelProvider(labelprovider); treeViewer.setInput(LogConsoleDocument.getInstance().getRoot()); treeViewer.expandAll(); addTreeViewerListeners(); textViewer = new TextViewer(sash, SWT.WRAP | SWT.V_SCROLL | SWT.H_SCROLL); GridData viewerData = new GridData(GridData.FILL_BOTH); textViewer.getControl().setLayoutData(viewerData); textViewer.setEditable(false); textViewer.setDocument(getDocument()); textViewer.getTextWidget().setFont(LogConsoleDocument.ANT_FONT); textViewer.getTextWidget().setStyleRanges((StyleRange[]) getStyleRanges().toArray(new StyleRange[getStyleRanges().size()])); addTextViewerListeners(); // sets the ratio tree/textViewer for the sashForm if (showTree) { sash.setWeights(new int[] { lastTreeWidth, 100 - lastTreeWidth }); } else { // the "hideOrShowTree" action wasn't checked: this means that the user didn't want to have the tree sash.SASH_WIDTH = 0; sash.setWeights(new int[] { 0, 100 }); } createActions(); addContributions(); // WorkbenchHelp.setHelp(parent, IHelpContextIds.LOG_CONSOLE_VIEW); } protected void addTreeViewerListeners() { treeViewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent e) { if (textViewer != null) if (showSelectedItemAction.isChecked()) showSelectedElementOnly(); else revealRangeOfSelectedItem(); } }); // to remember the place of the sash when we hide the tree treeViewer.getControl().addControlListener(new ControlAdapter() { public void controlResized(ControlEvent e) { if (treeViewer.getControl().getSize().x != 0) // we don't want the width to be stored when the tree is getting hidden // (because it equals zero and we want to have the previous value) lastTreeWidth = new Float((float) treeViewer.getControl().getSize().x / sash.getSize().x * 100).intValue(); } }); } protected void addTextViewerListeners() { textViewer.getTextWidget().addMouseListener(new MouseAdapter() { public void mouseDown(MouseEvent e) { if (!showSelectedItemAction.isChecked()) selectTreeItem(textViewer.getTextWidget().getCaretOffset()); } }); textViewer.getTextWidget().addKeyListener(new KeyAdapter() { public void keyReleased(KeyEvent e) { if (!showSelectedItemAction.isChecked()) selectTreeItem(textViewer.getTextWidget().getCaretOffset()); } }); } protected void selectTreeItem(int caretPosition) { // tree.getTree().getItems()[1] returns the root of the tree that contains the project // it may not exist if there is no output (in this case, there is only one item: the "External Tool" one) if (treeViewer.getTree().getItems().length != 1) { TreeItem itemToSelect = null; if (findItem(treeViewer.getTree().getItems()[0], caretPosition) != null) // the first item is the good one itemToSelect = treeViewer.getTree().getItems()[0]; else // the first item is not the good one, let's check the second one and its children itemToSelect = findItem(treeViewer.getTree().getItems()[1], caretPosition); treeViewer.getTree().setSelection(new TreeItem[] { itemToSelect }); } } private TreeItem findItem(TreeItem item, int position) { if (!(((OutputStructureElement) item.getData()).getStartIndex() <= position && ((OutputStructureElement) item.getData()).getEndIndex() > position)) return null; for (int i = 0; i < item.getItems().length; i++) { TreeItem child = findItem(item.getItems()[i], position); if (child != null) return child; } return item; } /** * @see IViewPart */ public void saveState(IMemento memento) { memento.putInteger(TREE_WIDTH_PROPERTY, lastTreeWidth); // it is not possible to put a boolean in a memento, so we use integers memento.putInteger(SHOW_ONLY_SELECTED_ITEM_PROPERTY, showOnlySelectedItems ? 1 : 0); memento.putInteger(SHOW_TREE_PROPERTY, showTree ? 1 : 0); } public void dispose() { LogConsoleDocument.getInstance().unregisterView(this); super.dispose(); } } \ No newline at end of file
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/LogTreeContentProvider.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/LogTreeContentProvider.java
deleted file mode 100644
index 5d3a51be9..000000000
--- a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/LogTreeContentProvider.java
+++ /dev/null
@@ -1,67 +0,0 @@
-package org.eclipse.ui.externaltools.internal.ui;
-
-/**********************************************************************
-Copyright (c) 2002 IBM Corp. and others.
-All rights reserved.   This program and the accompanying materials
-are made available under the terms of the Common Public License v0.5
-which accompanies this distribution, and is available at
-http://www.eclipse.org/legal/cpl-v05.html
-Contributors:
-**********************************************************************/
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.Viewer;
-
-/**
- * Content provider for the tree viewer of the Ant Console.
- */
-
-public class LogTreeContentProvider implements ITreeContentProvider {
-
- private LogConsoleView console;
-
- public LogTreeContentProvider(LogConsoleView console) {
- this.console = console;
- }
-
- /**
- * @see ITreeContentProvider#getChildren(Object)
- */
- public Object[] getChildren(Object parent) {
- return ((OutputStructureElement) parent).getChildren();
- }
-
- /**
- * @see ITreeContentProvider#getParent(Object)
- */
- public Object getParent(Object element) {
- return ((OutputStructureElement) element).getParent();
- }
-
- /**
- * @see ITreeContentProvider#hasChildren(Object)
- */
- public boolean hasChildren(Object element) {
- return ((OutputStructureElement) element).hasChildren();
- }
-
- /**
- * @see IStructuredContentProvider#getElements(Object)
- */
- public Object[] getElements(Object parent) {
- return ((OutputStructureElement) parent).getChildren();
- }
-
- /**
- * @see IContentProvider#dispose()
- */
- public void dispose() {
- }
-
- /**
- * @see IContentProvider#inputChanged(Viewer, Object, Object)
- */
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- }
-
-} \ No newline at end of file
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/LogTreeLabelProvider.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/LogTreeLabelProvider.java
deleted file mode 100644
index 2ec6bd080..000000000
--- a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/LogTreeLabelProvider.java
+++ /dev/null
@@ -1,72 +0,0 @@
-package org.eclipse.ui.externaltools.internal.ui;
-
-/**********************************************************************
-Copyright (c) 2002 IBM Corp. and others.
-All rights reserved.   This program and the accompanying materials
-are made available under the terms of the Common Public License v0.5
-which accompanies this distribution, and is available at
-http://www.eclipse.org/legal/cpl-v05.html
-Contributors:
-**********************************************************************/
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.ILabelProviderListener;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.ui.externaltools.internal.model.ToolMessages;
-
-/**
- * Label provider for the tree viewer of the Log Console.
- */
-public class LogTreeLabelProvider implements ILabelProvider {
-
- private LogConsoleView console;
-
- public LogTreeLabelProvider(LogConsoleView console) {
- this.console = console;
- }
-
- /**
- * @see ILabelProvider#getImage(Object)
- */
- public Image getImage(Object element) {
- return null;
- }
-
- /**
- * @see ILabelProvider#getText(Object)
- */
- public String getText(Object element) {
- String text = ((OutputStructureElement) element).getName();
- if (text == null)
- // this can happen if the user writes a task name that doesn't exist => the #taskStarted will be triggered
- // but null will be given as a name to the current task, and then only, the exception will be raised
- return ToolMessages.getString("LogTreeLabelProvider.invalidItemName"); // $NON-NLS-1$
- return text;
- }
-
- /**
- * @see IBaseLabelProvider#addListener(ILabelProviderListener)
- */
- public void addListener(ILabelProviderListener listener) {
- }
-
- /**
- * @see IBaseLabelProvider#dispose()
- */
- public void dispose() {
- }
-
- /**
- * @see IBaseLabelProvider#isLabelProperty(Object, String)
- */
- public boolean isLabelProperty(Object arg0, String arg1) {
- return false;
- }
-
- /**
- * @see IBaseLabelProvider#removeListener(ILabelProviderListener)
- */
- public void removeListener(ILabelProviderListener listener) {
- }
-
-} \ No newline at end of file
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/OutputStructureElement.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/OutputStructureElement.java
deleted file mode 100644
index 76b53979f..000000000
--- a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/OutputStructureElement.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/**********************************************************************
- * Copyright (c) 2002 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
- *
- * Contributors:
- * IBM - Initial API and implementation
- **********************************************************************/
-package org.eclipse.ui.externaltools.internal.ui;
-
-import java.util.ArrayList;
-
-/**
- * Object which stores the index and the length of the output for a given
- * target or task (represented by a string)
- */
-
-public class OutputStructureElement {
-
- private OutputStructureElement parent = null;
- private ArrayList children;
- private String name;
- private int startIndex = 0;
- private int length = 0;
-
-
-/**
- * This constructor is intended to be used only by the first element of the structure (the root element)
- */
-public OutputStructureElement(String name) {
- // there's at least one target as it is the root which may be instantiated via this constructor
- children = new ArrayList(1);
- this.name = name;
-}
-
-/**
- * This constructor is used for any element but the first element of the structure (the root element)
- */
-public OutputStructureElement(String name, OutputStructureElement parent, int startIndex) {
- children = new ArrayList(0);
- this.name = name;
- this.startIndex = startIndex;
- parent.addChild(this);
-}
-
-public void addChild(OutputStructureElement child) {
- children.add(child);
- child.setParent(this);
-}
-
-public boolean hasChildren() {
- return !children.isEmpty();
-}
-
-public String getName() {
- return name;
-}
-
-public void setName(String name) {
- this.name = name;
-}
-
-public void setParent(OutputStructureElement parent) {
- this.parent = parent;
-}
-
-public OutputStructureElement getParent() {
- return parent;
-}
-
-public OutputStructureElement[] getChildren() {
- return (OutputStructureElement[]) children.toArray(new OutputStructureElement[children.size()]);
-}
-
-public void setStartIndex(int index) {
- startIndex = index;
-}
-
-public void setEndIndex(int index) {
- length = index - startIndex;
-}
-
-public int getStartIndex() {
- return startIndex;
-}
-
-public int getEndIndex() {
- return startIndex + length;
-}
-
-public int getLength() {
- return length;
-}
-
-public String toString() {
- return name;
-}
-
-}
-
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/WorkInProgressPreferencePage.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/WorkInProgressPreferencePage.java
deleted file mode 100644
index 959e5dbc9..000000000
--- a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/WorkInProgressPreferencePage.java
+++ /dev/null
@@ -1,55 +0,0 @@
-package org.eclipse.ui.externaltools.internal.ui;
-
-/**********************************************************************
-Copyright (c) 2002 IBM Corp. and others. All rights reserved.
-This file is made available under the terms of the Common Public License v1.0
-which accompanies this distribution, and is available at
-http://www.eclipse.org/legal/cpl-v10.html
-Contributors:
-**********************************************************************/
-
-import org.eclipse.debug.internal.ui.preferences.BooleanFieldEditor2;
-import org.eclipse.jface.preference.FieldEditorPreferencePage;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchPreferencePage;
-import org.eclipse.ui.externaltools.internal.model.ExternalToolsPlugin;
-import org.eclipse.ui.externaltools.internal.model.IPreferenceConstants;
-
-/**
- * Temporary "work-in-progress" page to be removed before 2.1 release
- */
-public class WorkInProgressPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {
-
- private BooleanFieldEditor2 fUseConfigs = null;
-
- /**
- */
- public WorkInProgressPreferencePage() {
- super(GRID);
- setPreferenceStore(ExternalToolsPlugin.getDefault().getPreferenceStore());
- }
-
- /**
- * @see org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors()
- */
- protected void createFieldEditors() {
- fUseConfigs = new BooleanFieldEditor2(IPreferenceConstants.LAUNCH_CONFIG_MODE, "Use Launch Configurations", getFieldEditorParent()); //$NON-NLS-1$
- addField(fUseConfigs);
- }
-
- /**
- * @see org.eclipse.jface.preference.PreferencePage#performDefaults()
- */
- protected void performDefaults() {
- super.performDefaults();
- fUseConfigs.getChangeControl(getFieldEditorParent()).setSelection(false);
- }
-
- /**
- * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
- */
- public void init(IWorkbench workbench) {
- }
-
-}
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/view/DeleteExternalToolAction.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/view/DeleteExternalToolAction.java
deleted file mode 100644
index 4e86bcd2f..000000000
--- a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/view/DeleteExternalToolAction.java
+++ /dev/null
@@ -1,78 +0,0 @@
-package org.eclipse.ui.externaltools.internal.view;
-
-/**********************************************************************
-Copyright (c) 2002 IBM Corp. and others. All rights reserved.
-This file is made available under the terms of the Common Public License v1.0
-which accompanies this distribution, and is available at
-http://www.eclipse.org/legal/cpl-v10.html
-Contributors:
-**********************************************************************/
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.externaltools.internal.model.ExternalToolsPlugin;
-import org.eclipse.ui.externaltools.internal.model.IHelpContextIds;
-import org.eclipse.ui.externaltools.internal.model.ToolMessages;
-import org.eclipse.ui.externaltools.model.ExternalTool;
-import org.eclipse.ui.externaltools.model.ExternalToolStorage;
-import org.eclipse.ui.help.WorkbenchHelp;
-
-/**
- * Action that will delete the currently selected
- * external tool in the view.
- */
-public class DeleteExternalToolAction extends Action {
- private IWorkbenchPage page;
- private ExternalTool selectedTool;
-
- /**
- * Create an action to delete the selected external tool
- */
- public DeleteExternalToolAction(IWorkbenchPage page) {
- super();
- this.page = page;
- setText(ToolMessages.getString("DeleteExternalToolAction.text")); //$NON-NLS-1$
- setToolTipText(ToolMessages.getString("DeleteExternalToolAction.toolTip")); //$NON-NLS-1$
- setHoverImageDescriptor(ExternalToolsPlugin.getDefault().getImageDescriptor("icons/full/clcl16/del_tool.gif")); //$NON-NLS-1$
- setImageDescriptor(ExternalToolsPlugin.getDefault().getImageDescriptor("icons/full/elcl16/del_tool.gif")); //$NON-NLS-1$
- setDisabledImageDescriptor(ExternalToolsPlugin.getDefault().getImageDescriptor("icons/full/dlcl16/del_tool.gif")); //$NON-NLS-1$
- WorkbenchHelp.setHelp(this, IHelpContextIds.DELETE_TOOL_ACTION);
- }
-
- /**
- * Returns the selected external tool.
- */
- public ExternalTool getSelectedTool() {
- return selectedTool;
- }
-
- /* (non-Javadoc)
- * Method declared on Action.
- */
- public void run() {
- if (selectedTool == null)
- return;
-
- // Get user confirmation first
- Shell shell = page.getWorkbenchWindow().getShell();
- String title = ToolMessages.getString("DeleteExternalToolAction.confirmToolDeleteTitle"); //$NON-NLS-1$
- String msg = ToolMessages.format("DeleteExternalToolAction.confirmToolDeleteMsg", new Object[] {selectedTool.getName()}); //$NON-NLS-1$
- boolean deleteOk = MessageDialog.openQuestion(shell, title, msg);
- if (!deleteOk)
- return;
-
- // Delete the external tool
- ExternalToolStorage.deleteTool(selectedTool, shell);
- }
-
- /**
- * Sets the selected external tool.
- */
- public void setSelectedTool(ExternalTool tool) {
- selectedTool = tool;
- setEnabled(tool != null);
- }
-}
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/view/DuplicateExternalToolAction.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/view/DuplicateExternalToolAction.java
deleted file mode 100644
index c62ca5cc3..000000000
--- a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/view/DuplicateExternalToolAction.java
+++ /dev/null
@@ -1,63 +0,0 @@
-package org.eclipse.ui.externaltools.internal.view;
-
-/**********************************************************************
-Copyright (c) 2002 IBM Corp. and others. All rights reserved.
-This file is made available under the terms of the Common Public License v1.0
-which accompanies this distribution, and is available at
-http://www.eclipse.org/legal/cpl-v10.html
-Contributors:
-**********************************************************************/
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.externaltools.internal.model.ExternalToolsPlugin;
-import org.eclipse.ui.externaltools.internal.model.IHelpContextIds;
-import org.eclipse.ui.externaltools.model.ExternalTool;
-import org.eclipse.ui.help.WorkbenchHelp;
-
-/**
- * Action that will duplicate the currently selected
- * external tool.
- */
-public class DuplicateExternalToolAction extends Action {
- private IWorkbenchPage page;
- private ExternalTool selectedTool;
-
- /**
- * Create an action to copy the selected external
- * tool to the clipboard
- */
- public DuplicateExternalToolAction(IWorkbenchPage page) {
- super();
- this.page = page;
- setText("Duplicate");
- setToolTipText("Duplicate the selected tool");
- setHoverImageDescriptor(ExternalToolsPlugin.getDefault().getImageDescriptor("icons/full/clcl16/copy_tool.gif")); //$NON-NLS-1$
- setImageDescriptor(ExternalToolsPlugin.getDefault().getImageDescriptor("icons/full/elcl16/copy_tool.gif")); //$NON-NLS-1$
- setDisabledImageDescriptor(ExternalToolsPlugin.getDefault().getImageDescriptor("icons/full/dlcl16/copy_tool.gif")); //$NON-NLS-1$
- WorkbenchHelp.setHelp(this, IHelpContextIds.DUPLICATE_TOOL_ACTION);
- }
-
- /**
- * Returns the selected external tool.
- */
- public ExternalTool getSelectedTool() {
- return selectedTool;
- }
-
- /* (non-Javadoc)
- * Method declared on Action.
- */
- public void run() {
- org.eclipse.jface.dialogs.MessageDialog.openInformation(page.getWorkbenchWindow().getShell(), "Action", "This action is not yet implemented");
- }
-
- /**
- * Sets the selected external tool.
- */
- public void setSelectedTool(ExternalTool tool) {
- selectedTool = tool;
- setEnabled(tool != null);
- }
-}
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/view/EditExternalToolPropertiesAction.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/view/EditExternalToolPropertiesAction.java
deleted file mode 100644
index cf1b02791..000000000
--- a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/view/EditExternalToolPropertiesAction.java
+++ /dev/null
@@ -1,64 +0,0 @@
-package org.eclipse.ui.externaltools.internal.view;
-
-/**********************************************************************
-Copyright (c) 2002 IBM Corp. and others. All rights reserved.
-This file is made available under the terms of the Common Public License v1.0
-which accompanies this distribution, and is available at
-http://www.eclipse.org/legal/cpl-v10.html
-Contributors:
-**********************************************************************/
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.ui.dialogs.PropertyDialogAction;
-import org.eclipse.ui.externaltools.internal.model.ExternalToolsPlugin;
-import org.eclipse.ui.externaltools.internal.model.IHelpContextIds;
-import org.eclipse.ui.externaltools.internal.model.ToolMessages;
-import org.eclipse.ui.externaltools.model.ExternalTool;
-import org.eclipse.ui.help.WorkbenchHelp;
-
-/**
- * Action that will open a properties dialog to edit
- * the selected external tool.
- */
-public class EditExternalToolPropertiesAction extends Action {
- private ExternalTool selectedTool;
- private PropertyDialogAction propAction;
-
- /**
- * Create an action to edit the selected external tool.
- */
- public EditExternalToolPropertiesAction(ExternalToolView view) {
- super();
- setText(ToolMessages.getString("EditExternalToolPropertiesAction.text")); //$NON-NLS-1$
- setToolTipText(ToolMessages.getString("EditExternalToolPropertiesAction.toolTip")); //$NON-NLS-1$
- setHoverImageDescriptor(ExternalToolsPlugin.getDefault().getImageDescriptor("icons/full/clcl16/prop_tool.gif")); //$NON-NLS-1$
- setImageDescriptor(ExternalToolsPlugin.getDefault().getImageDescriptor("icons/full/elcl16/prop_tool.gif")); //$NON-NLS-1$
- setDisabledImageDescriptor(ExternalToolsPlugin.getDefault().getImageDescriptor("icons/full/dlcl16/prop_tool.gif")); //$NON-NLS-1$
- WorkbenchHelp.setHelp(this, IHelpContextIds.EDIT_TOOL_PROPERTIES_ACTION);
- propAction = new PropertyDialogAction(view.getSite().getShell(), view.getTreeViewer());
- }
-
- /**
- * Returns the selected external tool.
- */
- public ExternalTool getSelectedTool() {
- return selectedTool;
- }
-
- /* (non-Javadoc)
- * Method declared on Action.
- */
- public void run() {
- if (propAction.isEnabled())
- propAction.run();
- }
-
- /**
- * Sets the selected external tool.
- */
- public void setSelectedTool(ExternalTool tool) {
- selectedTool = tool;
- setEnabled(tool != null);
- }
-}
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/view/ExternalToolActionGroup.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/view/ExternalToolActionGroup.java
deleted file mode 100644
index fce7efaba..000000000
--- a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/view/ExternalToolActionGroup.java
+++ /dev/null
@@ -1,179 +0,0 @@
-package org.eclipse.ui.externaltools.internal.view;
-
-/**********************************************************************
-Copyright (c) 2002 IBM Corp. and others. All rights reserved.
-This file is made available under the terms of the Common Public License v1.0
-which accompanies this distribution, and is available at
-http://www.eclipse.org/legal/cpl-v10.html
-Contributors:
-**********************************************************************/
-
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.IToolBarManager;
-import org.eclipse.jface.action.Separator;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.IWorkbenchActionConstants;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.actions.ActionGroup;
-import org.eclipse.ui.actions.TextActionHandler;
-import org.eclipse.ui.externaltools.action.RunExternalToolAction;
-import org.eclipse.ui.externaltools.action.RunWithExternalToolAction;
-import org.eclipse.ui.externaltools.model.ExternalTool;
-
-/**
- * The action group for all of the external tools view actions.
- */
-public class ExternalToolActionGroup extends ActionGroup {
- private ExternalToolView view;
- private TextActionHandler textActionHandler;
- private NewExternalToolAction newAction;
- private DuplicateExternalToolAction copyAction;
- private DeleteExternalToolAction delAction;
- private RenameExternalToolAction renameAction;
- private RefreshViewAction refreshAction;
- private RunExternalToolAction runAction;
- private RunWithExternalToolAction runWithAction;
- private EditExternalToolPropertiesAction editAction;
-
- public ExternalToolActionGroup(ExternalToolView view) {
- super();
- this.view = view;
- makeActions();
- }
-
- /* (non-Javadoc)
- * Method declared on ActionGroup.
- */
- public void fillActionBars(IActionBars actionBars) {
- IToolBarManager toolBar = actionBars.getToolBarManager();
- toolBar.add(runAction);
- toolBar.add(newAction);
- toolBar.add(delAction);
- toolBar.add(refreshAction);
-
- textActionHandler = new TextActionHandler(actionBars); // hooks handlers
- textActionHandler.setCopyAction(copyAction);
- textActionHandler.setDeleteAction(delAction);
- renameAction.setTextActionHandler(textActionHandler);
-
- actionBars.setGlobalActionHandler(
- IWorkbenchActionConstants.REFRESH,
- refreshAction);
- actionBars.setGlobalActionHandler(
- IWorkbenchActionConstants.RENAME,
- renameAction);
- actionBars.setGlobalActionHandler(
- IWorkbenchActionConstants.PROPERTIES,
- editAction);
- }
-
- /* (non-Javadoc)
- * Method declared on ActionGroup.
- */
- public void fillContextMenu(IMenuManager menu) {
- updateActionEnablement();
-
- menu.add(newAction);
- menu.add(new Separator());
-
- menu.add(copyAction);
- menu.add(delAction);
- menu.add(renameAction);
- menu.add(new Separator());
-
- menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
- menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS + "-end")); //$NON-NLS-1$
- menu.add(new Separator());
-
- menu.add(refreshAction);
- menu.add(new Separator());
-
- menu.add(runAction);
- menu.add(runWithAction);
- menu.add(new Separator());
-
- menu.add(editAction);
- }
-
- /**
- * Returns the external tool if found in the selection,
- * or <code>null</code> if none.
- */
- private ExternalTool getSelectedTool(IStructuredSelection selection) {
- Object element = selection.getFirstElement();
- if (element instanceof ExternalTool)
- return (ExternalTool)element;
- return null;
- }
-
- /**
- * Handles a key pressed event by invoking the appropriate action.
- */
- public void handleKeyPressed(KeyEvent event) {
- if (event.character == SWT.DEL && event.stateMask == 0) {
- delAction.run();
- return;
- }
-
- if (event.keyCode == SWT.F2 && event.stateMask == 0) {
- renameAction.run();
- return;
- }
-
- if (event.keyCode == SWT.F5 && event.stateMask == 0) {
- refreshAction.run();
- return;
- }
- }
-
- /**
- * Runs the default action by invoking the appropriate action
- */
- public void runDefaultAction(IStructuredSelection selection) {
- ExternalTool tool = getSelectedTool(selection);
- runAction.setTool(tool);
- runAction.run();
- }
-
- /**
- * Create the actions contained in this group.
- */
- protected void makeActions() {
- IWorkbenchPage page = view.getSite().getPage();
- newAction = new NewExternalToolAction();
- copyAction = new DuplicateExternalToolAction(page);
- delAction = new DeleteExternalToolAction(page);
- renameAction = new RenameExternalToolAction(view);
- refreshAction = new RefreshViewAction(page);
- runAction = new RunExternalToolAction(page.getWorkbenchWindow());
- runWithAction = new RunWithExternalToolAction(page.getWorkbenchWindow());
- editAction = new EditExternalToolPropertiesAction(view);
- }
-
- /* (non-Javadoc)
- * Method declared on ActionGroup.
- */
- public void updateActionBars() {
- updateActionEnablement();
- }
-
- /**
- * Updates the enabled state of the group's actions
- * based on the current context selection
- */
- private void updateActionEnablement() {
- ExternalTool selectedTool = getSelectedTool(
- (IStructuredSelection) getContext().getSelection());
-
- copyAction.setSelectedTool(selectedTool);
- delAction.setSelectedTool(selectedTool);
- renameAction.setSelectedTool(selectedTool);
- runAction.setTool(selectedTool);
- runWithAction.setTool(selectedTool);
- editAction.setSelectedTool(selectedTool);
- }
-}
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/view/ExternalToolContentProvider.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/view/ExternalToolContentProvider.java
deleted file mode 100644
index 0cde730e2..000000000
--- a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/view/ExternalToolContentProvider.java
+++ /dev/null
@@ -1,178 +0,0 @@
-package org.eclipse.ui.externaltools.internal.view;
-
-/**********************************************************************
-Copyright (c) 2002 IBM Corp. and others. All rights reserved.
-This file is made available under the terms of the Common Public License v1.0
-which accompanies this distribution, and is available at
-http://www.eclipse.org/legal/cpl-v10.html
-Contributors:
-**********************************************************************/
-
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.externaltools.internal.model.ExternalToolsPlugin;
-import org.eclipse.ui.externaltools.internal.registry.ExternalToolRegistry;
-import org.eclipse.ui.externaltools.internal.registry.ExternalToolType;
-import org.eclipse.ui.externaltools.internal.registry.ExternalToolTypeRegistry;
-import org.eclipse.ui.externaltools.model.ExternalTool;
-import org.eclipse.ui.externaltools.model.ExternalToolStorage;
-import org.eclipse.ui.externaltools.model.IStorageListener;
-
-/**
- * Provides the external tools and types as content.
- */
-public class ExternalToolContentProvider implements ITreeContentProvider {
- private static final Object[] EMPTY_LIST = new Object[0];
-
- private ExternalToolTypeRegistry typeRegistry;
- private ExternalToolRegistry toolRegistry;
- private StorageListener listener;
-
- /**
- * Create a new external tools content provider.
- *
- * @param shell the shell to use for displaying any errors
- * when loading external tool definitions from storage.
- */
- public ExternalToolContentProvider(Shell shell) {
- super();
- typeRegistry = ExternalToolsPlugin.getDefault().getTypeRegistry();
- toolRegistry = ExternalToolsPlugin.getDefault().getToolRegistry(shell);
- listener = new StorageListener();
- listener.provider = this;
- }
-
- /* (non-Javadoc)
- * Method declared on ITreeContentProvider.
- */
- public Object[] getChildren(Object parentElement) {
- if (parentElement instanceof ExternalToolTypeRegistry) {
- return typeRegistry.getToolTypes();
- }
-
- if (parentElement instanceof ExternalToolType) {
- ExternalToolType type = (ExternalToolType) parentElement;
- return toolRegistry.getToolsOfType(type.getId());
- }
-
- return EMPTY_LIST;
- }
-
- /* (non-Javadoc)
- * Method declared on ITreeContentProvider.
- */
- public Object getParent(Object element) {
- if (element instanceof ExternalTool) {
- ExternalTool tool = (ExternalTool) element;
- return typeRegistry.getToolType(tool.getType());
- }
-
- return null;
- }
-
- /* (non-Javadoc)
- * Method declared on ITreeContentProvider.
- */
- public boolean hasChildren(Object element) {
- if (element instanceof ExternalToolTypeRegistry) {
- return typeRegistry.getTypeCount() > 0;
- }
-
- if (element instanceof ExternalToolType) {
- ExternalToolType type = (ExternalToolType) element;
- return toolRegistry.getToolCountOfType(type.getId()) > 0;
- }
-
- return false;
- }
-
- /* (non-Javadoc)
- * Method declared on IStructuredContentProvider.
- */
- public Object[] getElements(Object inputElement) {
- return getChildren(inputElement);
- }
-
- /* (non-Javadoc)
- * Method declared on IContentProvider.
- */
- public void dispose() {
- typeRegistry = null;
- toolRegistry = null;
- ExternalToolStorage.removeStorageListener(listener);
- listener.viewer = null;
- listener.provider = null;
- }
-
- /* (non-Javadoc)
- * Method declared on IContentProvider.
- */
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- if (oldInput == null && newInput != null) {
- listener.viewer = (TreeViewer)viewer;
- listener.provider = this;
- ExternalToolStorage.addStorageListener(listener);
- }
- if (oldInput != null && newInput == null) {
- ExternalToolStorage.removeStorageListener(listener);
- listener.viewer = null;
- listener.provider = null;
- }
- }
-
-
- /**
- * Internal listener for changes in the tool storage.
- */
- private static class StorageListener implements IStorageListener {
- public TreeViewer viewer = null;
- public ITreeContentProvider provider = null;
-
- public void toolDeleted(ExternalTool tool) {
- if (provider == null)
- return;
-
- Object parentElement = provider.getParent(tool);
- refresh(parentElement, false);
- }
-
- public void toolCreated(ExternalTool tool) {
- if (provider == null)
- return;
-
- Object parentElement = provider.getParent(tool);
- refresh(parentElement, false);
- }
-
- public void toolModified(ExternalTool tool) {
- if (provider == null)
- return;
-
- refresh(tool, true);
- }
-
- public void toolsRefreshed() {
- refresh(null, true);
- }
-
- private void refresh(final Object element, final boolean allLabels) {
- if (viewer == null)
- return;
- Control control = viewer.getControl();
- if (control != null && !control.isDisposed()) {
- control.getDisplay().syncExec(new Runnable() {
- public void run() {
- if (element == null)
- viewer.refresh();
- else
- viewer.refresh(element, allLabels);
- }
- });
- }
- }
- }
-}
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/view/ExternalToolLabelProvider.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/view/ExternalToolLabelProvider.java
deleted file mode 100644
index 2d55a205c..000000000
--- a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/view/ExternalToolLabelProvider.java
+++ /dev/null
@@ -1,108 +0,0 @@
-package org.eclipse.ui.externaltools.internal.view;
-
-/**********************************************************************
-Copyright (c) 2002 IBM Corp. and others. All rights reserved.
-This file is made available under the terms of the Common Public License v1.0
-which accompanies this distribution, and is available at
-http://www.eclipse.org/legal/cpl-v10.html
-Contributors:
-**********************************************************************/
-
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.Map;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.ui.ISharedImages;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.externaltools.internal.model.ExternalToolsPlugin;
-import org.eclipse.ui.externaltools.internal.registry.ExternalToolType;
-import org.eclipse.ui.externaltools.internal.registry.ExternalToolTypeRegistry;
-import org.eclipse.ui.externaltools.model.ExternalTool;
-
-/**
- * Provides the label for external tools and types.
- */
-public class ExternalToolLabelProvider extends LabelProvider {
- /**
- * The cache of images that have been dispensed by this provider.
- * Maps a tool type to an Image. These images will be
- * disposed when provider no longer needed.
- */
- private Map imageTable;
-
- /**
- * The shared workbench supplied folder image. Never disposed
- * by provider.
- */
- private Image folderImage;
-
- /**
- * Create a new external tools label provider
- */
- public ExternalToolLabelProvider() {
- super();
- folderImage = PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FOLDER);
- }
-
- /* (non-Javadoc)
- * Method declared on IBaseLabelProvider
- */
- public final void dispose() {
- // Dispose images created by this provider
- if (imageTable != null) {
- Iterator enum = imageTable.values().iterator();
- while (enum.hasNext()) {
- ((Image) enum.next()).dispose();
- }
- imageTable = null;
- }
-
- // Do not dispose this shared workbench image
- folderImage = null;
- }
-
- /* (non-Javadoc)
- * Method declared on ILabelProvider.
- */
- public Image getImage(Object element) {
- if (element instanceof ExternalToolType) {
- return folderImage;
- }
-
- if (element instanceof ExternalTool) {
- ExternalTool tool = (ExternalTool) element;
- if (imageTable == null)
- imageTable = new Hashtable(10);
- Image image = (Image) imageTable.get(tool.getType());
- if (image == null) {
- ExternalToolTypeRegistry registry = ExternalToolsPlugin.getDefault().getTypeRegistry();
- ExternalToolType type = registry.getToolType(tool.getType());
- if (type == null)
- image = ImageDescriptor.getMissingImageDescriptor().createImage();
- else
- image = type.getImageDescriptor().createImage();
- imageTable.put(tool.getType(), image);
- }
- return image;
- }
-
- return null;
- }
-
- /* (non-Javadoc)
- * Method declared on ILabelProvider.
- */
- public String getText(Object element) {
- if (element instanceof ExternalToolType)
- return ((ExternalToolType)element).getName();
-
- if (element instanceof ExternalTool)
- return ((ExternalTool)element).getName();
-
- return ""; //$NON-NLS-1$;
- }
-}
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/view/ExternalToolView.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/view/ExternalToolView.java
deleted file mode 100644
index 3312fa4ae..000000000
--- a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/view/ExternalToolView.java
+++ /dev/null
@@ -1,333 +0,0 @@
-package org.eclipse.ui.externaltools.internal.view;
-
-/**********************************************************************
-Copyright (c) 2002 IBM Corp. and others. All rights reserved.
-This file is made available under the terms of the Common Public License v1.0
-which accompanies this distribution, and is available at
-http://www.eclipse.org/legal/cpl-v10.html
-Contributors:
-**********************************************************************/
-
-import org.eclipse.jface.action.IMenuListener;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.viewers.DoubleClickEvent;
-import org.eclipse.jface.viewers.IDoubleClickListener;
-import org.eclipse.jface.viewers.IOpenListener;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.OpenEvent;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.events.KeyListener;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.actions.ActionContext;
-import org.eclipse.ui.externaltools.internal.model.ExternalToolsPlugin;
-import org.eclipse.ui.externaltools.internal.model.IHelpContextIds;
-import org.eclipse.ui.externaltools.internal.registry.ExternalToolType;
-import org.eclipse.ui.externaltools.model.ExternalTool;
-import org.eclipse.ui.help.WorkbenchHelp;
-import org.eclipse.ui.part.ViewPart;
-
-/**
- * The view to display all the external tools available to
- * the user. From this view, a user can create a new external
- * tool, delete an existing external tool, run an external
- * tool, or edit the properties of an existing external tool.
- */
-public class ExternalToolView extends ViewPart {
- private TreeViewer viewer;
- private ExternalToolActionGroup actionGroup;
-
- /**
- * Creates a new instance of the external tools view
- */
- public ExternalToolView() {
- super();
- }
-
- /* (non-Javadoc)
- * Method declared on IWorkbenchPart.
- */
- public void createPartControl(Composite parent) {
- viewer = createViewer(parent);
- initContextMenu();
- makeActions();
- viewer.setInput(getInitialInput());
-
- // Fill the action bars and update the global action handlers'
- // enabled state to match the current selection.
- actionGroup.fillActionBars(getViewSite().getActionBars());
- updateActionBars((IStructuredSelection) viewer.getSelection());
-
- getSite().setSelectionProvider(viewer);
- WorkbenchHelp.setHelp(viewer.getControl(), getHelpContextId());
- }
-
- /**
- * Creates the viewer control for the view.
- *
- * @param parent the parent composite
- * @return the tree viewer for the view
- */
- protected TreeViewer createViewer(Composite parent) {
- TreeViewer treeViewer = new TreeViewer(parent, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL);
- treeViewer.setUseHashlookup(true);
- initContentProvider(treeViewer);
- initLabelProvider(treeViewer);
- initFilters(treeViewer);
- initListeners(treeViewer);
-
- return treeViewer;
- }
-
- /* (non-Javadoc)
- * Method declared on IWorkbenchPart.
- */
- public void dispose() {
- if (actionGroup != null)
- actionGroup.dispose();
-
- super.dispose();
- }
-
- /**
- * Called when the context menu is about to open.
- * Delegates to the action group using the
- * viewer's selection as the action context.
- */
- protected void fillContextMenu(IMenuManager menu) {
- IStructuredSelection selection =
- (IStructuredSelection) viewer.getSelection();
- actionGroup.setContext(new ActionContext(selection));
- actionGroup.fillContextMenu(menu);
- }
-
- /**
- * Returns the action group.
- *
- * @return the action group
- */
- protected final ExternalToolActionGroup getActionGroup() {
- return actionGroup;
- }
-
- /**
- * Returns the help context id to use for this view.
- */
- protected String getHelpContextId() {
- return IHelpContextIds.EXTERNAL_TOOLS_VIEW;
- }
-
- /**
- * Returns the initial input for the viewer.
- */
- protected Object getInitialInput() {
- return ExternalToolsPlugin.getDefault().getTypeRegistry();
- }
-
- /**
- * Returns the message to show in the status line.
- *
- * @param selection the current selection
- * @return the status line message
- */
- protected String getStatusLineMessage(IStructuredSelection selection) {
- if (selection.size() == 1) {
- Object element = selection.getFirstElement();
- if (element instanceof ExternalToolType)
- return ((ExternalToolType)element).getDescription();
- if (element instanceof ExternalTool)
- return ((ExternalTool)element).getDescription();
- }
- return ""; //$NON-NLS-1$
- }
-
- /**
- * Returns the tree viewer which shows the external tools.
- */
- public final TreeViewer getTreeViewer() {
- return viewer;
- }
-
- /**
- * Handles a double-click event from the viewer.
- * Expands or collapses a type when double-clicked.
- *
- * @param event the double-click event
- */
- protected void handleDoubleClick(DoubleClickEvent event) {
- IStructuredSelection selection = (IStructuredSelection) event.getSelection();
- Object element = selection.getFirstElement();
- if (viewer.isExpandable(element))
- viewer.setExpandedState(element, !viewer.getExpandedState(element));
- }
-
- /**
- * Handles a key press event from the viewer.
- * Delegates to the action group.
- *
- * @param event the key event
- */
- protected void handleKeyPressed(KeyEvent event) {
- actionGroup.handleKeyPressed(event);
- }
-
- /**
- * Handles a key release in the viewer. Does
- * nothing by default.
- *
- * @param event the key event
- */
- protected void handleKeyReleased(KeyEvent event) {
- }
-
- /**
- * Handles an open event from the viewer.
- * Causes the selected external tool to be run.
- *
- * @param event the open event
- */
- protected void handleOpen(OpenEvent event) {
- IStructuredSelection selection = (IStructuredSelection) event.getSelection();
- actionGroup.runDefaultAction(selection);
- }
-
- /**
- * Handles a selection changed event from the viewer.
- * Updates the status line and the action bars.
- *
- * @param event the selection event
- */
- protected void handleSelectionChanged(SelectionChangedEvent event) {
- IStructuredSelection sel = (IStructuredSelection) event.getSelection();
- updateStatusLine(sel);
- updateActionBars(sel);
- }
-
- /**
- * Initializes and registers the context menu.
- */
- protected void initContextMenu() {
- MenuManager menuMgr = new MenuManager(); //$NON-NLS-1$
- menuMgr.setRemoveAllWhenShown(true);
- menuMgr.addMenuListener(new IMenuListener() {
- public void menuAboutToShow(IMenuManager manager) {
- fillContextMenu(manager);
- }
- });
- Menu menu = menuMgr.createContextMenu(viewer.getTree());
- viewer.getTree().setMenu(menu);
- getSite().registerContextMenu(menuMgr, viewer);
- }
-
- /**
- * Sets the content provider for the viewer.
- *
- * @param treeViewer the tree viewer
- */
- protected void initContentProvider(TreeViewer treeViewer) {
- Shell shell = getSite().getShell();
- treeViewer.setContentProvider(new ExternalToolContentProvider(shell));
- }
-
- /**
- * Sets the label provider for the viewer.
- *
- * @param treeViewer the tree viewer
- */
- protected void initLabelProvider(TreeViewer treeViewer) {
- treeViewer.setLabelProvider(new ExternalToolLabelProvider());
- }
-
- /**
- * Adds the filters to the viewer.
- *
- * @param treeViewer the tree viewer
- */
- protected void initFilters(TreeViewer treeViewer) {
- }
-
- /**
- * Adds the listeners to the viewer.
- *
- * @param treeViewer the tree viewer
- */
- protected void initListeners(TreeViewer treeViewer) {
- treeViewer.addSelectionChangedListener(new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- handleSelectionChanged(event);
- }
- });
-
- treeViewer.addDoubleClickListener(new IDoubleClickListener() {
- public void doubleClick(DoubleClickEvent event) {
- handleDoubleClick(event);
- }
- });
-
- treeViewer.addOpenListener(new IOpenListener() {
- public void open(OpenEvent event) {
- handleOpen(event);
- }
- });
-
- treeViewer.getControl().addKeyListener(new KeyListener() {
- public void keyPressed(KeyEvent event) {
- handleKeyPressed(event);
- }
- public void keyReleased(KeyEvent event) {
- handleKeyReleased(event);
- }
- });
- }
-
- /**
- * Creates the action group, which encapsulates all actions
- * for the view.
- */
- protected void makeActions() {
- setActionGroup(new ExternalToolActionGroup(this));
- }
-
- /**
- * Sets the action group.
- *
- * @param actionGroup the action group
- */
- protected void setActionGroup(ExternalToolActionGroup actionGroup) {
- this.actionGroup = actionGroup;
- }
-
- /* (non-Javadoc)
- * Method declared on IWorkbenchPart.
- */
- public void setFocus() {
- viewer.getTree().setFocus();
- }
-
- /**
- * Updates the action bar actions.
- *
- * @param selection the current selection
- */
- protected void updateActionBars(IStructuredSelection selection) {
- actionGroup.setContext(new ActionContext(selection));
- actionGroup.updateActionBars();
- }
-
- /**
- * Updates the message shown in the status line.
- *
- * @param selection the current selection
- */
- protected void updateStatusLine(IStructuredSelection selection) {
- String msg = getStatusLineMessage(selection);
- getViewSite().getActionBars().getStatusLineManager().setMessage(msg);
- }
-}
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/view/NewExternalToolAction.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/view/NewExternalToolAction.java
deleted file mode 100644
index 2fcf18d0f..000000000
--- a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/view/NewExternalToolAction.java
+++ /dev/null
@@ -1,48 +0,0 @@
-package org.eclipse.ui.externaltools.internal.view;
-
-/**********************************************************************
-Copyright (c) 2002 IBM Corp. and others. All rights reserved.
-This file is made available under the terms of the Common Public License v1.0
-which accompanies this distribution, and is available at
-http://www.eclipse.org/legal/cpl-v10.html
-Contributors:
-**********************************************************************/
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.ui.actions.NewWizardAction;
-import org.eclipse.ui.externaltools.internal.model.ExternalToolsPlugin;
-import org.eclipse.ui.externaltools.internal.model.IHelpContextIds;
-import org.eclipse.ui.externaltools.internal.model.ToolMessages;
-import org.eclipse.ui.help.WorkbenchHelp;
-
-/**
- * Action that will launch a wizard to create a new
- * external tool.
- */
-public class NewExternalToolAction extends Action {
- private static final String CATEGORY_ID = "org.eclipse.ui.externaltools.newWizards"; //$NON-NLS-1$
-
- /**
- * Create an action to launch a new
- * external tool wizard.
- */
- public NewExternalToolAction() {
- super();
- setText(ToolMessages.getString("NewExternalToolAction.text")); //$NON-NLS-1$
- setToolTipText(ToolMessages.getString("NewExternalToolAction.toolTip")); //$NON-NLS-1$
- setHoverImageDescriptor(ExternalToolsPlugin.getDefault().getImageDescriptor("icons/full/clcl16/new_tool.gif")); //$NON-NLS-1$
- setImageDescriptor(ExternalToolsPlugin.getDefault().getImageDescriptor("icons/full/elcl16/new_tool.gif")); //$NON-NLS-1$
- setDisabledImageDescriptor(ExternalToolsPlugin.getDefault().getImageDescriptor("icons/full/dlcl16/new_tool.gif")); //$NON-NLS-1$
- WorkbenchHelp.setHelp(this, IHelpContextIds.NEW_TOOL_ACTION);
- }
-
- /* (non-Javadoc)
- * Method declared on Action.
- */
- public void run() {
- NewWizardAction action = new NewWizardAction();
- action.setCategoryId(CATEGORY_ID);
- action.run();
- }
-}
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/view/RefreshViewAction.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/view/RefreshViewAction.java
deleted file mode 100644
index 9ee6d5f85..000000000
--- a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/view/RefreshViewAction.java
+++ /dev/null
@@ -1,49 +0,0 @@
-package org.eclipse.ui.externaltools.internal.view;
-
-/**********************************************************************
-Copyright (c) 2002 IBM Corp. and others. All rights reserved.
-This file is made available under the terms of the Common Public License v1.0
-which accompanies this distribution, and is available at
-http://www.eclipse.org/legal/cpl-v10.html
-Contributors:
-**********************************************************************/
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.externaltools.internal.model.ExternalToolsPlugin;
-import org.eclipse.ui.externaltools.internal.model.IHelpContextIds;
-import org.eclipse.ui.externaltools.internal.model.ToolMessages;
-import org.eclipse.ui.externaltools.model.ExternalToolStorage;
-import org.eclipse.ui.help.WorkbenchHelp;
-
-/**
- * Action that will refresh the contents of the
- * external tool view.
- */
-public class RefreshViewAction extends Action {
- private IWorkbenchPage page;
-
- /**
- * Create an action to refresh the view
- */
- public RefreshViewAction(IWorkbenchPage page) {
- super();
- this.page = page;
- setText(ToolMessages.getString("RefreshViewAction.text")); //$NON-NLS-1$
- setToolTipText(ToolMessages.getString("RefreshViewAction.toolTip")); //$NON-NLS-1$
- setHoverImageDescriptor(ExternalToolsPlugin.getDefault().getImageDescriptor("icons/full/clcl16/refresh.gif")); //$NON-NLS-1$
- setImageDescriptor(ExternalToolsPlugin.getDefault().getImageDescriptor("icons/full/elcl16/refresh.gif")); //$NON-NLS-1$
- setDisabledImageDescriptor(ExternalToolsPlugin.getDefault().getImageDescriptor("icons/full/dlcl16/refresh.gif")); //$NON-NLS-1$
- WorkbenchHelp.setHelp(this, IHelpContextIds.REFRESH_VIEW_ACTION);
- }
-
- /* (non-Javadoc)
- * Method declared on Action.
- */
- public void run() {
- Shell shell = page.getWorkbenchWindow().getShell();
- ExternalToolStorage.refreshTools(shell);
- }
-}
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/view/RenameExternalToolAction.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/view/RenameExternalToolAction.java
deleted file mode 100644
index 90c4383c5..000000000
--- a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/view/RenameExternalToolAction.java
+++ /dev/null
@@ -1,108 +0,0 @@
-package org.eclipse.ui.externaltools.internal.view;
-
-/**********************************************************************
-Copyright (c) 2002 IBM Corp. and others. All rights reserved.
-This file is made available under the terms of the Common Public License v1.0
-which accompanies this distribution, and is available at
-http://www.eclipse.org/legal/cpl-v10.html
-Contributors:
-**********************************************************************/
-
-import java.text.MessageFormat;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.ErrorDialog;
-import org.eclipse.jface.dialogs.IInputValidator;
-import org.eclipse.jface.dialogs.InputDialog;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.actions.TextActionHandler;
-import org.eclipse.ui.externaltools.internal.model.ExternalToolsPlugin;
-import org.eclipse.ui.externaltools.internal.model.IHelpContextIds;
-import org.eclipse.ui.externaltools.internal.model.ToolMessages;
-import org.eclipse.ui.externaltools.model.ExternalTool;
-import org.eclipse.ui.externaltools.model.ExternalToolStorage;
-import org.eclipse.ui.help.WorkbenchHelp;
-
-/**
- * Action that will rename the external tool selected
- * in the the view.
- */
-public class RenameExternalToolAction extends Action {
- private ExternalToolView view;
- private TextActionHandler textActionHandler;
- private ExternalTool selectedTool;
-
- /**
- * Create an action to rename the external tool.
- */
- public RenameExternalToolAction(ExternalToolView view) {
- super();
- this.view = view;
- setText(ToolMessages.getString("RenameExternalToolAction.text")); //$NON-NLS-1$
- setToolTipText(ToolMessages.getString("RenameExternalToolAction.toolTip")); //$NON-NLS-1$
- setHoverImageDescriptor(ExternalToolsPlugin.getDefault().getImageDescriptor("icons/full/clcl16/rename_tool.gif")); //$NON-NLS-1$
- setImageDescriptor(ExternalToolsPlugin.getDefault().getImageDescriptor("icons/full/elcl16/rename_tool.gif")); //$NON-NLS-1$
- setDisabledImageDescriptor(ExternalToolsPlugin.getDefault().getImageDescriptor("icons/full/dlcl16/rename_tool.gif")); //$NON-NLS-1$
- WorkbenchHelp.setHelp(this, IHelpContextIds.RENAME_TOOL_ACTION);
- }
-
- /**
- * Returns the selected external tool.
- */
- public ExternalTool getSelectedTool() {
- return selectedTool;
- }
-
- private Shell getShell() {
- return Display.getCurrent().getActiveShell();
- }
-
- /* (non-Javadoc)
- * Method declared on Action.
- */
- public void run() {
- if (selectedTool != null) {
- InputDialog dialog= new InputDialog(getShell(), "Rename Tool", "Enter a new name for the tool", selectedTool.getName(), new IInputValidator() {
- public String isValid(String newText) {
- if (newText.equals(selectedTool.getName())) {
- return null;
- } else if (ExternalToolsPlugin.getDefault().getToolRegistry(getShell()).hasToolNamed(newText)) {
- return "An external tool of that name already exists";
- }
- return ExternalTool.validateToolName(newText);
- }
- });
- if (dialog.open() == Dialog.OK) {
- String newName= dialog.getValue();
- if (newName.equals(selectedTool.getName())) {
- return;
- }
- try {
- selectedTool.rename(newName);
- ExternalToolStorage.saveTool(selectedTool, getShell());
- } catch (CoreException exception) {
- ErrorDialog.openError(getShell(), "External Tool Error", MessageFormat.format("An exception occurred while renaming {0}", new String[] {selectedTool.getName()}), exception.getStatus());
- }
- }
- }
- }
-
- /**
- * Sets the selected external tool.
- */
- public void setSelectedTool(ExternalTool tool) {
- selectedTool = tool;
- setEnabled(tool != null);
- }
-
- /**
- * Sets the text action handler
- */
- public void setTextActionHandler(TextActionHandler handler) {
- textActionHandler = handler;
- }
-}
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/model/ExternalTool.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/model/ExternalTool.java
deleted file mode 100644
index 9ad2ca6aa..000000000
--- a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/model/ExternalTool.java
+++ /dev/null
@@ -1,543 +0,0 @@
-package org.eclipse.ui.externaltools.model;
-
-/**********************************************************************
-Copyright (c) 2002 IBM Corp. and others. All rights reserved.
-This file is made available under the terms of the Common Public License v1.0
-which accompanies this distribution, and is available at
-http://www.eclipse.org/legal/cpl-v10.html
-Contributors:
-**********************************************************************/
-
-import java.text.MessageFormat;
-import java.util.ArrayList;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IncrementalProjectBuilder;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.ui.IActionFilter;
-import org.eclipse.ui.externaltools.internal.model.ExternalToolsPlugin;
-import org.eclipse.ui.model.IWorkbenchAdapter;
-
-/**
- * This class represents an external tool that can be run. The tool
- * can be inside or outside the workspace.
- * <p>
- * An external tool consist of a user defined name, the location
- * of the tool, optional arguments for the tool, and the working
- * directory.
- * </p><p>
- * After the tool has run, part or all of the workspace can be
- * refreshed to pickup changes made by the tool. This is optional
- * and does nothing by default
- * </p><p>
- * This class is not intended to be extended by clients
- * </p>
- */
-public final class ExternalTool implements IAdaptable {
- private static final String EMPTY_STRING = ""; //$NON-NLS-1$
- private static final int[] DEFAULT_BUILD_KINDS =
- {IncrementalProjectBuilder.INCREMENTAL_BUILD,
- IncrementalProjectBuilder.FULL_BUILD,
- IncrementalProjectBuilder.AUTO_BUILD};
-
- private static final ToolWorkbenchAdapter workbenchAdapter = new ToolWorkbenchAdapter();
- private static final ToolFilterAdapter filterAdapter = new ToolFilterAdapter();
-
- private String type = EMPTY_STRING;
- private String name = EMPTY_STRING;
- private String location = EMPTY_STRING;
- private String arguments = EMPTY_STRING;
- private String workDirectory = EMPTY_STRING;
- private String description = EMPTY_STRING;
- private String openPerspective = null;
- private String refreshScope = null;
- private boolean refreshRecursive = true;
- private boolean captureOutput = true;
- private boolean showConsole = true;
- private boolean runInBackground = true;
- private boolean promptForArguments = false;
- private boolean showInMenu = false;
- private boolean saveDirtyEditors = false;
- private int[] runForBuildKinds = DEFAULT_BUILD_KINDS;
- private ArrayList extraAttributes = null;
-
- /**
- * Creates a fully initialized external tool.
- *
- * @param type the type of external tool.
- * @param name the name given to the external tool. Must only
- * contain letters, numbers, hyphens, and spaces.
- */
- public ExternalTool(String type, String name) throws CoreException {
- super();
-
- if (type != null)
- this.type = type;
-
- String errorText = validateToolName(name);
- if (errorText == null)
- this.name = name.trim();
- else
- throw ExternalToolsPlugin.newError(errorText, null);
- }
-
- /**
- * Validates the specified tool name only includes letters,
- * numbers, hyphens, and spaces. Must contain at least one
- * letter or number.
- *
- * @param name the proposed name for the external tool
- * @return a string indicating the invalid format or <code>null</code> if valid.
- */
- public static String validateToolName(String name) {
- IStatus status = ResourcesPlugin.getWorkspace().validateName(name, IResource.FILE);
- if (status.getCode() != IStatus.OK) {
- return status.getMessage();
- }
- return null;
- }
-
- /* (non-Javadoc)
- * Method declared on IAdaptable.
- */
- public Object getAdapter(Class adapter) {
- if (adapter == IWorkbenchAdapter.class)
- return workbenchAdapter;
-
- if (adapter == IActionFilter.class)
- return filterAdapter;
-
- return null;
- }
-
- /**
- * Returns the extra attribute value
- *
- * @param key the unique attribute name
- * @return the value of the attribute, or <code>null</code>
- * if not such attribute name.
- */
- public String getExtraAttribute(String key) {
- if (key == null || key.length() == 0)
- return null;
- if (extraAttributes == null)
- return null;
-
- for (int i = 0; i < extraAttributes.size(); i++) {
- Attribute attr = (Attribute)extraAttributes.get(i);
- if (attr.key.equals(key))
- return attr.value;
- }
-
- return null;
- }
-
- /**
- * Returns all the extra attribute keys
- */
- public String[] getExtraAttributeKeys() {
- if (extraAttributes == null)
- return new String[0];
-
- String[] results = new String[extraAttributes.size()];
- for (int i = 0; i < extraAttributes.size(); i++) {
- Attribute attr = (Attribute)extraAttributes.get(i);
- results[i] = attr.key;
- }
-
- return results;
- }
-
- /**
- * Returns all the extra attribute values
- */
- public String[] getExtraAttributeValues() {
- if (extraAttributes == null)
- return new String[0];
-
- String[] results = new String[extraAttributes.size()];
- for (int i = 0; i < extraAttributes.size(); i++) {
- Attribute attr = (Attribute)extraAttributes.get(i);
- results[i] = attr.value;
- }
-
- return results;
- }
-
- /**
- * Sets an extra attribute to the tool.
- *
- * @param key the unique attribute name
- * @param value the value for the attribute. If <code>null</code>,
- * then the existing attribute is removed.
- */
- public void setExtraAttribute(String key, String value) {
- // Exit on invalid key
- if (key == null || key.length() == 0)
- return;
-
- // Init the list but only if not attempting to remove
- // an extra attribute
- if (extraAttributes == null) {
- if (value == null)
- return;
- else
- extraAttributes = new ArrayList(4);
- }
-
- // If the extra attribute exist, update it with the
- // new value, or remove it if the value is null
- for (int i = 0; i < extraAttributes.size(); i++) {
- Attribute attr = (Attribute)extraAttributes.get(i);
- if (attr.key.equals(key)) {
- if (value == null)
- extraAttributes.remove(i);
- else
- attr.value = value.trim();
- return;
- }
- }
-
- // Otherwise add the new extra attribute
- if (value != null)
- extraAttributes.add(new Attribute(key, value.trim()));
- }
-
- /**
- * Returns the type of external tool.
- */
- public String getType() {
- return type;
- }
-
- /**
- * Returns the name of the external tool.
- */
- public String getName() {
- return name;
- }
-
- /**
- * Returns the location of the external tool.
- */
- public String getLocation() {
- return location;
- }
-
- /**
- * Returns the arguments for the external tool.
- */
- public String getArguments() {
- return arguments;
- }
-
- /**
- * Returns the working directory to run the external tool in.
- */
- public String getWorkingDirectory() {
- return workDirectory;
- }
-
- /**
- * Returns whether the refresh will be recursive.
- */
- public boolean getRefreshRecursive() {
- return refreshRecursive;
- }
-
- /**
- * Returns the scope of resources to refresh after
- * the external tool is run, or <code>null</code> if
- * not specified. The value is in an variable
- * format.
- */
- public String getRefreshScope() {
- return refreshScope;
- }
-
- /**
- * Returns whether to capture output messages from the
- * running tool.
- */
- public boolean getCaptureOutput() {
- return captureOutput;
- }
-
- /**
- * Returns whether to show the log console when
- * the tool is run.
- */
- public boolean getShowConsole() {
- return showConsole;
- }
-
- /**
- * Returns whether to run the external tool in the
- * background so as not to block the UI.
- */
- public boolean getRunInBackground() {
- return runInBackground;
- }
-
- /**
- * Returns whether to prompt for arguments before
- * the tool is run.
- */
- public boolean getPromptForArguments() {
- return promptForArguments;
- }
-
- /**
- * Returns whether to show this tool in the
- * Run > External Tools menu.
- */
- public boolean getShowInMenu() {
- return showInMenu;
- }
-
- /**
- * Returns whether to save all dirty editors before
- * running this tool.
- */
- public boolean getSaveDirtyEditors() {
- return saveDirtyEditors;
- }
-
- /**
- * Returns the perspective ID to open when this
- * tool is run, or <code>null</code> if not specified.
- */
- public String getOpenPerspective() {
- return openPerspective;
- }
-
- /**
- * Returns a description of this external tool
- */
- public String getDescription() {
- return description;
- }
-
- /**
- * Returns the list of build kinds that this
- * tool wants to run when used as a builder.
- * The list of valid build kinds is defined
- * on <code>IncrementalProjectBuilder</code>.
- */
- public int[] getRunForBuildKinds() {
- return runForBuildKinds;
- }
-
- /**
- * Sets the name of the external tool.
- */
- public void rename(String name) throws CoreException {
- IStatus status= ExternalToolsPlugin.getDefault().getToolRegistry(null).renameTool(this, name);
- if (!status.isOK()) {
- // Throw an exception
- ExternalToolsPlugin.newError(MessageFormat.format("An exception occurred attempting to rename the tool: ", new Object[] {this.getName()}), null);
- }
- if (name == null) {
- this.name = EMPTY_STRING;
- } else {
- this.name = name;
- }
- }
-
- /**
- * Sets the location of the external tool.
- */
- public void setLocation(String location) {
- if (location == null)
- this.location = EMPTY_STRING;
- else
- this.location = location.trim();
- }
-
- /**
- * Sets the arguments for the external tool.
- */
- public void setArguments(String arguments) {
- if (arguments == null)
- this.arguments = EMPTY_STRING;
- else
- this.arguments = arguments.trim();
- }
-
- /**
- * Sets the working directory to run the external tool in.
- */
- public void setWorkingDirectory(String workDirectory) {
- if (workDirectory == null)
- this.workDirectory = EMPTY_STRING;
- else
- this.workDirectory = workDirectory.trim();
- }
-
- /**
- * Sets whether the refresh will be recursive.
- */
- public void setRefreshRecursive(boolean refreshRecursive) {
- this.refreshRecursive = refreshRecursive;
- }
-
- /**
- * Sets the scope of resources to refresh after
- * the external tool is run, or <code>null</code>
- * if none. The value is in a variable format.
- */
- public void setRefreshScope(String refreshScope) {
- if (refreshScope == null)
- this.refreshScope = null;
- else {
- this.refreshScope = refreshScope.trim();
- if (this.refreshScope.length() == 0)
- this.refreshScope = null;
- }
- }
-
- /**
- * Sets whether to capture output messages from the
- * running tool.
- */
- public void setCaptureOutput(boolean captureOutput) {
- this.captureOutput = captureOutput;
- }
-
- /**
- * Sets whether to show the log console when
- * the tool is run.
- */
- public void setShowConsole(boolean showConsole) {
- this.showConsole = showConsole;
- }
-
- /**
- * Sets whether to run the external tool in the
- * background so as not to block the UI.
- */
- public void setRunInBackground(boolean runInBackground) {
- this.runInBackground = runInBackground;
- }
-
- /**
- * Sets whether to prompt for arguments before
- * the tool is run.
- */
- public void setPromptForArguments(boolean promptForArguments) {
- this.promptForArguments = promptForArguments;
- }
-
- /**
- * Sets whether to show this tool in the
- * Run > External Tools menu.
- */
- public void setShowInMenu(boolean showInMenu) {
- this.showInMenu = showInMenu;
- }
-
- /**
- * Sets whether all dirty editors will be saved
- * before running this tool.
- */
- public void setSaveDirtyEditors(boolean saveDirtyEditors) {
- this.saveDirtyEditors = saveDirtyEditors;
- }
-
- /**
- * Sets the perspective ID to open when this
- * tool is run, or <code>null</code> if not specified.
- */
- public void setOpenPerspective(String openPerspective) {
- if (openPerspective == null)
- this.openPerspective = null;
- else {
- this.openPerspective = openPerspective.trim();
- if (this.openPerspective.length() == 0)
- this.openPerspective = null;
- }
- }
-
- /**
- * Sets a description of this external tool
- */
- public void setDescription(String description) {
- if (description == null)
- this.description = EMPTY_STRING;
- else
- this.description = description.trim();
- }
-
- /**
- * Sets the list of build kinds that this
- * tool wants to run when used as a builder.
- * The list of valid build kinds is defined
- * on <code>IncrementalProjectBuilder</code>.
- */
- public void setRunForBuildKinds(int[] kinds) {
- if (kinds == null)
- this.runForBuildKinds = DEFAULT_BUILD_KINDS;
- else
- this.runForBuildKinds = kinds;
- }
-
- /**
- * Internal representation of extra attributes.
- */
- private static class Attribute {
- public String key;
- public String value;
-
- public Attribute(String key, String value) {
- super();
- this.key = key;
- this.value = value;
- }
- }
-
- /**
- * Internal workbench adapter implementation.
- */
- private static class ToolWorkbenchAdapter implements IWorkbenchAdapter {
- public Object[] getChildren(Object o) {
- return new Object[0];
- }
-
- public ImageDescriptor getImageDescriptor(Object o) {
- String type = ((ExternalTool)o).getType();
- return ExternalToolsPlugin.getDefault().getTypeRegistry().getToolTypeImageDescriptor(type);
- }
-
- public String getLabel(Object o) {
- return ((ExternalTool)o).getName();
- }
-
- public Object getParent(Object o) {
- String type = ((ExternalTool)o).getType();
- return ExternalToolsPlugin.getDefault().getTypeRegistry().getToolType(type);
- }
- }
-
- /**
- * Internal action filter adapter implementation.
- */
- private static class ToolFilterAdapter implements IExternalToolFilter {
- public boolean testAttribute(Object target, String name, String value) {
- ExternalTool tool = (ExternalTool) target;
-
- if (IExternalToolFilter.TYPE.equals(name))
- return tool.getType().equals(value);
-
- String attrValue = tool.getExtraAttribute(name);
- if (attrValue != null)
- return attrValue.equals(value);
-
- return false;
- }
- }
-} \ No newline at end of file
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/model/ExternalToolStorage.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/model/ExternalToolStorage.java
deleted file mode 100644
index a22e2278c..000000000
--- a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/model/ExternalToolStorage.java
+++ /dev/null
@@ -1,153 +0,0 @@
-package org.eclipse.ui.externaltools.model;
-
-/**********************************************************************
-Copyright (c) 2002 IBM Corp. and others. All rights reserved.
-This file is made available under the terms of the Common Public License v1.0
-which accompanies this distribution, and is available at
-http://www.eclipse.org/legal/cpl-v10.html
-Contributors:
-**********************************************************************/
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jface.dialogs.ErrorDialog;
-import org.eclipse.jface.util.ListenerList;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.externaltools.internal.model.ExternalToolsPlugin;
-import org.eclipse.ui.externaltools.internal.model.ToolMessages;
-import org.eclipse.ui.externaltools.internal.registry.ExternalToolRegistry;
-
-/**
- * Provides utility methods to manager the storage
- * of external tools.
- */
-public final class ExternalToolStorage {
- private static ListenerList listeners = new ListenerList();
-
- /**
- * Allows no instance to be created
- */
- private ExternalToolStorage() {
- super();
- }
-
- /**
- * Adds a tool storage listener.
- *
- * @param listener the tool storage listener to add
- */
- public static void addStorageListener(IStorageListener listener) {
- listeners.add(listener);
- }
-
- /**
- * Deletes the external tool from storage and from
- * the tools registry.
- *
- * @param tool the external tool to be deleted
- * @param shell the shell to parent any error dialogs,
- * of <code>null</code> to operate quietly.
- */
- public static void deleteTool(ExternalTool tool, Shell shell) {
- if (tool == null)
- return;
-
- ExternalToolRegistry registry = ExternalToolsPlugin.getDefault().getToolRegistry(shell);
- IStatus results = registry.deleteTool(tool);
-
- if (handleResults(results, shell, "ExternalToolStorage.deleteErrorTitle", "ExternalToolStorage.deleteErrorMessage")) //$NON-NLS-2$//$NON-NLS-1$
- return;
-
- Object list[] = listeners.getListeners();
- for (int i = 0; i < list.length; i++) {
- ((IStorageListener)list[i]).toolDeleted(tool);
- }
- }
-
- /**
- * Handles the display of any error message if the
- * results were not ok.
- *
- * @return <code>true</code> if an error was displayed, <code>false</code> otherwise
- */
- private static boolean handleResults(final IStatus results, final Shell shell, final String titleKey, final String msgKey) {
- if (!results.isOK() && shell != null && !shell.isDisposed()) {
- shell.getDisplay().syncExec(new Runnable() {
- public void run() {
- String title = ToolMessages.getString(titleKey);
- String msg = ToolMessages.getString(msgKey);
- ErrorDialog.openError(shell, title, msg, results);
- }
- });
-
- return true;
- }
-
- return false;
- }
-
- /**
- * Reloads the tools from storage into the registry.
- *
- * @param shell the shell to parent any error dialogs,
- * of <code>null</code> to operate quietly.
- */
- public static void refreshTools(final Shell shell) {
- final IStatus[] results = new IStatus[1];
-
- BusyIndicator.showWhile(shell.getDisplay(), new Runnable() {
- public void run() {
- results[0] = ExternalToolsPlugin.getDefault().getToolRegistry(shell).reloadTools();
- }
- });
-
- if (handleResults(results[0], shell, "ExternalToolStorage.reloadErrorTitle", "ExternalToolStorage.reloadErrorMessage")) //$NON-NLS-2$//$NON-NLS-1$
- return;
-
- Object list[] = listeners.getListeners();
- for (int i = 0; i < list.length; i++) {
- ((IStorageListener)list[i]).toolsRefreshed();
- }
- }
-
- /**
- * Removes a tool storage listener.
- *
- * @param listener the tool storage listener to remove
- */
- public static void removeStorageListener(IStorageListener listener) {
- listeners.remove(listener);
- }
-
- /**
- * Saves the external tool to storage and to
- * the tools registry.
- *
- * @param tool the external tool to be saved
- * @param shell the shell to parent any error dialogs,
- * of <code>null</code> to operate quietly.
- * @return <code>true</code> if save successful, <code>false</code> otherwise.
- */
- public static boolean saveTool(ExternalTool tool, Shell shell) {
- if (tool == null)
- return false;
-
- ExternalToolRegistry registry = ExternalToolsPlugin.getDefault().getToolRegistry(shell);
- boolean exists = registry.hasToolNamed(tool.getName());
-
- IStatus results = registry.saveTool(tool);
- if (handleResults(results, shell, "ExternalToolStorage.saveErrorTitle", "ExternalToolStorage.saveErrorMessage")) //$NON-NLS-2$//$NON-NLS-1$
- return false;
-
- Object list[] = listeners.getListeners();
- for (int i = 0; i < list.length; i++) {
- if (exists)
- ((IStorageListener)list[i]).toolModified(tool);
- else
- ((IStorageListener)list[i]).toolCreated(tool);
- }
-
- return true;
- }
-}
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/model/IExternalToolFilter.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/model/IExternalToolFilter.java
deleted file mode 100644
index 5ec00651f..000000000
--- a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/model/IExternalToolFilter.java
+++ /dev/null
@@ -1,34 +0,0 @@
-package org.eclipse.ui.externaltools.model;
-
-/**********************************************************************
-Copyright (c) 2002 IBM Corp. and others. All rights reserved.
-This file is made available under the terms of the Common Public License v1.0
-which accompanies this distribution, and is available at
-http://www.eclipse.org/legal/cpl-v10.html
-Contributors:
-**********************************************************************/
-
-import org.eclipse.ui.IActionFilter;
-
-/**
- * Describes the public attributes for an external tool and the acceptables values
- * each may have.
- * <p>
- * Beside the attributes defined below, all of the extra attribute keys are
- * also available. Only use extra attribute keys which have been made public
- * by clients.
- * </p><p>
- * This interface is not to be extended or implemented by clients
- * </p>
- *
- * @see IActionFilter
- */
-public interface IExternalToolFilter extends IActionFilter {
- /**
- * An attribute indicating the external tool type (value <code>"type"</code>).
- * The attribute value should match one of the external tool types defined in
- * the external tool's type extension point.
- */
- public static final String TYPE = "type"; //$NON-NLS-1$
-}
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/model/IExternalToolRunner.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/model/IExternalToolRunner.java
deleted file mode 100644
index 5014e0f4d..000000000
--- a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/model/IExternalToolRunner.java
+++ /dev/null
@@ -1,38 +0,0 @@
-package org.eclipse.ui.externaltools.model;
-
-/**********************************************************************
-Copyright (c) 2002 IBM Corp. and others. All rights reserved.
-This file is made available under the terms of the Common Public License v1.0
-which accompanies this distribution, and is available at
-http://www.eclipse.org/legal/cpl-v10.html
-Contributors:
-**********************************************************************/
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.MultiStatus;
-
-/**
- * The implementation of this interface is responsible for running
- * an external tool within the specified context.
- * <p>
- * Clients using the extension point to define a new external
- * tool type must provide an implementation of this interface.
- * </p><p>
- * The implementation of this interface will be treated like
- * a singleton. That is, only one instance will be created
- * per tool type.
- * </p><p>
- * This interface is not intended to be extended by clients.
- * </p>
- */
-public interface IExternalToolRunner {
- /**
- * Runs an external tool using the specified context.
- *
- * @param monitor the monitor to report progress or cancellation to
- * @param runnerContext the context representing the tool to run
- * @param status a multi status to report any problems while running tool
- */
- public void run(IProgressMonitor monitor, IRunnerContext runnerContext, MultiStatus status);
-}
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/model/IRunnerContext.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/model/IRunnerContext.java
deleted file mode 100644
index 1b12e298c..000000000
--- a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/model/IRunnerContext.java
+++ /dev/null
@@ -1,67 +0,0 @@
-package org.eclipse.ui.externaltools.model;
-
-/**********************************************************************
-Copyright (c) 2002 IBM Corp. and others. All rights reserved.
-This file is made available under the terms of the Common Public License v1.0
-which accompanies this distribution, and is available at
-http://www.eclipse.org/legal/cpl-v10.html
-Contributors:
-**********************************************************************/
-
-/**
- * Represents the context of the external tool to run. An implementation
- * of this interface is provided to the <code>IExternalToolRunner</code>.
- * <p>
- * This interface is not be extended nor implemented by clients.
- * </p>
- */
-public interface IRunnerContext {
- /**
- * Returns whether the external tool runner should capture
- * output messages from the running tool and log these
- * messages.
- */
- public boolean getCaptureOutput();
-
- /**
- * Returns the arguments for the external tool. All
- * variables embedded in the arguments have been fully
- * expanded.
- */
- public String[] getExpandedArguments();
-
- /**
- * Returns the path where the external tool is located. All
- * variables embedded in the path have been fully
- * expanded.
- */
- public String getExpandedLocation();
-
- /**
- * Returns the working directory to run the external tool in.
- * All variables embedded in the path have been fully
- * expanded.
- */
- public String getExpandedWorkingDirectory();
-
- /**
- * Returns the extra attribute value of the external tool.
- *
- * @param key the unique attribute name
- * @return the value of the attribute, or <code>null</code>
- * if not such attribute name.
- */
- public String getExtraAttribute(String key);
-
- /**
- * Returns the log the runner can used to log
- * messages captured from the running tool's output.
- */
- public IRunnerLog getLog();
-
- /**
- * Returns the name of the external tool.
- */
- public String getName();
-}
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/model/IStorageListener.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/model/IStorageListener.java
deleted file mode 100644
index 84c502b76..000000000
--- a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/model/IStorageListener.java
+++ /dev/null
@@ -1,50 +0,0 @@
-package org.eclipse.ui.externaltools.model;
-
-/**********************************************************************
-Copyright (c) 2002 IBM Corp. and others. All rights reserved.
-This file is made available under the terms of the Common Public License v1.0
-which accompanies this distribution, and is available at
-http://www.eclipse.org/legal/cpl-v10.html
-Contributors:
-**********************************************************************/
-
-/**
- * Defines the changes within the external tool storage that
- * a listeners can be notified of.
- * <p>
- * This interface is not to be extended by clients, but can be
- * implemented by clients.
- * </p>
- */
-public interface IStorageListener {
- /**
- * Notifies this listener that an external tool has
- * been removed from the registry and storage.
- *
- * @param tool the external tool that was removed
- */
- public void toolDeleted(ExternalTool tool);
-
- /**
- * Notifies this listener that a new external tool has
- * been added to the registry and storage.
- *
- * @param tool the external tool that was created
- */
- public void toolCreated(ExternalTool tool);
-
- /**
- * Notifies this listener that an existing external tool
- * in the registry has been modified and saved to storage.
- *
- * @param tool the external tool that was modified
- */
- public void toolModified(ExternalTool tool);
-
- /**
- * Notifies this listener that the entire external tool
- * registry was refreshed from storage.
- */
- public void toolsRefreshed();
-}
diff --git a/org.eclipse.ui.externaltools/Program Tools Support/org/eclipse/ui/externaltools/internal/program/dialog/ProgramExternalToolNewWizard.java b/org.eclipse.ui.externaltools/Program Tools Support/org/eclipse/ui/externaltools/internal/program/dialog/ProgramExternalToolNewWizard.java
deleted file mode 100644
index fa170b7c8..000000000
--- a/org.eclipse.ui.externaltools/Program Tools Support/org/eclipse/ui/externaltools/internal/program/dialog/ProgramExternalToolNewWizard.java
+++ /dev/null
@@ -1,44 +0,0 @@
-package org.eclipse.ui.externaltools.internal.program.dialog;
-
-/**********************************************************************
-Copyright (c) 2002 IBM Corp. and others. All rights reserved.
-This file is made available under the terms of the Common Public License v1.0
-which accompanies this distribution, and is available at
-http://www.eclipse.org/legal/cpl-v10.html
-Contributors:
-**********************************************************************/
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.ui.externaltools.dialog.ExternalToolNewWizard;
-import org.eclipse.ui.externaltools.internal.model.ExternalToolsPlugin;
-import org.eclipse.ui.externaltools.model.IExternalToolConstants;
-
-/**
- * Wizard that will create a new external tool of type program.
- */
-public class ProgramExternalToolNewWizard extends ExternalToolNewWizard {
-
- /**
- * Creates the wizard for a new external tool
- */
- public ProgramExternalToolNewWizard() {
- super(IExternalToolConstants.TOOL_TYPE_PROGRAM);
- }
-
- /* (non-Javadoc)
- * Method declared on IWizard.
- */
- public void addPages() {
- addMainPage();
- addOptionPage();
- addRefreshPage();
- }
-
- /* (non-Javadoc)
- * Method declared on ExternalToolNewWizard.
- */
- protected ImageDescriptor getDefaultImageDescriptor() {
- return ExternalToolsPlugin.getDefault().getImageDescriptor("icons/full/wizban/program_wiz.gif"); //$NON-NLS-1$
- }
-}
diff --git a/org.eclipse.ui.externaltools/Program Tools Support/org/eclipse/ui/externaltools/internal/program/model/ProgramRunner.java b/org.eclipse.ui.externaltools/Program Tools Support/org/eclipse/ui/externaltools/internal/program/model/ProgramRunner.java
deleted file mode 100644
index c9e6e80a8..000000000
--- a/org.eclipse.ui.externaltools/Program Tools Support/org/eclipse/ui/externaltools/internal/program/model/ProgramRunner.java
+++ /dev/null
@@ -1,174 +0,0 @@
-package org.eclipse.ui.externaltools.internal.program.model;
-
-/**********************************************************************
-Copyright (c) 2002 IBM Corp. and others. All rights reserved.
-This file is made available under the terms of the Common Public License v1.0
-which accompanies this distribution, and is available at
-http://www.eclipse.org/legal/cpl-v10.html
-Contributors:
-**********************************************************************/
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.MultiStatus;
-import org.eclipse.ui.externaltools.internal.model.ExternalToolsPlugin;
-import org.eclipse.ui.externaltools.internal.model.ToolMessages;
-import org.eclipse.ui.externaltools.model.IExternalToolRunner;
-import org.eclipse.ui.externaltools.model.IRunnerContext;
-import org.eclipse.ui.externaltools.model.IRunnerLog;
-
-/**
- * Runs all external tools of type program.
- */
-public final class ProgramRunner implements IExternalToolRunner {
-
- /**
- * Creates a program runner
- */
- public ProgramRunner() {
- super();
- }
-
- /**
- * Handles exceptions that may occur while running.
- */
- private void handleException(Exception e, MultiStatus status) {
- String msg = e.getMessage();
- if (msg == null)
- msg = ToolMessages.getString("ProgramRunner.internalErrorMessage"); //$NON-NLS-1$;
- status.merge(ExternalToolsPlugin.newErrorStatus(msg, e));
- }
-
- /* (non-Javadoc)
- * Method declared in IExternalToolsRunner.
- */
- public void run(IProgressMonitor monitor, IRunnerContext runnerContext, MultiStatus status) {
- // Runtime exec requires an array where the first element is
- // the file to run, and the remaining elements are the
- // arguments to past along.
- String[] args = runnerContext.getExpandedArguments();
- String[] commands = new String[args.length + 1];
-
- commands[0] = runnerContext.getExpandedLocation();
- System.arraycopy(args, 0, commands, 1, args.length);
-
- try {
- // Determine the working directory to use, if any
- File workingDirectory = null;
- if (runnerContext.getExpandedWorkingDirectory().length() > 0)
- workingDirectory = new File(runnerContext.getExpandedWorkingDirectory());
-
- startMonitor(monitor, runnerContext, IProgressMonitor.UNKNOWN);
- if (monitor.isCanceled())
- return;
-
- // Print out the command used to run the program.
- if (IRunnerLog.LEVEL_VERBOSE <= runnerContext.getLog().getFilterLevel()) {
- runnerContext.getLog().append(
- ToolMessages.getString("ProgramRunner.callingRuntimeExec"), //$NON-NLS-1$;
- IRunnerLog.LEVEL_VERBOSE);
- runnerContext.getLog().append(
- ToolMessages.format("ProgramRunner.program", new Object[] {commands[0]}), //$NON-NLS-1$;
- IRunnerLog.LEVEL_VERBOSE);
- for (int i = 1; i < commands.length; i++) {
- runnerContext.getLog().append(
- ToolMessages.format("ProgramRunner.argument", new Object[] {commands[i]}), //$NON-NLS-1$;
- IRunnerLog.LEVEL_VERBOSE);
- }
- if (workingDirectory != null) {
- runnerContext.getLog().append(
- ToolMessages.format("ProgramRunner.workDir", new Object[] {workingDirectory.toString()}), //$NON-NLS-1$;
- IRunnerLog.LEVEL_VERBOSE);
- }
- }
-
- // Run the program
- boolean[] finished = new boolean[] {false};
- Process p;
- if (workingDirectory != null)
- p = Runtime.getRuntime().exec(commands, null, workingDirectory);
- else
- p = Runtime.getRuntime().exec(commands);
-
- // Collect the program's output in the background
- if (runnerContext.getCaptureOutput()) {
- startThread(
- p.getInputStream(),
- runnerContext.getLog(),
- IRunnerLog.LEVEL_INFO,
- finished);
- startThread(
- p.getErrorStream(),
- runnerContext.getLog(),
- IRunnerLog.LEVEL_ERROR,
- finished);
- }
-
- if (monitor.isCanceled()) {
- p.destroy();
- } else {
- p.waitFor();
-
- // Sleep to allow the two new threads to begin reading
- // the program-running process's input and error streams
- // before finished[0] is set to true. This is especially
- // necessary with short programs that execute quickly. If
- // finished[0] is set to true before the threads run,
- // nothing will be read from the input and error streams.
- Thread.sleep(300);
- }
-
- finished[0] = true;
- } catch (IOException e) {
- handleException(e, status);
- } catch (InterruptedException e) {
- handleException(e, status);
- } finally {
- monitor.done();
- }
- }
-
- /**
- * Starts a thread to capture the specified stream contents
- * and log it.
- */
- private void startThread(final InputStream input, final IRunnerLog log, final int level, final boolean[] finished) {
- Thread t = new Thread(new Runnable() {
- public void run() {
- try {
- StringBuffer sb;
- while (!finished[0]) {
- sb = new StringBuffer();
- int c = input.read();
- while (c != -1) {
- sb.append((char)c);
- c = input.read();
- }
- log.append(sb.toString(), level);
- try {
- Thread.sleep(100);
- } catch (InterruptedException e) {
- }
- }
- input.close();
- } catch (IOException e) {
- e.printStackTrace(System.out);
- }
- }
- });
-
- t.start();
- }
-
- /**
- * Starts the monitor to show progress while running.
- */
- private void startMonitor(IProgressMonitor monitor, IRunnerContext runnerContext, int workAmount) {
- String label = ToolMessages.format("ProgramRunner.runningToolLabel", new Object[] {runnerContext.getName()}); //$NON-NLS-1$;
- monitor.beginTask(label, workAmount);
- }
-}

Back to the top