Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 36064 Details for
Bug 51003
[launch][menu] Make launch favorites be buttons on the toolbar
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Custom Toolbar implementation
03-10-2006-patch.txt (text/plain), 100.92 KB, created by
Tim Mak
on 2006-03-10 11:55:00 EST
(
hide
)
Description:
Custom Toolbar implementation
Filename:
MIME Type:
Creator:
Tim Mak
Created:
2006-03-10 11:55:00 EST
Size:
100.92 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.debug.ui >Index: ui/org/eclipse/debug/internal/ui/DebugUIMessages.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIMessages.java,v >retrieving revision 1.22 >diff -u -r1.22 DebugUIMessages.java >--- ui/org/eclipse/debug/internal/ui/DebugUIMessages.java 7 Mar 2006 15:02:26 -0000 1.22 >+++ ui/org/eclipse/debug/internal/ui/DebugUIMessages.java 10 Mar 2006 15:58:02 -0000 >@@ -90,7 +90,8 @@ > public static String ReformatAction_title; > public static String SetDefaultColumnSizePrefAction_DefaultColumnSize; > public static String SetDefaultColumnSizePrefAction_SetDefaultColumnSize; >- >+ public static String ShowFavouritesOnToolbarAction_1; >+ > // > // Dialog > // >@@ -113,6 +114,10 @@ > public static String CodePagesPrefDialog_11; > public static String CodePagesPrefDialog_13; > >+ public static String FileSelectionDialog_Choose_Location_1; >+ public static String FileSelectionDialog_Ok_2; >+ public static String FileSelectionDialog_Cancel_3; >+ > // > // View Tab > // >Index: ui/org/eclipse/debug/internal/ui/DebugUIPlugin.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIPlugin.java,v >retrieving revision 1.271 >diff -u -r1.271 DebugUIPlugin.java >--- ui/org/eclipse/debug/internal/ui/DebugUIPlugin.java 9 Mar 2006 22:03:12 -0000 1.271 >+++ ui/org/eclipse/debug/internal/ui/DebugUIPlugin.java 10 Mar 2006 15:58:02 -0000 >@@ -466,6 +466,8 @@ > fServiceTracker.open(); > fPackageAdminService = (PackageAdmin) fServiceTracker.getService(); > >+ initializeToolbar(); >+ > } > > /** >@@ -1081,5 +1083,10 @@ > } > return ret; > } >+ >+ private void initializeToolbar() { >+ CustomToolbarManager mgr = CustomToolbarManager.getInstance(); >+ mgr.initialize(); >+ } > } > >Index: ui/org/eclipse/debug/internal/ui/DelegatingModelPresentation.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DelegatingModelPresentation.java,v >retrieving revision 1.65 >diff -u -r1.65 DelegatingModelPresentation.java >--- ui/org/eclipse/debug/internal/ui/DelegatingModelPresentation.java 9 Feb 2006 14:30:01 -0000 1.65 >+++ ui/org/eclipse/debug/internal/ui/DelegatingModelPresentation.java 10 Mar 2006 15:58:02 -0000 >@@ -11,38 +11,55 @@ > package org.eclipse.debug.internal.ui; > > >+import java.net.URL; >+import java.util.Collection; > import java.util.HashMap; > import java.util.Iterator; > import java.util.Map; >+import java.util.MissingResourceException; > > import org.eclipse.core.resources.IMarker; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.FileLocator; > import org.eclipse.core.runtime.IConfigurationElement; > import org.eclipse.core.runtime.IExtension; > import org.eclipse.core.runtime.IExtensionPoint; >+import org.eclipse.core.runtime.Path; > import org.eclipse.core.runtime.Platform; >+import org.eclipse.core.variables.VariablesPlugin; > import org.eclipse.debug.core.DebugException; > import org.eclipse.debug.core.DebugPlugin; >+import org.eclipse.debug.core.ILaunchConfiguration; >+import org.eclipse.debug.core.ILaunchManager; > import org.eclipse.debug.core.model.IBreakpoint; > import org.eclipse.debug.core.model.IDebugElement; > import org.eclipse.debug.core.model.IStackFrame; > import org.eclipse.debug.core.model.IThread; > import org.eclipse.debug.core.model.IValue; >+import org.eclipse.debug.internal.core.LaunchConfiguration; > import org.eclipse.debug.ui.DebugUITools; > import org.eclipse.debug.ui.IDebugEditorPresentation; > import org.eclipse.debug.ui.IDebugModelPresentation; > import org.eclipse.debug.ui.IDebugUIConstants; > import org.eclipse.debug.ui.IInstructionPointerPresentation; > import org.eclipse.debug.ui.IValueDetailListener; >+import org.eclipse.jface.resource.ImageDescriptor; > import org.eclipse.jface.text.source.Annotation; > import org.eclipse.jface.viewers.IColorProvider; > import org.eclipse.jface.viewers.IFontProvider; > import org.eclipse.jface.viewers.ILabelProvider; > import org.eclipse.jface.viewers.ILabelProviderListener; >+import org.eclipse.swt.SWTException; > import org.eclipse.swt.graphics.Color; > import org.eclipse.swt.graphics.Font; > import org.eclipse.swt.graphics.Image; >+import org.eclipse.swt.graphics.ImageData; >+import org.eclipse.swt.graphics.Point; >+import org.eclipse.swt.widgets.Display; > import org.eclipse.ui.IEditorInput; > import org.eclipse.ui.IEditorPart; >+import org.eclipse.ui.PlatformUI; >+import org.eclipse.ui.internal.util.BundleUtility; > > /** > * A model presentation that delegates to the appropriate extension. This >@@ -63,6 +80,11 @@ > */ > private HashMap fLabelProviders= new HashMap(5); > >+ /** >+ * A table of user defined custom images. Requires disposal. >+ */ >+ private HashMap fLaunchConfigImages = new HashMap(); >+ > /* (non-Javadoc) > * @see org.eclipse.debug.ui.IDebugEditorPresentation#removeAnnotations(org.eclipse.ui.IEditorPart, org.eclipse.debug.core.model.IThread) > */ >@@ -129,13 +151,40 @@ > while (i.hasNext()) { > ((ILabelProvider) i.next()).dispose(); > } >+ //dispose of all user defined images here >+ Iterator j = getLaunchConfigImages().values().iterator(); >+ while (j.hasNext()) { >+ ((Image)j.next()).dispose(); >+ } > } > > /** > * @see IDebugModelPresentation#getImage(Object) > */ > public Image getImage(Object item) { >- // Attempt to delegate >+ /*New order of image retrieval (for Launch Configurations): >+ * 1. Get the user defined custom image. >+ * 2. Get the default image for that launch configuration type. >+ */ >+ >+ Image img = null; >+ >+ if (item instanceof ILaunchConfiguration) { >+ ImageDescriptor id = CustomImageRegistry.getInstance().getImageDescriptor((ILaunchConfiguration)item); >+ try { >+ img = id.createImage(); >+ } >+ catch (SWTException e) { >+ DebugUIPlugin.log(e); >+ img = ImageDescriptor.getMissingImageDescriptor().createImage(); >+ } >+ //store custom images for disposal later >+ getLaunchConfigImages().put(((ILaunchConfiguration)item).getName(), img); >+ return img; >+ >+ } >+ >+ //Attempt to delegate > IDebugModelPresentation lp= getConfiguredPresentation(item); > if (lp != null) { > Image image= lp.getImage(item); >@@ -146,7 +195,7 @@ > // If no delegate returned an image, use the default > return getDefaultImage(item); > } >- >+ > /** > * @see IDebugModelPresentation#getText(Object) > */ >@@ -411,6 +460,14 @@ > } > return annotation; > } >+ >+ /** >+ * Get the collection of custom images >+ * @return the collection of custom images >+ */ >+ private HashMap getLaunchConfigImages() { >+ return fLaunchConfigImages; >+ } > > /* (non-Javadoc) > * @see org.eclipse.debug.ui.IInstructionPointerPresentation#getMarkerAnnotationSpecificationId(org.eclipse.ui.IEditorPart, org.eclipse.debug.core.model.IStackFrame) >@@ -422,7 +479,6 @@ > } > return null; > } >- > /* (non-Javadoc) > * @see org.eclipse.debug.ui.IInstructionPointerPresentation#getInstructionPointerImage(org.eclipse.ui.IEditorPart, org.eclipse.debug.core.model.IStackFrame) > */ >@@ -444,4 +500,5 @@ > } > return null; > } >+ > } >Index: ui/org/eclipse/debug/internal/ui/IDebugHelpContextIds.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/IDebugHelpContextIds.java,v >retrieving revision 1.50 >diff -u -r1.50 IDebugHelpContextIds.java >--- ui/org/eclipse/debug/internal/ui/IDebugHelpContextIds.java 9 Mar 2006 16:46:51 -0000 1.50 >+++ ui/org/eclipse/debug/internal/ui/IDebugHelpContextIds.java 10 Mar 2006 15:58:02 -0000 >@@ -85,6 +85,7 @@ > public static final String ADD_FOLDER_CONTAINER_DIALOG = PREFIX + "folder_source_container_dialog";//$NON-NLS-1$ > public static final String ADD_ARCHIVE_CONTAINER_DIALOG = PREFIX + "archive_source_container_dialog";//$NON-NLS-1$ > public static final String MULTIPLE_SOURCE_DIALOG = PREFIX + "multiple_source_selection_dialog";//$NON-NLS-1$ >+ public static final String FILE_SELECTION_DIALOG = PREFIX + "file_selection_dialog_context"; //$NON-NLS-1$ > public static final String FIND_EXPRESSION_DIALOG = PREFIX + "find_expressions_dialog_context"; //$NON-NLS-1$ > public static final String FIND_VARIABLES_DIALOG = PREFIX + "find_variables_dialog_context"; //$NON-NLS-1$ > public static final String ADD_WATCH_EXPRESSION_DIALOG= PREFIX + "add_watch_expression_dialog_context"; //$NON-NLS-1$ >Index: ui/org/eclipse/debug/internal/ui/DebugUIMessages.properties >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIMessages.properties,v >retrieving revision 1.106 >diff -u -r1.106 DebugUIMessages.properties >--- ui/org/eclipse/debug/internal/ui/DebugUIMessages.properties 7 Mar 2006 15:02:26 -0000 1.106 >+++ ui/org/eclipse/debug/internal/ui/DebugUIMessages.properties 10 Mar 2006 15:58:02 -0000 >@@ -108,6 +108,7 @@ > ReformatAction_title = Resize to Fit > SetDefaultColumnSizePrefAction_DefaultColumnSize = &Default Column Size... > SetDefaultColumnSizePrefAction_SetDefaultColumnSize = Set Default Column Size >+ShowFavouritesOnToolbarAction_1 = Show Favourites on Toolbar > > ############################################################## > # Dialog >@@ -131,6 +132,10 @@ > CodePagesPrefDialog_11=Select Codepage > CodePagesPrefDialog_13=Restore Defaults > >+FileSelectionDialog_Choose_Location_1=Choose Location >+FileSelectionDialog_Ok_2=Ok >+FileSelectionDialog_Cancel_3=Cancel >+ > ############################################################## > # View Tab > ############################################################## >Index: ui/org/eclipse/debug/internal/ui/launchConfigurations/FavoritesDialog.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/FavoritesDialog.java,v >retrieving revision 1.14 >diff -u -r1.14 FavoritesDialog.java >--- ui/org/eclipse/debug/internal/ui/launchConfigurations/FavoritesDialog.java 14 Jan 2006 21:05:24 -0000 1.14 >+++ ui/org/eclipse/debug/internal/ui/launchConfigurations/FavoritesDialog.java 10 Mar 2006 15:58:02 -0000 >@@ -23,7 +23,9 @@ > import org.eclipse.debug.core.DebugPlugin; > import org.eclipse.debug.core.ILaunchConfiguration; > import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; >+import org.eclipse.debug.internal.ui.CustomToolbarManager; > import org.eclipse.debug.internal.ui.DebugUIPlugin; >+import org.eclipse.debug.internal.ui.preferences.IDebugPreferenceConstants; > import org.eclipse.debug.ui.DebugUITools; > import org.eclipse.debug.ui.IDebugUIConstants; > import org.eclipse.jface.dialogs.Dialog; >@@ -42,6 +44,7 @@ > import org.eclipse.swt.events.KeyListener; > import org.eclipse.swt.events.SelectionAdapter; > import org.eclipse.swt.events.SelectionEvent; >+import org.eclipse.swt.events.SelectionListener; > import org.eclipse.swt.layout.GridData; > import org.eclipse.swt.layout.GridLayout; > import org.eclipse.swt.widgets.Button; >@@ -74,6 +77,8 @@ > protected Button fRemoveFavoritesButton; > protected Button fMoveUpButton; > protected Button fMoveDownButton; >+ // new button to toggle showing favourites on Toolbar >+ protected Button fShowOnToolbarButton; > > // button action handler > /** >@@ -302,7 +307,21 @@ > fAddFavoriteButton.setEnabled(true); > fRemoveFavoritesButton = createPushButton(buttonComp, LaunchConfigurationsMessages.FavoritesDialog_4); > fMoveUpButton = createPushButton(buttonComp, LaunchConfigurationsMessages.FavoritesDialog_5); >- fMoveDownButton = createPushButton(buttonComp, LaunchConfigurationsMessages.FavoritesDialog_6); >+ fMoveDownButton = createPushButton(buttonComp, LaunchConfigurationsMessages.FavoritesDialog_6); >+ >+ //Adding checkbox to display favourites on toolbar >+ Composite checkBoxComp = new Composite(parent, SWT.NULL); >+ GridLayout layout2 = new GridLayout(); >+ layout2.marginHeight = 0; >+ layout2.marginWidth = 0; >+ layout2.numColumns = 3; >+ checkBoxComp.setLayout(layout2); >+ >+ fShowOnToolbarButton = new Button(checkBoxComp, SWT.CHECK); >+ createLabel(checkBoxComp, LaunchConfigurationsMessages.FavoritesDialog_Show_on_Toolbar_Text); >+ boolean selected = DebugUIPlugin.getDefault().getPreferenceStore().getBoolean(IDebugPreferenceConstants.SHOW_FAVOURITES_ON_TOOLBAR); >+ fShowOnToolbarButton.setSelection(selected); >+ > } > > /** >@@ -521,6 +540,7 @@ > */ > protected void okPressed() { > saveFavorites(); >+ saveAndUpdateToolbar(); > super.okPressed(); > } > >@@ -544,4 +564,11 @@ > private String getDialogSettingsSectionName() { > return "FAVORITES_DIALOG_SECTION"; //$NON-NLS-1$ > } >+ >+ private void saveAndUpdateToolbar() { >+ boolean show = fShowOnToolbarButton.getSelection(); >+ DebugUIPlugin.getDefault().getPreferenceStore().setValue(IDebugPreferenceConstants.SHOW_FAVOURITES_ON_TOOLBAR, show); >+ DebugUIPlugin.getDefault().savePluginPreferences(); >+ CustomToolbarManager.getInstance().displayToolbarButtons(show); >+ } > } >Index: ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.properties >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.properties,v >retrieving revision 1.138 >diff -u -r1.138 LaunchConfigurationsMessages.properties >--- ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.properties 8 Mar 2006 17:59:27 -0000 1.138 >+++ ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.properties 10 Mar 2006 15:58:02 -0000 >@@ -40,6 +40,13 @@ > > EnvironmentTab_22=New Environment Variable > >+LaunchConfigurationDialog__Icon_error_file_does_not_exist = {0} does not exist. >+LaunchConfigurationDialog__Icon_error_is_not_a_file = {0} is not a file. >+LaunchConfigurationDialog__Icon_error_invalid_extension = The file {0} has an invalid extension. >+LaunchConfigurationDialog__Internal_error_retrieving_input = Internal error retrieving the icon text. >+LaunchConfigurationDialog__Workspace_selection_dialog_title = Select a resource: >+ >+LaunchConfigurationDialog__Icon_18 = &Icon: > LaunchConfigurationDialog__Apply_17=Appl&y > LaunchConfigurationDialog__Name__16=&Name: > LaunchConfigurationDialog_An_exception_occurred_while_retrieving_launch_configurations_20=An exception occurred while retrieving launch configurations >@@ -147,8 +154,10 @@ > FavoritesDialog_7=Select &Launch Configurations: > FavoritesDialog_0=Add {0} Favorites > FavoritesDialog_8=Updating Favorites... >+FavoritesDialog_Show_on_Toolbar_Text=Show Favourites on Toolbar > > OrganizeFavoritesAction_0=Organize Fa&vorites... >+ > PerspectiveManager_12=Confirm Perspective Switch > PerspectiveManager_13=This kind of launch is configured to open the {0} perspective when it suspends. Do you want to open this perspective now? > PerspectiveManager_15=This kind of launch is associated with the {0} perspective. Do you want to open this perspective now? >Index: ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationTabGroupViewer.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationTabGroupViewer.java,v >retrieving revision 1.52 >diff -u -r1.52 LaunchConfigurationTabGroupViewer.java >--- ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationTabGroupViewer.java 8 Mar 2006 17:59:27 -0000 1.52 >+++ ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationTabGroupViewer.java 10 Mar 2006 15:58:02 -0000 >@@ -11,25 +11,36 @@ > package org.eclipse.debug.internal.ui.launchConfigurations; > > >+import java.io.File; > import java.text.MessageFormat; > >+import org.eclipse.core.resources.IFile; > import org.eclipse.core.resources.IResource; > import org.eclipse.core.resources.ResourcesPlugin; > import org.eclipse.core.runtime.CoreException; > import org.eclipse.core.runtime.IStatus; > import org.eclipse.core.runtime.Status; >+import org.eclipse.core.variables.VariablesPlugin; > 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.debug.internal.core.LaunchConfigurationWorkingCopy; >+import org.eclipse.debug.internal.ui.CustomImageRegistry; > import org.eclipse.debug.internal.ui.DebugUIPlugin; >+import org.eclipse.debug.internal.ui.DelegatingModelPresentation; >+import org.eclipse.debug.internal.ui.FileSelectionDialog; > import org.eclipse.debug.internal.ui.IInternalDebugUIConstants; > import org.eclipse.debug.internal.ui.SWTUtil; >+import org.eclipse.debug.internal.ui.elements.adapters.LauchManagerContentAdapter; > import org.eclipse.debug.internal.ui.preferences.PerspectivePreferencePage; > import org.eclipse.debug.ui.DebugUITools; >+import org.eclipse.debug.ui.IDebugModelPresentation; > import org.eclipse.debug.ui.ILaunchConfigurationDialog; > import org.eclipse.debug.ui.ILaunchConfigurationTab; > import org.eclipse.debug.ui.ILaunchConfigurationTabGroup; >+import org.eclipse.debug.ui.StringVariableSelectionDialog; > import org.eclipse.jface.dialogs.Dialog; > import org.eclipse.jface.dialogs.ErrorDialog; > import org.eclipse.jface.viewers.ISelection; >@@ -57,6 +68,8 @@ > import org.eclipse.swt.widgets.Button; > import org.eclipse.swt.widgets.Composite; > import org.eclipse.swt.widgets.Control; >+import org.eclipse.swt.widgets.FileDialog; >+import org.eclipse.swt.widgets.Group; > import org.eclipse.swt.widgets.Label; > import org.eclipse.swt.widgets.Link; > import org.eclipse.swt.widgets.Shell; >@@ -69,6 +82,17 @@ > public class LaunchConfigurationTabGroupViewer extends Viewer { > > /** >+ * Valid image extensions that are supported by the Image class. These are used to >+ * validate the custom icons a user can define for any external tool action. >+ */ >+ private final static String IMAGE_EXTENSION_JPG = ".jpg"; //$NON-NLS-1$ >+ private final static String IMAGE_EXTENSION_BMP = ".bmp"; //$NON-NLS-1$ >+ private final static String IMAGE_EXTENSION_ICO = ".ico"; //$NON-NLS-1$ >+ private final static String IMAGE_EXTENSION_TIF = ".tif"; //$NON-NLS-1$ >+ private final static String IMAGE_EXTENSION_PNG = ".png"; //$NON-NLS-1$ >+ private final static String IMAGE_EXTENSION_GIF = ".gif"; //$NON-NLS-1$ >+ >+ /** > * Containing launch dialog > */ > private ILaunchConfigurationDialog fDialog; >@@ -109,6 +133,31 @@ > private Text fNameWidget; > > /** >+ * Icon label widget >+ */ >+ private Label fIconLabel; >+ >+ /** >+ * Icon text widget >+ */ >+ private Text fIconWidget; >+ >+ /** >+ * Icon browse file system widget >+ */ >+ private Button fBrowseFileSystem; >+ >+ /** >+ * Icon browse workspace widget >+ */ >+ private Button fBrowseWorkspace; >+ >+ /** >+ * Icon variables widget >+ */ >+ private Button fVariables; >+ >+ /** > * Composite containing the launch config tab widgets > */ > private Composite fTabComposite; >@@ -275,6 +324,79 @@ > } > ); > >+ //Area to attach custom icon >+ >+ Group iconGroup = new Group(fTabComposite, SWT.NONE ); >+ GridData gData = new GridData(GridData.FILL_HORIZONTAL); >+ gData.horizontalSpan = 2; >+ iconGroup.setLayoutData(gData); >+ GridLayout groupLayout = new GridLayout(); >+ groupLayout.numColumns = 1; >+ iconGroup.setLayout(groupLayout); >+ iconGroup.setText(LaunchConfigurationsMessages.LaunchConfigurationDialog__Icon_18); >+ >+ fIconWidget = new Text(iconGroup, SWT.SINGLE | SWT.BORDER); >+ gd = new GridData(GridData.FILL_HORIZONTAL); >+ fIconWidget.setLayoutData(gd); >+ >+ fIconWidget.addModifyListener( >+ new ModifyListener() { >+ public void modifyText(ModifyEvent e) { >+ handleIconModified(); >+ } >+ } >+ ); >+ >+ Composite buttonComposite = new Composite(iconGroup, SWT.NONE); >+ GridLayout layout2 = new GridLayout(); >+ layout2.marginHeight = 0; >+ layout2.marginWidth = 0; >+ layout2.numColumns = 3; >+ GridData gridData = new GridData(GridData.HORIZONTAL_ALIGN_END); >+ gridData.horizontalSpan = 1; >+ buttonComposite.setLayout(layout2); >+ buttonComposite.setLayoutData(gridData); >+ buttonComposite.setFont(parent.getFont()); >+ >+ fBrowseWorkspace = new Button(buttonComposite,SWT.PUSH); >+ fBrowseWorkspace.setText(LaunchConfigurationsMessages.CommonTab_12); >+ fBrowseWorkspace.addSelectionListener(new SelectionListener() { >+ >+ public void widgetSelected(SelectionEvent e) { >+ handleWorkspaceLocationButtonSelected(); >+ } >+ public void widgetDefaultSelected(SelectionEvent e) { >+ } >+ >+ } >+ ); >+ >+ fBrowseFileSystem = new Button(buttonComposite,SWT.PUSH); >+ fBrowseFileSystem.setText(LaunchConfigurationsMessages.CommonTab_7); >+ fBrowseFileSystem.addSelectionListener(new SelectionListener() { >+ >+ public void widgetSelected(SelectionEvent e) { >+ handleFileLocationButtonSelected(); >+ } >+ >+ public void widgetDefaultSelected(SelectionEvent e) { >+ } >+ >+ } >+ ); >+ >+ fVariables = new Button(buttonComposite,SWT.PUSH); >+ fVariables.setText(LaunchConfigurationsMessages.CommonTab_9); >+ >+ fVariables.addSelectionListener(new SelectionListener() { >+ >+ public void widgetSelected(SelectionEvent e) { >+ handleVariablesButtonSelected(fIconWidget); >+ } >+ public void widgetDefaultSelected(SelectionEvent e) { >+ } >+ >+ }); > createTabFolder(fTabComposite); > > Composite buttonComp = new Composite(mainComp, SWT.NONE); >@@ -421,6 +543,12 @@ > protected CTabFolder getTabFolder() { > return fTabFolder; > } >+ /** >+ * Returns the icon widget >+ */ >+ private Text getIconWidget() { >+ return fIconWidget; >+ } > > /** > * Sets the current name >@@ -626,7 +754,13 @@ > updateVisibleControls(true); > // Update the name field before to avoid verify error > fNameWidget.setText(getWorkingCopy().getName()); >- >+ >+ // set the icon text >+ try { >+ getIconWidget().setText(getWorkingCopy().getAttribute(ILaunchManager.ATTR_LAUNCH_ICON_PATH, "")); >+ } catch (CoreException e1) { >+ } >+ > // Retrieve the current tab group. If there is none, clean up and leave > ILaunchConfigurationTabGroup tabGroup = getTabGroup(); > if (tabGroup == null) { >@@ -933,6 +1067,8 @@ > // First make sure that name doesn't prevent saving the config > try { > verifyName(); >+ //verify the Icon choice as well >+ verifyIconText(); > } catch (CoreException ce) { > return false; > } >@@ -962,6 +1098,8 @@ > } > try { > verifyName(); >+ //Don't let a launch config start without a valid icon file >+ verifyIconText(); > } catch (CoreException e) { > return false; > } >@@ -991,6 +1129,8 @@ > } > try { > verifyName(); >+ //verify icon text here as well >+ verifyIconText(); > } catch (CoreException ce) { > return ce.getStatus().getMessage(); > } >@@ -1173,6 +1313,22 @@ > } > > /** >+ * Notification that the icon field has been modified >+ * >+ */ >+ protected void handleIconModified() { >+ //need to update the launch configuration with the new image >+ ILaunchConfigurationWorkingCopy workingCopy = getWorkingCopy(); >+ if (workingCopy instanceof LaunchConfigurationWorkingCopy) { >+ if (getIconWidget() != null && !getIconWidget().isDisposed()) { >+ ((LaunchConfigurationWorkingCopy)workingCopy).changeIconPath(getIconWidget().getText().trim()); >+ } >+ } >+ refreshStatus(); >+ >+ } >+ >+ /** > * Notification that the 'Apply' button has been pressed > */ > protected void handleApplyPressed() { >@@ -1188,11 +1344,20 @@ > widget.setText(trimmed); > } > getWorkingCopy().rename(trimmed); >+ if (getWorkingCopy() instanceof LaunchConfigurationWorkingCopy) { >+ if (getIconWidget() != null && !getIconWidget().isDisposed()) { >+ ((LaunchConfigurationWorkingCopy)getWorkingCopy()). >+ changeIconPath(getIconWidget().getText().trim()); >+ } >+ } >+ > getTabGroup().performApply(getWorkingCopy()); > fInitializingTabs = false; > > if (isDirty()) { > getWorkingCopy().doSave(); >+ //update the custom image registry for this configuration >+ CustomImageRegistry.getInstance().updateCache(getWorkingCopy().getOriginal()); > } > updateButtons(); > } catch (CoreException e) { >@@ -1256,5 +1421,124 @@ > handleTabSelected(); > } > } >- >+ >+ /** >+ * Prompts the user to choose a location from the filesystem and >+ * sets the location as the full path of the selected file. >+ */ >+ protected void handleFileLocationButtonSelected() { >+ FileDialog fileDialog = new FileDialog(getShell(), SWT.NONE); >+ fileDialog.setFileName(getIconWidget().getText()); >+ fileDialog.setFilterExtensions(new String[] {"*"+ IMAGE_EXTENSION_JPG + >+ ";*"+ IMAGE_EXTENSION_BMP + >+ ";*"+ IMAGE_EXTENSION_GIF + >+ ";*"+ IMAGE_EXTENSION_ICO + >+ ";*"+ IMAGE_EXTENSION_PNG + >+ ";*"+ IMAGE_EXTENSION_TIF >+ ,"*.*"}); >+ >+ String text= fileDialog.open(); >+ if (text != null) { >+ getIconWidget().setText(text); >+ } >+ } >+ >+ /** >+ * Prompts the user for a workspace location within the workspace and sets >+ * the location as a String containing the workspace_loc variable or >+ * <code>null</code> if no location was obtained from the user. >+ */ >+ protected void handleWorkspaceLocationButtonSelected() { >+ >+ FileSelectionDialog dialog; >+ dialog = new FileSelectionDialog(getShell(), ResourcesPlugin.getWorkspace().getRoot(), LaunchConfigurationsMessages.LaunchConfigurationDialog__Workspace_selection_dialog_title);//ExternalToolsLaunchConfigurationMessages.ExternalToolsMainTab_Select_a_resource_22); >+ dialog.open(); >+ IStructuredSelection result = dialog.getResult(); >+ if (result == null) { >+ return; >+ } >+ Object file= result.getFirstElement(); >+ if (file instanceof IFile) { >+ getIconWidget().setText(VariablesPlugin.getDefault(). >+ getStringVariableManager().generateVariableExpression("workspace_loc", ((IFile)file).getFullPath().toString())); //$NON-NLS-1$ >+ } >+ } >+ >+ /** >+ * A variable entry button has been pressed for the given text >+ * field. Prompt the user for a variable and enter the result >+ * in the given field. >+ */ >+ private void handleVariablesButtonSelected(Text textField) { >+ >+ StringVariableSelectionDialog dialog = new StringVariableSelectionDialog(getShell()); >+ dialog.open(); >+ String variable = dialog.getVariableExpression(); >+ >+ if (variable != null) { >+ textField.insert(variable); >+ } >+ } >+ /** >+ * Verifies that the text entered in the Icon text field is valid. >+ * >+ * @throws CoreException >+ */ >+ private void verifyIconText() throws CoreException { >+ >+ String enteredPath = null; >+ >+ if (getIconWidget() != null && !getIconWidget().isDisposed()) { >+ enteredPath = getIconWidget().getText().trim(); >+ } >+ else { >+ //This should not occur, just a redundancy check >+ throw new CoreException(new Status(IStatus.ERROR, >+ DebugUIPlugin.getUniqueIdentifier(), >+ 0, >+ MessageFormat.format(LaunchConfigurationsMessages.LaunchConfigurationDialog__Internal_error_retrieving_input, >+ null), >+ null)); >+ } >+ >+ try { >+ String subbedString = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(enteredPath); >+ VariablesPlugin.getDefault().getStringVariableManager().validateStringVariables(enteredPath); >+ //if the variable can be substituted, don't validate. It might become valid later. >+ if (!subbedString.equals(enteredPath)) >+ return; >+ } >+ catch (CoreException e) { >+ VariablesPlugin.getDefault().getStringVariableManager().validateStringVariables(enteredPath); >+ return; >+ } >+ >+ File file = new File(VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(enteredPath)); >+ >+ //if a dynamic variable is used, don't validate, since it could be valid later >+ //except if it is the workspace dynamic variable... >+ >+ //don't verify if nothing is entered >+ if (getIconWidget().getText().length() > 0) { >+ >+ if (!file.exists()) { // The file does not exist. >+ throw new CoreException(new Status(IStatus.ERROR, >+ DebugUIPlugin.getUniqueIdentifier(), >+ 0, >+ MessageFormat.format(LaunchConfigurationsMessages.LaunchConfigurationDialog__Icon_error_file_does_not_exist, >+ new String[] {file.toString()}), >+ null)); >+ } >+ if (!file.isFile()) { >+ throw new CoreException(new Status(IStatus.ERROR, >+ DebugUIPlugin.getUniqueIdentifier(), >+ 0, >+ MessageFormat.format(LaunchConfigurationsMessages.LaunchConfigurationDialog__Icon_error_is_not_a_file, >+ new String[] {file.toString()}), >+ >+ null)); >+ } >+ >+ } >+ } > } >Index: ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.java,v >retrieving revision 1.25 >diff -u -r1.25 LaunchConfigurationsMessages.java >--- ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.java 8 Mar 2006 17:59:27 -0000 1.25 >+++ ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.java 10 Mar 2006 15:58:02 -0000 >@@ -44,6 +44,14 @@ > > public static String EnvironmentTab_22; > >+ //Messages for custom icons >+ public static String LaunchConfigurationDialog__Icon_18; >+ public static String LaunchConfigurationDialog__Icon_error_file_does_not_exist; >+ public static String LaunchConfigurationDialog__Icon_error_invalid_extension; >+ public static String LaunchConfigurationDialog__Icon_error_is_not_a_file; >+ public static String LaunchConfigurationDialog__Internal_error_retrieving_input; >+ public static String LaunchConfigurationDialog__Workspace_selection_dialog_title; >+ > public static String LaunchConfigurationDialog__Apply_17; > public static String LaunchConfigurationDialog__Name__16; > public static String LaunchConfigurationDialog_An_exception_occurred_while_retrieving_launch_configurations_20; >@@ -132,7 +140,8 @@ > public static String FavoritesDialog_6; > public static String FavoritesDialog_7; > public static String FavoritesDialog_0; >- >+ public static String FavoritesDialog_Show_on_Toolbar_Text; >+ > public static String OrganizeFavoritesAction_0; > public static String PerspectiveManager_12; > public static String PerspectiveManager_13; >Index: ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchHistory.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchHistory.java,v >retrieving revision 1.25 >diff -u -r1.25 LaunchHistory.java >--- ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchHistory.java 8 Mar 2006 16:13:54 -0000 1.25 >+++ ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchHistory.java 10 Mar 2006 15:58:02 -0000 >@@ -327,6 +327,10 @@ > if (movedFrom == null) { > checkIfFavorite(configuration); > } else { >+ //This is a bug. If a user currently renames a configuration, and adds to favourites at the same >+ //time, the newly named launch configuration will not be added to the favourites list. >+ //We should check favourites even whening renaming or moving. >+ > String movedFromName= movedFrom.getName(); > ILaunchConfiguration[] history = getHistory(); > for (int i = 0; i < history.length; i++) { >Index: ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationView.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationView.java,v >retrieving revision 1.23 >diff -u -r1.23 LaunchConfigurationView.java >--- ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationView.java 24 Feb 2006 18:47:36 -0000 1.23 >+++ ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationView.java 10 Mar 2006 15:58:02 -0000 >@@ -311,12 +311,17 @@ > TreeViewer viewer = getTreeViewer(); > if (viewer != null) { > try { >- viewer.add(configuration.getType(), configuration); >- // if moved, remove original now >+ /* Check and remove the item from the tree FIRST, then add it. >+ * Do this so that a Launch Configuration which has had it's icon changed can also be treated >+ * in the same manner as one that was renamed >+ */ >+ // if moved, remove original now > ILaunchConfiguration from = getLaunchManager().getMovedFrom(configuration); > if (from != null) { > viewer.remove(from); > } >+ viewer.add(configuration.getType(), configuration); >+ > if (isAutoSelect()) { > viewer.setSelection(new StructuredSelection(configuration), true); > } >Index: ui/org/eclipse/debug/internal/ui/preferences/LaunchConfigurationsPreferencePage.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/LaunchConfigurationsPreferencePage.java,v >retrieving revision 1.8 >diff -u -r1.8 LaunchConfigurationsPreferencePage.java >--- ui/org/eclipse/debug/internal/ui/preferences/LaunchConfigurationsPreferencePage.java 2 Feb 2006 17:11:46 -0000 1.8 >+++ ui/org/eclipse/debug/internal/ui/preferences/LaunchConfigurationsPreferencePage.java 10 Mar 2006 15:58:02 -0000 >@@ -90,7 +90,7 @@ > /** > * describes the external tools launch group > */ >- private static final String EXT_BUILDER_GROUP = "org.eclipse.ui.externaltools.launchGroup"; //$NON-NLS-1$ >+ public static final String EXT_BUILDER_GROUP = "org.eclipse.ui.externaltools.launchGroup"; //$NON-NLS-1$ > > /** > * to monitor the proress of the migration process >Index: ui/org/eclipse/debug/internal/ui/preferences/IDebugPreferenceConstants.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/IDebugPreferenceConstants.java,v >retrieving revision 1.41 >diff -u -r1.41 IDebugPreferenceConstants.java >--- ui/org/eclipse/debug/internal/ui/preferences/IDebugPreferenceConstants.java 14 Jan 2006 21:04:13 -0000 1.41 >+++ ui/org/eclipse/debug/internal/ui/preferences/IDebugPreferenceConstants.java 10 Mar 2006 15:58:02 -0000 >@@ -245,6 +245,12 @@ > * @since 3.2 > */ > public static final String PREF_COL_SIZE_BY_MODEL = "org.eclipse.debug.ui.AbstractTableRendering.colSize"; //$NON-NLS-1$ >+ >+ /** >+ * The boolean setting of whether to show the launch configuration favourites on the Toolbar >+ */ >+ public static final String SHOW_FAVOURITES_ON_TOOLBAR = "org.eclipse.debug.ui.custom.toolbar.display.onToolbar"; //$NON-NLS-1$ >+ > } > > >Index: ui/org/eclipse/debug/ui/actions/LaunchAction.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/LaunchAction.java,v >retrieving revision 1.10 >diff -u -r1.10 LaunchAction.java >--- ui/org/eclipse/debug/ui/actions/LaunchAction.java 24 Feb 2005 06:43:48 -0000 1.10 >+++ ui/org/eclipse/debug/ui/actions/LaunchAction.java 10 Mar 2006 15:58:02 -0000 >@@ -11,11 +11,18 @@ > package org.eclipse.debug.ui.actions; > > >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.variables.VariablesPlugin; > import org.eclipse.debug.core.ILaunchConfiguration; >+import org.eclipse.debug.core.ILaunchManager; >+import org.eclipse.debug.internal.ui.CustomImageRegistry; >+import org.eclipse.debug.internal.ui.DebugPluginImages; > import org.eclipse.debug.internal.ui.DebugUIPlugin; > import org.eclipse.debug.internal.ui.IDebugHelpContextIds; > import org.eclipse.debug.ui.DebugUITools; >+import org.eclipse.debug.ui.IDebugModelPresentation; > import org.eclipse.jface.action.Action; >+import org.eclipse.jface.resource.ImageDescriptor; > import org.eclipse.jface.viewers.IStructuredSelection; > import org.eclipse.jface.viewers.StructuredSelection; > import org.eclipse.swt.SWT; >@@ -53,7 +60,11 @@ > fConfiguration = configuration; > fMode = mode; > setText(configuration.getName()); >- setImageDescriptor(DebugUITools.getDefaultImageDescriptor(configuration)); >+ //Attempt to set the image from the LaunchConfiguration first >+ >+ ImageDescriptor imageDesc = CustomImageRegistry.getInstance().getImageDescriptor(configuration); >+ setImageDescriptor(imageDesc); >+ > PlatformUI.getWorkbench().getHelpSystem().setHelp( > this, > IDebugHelpContextIds.RELAUNCH_HISTORY_ACTION); >Index: ui/org/eclipse/debug/ui/actions/AbstractLaunchToolbarAction.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/AbstractLaunchToolbarAction.java,v >retrieving revision 1.13 >diff -u -r1.13 AbstractLaunchToolbarAction.java >--- ui/org/eclipse/debug/ui/actions/AbstractLaunchToolbarAction.java 8 Apr 2005 16:08:20 -0000 1.13 >+++ ui/org/eclipse/debug/ui/actions/AbstractLaunchToolbarAction.java 10 Mar 2006 15:58:02 -0000 >@@ -13,6 +13,8 @@ > > import org.eclipse.debug.core.ILaunchConfiguration; > import org.eclipse.debug.internal.ui.DebugUIPlugin; >+import org.eclipse.debug.internal.ui.ShowOnToolbarAction; >+import org.eclipse.debug.internal.ui.actions.AddToFavoritesAction; > import org.eclipse.debug.internal.ui.launchConfigurations.OrganizeFavoritesAction; > import org.eclipse.debug.ui.DebugUITools; > import org.eclipse.jface.action.IAction; >@@ -58,6 +60,8 @@ > addToMenu(menu, new LaunchShortcutsAction(getLaunchGroupIdentifier()), -1); > addToMenu(menu, getOpenDialogAction(), -1); > addToMenu(menu, new OrganizeFavoritesAction(getLaunchGroupIdentifier()), -1); >+ //add new action to show on toolbar >+ addToMenu(menu, new ShowOnToolbarAction(),-1); > } > > /** >Index: ui/org/eclipse/debug/internal/ui/TreeAndListGroup.java >=================================================================== >RCS file: ui/org/eclipse/debug/internal/ui/TreeAndListGroup.java >diff -N ui/org/eclipse/debug/internal/ui/TreeAndListGroup.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ ui/org/eclipse/debug/internal/ui/TreeAndListGroup.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,316 @@ >+/******************************************************************************* >+ * 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.debug.internal.ui; >+ >+ >+import java.util.ArrayList; >+import java.util.Iterator; >+import java.util.List; >+ >+import org.eclipse.jface.viewers.DoubleClickEvent; >+import org.eclipse.jface.viewers.IDoubleClickListener; >+import org.eclipse.jface.viewers.ILabelProvider; >+import org.eclipse.jface.viewers.ISelection; >+import org.eclipse.jface.viewers.ISelectionChangedListener; >+import org.eclipse.jface.viewers.IStructuredContentProvider; >+import org.eclipse.jface.viewers.IStructuredSelection; >+import org.eclipse.jface.viewers.ITreeContentProvider; >+import org.eclipse.jface.viewers.SelectionChangedEvent; >+import org.eclipse.jface.viewers.StructuredSelection; >+import org.eclipse.jface.viewers.TableViewer; >+import org.eclipse.jface.viewers.TreeViewer; >+import org.eclipse.jface.viewers.ViewerSorter; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.layout.GridData; >+import org.eclipse.swt.layout.GridLayout; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.swt.widgets.Table; >+import org.eclipse.swt.widgets.Tree; >+import org.eclipse.ui.views.navigator.ResourceSorter; >+ >+/** >+ * This class was derived from org.eclipse.ui.internal.misc.CheckboxTreeAndListGroup >+ * >+ */ >+public class TreeAndListGroup implements ISelectionChangedListener { >+ private Object root; >+ private Object currentTreeSelection; >+ private List selectionChangedListeners = new ArrayList(); >+ private List doubleClickListeners= new ArrayList(); >+ >+ private ITreeContentProvider treeContentProvider; >+ private IStructuredContentProvider listContentProvider; >+ private ILabelProvider treeLabelProvider; >+ private ILabelProvider listLabelProvider; >+ >+ // widgets >+ private TreeViewer treeViewer; >+ private TableViewer listViewer; >+ private boolean allowMultiselection= false; >+ >+ /** >+ * Create an instance of this class. Use this constructor if you wish to specify >+ * the width and/or height of the combined widget (to only hardcode one of the >+ * sizing dimensions, specify the other dimension's value as -1) >+ * >+ * @param parent org.eclipse.swt.widgets.Composite >+ * @param style int >+ * @param rootObject java.lang.Object >+ * @param width int >+ * @param height int >+ * @param allowMultiselection Whether to allow multi-selection in the list viewer. >+ */ >+ public TreeAndListGroup(Composite parent, Object rootObject, ITreeContentProvider treeContentProvider, ILabelProvider treeLabelProvider, IStructuredContentProvider listContentProvider, ILabelProvider listLabelProvider, int style, int width, int height, boolean allowMultiselection) { >+ >+ root = rootObject; >+ this.treeContentProvider = treeContentProvider; >+ this.listContentProvider = listContentProvider; >+ this.treeLabelProvider = treeLabelProvider; >+ this.listLabelProvider = listLabelProvider; >+ this.allowMultiselection= allowMultiselection; >+ createContents(parent, width, height, style); >+ } >+ /** >+ * This method must be called just before this window becomes visible. >+ */ >+ public void aboutToOpen() { >+ currentTreeSelection = null; >+ >+ //select the first element in the list >+ Object[] elements = treeContentProvider.getElements(root); >+ Object primary = elements.length > 0 ? elements[0] : null; >+ if (primary != null) { >+ treeViewer.setSelection(new StructuredSelection(primary)); >+ } >+ treeViewer.getControl().setFocus(); >+ } >+ /** >+ * Add the passed listener to collection of clients >+ * that listen for changes to list viewer selection state >+ * >+ * @param listener ISelectionChangedListener >+ */ >+ public void addSelectionChangedListener(ISelectionChangedListener listener) { >+ selectionChangedListeners.add(listener); >+ } >+ >+ /** >+ * Add the given listener to the collection of clients that listen to >+ * double-click events in the list viewer >+ * >+ * @param listener IDoubleClickListener >+ */ >+ public void addDoubleClickListener(IDoubleClickListener listener) { >+ doubleClickListeners.add(listener); >+ } >+ >+ /** >+ * Notify all selection listeners that a selection has occurred in the list >+ * viewer >+ */ >+ protected void notifySelectionListeners(SelectionChangedEvent event) { >+ Iterator iter = selectionChangedListeners.iterator(); >+ while (iter.hasNext()) { >+ ((ISelectionChangedListener) iter.next()).selectionChanged(event); >+ } >+ } >+ >+ /** >+ * Notify all double click listeners that a double click event has occurred >+ * in the list viewer >+ */ >+ protected void notifyDoubleClickListeners(DoubleClickEvent event) { >+ Iterator iter= doubleClickListeners.iterator(); >+ while (iter.hasNext()) { >+ ((IDoubleClickListener) iter.next()).doubleClick(event); >+ } >+ } >+ >+ /** >+ * Lay out and initialize self's visual components. >+ * >+ * @param parent org.eclipse.swt.widgets.Composite >+ * @param width int >+ * @param height int >+ */ >+ protected void createContents(Composite parent, int width, int height, int style) { >+ // group pane >+ Composite composite = new Composite(parent, style); >+ composite.setFont(parent.getFont()); >+ GridLayout layout = new GridLayout(); >+ layout.numColumns = 2; >+ layout.makeColumnsEqualWidth = true; >+ layout.marginHeight = 0; >+ layout.marginWidth = 0; >+ composite.setLayout(layout); >+ composite.setLayoutData(new GridData(GridData.FILL_BOTH)); >+ >+ createTreeViewer(composite, width / 2, height); >+ createListViewer(composite, width / 2, height); >+ >+ initialize(); >+ } >+ /** >+ * Create this group's list viewer. >+ */ >+ protected void createListViewer(Composite parent, int width, int height) { >+ int style; >+ if (allowMultiselection) { >+ style= SWT.MULTI; >+ } else { >+ style= SWT.SINGLE; >+ } >+ listViewer = new TableViewer(parent, SWT.BORDER | style); >+ GridData data = new GridData(GridData.FILL_BOTH); >+ data.widthHint = width; >+ data.heightHint = height; >+ listViewer.getTable().setLayoutData(data); >+ listViewer.getTable().setFont(parent.getFont()); >+ listViewer.setContentProvider(listContentProvider); >+ listViewer.setLabelProvider(listLabelProvider); >+ listViewer.setSorter(new ResourceSorter(ResourceSorter.NAME)); >+ listViewer.addSelectionChangedListener(new ISelectionChangedListener() { >+ public void selectionChanged(SelectionChangedEvent event) { >+ notifySelectionListeners(event); >+ } >+ }); >+ listViewer.addDoubleClickListener(new IDoubleClickListener() { >+ public void doubleClick(DoubleClickEvent event) { >+ if (!event.getSelection().isEmpty()) { >+ notifyDoubleClickListeners(event); >+ } >+ } >+ }); >+ } >+ /** >+ * Create this group's tree viewer. >+ */ >+ protected void createTreeViewer(Composite parent, int width, int height) { >+ Tree tree = new Tree(parent, SWT.BORDER); >+ GridData data = new GridData(GridData.FILL_BOTH); >+ data.widthHint = width; >+ data.heightHint = height; >+ tree.setLayoutData(data); >+ tree.setFont(parent.getFont()); >+ >+ treeViewer = new TreeViewer(tree); >+ treeViewer.setContentProvider(treeContentProvider); >+ treeViewer.setLabelProvider(treeLabelProvider); >+ treeViewer.setSorter(new ResourceSorter(ResourceSorter.NAME)); >+ treeViewer.addSelectionChangedListener(this); >+ } >+ >+ public Table getListTable() { >+ return listViewer.getTable(); >+ } >+ >+ public IStructuredSelection getListTableSelection() { >+ ISelection selection= this.listViewer.getSelection(); >+ if (selection instanceof IStructuredSelection) { >+ return (IStructuredSelection)selection; >+ } >+ return StructuredSelection.EMPTY; >+ } >+ >+ protected void initialListItem(Object element) { >+ Object parent = treeContentProvider.getParent(element); >+ selectAndRevealFolder(parent); >+ } >+ >+ public void selectAndRevealFolder(Object treeElement) { >+ treeViewer.reveal(treeElement); >+ IStructuredSelection selection = new StructuredSelection(treeElement); >+ treeViewer.setSelection(selection); >+ } >+ >+ public void selectAndRevealFile(Object treeElement) { >+ listViewer.reveal(treeElement); >+ IStructuredSelection selection = new StructuredSelection(treeElement); >+ listViewer.setSelection(selection); >+ } >+ >+ /** >+ * Initialize this group's viewers after they have been laid out. >+ */ >+ protected void initialize() { >+ treeViewer.setInput(root); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent) >+ */ >+ public void selectionChanged(SelectionChangedEvent event) { >+ IStructuredSelection selection = (IStructuredSelection) event.getSelection(); >+ Object selectedElement = selection.getFirstElement(); >+ if (selectedElement == null) { >+ currentTreeSelection = null; >+ listViewer.setInput(currentTreeSelection); >+ return; >+ } >+ >+ // ie.- if not an item deselection >+ if (selectedElement != currentTreeSelection) { >+ listViewer.setInput(selectedElement); >+ } >+ >+ currentTreeSelection = selectedElement; >+ } >+ /** >+ * Set the list viewer's providers to those passed >+ * >+ * @param contentProvider ITreeContentProvider >+ * @param labelProvider ILabelProvider >+ */ >+ public void setListProviders(IStructuredContentProvider contentProvider, ILabelProvider labelProvider) { >+ listViewer.setContentProvider(contentProvider); >+ listViewer.setLabelProvider(labelProvider); >+ } >+ /** >+ * Set the sorter that is to be applied to self's list viewer >+ */ >+ public void setListSorter(ViewerSorter sorter) { >+ listViewer.setSorter(sorter); >+ } >+ /** >+ * Set the root of the widget to be new Root. Regenerate all of the tables and lists from this >+ * value. >+ * @param newRoot >+ */ >+ public void setRoot(Object newRoot) { >+ this.root = newRoot; >+ initialize(); >+ } >+ >+ /** >+ * Set the tree viewer's providers to those passed >+ * >+ * @param contentProvider ITreeContentProvider >+ * @param labelProvider ILabelProvider >+ */ >+ public void setTreeProviders(ITreeContentProvider contentProvider, ILabelProvider labelProvider) { >+ treeViewer.setContentProvider(contentProvider); >+ treeViewer.setLabelProvider(labelProvider); >+ } >+ /** >+ * Set the sorter that is to be applied to self's tree viewer >+ */ >+ public void setTreeSorter(ViewerSorter sorter) { >+ treeViewer.setSorter(sorter); >+ } >+ >+ /** >+ * Set the focus on to the list widget. >+ */ >+ public void setFocus() { >+ >+ this.treeViewer.getTree().setFocus(); >+ } >+} >Index: ui/org/eclipse/debug/internal/ui/CustomImageRegistry.java >=================================================================== >RCS file: ui/org/eclipse/debug/internal/ui/CustomImageRegistry.java >diff -N ui/org/eclipse/debug/internal/ui/CustomImageRegistry.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ ui/org/eclipse/debug/internal/ui/CustomImageRegistry.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,92 @@ >+package org.eclipse.debug.internal.ui; >+ >+import java.util.HashMap; >+ >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.variables.VariablesPlugin; >+import org.eclipse.debug.core.ILaunchConfiguration; >+import org.eclipse.debug.core.ILaunchManager; >+import org.eclipse.jface.resource.ImageDescriptor; >+ >+/** >+ * @author tmak >+ * This class caches the image descriptors of any custom icons used. Whenever a custom icon >+ * needs to be retrieved, this class should be consulted first. >+ */ >+public class CustomImageRegistry { >+ >+ private static CustomImageRegistry registry; >+ >+ private HashMap customImageDescriptors = new HashMap(); >+ >+ public static CustomImageRegistry getInstance() { >+ >+ if (registry == null) { >+ registry = new CustomImageRegistry(); >+ } >+ >+ return registry; >+ } >+ /** >+ * Retrieve the appropriate icon for a specific launch configuration. >+ * >+ * @param the config you want the image descriptor for. >+ * @return the image descriptor for this configuration >+ */ >+ public ImageDescriptor getImageDescriptor(ILaunchConfiguration config) { >+ >+ ImageDescriptor imageDesc; >+ >+ try { >+ //if the configuration has no icon attribute set, return default descriptor >+ if (config.getAttribute(ILaunchManager.ATTR_LAUNCH_ICON_PATH, "").equals("")) { >+ return DebugPluginImages.getImageDescriptor(config.getType().getIdentifier()); >+ } >+ } catch (CoreException e) { >+ DebugUIPlugin.log(e); >+ } >+ >+ imageDesc = (ImageDescriptor)customImageDescriptors.get(config.getName()); >+ //first time accessing the registry, update the cache, then retrieve it again >+ if (imageDesc == null) { >+ updateCache(config); >+ imageDesc = (ImageDescriptor)customImageDescriptors.get(config.getName()); >+ } >+ >+ return imageDesc; >+ >+ } >+ /** >+ * update the stored imagedescriptor for this specific launch configuration. >+ * Typically this is called if you know for certain that a launch configuration >+ * has had it's icon field updated. >+ * >+ * @param config >+ */ >+ public void updateCache (ILaunchConfiguration config) { >+ ImageDescriptor imageDesc = createLaunchConfigImageDescriptor(config); >+ customImageDescriptors.put(config.getName(), imageDesc); >+ } >+ >+ /** >+ * Needs to be called when a launch configuration is removed from the external tools dialog >+ * @param config >+ */ >+ public void removeImageDescriptor(ILaunchConfiguration config) { >+ customImageDescriptors.remove(config.getName()); >+ } >+ >+ private ImageDescriptor createLaunchConfigImageDescriptor(ILaunchConfiguration config) { >+ String subbedString; >+ ImageDescriptor id = null; >+ try { >+ subbedString = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution( >+ config.getAttribute(ILaunchManager.ATTR_LAUNCH_ICON_PATH, "")); >+ id = ImageDescriptor.createFromFile(null, subbedString); >+ } catch (CoreException e) { >+ id = ImageDescriptor.getMissingImageDescriptor(); >+ } >+ >+ return id; >+ } >+} >Index: ui/org/eclipse/debug/internal/ui/ShowOnToolbarAction.java >=================================================================== >RCS file: ui/org/eclipse/debug/internal/ui/ShowOnToolbarAction.java >diff -N ui/org/eclipse/debug/internal/ui/ShowOnToolbarAction.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ ui/org/eclipse/debug/internal/ui/ShowOnToolbarAction.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,28 @@ >+package org.eclipse.debug.internal.ui; >+ >+import org.eclipse.debug.internal.ui.preferences.IDebugPreferenceConstants; >+import org.eclipse.jface.action.Action; >+ >+/** >+ * @author tmak >+ * This action handles toggling the custom toolbar on and off. It will appaer in the >+ * External Tools drop down menu. >+ */ >+public class ShowOnToolbarAction extends Action{ >+ >+ private boolean checked; >+ >+ public ShowOnToolbarAction() { >+ super(DebugUIMessages.ShowFavouritesOnToolbarAction_1); >+ //get checked state from preference store >+ checked = DebugUIPlugin.getDefault().getPreferenceStore().getBoolean(IDebugPreferenceConstants.SHOW_FAVOURITES_ON_TOOLBAR); >+ setChecked(checked); >+ } >+ >+ public void run() { >+ DebugUIPlugin.getDefault().getPreferenceStore().setValue(IDebugPreferenceConstants.SHOW_FAVOURITES_ON_TOOLBAR,!checked); >+ DebugUIPlugin.getDefault().savePluginPreferences(); >+ CustomToolbarManager.getInstance().displayToolbarButtons(!checked); >+ } >+ >+} >Index: ui/org/eclipse/debug/internal/ui/CustomToolbarManager.java >=================================================================== >RCS file: ui/org/eclipse/debug/internal/ui/CustomToolbarManager.java >diff -N ui/org/eclipse/debug/internal/ui/CustomToolbarManager.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ ui/org/eclipse/debug/internal/ui/CustomToolbarManager.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,235 @@ >+package org.eclipse.debug.internal.ui; >+ >+import java.util.HashMap; >+import java.util.Iterator; >+import java.util.List; >+import java.util.Vector; >+ >+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.ILaunchConfiguration; >+import org.eclipse.debug.core.ILaunchConfigurationListener; >+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; >+import org.eclipse.debug.core.ILaunchManager; >+import org.eclipse.debug.internal.ui.launchConfigurations.LaunchHistory; >+import org.eclipse.debug.internal.ui.preferences.IDebugPreferenceConstants; >+import org.eclipse.debug.internal.ui.preferences.LaunchConfigurationsPreferencePage; >+import org.eclipse.debug.ui.DebugUITools; >+import org.eclipse.debug.ui.IDebugUIConstants; >+import org.eclipse.jface.action.Action; >+import org.eclipse.jface.action.ICoolBarManager; >+import org.eclipse.jface.action.IToolBarManager; >+import org.eclipse.jface.action.ToolBarContributionItem; >+import org.eclipse.jface.action.ToolBarManager; >+import org.eclipse.jface.resource.ImageDescriptor; >+import org.eclipse.jface.window.ApplicationWindow; >+import org.eclipse.swt.widgets.Display; >+import org.eclipse.ui.IWorkbenchWindow; >+import org.eclipse.ui.PlatformUI; >+ >+/** >+ * @author tmak >+ * This class is used to manage the custom toolbar area for external tool actions. >+ * >+ */ >+public class CustomToolbarManager implements ILaunchHistoryChangedListener, ILaunchConfigurationListener { >+ >+ //ID of the Toolbar group for the custom toolbar actions >+ public static final String ID_CUSTOM_TOOLBAR_GROUP = DebugUIPlugin.getUniqueIdentifier() + ".custom.toolbar"; //$NON-NLS-1$ >+ >+ //ID prefix of the action Toolbar actions >+ public static final String TOOLBAR_CUSTOM_ACTION_ID_PREFIX = ".custom.action."; //$NON-NLS-1$ >+ >+ //singleton instance >+ private static CustomToolbarManager manager; >+ >+ private HashMap toolbarIconPaths = new HashMap(); >+ private IToolBarManager customToolbar; >+ private ICoolBarManager coolBar; >+ private LaunchHistory launchHistory; >+ private boolean showOnToolbar = DebugUIPlugin.getDefault().getPreferenceStore().getBoolean(IDebugPreferenceConstants.SHOW_FAVOURITES_ON_TOOLBAR); >+ private boolean safeToRun = true; >+ >+ public static CustomToolbarManager getInstance() { >+ >+ if (manager == null) { >+ manager = new CustomToolbarManager(); >+ } >+ return manager; >+ } >+ >+ /** >+ * Called by the DebugUI plugin upon startup to initialize the toolbar area. >+ */ >+ public void initialize() { >+ >+ launchHistory = DebugUIPlugin.getDefault().getLaunchConfigurationManager(). >+ getLaunchHistory(LaunchConfigurationsPreferencePage.EXT_BUILDER_GROUP); >+ >+ DebugUIPlugin.getDefault().getLaunchConfigurationManager().addLaunchHistoryListener(this); >+ DebugPlugin.getDefault().getLaunchManager().addLaunchConfigurationListener(this); >+ >+ //get the workbench toolbar >+ IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); >+ >+ if (window != null && window instanceof ApplicationWindow) { >+ ApplicationWindow w = (ApplicationWindow)window; >+ coolBar = w.getCoolBarManager(); >+ } >+ >+ //add the empty Toolbar area to the Coolbar manager >+ if (coolBar != null) { >+ ToolBarManager newManager = new ToolBarManager(coolBar.getStyle()); >+ ToolBarContributionItem wrapper = new ToolBarContributionItem(newManager, ID_CUSTOM_TOOLBAR_GROUP); >+ coolBar.add(wrapper); >+ >+ } >+ >+ if (window == null || coolBar == null) { >+ safeToRun = false; >+ DebugUIPlugin.log(new Status(IStatus.ERROR, >+ DebugUIPlugin.getUniqueIdentifier(), >+ 0,"Failed to initialize custom toolbar", null)); >+ } >+ >+ customToolbar = ((ToolBarContributionItem)coolBar.find(ID_CUSTOM_TOOLBAR_GROUP)).getToolBarManager(); >+ >+ displayToolbarButtons(showOnToolbar); >+ } >+ >+ private void reloadToolbar() { >+ >+ Vector favList = new Vector(); >+ ILaunchConfiguration configs[] = launchHistory.getFavorites(); >+ ImageDescriptor imgID; >+ >+ //wrap all the configurations as a LaunchConfigAction >+ for (int i = 0; i < configs.length; i++) { >+ imgID = CustomImageRegistry.getInstance().getImageDescriptor(configs[i]); >+ favList.add(new LaunchConfigAction(configs[i],imgID)); >+ } >+ >+ customToolbar.removeAll(); >+ //add all the Favourites actions to the Toolbar >+ Iterator i = favList.iterator(); >+ while (i.hasNext()) { >+ customToolbar.add((LaunchConfigAction)i.next()); >+ } >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.internal.ui.ILaunchHistoryChangedListener#launchHistoryChanged() >+ */ >+ public void launchHistoryChanged() { >+ displayToolbarButtons(showOnToolbar); >+ } >+ >+ public void displayToolbarButtons(boolean show) { >+ >+ if (safeToRun) { >+ //this is the only method that should be changing the value of show, so we need to update it >+ this.showOnToolbar = show; >+ if (showOnToolbar) { >+ reloadToolbar(); >+ } >+ else { >+ customToolbar.removeAll(); >+ } >+ >+ //This is required because of the update Favourites progress dialog >+ Display.getDefault().syncExec(new Runnable() { >+ public void run() { >+ coolBar.update(true); >+ } >+ }); >+ } >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.ILaunchConfigurationListener#launchConfigurationAdded(org.eclipse.debug.core.ILaunchConfiguration) >+ */ >+ public void launchConfigurationAdded(ILaunchConfiguration configuration) { >+ >+ try { >+ //if this config is not on the toolbar, don't bother refreshing >+ List favoriteGroups = configuration.getAttribute(IDebugUIConstants.ATTR_FAVORITE_GROUPS, (List)null); >+ >+ if (favoriteGroups != null && >+ favoriteGroups.contains(LaunchConfigurationsPreferencePage.EXT_BUILDER_GROUP)) { >+ >+ ILaunchConfigurationWorkingCopy newCopy = configuration.getWorkingCopy(); >+ String existingIconPath = (String)toolbarIconPaths.get(newCopy.getName()); >+ //if it's not null, and the attribute is different than the value we have stored, recreate the images. >+ if (existingIconPath != null && >+ !existingIconPath.equals(configuration.getAttribute(ILaunchManager.ATTR_LAUNCH_ICON_PATH, ""))) { >+ displayToolbarButtons(showOnToolbar); >+ } >+ } >+ } catch (CoreException e) { >+ } >+ >+ } >+ >+ public void launchConfigurationChanged(ILaunchConfiguration configuration) { >+ >+ } >+ >+ public void launchConfigurationRemoved(ILaunchConfiguration configuration) { >+ CustomImageRegistry.getInstance().removeImageDescriptor(configuration); >+ } >+ >+/** >+ * @author tmak >+ * This class is used to wrap actions that will be shown on the custom toolbar. >+ */ >+class LaunchConfigAction extends Action { >+ >+ ILaunchConfiguration config; >+ >+ public LaunchConfigAction(ILaunchConfiguration config, ImageDescriptor imgID) { >+ >+ this.config = config; >+ >+ try { >+ //store the icon paths in a map, in case a user changes the icon in the External Tools preference page >+ toolbarIconPaths.put(config.getName(), config.getAttribute(ILaunchManager.ATTR_LAUNCH_ICON_PATH, "")); >+ } >+ catch(CoreException e) { >+ } >+ >+ setToolTipText(config.getName()); >+ setImageDescriptor(imgID); >+ setId(TOOLBAR_CUSTOM_ACTION_ID_PREFIX + config.getName()); >+ >+ } >+ >+ private void updateLaunchConfig() throws CoreException { >+ >+ ILaunchConfiguration allLaunchConfigs[] = DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurations(); >+ for (int i = 0; i < allLaunchConfigs.length; i++) { >+ //since names must be unique throughout all configurations, this should be a safe check >+ if (this.config.getName().equals(allLaunchConfigs[i].getName())) { >+ config = allLaunchConfigs[i]; >+ return; >+ } >+ } >+ >+ } >+ >+ public void run() { >+ //In this run method, query for the most up to date config to run. >+ try { >+ updateLaunchConfig(); >+ DebugUITools.launch(config, launchHistory.getLaunchGroup().getMode()); >+ } >+ catch (CoreException e) { >+ DebugUIPlugin.log(e); >+ } >+ } >+ >+} >+ >+} >+ >Index: ui/org/eclipse/debug/internal/ui/FileSelectionDialog.java >=================================================================== >RCS file: ui/org/eclipse/debug/internal/ui/FileSelectionDialog.java >diff -N ui/org/eclipse/debug/internal/ui/FileSelectionDialog.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ ui/org/eclipse/debug/internal/ui/FileSelectionDialog.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,244 @@ >+/******************************************************************************* >+ * 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.debug.internal.ui; >+ >+import java.util.ArrayList; >+import java.util.List; >+import java.util.regex.Pattern; >+import org.eclipse.core.resources.IContainer; >+import org.eclipse.core.resources.IResource; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IAdaptable; >+import org.eclipse.jface.dialogs.IDialogConstants; >+import org.eclipse.jface.dialogs.MessageDialog; >+import org.eclipse.jface.viewers.DoubleClickEvent; >+import org.eclipse.jface.viewers.IDoubleClickListener; >+import org.eclipse.jface.viewers.ISelectionChangedListener; >+import org.eclipse.jface.viewers.IStructuredSelection; >+import org.eclipse.jface.viewers.ITreeContentProvider; >+import org.eclipse.jface.viewers.SelectionChangedEvent; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.events.ControlEvent; >+import org.eclipse.swt.events.ControlListener; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.swt.widgets.Control; >+import org.eclipse.swt.widgets.Shell; >+import org.eclipse.swt.widgets.TableColumn; >+import org.eclipse.ui.PlatformUI; >+import org.eclipse.ui.model.WorkbenchContentProvider; >+import org.eclipse.ui.model.WorkbenchLabelProvider; >+ >+/** >+ * Dialog for selecting a file in the workspace. Derived from >+ * org.eclipse.ui.dialogs.ResourceSelectionDialog >+ */ >+public class FileSelectionDialog extends MessageDialog { >+ // the root element to populate the viewer with >+ private IAdaptable root; >+ >+ // the visual selection widget group >+ private TreeAndListGroup selectionGroup; >+ // constants >+ private final static int SIZING_SELECTION_WIDGET_WIDTH = 400; >+ private final static int SIZING_SELECTION_WIDGET_HEIGHT = 300; >+ /** >+ * The file(s) selected by the user. >+ */ >+ private IStructuredSelection result = null; >+ >+ private boolean allowMultiselection= false; >+ >+ private Pattern fPattern; >+ /** >+ * Creates a resource selection dialog rooted at the given element. >+ * >+ * @param parentShell >+ * the parent shell >+ * @param rootElement >+ * the root element to populate this dialog with >+ * @param message >+ * the message to be displayed at the top of this dialog, or >+ * <code>null</code> to display a default message >+ */ >+ public FileSelectionDialog(Shell parentShell, IAdaptable rootElement, String message) { >+ super(parentShell, DebugUIMessages.FileSelectionDialog_Choose_Location_1, null, message, MessageDialog.NONE, new String[] { DebugUIMessages.FileSelectionDialog_Ok_2, DebugUIMessages.FileSelectionDialog_Cancel_3}, 0); >+ root = rootElement; >+ setShellStyle(getShellStyle() | SWT.RESIZE); >+ } >+ >+ /** >+ * Limits the files displayed in this dialog to files matching the given >+ * pattern. The string can be a filename or a regular expression containing >+ * '*' for any series of characters or '?' for any single character. >+ * >+ * @param pattern >+ * a pattern used to filter the displayed files or <code>null</code> >+ * to display all files. If a pattern is supplied, only files >+ * whose names match the given pattern will be available for >+ * selection. >+ * @param ignoreCase >+ * if true, case is ignored. If the pattern argument is <code>null</code>, >+ * this argument is ignored. >+ */ >+ public void setFileFilter(String pattern, boolean ignoreCase) { >+ if (pattern != null) { >+ if (ignoreCase) { >+ fPattern = Pattern.compile(pattern, Pattern.CASE_INSENSITIVE); >+ } else { >+ fPattern = Pattern.compile(pattern); >+ } >+ } else { >+ fPattern = null; >+ } >+ } >+ >+ /* >+ * (non-Javadoc) Method declared in Window. >+ */ >+ protected void configureShell(Shell shell) { >+ super.configureShell(shell); >+ PlatformUI.getWorkbench().getHelpSystem().setHelp(shell, IDebugHelpContextIds.FILE_SELECTION_DIALOG); >+ } >+ >+ protected void createButtonsForButtonBar(Composite parent) { >+ super.createButtonsForButtonBar(parent); >+ initializeDialog(); >+ } >+ >+ /* >+ * (non-Javadoc) Method declared on Dialog. >+ */ >+ protected Control createDialogArea(Composite parent) { >+ // page group >+ Composite composite = (Composite) super.createDialogArea(parent); >+ >+ //create the input element, which has the root resource >+ //as its only child >+ selectionGroup = >+ new TreeAndListGroup( >+ composite, >+ root, >+ getResourceProvider( >+ IResource.FOLDER | IResource.PROJECT | IResource.ROOT), >+ new WorkbenchLabelProvider(), >+ getResourceProvider(IResource.FILE), >+ new WorkbenchLabelProvider(), >+ SWT.NONE, >+ // since this page has no other significantly-sized >+ // widgets we need to hardcode the combined widget's >+ // size, otherwise it will open too small >+ SIZING_SELECTION_WIDGET_WIDTH, SIZING_SELECTION_WIDGET_HEIGHT, >+ allowMultiselection); >+ >+ composite.addControlListener(new ControlListener() { >+ public void controlMoved(ControlEvent e) { >+ } >+ public void controlResized(ControlEvent e) { >+ //Also try and reset the size of the columns as appropriate >+ TableColumn[] columns = >+ selectionGroup.getListTable().getColumns(); >+ for (int i = 0; i < columns.length; i++) { >+ columns[i].pack(); >+ } >+ } >+ }); >+ >+ return composite; >+ } >+ /** >+ * Returns a content provider for <code>IResource</code> s that returns >+ * only children of the given resource type. >+ */ >+ private ITreeContentProvider getResourceProvider(final int resourceType) { >+ return new WorkbenchContentProvider() { >+ public Object[] getChildren(Object o) { >+ if (o instanceof IContainer) { >+ IResource[] members = null; >+ try { >+ members = ((IContainer) o).members(); >+ List accessibleMembers = new ArrayList(members.length); >+ for (int i = 0; i < members.length; i++) { >+ IResource resource = members[i]; >+ if (resource.isAccessible()) { >+ accessibleMembers.add(resource); >+ } >+ } >+ members = >+ (IResource[]) accessibleMembers.toArray( >+ new IResource[accessibleMembers.size()]); >+ } catch (CoreException e) { >+ //just return an empty set of children >+ return new Object[0]; >+ } >+ >+ //filter out the desired resource types >+ ArrayList results = new ArrayList(); >+ for (int i = 0; i < members.length; i++) { >+ //And the test bits with the resource types to see if >+ // they are what we want >+ if ((members[i].getType() & resourceType) > 0) { >+ if (members[i].getType() == IResource.FILE >+ && fPattern != null >+ && !fPattern.matcher(members[i].getName()).find()) { >+ continue; >+ } >+ results.add(members[i]); >+ } >+ } >+ return results.toArray(); >+ } >+ >+ return new Object[0]; >+ } >+ }; >+ } >+ /** >+ * Initializes this dialog's controls. >+ */ >+ private void initializeDialog() { >+ selectionGroup >+ .addSelectionChangedListener(new ISelectionChangedListener() { >+ public void selectionChanged(SelectionChangedEvent event) { >+ getButton(IDialogConstants.OK_ID).setEnabled( >+ !selectionGroup.getListTableSelection().isEmpty()); >+ } >+ }); >+ selectionGroup.addDoubleClickListener(new IDoubleClickListener() { >+ public void doubleClick(DoubleClickEvent event) { >+ buttonPressed(IDialogConstants.OK_ID); >+ } >+ }); >+ >+ getButton(IDialogConstants.OK_ID).setEnabled(false); >+ } >+ >+ /** >+ * Returns the file the user chose or <code>null</code> if none. >+ */ >+ public IStructuredSelection getResult() { >+ return result; >+ } >+ >+ protected void buttonPressed(int buttonId) { >+ if (buttonId == IDialogConstants.OK_ID) { >+ result= selectionGroup.getListTableSelection(); >+ } >+ super.buttonPressed(buttonId); >+ } >+ /** >+ * Sets whether this dialog will allow multi-selection. >+ * Must be called before <code>open</code> >+ * @param allowMultiselection whether to allow multi-selection in the dialog >+ */ >+ public void setAllowMultiselection(boolean allowMultiselection) { >+ this.allowMultiselection= allowMultiselection; >+ } >+} >#P org.eclipse.ui.externaltools >Index: External Tools Base/org/eclipse/ui/externaltools/internal/ui/FileSelectionDialog.java >=================================================================== >RCS file: External Tools Base/org/eclipse/ui/externaltools/internal/ui/FileSelectionDialog.java >diff -N External Tools Base/org/eclipse/ui/externaltools/internal/ui/FileSelectionDialog.java >--- External Tools Base/org/eclipse/ui/externaltools/internal/ui/FileSelectionDialog.java 12 Aug 2005 20:39:29 -0000 1.19 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,245 +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.ui; >- >-import java.util.ArrayList; >-import java.util.List; >-import java.util.regex.Pattern; >-import org.eclipse.core.resources.IContainer; >-import org.eclipse.core.resources.IResource; >-import org.eclipse.core.runtime.CoreException; >-import org.eclipse.core.runtime.IAdaptable; >-import org.eclipse.jface.dialogs.IDialogConstants; >-import org.eclipse.jface.dialogs.MessageDialog; >-import org.eclipse.jface.viewers.DoubleClickEvent; >-import org.eclipse.jface.viewers.IDoubleClickListener; >-import org.eclipse.jface.viewers.ISelectionChangedListener; >-import org.eclipse.jface.viewers.IStructuredSelection; >-import org.eclipse.jface.viewers.ITreeContentProvider; >-import org.eclipse.jface.viewers.SelectionChangedEvent; >-import org.eclipse.swt.SWT; >-import org.eclipse.swt.events.ControlEvent; >-import org.eclipse.swt.events.ControlListener; >-import org.eclipse.swt.widgets.Composite; >-import org.eclipse.swt.widgets.Control; >-import org.eclipse.swt.widgets.Shell; >-import org.eclipse.swt.widgets.TableColumn; >-import org.eclipse.ui.PlatformUI; >-import org.eclipse.ui.externaltools.internal.model.IExternalToolsHelpContextIds; >-import org.eclipse.ui.model.WorkbenchContentProvider; >-import org.eclipse.ui.model.WorkbenchLabelProvider; >- >-/** >- * Dialog for selecting a file in the workspace. Derived from >- * org.eclipse.ui.dialogs.ResourceSelectionDialog >- */ >-public class FileSelectionDialog extends MessageDialog { >- // the root element to populate the viewer with >- private IAdaptable root; >- >- // the visual selection widget group >- private TreeAndListGroup selectionGroup; >- // constants >- private final static int SIZING_SELECTION_WIDGET_WIDTH = 400; >- private final static int SIZING_SELECTION_WIDGET_HEIGHT = 300; >- /** >- * The file(s) selected by the user. >- */ >- private IStructuredSelection result = null; >- >- private boolean allowMultiselection= false; >- >- private Pattern fPattern; >- /** >- * Creates a resource selection dialog rooted at the given element. >- * >- * @param parentShell >- * the parent shell >- * @param rootElement >- * the root element to populate this dialog with >- * @param message >- * the message to be displayed at the top of this dialog, or >- * <code>null</code> to display a default message >- */ >- public FileSelectionDialog(Shell parentShell, IAdaptable rootElement, String message) { >- super(parentShell, ExternalToolsUIMessages.FileSelectionDialog_Choose_Location_1, null, message, MessageDialog.NONE, new String[] { ExternalToolsUIMessages.FileSelectionDialog_Ok_2, ExternalToolsUIMessages.FileSelectionDialog_Cancel_3}, 0); >- root = rootElement; >- setShellStyle(getShellStyle() | SWT.RESIZE); >- } >- >- /** >- * Limits the files displayed in this dialog to files matching the given >- * pattern. The string can be a filename or a regular expression containing >- * '*' for any series of characters or '?' for any single character. >- * >- * @param pattern >- * a pattern used to filter the displayed files or <code>null</code> >- * to display all files. If a pattern is supplied, only files >- * whose names match the given pattern will be available for >- * selection. >- * @param ignoreCase >- * if true, case is ignored. If the pattern argument is <code>null</code>, >- * this argument is ignored. >- */ >- public void setFileFilter(String pattern, boolean ignoreCase) { >- if (pattern != null) { >- if (ignoreCase) { >- fPattern = Pattern.compile(pattern, Pattern.CASE_INSENSITIVE); >- } else { >- fPattern = Pattern.compile(pattern); >- } >- } else { >- fPattern = null; >- } >- } >- >- /* >- * (non-Javadoc) Method declared in Window. >- */ >- protected void configureShell(Shell shell) { >- super.configureShell(shell); >- PlatformUI.getWorkbench().getHelpSystem().setHelp(shell, IExternalToolsHelpContextIds.FILE_SELECTION_DIALOG); >- } >- >- protected void createButtonsForButtonBar(Composite parent) { >- super.createButtonsForButtonBar(parent); >- initializeDialog(); >- } >- >- /* >- * (non-Javadoc) Method declared on Dialog. >- */ >- protected Control createDialogArea(Composite parent) { >- // page group >- Composite composite = (Composite) super.createDialogArea(parent); >- >- //create the input element, which has the root resource >- //as its only child >- selectionGroup = >- new TreeAndListGroup( >- composite, >- root, >- getResourceProvider( >- IResource.FOLDER | IResource.PROJECT | IResource.ROOT), >- new WorkbenchLabelProvider(), >- getResourceProvider(IResource.FILE), >- new WorkbenchLabelProvider(), >- SWT.NONE, >- // since this page has no other significantly-sized >- // widgets we need to hardcode the combined widget's >- // size, otherwise it will open too small >- SIZING_SELECTION_WIDGET_WIDTH, SIZING_SELECTION_WIDGET_HEIGHT, >- allowMultiselection); >- >- composite.addControlListener(new ControlListener() { >- public void controlMoved(ControlEvent e) { >- } >- public void controlResized(ControlEvent e) { >- //Also try and reset the size of the columns as appropriate >- TableColumn[] columns = >- selectionGroup.getListTable().getColumns(); >- for (int i = 0; i < columns.length; i++) { >- columns[i].pack(); >- } >- } >- }); >- >- return composite; >- } >- /** >- * Returns a content provider for <code>IResource</code> s that returns >- * only children of the given resource type. >- */ >- private ITreeContentProvider getResourceProvider(final int resourceType) { >- return new WorkbenchContentProvider() { >- public Object[] getChildren(Object o) { >- if (o instanceof IContainer) { >- IResource[] members = null; >- try { >- members = ((IContainer) o).members(); >- List accessibleMembers = new ArrayList(members.length); >- for (int i = 0; i < members.length; i++) { >- IResource resource = members[i]; >- if (resource.isAccessible()) { >- accessibleMembers.add(resource); >- } >- } >- members = >- (IResource[]) accessibleMembers.toArray( >- new IResource[accessibleMembers.size()]); >- } catch (CoreException e) { >- //just return an empty set of children >- return new Object[0]; >- } >- >- //filter out the desired resource types >- ArrayList results = new ArrayList(); >- for (int i = 0; i < members.length; i++) { >- //And the test bits with the resource types to see if >- // they are what we want >- if ((members[i].getType() & resourceType) > 0) { >- if (members[i].getType() == IResource.FILE >- && fPattern != null >- && !fPattern.matcher(members[i].getName()).find()) { >- continue; >- } >- results.add(members[i]); >- } >- } >- return results.toArray(); >- } >- >- return new Object[0]; >- } >- }; >- } >- /** >- * Initializes this dialog's controls. >- */ >- private void initializeDialog() { >- selectionGroup >- .addSelectionChangedListener(new ISelectionChangedListener() { >- public void selectionChanged(SelectionChangedEvent event) { >- getButton(IDialogConstants.OK_ID).setEnabled( >- !selectionGroup.getListTableSelection().isEmpty()); >- } >- }); >- selectionGroup.addDoubleClickListener(new IDoubleClickListener() { >- public void doubleClick(DoubleClickEvent event) { >- buttonPressed(IDialogConstants.OK_ID); >- } >- }); >- >- getButton(IDialogConstants.OK_ID).setEnabled(false); >- } >- >- /** >- * Returns the file the user chose or <code>null</code> if none. >- */ >- public IStructuredSelection getResult() { >- return result; >- } >- >- protected void buttonPressed(int buttonId) { >- if (buttonId == IDialogConstants.OK_ID) { >- result= selectionGroup.getListTableSelection(); >- } >- super.buttonPressed(buttonId); >- } >- /** >- * Sets whether this dialog will allow multi-selection. >- * Must be called before <code>open</code> >- * @param allowMultiselection whether to allow multi-selection in the dialog >- */ >- public void setAllowMultiselection(boolean allowMultiselection) { >- this.allowMultiselection= allowMultiselection; >- } >-} >Index: External Tools Base/org/eclipse/ui/externaltools/internal/ui/TreeAndListGroup.java >=================================================================== >RCS file: External Tools Base/org/eclipse/ui/externaltools/internal/ui/TreeAndListGroup.java >diff -N External Tools Base/org/eclipse/ui/externaltools/internal/ui/TreeAndListGroup.java >--- External Tools Base/org/eclipse/ui/externaltools/internal/ui/TreeAndListGroup.java 23 Feb 2005 16:02:16 -0000 1.12 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,316 +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.ui; >- >- >-import java.util.ArrayList; >-import java.util.Iterator; >-import java.util.List; >- >-import org.eclipse.jface.viewers.DoubleClickEvent; >-import org.eclipse.jface.viewers.IDoubleClickListener; >-import org.eclipse.jface.viewers.ILabelProvider; >-import org.eclipse.jface.viewers.ISelection; >-import org.eclipse.jface.viewers.ISelectionChangedListener; >-import org.eclipse.jface.viewers.IStructuredContentProvider; >-import org.eclipse.jface.viewers.IStructuredSelection; >-import org.eclipse.jface.viewers.ITreeContentProvider; >-import org.eclipse.jface.viewers.SelectionChangedEvent; >-import org.eclipse.jface.viewers.StructuredSelection; >-import org.eclipse.jface.viewers.TableViewer; >-import org.eclipse.jface.viewers.TreeViewer; >-import org.eclipse.jface.viewers.ViewerSorter; >-import org.eclipse.swt.SWT; >-import org.eclipse.swt.layout.GridData; >-import org.eclipse.swt.layout.GridLayout; >-import org.eclipse.swt.widgets.Composite; >-import org.eclipse.swt.widgets.Table; >-import org.eclipse.swt.widgets.Tree; >-import org.eclipse.ui.views.navigator.ResourceSorter; >- >-/** >- * This class was derived from org.eclipse.ui.internal.misc.CheckboxTreeAndListGroup >- * >- */ >-public class TreeAndListGroup implements ISelectionChangedListener { >- private Object root; >- private Object currentTreeSelection; >- private List selectionChangedListeners = new ArrayList(); >- private List doubleClickListeners= new ArrayList(); >- >- private ITreeContentProvider treeContentProvider; >- private IStructuredContentProvider listContentProvider; >- private ILabelProvider treeLabelProvider; >- private ILabelProvider listLabelProvider; >- >- // widgets >- private TreeViewer treeViewer; >- private TableViewer listViewer; >- private boolean allowMultiselection= false; >- >- /** >- * Create an instance of this class. Use this constructor if you wish to specify >- * the width and/or height of the combined widget (to only hardcode one of the >- * sizing dimensions, specify the other dimension's value as -1) >- * >- * @param parent org.eclipse.swt.widgets.Composite >- * @param style int >- * @param rootObject java.lang.Object >- * @param width int >- * @param height int >- * @param allowMultiselection Whether to allow multi-selection in the list viewer. >- */ >- public TreeAndListGroup(Composite parent, Object rootObject, ITreeContentProvider treeContentProvider, ILabelProvider treeLabelProvider, IStructuredContentProvider listContentProvider, ILabelProvider listLabelProvider, int style, int width, int height, boolean allowMultiselection) { >- >- root = rootObject; >- this.treeContentProvider = treeContentProvider; >- this.listContentProvider = listContentProvider; >- this.treeLabelProvider = treeLabelProvider; >- this.listLabelProvider = listLabelProvider; >- this.allowMultiselection= allowMultiselection; >- createContents(parent, width, height, style); >- } >- /** >- * This method must be called just before this window becomes visible. >- */ >- public void aboutToOpen() { >- currentTreeSelection = null; >- >- //select the first element in the list >- Object[] elements = treeContentProvider.getElements(root); >- Object primary = elements.length > 0 ? elements[0] : null; >- if (primary != null) { >- treeViewer.setSelection(new StructuredSelection(primary)); >- } >- treeViewer.getControl().setFocus(); >- } >- /** >- * Add the passed listener to collection of clients >- * that listen for changes to list viewer selection state >- * >- * @param listener ISelectionChangedListener >- */ >- public void addSelectionChangedListener(ISelectionChangedListener listener) { >- selectionChangedListeners.add(listener); >- } >- >- /** >- * Add the given listener to the collection of clients that listen to >- * double-click events in the list viewer >- * >- * @param listener IDoubleClickListener >- */ >- public void addDoubleClickListener(IDoubleClickListener listener) { >- doubleClickListeners.add(listener); >- } >- >- /** >- * Notify all selection listeners that a selection has occurred in the list >- * viewer >- */ >- protected void notifySelectionListeners(SelectionChangedEvent event) { >- Iterator iter = selectionChangedListeners.iterator(); >- while (iter.hasNext()) { >- ((ISelectionChangedListener) iter.next()).selectionChanged(event); >- } >- } >- >- /** >- * Notify all double click listeners that a double click event has occurred >- * in the list viewer >- */ >- protected void notifyDoubleClickListeners(DoubleClickEvent event) { >- Iterator iter= doubleClickListeners.iterator(); >- while (iter.hasNext()) { >- ((IDoubleClickListener) iter.next()).doubleClick(event); >- } >- } >- >- /** >- * Lay out and initialize self's visual components. >- * >- * @param parent org.eclipse.swt.widgets.Composite >- * @param width int >- * @param height int >- */ >- protected void createContents(Composite parent, int width, int height, int style) { >- // group pane >- Composite composite = new Composite(parent, style); >- composite.setFont(parent.getFont()); >- GridLayout layout = new GridLayout(); >- layout.numColumns = 2; >- layout.makeColumnsEqualWidth = true; >- layout.marginHeight = 0; >- layout.marginWidth = 0; >- composite.setLayout(layout); >- composite.setLayoutData(new GridData(GridData.FILL_BOTH)); >- >- createTreeViewer(composite, width / 2, height); >- createListViewer(composite, width / 2, height); >- >- initialize(); >- } >- /** >- * Create this group's list viewer. >- */ >- protected void createListViewer(Composite parent, int width, int height) { >- int style; >- if (allowMultiselection) { >- style= SWT.MULTI; >- } else { >- style= SWT.SINGLE; >- } >- listViewer = new TableViewer(parent, SWT.BORDER | style); >- GridData data = new GridData(GridData.FILL_BOTH); >- data.widthHint = width; >- data.heightHint = height; >- listViewer.getTable().setLayoutData(data); >- listViewer.getTable().setFont(parent.getFont()); >- listViewer.setContentProvider(listContentProvider); >- listViewer.setLabelProvider(listLabelProvider); >- listViewer.setSorter(new ResourceSorter(ResourceSorter.NAME)); >- listViewer.addSelectionChangedListener(new ISelectionChangedListener() { >- public void selectionChanged(SelectionChangedEvent event) { >- notifySelectionListeners(event); >- } >- }); >- listViewer.addDoubleClickListener(new IDoubleClickListener() { >- public void doubleClick(DoubleClickEvent event) { >- if (!event.getSelection().isEmpty()) { >- notifyDoubleClickListeners(event); >- } >- } >- }); >- } >- /** >- * Create this group's tree viewer. >- */ >- protected void createTreeViewer(Composite parent, int width, int height) { >- Tree tree = new Tree(parent, SWT.BORDER); >- GridData data = new GridData(GridData.FILL_BOTH); >- data.widthHint = width; >- data.heightHint = height; >- tree.setLayoutData(data); >- tree.setFont(parent.getFont()); >- >- treeViewer = new TreeViewer(tree); >- treeViewer.setContentProvider(treeContentProvider); >- treeViewer.setLabelProvider(treeLabelProvider); >- treeViewer.setSorter(new ResourceSorter(ResourceSorter.NAME)); >- treeViewer.addSelectionChangedListener(this); >- } >- >- public Table getListTable() { >- return listViewer.getTable(); >- } >- >- public IStructuredSelection getListTableSelection() { >- ISelection selection= this.listViewer.getSelection(); >- if (selection instanceof IStructuredSelection) { >- return (IStructuredSelection)selection; >- } >- return StructuredSelection.EMPTY; >- } >- >- protected void initialListItem(Object element) { >- Object parent = treeContentProvider.getParent(element); >- selectAndRevealFolder(parent); >- } >- >- public void selectAndRevealFolder(Object treeElement) { >- treeViewer.reveal(treeElement); >- IStructuredSelection selection = new StructuredSelection(treeElement); >- treeViewer.setSelection(selection); >- } >- >- public void selectAndRevealFile(Object treeElement) { >- listViewer.reveal(treeElement); >- IStructuredSelection selection = new StructuredSelection(treeElement); >- listViewer.setSelection(selection); >- } >- >- /** >- * Initialize this group's viewers after they have been laid out. >- */ >- protected void initialize() { >- treeViewer.setInput(root); >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent) >- */ >- public void selectionChanged(SelectionChangedEvent event) { >- IStructuredSelection selection = (IStructuredSelection) event.getSelection(); >- Object selectedElement = selection.getFirstElement(); >- if (selectedElement == null) { >- currentTreeSelection = null; >- listViewer.setInput(currentTreeSelection); >- return; >- } >- >- // ie.- if not an item deselection >- if (selectedElement != currentTreeSelection) { >- listViewer.setInput(selectedElement); >- } >- >- currentTreeSelection = selectedElement; >- } >- /** >- * Set the list viewer's providers to those passed >- * >- * @param contentProvider ITreeContentProvider >- * @param labelProvider ILabelProvider >- */ >- public void setListProviders(IStructuredContentProvider contentProvider, ILabelProvider labelProvider) { >- listViewer.setContentProvider(contentProvider); >- listViewer.setLabelProvider(labelProvider); >- } >- /** >- * Set the sorter that is to be applied to self's list viewer >- */ >- public void setListSorter(ViewerSorter sorter) { >- listViewer.setSorter(sorter); >- } >- /** >- * Set the root of the widget to be new Root. Regenerate all of the tables and lists from this >- * value. >- * @param newRoot >- */ >- public void setRoot(Object newRoot) { >- this.root = newRoot; >- initialize(); >- } >- >- /** >- * Set the tree viewer's providers to those passed >- * >- * @param contentProvider ITreeContentProvider >- * @param labelProvider ILabelProvider >- */ >- public void setTreeProviders(ITreeContentProvider contentProvider, ILabelProvider labelProvider) { >- treeViewer.setContentProvider(contentProvider); >- treeViewer.setLabelProvider(labelProvider); >- } >- /** >- * Set the sorter that is to be applied to self's tree viewer >- */ >- public void setTreeSorter(ViewerSorter sorter) { >- treeViewer.setSorter(sorter); >- } >- >- /** >- * Set the focus on to the list widget. >- */ >- public void setFocus() { >- >- this.treeViewer.getTree().setFocus(); >- } >-} >Index: External Tools Base/org/eclipse/ui/externaltools/internal/model/IExternalToolsHelpContextIds.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/model/IExternalToolsHelpContextIds.java,v >retrieving revision 1.19 >diff -u -r1.19 IExternalToolsHelpContextIds.java >--- External Tools Base/org/eclipse/ui/externaltools/internal/model/IExternalToolsHelpContextIds.java 23 Feb 2005 16:02:16 -0000 1.19 >+++ External Tools Base/org/eclipse/ui/externaltools/internal/model/IExternalToolsHelpContextIds.java 10 Mar 2006 15:58:03 -0000 >@@ -29,7 +29,7 @@ > > //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$ >+ //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$ >Index: Program Tools Support/org/eclipse/ui/externaltools/internal/program/launchConfigurations/ProgramMainTab.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.externaltools/Program Tools Support/org/eclipse/ui/externaltools/internal/program/launchConfigurations/ProgramMainTab.java,v >retrieving revision 1.21 >diff -u -r1.21 ProgramMainTab.java >--- Program Tools Support/org/eclipse/ui/externaltools/internal/program/launchConfigurations/ProgramMainTab.java 12 Aug 2005 20:39:29 -0000 1.21 >+++ Program Tools Support/org/eclipse/ui/externaltools/internal/program/launchConfigurations/ProgramMainTab.java 10 Mar 2006 15:58:03 -0000 >@@ -13,12 +13,12 @@ > > import org.eclipse.core.resources.IFile; > import org.eclipse.core.resources.ResourcesPlugin; >+import org.eclipse.debug.internal.ui.FileSelectionDialog; > import org.eclipse.jface.viewers.IStructuredSelection; > import org.eclipse.swt.widgets.Composite; > import org.eclipse.ui.PlatformUI; > import org.eclipse.ui.externaltools.internal.launchConfigurations.ExternalToolsMainTab; > import org.eclipse.ui.externaltools.internal.model.IExternalToolsHelpContextIds; >-import org.eclipse.ui.externaltools.internal.ui.FileSelectionDialog; > > public class ProgramMainTab extends ExternalToolsMainTab { > >#P org.eclipse.debug.core >Index: core/org/eclipse/debug/core/ILaunchManager.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.debug.core/core/org/eclipse/debug/core/ILaunchManager.java,v >retrieving revision 1.56 >diff -u -r1.56 ILaunchManager.java >--- core/org/eclipse/debug/core/ILaunchManager.java 9 Dec 2005 15:55:03 -0000 1.56 >+++ core/org/eclipse/debug/core/ILaunchManager.java 10 Mar 2006 15:58:03 -0000 >@@ -68,6 +68,16 @@ > public static final String ATTR_APPEND_ENVIRONMENT_VARIABLES = DebugPlugin.getUniqueIdentifier() + ".appendEnvironmentVariables"; //$NON-NLS-1$ > > /** >+ * Launch configuration attribute name. The value contains a path to the >+ * user specified icon file. If this attribute is not defined, then the >+ * default icon (the icon that represents this launch configurations type) >+ * will be used. >+ * >+ * @since 3.2 >+ */ >+ public static final String ATTR_LAUNCH_ICON_PATH = DebugPlugin.getUniqueIdentifier() + ".imagePath"; //$NON-NLS-1$ >+ >+ /** > * Adds the specified launch and notifies listeners. Has no > * effect if an identical launch is already registered. > * >Index: core/org/eclipse/debug/internal/core/LaunchConfigurationWorkingCopy.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfigurationWorkingCopy.java,v >retrieving revision 1.54 >diff -u -r1.54 LaunchConfigurationWorkingCopy.java >--- core/org/eclipse/debug/internal/core/LaunchConfigurationWorkingCopy.java 9 Dec 2005 18:26:07 -0000 1.54 >+++ core/org/eclipse/debug/internal/core/LaunchConfigurationWorkingCopy.java 10 Mar 2006 15:58:03 -0000 >@@ -39,6 +39,7 @@ > import org.eclipse.debug.core.ILaunchConfiguration; > import org.eclipse.debug.core.ILaunchConfigurationType; > import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; >+import org.eclipse.debug.core.ILaunchManager; > > /** > * A working copy launch configuration >@@ -73,6 +74,11 @@ > private boolean fRenamed = false; > > /** >+ * Indicates whether this working copy has had it's icon changed. >+ */ >+ private boolean fIconChanged = false; >+ >+ /** > * Suppress change notification until created > */ > private boolean fSuppressChange = true; >@@ -483,7 +489,8 @@ > * location has changed from that of its original > */ > protected boolean isMoved() { >- if (isNew() || fRenamed) { >+ //if the icon has been changed, also treat it as moved >+ if (isNew() || fRenamed || fIconChanged) { > return true; > } > IContainer newContainer = getContainer(); >@@ -575,5 +582,20 @@ > setAttribute(LaunchConfiguration.ATTR_MAPPED_RESOURCE_TYPES, types); > }//end setResource > >+ /** >+ * Changes the Icon path attribute for this working copy >+ * @param value the value to set the icon path to >+ */ >+ public void changeIconPath(String value) { >+ //if the icon was left empty, remove/don't set the entry >+ if (!value.equals("")) { >+ setAttribute(ILaunchManager.ATTR_LAUNCH_ICON_PATH, value); >+ } >+ else { >+ setAttribute(ILaunchManager.ATTR_LAUNCH_ICON_PATH, (String)null); >+ } >+ fIconChanged = true; >+ } >+ > }//end class > >#P org.eclipse.ant.ui >Index: Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntMainTab.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntMainTab.java,v >retrieving revision 1.21 >diff -u -r1.21 AntMainTab.java >--- Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntMainTab.java 11 Jan 2006 00:46:53 -0000 1.21 >+++ Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntMainTab.java 10 Mar 2006 15:58:03 -0000 >@@ -21,6 +21,7 @@ > import org.eclipse.core.variables.VariablesPlugin; > import org.eclipse.debug.core.ILaunchConfiguration; > import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; >+import org.eclipse.debug.internal.ui.FileSelectionDialog; > import org.eclipse.debug.ui.ILaunchConfigurationTab; > import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants; > import org.eclipse.jface.dialogs.Dialog; >@@ -35,7 +36,6 @@ > import org.eclipse.ui.PlatformUI; > import org.eclipse.ui.externaltools.internal.launchConfigurations.ExternalToolsMainTab; > import org.eclipse.ui.externaltools.internal.model.IExternalToolConstants; >-import org.eclipse.ui.externaltools.internal.ui.FileSelectionDialog; > > public class AntMainTab extends ExternalToolsMainTab { > >Index: Ant Tools Support/org/eclipse/ant/internal/ui/preferences/AddCustomDialog.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/AddCustomDialog.java,v >retrieving revision 1.18 >diff -u -r1.18 AddCustomDialog.java >--- Ant Tools Support/org/eclipse/ant/internal/ui/preferences/AddCustomDialog.java 11 Aug 2005 16:29:47 -0000 1.18 >+++ Ant Tools Support/org/eclipse/ant/internal/ui/preferences/AddCustomDialog.java 10 Mar 2006 15:58:04 -0000 >@@ -27,6 +27,7 @@ > import org.eclipse.core.runtime.IPath; > import org.eclipse.core.runtime.Path; > import org.eclipse.core.variables.VariablesPlugin; >+import org.eclipse.debug.internal.ui.TreeAndListGroup; > import org.eclipse.jface.dialogs.IDialogConstants; > import org.eclipse.jface.dialogs.StatusDialog; > import org.eclipse.jface.viewers.DoubleClickEvent; >@@ -55,7 +56,6 @@ > import org.eclipse.swt.widgets.Text; > import org.eclipse.ui.PlatformUI; > import org.eclipse.ui.dialogs.FileSystemElement; >-import org.eclipse.ui.externaltools.internal.ui.TreeAndListGroup; > import org.eclipse.ui.model.WorkbenchContentProvider; > import org.eclipse.ui.model.WorkbenchLabelProvider; > import org.eclipse.ui.model.WorkbenchViewerSorter;
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 51003
:
36064