Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui')
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/BuilderLabelProvider.java133
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/BuilderPropertyPage.java1144
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/ExternalToolsPreferencePage.java97
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/ExternalToolsUIMessages.java42
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/ExternalToolsUIMessages.properties54
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/FileSelectionDialog.java246
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/TreeAndListGroup.java316
7 files changed, 0 insertions, 2032 deletions
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/BuilderLabelProvider.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/BuilderLabelProvider.java
deleted file mode 100644
index 40be6be30..000000000
--- a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/BuilderLabelProvider.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.externaltools.internal.ui;
-
-import java.text.MessageFormat;
-
-import org.eclipse.core.resources.ICommand;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IExtension;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.debug.core.ILaunchConfiguration;
-import org.eclipse.debug.core.ILaunchConfigurationType;
-import org.eclipse.debug.ui.DebugUITools;
-import org.eclipse.debug.ui.IDebugModelPresentation;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.ui.externaltools.internal.model.ExternalToolsPlugin;
-import org.eclipse.ui.externaltools.internal.model.IExternalToolConstants;
-import org.eclipse.ui.externaltools.internal.ui.BuilderPropertyPage.ErrorConfig;
-
-
-class BuilderLabelProvider extends LabelProvider {
- private static final String IMG_BUILDER = "icons/full/obj16/builder.gif"; //$NON-NLS-1$;
- private static final String IMG_INVALID_BUILD_TOOL = "icons/full/obj16/invalid_build_tool.gif"; //$NON-NLS-1$
- IDebugModelPresentation debugModelPresentation= DebugUITools.newDebugModelPresentation();
-
- private Image builderImage = ExternalToolsPlugin.getDefault().getImageDescriptor(IMG_BUILDER).createImage();
- private Image invalidBuildToolImage = ExternalToolsPlugin.getDefault().getImageDescriptor(IMG_INVALID_BUILD_TOOL).createImage();
-
- public String getText(Object element) {
- if (element instanceof ICommand) {
- return getCommandText((ICommand) element);
- } else if (element instanceof ILaunchConfiguration || element instanceof ILaunchConfigurationType) {
- return getDebugModelText(element);
- } else if (element instanceof ErrorConfig) {
- return ExternalToolsUIMessages.getString("BuilderPropertyPage.invalidBuildTool"); //$NON-NLS-1$
- }
- return super.getText(element);
- }
-
- public Image getImage(Object element) {
- if (element instanceof ICommand) {
- return getCommandImage();
- } else if (element instanceof ILaunchConfiguration || element instanceof ILaunchConfigurationType) {
- return getDebugModelImage(element);
- } else if (element instanceof ErrorConfig) {
- return invalidBuildToolImage;
- }
- return super.getImage(element);
- }
-
- public String getCommandText(ICommand command) {
- String builderID = command.getBuilderName();
- return getBuilderName(builderID);
- }
-
- private String getBuilderName(String builderID) {
- // Get the human-readable name of the builder
- IExtension extension = Platform.getExtensionRegistry().getExtension(ResourcesPlugin.PI_RESOURCES, ResourcesPlugin.PT_BUILDERS, builderID);
- String builderName;
- if (extension != null) {
- builderName = extension.getLabel();
- } else {
- builderName = MessageFormat.format(ExternalToolsUIMessages.getString("BuilderPropertyPage.missingBuilder"), new Object[] { builderID }); //$NON-NLS-1$
- }
- return builderName;
- }
-
- /**
- * Returns the image for build commands.
- *
- * @return the build command image
- */
- public Image getCommandImage() {
- return builderImage;
- }
-
- /**
- * Returns a text label for the given object from a debug
- * model presentation.
- * @param element the element
- * @return a text label from a debug model presentation
- */
- public String getDebugModelText(Object element) {
- if (element instanceof ILaunchConfiguration) {
- try {
- String disabledBuilderName= ((ILaunchConfiguration) element).getAttribute(IExternalToolConstants.ATTR_DISABLED_BUILDER, (String)null);
- if (disabledBuilderName != null) {
- //really a disabled builder wrapped as a launch configuration
- return getBuilderName(disabledBuilderName);
- }
- } catch (CoreException e) {
- }
- }
- return debugModelPresentation.getText(element);
- }
-
- /**
- * Returns an image for the given object from a debug
- * model presentation.
- * @param element the element
- * @return an image from a debug model presentation
- */
- public Image getDebugModelImage(Object element) {
- if (element instanceof ILaunchConfiguration) {
- try {
- String disabledBuilderName= ((ILaunchConfiguration) element).getAttribute(IExternalToolConstants.ATTR_DISABLED_BUILDER, (String)null);
- if (disabledBuilderName != null) {
- //really a disabled builder wrapped as a launch configuration
- return builderImage;
- }
- } catch (CoreException e) {
- }
- }
- return debugModelPresentation.getImage(element);
- }
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.IBaseLabelProvider#dispose()
- */
- public void dispose() {
- builderImage.dispose();
- invalidBuildToolImage.dispose();
- }
-} \ No newline at end of file
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/BuilderPropertyPage.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/BuilderPropertyPage.java
deleted file mode 100644
index 1eecf1761..000000000
--- a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/BuilderPropertyPage.java
+++ /dev/null
@@ -1,1144 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.externaltools.internal.ui;
-
-
-import java.lang.reflect.InvocationTargetException;
-import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.resources.ICommand;
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IProjectDescription;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.IWorkspaceDescription;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IExtension;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.debug.core.DebugPlugin;
-import org.eclipse.debug.core.ILaunchConfiguration;
-import org.eclipse.debug.core.ILaunchConfigurationListener;
-import org.eclipse.debug.core.ILaunchConfigurationType;
-import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
-import org.eclipse.debug.core.ILaunchManager;
-import org.eclipse.debug.ui.DebugUITools;
-import org.eclipse.jface.dialogs.ErrorDialog;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.dialogs.MessageDialogWithToggle;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.viewers.CheckStateChangedEvent;
-import org.eclipse.jface.viewers.CheckboxTableViewer;
-import org.eclipse.jface.viewers.ICheckStateListener;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.window.Window;
-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.graphics.Font;
-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.Display;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableItem;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.dialogs.ElementListSelectionDialog;
-import org.eclipse.ui.dialogs.PropertyPage;
-import org.eclipse.ui.externaltools.internal.launchConfigurations.ExternalToolsMainTab;
-import org.eclipse.ui.externaltools.internal.launchConfigurations.ExternalToolsUtil;
-import org.eclipse.ui.externaltools.internal.launchConfigurations.IgnoreWhiteSpaceComparator;
-import org.eclipse.ui.externaltools.internal.model.BuilderUtils;
-import org.eclipse.ui.externaltools.internal.model.ExternalToolBuilder;
-import org.eclipse.ui.externaltools.internal.model.ExternalToolsPlugin;
-import org.eclipse.ui.externaltools.internal.model.IExternalToolConstants;
-import org.eclipse.ui.externaltools.internal.model.IExternalToolsHelpContextIds;
-import org.eclipse.ui.externaltools.internal.model.IPreferenceConstants;
-import org.eclipse.ui.help.WorkbenchHelp;
-import org.eclipse.ui.progress.IProgressService;
-
-/**
- * Property page to add external tools builders.
- */
-public final class BuilderPropertyPage extends PropertyPage implements ICheckStateListener {
-
- //locally mark a command's enabled state so it can be processed correctly on performOK
- private static final String COMMAND_ENABLED= "CommandEnabled"; //$NON-NLS-1$
-
- private Button upButton, downButton, newButton, importButton, editButton, removeButton;
-
- private boolean userHasMadeChanges= false;
-
- private List configsToBeDeleted= null;
- private List commandsToBeDeleted= null;
-
- private CheckboxTableViewer viewer= null;
-
- private ILabelProvider labelProvider= new BuilderLabelProvider();
-
- /**
- * Error configs are objects representing entries pointing to
- * invalid launch configurations
- */
- public class ErrorConfig {
- private ICommand command;
- public ErrorConfig(ICommand command) {
- this.command= command;
- }
- public ICommand getCommand() {
- return command;
- }
- }
-
- /**
- * Collection of configurations created while the page is open.
- * Stored here so they can be deleted if the page is cancelled.
- */
- private List newConfigList= new ArrayList();
-
- private SelectionListener buttonListener= new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- handleButtonPressed((Button) e.widget);
- }
- };
-
- /**
- * Launch configuration listener which is responsible for updating items in
- * the tree when the user renames configurations in the dialog.
- *
- * This is necessary because when we tell the configuration dialog to open
- * on a launch config and the user renames that config, the old config (the
- * one in the tree) is made obsolete and a new config is created. This
- * listener hears when new configurations are created this way and replaces
- * the old configuration with the new.
- */
- private ILaunchConfigurationListener configurationListener= new ILaunchConfigurationListener() {
- /**
- * A launch configuration has been added. If this config has been
- * movedFrom a configuration in the tree, replace the old config with
- * the new.
- */
- public void launchConfigurationAdded(final ILaunchConfiguration configuration) {
- ILaunchManager manager= DebugPlugin.getDefault().getLaunchManager();
- final ILaunchConfiguration oldConfig= manager.getMovedFrom(configuration);
- if (oldConfig == null) {
- return;
- }
-
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- TableItem[] items= viewer.getTable().getItems();
- for (int i = 0; i < items.length; i++) {
- TableItem item = items[i];
- Object data= item.getData();
- if (data == oldConfig) {
- // Found the movedFrom config in the tree. Replace it with the new config
- item.setData(configuration);
- viewer.update(configuration, null);
- break;
- }
- }
- //Also replace the movedFrom config in the list of newly created configs
- if (newConfigList.remove(oldConfig)) {
- newConfigList.add(configuration);
- }
- }
- });
- }
- public void launchConfigurationChanged(ILaunchConfiguration configuration) {
- }
- public void launchConfigurationRemoved(ILaunchConfiguration configuration) {
- }
- };
-
- /**
- * Creates an initialized property page
- */
- public BuilderPropertyPage() {
- super();
- noDefaultAndApplyButton();
- }
-
- /**
- * Add the project's build to the table viewer.
- */
- private void addBuildersToTable() {
- IProject project = getInputProject();
- if (project == null) {
- return;
- }
- //add build spec entries to the table
- ICommand[] commands= null;
- try {
- commands = project.getDescription().getBuildSpec();
- } catch (CoreException e) {
- handleException(e);
- }
-
- boolean projectNeedsMigration= false;
- for (int i = 0; i < commands.length; i++) {
- String[] version= new String[] {""}; //$NON-NLS-1$
- ILaunchConfiguration config = BuilderUtils.configFromBuildCommandArgs(project, commands[i].getArguments(), version);
- if (BuilderUtils.VERSION_2_1.equals(version[0])) { //$NON-NLS-1$
- // Storing the .project file of a project with 2.1 configs, will
- // edit the file in a way that isn't backwards compatible.
- projectNeedsMigration= true;
- }
- Object element= null;
- if (config != null) {
- if (!config.isWorkingCopy() && !config.exists()) {
- IStatus status = new Status(IStatus.ERROR, IExternalToolConstants.PLUGIN_ID, 0, MessageFormat.format(ExternalToolsUIMessages.getString("BuilderPropertyPage.Exists"), new String[]{config.getLocation().toOSString()}), null); //$NON-NLS-1$
- ErrorDialog.openError(getShell(), ExternalToolsUIMessages.getString("BuilderPropertyPage.errorTitle"), //$NON-NLS-1$
- MessageFormat.format(ExternalToolsUIMessages.getString("BuilderPropertyPage.External_Tool_Builder_{0}_Not_Added_2"), new String[]{config.getName()}), //$NON-NLS-1$
- status);
- userHasMadeChanges= true;
- } else {
- element= config;
- }
- } else {
- String builderID = commands[i].getBuilderName();
- if (builderID.equals(ExternalToolBuilder.ID) && commands[i].getArguments().get(BuilderUtils.LAUNCH_CONFIG_HANDLE) != null) {
- // An invalid external tool entry.
- element= new ErrorConfig(commands[i]);
- } else {
- element= commands[i];
- }
- }
- if (element != null) {
- viewer.add(element);
- viewer.setChecked(element, isEnabled(element));
- }
- }
- if (projectNeedsMigration) {
- IPreferenceStore store= ExternalToolsPlugin.getDefault().getPreferenceStore();
- boolean prompt= store.getBoolean(IPreferenceConstants.PROMPT_FOR_PROJECT_MIGRATION);
- boolean proceed= true;
- if (prompt) {
- MessageDialogWithToggle dialog= MessageDialogWithToggle.openYesNoQuestion(getShell(), ExternalToolsUIMessages.getString("BuilderPropertyPage.0"), ExternalToolsUIMessages.getString("BuilderPropertyPage.1"), ExternalToolsUIMessages.getString("BuilderPropertyPage.2"), false, null, null); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- proceed= dialog.getReturnCode() == IDialogConstants.YES_ID;
- store.setValue(IPreferenceConstants.PROMPT_FOR_PROJECT_MIGRATION, !dialog.getToggleState());
- }
- if (!proceed) {
- // Open the page read-only
- viewer.getTable().setEnabled(false);
- downButton.setEnabled(false);
- editButton.setEnabled(false);
- importButton.setEnabled(false);
- newButton.setEnabled(false);
- removeButton.setEnabled(false);
- }
- }
- }
-
- /**
- * Creates and returns a button with the given label, id, and enablement.
- */
- private Button createButton(Composite parent, String label) {
- Button button = new Button(parent, SWT.PUSH);
- GridData data = new GridData();
- data.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
- button.setLayoutData(data);
- button.setFont(parent.getFont());
- button.setText(label);
- button.setEnabled(false);
- button.addSelectionListener(buttonListener);
- return button;
- }
-
- /* (non-Javadoc)
- * Method declared on PreferencePage.
- */
- protected Control createContents(Composite parent) {
-
- WorkbenchHelp.setHelp(parent, IExternalToolsHelpContextIds.EXTERNAL_TOOLS_BUILDER_PROPERTY_PAGE);
-
- Font font = parent.getFont();
-
- Composite topLevel = new Composite(parent, SWT.NONE);
- GridLayout layout = new GridLayout();
- layout.marginHeight = 0;
- layout.marginWidth = 0;
- topLevel.setLayout(layout);
- topLevel.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- Label description = new Label(topLevel, SWT.WRAP);
- description.setText(ExternalToolsUIMessages.getString("BuilderPropertyPage.description")); //$NON-NLS-1$
- description.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- description.setFont(font);
-
- Composite tableAndButtons = new Composite(topLevel, SWT.NONE);
- tableAndButtons.setLayoutData(new GridData(GridData.FILL_BOTH));
- layout = new GridLayout();
- layout.marginHeight = 0;
- layout.marginWidth = 0;
- layout.numColumns = 2;
- tableAndButtons.setLayout(layout);
-
- // table of builders and tools
- viewer= CheckboxTableViewer.newCheckList(tableAndButtons, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);
- viewer.setLabelProvider(labelProvider);
- viewer.addCheckStateListener(this);
- Table builderTable= viewer.getTable();
- builderTable.setLayoutData(new GridData(GridData.FILL_BOTH));
- builderTable.setFont(font);
- builderTable.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- handleTableSelectionChanged();
- }
- });
-
- builderTable.addListener(SWT.MouseDoubleClick, new Listener() {
- public void handleEvent(Event event) {
- handleEditButtonPressed();
- }
- });
-
- //button area
- Composite buttonArea = new Composite(tableAndButtons, SWT.NONE);
- layout = new GridLayout();
- layout.marginHeight = 0;
- layout.marginWidth = 0;
- buttonArea.setLayout(layout);
- buttonArea.setFont(font);
- buttonArea.setLayoutData(new GridData(GridData.FILL_VERTICAL));
- newButton = createButton(buttonArea, ExternalToolsUIMessages.getString("BuilderPropertyPage.newButton")); //$NON-NLS-1$
- importButton = createButton(buttonArea, ExternalToolsUIMessages.getString("BuilderPropertyPage.&Import..._3")); //$NON-NLS-1$
- editButton = createButton(buttonArea, ExternalToolsUIMessages.getString("BuilderPropertyPage.editButton")); //$NON-NLS-1$
- removeButton = createButton(buttonArea, ExternalToolsUIMessages.getString("BuilderPropertyPage.removeButton")); //$NON-NLS-1$
- new Label(buttonArea, SWT.LEFT);
- upButton = createButton(buttonArea, ExternalToolsUIMessages.getString("BuilderPropertyPage.upButton")); //$NON-NLS-1$
- downButton = createButton(buttonArea, ExternalToolsUIMessages.getString("BuilderPropertyPage.downButton")); //$NON-NLS-1$
-
- newButton.setEnabled(true);
- importButton.setEnabled(true);
-
- //populate widget contents
- addBuildersToTable();
-
- return topLevel;
- }
-
- /**
- * Turns autobuilding on or off in the workspace.
- */
- private void setAutobuild(boolean newState) throws CoreException {
- IWorkspace workspace= ResourcesPlugin.getWorkspace();
- IWorkspaceDescription wsDescription= workspace.getDescription();
- boolean oldState= wsDescription.isAutoBuilding();
- if (oldState != newState) {
- wsDescription.setAutoBuilding(newState);
- workspace.setDescription(wsDescription);
- }
- }
-
- /**
- * Returns the project that is the input for this property page,
- * or <code>null</code>.
- */
- private IProject getInputProject() {
- IAdaptable element = getElement();
- if (element instanceof IProject) {
- return (IProject) element;
- }
- Object resource = element.getAdapter(IResource.class);
- if (resource instanceof IProject) {
- return (IProject) resource;
- }
- return null;
- }
-
- /**
- * One of the buttons has been pressed, act accordingly.
- */
- private void handleButtonPressed(Button button) {
- if (button == newButton) {
- handleNewButtonPressed();
- } else if (button == importButton) {
- handleImportButtonPressed();
- } else if (button == editButton) {
- handleEditButtonPressed();
- } else if (button == removeButton) {
- handleRemoveButtonPressed();
- } else if (button == upButton) {
- moveSelectionUp();
- } else if (button == downButton) {
- moveSelectionDown();
- }
- handleTableSelectionChanged();
- viewer.getTable().setFocus();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ICheckStateListener#checkStateChanged(org.eclipse.jface.viewers.CheckStateChangedEvent)
- */
- public void checkStateChanged(CheckStateChangedEvent event) {
- Object element= event.getElement();
- if (element instanceof ILaunchConfiguration) {
- enableLaunchConfiguration((ILaunchConfiguration) element, event.getChecked());
- } else if (element instanceof ICommand) {
- if (MessageDialog.openConfirm(getShell(), ExternalToolsUIMessages.getString("BuilderPropertyPage.6"), ExternalToolsUIMessages.getString("BuilderPropertyPage.7"))) { //$NON-NLS-1$ //$NON-NLS-2$
- enableCommand((ICommand)element, event.getChecked());
- } else {
- viewer.removeCheckStateListener(this);
- viewer.setChecked(element, true);
- viewer.addCheckStateListener(this);
- }
- }
- }
-
- private void enableLaunchConfiguration(ILaunchConfiguration configuration, boolean enable) {
- ILaunchConfigurationWorkingCopy workingCopy= null;
- try {
- if (configuration instanceof ILaunchConfigurationWorkingCopy) {
- workingCopy = (ILaunchConfigurationWorkingCopy) configuration;
- } else {
- // Replace the config with a working copy
- TableItem[] items= viewer.getTable().getItems();
- for (int i = 0; i < items.length; i++) {
- TableItem item = items[i];
- if (item.getData() == configuration) {
- workingCopy = configuration.getWorkingCopy();
- item.setData(workingCopy);
- }
- }
- }
- if (workingCopy != null) {
- workingCopy.setAttribute(IExternalToolConstants.ATTR_BUILDER_ENABLED, enable);
- }
- } catch (CoreException e) {
- return;
- }
- userHasMadeChanges= true;
- }
-
- private void enableCommand(ICommand command, boolean enable) {
- Map args= command.getArguments();
- if (args == null) {
- args= new HashMap(1);
- }
- args.put(COMMAND_ENABLED, Boolean.valueOf(enable));
- command.setArguments(args);
- userHasMadeChanges= true;
- }
-
- /**
- * The user has pressed the import button. Prompt them to select a
- * configuration to import from the workspace.
- */
- private void handleImportButtonPressed() {
- ILaunchManager manager= DebugPlugin.getDefault().getLaunchManager();
- List toolTypes= getConfigurationTypes(IExternalToolConstants.ID_EXTERNAL_TOOLS_LAUNCH_CATEGORY);
- List configurations= new ArrayList();
- Iterator iter= toolTypes.iterator();
- while (iter.hasNext()) {
- try {
- ILaunchConfiguration[] configs= manager.getLaunchConfigurations((ILaunchConfigurationType) iter.next());
- for (int i = 0; i < configs.length; i++) {
- configurations.add(configs[i]);
- }
- } catch (CoreException e) {
- }
- }
- ElementListSelectionDialog dialog= new ElementListSelectionDialog(getShell(), new BuilderLabelProvider());
- dialog.setTitle(ExternalToolsUIMessages.getString("BuilderPropertyPage.4")); //$NON-NLS-1$
- dialog.setMessage(ExternalToolsUIMessages.getString("BuilderPropertyPage.5")); //$NON-NLS-1$
- dialog.setElements(configurations.toArray());
- if (dialog.open() == Window.CANCEL) {
- return;
- }
- Object results[]= dialog.getResult();
- if (results.length == 0) { //OK pressed with nothing selected
- return;
- }
- ILaunchConfiguration config= (ILaunchConfiguration) results[0];
- ILaunchConfiguration newConfig= null;
- boolean wasAutobuilding= ResourcesPlugin.getWorkspace().getDescription().isAutoBuilding();
- try {
- setAutobuild(false);
- newConfig= BuilderUtils.duplicateConfiguration(getInputProject(), config);
- } catch (CoreException e) {
- handleException(e);
- } finally {
- try {
- setAutobuild(wasAutobuilding);
- } catch (CoreException e) {
- handleException(e);
- }
- }
- if (newConfig != null) {
- userHasMadeChanges= true;
- viewer.add(newConfig);
- viewer.setChecked(newConfig, isEnabled(newConfig));
- newConfigList.add(newConfig);
- }
- }
-
- /**
- * The user has pressed the remove button. Delete the selected builder.
- */
- private void handleRemoveButtonPressed() {
- IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
- if (selection != null) {
- int numSelected= selection.size();
- userHasMadeChanges= true;
- Iterator iterator= selection.iterator();
- while (iterator.hasNext()) {
- Object item= iterator.next();
- if (item instanceof ILaunchConfiguration) {
- if (configsToBeDeleted == null) {
- configsToBeDeleted= new ArrayList(numSelected);
- }
- configsToBeDeleted.add(item);
- } else if (item instanceof ICommand) {
- if (commandsToBeDeleted == null) {
- commandsToBeDeleted= new ArrayList(numSelected);
- }
- commandsToBeDeleted.add(item);
- }
- viewer.remove(item);
- }
- }
- }
-
- /**
- * The user has pressed the new button. Create a new configuration and open
- * the launch configuration edit dialog on the new config.
- */
- private void handleNewButtonPressed() {
- ILaunchConfigurationType type = promptForConfigurationType();
- if (type == null) {
- return;
- }
- boolean wasAutobuilding= ResourcesPlugin.getWorkspace().getDescription().isAutoBuilding();
- try {
- ILaunchConfigurationWorkingCopy workingCopy = null;
- String name= DebugPlugin.getDefault().getLaunchManager().generateUniqueLaunchConfigurationNameFrom(ExternalToolsUIMessages.getString("BuilderPropertyPage.New_Builder_7")); //$NON-NLS-1$
- workingCopy = type.newInstance(BuilderUtils.getBuilderFolder(getInputProject(), true), name);
-
- StringBuffer buffer= new StringBuffer(IExternalToolConstants.BUILD_TYPE_FULL);
- buffer.append(',');
- buffer.append(IExternalToolConstants.BUILD_TYPE_INCREMENTAL);
- buffer.append(',');
- workingCopy.setAttribute(IExternalToolConstants.ATTR_RUN_BUILD_KINDS, buffer.toString());
- workingCopy.setAttribute(ExternalToolsMainTab.FIRST_EDIT, true);
- ILaunchConfiguration config = null;
- setAutobuild(false);
- config = workingCopy.doSave();
- //needs to be added here in case the user hits apply in the edit dialog
- //then we can correctly update the list with the new config.
- newConfigList.add(config);
- int code= editConfiguration(config);
- if (code == Window.CANCEL) {
- // If the user cancelled, delete the newly created config
- newConfigList.remove(config);
- config.delete();
- } else {
- userHasMadeChanges= true;
- //retrieve the last "new" config
- //may have been changed by the user pressing apply in the edit dialog
- config= (ILaunchConfiguration)newConfigList.get(newConfigList.size() - 1);
- viewer.add(config);
- viewer.setChecked(config, isEnabled(config));
- }
- } catch (CoreException e) {
- handleException(e);
- } finally {
- try {
- setAutobuild(wasAutobuilding);
- } catch (CoreException e) {
- handleException(e);
- }
- }
- }
-
- /**
- * Prompts the user to edit the given launch configuration. Returns the
- * return code from opening the launch configuration dialog.
- */
- private int editConfiguration(ILaunchConfiguration config) {
- ILaunchManager manager= DebugPlugin.getDefault().getLaunchManager();
- manager.addLaunchConfigurationListener(configurationListener);
- int code= DebugUITools.openLaunchConfigurationPropertiesDialog(getShell(), config, IExternalToolConstants.ID_EXTERNAL_TOOLS_BUILDER_LAUNCH_GROUP);
- manager.removeLaunchConfigurationListener(configurationListener);
- return code;
- }
-
- /**
- * Prompts the user to choose a launch configuration type to create and
- * returns the type the user selected or <code>null</code> if the user
- * cancelled.
- *
- * @return the configuration type selected by the user or <code>null</code>
- * if the user cancelled.
- */
- private ILaunchConfigurationType promptForConfigurationType() {
- List externalToolTypes= getConfigurationTypes(IExternalToolConstants.ID_EXTERNAL_TOOLS_BUILDER_LAUNCH_CATEGORY);
-
- ElementListSelectionDialog dialog = new ElementListSelectionDialog(getShell(), new BuilderLabelProvider());
- dialog.setElements(externalToolTypes.toArray());
- dialog.setMultipleSelection(false);
- dialog.setTitle(ExternalToolsUIMessages.getString("BuilderPropertyPage.Choose_configuration_type_8")); //$NON-NLS-1$
- dialog.setMessage(ExternalToolsUIMessages.getString("BuilderPropertyPage.Choose_an_external_tool_type_to_create_9")); //$NON-NLS-1$
- dialog.open();
- Object result[] = dialog.getResult();
- if (result == null || result.length == 0) {
- return null;
- }
- return (ILaunchConfigurationType) result[0];
- }
-
- /**
- * Returns the launch configuration types of the given category
- */
- private List getConfigurationTypes(String category) {
- ILaunchConfigurationType types[] = DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurationTypes();
- List externalToolTypes = new ArrayList();
- for (int i = 0; i < types.length; i++) {
- ILaunchConfigurationType configurationType = types[i];
- if (category.equals(configurationType.getCategory())) {
- externalToolTypes.add(configurationType);
- }
- }
- return externalToolTypes;
- }
-
- /**
- * The user has pressed the edit button or double-clicked. Open the launch configuration edit
- * dialog on the selection after migrating the tool if necessary.
- */
- private void handleEditButtonPressed() {
- TableItem[] items= viewer.getTable().getSelection();
- if (items.length == 0) {
- return;
- }
- TableItem selection= items[0];
- if (selection != null) {
- Object data = selection.getData();
- if (data instanceof ILaunchConfiguration) {
- ILaunchConfiguration config= (ILaunchConfiguration) data;
- if (BuilderUtils.isUnmigratedConfig(config)) {
- if (!shouldProceedWithMigration()) {
- return;
- }
- try {
- config= BuilderUtils.migrateBuilderConfiguration(getInputProject(), (ILaunchConfigurationWorkingCopy) config);
- } catch (CoreException e) {
- handleException(e);
- return;
- }
- // Replace the working copy in the table with the migrated configuration
- selection.setData(config);
- }
- userHasMadeChanges= true;
- boolean wasAutobuilding= ResourcesPlugin.getWorkspace().getDescription().isAutoBuilding();
- try {
- setAutobuild(false);
- editConfiguration(config);
- } catch (CoreException e) {
- handleException(e);
- } finally {
- try {
- setAutobuild(wasAutobuilding);
- } catch (CoreException e) {
- handleException(e);
- }
- }
- }
- }
- }
-
- /**
- * Prompts the user to proceed with the migration of a project builder from
- * the old format to the new, launch configuration-based, format and returns
- * whether or not the user wishes to proceed with the migration.
- *
- * @return boolean whether or not the user wishes to proceed with migration
- */
- private boolean shouldProceedWithMigration() {
- if (!ExternalToolsPlugin.getDefault().getPreferenceStore().getBoolean(IPreferenceConstants.PROMPT_FOR_TOOL_MIGRATION)) {
- // User has asked not to be prompted
- return true;
- }
- // Warn the user that editing an old config will cause storage migration.
- MessageDialogWithToggle dialog= MessageDialogWithToggle.openYesNoQuestion(getShell(),
- ExternalToolsUIMessages.getString("BuilderPropertyPage.Migrate_project_builder_10"), //$NON-NLS-1$
- ExternalToolsUIMessages.getString("BuilderPropertyPage.Not_Support"), //$NON-NLS-1$
- ExternalToolsUIMessages.getString("BuilderPropertyPage.Prompt"), //$NON-NLS-1$
- false,
- ExternalToolsPlugin.getDefault().getPreferenceStore(),
- IPreferenceConstants.PROMPT_FOR_TOOL_MIGRATION);
- return dialog.getReturnCode() == IDialogConstants.YES_ID;
- }
-
- /**
- * Handles unexpected internal exceptions
- */
- private void handleException(Exception e) {
- IStatus status;
- if (e instanceof CoreException) {
- status = ((CoreException) e).getStatus();
- } else {
- status = new Status(IStatus.ERROR, IExternalToolConstants.PLUGIN_ID, 0, ExternalToolsUIMessages.getString("BuilderPropertyPage.statusMessage"), e); //$NON-NLS-1$
- }
- ErrorDialog.openError(getShell(), ExternalToolsUIMessages.getString("BuilderPropertyPage.errorTitle"), //$NON-NLS-1$
- ExternalToolsUIMessages.getString("BuilderPropertyPage.errorMessage"), //$NON-NLS-1$
- status);
- }
-
- /**
- * The user has selected a different builder in table.
- * Update button enablement.
- */
- private void handleTableSelectionChanged() {
- newButton.setEnabled(true);
- Table builderTable= viewer.getTable();
- TableItem[] items = builderTable.getSelection();
- boolean validSelection= items != null && items.length > 0;
- boolean enableEdit= validSelection;
- boolean enableRemove= validSelection;
- boolean enableUp= validSelection;
- boolean enableDown= validSelection;
- if (validSelection) {
- if (items.length > 1) {
- enableEdit= false;
- }
- int indices[]= builderTable.getSelectionIndices();
- int max = builderTable.getItemCount();
- enableUp= indices[0] != 0;
- enableDown= indices[indices.length - 1] < max - 1;
- for (int i = 0; i < items.length; i++) {
- TableItem item = items[i];
- Object data= item.getData();
- if (data instanceof ILaunchConfiguration) {
- ILaunchConfiguration config= (ILaunchConfiguration)data;
- String builderName= null;
- try {
- builderName = config.getAttribute(IExternalToolConstants.ATTR_DISABLED_BUILDER, (String)null);
- } catch (CoreException e) {
- }
- if (builderName != null) {
- //do not allow "wrapped" builders to be removed or edited if they are valid
- IExtension ext= Platform.getExtensionRegistry().getExtension(ResourcesPlugin.PI_RESOURCES, ResourcesPlugin.PT_BUILDERS, builderName);
- enableEdit= false;
- enableRemove= ext == null;
- }
- } else {
- enableEdit= false;
-
- if (data instanceof ErrorConfig) {
- continue;
- }
- IExtension ext= Platform.getExtensionRegistry().getExtension(ResourcesPlugin.PI_RESOURCES, ResourcesPlugin.PT_BUILDERS, ((ICommand)data).getBuilderName());
- enableRemove= ext == null;
- break;
- }
- }
- }
- editButton.setEnabled(enableEdit);
- removeButton.setEnabled(enableRemove);
- upButton.setEnabled(enableUp);
- downButton.setEnabled(enableDown);
- }
-
- /**
- * Returns whether the given element (command or launch config)
- * is enabled.
- *
- * @param element the element
- * @return whether the given element is enabled
- */
- private boolean isEnabled(Object element) {
- if (element instanceof ICommand) {
- Boolean enabled= (Boolean)((ICommand) element).getArguments().get(COMMAND_ENABLED);
- if (enabled != null) {
- return enabled.booleanValue();
- }
- } else if (element instanceof ILaunchConfiguration) {
- try {
- return ExternalToolsUtil.isBuilderEnabled((ILaunchConfiguration) element);
- } catch (CoreException e) {
- }
- } else if (element instanceof ErrorConfig) {
- return false;
- }
- return true;
- }
-
- /**
- * Moves an entry in the builder table to the given index.
- */
- private void move(TableItem item, int index) {
- userHasMadeChanges= true;
- Object data = item.getData();
- item.dispose();
- viewer.insert(data, index);
- viewer.setChecked(data, isEnabled(data));
- }
-
- /**
- * Move the current selection in the build list down.
- */
- private void moveSelectionDown() {
- Table builderTable= viewer.getTable();
- int indices[]= builderTable.getSelectionIndices();
- if (indices.length < 1) {
- return;
- }
- int newSelection[]= new int[indices.length];
- int max= builderTable.getItemCount() - 1;
- for (int i = indices.length - 1; i >= 0; i--) {
- int index= indices[i];
- if (index < max) {
- move (builderTable.getItem(index), index + 1);
- newSelection[i]= index + 1;
- }
- }
- builderTable.setSelection(newSelection);
- }
-
- /**
- * Move the current selection in the build list up.
- */
- private void moveSelectionUp() {
- Table builderTable= viewer.getTable();
- int indices[]= builderTable.getSelectionIndices();
- int newSelection[]= new int[indices.length];
- for (int i = 0; i < indices.length; i++) {
- int index= indices[i];
- if (index > 0) {
- move (builderTable.getItem(index), index - 1);
- newSelection[i]= index - 1;
- }
- }
- builderTable.setSelection(newSelection);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.preference.IPreferencePage#performOk()
- */
- public boolean performOk() {
- if (!userHasMadeChanges) {
- return super.performOk();
- }
- userHasMadeChanges= false;
- Table builderTable= viewer.getTable();
- int numCommands = builderTable.getItemCount();
- final Object[] itemData= new Object[numCommands];
- for (int i = 0; i < numCommands; i++) {
- itemData[i]= builderTable.getItem(i).getData();
- }
- IRunnableWithProgress runnable= new IRunnableWithProgress() {
- public void run(IProgressMonitor monitor)
- throws InvocationTargetException, InterruptedException {
- doPerformOk(monitor, itemData);
- if (monitor.isCanceled()) {
- throw new InterruptedException();
- }
- }
- };
-
- IProgressService service= PlatformUI.getWorkbench().getProgressService();
- try {
- service.busyCursorWhile(runnable);
- } catch (InvocationTargetException e) {
- return false;
- } catch (InterruptedException e) {
- return false;
- }
- return super.performOk();
- }
-
- private void doPerformOk(IProgressMonitor monitor, Object[] itemData) {
- if (monitor.isCanceled()) {
- return;
- }
-
- IProject project = getInputProject();
- //get all the build commands
- int numCommands = itemData.length;
- monitor.beginTask(ExternalToolsUIMessages.getString("BuilderPropertyPage.3"), numCommands + 1); //$NON-NLS-1$
- List possibleCommands= new ArrayList(numCommands);
- for (int i = 0; i < numCommands; i++) {
- Object data = itemData[i];
- if (data instanceof ICommand) {
- if (commandsToBeDeleted != null && commandsToBeDeleted.contains(data)) {
- //command specified to be removed
- data= null;
- }
- ICommand command= (ICommand)data;
- Map args= command.getArguments();
- Boolean enabled= (Boolean)args.get(COMMAND_ENABLED);
- if (enabled != null && enabled.equals(Boolean.FALSE)) {
- ILaunchConfiguration config= disableCommand(command);
- if (config != null) {
- data= BuilderUtils.commandFromLaunchConfig(project,config);
- }
- } else {
- args.remove(COMMAND_ENABLED);
- command.setArguments(args);
- }
- } else if (data instanceof ILaunchConfiguration) {
- ILaunchConfiguration config= (ILaunchConfiguration) data;
- String disabledBuilderName;
- try {
- disabledBuilderName = config.getAttribute(IExternalToolConstants.ATTR_DISABLED_BUILDER, (String)null);
- if (disabledBuilderName != null && ExternalToolsUtil.isBuilderEnabled(config)) {
- possibleCommands.add(translateBackToCommand(config, project));
- continue;
- }
- } catch (CoreException e1) {
- }
-
- if (!BuilderUtils.isUnmigratedConfig(config) && (config instanceof ILaunchConfigurationWorkingCopy)) {
- ILaunchConfigurationWorkingCopy workingCopy= ((ILaunchConfigurationWorkingCopy) config);
- // Save any changes to the config (such as enable/disable)
- if (workingCopy.isDirty()) {
- try {
- workingCopy.doSave();
- } catch (CoreException e) {
- MessageDialog.openError(getShell(), ExternalToolsUIMessages.getString("BuilderPropertyPage.39"), MessageFormat.format(ExternalToolsUIMessages.getString("BuilderPropertyPage.40"), new String[] {workingCopy.getName()})); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
- }
- data= BuilderUtils.commandFromLaunchConfig(project, config);
- } else if (data instanceof ErrorConfig) {
- data= ((ErrorConfig) data).getCommand();
- }
- if (data != null) {
- possibleCommands.add(data);
- }
- monitor.worked(1);
- }
- ICommand[] commands= new ICommand[possibleCommands.size()];
- possibleCommands.toArray(commands);
- if (checkCommandsForChange(commands)) {
- //set the build spec
- try {
- IProjectDescription desc = project.getDescription();
- desc.setBuildSpec(commands);
- project.setDescription(desc, IResource.FORCE, monitor);
- } catch (CoreException e) {
- handleException(e);
- }
- }
-
- if (configsToBeDeleted != null) {
- deleteConfigurations();
- }
- monitor.done();
- }
-
- private void checkBuilderFolder() {
- try {
- IFolder builderFolder= BuilderUtils.getBuilderFolder(getInputProject(), false);
- if (builderFolder != null && builderFolder.exists() && builderFolder.members().length == 0) {
- // All files in the builder folder have been deleted. Clean up
- builderFolder.delete(true, false, null);
- }
- } catch (CoreException e) {
- handleException(e);
- }
- }
-
- /**
- * A non-external tool builder builder was disabled.
- * It has been re-enabled. Translate the disabled external tool builder launch configuration
- * wrapper back into the full fledged builder command.
- */
- private ICommand translateBackToCommand(ILaunchConfiguration config, IProject project) {
- try {
- ICommand newCommand = project.getDescription().newCommand();
- String builderName= config.getAttribute(IExternalToolConstants.ATTR_DISABLED_BUILDER, (String)null);
- Map args= config.getAttribute(IExternalToolConstants.ATTR_TOOL_ARGUMENTS, new HashMap(0));
-
- newCommand.setBuilderName(builderName);
- newCommand.setArguments(args);
- if (configsToBeDeleted == null) {
- configsToBeDeleted= new ArrayList();
- }
- configsToBeDeleted.add(config);
- return newCommand;
- } catch (CoreException exception) {
- MessageDialog.openError(getShell(), ExternalToolsUIMessages.getString("BuilderPropertyPage.13"), ExternalToolsUIMessages.getString("BuilderPropertyPage.error")); //$NON-NLS-1$ //$NON-NLS-2$
- return null;
- }
- }
-
- /**
- * Disables a builder by wrappering the builder command as a disabled external tool builder.
- * The details of the command is persisted in the launch configuration.
- */
- private ILaunchConfiguration disableCommand(ICommand command) {
- Map arguments= command.getArguments();
- if (arguments != null) {
- arguments.remove(COMMAND_ENABLED);
- }
- List externalToolTypes= getConfigurationTypes(IExternalToolConstants.ID_EXTERNAL_TOOLS_BUILDER_LAUNCH_CATEGORY);
- if (externalToolTypes.size() == 0) {
- return null;
- }
- ILaunchConfigurationType type= (ILaunchConfigurationType)externalToolTypes.get(0);
- if (type == null) {
- return null;
- }
- boolean wasAutobuilding= ResourcesPlugin.getWorkspace().getDescription().isAutoBuilding();
- try {
- ILaunchConfigurationWorkingCopy workingCopy = null;
- String builderName = command.getBuilderName();
- String name= DebugPlugin.getDefault().getLaunchManager().generateUniqueLaunchConfigurationNameFrom(builderName);
- workingCopy = type.newInstance(BuilderUtils.getBuilderFolder(getInputProject(), true), name);
-
- workingCopy.setAttribute(IExternalToolConstants.ATTR_DISABLED_BUILDER, builderName);
- if (arguments != null) {
- workingCopy.setAttribute(IExternalToolConstants.ATTR_TOOL_ARGUMENTS, arguments);
- }
- workingCopy.setAttribute(IExternalToolConstants.ATTR_BUILDER_ENABLED, false);
- ILaunchConfiguration config = null;
- setAutobuild(false);
- config = workingCopy.doSave();
- return config;
- } catch (CoreException e) {
- handleException(e);
- } finally {
- try {
- setAutobuild(wasAutobuilding);
- } catch (CoreException e) {
- handleException(e);
- }
- }
- return null;
- }
-
- private void deleteConfigurations() {
- boolean wasAutobuilding= ResourcesPlugin.getWorkspace().getDescription().isAutoBuilding();
- try {
- setAutobuild(false);
-
- Iterator itr= configsToBeDeleted.iterator();
- while (itr.hasNext()) {
- ILaunchConfiguration element = (ILaunchConfiguration) itr.next();
- element.delete();
- }
-
- checkBuilderFolder();
- } catch (CoreException e) {
- handleException(e);
- } finally {
- try {
- setAutobuild(wasAutobuilding);
- } catch (CoreException e) {
- handleException(e);
- }
- }
- }
-
- /**
- * Returns whether any of the commands have changed.
- */
- private boolean checkCommandsForChange(ICommand[] newCommands) {
- try {
- ICommand[] oldCommands = getInputProject().getDescription().getBuildSpec();
- if (oldCommands.length != newCommands.length) {
- return true;
- }
- IgnoreWhiteSpaceComparator comparator= new IgnoreWhiteSpaceComparator();
- for (int i = 0; i < oldCommands.length; i++) {
- ICommand oldCommand = oldCommands[i];
- ICommand newCommand= newCommands[i];
- String oldName= oldCommand.getBuilderName();
- String newName= newCommand.getBuilderName();
- if (oldName == null && newName != null) {
- return true;
- }
-
- if(oldName != null && !oldName.equals(newName)) {
- return true;
- }
- Map oldArgs= oldCommand.getArguments();
- Map newArgs= newCommand.getArguments();
- if (oldArgs == null && newArgs != null) {
- return true;
- }
- if (oldArgs == null && newArgs == null) {
- continue;
- }
- if(oldArgs.size() != newArgs.size()) {
- return true;
- }
- Iterator keySet= oldArgs.keySet().iterator();
- while (keySet.hasNext()) {
- Object key = keySet.next();
- Object oldArg= oldArgs.get(key);
- Object newArg= newArgs.get(key);
- if (oldArg instanceof String && newArg instanceof String) {
- if (comparator.compare(oldArg, newArg) != 0) {
- return true;
- }
- } else if (!oldArg.equals(newArg)){
- return true;
- }
- }
- }
- } catch (CoreException ce) {
- return true;
- }
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.preference.IPreferencePage#performCancel()
- */
- public boolean performCancel() {
- Iterator iter= newConfigList.iterator();
- while (iter.hasNext()) {
- try {
- ((ILaunchConfiguration) iter.next()).delete();
- } catch (CoreException e) {
- handleException(e);
- }
- }
-
- checkBuilderFolder();
-
- //remove the local marking of the enabled state of the commands
- Table builderTable= viewer.getTable();
- int numCommands = builderTable.getItemCount();
- for (int i = 0; i < numCommands; i++) {
- Object data = builderTable.getItem(i).getData();
- if (data instanceof ICommand) {
- ICommand command= (ICommand)data;
- Map args= command.getArguments();
- args.remove(COMMAND_ENABLED);
- command.setArguments(args);
- }
- }
- return super.performCancel();
- }
-} \ No newline at end of file
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/ExternalToolsPreferencePage.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/ExternalToolsPreferencePage.java
deleted file mode 100644
index a13cba11f..000000000
--- a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/ExternalToolsPreferencePage.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.externaltools.internal.ui;
-
-
-import org.eclipse.jface.preference.PreferencePage;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchPreferencePage;
-import org.eclipse.ui.externaltools.internal.model.ExternalToolsPlugin;
-import org.eclipse.ui.externaltools.internal.model.IExternalToolsHelpContextIds;
-import org.eclipse.ui.externaltools.internal.model.IPreferenceConstants;
-import org.eclipse.ui.help.WorkbenchHelp;
-
-/**
- * Preference page that allows the user to customize external tools
- */
-public class ExternalToolsPreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
-
- private Button promptForToolMigrationButton;
- private Button promptForProjectMigrationButton;
-
- public ExternalToolsPreferencePage() {
- setPreferenceStore(ExternalToolsPlugin.getDefault().getPreferenceStore());
- setDescription(ExternalToolsUIMessages.getString("ExternalToolsPreferencePage.External_tool_project_builders_migration_2")); //$NON-NLS-1$
- }
-
- /**
- * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
- */
- protected Control createContents(Composite parent) {
- WorkbenchHelp.setHelp(parent, IExternalToolsHelpContextIds.EXTERNAL_TOOLS_PREFERENCE_PAGE);
- //The main composite
- Composite composite = new Composite(parent, SWT.NULL);
- GridLayout layout = new GridLayout();
- layout.marginHeight=0;
- layout.marginWidth=0;
- composite.setLayout(layout);
- composite.setFont(parent.getFont());
-
- promptForToolMigrationButton= createCheckButton(composite, ExternalToolsUIMessages.getString("ExternalToolsPreferencePage.Prompt_before_migrating_3"), IPreferenceConstants.PROMPT_FOR_TOOL_MIGRATION); //$NON-NLS-1$
- promptForProjectMigrationButton= createCheckButton(composite, ExternalToolsUIMessages.getString("ExternalToolsPreferencePage.1"), IPreferenceConstants.PROMPT_FOR_PROJECT_MIGRATION); //$NON-NLS-1$
-
- applyDialogFont(composite);
-
- return composite;
- }
-
- /**
- * Returns a new check button with the given label for the given preference.
- */
- private Button createCheckButton(Composite parent, String label, String preferenceKey) {
- Button button= new Button(parent, SWT.CHECK | SWT.LEFT);
- button.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
- button.setFont(parent.getFont());
- button.setText(label);
- button.setSelection(getPreferenceStore().getBoolean(preferenceKey));
- return button;
- }
-
- /**
- * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
- */
- public void init(IWorkbench workbench) {
- }
-
- /**
- * @see org.eclipse.jface.preference.PreferencePage#performOk()
- */
- public boolean performOk() {
- getPreferenceStore().setValue(IPreferenceConstants.PROMPT_FOR_TOOL_MIGRATION, promptForToolMigrationButton.getSelection());
- getPreferenceStore().setValue(IPreferenceConstants.PROMPT_FOR_PROJECT_MIGRATION, promptForProjectMigrationButton.getSelection());
- return super.performOk();
- }
-
- /**
- * @see org.eclipse.jface.preference.PreferencePage#performDefaults()
- */
- protected void performDefaults() {
- promptForToolMigrationButton.setSelection(getPreferenceStore().getDefaultBoolean(IPreferenceConstants.PROMPT_FOR_TOOL_MIGRATION));
- promptForToolMigrationButton.setSelection(getPreferenceStore().getDefaultBoolean(IPreferenceConstants.PROMPT_FOR_PROJECT_MIGRATION));
- super.performDefaults();
- }
-}
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/ExternalToolsUIMessages.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/ExternalToolsUIMessages.java
deleted file mode 100644
index 576ea366c..000000000
--- a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/ExternalToolsUIMessages.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.externaltools.internal.ui;
-
-
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-public final class ExternalToolsUIMessages {
- private static final String BUNDLE_NAME= "org.eclipse.ui.externaltools.internal.ui.ExternalToolsUIMessages"; //$NON-NLS-1$
-
- private static final ResourceBundle RESOURCE_BUNDLE =
- ResourceBundle.getBundle(BUNDLE_NAME);
-
- private ExternalToolsUIMessages(){
- // prevent instantiation of class
- }
-
- /**
- * Returns the message with the given key in
- * the resource bundle. If there isn't any value under
- * the given key, the key is returned.
- *
- * @param key the message name
- * @return the message
- */
- public static String getString(String key) {
- try {
- return RESOURCE_BUNDLE.getString(key);
- } catch (MissingResourceException e) {
- return '!' + key + '!';
- }
- }
-}
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/ExternalToolsUIMessages.properties b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/ExternalToolsUIMessages.properties
deleted file mode 100644
index 4827229f0..000000000
--- a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/ExternalToolsUIMessages.properties
+++ /dev/null
@@ -1,54 +0,0 @@
-###############################################################################
-# Copyright (c) 2000, 2004 IBM Corporation and others.
-# All rights reserved. This program and the accompanying materials
-# are 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:
-# IBM Corporation - initial API and implementation
-###############################################################################
-
-BuilderPropertyPage.description = Configure the builders for the &project:
-BuilderPropertyPage.newButton = &New...
-BuilderPropertyPage.editButton = &Edit...
-BuilderPropertyPage.removeButton = &Remove
-BuilderPropertyPage.upButton = &Up
-BuilderPropertyPage.downButton = &Down
-BuilderPropertyPage.statusMessage = Internal error
-BuilderPropertyPage.errorTitle = External Tool Builder Problem
-BuilderPropertyPage.errorMessage = Internal error
-BuilderPropertyPage.invalidBuildTool = Invalid External Tool Builder
-BuilderPropertyPage.missingBuilder = Missing builder ({0})
-BuilderPropertyPage.Exists=Builder launch configuration {0} no longer exists
-BuilderPropertyPage.External_Tool_Builder_{0}_Not_Added_2=External Tool Builder {0} Not Added
-BuilderPropertyPage.&Import..._3=&Import...
-BuilderPropertyPage.New_Builder_7=New_Builder
-BuilderPropertyPage.Choose_configuration_type_8=Choose configuration type
-BuilderPropertyPage.Choose_an_external_tool_type_to_create_9=&Choose an external tool type to create:
-BuilderPropertyPage.Migrate_project_builder_10=Migrate project builder
-BuilderPropertyPage.Not_Support=This project builder is stored in a format that is no longer supported. If you wish to edit this builder, it will first be migrated to a new format. If you proceed, this project builder will not be understood by installations using the old format.\n\nProceed with migration?
-BuilderPropertyPage.Prompt=&Do not prompt before migrating project builders
-BuilderPropertyPage.error=An error occurred while saving the project\'s build commands
-BuilderPropertyPage.0=Project Migration
-BuilderPropertyPage.2=&Do not prompt before migrating projects
-BuilderPropertyPage.1=This project stores its builders in a format that is no longer supported. If any changes are made, the project will be migrated to the new format which will not be understood by installations using the old format.\n\nProceed? (Selecting "No" will open the page read-only)
-BuilderPropertyPage.4=Import launch configuration
-BuilderPropertyPage.5=&Choose a launch configuration from the workspace to import.\nThis will create a copy of the selected configuration.
-BuilderPropertyPage.13=Command error
-BuilderPropertyPage.39=Error Saving Builder
-BuilderPropertyPage.3=Updating builders...
-BuilderPropertyPage.6=Confirm Disable Builder
-BuilderPropertyPage.7=This is an advanced operation. Disabling a project builder can have many side-effects. Continue?
-BuilderPropertyPage.40=An exception occurred while attempting to save builder {0}
-
-FileSelectionDialog.Choose_Location_1=Choose Location
-FileSelectionDialog.Ok_2=Ok
-FileSelectionDialog.Cancel_3=Cancel
-
-ExternalToolsPreferencePage.External_tool_project_builders_migration_2=External tool project builders stored in an old format will be migrated to a new format when edited. Projects which store builders using an old format will be migrated whenever a change is made. Once migrated, project builders will not be understood by installations using these older formats.
-ExternalToolsPreferencePage.Prompt_before_migrating_3=&Confirm before migrating external tool project builders for edit
-ExternalToolsPreferencePage.1=C&onfirm before migrating projects to the new format
-
-ExternalToolMigration.37=An exception occurred accessing external tool\'s \"run in background\" attribute
-ExternalToolMigration.38=An exception occurred attempting to migrate external tool\'s \"run in background\" attribute
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/FileSelectionDialog.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/FileSelectionDialog.java
deleted file mode 100644
index d4100355b..000000000
--- a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/FileSelectionDialog.java
+++ /dev/null
@@ -1,246 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.externaltools.internal.ui;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.viewers.DoubleClickEvent;
-import org.eclipse.jface.viewers.IDoubleClickListener;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ControlEvent;
-import org.eclipse.swt.events.ControlListener;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.TableColumn;
-import org.eclipse.ui.externaltools.internal.model.IExternalToolsHelpContextIds;
-import org.eclipse.ui.externaltools.internal.model.StringMatcher;
-import org.eclipse.ui.help.WorkbenchHelp;
-import org.eclipse.ui.model.WorkbenchContentProvider;
-import org.eclipse.ui.model.WorkbenchLabelProvider;
-
-/**
- * Dialog for selecting a file in the workspace. Derived from
- * org.eclipse.ui.dialogs.ResourceSelectionDialog
- */
-public class FileSelectionDialog extends MessageDialog {
- // the root element to populate the viewer with
- private IAdaptable root;
-
- // the visual selection widget group
- private TreeAndListGroup selectionGroup;
- // constants
- private final static int SIZING_SELECTION_WIDGET_WIDTH = 400;
- private final static int SIZING_SELECTION_WIDGET_HEIGHT = 300;
- /**
- * The file(s) selected by the user.
- */
- private IStructuredSelection result = null;
- /**
- * String matcher used to filter content
- */
- private StringMatcher stringMatcher = null;
-
- private boolean allowMultiselection= false;
- /**
- * Creates a resource selection dialog rooted at the given element.
- *
- * @param parentShell
- * the parent shell
- * @param rootElement
- * the root element to populate this dialog with
- * @param message
- * the message to be displayed at the top of this dialog, or
- * <code>null</code> to display a default message
- */
- public FileSelectionDialog(Shell parentShell, IAdaptable rootElement, String message) {
- super(parentShell, ExternalToolsUIMessages.getString("FileSelectionDialog.Choose_Location_1"), null, message, MessageDialog.NONE, new String[] { ExternalToolsUIMessages.getString("FileSelectionDialog.Ok_2"), ExternalToolsUIMessages.getString("FileSelectionDialog.Cancel_3")}, 0); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- root = rootElement;
- setShellStyle(getShellStyle() | SWT.RESIZE);
- }
-
- /**
- * Limits the files displayed in this dialog to files matching the given
- * pattern. The string can be a filename or a regular expression containing
- * '*' for any series of characters or '?' for any single character.
- *
- * @param pattern
- * a pattern used to filter the displayed files or <code>null</code>
- * to display all files. If a pattern is supplied, only files
- * whose names match the given pattern will be available for
- * selection.
- * @param ignoreCase
- * if true, case is ignored. If the pattern argument is <code>null</code>,
- * this argument is ignored.
- */
- public void setFileFilter(String pattern, boolean ignoreCase) {
- if (pattern != null) {
- stringMatcher = new StringMatcher(pattern, ignoreCase, false);
- } else {
- stringMatcher = null;
- }
- }
-
- /*
- * (non-Javadoc) Method declared in Window.
- */
- protected void configureShell(Shell shell) {
- super.configureShell(shell);
- WorkbenchHelp.setHelp(
- shell,
- IExternalToolsHelpContextIds.FILE_SELECTION_DIALOG);
- }
-
- protected void createButtonsForButtonBar(Composite parent) {
- super.createButtonsForButtonBar(parent);
- initializeDialog();
- }
-
- /*
- * (non-Javadoc) Method declared on Dialog.
- */
- protected Control createDialogArea(Composite parent) {
- // page group
- Composite composite = (Composite) super.createDialogArea(parent);
-
- //create the input element, which has the root resource
- //as its only child
- selectionGroup =
- new TreeAndListGroup(
- composite,
- root,
- getResourceProvider(
- IResource.FOLDER | IResource.PROJECT | IResource.ROOT),
- new WorkbenchLabelProvider(),
- getResourceProvider(IResource.FILE),
- new WorkbenchLabelProvider(),
- SWT.NONE,
- // since this page has no other significantly-sized
- // widgets we need to hardcode the combined widget's
- // size, otherwise it will open too small
- SIZING_SELECTION_WIDGET_WIDTH, SIZING_SELECTION_WIDGET_HEIGHT,
- allowMultiselection);
-
- composite.addControlListener(new ControlListener() {
- public void controlMoved(ControlEvent e) {
- }
- public void controlResized(ControlEvent e) {
- //Also try and reset the size of the columns as appropriate
- TableColumn[] columns =
- selectionGroup.getListTable().getColumns();
- for (int i = 0; i < columns.length; i++) {
- columns[i].pack();
- }
- }
- });
-
- return composite;
- }
- /**
- * Returns a content provider for <code>IResource</code> s that returns
- * only children of the given resource type.
- */
- private ITreeContentProvider getResourceProvider(final int resourceType) {
- return new WorkbenchContentProvider() {
- public Object[] getChildren(Object o) {
- if (o instanceof IContainer) {
- IResource[] members = null;
- try {
- members = ((IContainer) o).members();
- List accessibleMembers = new ArrayList(members.length);
- for (int i = 0; i < members.length; i++) {
- IResource resource = members[i];
- if (resource.isAccessible()) {
- accessibleMembers.add(resource);
- }
- }
- members =
- (IResource[]) accessibleMembers.toArray(
- new IResource[accessibleMembers.size()]);
- } catch (CoreException e) {
- //just return an empty set of children
- return new Object[0];
- }
-
- //filter out the desired resource types
- ArrayList results = new ArrayList();
- for (int i = 0; i < members.length; i++) {
- //And the test bits with the resource types to see if
- // they are what we want
- if ((members[i].getType() & resourceType) > 0) {
- if (members[i].getType() == IResource.FILE
- && stringMatcher != null
- && !stringMatcher.match(members[i].getName())) {
- continue;
- }
- results.add(members[i]);
- }
- }
- return results.toArray();
- }
-
- return new Object[0];
- }
- };
- }
- /**
- * Initializes this dialog's controls.
- */
- private void initializeDialog() {
- selectionGroup
- .addSelectionChangedListener(new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- getButton(IDialogConstants.OK_ID).setEnabled(
- !selectionGroup.getListTableSelection().isEmpty());
- }
- });
- selectionGroup.addDoubleClickListener(new IDoubleClickListener() {
- public void doubleClick(DoubleClickEvent event) {
- buttonPressed(IDialogConstants.OK_ID);
- }
- });
-
- getButton(IDialogConstants.OK_ID).setEnabled(false);
- }
-
- /**
- * Returns the file the user chose or <code>null</code> if none.
- */
- public IStructuredSelection getResult() {
- return result;
- }
-
- protected void buttonPressed(int buttonId) {
- if (buttonId == IDialogConstants.OK_ID) {
- result= selectionGroup.getListTableSelection();
- }
- super.buttonPressed(buttonId);
- }
- /**
- * Sets whether this dialog will allow multi-selection.
- * Must be called before <code>open</code>
- * @param allowMultiselection whether to allow multi-selection in the dialog
- */
- public void setAllowMultiselection(boolean allowMultiselection) {
- this.allowMultiselection= allowMultiselection;
- }
-} \ No newline at end of file
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/TreeAndListGroup.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/TreeAndListGroup.java
deleted file mode 100644
index 48f387ab1..000000000
--- a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/TreeAndListGroup.java
+++ /dev/null
@@ -1,316 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.externaltools.internal.ui;
-
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.jface.viewers.DoubleClickEvent;
-import org.eclipse.jface.viewers.IDoubleClickListener;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.ViewerSorter;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.ui.views.navigator.ResourceSorter;
-
-/**
- * This class was derived from org.eclipse.ui.internal.misc.CheckboxTreeAndListGroup
- *
- */
-public class TreeAndListGroup implements ISelectionChangedListener {
- private Object root;
- private Object currentTreeSelection;
- private List selectionChangedListeners = new ArrayList();
- private List doubleClickListeners= new ArrayList();
-
- private ITreeContentProvider treeContentProvider;
- private IStructuredContentProvider listContentProvider;
- private ILabelProvider treeLabelProvider;
- private ILabelProvider listLabelProvider;
-
- // widgets
- private TreeViewer treeViewer;
- private TableViewer listViewer;
- private boolean allowMultiselection= false;
-
- /**
- * Create an instance of this class. Use this constructor if you wish to specify
- * the width and/or height of the combined widget (to only hardcode one of the
- * sizing dimensions, specify the other dimension's value as -1)
- *
- * @param parent org.eclipse.swt.widgets.Composite
- * @param style int
- * @param rootObject java.lang.Object
- * @param width int
- * @param height int
- * @param allowMultiselection Whether to allow multi-selection in the list viewer.
- */
- public TreeAndListGroup(Composite parent, Object rootObject, ITreeContentProvider treeContentProvider, ILabelProvider treeLabelProvider, IStructuredContentProvider listContentProvider, ILabelProvider listLabelProvider, int style, int width, int height, boolean allowMultiselection) {
-
- root = rootObject;
- this.treeContentProvider = treeContentProvider;
- this.listContentProvider = listContentProvider;
- this.treeLabelProvider = treeLabelProvider;
- this.listLabelProvider = listLabelProvider;
- this.allowMultiselection= allowMultiselection;
- createContents(parent, width, height, style);
- }
- /**
- * This method must be called just before this window becomes visible.
- */
- public void aboutToOpen() {
- currentTreeSelection = null;
-
- //select the first element in the list
- Object[] elements = treeContentProvider.getElements(root);
- Object primary = elements.length > 0 ? elements[0] : null;
- if (primary != null) {
- treeViewer.setSelection(new StructuredSelection(primary));
- }
- treeViewer.getControl().setFocus();
- }
- /**
- * Add the passed listener to collection of clients
- * that listen for changes to list viewer selection state
- *
- * @param listener ISelectionChangedListener
- */
- public void addSelectionChangedListener(ISelectionChangedListener listener) {
- selectionChangedListeners.add(listener);
- }
-
- /**
- * Add the given listener to the collection of clients that listen to
- * double-click events in the list viewer
- *
- * @param listener IDoubleClickListener
- */
- public void addDoubleClickListener(IDoubleClickListener listener) {
- doubleClickListeners.add(listener);
- }
-
- /**
- * Notify all selection listeners that a selection has occurred in the list
- * viewer
- */
- protected void notifySelectionListeners(SelectionChangedEvent event) {
- Iterator iter = selectionChangedListeners.iterator();
- while (iter.hasNext()) {
- ((ISelectionChangedListener) iter.next()).selectionChanged(event);
- }
- }
-
- /**
- * Notify all double click listeners that a double click event has occurred
- * in the list viewer
- */
- protected void notifyDoubleClickListeners(DoubleClickEvent event) {
- Iterator iter= doubleClickListeners.iterator();
- while (iter.hasNext()) {
- ((IDoubleClickListener) iter.next()).doubleClick(event);
- }
- }
-
- /**
- * Lay out and initialize self's visual components.
- *
- * @param parent org.eclipse.swt.widgets.Composite
- * @param width int
- * @param height int
- */
- protected void createContents(Composite parent, int width, int height, int style) {
- // group pane
- Composite composite = new Composite(parent, style);
- composite.setFont(parent.getFont());
- GridLayout layout = new GridLayout();
- layout.numColumns = 2;
- layout.makeColumnsEqualWidth = true;
- layout.marginHeight = 0;
- layout.marginWidth = 0;
- composite.setLayout(layout);
- composite.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- createTreeViewer(composite, width / 2, height);
- createListViewer(composite, width / 2, height);
-
- initialize();
- }
- /**
- * Create this group's list viewer.
- */
- protected void createListViewer(Composite parent, int width, int height) {
- int style;
- if (allowMultiselection) {
- style= SWT.MULTI;
- } else {
- style= SWT.SINGLE;
- }
- listViewer = new TableViewer(parent, SWT.BORDER | style);
- GridData data = new GridData(GridData.FILL_BOTH);
- data.widthHint = width;
- data.heightHint = height;
- listViewer.getTable().setLayoutData(data);
- listViewer.getTable().setFont(parent.getFont());
- listViewer.setContentProvider(listContentProvider);
- listViewer.setLabelProvider(listLabelProvider);
- listViewer.setSorter(new ResourceSorter(ResourceSorter.NAME));
- listViewer.addSelectionChangedListener(new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- notifySelectionListeners(event);
- }
- });
- listViewer.addDoubleClickListener(new IDoubleClickListener() {
- public void doubleClick(DoubleClickEvent event) {
- if (!event.getSelection().isEmpty()) {
- notifyDoubleClickListeners(event);
- }
- }
- });
- }
- /**
- * Create this group's tree viewer.
- */
- protected void createTreeViewer(Composite parent, int width, int height) {
- Tree tree = new Tree(parent, SWT.BORDER);
- GridData data = new GridData(GridData.FILL_BOTH);
- data.widthHint = width;
- data.heightHint = height;
- tree.setLayoutData(data);
- tree.setFont(parent.getFont());
-
- treeViewer = new TreeViewer(tree);
- treeViewer.setContentProvider(treeContentProvider);
- treeViewer.setLabelProvider(treeLabelProvider);
- treeViewer.setSorter(new ResourceSorter(ResourceSorter.NAME));
- treeViewer.addSelectionChangedListener(this);
- }
-
- public Table getListTable() {
- return listViewer.getTable();
- }
-
- public IStructuredSelection getListTableSelection() {
- ISelection selection= this.listViewer.getSelection();
- if (selection instanceof IStructuredSelection) {
- return (IStructuredSelection)selection;
- }
- return StructuredSelection.EMPTY;
- }
-
- protected void initialListItem(Object element) {
- Object parent = treeContentProvider.getParent(element);
- selectAndRevealFolder(parent);
- }
-
- public void selectAndRevealFolder(Object treeElement) {
- treeViewer.reveal(treeElement);
- IStructuredSelection selection = new StructuredSelection(treeElement);
- treeViewer.setSelection(selection);
- }
-
- public void selectAndRevealFile(Object treeElement) {
- listViewer.reveal(treeElement);
- IStructuredSelection selection = new StructuredSelection(treeElement);
- listViewer.setSelection(selection);
- }
-
- /**
- * Initialize this group's viewers after they have been laid out.
- */
- protected void initialize() {
- treeViewer.setInput(root);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)
- */
- public void selectionChanged(SelectionChangedEvent event) {
- IStructuredSelection selection = (IStructuredSelection) event.getSelection();
- Object selectedElement = selection.getFirstElement();
- if (selectedElement == null) {
- currentTreeSelection = null;
- listViewer.setInput(currentTreeSelection);
- return;
- }
-
- // ie.- if not an item deselection
- if (selectedElement != currentTreeSelection) {
- listViewer.setInput(selectedElement);
- }
-
- currentTreeSelection = selectedElement;
- }
- /**
- * Set the list viewer's providers to those passed
- *
- * @param contentProvider ITreeContentProvider
- * @param labelProvider ILabelProvider
- */
- public void setListProviders(IStructuredContentProvider contentProvider, ILabelProvider labelProvider) {
- listViewer.setContentProvider(contentProvider);
- listViewer.setLabelProvider(labelProvider);
- }
- /**
- * Set the sorter that is to be applied to self's list viewer
- */
- public void setListSorter(ViewerSorter sorter) {
- listViewer.setSorter(sorter);
- }
- /**
- * Set the root of the widget to be new Root. Regenerate all of the tables and lists from this
- * value.
- * @param newRoot
- */
- public void setRoot(Object newRoot) {
- this.root = newRoot;
- initialize();
- }
-
- /**
- * Set the tree viewer's providers to those passed
- *
- * @param contentProvider ITreeContentProvider
- * @param labelProvider ILabelProvider
- */
- public void setTreeProviders(ITreeContentProvider contentProvider, ILabelProvider labelProvider) {
- treeViewer.setContentProvider(contentProvider);
- treeViewer.setLabelProvider(labelProvider);
- }
- /**
- * Set the sorter that is to be applied to self's tree viewer
- */
- public void setTreeSorter(ViewerSorter sorter) {
- treeViewer.setSorter(sorter);
- }
-
- /**
- * Set the focus on to the list widget.
- */
- public void setFocus() {
-
- this.treeViewer.getTree().setFocus();
- }
-}

Back to the top