diff options
Diffstat (limited to 'org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/model')
12 files changed, 0 insertions, 1775 deletions
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/model/BuilderUtils.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/model/BuilderUtils.java deleted file mode 100644 index e253213e0..000000000 --- a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/model/BuilderUtils.java +++ /dev/null @@ -1,283 +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.model; - -import java.util.HashMap; -import java.util.Map; - -import org.eclipse.core.resources.ICommand; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IFolder; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.IExtensionPoint; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.Platform; -import org.eclipse.debug.core.DebugPlugin; -import org.eclipse.debug.core.ILaunchConfiguration; -import org.eclipse.debug.core.ILaunchConfigurationType; -import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; -import org.eclipse.debug.core.ILaunchManager; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.externaltools.internal.registry.ExternalToolMigration; - -/** - * Utility methods for working with external tool project builders. - */ -public class BuilderUtils { - - public static final String LAUNCH_CONFIG_HANDLE = "LaunchConfigHandle"; //$NON-NLS-1$ - - /** - * Constant used to find a builder using the 3.0-interim format - */ - public static final String BUILDER_FOLDER_NAME= ".externalToolBuilders"; //$NON-NLS-1$ - /** - * Constant used to represent the current project in the 3.0-final format. - */ - public static final String PROJECT_TAG= "<project>"; //$NON-NLS-1$ - - public static final String VERSION_1_0= "1.0"; //$NON-NLS-1$ - public static final String VERSION_2_1= "2.1"; //$NON-NLS-1$ - // The format shipped up to and including Eclipse 3.0 RC1 - public static final String VERSION_3_0_interim= "3.0.interim"; //$NON-NLS-1$ - // The format shipped in Eclipse 3.0 final - public static final String VERSION_3_0_final= "3.0"; //$NON-NLS-1$ - - // Extension point constants. - private static final String TAG_CONFIGURATION_MAP= "configurationMap"; //$NON-NLS-1$ - private static final String TAG_SOURCE_TYPE= "sourceType"; //$NON-NLS-1$ - private static final String TAG_BUILDER_TYPE= "builderType"; //$NON-NLS-1$ - - /** - * Returns a launch configuration from the given ICommand arguments. If the - * given arguments are from an old-style external tool, an unsaved working - * copy will be created from the arguments and returned. - * - * @param commandArgs the builder ICommand arguments - * @return a launch configuration, a launch configuration working copy, or - * <code>null</code> if not possible. - */ - public static ILaunchConfiguration configFromBuildCommandArgs(IProject project, Map commandArgs, String[] version) { - String configHandle = (String) commandArgs.get(LAUNCH_CONFIG_HANDLE); - if (configHandle == null) { - // Probably an old-style (Eclipse 1.0 or 2.0) external tool. Try to migrate. - version[0]= VERSION_1_0; - return ExternalToolMigration.configFromArgumentMap(commandArgs); - } - ILaunchManager manager= DebugPlugin.getDefault().getLaunchManager(); - ILaunchConfiguration configuration= null; - if (configHandle.startsWith(PROJECT_TAG)) { - version[0]= VERSION_3_0_final; - IPath path= new Path(configHandle); - IFile file= project.getFile(path.removeFirstSegments(1)); - if (file.exists()) { - configuration= manager.getLaunchConfiguration(file); - } - } else { - // Try treating the handle as a file name. - // This is the format used in 3.0 RC1. - IPath path= new Path(BUILDER_FOLDER_NAME).append(configHandle); - IFile file= project.getFile(path); - if (file.exists()) { - version[0]= VERSION_3_0_interim; - configuration= manager.getLaunchConfiguration(file); - } else { - try { - // Treat the configHandle as a memento. This is the format - // used in Eclipse 2.1. - configuration = manager.getLaunchConfiguration(configHandle); - } catch (CoreException e) { - } - if (configuration != null) { - version[0]= VERSION_2_1; - } - } - } - return configuration; - } - - /** - * Returns an <code>ICommand</code> from the given launch configuration. - * - * @param project the project the ICommand is relevant to - * @param config, the launch configuration to create the command from - * @return the new command. <code>null</code> can be returned if problems occur during - * the translation. - */ - public static ICommand commandFromLaunchConfig(IProject project, ILaunchConfiguration config) { - ICommand newCommand = null; - try { - newCommand = project.getDescription().newCommand(); - newCommand = toBuildCommand(project, config, newCommand); - } catch (CoreException exception) { - Shell shell= ExternalToolsPlugin.getActiveWorkbenchShell(); - if (shell != null) { - MessageDialog.openError(shell, ExternalToolsModelMessages.getString("BuilderUtils.5"), ExternalToolsModelMessages.getString("BuilderUtils.6")); //$NON-NLS-1$ //$NON-NLS-2$ - } - return null; - } - return newCommand; - } - - /** - * Returns whether the given configuration is an "unmigrated" builder. - * Unmigrated builders are external tools that are stored in an old format - * but have not been migrated by the user. Old format builders are always - * translated into launch config working copies in memory, but they're not - * considered "migrated" until the config has been saved and the project spec - * updated. - * @param config the config to examine - * @return whether the given config represents an unmigrated builder - */ - public static boolean isUnmigratedConfig(ILaunchConfiguration config) { - return config.isWorkingCopy() && ((ILaunchConfigurationWorkingCopy) config).getOriginal() == null; - } - - /** - * Converts the given config to a build command which is stored in the - * given command. - * - * @return the configured build command - */ - public static ICommand toBuildCommand(IProject project, ILaunchConfiguration config, ICommand command) throws CoreException { - Map args= null; - if (isUnmigratedConfig(config)) { - // This config represents an old external tool builder that hasn't - // been edited. Try to find the old ICommand and reuse the arguments. - // The goal here is to not change the storage format of old, unedited builders. - ICommand[] commands= project.getDescription().getBuildSpec(); - for (int i = 0; i < commands.length; i++) { - ICommand projectCommand = commands[i]; - String name= ExternalToolMigration.getNameFromCommandArgs(projectCommand.getArguments()); - if (name != null && name.equals(config.getName())) { - args= projectCommand.getArguments(); - break; - } - } - } else { - if (config instanceof ILaunchConfigurationWorkingCopy) { - ILaunchConfigurationWorkingCopy workingCopy= (ILaunchConfigurationWorkingCopy) config; - if (workingCopy.getOriginal() != null) { - config= workingCopy.getOriginal(); - } - } - args= new HashMap(); - // Launch configuration builders are stored with a project-relative path - StringBuffer buffer= new StringBuffer(PROJECT_TAG); - // Append the project-relative path (workspace path minus first segment) - buffer.append('/').append(config.getFile().getFullPath().removeFirstSegments(1)); - args.put(LAUNCH_CONFIG_HANDLE, buffer.toString()); - } - command.setBuilderName(ExternalToolBuilder.ID); - command.setArguments(args); - return command; - } - - /** - * Returns the type of launch configuration that should be created when - * duplicating the given configuration as a project builder. Queries to see - * if an extension has been specified to explicitly declare the mapping. - */ - public static ILaunchConfigurationType getConfigurationDuplicationType(ILaunchConfiguration config) throws CoreException { - IExtensionPoint ep= Platform.getExtensionRegistry().getExtensionPoint(IExternalToolConstants.PLUGIN_ID, IExternalToolConstants.EXTENSION_POINT_CONFIGURATION_DUPLICATION_MAPS); - IConfigurationElement[] elements = ep.getConfigurationElements(); - String sourceType= config.getType().getIdentifier(); - String builderType= null; - for (int i= 0; i < elements.length; i++) { - IConfigurationElement element= elements[i]; - if (element.getName().equals(TAG_CONFIGURATION_MAP) && sourceType.equals(element.getAttribute(TAG_SOURCE_TYPE))) { - builderType= element.getAttribute(TAG_BUILDER_TYPE); - break; - } - } - if (builderType != null) { - ILaunchConfigurationType type= DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurationType(builderType); - if (type != null) { - return type; - } - } - return config.getType(); - } - - /** - * Returns the folder where project builders should be stored or - * <code>null</code> if the folder could not be created - */ - public static IFolder getBuilderFolder(IProject project, boolean create) { - IFolder folder = project.getFolder(BUILDER_FOLDER_NAME); - if (!folder.exists() && create) { - try { - folder.create(true, true, new NullProgressMonitor()); - } catch (CoreException e) { - return null; - } - } - return folder; - } - - /** - * Returns a duplicate of the given configuration. The new configuration - * will be of the same type as the given configuration or of the duplication - * type registered for the given configuration via the extension point - * IExternalToolConstants.EXTENSION_POINT_CONFIGURATION_DUPLICATION_MAPS. - */ - public static ILaunchConfiguration duplicateConfiguration(IProject project, ILaunchConfiguration config) throws CoreException { - Map attributes= null; - attributes= config.getAttributes(); - String newName= new StringBuffer(config.getName()).append(ExternalToolsModelMessages.getString("BuilderUtils.7")).toString(); //$NON-NLS-1$ - newName= DebugPlugin.getDefault().getLaunchManager().generateUniqueLaunchConfigurationNameFrom(newName); - ILaunchConfigurationType newType= getConfigurationDuplicationType(config); - ILaunchConfigurationWorkingCopy newWorkingCopy= newType.newInstance(getBuilderFolder(project, true), newName); - newWorkingCopy.setAttributes(attributes); - return newWorkingCopy.doSave(); - } - - /** - * Migrates the launch configuration working copy, which is based on an old- - * style external tool builder, to a new, saved launch configuration. The - * returned launch configuration will contain the same attributes as the - * given working copy with the exception of the configuration name, which - * may be changed during the migration. The name of the configuration will - * only be changed if the current name is not a valid name for a saved - * config. - * - * @param workingCopy the launch configuration containing attributes from an - * old-style project builder. - * @return ILaunchConfiguration a new, saved launch configuration whose - * attributes match those of the given working copy as well as possible - * @throws CoreException if an exception occurs while attempting to save the - * new launch configuration - */ - public static ILaunchConfiguration migrateBuilderConfiguration(IProject project, ILaunchConfigurationWorkingCopy workingCopy) throws CoreException { - workingCopy.setContainer(getBuilderFolder(project, true)); - // Before saving, make sure the name is valid - String name= workingCopy.getName(); - name= name.replace('/', '.'); - if (name.charAt(0) == ('.')) { - name = name.substring(1); - } - IStatus status = ResourcesPlugin.getWorkspace().validateName(name, IResource.FILE); - if (!status.isOK()) { - name = "ExternalTool"; //$NON-NLS-1$ - } - name = DebugPlugin.getDefault().getLaunchManager().generateUniqueLaunchConfigurationNameFrom(name); - workingCopy.rename(name); - return workingCopy.doSave(); - } -}
\ No newline at end of file diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/model/ExternalToolBuilder.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/model/ExternalToolBuilder.java deleted file mode 100644 index 948043ce1..000000000 --- a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/model/ExternalToolBuilder.java +++ /dev/null @@ -1,276 +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.model; - - -import java.text.MessageFormat; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.StringTokenizer; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IResourceDelta; -import org.eclipse.core.resources.IResourceDeltaVisitor; -import org.eclipse.core.resources.IncrementalProjectBuilder; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.debug.core.ILaunchConfiguration; -import org.eclipse.debug.core.ILaunchManager; -import org.eclipse.ui.externaltools.internal.launchConfigurations.ExternalToolsUtil; -import org.eclipse.ui.externaltools.internal.registry.ExternalToolMigration; -import org.osgi.framework.Bundle; - -/** - * This project builder implementation will run an external tool during the - * build process. - */ -public final class ExternalToolBuilder extends IncrementalProjectBuilder { - private final class IgnoreTeamPrivateChanges implements IResourceDeltaVisitor { - private boolean[] fTrueChange; - private IgnoreTeamPrivateChanges(boolean[] trueChange) { - super(); - fTrueChange= trueChange; - } - public boolean visit(IResourceDelta visitDelta) throws CoreException { - IResource resource= visitDelta.getResource(); - if (resource instanceof IFile) { - fTrueChange[0]= true; - return false; - } - return true; - } - } - - public static final String ID = "org.eclipse.ui.externaltools.ExternalToolBuilder"; //$NON-NLS-1$; - - private static final String BUILD_TYPE_SEPARATOR = ","; //$NON-NLS-1$ - private static final int[] DEFAULT_BUILD_TYPES= new int[] { - IncrementalProjectBuilder.INCREMENTAL_BUILD, - IncrementalProjectBuilder.FULL_BUILD}; - - private static String buildType = IExternalToolConstants.BUILD_TYPE_NONE; - - private static IProject buildProject= null; - - private List projectsWithinScope; - - private boolean buildKindCompatible(int kind, ILaunchConfiguration config) throws CoreException { - int[] buildKinds = buildTypesToArray(config.getAttribute(IExternalToolConstants.ATTR_RUN_BUILD_KINDS, "")); //$NON-NLS-1$ - for (int j = 0; j < buildKinds.length; j++) { - if (kind == buildKinds[j]) { - return true; - } - } - return false; - } - - /* (non-Javadoc) - * @see org.eclipse.core.internal.events.InternalBuilder#build(int, java.util.Map, org.eclipse.core.runtime.IProgressMonitor) - */ - protected IProject[] build(int kind, Map args, IProgressMonitor monitor) throws CoreException { - if (ExternalToolsPlugin.getDefault().getBundle().getState() != Bundle.ACTIVE) { - return null; - } - - projectsWithinScope= new ArrayList(); - ILaunchConfiguration config = BuilderUtils.configFromBuildCommandArgs(getProject(), args, new String[1]); - if (config != null && buildKindCompatible(kind, config) && configEnabled(config)) { - doBuildBasedOnScope(kind, config, monitor); - } - return getProjectsWithinScope(); - } - - /** - * Returns whether the given builder config is enabled or not. - * - * @param config the config to examine - * @return whether the config is enabled - */ - private boolean configEnabled(ILaunchConfiguration config) { - try { - return ExternalToolsUtil.isBuilderEnabled(config); - } catch (CoreException e) { - ExternalToolsPlugin.getDefault().log(e); - } - return true; - } - - private IProject[] getProjectsWithinScope() { - if (projectsWithinScope == null || projectsWithinScope.isEmpty()) { - projectsWithinScope = null; - return null; - } - return (IProject[])projectsWithinScope.toArray(new IProject[projectsWithinScope.size()]); - } - - private void doBuildBasedOnScope(int kind, ILaunchConfiguration config, IProgressMonitor monitor) throws CoreException { - boolean buildForChange = true; - if (kind != FULL_BUILD) { //scope not applied for full builds - IResource[] resources = ExternalToolsUtil.getResourcesForBuildScope(config); - if (resources != null && resources.length > 0) { - for (int i = 0; i < resources.length; i++) { - IResource resource = resources[i]; - projectsWithinScope.add(resource.getProject()); - } - buildForChange = buildScopeIndicatesBuild(resources); - } - } - - if (buildForChange) { - launchBuild(kind, config, monitor); - } - } - - private void launchBuild(int kind, ILaunchConfiguration config, IProgressMonitor monitor) throws CoreException { - monitor.subTask(MessageFormat.format(ExternalToolsModelMessages.getString("ExternalToolBuilder.Running_{0}..._1"), new String[] { config.getName()})); //$NON-NLS-1$ - buildStarted(kind); - // The default value for "launch in background" is true in debug core. If - // the user doesn't go through the UI, the new attribute won't be set. This means - // that existing Ant builders will try to run in the background (and likely conflict with - // each other) without migration. - config= ExternalToolMigration.migrateRunInBackground(config); - config.launch(ILaunchManager.RUN_MODE, monitor); - buildEnded(); - } - - /** - * 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 static String getBuildType() { - return buildType; - } - - /** - * Returns the project that is being built and has triggered the current external - * tool builder. <code>null</code> is returned if no build is currently occurring. - * - * @return project being built or <code>null</code>. - */ - public static IProject getBuildProject() { - return buildProject; - } - - /** - * Stores the currently active build kind and build project when a build begins - * @param buildKind - */ - private void buildStarted(int buildKind) { - switch (buildKind) { - case IncrementalProjectBuilder.INCREMENTAL_BUILD : - buildType = IExternalToolConstants.BUILD_TYPE_INCREMENTAL; - break; - case IncrementalProjectBuilder.FULL_BUILD : - buildType = IExternalToolConstants.BUILD_TYPE_FULL; - break; - case IncrementalProjectBuilder.AUTO_BUILD : - buildType = IExternalToolConstants.BUILD_TYPE_AUTO; - break; - default : - buildType = IExternalToolConstants.BUILD_TYPE_NONE; - break; - } - buildProject= getProject(); - } - - /** - * Clears the current build kind and build project when a build finishes. - */ - private void buildEnded() { - buildType= IExternalToolConstants.BUILD_TYPE_NONE; - buildProject= null; - } - - private boolean buildScopeIndicatesBuild(IResource[] resources) { - for (int i = 0; i < resources.length; i++) { - IResourceDelta delta = getDelta(resources[i].getProject()); - if (delta == null) { - //project just added to the workspace..no previous build tree - return true; - } - IPath path= resources[i].getProjectRelativePath(); - IResourceDelta change= delta.findMember(path); - if (change != null) { - final boolean[] trueChange= new boolean[1]; - trueChange[0]= false; - try { - change.accept(new IgnoreTeamPrivateChanges(trueChange)); - } catch (CoreException e) { - ExternalToolsPlugin.getDefault().log("Internal error resolving changed resources during build", e); //$NON-NLS-1$ - } - - return trueChange[0]; //filtered out team private changes - } - } - return false; - } - - /** - * Converts the build types string into an array of - * build kinds. - * - * @param buildTypes the string of built types to convert - * @return the array of build kinds. - */ - public static int[] buildTypesToArray(String buildTypes) { - if (buildTypes == null || buildTypes.length() == 0) { - return DEFAULT_BUILD_TYPES; - } - - int count = 0; - boolean incremental = false; - boolean full = false; - boolean auto = false; - - StringTokenizer tokenizer = new StringTokenizer(buildTypes, BUILD_TYPE_SEPARATOR); - while (tokenizer.hasMoreTokens()) { - String token = tokenizer.nextToken(); - if (IExternalToolConstants.BUILD_TYPE_INCREMENTAL.equals(token)) { - if (!incremental) { - incremental = true; - count++; - } - } else if (IExternalToolConstants.BUILD_TYPE_FULL.equals(token)) { - if (!full) { - full = true; - count++; - } - } else if (IExternalToolConstants.BUILD_TYPE_AUTO.equals(token)) { - if (!auto) { - auto = true; - count++; - } - } - } - - int[] results = new int[count]; - count = 0; - if (incremental) { - results[count] = IncrementalProjectBuilder.INCREMENTAL_BUILD; - count++; - } - if (full) { - results[count] = IncrementalProjectBuilder.FULL_BUILD; - count++; - } - if (auto) { - results[count] = IncrementalProjectBuilder.AUTO_BUILD; - count++; - } - - return results; - } -}
\ No newline at end of file diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/model/ExternalToolsImages.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/model/ExternalToolsImages.java deleted file mode 100644 index 5ba59682a..000000000 --- a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/model/ExternalToolsImages.java +++ /dev/null @@ -1,215 +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.model; - -import java.net.MalformedURLException; -import java.net.URL; -import java.util.HashMap; -import java.util.Map; - -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.resource.CompositeImageDescriptor; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.resource.ImageRegistry; -import org.eclipse.swt.graphics.Image; - -/** - * The images provided by the external tools plugin. - */ -public class ExternalToolsImages { - - /** - * The image registry containing <code>Image</code>s. - */ - private static ImageRegistry imageRegistry; - - /** - * The registry for composite images - */ - private static ImageDescriptorRegistry imageDescriptorRegistry; - - /** - * A table of all the <code>ImageDescriptor</code>s. - */ - private static Map imageDescriptors; - - /* Declare Common paths */ - private static URL ICON_BASE_URL= null; - - static { - String pathSuffix = "icons/full/"; //$NON-NLS-1$ - ICON_BASE_URL= ExternalToolsPlugin.getDefault().getBundle().getEntry(pathSuffix); - } - - // Use IPath and toOSString to build the names to ensure they have the slashes correct - private final static String OBJECT= "obj16/"; //basic colors - size 16x16 //$NON-NLS-1$ - - /** - * Declare all images - */ - private static void declareImages() { - // Objects - declareRegistryImage(IExternalToolConstants.IMG_TAB_MAIN, OBJECT + "main_tab.gif"); //$NON-NLS-1$ - } - - /** - * Declare an Image in the registry table. - * @param key The key to use when registering the image - * @param path The path where the image can be found. This path is relative to where - * this plugin class is found (i.e. typically the packages directory) - */ - private final static void declareRegistryImage(String key, String path) { - ImageDescriptor desc= ImageDescriptor.getMissingImageDescriptor(); - try { - desc= ImageDescriptor.createFromURL(makeIconFileURL(path)); - } catch (MalformedURLException me) { - } - imageRegistry.put(key, desc); - imageDescriptors.put(key, desc); - } - - /** - * Returns the ImageRegistry. - */ - public static ImageRegistry getImageRegistry() { - if (imageRegistry == null) { - initializeImageRegistry(); - } - return imageRegistry; - } - - /** - * Initialize the image registry by declaring all of the required - * graphics. This involves creating JFace image descriptors describing - * how to create/find the image should it be needed. - * The image is not actually allocated until requested. - * - * Prefix conventions - * Wizard Banners WIZBAN_ - * Preference Banners PREF_BAN_ - * Property Page Banners PROPBAN_ - * Color toolbar CTOOL_ - * Enable toolbar ETOOL_ - * Disable toolbar DTOOL_ - * Local enabled toolbar ELCL_ - * Local Disable toolbar DLCL_ - * Object large OBJL_ - * Object small OBJS_ - * View VIEW_ - * Product images PROD_ - * Misc images MISC_ - * - * Where are the images? - * The images (typically gifs) are found in the same location as this plugin class. - * This may mean the same package directory as the package holding this class. - * The images are declared using this.getClass() to ensure they are looked up via - * this plugin class. - * @see org.eclipse.jface.resource.ImageRegistry - */ - public static ImageRegistry initializeImageRegistry() { - imageRegistry= new ImageRegistry(ExternalToolsPlugin.getStandardDisplay()); - imageDescriptors = new HashMap(30); - declareImages(); - return imageRegistry; - } - - /** - * Returns the <code>Image<code> identified by the given key, - * or <code>null</code> if it does not exist. - */ - public static Image getImage(String key) { - return getImageRegistry().get(key); - } - - /** - * Returns the <code>ImageDescriptor<code> identified by the given key, - * or <code>null</code> if it does not exist. - */ - public static ImageDescriptor getImageDescriptor(String key) { - if (imageDescriptors == null) { - initializeImageRegistry(); - } - return (ImageDescriptor)imageDescriptors.get(key); - } - - private static URL makeIconFileURL(String iconPath) throws MalformedURLException { - if (ICON_BASE_URL == null) { - throw new MalformedURLException(); - } - - return new URL(ICON_BASE_URL, iconPath); - } - - /** - * Sets the three image descriptors for enabled, disabled, and hovered to an action. The actions - * are retrieved from the *lcl16 folders. - */ - public static void setLocalImageDescriptors(IAction action, String iconName) { - setImageDescriptors(action, "lcl16", iconName); //$NON-NLS-1$ - } - - private static void setImageDescriptors(IAction action, String type, String relPath) { - - try { - ImageDescriptor id= ImageDescriptor.createFromURL(makeIconFileURL("d" + type, relPath)); //$NON-NLS-1$ - if (id != null) - action.setDisabledImageDescriptor(id); - } catch (MalformedURLException e) { - ExternalToolsPlugin.getDefault().log(e); - } - - try { - ImageDescriptor id= ImageDescriptor.createFromURL(makeIconFileURL("c" + type, relPath)); //$NON-NLS-1$ - if (id != null) - action.setHoverImageDescriptor(id); - } catch (MalformedURLException e) { - ExternalToolsPlugin.getDefault().log(e); - } - - action.setImageDescriptor(create("e" + type, relPath)); //$NON-NLS-1$ - } - - private static URL makeIconFileURL(String prefix, String name) throws MalformedURLException { - if (ICON_BASE_URL == null) { - throw new MalformedURLException(); - } - - StringBuffer buffer= new StringBuffer(prefix); - buffer.append('/'); - buffer.append(name); - return new URL(ICON_BASE_URL, buffer.toString()); - } - - private static ImageDescriptor create(String prefix, String name) { - try { - return ImageDescriptor.createFromURL(makeIconFileURL(prefix, name)); - } catch (MalformedURLException e) { - ExternalToolsPlugin.getDefault().log(e); - return ImageDescriptor.getMissingImageDescriptor(); - } - } - - /** - * Returns the image for the given composite descriptor. - */ - public static Image getImage(CompositeImageDescriptor imageDescriptor) { - if (imageDescriptorRegistry == null) { - imageDescriptorRegistry = new ImageDescriptorRegistry(); - } - return imageDescriptorRegistry.get(imageDescriptor); - } - - public static void disposeImageDescriptorRegistry() { - if (imageDescriptorRegistry != null) { - imageDescriptorRegistry.dispose(); - } - } -}
\ No newline at end of file diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/model/ExternalToolsModelMessages.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/model/ExternalToolsModelMessages.java deleted file mode 100644 index 75bd41e71..000000000 --- a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/model/ExternalToolsModelMessages.java +++ /dev/null @@ -1,32 +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.model; - -import java.util.MissingResourceException; -import java.util.ResourceBundle; - -public class ExternalToolsModelMessages { - - private static final String BUNDLE_NAME = "org.eclipse.ui.externaltools.internal.model.ExternalToolsModelMessages"; //$NON-NLS-1$ - - private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME); - - private ExternalToolsModelMessages() { - } - - 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/model/ExternalToolsModelMessages.properties b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/model/ExternalToolsModelMessages.properties deleted file mode 100644 index 61fcca0f3..000000000 --- a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/model/ExternalToolsModelMessages.properties +++ /dev/null @@ -1,16 +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 -############################################################################### - -ImageDescriptorRegistry.Allocating_image_for_wrong_display_1=Allocating image for wrong display -ExternalToolBuilder.Running_{0}..._1=Running {0}... -BuilderUtils.5=Command Error -BuilderUtils.6=An error occurred while saving the project's build commands -BuilderUtils.7=\ [Builder] diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/model/ExternalToolsPlugin.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/model/ExternalToolsPlugin.java deleted file mode 100644 index d412fb51e..000000000 --- a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/model/ExternalToolsPlugin.java +++ /dev/null @@ -1,167 +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.model; - - -import java.net.MalformedURLException; -import java.net.URL; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.resource.ImageRegistry; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.plugin.AbstractUIPlugin; -import org.osgi.framework.Bundle; -import org.osgi.framework.BundleContext; - -/** - * External tools plug-in class - */ -public final class ExternalToolsPlugin extends AbstractUIPlugin { - /** - * Status representing no problems encountered during operation. - */ - public static final IStatus OK_STATUS = new Status(IStatus.OK, IExternalToolConstants.PLUGIN_ID, 0, "", null); //$NON-NLS-1$ - - private static ExternalToolsPlugin plugin; - - private static final String EMPTY_STRING= ""; //$NON-NLS-1$ - - /** - * Create an instance of the External Tools plug-in. - */ - public ExternalToolsPlugin() { - super(); - plugin = this; - } - - /** - * Returns the default instance of the receiver. - * This represents the runtime plugin. - */ - public static ExternalToolsPlugin getDefault() { - return plugin; - } - - /** - * Returns a new <code>IStatus</code> for this plug-in - */ - public static IStatus newErrorStatus(String message, Throwable exception) { - if (message == null) { - message= EMPTY_STRING; - } - return new Status(IStatus.ERROR, IExternalToolConstants.PLUGIN_ID, 0, message, exception); - } - - /** - * Returns a new <code>CoreException</code> for this plug-in - */ - public static CoreException newError(String message, Throwable exception) { - return new CoreException(new Status(IStatus.ERROR, IExternalToolConstants.PLUGIN_ID, 0, message, exception)); - } - - /** - * Writes the message to the plug-in's log - * - * @param message the text to write to the log - */ - public void log(String message, Throwable exception) { - IStatus status = newErrorStatus(message, exception); - getLog().log(status); - } - - public void log(Throwable exception) { - //this message is intentionally not internationalized, as an exception may - // be due to the resource bundle itself - getLog().log(newErrorStatus("Internal error logged from External Tools UI: ", exception)); //$NON-NLS-1$ - } - - /** - * Returns the ImageDescriptor for the icon with the given path - * - * @return the ImageDescriptor object - */ - public ImageDescriptor getImageDescriptor(String path) { - try { - Bundle bundle= getDefault().getBundle(); - URL installURL = bundle.getEntry("/"); //$NON-NLS-1$ - URL url = new URL(installURL, path); - return ImageDescriptor.createFromURL(url); - } catch (MalformedURLException e) { - return null; - } - } - - /** - * Returns the active workbench window or <code>null</code> if none - */ - public static IWorkbenchWindow getActiveWorkbenchWindow() { - return getDefault().getWorkbench().getActiveWorkbenchWindow(); - } - - /** - * Returns the active workbench page or <code>null</code> if none. - */ - public static IWorkbenchPage getActivePage() { - IWorkbenchWindow window= getActiveWorkbenchWindow(); - if (window != null) { - return window.getActivePage(); - } - return null; - } - - /** - * Returns the active workbench shell or <code>null</code> if none. - */ - public static Shell getActiveWorkbenchShell() { - IWorkbenchWindow window = getActiveWorkbenchWindow(); - if (window != null) { - return window.getShell(); - } - return null; - } - - /** - * Returns the standard display to be used. The method first checks, if - * the thread calling this method has an associated display. If so, this - * display is returned. Otherwise the method returns the default display. - */ - public static Display getStandardDisplay() { - Display display = Display.getCurrent(); - if (display == null) { - display = Display.getDefault(); - } - return display; - } - - /* (non-Javadoc) - * @see org.eclipse.ui.plugin.AbstractUIPlugin#createImageRegistry() - */ - protected ImageRegistry createImageRegistry() { - return ExternalToolsImages.initializeImageRegistry(); - } - - /* (non-Javadoc) - * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext) - */ - public void stop(BundleContext context) throws Exception { - try { - ExternalToolsImages.disposeImageDescriptorRegistry(); - } finally { - super.stop(context); - } - } -}
\ No newline at end of file diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/model/ExternalToolsPreferenceInitializer.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/model/ExternalToolsPreferenceInitializer.java deleted file mode 100644 index 93eddffd3..000000000 --- a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/model/ExternalToolsPreferenceInitializer.java +++ /dev/null @@ -1,32 +0,0 @@ -/******************************************************************************* - * Copyright (c) 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.model; - -import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer; -import org.eclipse.jface.preference.IPreferenceStore; - -public class ExternalToolsPreferenceInitializer extends AbstractPreferenceInitializer { - - public ExternalToolsPreferenceInitializer() { - super(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences() - */ - public void initializeDefaultPreferences() { - IPreferenceStore prefs = ExternalToolsPlugin.getDefault().getPreferenceStore(); - prefs.setDefault(IPreferenceConstants.PROMPT_FOR_TOOL_MIGRATION, true); - prefs.setDefault(IPreferenceConstants.PROMPT_FOR_PROJECT_MIGRATION, true); - } -}
\ No newline at end of file diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/model/IExternalToolConstants.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/model/IExternalToolConstants.java deleted file mode 100644 index a0cd1ecb6..000000000 --- a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/model/IExternalToolConstants.java +++ /dev/null @@ -1,200 +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.model; - -/** - * Defines the constants available for client use. - * <p> - * This interface is not intended to be extended or implemented by clients. - * </p> - */ -public interface IExternalToolConstants { - /** - * Plugin identifier for external tools (value <code>org.eclipse.ui.externaltools</code>). - */ - public static final String PLUGIN_ID = "org.eclipse.ui.externaltools"; //$NON-NLS-1$; - - // ------- Extensions Points ------- - /** - * Extension point to declare the launch configuration type that should be - * created when duplicating an existing configuration as a project builder. - */ - public static final String EXTENSION_POINT_CONFIGURATION_DUPLICATION_MAPS = "configurationDuplicationMaps"; //$NON-NLS-1$ - // ------- Refresh Variables ------- - /** - * Variable that expands to the workspace root object (value <code>workspace</code>). - */ - public static final String VAR_WORKSPACE = "workspace"; //$NON-NLS-1$ - /** - * Variable that expands to the project resource (value <code>project</code>). - */ - public static final String VAR_PROJECT = "project"; //$NON-NLS-1$ - /** - * Variable that expands to the container resource (value <code>container</code>). - */ - public static final String VAR_CONTAINER = "container"; //$NON-NLS-1$ - /** - * Variable that expands to a resource (value <code>resource</code>). - */ - public static final String VAR_RESOURCE = "resource"; //$NON-NLS-1$ - /** - * Variable that expands to the working set object (value <code>working_set</code>). - */ - public static final String VAR_WORKING_SET = "working_set"; //$NON-NLS-1$ - // ------- Tool Types ------- - /** - * External tool type for programs such as executables, batch files, - * shell scripts, etc (value <code>programType</code>). - */ - public static final String TOOL_TYPE_PROGRAM = "programType"; //$NON-NLS-1$; - - // ------- Build Types ------- - /** - * Build type indicating an incremental project build request for - * the external tool running as a builder (value <code>incremental</code>). - */ - public static final String BUILD_TYPE_INCREMENTAL = "incremental"; //$NON-NLS-1$ - - /** - * Build type indicating a full project build request for - * the external tool running as a builder (value <code>full</code>). - */ - public static final String BUILD_TYPE_FULL = "full"; //$NON-NLS-1$ - - /** - * Build type indicating an automatic project build request for - * the external tool running as a builder (value <code>incremental</code>). - */ - public static final String BUILD_TYPE_AUTO = "auto"; //$NON-NLS-1$ - - /** - * Build type indicating an no project build request for - * the external tool running as a builder (value <code>none</code>). - */ - public static final String BUILD_TYPE_NONE = "none"; //$NON-NLS-1$ - - // ------- Images ------- - - /** - * Main tab image. - */ - public static final String IMG_TAB_MAIN = PLUGIN_ID + ".IMG_TAB_MAIN"; //$NON-NLS-1$ - - // ------- Launch configuration types -------- - /** - * Program launch configuration type identifier. - */ - public static final String ID_PROGRAM_LAUNCH_CONFIGURATION_TYPE = "org.eclipse.ui.externaltools.ProgramLaunchConfigurationType"; //$NON-NLS-1$ - - /** - * Program builder launch configuration type identifier. Program project - * builders are of this type. - */ - public static final String ID_PROGRAM_BUILDER_LAUNCH_CONFIGURATION_TYPE = "org.eclipse.ui.externaltools.ProgramBuilderLaunchConfigurationType"; //$NON-NLS-1$ - - // ------- Launch configuration category -------- - /** - * Identifier for external tools launch configuration category. Launch - * configuration types for external tools that appear in the external tools - * launch configuration dialog should belong to this category. - */ - public static final String ID_EXTERNAL_TOOLS_LAUNCH_CATEGORY = "org.eclipse.ui.externaltools"; //$NON-NLS-1$ - /** - * Identifier for external tools launch configuration builders category. - * Launch configuration types that can be added as project builders should - * belong to this category. - */ - public static final String ID_EXTERNAL_TOOLS_BUILDER_LAUNCH_CATEGORY = "org.eclipse.ui.externaltools.builder"; //$NON-NLS-1$ - - // ------- Launch configuration groups -------- - /** - * Identifier for external tools launch configuration group. The external - * tools launch configuration group corresponds to the external tools - * category in run mode. - */ - public static final String ID_EXTERNAL_TOOLS_LAUNCH_GROUP = "org.eclipse.ui.externaltools.launchGroup"; //$NON-NLS-1$ - /** - * Identifier for external tools launch configuration group - */ - public static final String ID_EXTERNAL_TOOLS_BUILDER_LAUNCH_GROUP = "org.eclipse.ui.externaltools.launchGroup.builder"; //$NON-NLS-1$ - - // ------- Common External Tool Launch Configuration Attributes ------- - - /** - * Boolean attribute indicating if external tool output should be captured. - * Default value is <code>false</code>. - * @deprecated since 3.1 Replaced by <code>org.eclipse.debug.core.DebugPlugin.ATTR_CAPTURE_OUTPUT</code> - */ - public static final String ATTR_CAPTURE_OUTPUT = PLUGIN_ID + ".ATTR_CAPTURE_OUTPUT"; //$NON-NLS-1$ - /** - * String attribute identifying the location of an external. Default value - * is <code>null</code>. Encoding is tool specific. - */ - public static final String ATTR_LOCATION = PLUGIN_ID + ".ATTR_LOCATION"; //$NON-NLS-1$ - - /** - * Boolean attribute indicating if the user should be prompted for - * arguments before running a tool. Default value is <code>false</code>. - * THIS ATTRIBUTE IS NOT USED. - */ - public static final String ATTR_PROMPT_FOR_ARGUMENTS = PLUGIN_ID + ".ATTR_PROMPT_FOR_ARGUMENTS"; //$NON-NLS-1$ - - /** - * String attribute identifying the scope of resources that should trigger an - * external tool to run. Default value is <code>null</code> - * indicating that the builder will be triggered for all changes. - */ - public static final String ATTR_BUILD_SCOPE = PLUGIN_ID + ".ATTR_BUILD_SCOPE"; //$NON-NLS-1$ - - - /** - * String attribute containing an array of build kinds for which an - * external tool builder should be run. - */ - public static final String ATTR_RUN_BUILD_KINDS = PLUGIN_ID + ".ATTR_RUN_BUILD_KINDS"; //$NON-NLS-1$ - - /** - * Boolean attribute indicating if the console should be shown on external - * tool output. Default value is <code>false</code>. - */ - public static final String ATTR_SHOW_CONSOLE = PLUGIN_ID + ".ATTR_SHOW_CONSOLE"; //$NON-NLS-1$ - - /** - * String attribute containing the arguments that should be passed to the - * tool. Default value is <code>null</code>, and encoding is tool specific. - */ - public static final String ATTR_TOOL_ARGUMENTS = PLUGIN_ID + ".ATTR_TOOL_ARGUMENTS"; //$NON-NLS-1$ - - /** - * String attribute identifying the working directory of an external tool. - * Default value is <code>null</code>, which indicates a default working - * directory, which is tool specific. - */ - public static final String ATTR_WORKING_DIRECTORY = PLUGIN_ID + ".ATTR_WORKING_DIRECTORY"; //$NON-NLS-1$ - - /** - * String attribute identifying whether an external tool builder configuration - * is enabled. The default value is <code>true</code>, which indicates - * that the configuration will be executed as appropriate by the builder. - */ - public static final String ATTR_BUILDER_ENABLED = PLUGIN_ID + ".ATTR_BUILDER_ENABLED"; //$NON-NLS-1$ - - /** - * Status code indicating an unexpected internal error. - */ - public static final int ERR_INTERNAL_ERROR = 150; - - /** - * String attribute identifying a non-external tool builder launch configuration that is disabled - * The value is the name of the disabled builder. - */ - public static final String ATTR_DISABLED_BUILDER = PLUGIN_ID + ".ATTR_DISABLED_BUILDER"; //$NON-NLS-1$ -}
\ No newline at end of file diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/model/IExternalToolsHelpContextIds.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/model/IExternalToolsHelpContextIds.java deleted file mode 100644 index 409bcac67..000000000 --- a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/model/IExternalToolsHelpContextIds.java +++ /dev/null @@ -1,37 +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.model; - - -/** - * Help context ids for the external tools. - * <p> - * This interface contains constants only; it is not intended to be implemented - * or extended. - * </p> - */ -public interface IExternalToolsHelpContextIds { - public static final String PREFIX = "org.eclipse.ui.externaltools."; //$NON-NLS-1$ - - // Preference Pages - public static final String EXTERNAL_TOOLS_PREFERENCE_PAGE = PREFIX + "preference_page_context"; //$NON-NLS-1$ - - // Property Pages - public static final String EXTERNAL_TOOLS_BUILDER_PROPERTY_PAGE = PREFIX + "builder_property_page_context"; //$NON-NLS-1$ - - //Dialogs - public static final String MESSAGE_WITH_TOGGLE_DIALOG = PREFIX + "message_with_toggle_dialog_context"; //$NON-NLS-1$ - public static final String FILE_SELECTION_DIALOG = PREFIX + "file_selection_dialog_context"; //$NON-NLS-1$ - - //Launch configuration dialog tabs - public static final String EXTERNAL_TOOLS_LAUNCH_CONFIGURATION_DIALOG_BUILDER_TAB = PREFIX + "builders_tab_context"; //$NON-NLS-1$ - public static final String EXTERNAL_TOOLS_LAUNCH_CONFIGURATION_DIALOG_PROGRAM_MAIN_TAB = PREFIX + "program_main_tab_context"; //$NON-NLS-1$ -} diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/model/IPreferenceConstants.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/model/IPreferenceConstants.java deleted file mode 100644 index fe9307e0e..000000000 --- a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/model/IPreferenceConstants.java +++ /dev/null @@ -1,33 +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.model; - - -/** - * Constants used to identify user preferences. - */ -public interface IPreferenceConstants { - - /** - * Boolean preference key which indicates whether or not the user should be prompted - * before an external tool project builder is migrated to the new builder format. - * This is used before an old-style (Eclipse 1.0 or 2.0) builder is migrated to - * the new format (launch configurations). - */ - public static final String PROMPT_FOR_TOOL_MIGRATION = "externaltools.builders.promptForMigration"; //$NON-NLS-1$ - /** - * Boolean preference key which indicates whether or not the user should be prompted - * before a project is migrated tot he new builder handle format. - * This is used before an old-style (Eclipse 2.1) project handle is migrated - * from the old format (launch config handles) to the new format (path to the launch). - */ - public static final String PROMPT_FOR_PROJECT_MIGRATION = "externaltools.builders.promptForProjectMigration"; //$NON-NLS-1$ -} diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/model/ImageDescriptorRegistry.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/model/ImageDescriptorRegistry.java deleted file mode 100644 index 3e20c1de8..000000000 --- a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/model/ImageDescriptorRegistry.java +++ /dev/null @@ -1,91 +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.model; - - -import java.util.HashMap; -import java.util.Iterator; - -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.util.Assert; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.widgets.Display; - -/** - * A registry that maps <code>ImageDescriptors</code> to <code>Image</code>. - */ -public class ImageDescriptorRegistry { - - private HashMap fRegistry= new HashMap(10); - private Display fDisplay; - - /** - * Creates a new image descriptor registry for the current or default display, - * respectively. - */ - public ImageDescriptorRegistry() { - this(ExternalToolsPlugin.getStandardDisplay()); - } - - /** - * Creates a new image descriptor registry for the given display. All images - * managed by this registry will be disposed when the display gets disposed. - * - * @param display the display the images managed by this registry are allocated for - */ - public ImageDescriptorRegistry(Display display) { - fDisplay= display; - Assert.isNotNull(fDisplay); - hookDisplay(); - } - - /** - * Returns the image associated with the given image descriptor. - * - * @param descriptor the image descriptor for which the registry manages an image - * @return the image associated with the image descriptor or <code>null</code> - * if the image descriptor can't create the requested image. - */ - public Image get(ImageDescriptor descriptor) { - if (descriptor == null) - descriptor= ImageDescriptor.getMissingImageDescriptor(); - - Image result= (Image)fRegistry.get(descriptor); - if (result != null) - return result; - - Assert.isTrue(fDisplay == ExternalToolsPlugin.getStandardDisplay(), ExternalToolsModelMessages.getString("ImageDescriptorRegistry.Allocating_image_for_wrong_display_1")); //$NON-NLS-1$ - result= descriptor.createImage(); - if (result != null) - fRegistry.put(descriptor, result); - return result; - } - - /** - * Disposes all images managed by this registry. - */ - public void dispose() { - for (Iterator iter= fRegistry.values().iterator(); iter.hasNext(); ) { - Image image= (Image)iter.next(); - image.dispose(); - } - fRegistry.clear(); - } - - private void hookDisplay() { - fDisplay.disposeExec(new Runnable() { - public void run() { - dispose(); - } - }); - } -} - diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/model/StringMatcher.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/model/StringMatcher.java deleted file mode 100644 index 4a4b2ea2b..000000000 --- a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/model/StringMatcher.java +++ /dev/null @@ -1,393 +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.model; - -import java.util.Vector; - -/** - * A string pattern matcher, suppporting * and ? wildcards. - */ -public class StringMatcher { - protected String fPattern; - protected int fLength; // pattern length - protected boolean fIgnoreWildCards; - protected boolean fIgnoreCase; - protected boolean fHasLeadingStar; - protected boolean fHasTrailingStar; - protected String fSegments[]; //the given pattern is split into * separated segments - - /* boundary value beyond which we don't need to search in the text */ - protected int fBound= 0; - - - protected static final char fSingleWildCard= '\u0000'; - - public static class Position { - int start; //inclusive - int end; //exclusive - public Position(int start, int end) { - this.start= start; - this.end= end; - } - public int getStart() { - return start; - } - public int getEnd() { - return end; - } - } - /** - * StringMatcher constructor takes in a String object that is a simple - * pattern which may contain '*' for 0 and many characters and - * '?' for exactly one character. - * - * Literal '*' and '?' characters must be escaped in the pattern - * e.g., "\*" means literal "*", etc. - * - * Escaping any other character (including the escape character itself), - * just results in that character in the pattern. - * e.g., "\a" means "a" and "\\" means "\" - * - * If invoking the StringMatcher with string literals in Java, don't forget - * escape characters are represented by "\\". - * - * @param pattern the pattern to match text against - * @param ignoreCase if true, case is ignored - * @param ignoreWildCards if true, wild cards and their escape sequences are ignored - * (everything is taken literally). - */ - public StringMatcher(String pattern, boolean ignoreCase, boolean ignoreWildCards) { - if (pattern == null) - throw new IllegalArgumentException(); - fIgnoreCase= ignoreCase; - fIgnoreWildCards= ignoreWildCards; - fPattern= pattern; - fLength= pattern.length(); - - if (fIgnoreWildCards) { - parseNoWildCards(); - } else { - parseWildCards(); - } - } - /** - * Find the first occurrence of the pattern between <code>start</code>(inclusive) - * and <code>end</code>(exclusive). - * @param text the String object to search in - * @param start the starting index of the search range, inclusive - * @param end the ending index of the search range, exclusive - * @return an StringMatcher.Position</code> object that keeps the starting - * (inclusive) and ending positions (exclusive) of the first occurrence of the - * pattern in the specified range of the text; return null if not found or subtext - * is empty (start==end). A pair of zeros is returned if pattern is empty string - * Note that for pattern like "*abc*" with leading and trailing stars, position of "abc" - * is returned. For a pattern like"*??*" in text "abcdf", (1,3) is returned - */ - public StringMatcher.Position find(String text, int start, int end) { - if (text == null) - throw new IllegalArgumentException(); - - int tlen= text.length(); - if (start < 0) - start= 0; - if (end > tlen) - end= tlen; - if (end < 0 ||start >= end ) - return null; - if (fLength == 0) - return new Position(start, start); - if (fIgnoreWildCards) { - int x= posIn(text, start, end); - if (x < 0) - return null; - return new Position(x, x+fLength); - } - - int segCount= fSegments.length; - if (segCount == 0)//pattern contains only '*'(s) - return new Position (start, end); - - int curPos= start; - int matchStart= -1; - int i; - for (i= 0; i < segCount && curPos < end; ++i) { - String current= fSegments[i]; - int nextMatch= regExpPosIn(text, curPos, end, current); - if (nextMatch < 0 ) - return null; - if(i == 0) - matchStart= nextMatch; - curPos= nextMatch + current.length(); - } - if (i < segCount) - return null; - return new Position(matchStart, curPos); - } - /** - * match the given <code>text</code> with the pattern - * @return true if matched eitherwise false - * @param text a String object - */ - public boolean match(String text) { - return match(text, 0, text.length()); - } - /** - * Given the starting (inclusive) and the ending (exclusive) positions in the - * <code>text</code>, determine if the given substring matches with aPattern - * @return true if the specified portion of the text matches the pattern - * @param text a String object that contains the substring to match - * @param start marks the starting position (inclusive) of the substring - * @param end marks the ending index (exclusive) of the substring - */ - public boolean match(String text, int start, int end) { - if (null == text) - throw new IllegalArgumentException(); - - if (start > end) - return false; - - if (fIgnoreWildCards) - return (end - start == fLength) && fPattern.regionMatches(fIgnoreCase, 0, text, start, fLength); - int segCount= fSegments.length; - if (segCount == 0 && (fHasLeadingStar || fHasTrailingStar)) // pattern contains only '*'(s) - return true; - if (start == end) - return fLength == 0; - if (fLength == 0) - return start == end; - - int tlen= text.length(); - if (start < 0) - start= 0; - if (end > tlen) - end= tlen; - - int tCurPos= start; - int bound= end - fBound; - if ( bound < 0) - return false; - int i=0; - String current= fSegments[i]; - int segLength= current.length(); - - /* process first segment */ - if (!fHasLeadingStar){ - if(!regExpRegionMatches(text, start, current, 0, segLength)) { - return false; - } - ++i; - tCurPos= tCurPos + segLength; - } - if ((fSegments.length == 1) && (!fHasLeadingStar) && (!fHasTrailingStar)) { - // only one segment to match, no wildcards specified - return tCurPos == end; - } - /* process middle segments */ - while (i < segCount) { - current= fSegments[i]; - int currentMatch; - int k= current.indexOf(fSingleWildCard); - if (k < 0) { - currentMatch= textPosIn(text, tCurPos, end, current); - if (currentMatch < 0) - return false; - } else { - currentMatch= regExpPosIn(text, tCurPos, end, current); - if (currentMatch < 0) - return false; - } - tCurPos= currentMatch + current.length(); - i++; - } - - /* process final segment */ - if (!fHasTrailingStar && tCurPos != end) { - int clen= current.length(); - return regExpRegionMatches(text, end - clen, current, 0, clen); - } - return i == segCount ; - } - - /** - * This method parses the given pattern into segments seperated by wildcard '*' characters. - * Since wildcards are not being used in this case, the pattern consists of a single segment. - */ - private void parseNoWildCards() { - fSegments= new String[1]; - fSegments[0]= fPattern; - fBound= fLength; - } - /** - * Parses the given pattern into segments seperated by wildcard '*' characters. - * @param p, a String object that is a simple regular expression with '*' and/or '?' - */ - private void parseWildCards() { - if(fPattern.startsWith("*"))//$NON-NLS-1$ - fHasLeadingStar= true; - if(fPattern.endsWith("*")) {//$NON-NLS-1$ - /* make sure it's not an escaped wildcard */ - if (fLength > 1 && fPattern.charAt(fLength - 2) != '\\') { - fHasTrailingStar= true; - } - } - - Vector temp= new Vector(); - - int pos= 0; - StringBuffer buf= new StringBuffer(); - while (pos < fLength) { - char c= fPattern.charAt(pos++); - switch (c) { - case '\\': - if (pos >= fLength) { - buf.append(c); - } else { - char next= fPattern.charAt(pos++); - /* if it's an escape sequence */ - if (next == '*' || next == '?' || next == '\\') { - buf.append(next); - } else { - /* not an escape sequence, just insert literally */ - buf.append(c); - buf.append(next); - } - } - break; - case '*': - if (buf.length() > 0) { - /* new segment */ - temp.addElement(buf.toString()); - fBound += buf.length(); - buf.setLength(0); - } - break; - case '?': - /* append special character representing single match wildcard */ - buf.append(fSingleWildCard); - break; - default: - buf.append(c); - } - } - - /* add last buffer to segment list */ - if (buf.length() > 0) { - temp.addElement(buf.toString()); - fBound += buf.length(); - } - - fSegments= new String[temp.size()]; - temp.copyInto(fSegments); - } - /** - * @param text a string which contains no wildcard - * @param start the starting index in the text for search, inclusive - * @param end the stopping point of search, exclusive - * @return the starting index in the text of the pattern , or -1 if not found - */ - protected int posIn(String text, int start, int end) {//no wild card in pattern - int max= end - fLength; - - if (!fIgnoreCase) { - int i= text.indexOf(fPattern, start); - if (i == -1 || i > max) - return -1; - return i; - } - - for (int i= start; i <= max; ++i) { - if (text.regionMatches(true, i, fPattern, 0, fLength)) - return i; - } - - return -1; - } - /** - * @param text a simple regular expression that may only contain '?'(s) - * @param start the starting index in the text for search, inclusive - * @param end the stopping point of search, exclusive - * @param p a simple regular expression that may contains '?' - * @param caseIgnored whether the pattern is not casesensitive - * @return the starting index in the text of the pattern , or -1 if not found - */ - protected int regExpPosIn(String text, int start, int end, String p) { - int plen= p.length(); - - int max= end - plen; - for (int i= start; i <= max; ++i) { - if (regExpRegionMatches(text, i, p, 0, plen)) - return i; - } - return -1; - } - /** - * - * @return boolean - * @param text a String to match - * @param start int that indicates the starting index of match, inclusive - * @param end int that indicates the ending index of match, exclusive - * @param p a simple regular expression that may contain '?' - * @param ignoreCase boolean indicating wether code>p</code> is case sensitive - */ - protected boolean regExpRegionMatches(String text, int tStart, String p, int pStart, int plen) { - while (plen-- > 0) { - char tchar= text.charAt(tStart++); - char pchar= p.charAt(pStart++); - - /* process wild cards */ - if (!fIgnoreWildCards) { - /* skip single wild cards */ - if (pchar == fSingleWildCard) { - continue; - } - } - if (pchar == tchar) - continue; - if (fIgnoreCase) { - if (Character.toUpperCase(tchar) == Character.toUpperCase(pchar)) - continue; - // comparing after converting to upper case doesn't handle all cases; - // also compare after converting to lower case - if (Character.toLowerCase(tchar) == Character.toLowerCase(pchar)) - continue; - } - return false; - } - return true; - } - /** - * @param text the string to match - * @param start the starting index in the text for search, inclusive - * @param end the stopping point of search, exclusive - * @param p a string that has no wildcard - * @param ignoreCase boolean indicating wether code>p</code> is case sensitive - * @return the starting index in the text of the pattern , or -1 if not found - */ - protected int textPosIn(String text, int start, int end, String p) { - - int plen= p.length(); - int max= end - plen; - - if (!fIgnoreCase) { - int i= text.indexOf(p, start); - if (i == -1 || i > max) - return -1; - return i; - } - - for (int i= start; i <= max; ++i) { - if (text.regionMatches(true, i, p, 0, plen)) - return i; - } - - return -1; - } -}
\ No newline at end of file |