diff options
16 files changed, 789 insertions, 11 deletions
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/variable/BuildTypeExpander.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/variable/BuildTypeExpander.java new file mode 100644 index 000000000..c6a576036 --- /dev/null +++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/variable/BuildTypeExpander.java @@ -0,0 +1,15 @@ +package org.eclipse.ui.externaltools.internal.variable; + +/********************************************************************** +Copyright (c) 2002 IBM Corp. and others. All rights reserved. +This file is made available under the terms of the Common Public License v1.0 +which accompanies this distribution, and is available at +http://www.eclipse.org/legal/cpl-v10.html +**********************************************************************/ + +public class BuildTypeExpander extends DefaultVariableExpander { + + public String getText(String varTag, String varValue, ExpandVariableContext context) { + return context.getBuildType(); + } +} diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/variable/ContainerExpander.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/variable/ContainerExpander.java new file mode 100644 index 000000000..64b81f201 --- /dev/null +++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/variable/ContainerExpander.java @@ -0,0 +1,40 @@ +package org.eclipse.ui.externaltools.internal.variable; + +/********************************************************************** +Copyright (c) 2002 IBM Corp. and others. All rights reserved. +This file is made available under the terms of the Common Public License v1.0 +which accompanies this distribution, and is available at +http://www.eclipse.org/legal/cpl-v10.html + +Contributors: +**********************************************************************/ + +import org.eclipse.core.resources.IResource; + +/** + * Expands a resource's container type variable into the desired + * result format. + * <p> + * This class is not intended to be extended by clients. + * </p> + */ +public class ContainerExpander extends ResourceExpander { + + /** + * Create an instance + */ + public ContainerExpander() { + super(); + } + + /* (non-Javadoc) + * Method declared on ResourceExpander. + */ + /*package*/ IResource expand(String varValue, ExpandVariableContext context) { + IResource resource = super.expand(varValue, context); + if (resource != null) + return resource.getParent(); + else + return null; + } +} diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/variable/ContainerNameExpander.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/variable/ContainerNameExpander.java new file mode 100644 index 000000000..17b283dd6 --- /dev/null +++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/variable/ContainerNameExpander.java @@ -0,0 +1,32 @@ +package org.eclipse.ui.externaltools.internal.variable; + +/********************************************************************** +Copyright (c) 2002 IBM Corp. and others. All rights reserved. +This file is made available under the terms of the Common Public License v1.0 +which accompanies this distribution, and is available at +http://www.eclipse.org/legal/cpl-v10.html +**********************************************************************/ + +import org.eclipse.core.resources.IContainer; +import org.eclipse.core.resources.IResource; + +/** + * Extracts the container name from a variable context + */ +public class ContainerNameExpander extends DefaultVariableExpander { + + /** + * @see IVariableTextExpander#getText(String, String, ExpandVariableContext) + */ + public String getText(String varTag, String varValue, ExpandVariableContext context) { + IResource resource= context.getSelectedResource(); + if (resource != null) { + IContainer parent= resource.getParent(); + if (parent != null) { + return parent.getName(); + } + } + return null; + } + +} diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/variable/DefaultVariableExpander.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/variable/DefaultVariableExpander.java new file mode 100644 index 000000000..0cf3f05f8 --- /dev/null +++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/variable/DefaultVariableExpander.java @@ -0,0 +1,40 @@ +package org.eclipse.ui.externaltools.internal.variable; + +/******************************************************************************* + * 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 v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM - Initial API and implementation + ******************************************************************************/ + +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.IPath; + +public class DefaultVariableExpander implements IVariableExpander { + + private static DefaultVariableExpander instance; + + public static DefaultVariableExpander getDefault() { + if (instance == null) { + instance= new DefaultVariableExpander(); + } + return instance; + } + + public IPath getPath(String varTag, String varValue, ExpandVariableContext context) { + return null; + } + + public IResource[] getResources(String varTag, String varValue, ExpandVariableContext context) { + return null; + } + + public String getText(String varTag, String varValue, ExpandVariableContext context) { + return null; + } + +} diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/variable/ExpandVariableContext.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/variable/ExpandVariableContext.java new file mode 100644 index 000000000..10b4571d4 --- /dev/null +++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/variable/ExpandVariableContext.java @@ -0,0 +1,101 @@ +package org.eclipse.ui.externaltools.internal.variable; + +/********************************************************************** +Copyright (c) 2002 IBM Corp. and others. All rights reserved. +This file is made available under the terms of the Common Public License v1.0 +which accompanies this distribution, and is available at +http://www.eclipse.org/legal/cpl-v10.html + +Contributors: +**********************************************************************/ + +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IncrementalProjectBuilder; +import org.eclipse.ui.externaltools.internal.model.IExternalToolConstants; + +/** + * Represents the context the external tool is running in + * that a variable uses to expand itself. + */ +public final class ExpandVariableContext { + public static final ExpandVariableContext EMPTY_CONTEXT = new ExpandVariableContext(null); + + private IProject project = null; + private IResource selectedResource = null; + private String buildType = IExternalToolConstants.BUILD_TYPE_NONE; + + /** + * Create a context for an external tool running + * as a builder on the given project. + * + * @param project the <code>IProject</code> being built. + * @param buildKind the kind of build being performed + * (see <code>IncrementalProjectBuilder</code>). + */ + public ExpandVariableContext(IProject project, int buildKind) { + super(); + this.project = project; + switch (buildKind) { + case IncrementalProjectBuilder.INCREMENTAL_BUILD : + this.buildType = IExternalToolConstants.BUILD_TYPE_INCREMENTAL; + break; + case IncrementalProjectBuilder.FULL_BUILD : + this.buildType = IExternalToolConstants.BUILD_TYPE_FULL; + break; + case IncrementalProjectBuilder.AUTO_BUILD : + this.buildType = IExternalToolConstants.BUILD_TYPE_AUTO; + break; + default : + this.buildType = IExternalToolConstants.BUILD_TYPE_NONE; + break; + } + } + + /** + * Create a context for an external tool running + * with the given resource selected. + * + * @param selectedResource the <code>IResource</code> selected + * or <code>null</code> if none. + */ + public ExpandVariableContext(IResource selectedResource) { + super(); + if (selectedResource != null) { + this.selectedResource = selectedResource; + this.project = selectedResource.getProject(); + } + } + + /** + * Returns the build type being performed if the + * external tool is being run as a project builder. + * + * @return one of the <code>IExternalToolConstants.BUILD_TYPE_*</code> constants. + */ + public String getBuildType() { + return buildType; + } + + /** + * Returns the project which the variable can use. This + * will the the project being built if the tool is being + * run as a builder. Otherwise, it is the project of the + * selected resource, or <code>null</code> if none. + * + * @return the <code>IProject</code> or <code>null</code> if none + */ + public IProject getProject() { + return project; + } + + /** + * Returns the resource selected at the time the tool + * is run, or <code>null</code> if none selected. + * + * @return the <code>IResource</code> selected, or <code>null</code> if none + */ + public IResource getSelectedResource() { + return selectedResource; + } +} diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/variable/ExternalToolsVariableMessages.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/variable/ExternalToolsVariableMessages.java new file mode 100644 index 000000000..3c36f386f --- /dev/null +++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/variable/ExternalToolsVariableMessages.java @@ -0,0 +1,30 @@ +package org.eclipse.ui.externaltools.internal.variable; + +/********************************************************************** +Copyright (c) 2000, 2002 IBM Corp. 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 +**********************************************************************/ + +import java.util.MissingResourceException; +import java.util.ResourceBundle; + +public class ExternalToolsVariableMessages { + + private static final String BUNDLE_NAME = "org.eclipse.ui.externaltools.variable.ExternalToolsVariableMessages"; //$NON-NLS-1$ + + private static final ResourceBundle RESOURCE_BUNDLE = + ResourceBundle.getBundle(BUNDLE_NAME); + + private ExternalToolsVariableMessages() { + } + + 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/variable/IVariableComponent.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/variable/IVariableComponent.java new file mode 100644 index 000000000..695a9f47e --- /dev/null +++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/variable/IVariableComponent.java @@ -0,0 +1,76 @@ +package org.eclipse.ui.externaltools.internal.variable; + +/********************************************************************** +Copyright (c) 2002 IBM Corp. and others. All rights reserved. +This file is made available under the terms of the Common Public License v1.0 +which accompanies this distribution, and is available at +http://www.eclipse.org/legal/cpl-v10.html + +Contributors: +**********************************************************************/ + +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.ui.externaltools.internal.group.IGroupDialogPage; + +/** + * Represents the API for a client extending one of the + * variable extension points to provide visual editing + * of the variable. + * <p> + * This interface is not to be extended by clients. Clients + * may implement this interface. + * </p> + */ +public interface IVariableComponent { + /** + * Returns the control to edit the variable + * value, otherwise <code>null</code> if no editing + * supported or if <code>createContents</code> has + * not been called yet + * + * @return the main control for the variable component + * or <code>null</code> if none + */ + public Control getControl(); + + /** + * Creates the control to edit the variable. Does nothing + * if no editing supported. + * + * @param parent the composite to parent all controls to + * @param varTag the variable tag name to create the controls for + * @param page the dialog page this visual component will be part of + */ + public void createContents(Composite parent, String varTag, IGroupDialogPage page); + + /** + * Returns the variable value as specified by + * the user thru the visual component. + * + * @return the variable value as indicated by the visual component + */ + public String getVariableValue(); + + /** + * Returns whether the variable's visual component has an + * acceptable value. + * + * @return <code>true</code> if all value acceptable, or <code>false</code> otherwise + */ + public boolean isValid(); + + /** + * Sets the visual component to represent the + * given variable value. + * + * @param varValue the variable value the visual component should indicate + */ + public void setVariableValue(String varValue); + + /** + * Validates visual component current values entered by the + * user and updates it's valid state if needed + */ + public void validate(); +} diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/variable/ProjectNameExpander.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/variable/ProjectNameExpander.java new file mode 100644 index 000000000..c1dfb0ad7 --- /dev/null +++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/variable/ProjectNameExpander.java @@ -0,0 +1,28 @@ +package org.eclipse.ui.externaltools.internal.variable; + +/********************************************************************** +Copyright (c) 2002 IBM Corp. and others. All rights reserved. +This file is made available under the terms of the Common Public License v1.0 +which accompanies this distribution, and is available at +http://www.eclipse.org/legal/cpl-v10.html +**********************************************************************/ + +import org.eclipse.core.resources.IProject; + +/** + * Extracts the project name from a variable context + */ +public class ProjectNameExpander extends DefaultVariableExpander { + + /** + * Returns the name of the project in the given context or + * <code>null</code> if there is no project in the context. + */ + public String getText(String varTag, String varValue, ExpandVariableContext context) { + IProject project= context.getProject(); + if (project != null) { + return project.getName(); + } + return null; + } +} diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/variable/ResourceComponent.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/variable/ResourceComponent.java new file mode 100644 index 000000000..e97a1c8ea --- /dev/null +++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/variable/ResourceComponent.java @@ -0,0 +1,272 @@ +package org.eclipse.ui.externaltools.internal.variable; + +/********************************************************************** +Copyright (c) 2002 IBM Corp. and others. All rights reserved. +This file is made available under the terms of the Common Public License v1.0 +which accompanies this distribution, and is available at +http://www.eclipse.org/legal/cpl-v10.html + +Contributors: +**********************************************************************/ + +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.jface.dialogs.IMessageProvider; +import org.eclipse.jface.viewers.ISelectionChangedListener; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.SelectionChangedEvent; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.jface.viewers.TreeViewer; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Group; +import org.eclipse.swt.widgets.Tree; +import org.eclipse.ui.externaltools.internal.group.IGroupDialogPage; +import org.eclipse.ui.externaltools.internal.model.ToolUtil; +import org.eclipse.ui.model.WorkbenchContentProvider; +import org.eclipse.ui.model.WorkbenchLabelProvider; + +/** + * Visual component to edit the resource type variable + * value. + * <p> + * This class is not intended to be extended by clients. + * </p> + */ +public class ResourceComponent implements IVariableComponent { + private IGroupDialogPage page; + private boolean isValid = true; + + protected Group mainGroup; + protected Button selectedResourceButton; + protected Button specificResourceButton; + protected TreeViewer resourceList; + private IResource selectedResource; + + /** + * Creates the component + */ + public ResourceComponent() { + super(); + } + + /* (non-Javadoc) + * Method declared on IVariableComponent. + */ + public void createContents(Composite parent, String varTag, IGroupDialogPage page) { + this.page = page; + + // main composite + mainGroup = new Group(parent, SWT.NONE); + GridLayout layout = new GridLayout(); + layout.marginWidth = 0; + layout.marginHeight = 0; + layout.numColumns = 1; + GridData gridData = new GridData(GridData.FILL_BOTH); + mainGroup.setLayout(layout); + mainGroup.setLayoutData(gridData); + mainGroup.setFont(parent.getFont()); + mainGroup.setText(ToolUtil.buildVariableTag(varTag, null)); + + createSelectedResourceOption(); + createSpecificResourceOption(); + createResourceList(); + + updateResourceListEnablement(); + } + + /** + * Creates the list of resources. + */ + protected void createResourceList() { + Tree tree = new Tree(mainGroup, SWT.SINGLE | SWT.BORDER); + GridData data = new GridData(GridData.FILL_BOTH); + data.heightHint = tree.getItemHeight() * getInitialVisibleItemCount(); + tree.setLayoutData(data); + tree.setFont(mainGroup.getFont()); + + resourceList = new TreeViewer(tree); + resourceList.addSelectionChangedListener(new ISelectionChangedListener() { + public void selectionChanged(SelectionChangedEvent event) { + validateResourceListSelection(); + selectedResource= (IResource) ((IStructuredSelection)event.getSelection()).getFirstElement(); + } + }); + resourceList.setContentProvider(new WorkbenchContentProvider()); + resourceList.setLabelProvider(new WorkbenchLabelProvider()); + resourceList.setInput(ResourcesPlugin.getWorkspace().getRoot()); + } + + /** + * Creates the option button for using the selected + * resource. + */ + protected void createSelectedResourceOption() { + selectedResourceButton = new Button(mainGroup, SWT.RADIO); + selectedResourceButton.setText(ExternalToolsVariableMessages.getString("ResourceComponent.selectedResLabel")); //$NON-NLS-1$ + GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL); + selectedResourceButton.setLayoutData(data); + selectedResourceButton.setFont(mainGroup.getFont()); + selectedResourceButton.setSelection(true); + } + + /** + * Creates the option button for using a specific + * resource. + */ + protected void createSpecificResourceOption() { + specificResourceButton = new Button(mainGroup, SWT.RADIO); + specificResourceButton.setText(ExternalToolsVariableMessages.getString("ResourceComponent.specificResLabel")); //$NON-NLS-1$ + GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL); + specificResourceButton.setLayoutData(data); + specificResourceButton.setFont(mainGroup.getFont()); + specificResourceButton.setSelection(false); + + specificResourceButton.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + updateResourceListEnablement(); + } + }); + } + + /* (non-Javadoc) + * Method declared on IVariableComponent. + */ + public Control getControl() { + return mainGroup; + } + + /** + * Returns the dialog page this component is part of + */ + protected final IGroupDialogPage getPage() { + return page; + } + + /* (non-Javadoc) + * Method declared on IVariableComponent. + */ + public String getVariableValue() { + if (selectedResourceButton != null && selectedResourceButton.getSelection()) { + return null; + } + + if (resourceList != null) { + if (selectedResource != null) { + return selectedResource.getFullPath().toString(); + } + } + + return null; + } + + /** + * Returns the number of items to be visible in the + * resource list. This will determine the initial height. + */ + protected int getInitialVisibleItemCount() { + return 10; + } + + /* (non-Javadoc) + * Method declared on IVariableComponent. + */ + public boolean isValid() { + return isValid; + } + + /** + * Sets whether the component's values are all valid. + * Updates the components's page valid state. No action + * taken if new valid state same as current one. + * + * @param isValid <code>true</code> if all values valid, + * <code>false</code> otherwise + */ + protected final void setIsValid(boolean isValid) { + if (this.isValid != isValid) { + this.isValid = isValid; + this.page.updateValidState(); + } + } + + /** + * Updates the enablement of the resource list if needed + */ + protected void updateResourceListEnablement() { + if (specificResourceButton != null && resourceList != null) { + resourceList.getTree().setEnabled(specificResourceButton.getSelection()); + } + } + + /* (non-Javadoc) + * Method declared on IVariableComponent. + */ + public void setVariableValue(String varValue) { + if (varValue == null || varValue.length() == 0) { + if (selectedResourceButton != null) { + selectedResourceButton.setSelection(true); + } + if (specificResourceButton != null) { + specificResourceButton.setSelection(false); + } + if (resourceList != null) { + resourceList.getTree().setEnabled(false); + } + } else { + if (selectedResourceButton != null) { + selectedResourceButton.setSelection(false); + } + if (specificResourceButton != null) { + specificResourceButton.setSelection(true); + } + if (resourceList != null) { + resourceList.getTree().setEnabled(true); + IResource member = ResourcesPlugin.getWorkspace().getRoot().findMember(varValue); + if (member != null) { + resourceList.setSelection(new StructuredSelection(member), true); + } else { + resourceList.setSelection(StructuredSelection.EMPTY); + } + } + } + } + + /* (non-Javadoc) + * Method declared on IVariableComponent. + */ + public void validate() { + if (specificResourceButton != null && specificResourceButton.getSelection()) { + validateResourceListSelection(); + } + + getPage().setMessage(null, IMessageProvider.NONE); + setIsValid(true); + } + + /** + * Returns whether that the resource list selection is valid. + * If the list was not created, returns <code>true</code>. + * + * @return <code>true</code> to continue validating other + * fields, <code>false</code> to stop. + */ + protected boolean validateResourceListSelection() { + if (resourceList == null) + return true; + + if (resourceList.getSelection().isEmpty()) { + getPage().setMessage(ExternalToolsVariableMessages.getString("ResourceComponent.selectionRequired"), IMessageProvider.WARNING); //$NON-NLS-1$ + setIsValid(false); + return false; + } + + return true; + } +} diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/variable/SpecificFolderResourceComponent.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/variable/SpecificFolderResourceComponent.java new file mode 100644 index 000000000..ae8257ae8 --- /dev/null +++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/variable/SpecificFolderResourceComponent.java @@ -0,0 +1,109 @@ +package org.eclipse.ui.externaltools.internal.variable; + +/********************************************************************** +Copyright (c) 2002 IBM Corp. and others. All rights reserved. +This file is made available under the terms of the Common Public License v1.0 +which accompanies this distribution, and is available at +http://www.eclipse.org/legal/cpl-v10.html + +Contributors: +**********************************************************************/ + +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.jface.dialogs.IMessageProvider; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.Viewer; +import org.eclipse.jface.viewers.ViewerFilter; +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.widgets.Label; + +/** + * Visual component to edit the resource type variable + * value for the working directory. Variable is limited to a specific + * <code>IContainer</code> resource. + * <p> + * This class is not intended to be extended by clients. + * </p> + */ +public class SpecificFolderResourceComponent extends ResourceComponent { + + /** + * Creates an instance + */ + public SpecificFolderResourceComponent() { + super(); + } + + /* (non-Javadoc) + * Method declared on ResourceComponent. + */ + protected void createSelectedResourceOption() { + // Do not present this option... + } + + /* (non-Javadoc) + * Method declared on ResourceComponent. + */ + protected void createResourceList() { + super.createResourceList(); + if (resourceList != null) + resourceList.addFilter(new FileFilter()); + } + + /* (non-Javadoc) + * Method declared on ResourceComponent. + */ + protected void createSpecificResourceOption() { + Label label = new Label(mainGroup, SWT.NONE); + GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL); + label.setLayoutData(data); + label.setFont(mainGroup.getFont()); + label.setText(ExternalToolsVariableMessages.getString("ResourceComponent.specificResLabel")); //$NON-NLS-1$ + } + + /* (non-Javadoc) + * Method declared on ResourceComponent. + */ + protected boolean validateResourceListSelection() { + if (resourceList == null) + return true; + + IStructuredSelection sel = (IStructuredSelection) resourceList.getSelection(); + IResource resource = (IResource) sel.getFirstElement(); + if (resource == null || resource.getType() == IResource.FILE) { + getPage().setMessage(ExternalToolsVariableMessages.getString("ResourceComponent.selectionRequired"), IMessageProvider.WARNING); //$NON-NLS-1$ + setIsValid(false); + return false; + } + + return true; + } + + + /** + * Filter to remove any IFile resources. + */ + private static final class FileFilter extends ViewerFilter { + /* (non-Javadoc) + * Method declared on ViewerFilter. + */ + public boolean select(Viewer viewer, Object parentElement, Object element) { + IResource resource = null; + if (element instanceof IResource) { + resource = (IResource) element; + } else { + if (element instanceof IAdaptable) { + IAdaptable adaptable = (IAdaptable) element; + resource = (IResource) adaptable.getAdapter(IResource.class); + } + } + + if (resource != null) + return resource.getType() != IResource.FILE; + else + return false; + } + } +} diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/variable/WorkspaceExpander.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/variable/WorkspaceExpander.java new file mode 100644 index 000000000..6bfcee579 --- /dev/null +++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/variable/WorkspaceExpander.java @@ -0,0 +1,36 @@ +package org.eclipse.ui.externaltools.internal.variable; + +/********************************************************************** +Copyright (c) 2002 IBM Corp. and others. All rights reserved. +This file is made available under the terms of the Common Public License v1.0 +which accompanies this distribution, and is available at +http://www.eclipse.org/legal/cpl-v10.html + +Contributors: +**********************************************************************/ + +import org.eclipse.core.resources.IResource; + +/** + * Expands a workspace variable into the desired + * result format. + * <p> + * This class is not intended to be extended by clients. + * </p> + */ +public class WorkspaceExpander extends ResourceExpander { + + /** + * Create an instance + */ + public WorkspaceExpander() { + super(); + } + + /* (non-Javadoc) + * Method declared on ResourceExpander. + */ + /*package*/ IResource expandUsingContext(ExpandVariableContext context) { + return getWorkspaceRoot(); + } +} diff --git a/org.eclipse.ui.externaltools/Program Tools Support/org/eclipse/ui/externaltools/internal/program/launchConfigurations/BackgroundResourceRefresher.java b/org.eclipse.ui.externaltools/Program Tools Support/org/eclipse/ui/externaltools/internal/program/launchConfigurations/BackgroundResourceRefresher.java index a6612f017..9080aa630 100644 --- a/org.eclipse.ui.externaltools/Program Tools Support/org/eclipse/ui/externaltools/internal/program/launchConfigurations/BackgroundResourceRefresher.java +++ b/org.eclipse.ui.externaltools/Program Tools Support/org/eclipse/ui/externaltools/internal/program/launchConfigurations/BackgroundResourceRefresher.java @@ -20,9 +20,9 @@ import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.model.IProcess; import org.eclipse.jface.dialogs.ProgressMonitorDialog; import org.eclipse.jface.operation.IRunnableWithProgress; +import org.eclipse.ui.externaltools.internal.launchConfigurations.ExternalToolsUtil; import org.eclipse.ui.externaltools.internal.model.ExternalToolsPlugin; -import org.eclipse.ui.externaltools.launchConfigurations.ExternalToolsUtil; -import org.eclipse.ui.externaltools.variable.ExpandVariableContext; +import org.eclipse.ui.externaltools.internal.variable.ExpandVariableContext; /** * Refreshes resources as specified by a lanunch configuration, when diff --git a/org.eclipse.ui.externaltools/Program Tools Support/org/eclipse/ui/externaltools/internal/program/launchConfigurations/ProgramBuilderTabGroup.java b/org.eclipse.ui.externaltools/Program Tools Support/org/eclipse/ui/externaltools/internal/program/launchConfigurations/ProgramBuilderTabGroup.java index f98a20102..a7072281e 100644 --- a/org.eclipse.ui.externaltools/Program Tools Support/org/eclipse/ui/externaltools/internal/program/launchConfigurations/ProgramBuilderTabGroup.java +++ b/org.eclipse.ui.externaltools/Program Tools Support/org/eclipse/ui/externaltools/internal/program/launchConfigurations/ProgramBuilderTabGroup.java @@ -10,8 +10,8 @@ http://www.eclipse.org/legal/cpl-v10.html import org.eclipse.debug.ui.AbstractLaunchConfigurationTabGroup; import org.eclipse.debug.ui.ILaunchConfigurationDialog; import org.eclipse.debug.ui.ILaunchConfigurationTab; -import org.eclipse.ui.externaltools.launchConfigurations.ExternalToolsBuilderTab; -import org.eclipse.ui.externaltools.launchConfigurations.ExternalToolsRefreshTab; +import org.eclipse.ui.externaltools.internal.launchConfigurations.ExternalToolsBuilderTab; +import org.eclipse.ui.externaltools.internal.launchConfigurations.ExternalToolsRefreshTab; public class ProgramBuilderTabGroup extends AbstractLaunchConfigurationTabGroup { @@ -26,5 +26,4 @@ public class ProgramBuilderTabGroup extends AbstractLaunchConfigurationTabGroup }; setTabs(tabs); } - } diff --git a/org.eclipse.ui.externaltools/Program Tools Support/org/eclipse/ui/externaltools/internal/program/launchConfigurations/ProgramLaunchDelegate.java b/org.eclipse.ui.externaltools/Program Tools Support/org/eclipse/ui/externaltools/internal/program/launchConfigurations/ProgramLaunchDelegate.java index 82f94fc63..8c98dcc58 100644 --- a/org.eclipse.ui.externaltools/Program Tools Support/org/eclipse/ui/externaltools/internal/program/launchConfigurations/ProgramLaunchDelegate.java +++ b/org.eclipse.ui.externaltools/Program Tools Support/org/eclipse/ui/externaltools/internal/program/launchConfigurations/ProgramLaunchDelegate.java @@ -19,8 +19,8 @@ import org.eclipse.debug.core.ILaunch; import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.model.ILaunchConfigurationDelegate; import org.eclipse.debug.core.model.IProcess; -import org.eclipse.ui.externaltools.launchConfigurations.ExternalToolsUtil; -import org.eclipse.ui.externaltools.variable.ExpandVariableContext; +import org.eclipse.ui.externaltools.internal.launchConfigurations.ExternalToolsUtil; +import org.eclipse.ui.externaltools.internal.variable.ExpandVariableContext; /** * Launch delegate for a program. diff --git a/org.eclipse.ui.externaltools/Program Tools Support/org/eclipse/ui/externaltools/internal/program/launchConfigurations/ProgramMainTab.java b/org.eclipse.ui.externaltools/Program Tools Support/org/eclipse/ui/externaltools/internal/program/launchConfigurations/ProgramMainTab.java index 6e420d766..ecd6b3ca0 100644 --- a/org.eclipse.ui.externaltools/Program Tools Support/org/eclipse/ui/externaltools/internal/program/launchConfigurations/ProgramMainTab.java +++ b/org.eclipse.ui.externaltools/Program Tools Support/org/eclipse/ui/externaltools/internal/program/launchConfigurations/ProgramMainTab.java @@ -9,10 +9,10 @@ http://www.eclipse.org/legal/cpl-v10.html import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.ui.externaltools.internal.launchConfigurations.ExternalToolsMainTab; +import org.eclipse.ui.externaltools.internal.model.IExternalToolConstants; +import org.eclipse.ui.externaltools.internal.model.ToolUtil; import org.eclipse.ui.externaltools.internal.ui.FileSelectionDialog; -import org.eclipse.ui.externaltools.launchConfigurations.ExternalToolsMainTab; -import org.eclipse.ui.externaltools.model.IExternalToolConstants; -import org.eclipse.ui.externaltools.model.ToolUtil; public class ProgramMainTab extends ExternalToolsMainTab { diff --git a/org.eclipse.ui.externaltools/Program Tools Support/org/eclipse/ui/externaltools/internal/program/launchConfigurations/ProgramTabGroup.java b/org.eclipse.ui.externaltools/Program Tools Support/org/eclipse/ui/externaltools/internal/program/launchConfigurations/ProgramTabGroup.java index 74b0a38e7..356d3b067 100644 --- a/org.eclipse.ui.externaltools/Program Tools Support/org/eclipse/ui/externaltools/internal/program/launchConfigurations/ProgramTabGroup.java +++ b/org.eclipse.ui.externaltools/Program Tools Support/org/eclipse/ui/externaltools/internal/program/launchConfigurations/ProgramTabGroup.java @@ -11,7 +11,7 @@ import org.eclipse.debug.ui.AbstractLaunchConfigurationTabGroup; import org.eclipse.debug.ui.CommonTab; import org.eclipse.debug.ui.ILaunchConfigurationDialog; import org.eclipse.debug.ui.ILaunchConfigurationTab; -import org.eclipse.ui.externaltools.launchConfigurations.ExternalToolsRefreshTab; +import org.eclipse.ui.externaltools.internal.launchConfigurations.ExternalToolsRefreshTab; public class ProgramTabGroup extends AbstractLaunchConfigurationTabGroup { |