diff options
Diffstat (limited to 'org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/model')
10 files changed, 0 insertions, 1171 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 4c52dd0ca..000000000 --- a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/model/BuilderUtils.java +++ /dev/null @@ -1,185 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2009 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.ui.externaltools.internal.model; - -import java.util.Map; - -import org.eclipse.core.externaltools.internal.model.BuilderCoreUtils; -import org.eclipse.core.resources.ICommand; -import org.eclipse.core.resources.IFolder; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.IExtensionPoint; -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.jface.dialogs.MessageDialog; -import org.eclipse.swt.widgets.Shell; - -/** - * Utility methods for working with external tool project builders. - */ -public class BuilderUtils { - - // 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) { - return BuilderCoreUtils.configFromBuildCommandArgs(project, commandArgs, version); - } - - /** - * 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); - configureTriggers(config, newCommand); - } catch (CoreException exception) { - Shell shell= ExternalToolsPlugin.getActiveWorkbenchShell(); - if (shell != null) { - MessageDialog.openError(shell, ExternalToolsModelMessages.BuilderUtils_5, ExternalToolsModelMessages.BuilderUtils_6); - } - return null; - } - return newCommand; - } - - public static void configureTriggers(ILaunchConfiguration config, ICommand newCommand) throws CoreException { - BuilderCoreUtils.configureTriggers(config, 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 BuilderCoreUtils.isUnmigratedConfig(config); - } - - /** - * 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 { - return BuilderCoreUtils.toBuildCommand(project, config, 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(ExternalToolsPlugin.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) { - return BuilderCoreUtils.getBuilderFolder(project, create); - } - - /** - * 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= config.getAttributes(); - String newName= new StringBuffer(config.getName()).append(ExternalToolsModelMessages.BuilderUtils_7).toString(); - 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 { - return BuilderCoreUtils.migrateBuilderConfiguration(project, workingCopy); - } - - /** - * 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) { - return BuilderCoreUtils.buildTypesToArray(buildTypes); - } -} 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 f21865edf..000000000 --- a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/model/ExternalToolsImages.java +++ /dev/null @@ -1,205 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2009 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * dakshinamurthy.karra@gmail.com - bug 165371 - *******************************************************************************/ -package org.eclipse.ui.externaltools.internal.model; - -import java.net.MalformedURLException; -import java.net.URL; - -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; - - /* 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$ - declareRegistryImage(IExternalToolConstants.IMG_TAB_BUILD, OBJECT + "build_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); - } - - /** - * 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()); - 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) { - return getImageRegistry().getDescriptor(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(); - } - } -} 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 3b66a05c5..000000000 --- a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/model/ExternalToolsModelMessages.java +++ /dev/null @@ -1,26 +0,0 @@ -/********************************************************************** - * Copyright (c) 2000, 2009 IBM Corporation and others. All rights reserved. This - * program and the accompanying materials are made available under the terms of - * the Eclipse Public License v1.0 which accompanies this distribution, and is - * available at http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM - Initial API and implementation - **********************************************************************/ -package org.eclipse.ui.externaltools.internal.model; - -import org.eclipse.osgi.util.NLS; - -public class ExternalToolsModelMessages extends NLS { - private static final String BUNDLE_NAME = "org.eclipse.ui.externaltools.internal.model.ExternalToolsModelMessages";//$NON-NLS-1$ - - public static String ImageDescriptorRegistry_Allocating_image_for_wrong_display_1; - public static String BuilderUtils_5; - public static String BuilderUtils_6; - public static String BuilderUtils_7; - - static { - // load message values from bundle file - NLS.initializeMessages(BUNDLE_NAME, ExternalToolsModelMessages.class); - } -}
\ No newline at end of file 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 cb3e2a61a..000000000 --- a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/model/ExternalToolsModelMessages.properties +++ /dev/null @@ -1,15 +0,0 @@ -############################################################################### -# Copyright (c) 2000, 2009 IBM Corporation and others. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html -# -# Contributors: -# IBM Corporation - initial API and implementation -############################################################################### - -ImageDescriptorRegistry_Allocating_image_for_wrong_display_1=Allocating image for wrong display -BuilderUtils_5=Command Error -BuilderUtils_6=An error occurred while saving the build commands of the project -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 f3b82cbdb..000000000 --- a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/model/ExternalToolsPlugin.java +++ /dev/null @@ -1,288 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2009 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-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.externaltools.internal.IExternalToolConstants; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.debug.core.DebugPlugin; -import org.eclipse.debug.core.ILaunch; -import org.eclipse.debug.core.ILaunchConfiguration; -import org.eclipse.debug.core.ILaunchConfigurationType; -import org.eclipse.debug.core.ILaunchListener; -import org.eclipse.debug.core.ILaunchManager; -import org.eclipse.jface.dialogs.MessageDialog; -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.IWindowListener; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.externaltools.internal.program.launchConfigurations.ExternalToolsProgramMessages; -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 implements - ILaunchListener { - - public static final String PLUGIN_ID = "org.eclipse.ui.externaltools"; //$NON-NLS-1$ - - /** - * Status representing no problems encountered during operation. - */ - public static final IStatus OK_STATUS = new Status(IStatus.OK, PLUGIN_ID, 0, "", null); //$NON-NLS-1$ - - private static ExternalToolsPlugin plugin; - - private static final String EMPTY_STRING = ""; //$NON-NLS-1$ - - private static IWindowListener fWindowListener; - - private static ILaunchManager launchManager; - - /** - * A window listener that warns the user about any running programs when the - * workbench closes. Programs are killed when the VM exits. - */ - private class ProgramLaunchWindowListener implements IWindowListener { - public void windowActivated(IWorkbenchWindow window) { - } - - public void windowDeactivated(IWorkbenchWindow window) { - } - - public void windowClosed(IWorkbenchWindow window) { - IWorkbenchWindow windows[] = PlatformUI.getWorkbench() - .getWorkbenchWindows(); - if (windows.length > 1) { - // There are more windows still open. - return; - } - ILaunchManager manager = DebugPlugin.getDefault() - .getLaunchManager(); - ILaunchConfigurationType programType = manager - .getLaunchConfigurationType(IExternalToolConstants.ID_PROGRAM_LAUNCH_CONFIGURATION_TYPE); - if (programType == null) { - return; - } - ILaunch launches[] = manager.getLaunches(); - ILaunchConfigurationType configType; - ILaunchConfiguration config; - for (int i = 0; i < launches.length; i++) { - try { - config = launches[i].getLaunchConfiguration(); - if (config == null) { - continue; - } - configType = config.getType(); - } catch (CoreException e) { - continue; - } - if (configType.equals(programType)) { - if (!launches[i].isTerminated()) { - MessageDialog - .openWarning( - window.getShell(), - ExternalToolsProgramMessages.ProgramLaunchDelegate_Workbench_Closing_1, - ExternalToolsProgramMessages.ProgramLaunchDelegate_The_workbench_is_exiting); - break; - } - } - } - } - - public void windowOpened(IWorkbenchWindow window) { - } - } - - /** - * 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, 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, 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); - } - } - - public void start(BundleContext context) throws Exception { - super.start(context); - // Listen to launches to lazily create "launch processors" - launchManager = DebugPlugin.getDefault().getLaunchManager(); - ILaunch[] launches = launchManager.getLaunches(); - if (launches.length > 0) { - if (fWindowListener == null) { - fWindowListener = new ProgramLaunchWindowListener(); - PlatformUI.getWorkbench().addWindowListener(fWindowListener); - } - } else { - // if no launches, wait for first launch to initialize processors - launchManager.addLaunchListener(this); - } - } - - /* (non-Javadoc) - * @see org.eclipse.debug.core.ILaunchListener#launchAdded(org.eclipse.debug.core.ILaunch) - */ - public void launchAdded(ILaunch launch) { - ILaunchConfiguration launchConfiguration = launch.getLaunchConfiguration(); - try { - ILaunchConfigurationType launchConfigurationType = launchConfiguration.getType(); - if (launchConfigurationType.getIdentifier().equals( - IExternalToolConstants.ID_PROGRAM_LAUNCH_CONFIGURATION_TYPE)) { - if (fWindowListener == null) { - fWindowListener = new ProgramLaunchWindowListener(); - PlatformUI.getWorkbench().addWindowListener(fWindowListener); - launchManager.removeLaunchListener(this); - } - } - } catch (CoreException e) { - log(e); - } - } - - /* (non-Javadoc) - * @see org.eclipse.debug.core.ILaunchListener#launchChanged(org.eclipse.debug.core.ILaunch) - */ - public void launchChanged(ILaunch launch) { - } - - /* (non-Javadoc) - * @see org.eclipse.debug.core.ILaunchListener#launchRemoved(org.eclipse.debug.core.ILaunch) - */ - public void launchRemoved(ILaunch launch) { - } -} 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 b7bbb8b37..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, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-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); - } -} 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 4c8dd3ca1..000000000 --- a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/model/IExternalToolConstants.java +++ /dev/null @@ -1,259 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2009 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * dakshinamurthy.karra@gmail.com - bug 165371 - *******************************************************************************/ -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>). - * @deprecated use {@link org.eclipse.core.externaltools.internal.IExternalToolConstants#VAR_WORKSPACE} - */ - public static final String VAR_WORKSPACE = org.eclipse.core.externaltools.internal.IExternalToolConstants.VAR_WORKSPACE; - /** - * Variable that expands to the project resource (value <code>project</code>). - * @deprecated use {@link org.eclipse.core.externaltools.internal.IExternalToolConstants#VAR_PROJECT} - */ - public static final String VAR_PROJECT = org.eclipse.core.externaltools.internal.IExternalToolConstants.VAR_PROJECT; - /** - * Variable that expands to the container resource (value <code>container</code>). - * @deprecated use {@link org.eclipse.core.externaltools.internal.IExternalToolConstants#VAR_CONTAINER} - */ - public static final String VAR_CONTAINER = org.eclipse.core.externaltools.internal.IExternalToolConstants.VAR_CONTAINER; - /** - * Variable that expands to a resource (value <code>resource</code>). - * @deprecated use {@link org.eclipse.core.externaltools.internal.IExternalToolConstants#VAR_RESOURCE} - */ - public static final String VAR_RESOURCE = org.eclipse.core.externaltools.internal.IExternalToolConstants.VAR_RESOURCE; - /** - * Variable that expands to the working set object (value <code>working_set</code>). - * @deprecated use {@link org.eclipse.core.externaltools.internal.IExternalToolConstants#VAR_WORKING_SET} - */ - public static final String VAR_WORKING_SET = org.eclipse.core.externaltools.internal.IExternalToolConstants.VAR_WORKING_SET; - // ------- Tool Types ------- - /** - * External tool type for programs such as executables, batch files, - * shell scripts, etc (value <code>programType</code>). - * @deprecated use {@link org.eclipse.core.externaltools.internal.IExternalToolConstants#TOOL_TYPE_PROGRAM} - */ - public static final String TOOL_TYPE_PROGRAM = org.eclipse.core.externaltools.internal.IExternalToolConstants.TOOL_TYPE_PROGRAM; - - // ------- Build Types ------- - /** - * Build type indicating an incremental project build request for - * the external tool running as a builder (value <code>incremental</code>). - * @deprecated use {@link org.eclipse.core.externaltools.internal.IExternalToolConstants#BUILD_TYPE_INCREMENTAL} - */ - public static final String BUILD_TYPE_INCREMENTAL = org.eclipse.core.externaltools.internal.IExternalToolConstants.BUILD_TYPE_INCREMENTAL; - - /** - * Build type indicating a full project build request for - * the external tool running as a builder (value <code>full</code>). - * @deprecated use {@link org.eclipse.core.externaltools.internal.IExternalToolConstants#BUILD_TYPE_FULL} - */ - public static final String BUILD_TYPE_FULL = org.eclipse.core.externaltools.internal.IExternalToolConstants.BUILD_TYPE_FULL; - - /** - * Build type indicating an automatic project build request for - * the external tool running as a builder (value <code>auto</code>). - * @deprecated use {@link org.eclipse.core.externaltools.internal.IExternalToolConstants#BUILD_TYPE_AUTO} - */ - public static final String BUILD_TYPE_AUTO = org.eclipse.core.externaltools.internal.IExternalToolConstants.BUILD_TYPE_AUTO; - - /** - * Build type indicating a clean project build request for - * the external tool running as a builder (value <code>clean</code>). - * @deprecated use {@link org.eclipse.core.externaltools.internal.IExternalToolConstants#BUILD_TYPE_CLEAN} - */ - public static final String BUILD_TYPE_CLEAN = org.eclipse.core.externaltools.internal.IExternalToolConstants.BUILD_TYPE_CLEAN; - - /** - * Build type indicating no project build request for - * the external tool running as a builder (value <code>none</code>). - * @deprecated use {@link org.eclipse.core.externaltools.internal.IExternalToolConstants#BUILD_TYPE_NONE} - */ - public static final String BUILD_TYPE_NONE = org.eclipse.core.externaltools.internal.IExternalToolConstants.BUILD_TYPE_NONE; - - // ------- Images ------- - - /** - * Main tab image. - */ - public static final String IMG_TAB_MAIN = PLUGIN_ID + ".IMG_TAB_MAIN"; //$NON-NLS-1$ - - /** - * Build tab image - */ - public static final String IMG_TAB_BUILD = PLUGIN_ID + ".IMG_TAB_BUILD"; //$NON-NLS-1$ - - // ------- Launch configuration types -------- - /** - * Program launch configuration type identifier. - * @deprecated use {@link org.eclipse.core.externaltools.internal.IExternalToolConstants#ID_PROGRAM_LAUNCH_CONFIGURATION_TYPE} - */ - public static final String ID_PROGRAM_LAUNCH_CONFIGURATION_TYPE = org.eclipse.core.externaltools.internal.IExternalToolConstants.ID_PROGRAM_LAUNCH_CONFIGURATION_TYPE; - - /** - * Program builder launch configuration type identifier. Program project - * builders are of this type. - * @deprecated use {@link org.eclipse.core.externaltools.internal.IExternalToolConstants#ID_PROGRAM_BUILDER_LAUNCH_CONFIGURATION_TYPE} - */ - public static final String ID_PROGRAM_BUILDER_LAUNCH_CONFIGURATION_TYPE = org.eclipse.core.externaltools.internal.IExternalToolConstants.ID_PROGRAM_BUILDER_LAUNCH_CONFIGURATION_TYPE; - - // ------- 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. - * @deprecated use {@link org.eclipse.core.externaltools.internal.IExternalToolConstants#ID_EXTERNAL_TOOLS_LAUNCH_CATEGORY} - */ - public static final String ID_EXTERNAL_TOOLS_LAUNCH_CATEGORY = org.eclipse.core.externaltools.internal.IExternalToolConstants.ID_EXTERNAL_TOOLS_LAUNCH_CATEGORY; - /** - * Identifier for external tools launch configuration builders category. - * Launch configuration types that can be added as project builders should - * belong to this category. - * @deprecated use {@link org.eclipse.core.externaltools.internal.IExternalToolConstants#ID_EXTERNAL_TOOLS_BUILDER_LAUNCH_CATEGORY} - */ - public static final String ID_EXTERNAL_TOOLS_BUILDER_LAUNCH_CATEGORY = org.eclipse.core.externaltools.internal.IExternalToolConstants.ID_EXTERNAL_TOOLS_BUILDER_LAUNCH_CATEGORY; - - // ------- 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. - * @deprecated use {@link org.eclipse.core.externaltools.internal.IExternalToolConstants#ATTR_LOCATION} - */ - public static final String ATTR_LOCATION = org.eclipse.core.externaltools.internal.IExternalToolConstants.ATTR_LOCATION; - - /** - * 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. - * @deprecated use {@link org.eclipse.core.externaltools.internal.IExternalToolConstants#ATTR_PROMPT_FOR_ARGUMENTS} - */ - public static final String ATTR_PROMPT_FOR_ARGUMENTS = org.eclipse.core.externaltools.internal.IExternalToolConstants.ATTR_PROMPT_FOR_ARGUMENTS; - - /** - * 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. - * @deprecated use {@link org.eclipse.core.externaltools.internal.IExternalToolConstants#ATTR_BUILDER_SCOPE} - */ - public static final String ATTR_BUILDER_SCOPE = org.eclipse.core.externaltools.internal.IExternalToolConstants.ATTR_BUILDER_SCOPE; - - /** - * String attribute containing an array of build kinds for which an - * external tool builder should be run. - * @deprecated use {@link org.eclipse.core.externaltools.internal.IExternalToolConstants#ATTR_RUN_BUILD_KINDS} - */ - public static final String ATTR_RUN_BUILD_KINDS = org.eclipse.core.externaltools.internal.IExternalToolConstants.ATTR_RUN_BUILD_KINDS; - - /** - * Boolean attribute indicating if the console should be shown on external - * tool output. Default value is <code>false</code>. - * @deprecated use {@link org.eclipse.core.externaltools.internal.IExternalToolConstants#ATTR_SHOW_CONSOLE} - */ - public static final String ATTR_SHOW_CONSOLE = org.eclipse.core.externaltools.internal.IExternalToolConstants.ATTR_SHOW_CONSOLE; - - /** - * String attribute containing the arguments that should be passed to the - * tool. Default value is <code>null</code>, and encoding is tool specific. - * @deprecated use {@link org.eclipse.core.externaltools.internal.IExternalToolConstants#ATTR_TOOL_ARGUMENTS} - */ - public static final String ATTR_TOOL_ARGUMENTS = org.eclipse.core.externaltools.internal.IExternalToolConstants.ATTR_TOOL_ARGUMENTS; - - /** - * 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. - * @deprecated use {@link org.eclipse.core.externaltools.internal.IExternalToolConstants#ATTR_WORKING_DIRECTORY} - */ - public static final String ATTR_WORKING_DIRECTORY = org.eclipse.core.externaltools.internal.IExternalToolConstants.ATTR_WORKING_DIRECTORY; - - /** - * 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. - * @deprecated use {@link org.eclipse.core.externaltools.internal.IExternalToolConstants#ATTR_BUILDER_ENABLED} - */ - public static final String ATTR_BUILDER_ENABLED = org.eclipse.core.externaltools.internal.IExternalToolConstants.ATTR_BUILDER_ENABLED; - - /** - * Status code indicating an unexpected internal error. - * @deprecated use {@link org.eclipse.core.externaltools.internal.IExternalToolConstants#ERR_INTERNAL_ERROR} - */ - public static final int ERR_INTERNAL_ERROR = org.eclipse.core.externaltools.internal.IExternalToolConstants.ERR_INTERNAL_ERROR; - - /** - * String attribute identifying a non-external tool builder launch configuration that is disabled - * The value is the name of the disabled builder. - * @deprecated use {@link org.eclipse.core.externaltools.internal.IExternalToolConstants#ATTR_DISABLED_BUILDER} - */ - public static final String ATTR_DISABLED_BUILDER = org.eclipse.core.externaltools.internal.IExternalToolConstants.ATTR_DISABLED_BUILDER; - - /** - * boolean attribute identifying that an external tool builder has been configured for triggering - * using the <code>ICommand.setBuilding(int)</code> mechanism - * @since 3.1 - * @deprecated use {@link org.eclipse.core.externaltools.internal.IExternalToolConstants#ATTR_TRIGGERS_CONFIGURED} - */ - public static final String ATTR_TRIGGERS_CONFIGURED = org.eclipse.core.externaltools.internal.IExternalToolConstants.ATTR_TRIGGERS_CONFIGURED; - - /** - * String attribute identifying the build scope for a launch configuration. - * <code>null</code> indicates the default workspace build. - * @deprecated use {@link org.eclipse.core.externaltools.internal.IExternalToolConstants#ATTR_BUILD_SCOPE} - */ - public static final String ATTR_BUILD_SCOPE = org.eclipse.core.externaltools.internal.IExternalToolConstants.ATTR_BUILD_SCOPE; - - /** - * Attribute identifier specifying whether referenced projects should be - * considered when computing the projects to build. Default value is - * <code>true</code>. - * @deprecated use {@link org.eclipse.core.externaltools.internal.IExternalToolConstants#ATTR_INCLUDE_REFERENCED_PROJECTS} - */ - public static final String ATTR_INCLUDE_REFERENCED_PROJECTS = org.eclipse.core.externaltools.internal.IExternalToolConstants.ATTR_INCLUDE_REFERENCED_PROJECTS; -} 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 0bbfd05bc..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, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-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 ab0944c78..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, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-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 346f60c85..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, 2009 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-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.core.runtime.Assert; -import org.eclipse.jface.resource.ImageDescriptor; -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.ImageDescriptorRegistry_Allocating_image_for_wrong_display_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(); - } - }); - } -} - |