Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 51003
Collapse All | Expand All

(-)ui/org/eclipse/debug/internal/ui/DebugUIMessages.java (-1 / +6 lines)
Lines 90-96 Link Here
90
	public static String ReformatAction_title;
90
	public static String ReformatAction_title;
91
	public static String SetDefaultColumnSizePrefAction_DefaultColumnSize;
91
	public static String SetDefaultColumnSizePrefAction_DefaultColumnSize;
92
	public static String SetDefaultColumnSizePrefAction_SetDefaultColumnSize;
92
	public static String SetDefaultColumnSizePrefAction_SetDefaultColumnSize;
93
93
	public static String ShowFavouritesOnToolbarAction_1;
94
	
94
	//
95
	//
95
	// Dialog
96
	// Dialog
96
	//
97
	//
Lines 113-118 Link Here
113
	public static String CodePagesPrefDialog_11;
114
	public static String CodePagesPrefDialog_11;
114
	public static String CodePagesPrefDialog_13;
115
	public static String CodePagesPrefDialog_13;
115
116
117
	public static String FileSelectionDialog_Choose_Location_1;
118
	public static String FileSelectionDialog_Ok_2;
119
	public static String FileSelectionDialog_Cancel_3;
120
	
116
	//
121
	//
117
	// View Tab
122
	// View Tab
118
	//
123
	//
(-)ui/org/eclipse/debug/internal/ui/DebugUIPlugin.java (+7 lines)
Lines 466-471 Link Here
466
		fServiceTracker.open();
466
		fServiceTracker.open();
467
		fPackageAdminService = (PackageAdmin) fServiceTracker.getService();
467
		fPackageAdminService = (PackageAdmin) fServiceTracker.getService();
468
		
468
		
469
		initializeToolbar();
470
		
469
	}
471
	}
470
472
471
	/**
473
	/**
Lines 1081-1085 Link Here
1081
		}
1083
		}
1082
		return ret;
1084
		return ret;
1083
	}
1085
	}
1086
	
1087
	private void initializeToolbar() {
1088
		CustomToolbarManager mgr = CustomToolbarManager.getInstance();
1089
		mgr.initialize();
1090
	}
1084
}
1091
}
1085
1092
(-)ui/org/eclipse/debug/internal/ui/DelegatingModelPresentation.java (-3 / +60 lines)
Lines 11-48 Link Here
11
package org.eclipse.debug.internal.ui;
11
package org.eclipse.debug.internal.ui;
12
12
13
13
14
import java.net.URL;
15
import java.util.Collection;
14
import java.util.HashMap;
16
import java.util.HashMap;
15
import java.util.Iterator;
17
import java.util.Iterator;
16
import java.util.Map;
18
import java.util.Map;
19
import java.util.MissingResourceException;
17
20
18
import org.eclipse.core.resources.IMarker;
21
import org.eclipse.core.resources.IMarker;
22
import org.eclipse.core.runtime.CoreException;
23
import org.eclipse.core.runtime.FileLocator;
19
import org.eclipse.core.runtime.IConfigurationElement;
24
import org.eclipse.core.runtime.IConfigurationElement;
20
import org.eclipse.core.runtime.IExtension;
25
import org.eclipse.core.runtime.IExtension;
21
import org.eclipse.core.runtime.IExtensionPoint;
26
import org.eclipse.core.runtime.IExtensionPoint;
27
import org.eclipse.core.runtime.Path;
22
import org.eclipse.core.runtime.Platform;
28
import org.eclipse.core.runtime.Platform;
29
import org.eclipse.core.variables.VariablesPlugin;
23
import org.eclipse.debug.core.DebugException;
30
import org.eclipse.debug.core.DebugException;
24
import org.eclipse.debug.core.DebugPlugin;
31
import org.eclipse.debug.core.DebugPlugin;
32
import org.eclipse.debug.core.ILaunchConfiguration;
33
import org.eclipse.debug.core.ILaunchManager;
25
import org.eclipse.debug.core.model.IBreakpoint;
34
import org.eclipse.debug.core.model.IBreakpoint;
26
import org.eclipse.debug.core.model.IDebugElement;
35
import org.eclipse.debug.core.model.IDebugElement;
27
import org.eclipse.debug.core.model.IStackFrame;
36
import org.eclipse.debug.core.model.IStackFrame;
28
import org.eclipse.debug.core.model.IThread;
37
import org.eclipse.debug.core.model.IThread;
29
import org.eclipse.debug.core.model.IValue;
38
import org.eclipse.debug.core.model.IValue;
39
import org.eclipse.debug.internal.core.LaunchConfiguration;
30
import org.eclipse.debug.ui.DebugUITools;
40
import org.eclipse.debug.ui.DebugUITools;
31
import org.eclipse.debug.ui.IDebugEditorPresentation;
41
import org.eclipse.debug.ui.IDebugEditorPresentation;
32
import org.eclipse.debug.ui.IDebugModelPresentation;
42
import org.eclipse.debug.ui.IDebugModelPresentation;
33
import org.eclipse.debug.ui.IDebugUIConstants;
43
import org.eclipse.debug.ui.IDebugUIConstants;
34
import org.eclipse.debug.ui.IInstructionPointerPresentation;
44
import org.eclipse.debug.ui.IInstructionPointerPresentation;
35
import org.eclipse.debug.ui.IValueDetailListener;
45
import org.eclipse.debug.ui.IValueDetailListener;
46
import org.eclipse.jface.resource.ImageDescriptor;
36
import org.eclipse.jface.text.source.Annotation;
47
import org.eclipse.jface.text.source.Annotation;
37
import org.eclipse.jface.viewers.IColorProvider;
48
import org.eclipse.jface.viewers.IColorProvider;
38
import org.eclipse.jface.viewers.IFontProvider;
49
import org.eclipse.jface.viewers.IFontProvider;
39
import org.eclipse.jface.viewers.ILabelProvider;
50
import org.eclipse.jface.viewers.ILabelProvider;
40
import org.eclipse.jface.viewers.ILabelProviderListener;
51
import org.eclipse.jface.viewers.ILabelProviderListener;
52
import org.eclipse.swt.SWTException;
41
import org.eclipse.swt.graphics.Color;
53
import org.eclipse.swt.graphics.Color;
42
import org.eclipse.swt.graphics.Font;
54
import org.eclipse.swt.graphics.Font;
43
import org.eclipse.swt.graphics.Image;
55
import org.eclipse.swt.graphics.Image;
56
import org.eclipse.swt.graphics.ImageData;
57
import org.eclipse.swt.graphics.Point;
58
import org.eclipse.swt.widgets.Display;
44
import org.eclipse.ui.IEditorInput;
59
import org.eclipse.ui.IEditorInput;
45
import org.eclipse.ui.IEditorPart;
60
import org.eclipse.ui.IEditorPart;
61
import org.eclipse.ui.PlatformUI;
62
import org.eclipse.ui.internal.util.BundleUtility;
46
63
47
/**
64
/**
48
 * A model presentation that delegates to the appropriate extension. This
65
 * A model presentation that delegates to the appropriate extension. This
Lines 63-68 Link Here
63
	 */
80
	 */
64
	private HashMap fLabelProviders= new HashMap(5);
81
	private HashMap fLabelProviders= new HashMap(5);
65
82
83
	/**
84
	 * A table of user defined custom images.  Requires disposal.
85
	 */
86
	private HashMap fLaunchConfigImages = new HashMap();
87
66
	/* (non-Javadoc)
88
	/* (non-Javadoc)
67
	 * @see org.eclipse.debug.ui.IDebugEditorPresentation#removeAnnotations(org.eclipse.ui.IEditorPart, org.eclipse.debug.core.model.IThread)
89
	 * @see org.eclipse.debug.ui.IDebugEditorPresentation#removeAnnotations(org.eclipse.ui.IEditorPart, org.eclipse.debug.core.model.IThread)
68
	 */
90
	 */
Lines 129-141 Link Here
129
		while (i.hasNext()) {
151
		while (i.hasNext()) {
130
			((ILabelProvider) i.next()).dispose();
152
			((ILabelProvider) i.next()).dispose();
131
		}
153
		}
154
		//dispose of all user defined images here
155
		Iterator j = getLaunchConfigImages().values().iterator();
156
		while (j.hasNext()) {
157
			((Image)j.next()).dispose();
158
		}
132
	}
159
	}
133
160
134
	/**
161
	/**
135
	 * @see IDebugModelPresentation#getImage(Object)
162
	 * @see IDebugModelPresentation#getImage(Object)
136
	 */
163
	 */
137
	public Image getImage(Object item) {
164
	public Image getImage(Object item) {
138
		// Attempt to delegate
165
		/*New order of image retrieval (for Launch Configurations):
166
		 * 1.  Get the user defined custom image.
167
		 * 2.  Get the default image for that launch configuration type.
168
		 */
169
		
170
		Image img = null;
171
		
172
		if (item instanceof ILaunchConfiguration) {
173
			ImageDescriptor id = CustomImageRegistry.getInstance().getImageDescriptor((ILaunchConfiguration)item); 
174
			try {				
175
				img = id.createImage();
176
			}
177
			catch (SWTException e) {
178
				DebugUIPlugin.log(e);
179
				img = ImageDescriptor.getMissingImageDescriptor().createImage();
180
			}
181
			//store custom images for disposal later
182
			getLaunchConfigImages().put(((ILaunchConfiguration)item).getName(), img);
183
			return img;
184
											
185
		}
186
		
187
		//Attempt to delegate
139
		IDebugModelPresentation lp= getConfiguredPresentation(item);
188
		IDebugModelPresentation lp= getConfiguredPresentation(item);
140
		if (lp != null) {
189
		if (lp != null) {
141
			Image image= lp.getImage(item);
190
			Image image= lp.getImage(item);
Lines 146-152 Link Here
146
		// If no delegate returned an image, use the default
195
		// If no delegate returned an image, use the default
147
		return getDefaultImage(item);
196
		return getDefaultImage(item);
148
	}
197
	}
149
	
198
		
150
	/**
199
	/**
151
     * @see IDebugModelPresentation#getText(Object)
200
     * @see IDebugModelPresentation#getText(Object)
152
     */
201
     */
Lines 411-416 Link Here
411
		}
460
		}
412
		return annotation;
461
		return annotation;
413
	}
462
	}
463
	
464
	/**
465
	 * Get the collection of custom images
466
	 * @return the collection of custom images
467
	 */
468
	private HashMap getLaunchConfigImages() {
469
		return fLaunchConfigImages;
470
	}
414
471
415
	/* (non-Javadoc)
472
	/* (non-Javadoc)
416
	 * @see org.eclipse.debug.ui.IInstructionPointerPresentation#getMarkerAnnotationSpecificationId(org.eclipse.ui.IEditorPart, org.eclipse.debug.core.model.IStackFrame)
473
	 * @see org.eclipse.debug.ui.IInstructionPointerPresentation#getMarkerAnnotationSpecificationId(org.eclipse.ui.IEditorPart, org.eclipse.debug.core.model.IStackFrame)
Lines 422-428 Link Here
422
		}
479
		}
423
		return null;
480
		return null;
424
	}
481
	}
425
426
	/* (non-Javadoc)
482
	/* (non-Javadoc)
427
	 * @see org.eclipse.debug.ui.IInstructionPointerPresentation#getInstructionPointerImage(org.eclipse.ui.IEditorPart, org.eclipse.debug.core.model.IStackFrame)
483
	 * @see org.eclipse.debug.ui.IInstructionPointerPresentation#getInstructionPointerImage(org.eclipse.ui.IEditorPart, org.eclipse.debug.core.model.IStackFrame)
428
	 */
484
	 */
Lines 444-447 Link Here
444
		}
500
		}
445
		return null;
501
		return null;
446
	}
502
	}
503
	
447
}
504
}
(-)ui/org/eclipse/debug/internal/ui/IDebugHelpContextIds.java (+1 lines)
Lines 85-90 Link Here
85
	public static final String ADD_FOLDER_CONTAINER_DIALOG = PREFIX + "folder_source_container_dialog";//$NON-NLS-1$
85
	public static final String ADD_FOLDER_CONTAINER_DIALOG = PREFIX + "folder_source_container_dialog";//$NON-NLS-1$
86
	public static final String ADD_ARCHIVE_CONTAINER_DIALOG = PREFIX + "archive_source_container_dialog";//$NON-NLS-1$
86
	public static final String ADD_ARCHIVE_CONTAINER_DIALOG = PREFIX + "archive_source_container_dialog";//$NON-NLS-1$
87
	public static final String MULTIPLE_SOURCE_DIALOG = PREFIX + "multiple_source_selection_dialog";//$NON-NLS-1$
87
	public static final String MULTIPLE_SOURCE_DIALOG = PREFIX + "multiple_source_selection_dialog";//$NON-NLS-1$
88
	public static final String FILE_SELECTION_DIALOG = PREFIX + "file_selection_dialog_context"; //$NON-NLS-1$
88
	public static final String FIND_EXPRESSION_DIALOG = PREFIX + "find_expressions_dialog_context"; //$NON-NLS-1$
89
	public static final String FIND_EXPRESSION_DIALOG = PREFIX + "find_expressions_dialog_context"; //$NON-NLS-1$
89
	public static final String FIND_VARIABLES_DIALOG = PREFIX + "find_variables_dialog_context"; //$NON-NLS-1$
90
	public static final String FIND_VARIABLES_DIALOG = PREFIX + "find_variables_dialog_context"; //$NON-NLS-1$
90
	public static final String ADD_WATCH_EXPRESSION_DIALOG= PREFIX + "add_watch_expression_dialog_context"; //$NON-NLS-1$
91
	public static final String ADD_WATCH_EXPRESSION_DIALOG= PREFIX + "add_watch_expression_dialog_context"; //$NON-NLS-1$
(-)ui/org/eclipse/debug/internal/ui/DebugUIMessages.properties (+5 lines)
Lines 108-113 Link Here
108
ReformatAction_title = Resize to Fit
108
ReformatAction_title = Resize to Fit
109
SetDefaultColumnSizePrefAction_DefaultColumnSize = &Default Column Size...
109
SetDefaultColumnSizePrefAction_DefaultColumnSize = &Default Column Size...
110
SetDefaultColumnSizePrefAction_SetDefaultColumnSize = Set Default Column Size
110
SetDefaultColumnSizePrefAction_SetDefaultColumnSize = Set Default Column Size
111
ShowFavouritesOnToolbarAction_1 = Show Favourites on Toolbar
111
112
112
##############################################################
113
##############################################################
113
# Dialog
114
# Dialog
Lines 131-136 Link Here
131
CodePagesPrefDialog_11=Select Codepage
132
CodePagesPrefDialog_11=Select Codepage
132
CodePagesPrefDialog_13=Restore Defaults
133
CodePagesPrefDialog_13=Restore Defaults
133
134
135
FileSelectionDialog_Choose_Location_1=Choose Location
136
FileSelectionDialog_Ok_2=Ok
137
FileSelectionDialog_Cancel_3=Cancel
138
134
##############################################################
139
##############################################################
135
# View Tab
140
# View Tab
136
##############################################################
141
##############################################################
(-)ui/org/eclipse/debug/internal/ui/launchConfigurations/FavoritesDialog.java (-1 / +28 lines)
Lines 23-29 Link Here
23
import org.eclipse.debug.core.DebugPlugin;
23
import org.eclipse.debug.core.DebugPlugin;
24
import org.eclipse.debug.core.ILaunchConfiguration;
24
import org.eclipse.debug.core.ILaunchConfiguration;
25
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
25
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
26
import org.eclipse.debug.internal.ui.CustomToolbarManager;
26
import org.eclipse.debug.internal.ui.DebugUIPlugin;
27
import org.eclipse.debug.internal.ui.DebugUIPlugin;
28
import org.eclipse.debug.internal.ui.preferences.IDebugPreferenceConstants;
27
import org.eclipse.debug.ui.DebugUITools;
29
import org.eclipse.debug.ui.DebugUITools;
28
import org.eclipse.debug.ui.IDebugUIConstants;
30
import org.eclipse.debug.ui.IDebugUIConstants;
29
import org.eclipse.jface.dialogs.Dialog;
31
import org.eclipse.jface.dialogs.Dialog;
Lines 42-47 Link Here
42
import org.eclipse.swt.events.KeyListener;
44
import org.eclipse.swt.events.KeyListener;
43
import org.eclipse.swt.events.SelectionAdapter;
45
import org.eclipse.swt.events.SelectionAdapter;
44
import org.eclipse.swt.events.SelectionEvent;
46
import org.eclipse.swt.events.SelectionEvent;
47
import org.eclipse.swt.events.SelectionListener;
45
import org.eclipse.swt.layout.GridData;
48
import org.eclipse.swt.layout.GridData;
46
import org.eclipse.swt.layout.GridLayout;
49
import org.eclipse.swt.layout.GridLayout;
47
import org.eclipse.swt.widgets.Button;
50
import org.eclipse.swt.widgets.Button;
Lines 74-79 Link Here
74
	protected Button fRemoveFavoritesButton;
77
	protected Button fRemoveFavoritesButton;
75
	protected Button fMoveUpButton;
78
	protected Button fMoveUpButton;
76
	protected Button fMoveDownButton;
79
	protected Button fMoveDownButton;
80
	// new button to toggle showing favourites on Toolbar
81
	protected Button fShowOnToolbarButton;
77
82
78
	// button action handler
83
	// button action handler
79
	/**
84
	/**
Lines 302-308 Link Here
302
		fAddFavoriteButton.setEnabled(true);
307
		fAddFavoriteButton.setEnabled(true);
303
		fRemoveFavoritesButton = createPushButton(buttonComp, LaunchConfigurationsMessages.FavoritesDialog_4); 
308
		fRemoveFavoritesButton = createPushButton(buttonComp, LaunchConfigurationsMessages.FavoritesDialog_4); 
304
		fMoveUpButton = createPushButton(buttonComp, LaunchConfigurationsMessages.FavoritesDialog_5); 
309
		fMoveUpButton = createPushButton(buttonComp, LaunchConfigurationsMessages.FavoritesDialog_5); 
305
		fMoveDownButton = createPushButton(buttonComp, LaunchConfigurationsMessages.FavoritesDialog_6);  
310
		fMoveDownButton = createPushButton(buttonComp, LaunchConfigurationsMessages.FavoritesDialog_6);
311
		
312
		//Adding checkbox to display favourites on toolbar
313
		Composite checkBoxComp = new Composite(parent, SWT.NULL);
314
		GridLayout layout2 = new GridLayout();
315
		layout2.marginHeight = 0;
316
		layout2.marginWidth = 0;
317
		layout2.numColumns = 3;
318
		checkBoxComp.setLayout(layout2);
319
		
320
		fShowOnToolbarButton = new Button(checkBoxComp, SWT.CHECK);
321
		createLabel(checkBoxComp, LaunchConfigurationsMessages.FavoritesDialog_Show_on_Toolbar_Text);
322
		boolean selected = DebugUIPlugin.getDefault().getPreferenceStore().getBoolean(IDebugPreferenceConstants.SHOW_FAVOURITES_ON_TOOLBAR);
323
		fShowOnToolbarButton.setSelection(selected);
324
		
306
	}
325
	}
307
	
326
	
308
	/**
327
	/**
Lines 521-526 Link Here
521
	 */
540
	 */
522
	protected void okPressed() {
541
	protected void okPressed() {
523
		saveFavorites();
542
		saveFavorites();
543
		saveAndUpdateToolbar();
524
		super.okPressed();
544
		super.okPressed();
525
	}
545
	}
526
	
546
	
Lines 544-547 Link Here
544
	private String getDialogSettingsSectionName() {
564
	private String getDialogSettingsSectionName() {
545
		return "FAVORITES_DIALOG_SECTION"; //$NON-NLS-1$
565
		return "FAVORITES_DIALOG_SECTION"; //$NON-NLS-1$
546
	}
566
	}
567
	
568
	private void saveAndUpdateToolbar() {
569
		boolean show = fShowOnToolbarButton.getSelection();	
570
		DebugUIPlugin.getDefault().getPreferenceStore().setValue(IDebugPreferenceConstants.SHOW_FAVOURITES_ON_TOOLBAR, show);
571
		DebugUIPlugin.getDefault().savePluginPreferences();
572
		CustomToolbarManager.getInstance().displayToolbarButtons(show);
573
	}
547
}
574
}
(-)ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.properties (+9 lines)
Lines 40-45 Link Here
40
40
41
EnvironmentTab_22=New Environment Variable
41
EnvironmentTab_22=New Environment Variable
42
42
43
LaunchConfigurationDialog__Icon_error_file_does_not_exist = {0} does not exist.
44
LaunchConfigurationDialog__Icon_error_is_not_a_file = {0} is not a file.
45
LaunchConfigurationDialog__Icon_error_invalid_extension = The file {0} has an invalid extension. 
46
LaunchConfigurationDialog__Internal_error_retrieving_input = Internal error retrieving the icon text.
47
LaunchConfigurationDialog__Workspace_selection_dialog_title = Select a resource:
48
49
LaunchConfigurationDialog__Icon_18 = &Icon:
43
LaunchConfigurationDialog__Apply_17=Appl&y
50
LaunchConfigurationDialog__Apply_17=Appl&y
44
LaunchConfigurationDialog__Name__16=&Name:
51
LaunchConfigurationDialog__Name__16=&Name:
45
LaunchConfigurationDialog_An_exception_occurred_while_retrieving_launch_configurations_20=An exception occurred while retrieving launch configurations
52
LaunchConfigurationDialog_An_exception_occurred_while_retrieving_launch_configurations_20=An exception occurred while retrieving launch configurations
Lines 147-154 Link Here
147
FavoritesDialog_7=Select &Launch Configurations:
154
FavoritesDialog_7=Select &Launch Configurations:
148
FavoritesDialog_0=Add {0} Favorites
155
FavoritesDialog_0=Add {0} Favorites
149
FavoritesDialog_8=Updating Favorites...
156
FavoritesDialog_8=Updating Favorites...
157
FavoritesDialog_Show_on_Toolbar_Text=Show Favourites on Toolbar
150
158
151
OrganizeFavoritesAction_0=Organize Fa&vorites...
159
OrganizeFavoritesAction_0=Organize Fa&vorites...
160
152
PerspectiveManager_12=Confirm Perspective Switch
161
PerspectiveManager_12=Confirm Perspective Switch
153
PerspectiveManager_13=This kind of launch is configured to open the {0} perspective when it suspends. Do you want to open this perspective now?
162
PerspectiveManager_13=This kind of launch is configured to open the {0} perspective when it suspends. Do you want to open this perspective now?
154
PerspectiveManager_15=This kind of launch is associated with the {0} perspective. Do you want to open this perspective now?
163
PerspectiveManager_15=This kind of launch is associated with the {0} perspective. Do you want to open this perspective now?
(-)ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationTabGroupViewer.java (-2 / +286 lines)
Lines 11-35 Link Here
11
package org.eclipse.debug.internal.ui.launchConfigurations;
11
package org.eclipse.debug.internal.ui.launchConfigurations;
12
12
13
13
14
import java.io.File;
14
import java.text.MessageFormat;
15
import java.text.MessageFormat;
15
16
17
import org.eclipse.core.resources.IFile;
16
import org.eclipse.core.resources.IResource;
18
import org.eclipse.core.resources.IResource;
17
import org.eclipse.core.resources.ResourcesPlugin;
19
import org.eclipse.core.resources.ResourcesPlugin;
18
import org.eclipse.core.runtime.CoreException;
20
import org.eclipse.core.runtime.CoreException;
19
import org.eclipse.core.runtime.IStatus;
21
import org.eclipse.core.runtime.IStatus;
20
import org.eclipse.core.runtime.Status;
22
import org.eclipse.core.runtime.Status;
23
import org.eclipse.core.variables.VariablesPlugin;
21
import org.eclipse.debug.core.DebugPlugin;
24
import org.eclipse.debug.core.DebugPlugin;
22
import org.eclipse.debug.core.ILaunchConfiguration;
25
import org.eclipse.debug.core.ILaunchConfiguration;
23
import org.eclipse.debug.core.ILaunchConfigurationType;
26
import org.eclipse.debug.core.ILaunchConfigurationType;
24
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
27
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
28
import org.eclipse.debug.core.ILaunchManager;
29
import org.eclipse.debug.internal.core.LaunchConfigurationWorkingCopy;
30
import org.eclipse.debug.internal.ui.CustomImageRegistry;
25
import org.eclipse.debug.internal.ui.DebugUIPlugin;
31
import org.eclipse.debug.internal.ui.DebugUIPlugin;
32
import org.eclipse.debug.internal.ui.DelegatingModelPresentation;
33
import org.eclipse.debug.internal.ui.FileSelectionDialog;
26
import org.eclipse.debug.internal.ui.IInternalDebugUIConstants;
34
import org.eclipse.debug.internal.ui.IInternalDebugUIConstants;
27
import org.eclipse.debug.internal.ui.SWTUtil;
35
import org.eclipse.debug.internal.ui.SWTUtil;
36
import org.eclipse.debug.internal.ui.elements.adapters.LauchManagerContentAdapter;
28
import org.eclipse.debug.internal.ui.preferences.PerspectivePreferencePage;
37
import org.eclipse.debug.internal.ui.preferences.PerspectivePreferencePage;
29
import org.eclipse.debug.ui.DebugUITools;
38
import org.eclipse.debug.ui.DebugUITools;
39
import org.eclipse.debug.ui.IDebugModelPresentation;
30
import org.eclipse.debug.ui.ILaunchConfigurationDialog;
40
import org.eclipse.debug.ui.ILaunchConfigurationDialog;
31
import org.eclipse.debug.ui.ILaunchConfigurationTab;
41
import org.eclipse.debug.ui.ILaunchConfigurationTab;
32
import org.eclipse.debug.ui.ILaunchConfigurationTabGroup;
42
import org.eclipse.debug.ui.ILaunchConfigurationTabGroup;
43
import org.eclipse.debug.ui.StringVariableSelectionDialog;
33
import org.eclipse.jface.dialogs.Dialog;
44
import org.eclipse.jface.dialogs.Dialog;
34
import org.eclipse.jface.dialogs.ErrorDialog;
45
import org.eclipse.jface.dialogs.ErrorDialog;
35
import org.eclipse.jface.viewers.ISelection;
46
import org.eclipse.jface.viewers.ISelection;
Lines 57-62 Link Here
57
import org.eclipse.swt.widgets.Button;
68
import org.eclipse.swt.widgets.Button;
58
import org.eclipse.swt.widgets.Composite;
69
import org.eclipse.swt.widgets.Composite;
59
import org.eclipse.swt.widgets.Control;
70
import org.eclipse.swt.widgets.Control;
71
import org.eclipse.swt.widgets.FileDialog;
72
import org.eclipse.swt.widgets.Group;
60
import org.eclipse.swt.widgets.Label;
73
import org.eclipse.swt.widgets.Label;
61
import org.eclipse.swt.widgets.Link;
74
import org.eclipse.swt.widgets.Link;
62
import org.eclipse.swt.widgets.Shell;
75
import org.eclipse.swt.widgets.Shell;
Lines 69-74 Link Here
69
public class LaunchConfigurationTabGroupViewer extends Viewer {
82
public class LaunchConfigurationTabGroupViewer extends Viewer {
70
	
83
	
71
	/**
84
	/**
85
	 * Valid image extensions that are supported by the Image class.  These are used to
86
	 * validate the custom icons a user can define for any external tool action.
87
	 */  
88
	private final static String IMAGE_EXTENSION_JPG = ".jpg"; //$NON-NLS-1$
89
	private final static String IMAGE_EXTENSION_BMP = ".bmp"; //$NON-NLS-1$
90
	private final static String IMAGE_EXTENSION_ICO = ".ico"; //$NON-NLS-1$
91
	private final static String IMAGE_EXTENSION_TIF = ".tif"; //$NON-NLS-1$
92
	private final static String IMAGE_EXTENSION_PNG = ".png"; //$NON-NLS-1$
93
	private final static String IMAGE_EXTENSION_GIF = ".gif"; //$NON-NLS-1$
94
	
95
	/**
72
	 * Containing launch dialog
96
	 * Containing launch dialog
73
	 */
97
	 */
74
	private ILaunchConfigurationDialog fDialog;
98
	private ILaunchConfigurationDialog fDialog;
Lines 109-114 Link Here
109
	private Text fNameWidget;
133
	private Text fNameWidget;
110
	
134
	
111
	/**
135
	/**
136
	 * Icon label widget
137
	 */
138
	private Label fIconLabel;
139
	
140
	/**
141
	 * Icon text widget
142
	 */
143
	private Text fIconWidget;
144
	
145
	/**
146
	 * Icon browse file system widget
147
	 */
148
	private Button fBrowseFileSystem;
149
	
150
	/**
151
	 * Icon browse workspace widget
152
	 */
153
	private Button fBrowseWorkspace;
154
	
155
	/**
156
	 * Icon variables widget
157
	 */
158
	private Button fVariables;
159
			
160
	/**
112
	 * Composite containing the launch config tab widgets
161
	 * Composite containing the launch config tab widgets
113
	 */
162
	 */
114
	private Composite fTabComposite;
163
	private Composite fTabComposite;
Lines 275-280 Link Here
275
    			}
324
    			}
276
    		);
325
    		);
277
    		
326
    		
327
        //Area to attach custom icon
328
		
329
        Group iconGroup = new Group(fTabComposite, SWT.NONE );
330
        GridData gData = new GridData(GridData.FILL_HORIZONTAL);
331
		gData.horizontalSpan = 2;
332
		iconGroup.setLayoutData(gData);
333
        GridLayout groupLayout = new GridLayout();
334
        groupLayout.numColumns = 1;
335
        iconGroup.setLayout(groupLayout);
336
        iconGroup.setText(LaunchConfigurationsMessages.LaunchConfigurationDialog__Icon_18);
337
338
		fIconWidget = new Text(iconGroup, SWT.SINGLE | SWT.BORDER);
339
		gd = new GridData(GridData.FILL_HORIZONTAL);
340
		fIconWidget.setLayoutData(gd);
341
				
342
		fIconWidget.addModifyListener(
343
				new ModifyListener() {
344
					public void modifyText(ModifyEvent e) {
345
						handleIconModified();
346
					}
347
				}
348
			);
349
        		
350
		Composite buttonComposite = new Composite(iconGroup, SWT.NONE);
351
		GridLayout layout2 = new GridLayout();
352
		layout2.marginHeight = 0;
353
        layout2.marginWidth = 0;   
354
		layout2.numColumns = 3;
355
		GridData gridData = new GridData(GridData.HORIZONTAL_ALIGN_END);
356
		gridData.horizontalSpan = 1;
357
		buttonComposite.setLayout(layout2);
358
		buttonComposite.setLayoutData(gridData);
359
		buttonComposite.setFont(parent.getFont());
360
								
361
		fBrowseWorkspace = new Button(buttonComposite,SWT.PUSH);
362
		fBrowseWorkspace.setText(LaunchConfigurationsMessages.CommonTab_12);
363
		fBrowseWorkspace.addSelectionListener(new SelectionListener() {
364
365
			public void widgetSelected(SelectionEvent e) {
366
				handleWorkspaceLocationButtonSelected();
367
			}
368
			public void widgetDefaultSelected(SelectionEvent e) {
369
			}
370
				
371
			}
372
		);
373
		
374
		fBrowseFileSystem = new Button(buttonComposite,SWT.PUSH);
375
		fBrowseFileSystem.setText(LaunchConfigurationsMessages.CommonTab_7);
376
		fBrowseFileSystem.addSelectionListener(new SelectionListener() {
377
378
			public void widgetSelected(SelectionEvent e) {
379
				handleFileLocationButtonSelected();
380
			}
381
382
			public void widgetDefaultSelected(SelectionEvent e) {
383
			}
384
				
385
			}
386
		);
387
		
388
		fVariables = new Button(buttonComposite,SWT.PUSH);
389
		fVariables.setText(LaunchConfigurationsMessages.CommonTab_9);
390
		
391
		fVariables.addSelectionListener(new SelectionListener() {
392
393
			public void widgetSelected(SelectionEvent e) {
394
				handleVariablesButtonSelected(fIconWidget);
395
			}
396
			public void widgetDefaultSelected(SelectionEvent e) {
397
			}
398
			
399
		});
278
		createTabFolder(fTabComposite);
400
		createTabFolder(fTabComposite);
279
		
401
		
280
		Composite buttonComp = new Composite(mainComp, SWT.NONE);
402
		Composite buttonComp = new Composite(mainComp, SWT.NONE);
Lines 421-426 Link Here
421
	protected CTabFolder getTabFolder() {
543
	protected CTabFolder getTabFolder() {
422
		return fTabFolder;
544
		return fTabFolder;
423
	}
545
	}
546
	/**
547
	 * Returns the icon widget 
548
	 */
549
	private Text getIconWidget() {
550
		return fIconWidget;
551
	}
424
	
552
	
425
	/**
553
	/**
426
	 * Sets the current name
554
	 * Sets the current name
Lines 626-632 Link Here
626
		updateVisibleControls(true);
754
		updateVisibleControls(true);
627
		// Update the name field before to avoid verify error
755
		// Update the name field before to avoid verify error
628
		fNameWidget.setText(getWorkingCopy().getName());
756
		fNameWidget.setText(getWorkingCopy().getName());
629
757
		
758
		// set the icon text
759
		try {
760
			getIconWidget().setText(getWorkingCopy().getAttribute(ILaunchManager.ATTR_LAUNCH_ICON_PATH, ""));
761
		} catch (CoreException e1) {
762
		}
763
		
630
		// Retrieve the current tab group.  If there is none, clean up and leave
764
		// Retrieve the current tab group.  If there is none, clean up and leave
631
		ILaunchConfigurationTabGroup tabGroup = getTabGroup();
765
		ILaunchConfigurationTabGroup tabGroup = getTabGroup();
632
		if (tabGroup == null) {
766
		if (tabGroup == null) {
Lines 933-938 Link Here
933
		// First make sure that name doesn't prevent saving the config
1067
		// First make sure that name doesn't prevent saving the config
934
		try {
1068
		try {
935
			verifyName();
1069
			verifyName();
1070
			//verify the Icon choice as well
1071
			verifyIconText();
936
		} catch (CoreException ce) {
1072
		} catch (CoreException ce) {
937
			return false;
1073
			return false;
938
		}
1074
		}
Lines 962-967 Link Here
962
		}
1098
		}
963
		try {
1099
		try {
964
			verifyName();
1100
			verifyName();
1101
			//Don't let a launch config start without a valid icon file
1102
			verifyIconText();
965
		} catch (CoreException e) {
1103
		} catch (CoreException e) {
966
			return false;
1104
			return false;
967
		}
1105
		}
Lines 991-996 Link Here
991
		}
1129
		}
992
		try {
1130
		try {
993
			verifyName();
1131
			verifyName();
1132
			//verify icon text here as well
1133
			verifyIconText();
994
		} catch (CoreException ce) {
1134
		} catch (CoreException ce) {
995
			return ce.getStatus().getMessage();
1135
			return ce.getStatus().getMessage();
996
		}
1136
		}
Lines 1173-1178 Link Here
1173
	}		
1313
	}		
1174
	
1314
	
1175
	/**
1315
	/**
1316
	 * Notification that the icon field has been modified
1317
	 *
1318
	 */
1319
	protected void handleIconModified() {
1320
		//need to update the launch configuration with the new image
1321
		ILaunchConfigurationWorkingCopy workingCopy = getWorkingCopy();
1322
		if (workingCopy instanceof LaunchConfigurationWorkingCopy) {
1323
			if (getIconWidget() != null && !getIconWidget().isDisposed()) {
1324
				((LaunchConfigurationWorkingCopy)workingCopy).changeIconPath(getIconWidget().getText().trim());
1325
			}
1326
		}
1327
		refreshStatus();
1328
		
1329
	}
1330
	
1331
	/**
1176
	 * Notification that the 'Apply' button has been pressed
1332
	 * Notification that the 'Apply' button has been pressed
1177
	 */
1333
	 */
1178
	protected void handleApplyPressed() {
1334
	protected void handleApplyPressed() {
Lines 1188-1198 Link Here
1188
				widget.setText(trimmed);
1344
				widget.setText(trimmed);
1189
			}
1345
			}
1190
			getWorkingCopy().rename(trimmed);
1346
			getWorkingCopy().rename(trimmed);
1347
			if (getWorkingCopy() instanceof LaunchConfigurationWorkingCopy) {
1348
				if (getIconWidget() != null && !getIconWidget().isDisposed()) {
1349
					((LaunchConfigurationWorkingCopy)getWorkingCopy()).
1350
						changeIconPath(getIconWidget().getText().trim());
1351
				}
1352
			}
1353
			
1191
			getTabGroup().performApply(getWorkingCopy());
1354
			getTabGroup().performApply(getWorkingCopy());
1192
			fInitializingTabs = false;
1355
			fInitializingTabs = false;
1193
1356
1194
			if (isDirty()) {
1357
			if (isDirty()) {
1195
				getWorkingCopy().doSave();
1358
				getWorkingCopy().doSave();
1359
				//update the custom image registry for this configuration
1360
				CustomImageRegistry.getInstance().updateCache(getWorkingCopy().getOriginal());
1196
			}
1361
			}
1197
			updateButtons();
1362
			updateButtons();
1198
		} catch (CoreException e) {
1363
		} catch (CoreException e) {
Lines 1256-1260 Link Here
1256
			handleTabSelected();
1421
			handleTabSelected();
1257
		}
1422
		}
1258
	}
1423
	}
1259
1424
	
1425
	/**
1426
	 * Prompts the user to choose a location from the filesystem and
1427
	 * sets the location as the full path of the selected file.
1428
	 */
1429
	protected void handleFileLocationButtonSelected() {
1430
		FileDialog fileDialog = new FileDialog(getShell(), SWT.NONE);
1431
		fileDialog.setFileName(getIconWidget().getText());
1432
		fileDialog.setFilterExtensions(new String[] {"*"+ IMAGE_EXTENSION_JPG +
1433
													 ";*"+ IMAGE_EXTENSION_BMP +
1434
													 ";*"+ IMAGE_EXTENSION_GIF +
1435
													 ";*"+ IMAGE_EXTENSION_ICO +
1436
													 ";*"+ IMAGE_EXTENSION_PNG +
1437
													 ";*"+ IMAGE_EXTENSION_TIF
1438
													 ,"*.*"});
1439
													 
1440
		String text= fileDialog.open();
1441
		if (text != null) {
1442
			getIconWidget().setText(text);
1443
		}
1444
	}
1445
	
1446
	/**
1447
	 * Prompts the user for a workspace location within the workspace and sets
1448
	 * the location as a String containing the workspace_loc variable or
1449
	 * <code>null</code> if no location was obtained from the user.
1450
	 */
1451
	protected void handleWorkspaceLocationButtonSelected() {
1452
		
1453
		FileSelectionDialog dialog;
1454
		dialog = new FileSelectionDialog(getShell(), ResourcesPlugin.getWorkspace().getRoot(), LaunchConfigurationsMessages.LaunchConfigurationDialog__Workspace_selection_dialog_title);//ExternalToolsLaunchConfigurationMessages.ExternalToolsMainTab_Select_a_resource_22);
1455
		dialog.open();
1456
		IStructuredSelection result = dialog.getResult();
1457
		if (result == null) {
1458
			return;
1459
		}
1460
		Object file= result.getFirstElement();
1461
		if (file instanceof IFile) {
1462
			getIconWidget().setText(VariablesPlugin.getDefault().
1463
					getStringVariableManager().generateVariableExpression("workspace_loc", ((IFile)file).getFullPath().toString())); //$NON-NLS-1$
1464
		}
1465
	}
1466
	
1467
	/**
1468
	 * A variable entry button has been pressed for the given text
1469
	 * field. Prompt the user for a variable and enter the result
1470
	 * in the given field.
1471
	 */
1472
	private void handleVariablesButtonSelected(Text textField) {
1473
		
1474
		StringVariableSelectionDialog dialog = new StringVariableSelectionDialog(getShell());
1475
		dialog.open();
1476
		String variable = dialog.getVariableExpression();
1477
					
1478
		if (variable != null) {
1479
			textField.insert(variable);
1480
		}
1481
	}
1482
	/**
1483
	 * Verifies that the text entered in the Icon text field is valid.
1484
	 * 
1485
	 * @throws CoreException
1486
	 */
1487
	private void verifyIconText() throws CoreException {
1488
		
1489
		String enteredPath = null;
1490
		
1491
		if (getIconWidget() != null && !getIconWidget().isDisposed()) {
1492
			enteredPath = getIconWidget().getText().trim();
1493
		}
1494
		else {
1495
			//This should not occur, just a redundancy check 
1496
			throw new CoreException(new Status(IStatus.ERROR,
1497
					 DebugUIPlugin.getUniqueIdentifier(),
1498
					 0,
1499
					 MessageFormat.format(LaunchConfigurationsMessages.LaunchConfigurationDialog__Internal_error_retrieving_input,
1500
						 	   null),
1501
					 null));
1502
		}
1503
		
1504
		try {
1505
			String subbedString = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(enteredPath);
1506
			VariablesPlugin.getDefault().getStringVariableManager().validateStringVariables(enteredPath);
1507
			//if the variable can be substituted, don't validate.  It might become valid later.
1508
			if (!subbedString.equals(enteredPath))
1509
				return;
1510
		}
1511
		catch (CoreException e) {
1512
			VariablesPlugin.getDefault().getStringVariableManager().validateStringVariables(enteredPath);
1513
			return;
1514
		}
1515
	
1516
		File file = new File(VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(enteredPath));
1517
		
1518
		//if a dynamic variable is used, don't validate, since it could be valid later
1519
		//except if it is the workspace dynamic variable...
1520
		
1521
		//don't verify if nothing is entered
1522
		if (getIconWidget().getText().length() > 0) {
1523
		
1524
			if (!file.exists()) { // The file does not exist.
1525
				throw new CoreException(new Status(IStatus.ERROR,
1526
						 DebugUIPlugin.getUniqueIdentifier(),
1527
						 0,
1528
						 MessageFormat.format(LaunchConfigurationsMessages.LaunchConfigurationDialog__Icon_error_file_does_not_exist,
1529
								 new String[] {file.toString()}),
1530
						 null));
1531
			}
1532
			if (!file.isFile()) {
1533
				throw new CoreException(new Status(IStatus.ERROR,
1534
						 DebugUIPlugin.getUniqueIdentifier(),
1535
						 0,
1536
						 MessageFormat.format(LaunchConfigurationsMessages.LaunchConfigurationDialog__Icon_error_is_not_a_file,
1537
							 	   new String[] {file.toString()}),
1538
 
1539
						 null));
1540
			}
1541
	
1542
		}
1543
	}
1260
}
1544
}
(-)ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.java (-1 / +10 lines)
Lines 44-49 Link Here
44
44
45
	public static String EnvironmentTab_22;
45
	public static String EnvironmentTab_22;
46
46
47
	//Messages for custom icons
48
	public static String LaunchConfigurationDialog__Icon_18;
49
	public static String LaunchConfigurationDialog__Icon_error_file_does_not_exist;
50
	public static String LaunchConfigurationDialog__Icon_error_invalid_extension;
51
	public static String LaunchConfigurationDialog__Icon_error_is_not_a_file;
52
	public static String LaunchConfigurationDialog__Internal_error_retrieving_input;
53
	public static String LaunchConfigurationDialog__Workspace_selection_dialog_title;
54
	
47
	public static String LaunchConfigurationDialog__Apply_17;
55
	public static String LaunchConfigurationDialog__Apply_17;
48
	public static String LaunchConfigurationDialog__Name__16;
56
	public static String LaunchConfigurationDialog__Name__16;
49
	public static String LaunchConfigurationDialog_An_exception_occurred_while_retrieving_launch_configurations_20;
57
	public static String LaunchConfigurationDialog_An_exception_occurred_while_retrieving_launch_configurations_20;
Lines 132-138 Link Here
132
	public static String FavoritesDialog_6;
140
	public static String FavoritesDialog_6;
133
	public static String FavoritesDialog_7;
141
	public static String FavoritesDialog_7;
134
	public static String FavoritesDialog_0;
142
	public static String FavoritesDialog_0;
135
143
	public static String FavoritesDialog_Show_on_Toolbar_Text;
144
	
136
	public static String OrganizeFavoritesAction_0;
145
	public static String OrganizeFavoritesAction_0;
137
	public static String PerspectiveManager_12;
146
	public static String PerspectiveManager_12;
138
	public static String PerspectiveManager_13;
147
	public static String PerspectiveManager_13;
(-)ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchHistory.java (+4 lines)
Lines 327-332 Link Here
327
		if (movedFrom == null) {
327
		if (movedFrom == null) {
328
			checkIfFavorite(configuration);
328
			checkIfFavorite(configuration);
329
		} else {
329
		} else {
330
			//This is a bug.  If a user currently renames a configuration, and adds to favourites at the same
331
			//time, the newly named launch configuration will not be added to the favourites list.
332
			//We should check favourites even whening renaming or moving.
333
330
			String movedFromName= movedFrom.getName();
334
			String movedFromName= movedFrom.getName();
331
			ILaunchConfiguration[] history = getHistory();
335
			ILaunchConfiguration[] history = getHistory();
332
			for (int i = 0; i < history.length; i++) {
336
			for (int i = 0; i < history.length; i++) {
(-)ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationView.java (-2 / +7 lines)
Lines 311-322 Link Here
311
        TreeViewer viewer = getTreeViewer();
311
        TreeViewer viewer = getTreeViewer();
312
        if (viewer != null) {
312
        if (viewer != null) {
313
			try {
313
			try {
314
                viewer.add(configuration.getType(), configuration);
314
				/* Check and remove the item from the tree FIRST, then add it.
315
                // if moved, remove original now
315
				 * Do this so that a Launch Configuration which has had it's icon changed can also be treated
316
				 * in the same manner as one that was renamed
317
				 */
318
				// if moved, remove original now
316
                ILaunchConfiguration from = getLaunchManager().getMovedFrom(configuration);
319
                ILaunchConfiguration from = getLaunchManager().getMovedFrom(configuration);
317
                if (from != null) {
320
                if (from != null) {
318
                    viewer.remove(from);
321
                    viewer.remove(from);
319
                }
322
                }
323
				viewer.add(configuration.getType(), configuration);
324
320
                if (isAutoSelect()) {
325
                if (isAutoSelect()) {
321
    				viewer.setSelection(new StructuredSelection(configuration), true);
326
    				viewer.setSelection(new StructuredSelection(configuration), true);
322
    			}
327
    			}
(-)ui/org/eclipse/debug/internal/ui/preferences/LaunchConfigurationsPreferencePage.java (-1 / +1 lines)
Lines 90-96 Link Here
90
	/**
90
	/**
91
	 * describes the external tools launch group
91
	 * describes the external tools launch group
92
	 */
92
	 */
93
	private static final String EXT_BUILDER_GROUP = "org.eclipse.ui.externaltools.launchGroup"; //$NON-NLS-1$
93
	public static final String EXT_BUILDER_GROUP = "org.eclipse.ui.externaltools.launchGroup"; //$NON-NLS-1$
94
	
94
	
95
	/**
95
	/**
96
	 * to monitor the proress of the migration process
96
	 * to monitor the proress of the migration process
(-)ui/org/eclipse/debug/internal/ui/preferences/IDebugPreferenceConstants.java (+6 lines)
Lines 245-250 Link Here
245
	 * @since 3.2
245
	 * @since 3.2
246
	 */
246
	 */
247
	public static final String PREF_COL_SIZE_BY_MODEL = "org.eclipse.debug.ui.AbstractTableRendering.colSize"; //$NON-NLS-1$
247
	public static final String PREF_COL_SIZE_BY_MODEL = "org.eclipse.debug.ui.AbstractTableRendering.colSize"; //$NON-NLS-1$
248
249
	/**
250
	 * The boolean setting of whether to show the launch configuration favourites on the Toolbar
251
	 */
252
	public static final String SHOW_FAVOURITES_ON_TOOLBAR = "org.eclipse.debug.ui.custom.toolbar.display.onToolbar"; //$NON-NLS-1$
253
	
248
}
254
}
249
255
250
256
(-)ui/org/eclipse/debug/ui/actions/LaunchAction.java (-1 / +12 lines)
Lines 11-21 Link Here
11
package org.eclipse.debug.ui.actions;
11
package org.eclipse.debug.ui.actions;
12
12
13
13
14
import org.eclipse.core.runtime.CoreException;
15
import org.eclipse.core.variables.VariablesPlugin;
14
import org.eclipse.debug.core.ILaunchConfiguration;
16
import org.eclipse.debug.core.ILaunchConfiguration;
17
import org.eclipse.debug.core.ILaunchManager;
18
import org.eclipse.debug.internal.ui.CustomImageRegistry;
19
import org.eclipse.debug.internal.ui.DebugPluginImages;
15
import org.eclipse.debug.internal.ui.DebugUIPlugin;
20
import org.eclipse.debug.internal.ui.DebugUIPlugin;
16
import org.eclipse.debug.internal.ui.IDebugHelpContextIds;
21
import org.eclipse.debug.internal.ui.IDebugHelpContextIds;
17
import org.eclipse.debug.ui.DebugUITools;
22
import org.eclipse.debug.ui.DebugUITools;
23
import org.eclipse.debug.ui.IDebugModelPresentation;
18
import org.eclipse.jface.action.Action;
24
import org.eclipse.jface.action.Action;
25
import org.eclipse.jface.resource.ImageDescriptor;
19
import org.eclipse.jface.viewers.IStructuredSelection;
26
import org.eclipse.jface.viewers.IStructuredSelection;
20
import org.eclipse.jface.viewers.StructuredSelection;
27
import org.eclipse.jface.viewers.StructuredSelection;
21
import org.eclipse.swt.SWT;
28
import org.eclipse.swt.SWT;
Lines 53-59 Link Here
53
		fConfiguration = configuration;
60
		fConfiguration = configuration;
54
		fMode = mode;
61
		fMode = mode;
55
		setText(configuration.getName());
62
		setText(configuration.getName());
56
		setImageDescriptor(DebugUITools.getDefaultImageDescriptor(configuration));
63
		//Attempt to set the image from the LaunchConfiguration first
64
				
65
		ImageDescriptor imageDesc = CustomImageRegistry.getInstance().getImageDescriptor(configuration);
66
		setImageDescriptor(imageDesc);
67
				
57
		PlatformUI.getWorkbench().getHelpSystem().setHelp(
68
		PlatformUI.getWorkbench().getHelpSystem().setHelp(
58
			this,
69
			this,
59
			IDebugHelpContextIds.RELAUNCH_HISTORY_ACTION);
70
			IDebugHelpContextIds.RELAUNCH_HISTORY_ACTION);
(-)ui/org/eclipse/debug/ui/actions/AbstractLaunchToolbarAction.java (+4 lines)
Lines 13-18 Link Here
13
13
14
import org.eclipse.debug.core.ILaunchConfiguration;
14
import org.eclipse.debug.core.ILaunchConfiguration;
15
import org.eclipse.debug.internal.ui.DebugUIPlugin;
15
import org.eclipse.debug.internal.ui.DebugUIPlugin;
16
import org.eclipse.debug.internal.ui.ShowOnToolbarAction;
17
import org.eclipse.debug.internal.ui.actions.AddToFavoritesAction;
16
import org.eclipse.debug.internal.ui.launchConfigurations.OrganizeFavoritesAction;
18
import org.eclipse.debug.internal.ui.launchConfigurations.OrganizeFavoritesAction;
17
import org.eclipse.debug.ui.DebugUITools;
19
import org.eclipse.debug.ui.DebugUITools;
18
import org.eclipse.jface.action.IAction;
20
import org.eclipse.jface.action.IAction;
Lines 58-63 Link Here
58
		addToMenu(menu, new LaunchShortcutsAction(getLaunchGroupIdentifier()), -1);
60
		addToMenu(menu, new LaunchShortcutsAction(getLaunchGroupIdentifier()), -1);
59
		addToMenu(menu, getOpenDialogAction(), -1);
61
		addToMenu(menu, getOpenDialogAction(), -1);
60
		addToMenu(menu, new OrganizeFavoritesAction(getLaunchGroupIdentifier()), -1);
62
		addToMenu(menu, new OrganizeFavoritesAction(getLaunchGroupIdentifier()), -1);
63
		//add new action to show on toolbar
64
		addToMenu(menu, new ShowOnToolbarAction(),-1);
61
	}
65
	}
62
	
66
	
63
	/**
67
	/**
(-)ui/org/eclipse/debug/internal/ui/TreeAndListGroup.java (+316 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2005 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.debug.internal.ui;
12
13
14
import java.util.ArrayList;
15
import java.util.Iterator;
16
import java.util.List;
17
18
import org.eclipse.jface.viewers.DoubleClickEvent;
19
import org.eclipse.jface.viewers.IDoubleClickListener;
20
import org.eclipse.jface.viewers.ILabelProvider;
21
import org.eclipse.jface.viewers.ISelection;
22
import org.eclipse.jface.viewers.ISelectionChangedListener;
23
import org.eclipse.jface.viewers.IStructuredContentProvider;
24
import org.eclipse.jface.viewers.IStructuredSelection;
25
import org.eclipse.jface.viewers.ITreeContentProvider;
26
import org.eclipse.jface.viewers.SelectionChangedEvent;
27
import org.eclipse.jface.viewers.StructuredSelection;
28
import org.eclipse.jface.viewers.TableViewer;
29
import org.eclipse.jface.viewers.TreeViewer;
30
import org.eclipse.jface.viewers.ViewerSorter;
31
import org.eclipse.swt.SWT;
32
import org.eclipse.swt.layout.GridData;
33
import org.eclipse.swt.layout.GridLayout;
34
import org.eclipse.swt.widgets.Composite;
35
import org.eclipse.swt.widgets.Table;
36
import org.eclipse.swt.widgets.Tree;
37
import org.eclipse.ui.views.navigator.ResourceSorter;
38
39
/**
40
 * This class was derived from org.eclipse.ui.internal.misc.CheckboxTreeAndListGroup
41
 *
42
 */
43
public class TreeAndListGroup implements ISelectionChangedListener {
44
	private Object root;
45
	private Object currentTreeSelection;
46
	private List selectionChangedListeners = new ArrayList();
47
	private List doubleClickListeners= new ArrayList();
48
49
	private ITreeContentProvider treeContentProvider;
50
	private IStructuredContentProvider listContentProvider;
51
	private ILabelProvider treeLabelProvider;
52
	private ILabelProvider listLabelProvider;
53
54
	// widgets
55
	private TreeViewer treeViewer;
56
	private TableViewer listViewer;
57
	private boolean allowMultiselection= false;
58
59
	/**
60
	 *	Create an instance of this class.  Use this constructor if you wish to specify
61
	 *	the width and/or height of the combined widget (to only hardcode one of the
62
	 *	sizing dimensions, specify the other dimension's value as -1)
63
	 *
64
	 *	@param parent org.eclipse.swt.widgets.Composite
65
	 *	@param style int
66
	 *  @param rootObject java.lang.Object
67
	 *	@param width int
68
	 *	@param height int
69
	 *  @param allowMultiselection Whether to allow multi-selection in the list viewer.
70
	 */
71
	public TreeAndListGroup(Composite parent, Object rootObject, ITreeContentProvider treeContentProvider, ILabelProvider treeLabelProvider, IStructuredContentProvider listContentProvider, ILabelProvider listLabelProvider, int style, int width, int height, boolean allowMultiselection) {
72
73
		root = rootObject;
74
		this.treeContentProvider = treeContentProvider;
75
		this.listContentProvider = listContentProvider;
76
		this.treeLabelProvider = treeLabelProvider;
77
		this.listLabelProvider = listLabelProvider;
78
		this.allowMultiselection= allowMultiselection;
79
		createContents(parent, width, height, style);
80
	}
81
	/**
82
	 * This method must be called just before this window becomes visible.
83
	 */
84
	public void aboutToOpen() {
85
		currentTreeSelection = null;
86
87
		//select the first element in the list
88
		Object[] elements = treeContentProvider.getElements(root);
89
		Object primary = elements.length > 0 ? elements[0] : null;
90
		if (primary != null) {
91
			treeViewer.setSelection(new StructuredSelection(primary));
92
		}
93
		treeViewer.getControl().setFocus();
94
	}
95
	/**
96
	 *	Add the passed listener to collection of clients
97
	 *	that listen for changes to list viewer selection state
98
	 *
99
	 *	@param listener ISelectionChangedListener
100
	 */
101
	public void addSelectionChangedListener(ISelectionChangedListener listener) {
102
		selectionChangedListeners.add(listener);
103
	}
104
	
105
	/**
106
	 * Add the given listener to the collection of clients that listen to
107
	 * double-click events in the list viewer
108
	 * 
109
	 * @param listener IDoubleClickListener
110
	 */
111
	public void addDoubleClickListener(IDoubleClickListener listener) {
112
		doubleClickListeners.add(listener);
113
	}
114
115
	/**
116
	 * Notify all selection listeners that a selection has occurred in the list
117
	 * viewer
118
	 */
119
	protected void notifySelectionListeners(SelectionChangedEvent event) {
120
		Iterator iter = selectionChangedListeners.iterator();
121
		while (iter.hasNext()) {
122
			 ((ISelectionChangedListener) iter.next()).selectionChanged(event);
123
		}
124
	}
125
	
126
	/**
127
	 * Notify all double click listeners that a double click event has occurred
128
	 * in the list viewer
129
	 */
130
	protected void notifyDoubleClickListeners(DoubleClickEvent event) {
131
		Iterator iter= doubleClickListeners.iterator();
132
		while (iter.hasNext()) {
133
			((IDoubleClickListener) iter.next()).doubleClick(event);
134
		}
135
	}
136
137
	/**
138
	 *	Lay out and initialize self's visual components.
139
	 *
140
	 *	@param parent org.eclipse.swt.widgets.Composite
141
	 *	@param width int
142
	 *	@param height int
143
	 */
144
	protected void createContents(Composite parent, int width, int height, int style) {
145
		// group pane
146
		Composite composite = new Composite(parent, style);
147
		composite.setFont(parent.getFont());
148
		GridLayout layout = new GridLayout();
149
		layout.numColumns = 2;
150
		layout.makeColumnsEqualWidth = true;
151
		layout.marginHeight = 0;
152
		layout.marginWidth = 0;
153
		composite.setLayout(layout);
154
		composite.setLayoutData(new GridData(GridData.FILL_BOTH));
155
156
		createTreeViewer(composite, width / 2, height);
157
		createListViewer(composite, width / 2, height);
158
159
		initialize();
160
	}
161
	/**
162
	 *	Create this group's list viewer.
163
	 */
164
	protected void createListViewer(Composite parent, int width, int height) {
165
		int style;
166
		if (allowMultiselection) {
167
			style= SWT.MULTI;
168
		} else {
169
			style= SWT.SINGLE;
170
		}
171
		listViewer = new TableViewer(parent, SWT.BORDER | style);
172
		GridData data = new GridData(GridData.FILL_BOTH);
173
		data.widthHint = width;
174
		data.heightHint = height;
175
		listViewer.getTable().setLayoutData(data);
176
		listViewer.getTable().setFont(parent.getFont());
177
		listViewer.setContentProvider(listContentProvider);
178
		listViewer.setLabelProvider(listLabelProvider);
179
		listViewer.setSorter(new ResourceSorter(ResourceSorter.NAME));
180
		listViewer.addSelectionChangedListener(new ISelectionChangedListener() {
181
			public void selectionChanged(SelectionChangedEvent event) {
182
				notifySelectionListeners(event);
183
			}
184
		});
185
		listViewer.addDoubleClickListener(new IDoubleClickListener() {
186
			public void doubleClick(DoubleClickEvent event) {
187
				if (!event.getSelection().isEmpty()) {
188
					notifyDoubleClickListeners(event);
189
				}
190
			}
191
		});
192
	}
193
	/**
194
	 *	Create this group's tree viewer.
195
	 */
196
	protected void createTreeViewer(Composite parent, int width, int height) {
197
		Tree tree = new Tree(parent, SWT.BORDER);
198
		GridData data = new GridData(GridData.FILL_BOTH);
199
		data.widthHint = width;
200
		data.heightHint = height;
201
		tree.setLayoutData(data);
202
		tree.setFont(parent.getFont());
203
204
		treeViewer = new TreeViewer(tree);
205
		treeViewer.setContentProvider(treeContentProvider);
206
		treeViewer.setLabelProvider(treeLabelProvider);
207
		treeViewer.setSorter(new ResourceSorter(ResourceSorter.NAME));
208
		treeViewer.addSelectionChangedListener(this);
209
	}
210
	
211
	public Table getListTable() {
212
		return listViewer.getTable();
213
	}
214
	
215
	public IStructuredSelection getListTableSelection() {
216
		ISelection selection=  this.listViewer.getSelection();
217
		if (selection instanceof IStructuredSelection) {
218
			return (IStructuredSelection)selection;
219
		} 
220
		return StructuredSelection.EMPTY;
221
	}
222
	
223
	protected void initialListItem(Object element) {
224
		Object parent = treeContentProvider.getParent(element);
225
		selectAndRevealFolder(parent);
226
	}
227
	
228
	public void selectAndRevealFolder(Object treeElement) {
229
		treeViewer.reveal(treeElement);
230
		IStructuredSelection selection = new StructuredSelection(treeElement);
231
		treeViewer.setSelection(selection);
232
	}
233
	
234
	public void selectAndRevealFile(Object treeElement) {
235
		listViewer.reveal(treeElement);
236
		IStructuredSelection selection = new StructuredSelection(treeElement);
237
		listViewer.setSelection(selection);
238
	}
239
240
	/**
241
	 *	Initialize this group's viewers after they have been laid out.
242
	 */
243
	protected void initialize() {
244
		treeViewer.setInput(root);
245
	}
246
247
	/* (non-Javadoc)
248
	 * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)
249
	 */
250
	public void selectionChanged(SelectionChangedEvent event) {
251
		IStructuredSelection selection = (IStructuredSelection) event.getSelection();
252
		Object selectedElement = selection.getFirstElement();
253
		if (selectedElement == null) {
254
			currentTreeSelection = null;
255
			listViewer.setInput(currentTreeSelection);
256
			return;
257
		}
258
259
		// ie.- if not an item deselection
260
		if (selectedElement != currentTreeSelection) {
261
			listViewer.setInput(selectedElement);
262
		}
263
264
		currentTreeSelection = selectedElement;
265
	}
266
	/**
267
	 *	Set the list viewer's providers to those passed
268
	 *
269
	 *	@param contentProvider ITreeContentProvider
270
	 *	@param labelProvider ILabelProvider
271
	 */
272
	public void setListProviders(IStructuredContentProvider contentProvider, ILabelProvider labelProvider) {
273
		listViewer.setContentProvider(contentProvider);
274
		listViewer.setLabelProvider(labelProvider);
275
	}
276
	/**
277
	 *	Set the sorter that is to be applied to self's list viewer
278
	 */
279
	public void setListSorter(ViewerSorter sorter) {
280
		listViewer.setSorter(sorter);
281
	}
282
	/**
283
	 * Set the root of the widget to be new Root. Regenerate all of the tables and lists from this
284
	 * value.
285
	 * @param newRoot
286
	 */
287
	public void setRoot(Object newRoot) {
288
		this.root = newRoot;
289
		initialize();
290
	}
291
292
	/**
293
	 *	Set the tree viewer's providers to those passed
294
	 *
295
	 *	@param contentProvider ITreeContentProvider
296
	 *	@param labelProvider ILabelProvider
297
	 */
298
	public void setTreeProviders(ITreeContentProvider contentProvider, ILabelProvider labelProvider) {
299
		treeViewer.setContentProvider(contentProvider);
300
		treeViewer.setLabelProvider(labelProvider);
301
	}
302
	/**
303
	 *	Set the sorter that is to be applied to self's tree viewer
304
	 */
305
	public void setTreeSorter(ViewerSorter sorter) {
306
		treeViewer.setSorter(sorter);
307
	}
308
309
	/**
310
	 * Set the focus on to the list widget.
311
	 */
312
	public void setFocus() {
313
314
		this.treeViewer.getTree().setFocus();
315
	}
316
}
(-)ui/org/eclipse/debug/internal/ui/CustomImageRegistry.java (+92 lines)
Added Link Here
1
package org.eclipse.debug.internal.ui;
2
3
import java.util.HashMap;
4
5
import org.eclipse.core.runtime.CoreException;
6
import org.eclipse.core.variables.VariablesPlugin;
7
import org.eclipse.debug.core.ILaunchConfiguration;
8
import org.eclipse.debug.core.ILaunchManager;
9
import org.eclipse.jface.resource.ImageDescriptor;
10
11
/**
12
 * @author tmak
13
 * This class caches the image descriptors of any custom icons used.  Whenever a custom icon
14
 * needs to be retrieved, this class should be consulted first.
15
 */
16
public class CustomImageRegistry {
17
18
	private static CustomImageRegistry registry;
19
	
20
	private HashMap customImageDescriptors = new HashMap();
21
	
22
	public static CustomImageRegistry getInstance() {
23
		
24
		if (registry == null) {
25
			registry = new CustomImageRegistry();
26
		}
27
		
28
		return registry;
29
	}
30
	/**
31
	 * Retrieve the appropriate icon for a specific launch configuration.
32
	 * 
33
	 * @param the config you want the image descriptor for.
34
	 * @return the image descriptor for this configuration
35
	 */
36
	public ImageDescriptor getImageDescriptor(ILaunchConfiguration config) {
37
		
38
		ImageDescriptor imageDesc;
39
		
40
		try {
41
			//if the configuration has no icon attribute set, return default descriptor
42
			if (config.getAttribute(ILaunchManager.ATTR_LAUNCH_ICON_PATH, "").equals("")) {
43
				return DebugPluginImages.getImageDescriptor(config.getType().getIdentifier()); 
44
			}
45
		} catch (CoreException e) {
46
			DebugUIPlugin.log(e);
47
		}
48
		
49
		imageDesc = (ImageDescriptor)customImageDescriptors.get(config.getName());
50
		//first time accessing the registry, update the cache, then retrieve it again
51
		if (imageDesc == null) {
52
			updateCache(config);
53
			imageDesc = (ImageDescriptor)customImageDescriptors.get(config.getName());
54
		}
55
		
56
		return imageDesc;
57
		
58
	}
59
	/**
60
	 *  update the stored imagedescriptor for this specific launch configuration.
61
	 *  Typically this is called if you know for certain that a launch configuration
62
	 *  has had it's icon field updated.
63
	 *  
64
	 * @param config
65
	 */
66
	public void updateCache (ILaunchConfiguration config) {
67
		ImageDescriptor imageDesc = createLaunchConfigImageDescriptor(config);
68
		customImageDescriptors.put(config.getName(), imageDesc);
69
	}
70
	
71
	/**
72
	 * Needs to be called when a launch configuration is removed from the external tools dialog
73
	 * @param config
74
	 */
75
	public void removeImageDescriptor(ILaunchConfiguration config) {
76
		customImageDescriptors.remove(config.getName());
77
	}
78
	
79
	private ImageDescriptor createLaunchConfigImageDescriptor(ILaunchConfiguration config) {
80
		String subbedString;
81
		ImageDescriptor id = null;
82
		try {
83
			subbedString = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(
84
					config.getAttribute(ILaunchManager.ATTR_LAUNCH_ICON_PATH, ""));
85
			id = ImageDescriptor.createFromFile(null, subbedString);
86
		} catch (CoreException e) {
87
			id = ImageDescriptor.getMissingImageDescriptor();
88
		}
89
			
90
		return id;
91
	}
92
}
(-)ui/org/eclipse/debug/internal/ui/ShowOnToolbarAction.java (+28 lines)
Added Link Here
1
package org.eclipse.debug.internal.ui;
2
3
import org.eclipse.debug.internal.ui.preferences.IDebugPreferenceConstants;
4
import org.eclipse.jface.action.Action;
5
6
/**
7
 * @author tmak
8
 * This action handles toggling the custom toolbar on and off.  It will appaer in the 
9
 * External Tools drop down menu.
10
 */
11
public class ShowOnToolbarAction extends Action{
12
13
	private boolean checked;	
14
	
15
	public ShowOnToolbarAction() {
16
		super(DebugUIMessages.ShowFavouritesOnToolbarAction_1); 
17
		//get checked state from preference store
18
		checked = DebugUIPlugin.getDefault().getPreferenceStore().getBoolean(IDebugPreferenceConstants.SHOW_FAVOURITES_ON_TOOLBAR);
19
		setChecked(checked);
20
	}
21
22
	public void run() {
23
		DebugUIPlugin.getDefault().getPreferenceStore().setValue(IDebugPreferenceConstants.SHOW_FAVOURITES_ON_TOOLBAR,!checked);
24
		DebugUIPlugin.getDefault().savePluginPreferences();
25
		CustomToolbarManager.getInstance().displayToolbarButtons(!checked);
26
	}
27
	
28
}
(-)ui/org/eclipse/debug/internal/ui/CustomToolbarManager.java (+235 lines)
Added Link Here
1
package org.eclipse.debug.internal.ui;
2
3
import java.util.HashMap;
4
import java.util.Iterator;
5
import java.util.List;
6
import java.util.Vector;
7
8
import org.eclipse.core.runtime.CoreException;
9
import org.eclipse.core.runtime.IStatus;
10
import org.eclipse.core.runtime.Status;
11
import org.eclipse.debug.core.DebugPlugin;
12
import org.eclipse.debug.core.ILaunchConfiguration;
13
import org.eclipse.debug.core.ILaunchConfigurationListener;
14
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
15
import org.eclipse.debug.core.ILaunchManager;
16
import org.eclipse.debug.internal.ui.launchConfigurations.LaunchHistory;
17
import org.eclipse.debug.internal.ui.preferences.IDebugPreferenceConstants;
18
import org.eclipse.debug.internal.ui.preferences.LaunchConfigurationsPreferencePage;
19
import org.eclipse.debug.ui.DebugUITools;
20
import org.eclipse.debug.ui.IDebugUIConstants;
21
import org.eclipse.jface.action.Action;
22
import org.eclipse.jface.action.ICoolBarManager;
23
import org.eclipse.jface.action.IToolBarManager;
24
import org.eclipse.jface.action.ToolBarContributionItem;
25
import org.eclipse.jface.action.ToolBarManager;
26
import org.eclipse.jface.resource.ImageDescriptor;
27
import org.eclipse.jface.window.ApplicationWindow;
28
import org.eclipse.swt.widgets.Display;
29
import org.eclipse.ui.IWorkbenchWindow;
30
import org.eclipse.ui.PlatformUI;
31
32
/**
33
 * @author tmak
34
 * This class is used to manage the custom toolbar area for external tool actions. 
35
 * 
36
 */
37
public class CustomToolbarManager implements ILaunchHistoryChangedListener, ILaunchConfigurationListener {
38
	
39
	//ID of the Toolbar group for the custom toolbar actions
40
	public static final String ID_CUSTOM_TOOLBAR_GROUP = DebugUIPlugin.getUniqueIdentifier() + ".custom.toolbar"; //$NON-NLS-1$
41
42
	//ID prefix of the action Toolbar actions
43
	public static final String TOOLBAR_CUSTOM_ACTION_ID_PREFIX = ".custom.action."; //$NON-NLS-1$
44
	
45
	//singleton instance
46
	private static CustomToolbarManager manager;
47
	
48
	private HashMap toolbarIconPaths = new HashMap();	
49
	private IToolBarManager customToolbar;
50
	private ICoolBarManager coolBar;
51
	private LaunchHistory launchHistory;	
52
	private boolean showOnToolbar = DebugUIPlugin.getDefault().getPreferenceStore().getBoolean(IDebugPreferenceConstants.SHOW_FAVOURITES_ON_TOOLBAR);
53
	private boolean safeToRun = true;
54
	
55
	public static CustomToolbarManager getInstance() {
56
		
57
		if (manager == null) {
58
			manager = new CustomToolbarManager();
59
		}
60
		return manager;
61
	}
62
	
63
	/**
64
	 * Called by the DebugUI plugin upon startup to initialize the toolbar area.
65
	 */
66
	public void initialize() {
67
		
68
		launchHistory = DebugUIPlugin.getDefault().getLaunchConfigurationManager().
69
						getLaunchHistory(LaunchConfigurationsPreferencePage.EXT_BUILDER_GROUP);
70
								
71
		DebugUIPlugin.getDefault().getLaunchConfigurationManager().addLaunchHistoryListener(this);
72
		DebugPlugin.getDefault().getLaunchManager().addLaunchConfigurationListener(this);	
73
		
74
		//get the workbench toolbar
75
		IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
76
		
77
		if (window != null && window instanceof ApplicationWindow) {
78
			ApplicationWindow w = (ApplicationWindow)window;
79
			coolBar = w.getCoolBarManager();
80
		}
81
		
82
		//add the empty Toolbar area to the Coolbar manager
83
		if (coolBar != null) {
84
			ToolBarManager newManager = new ToolBarManager(coolBar.getStyle());
85
			ToolBarContributionItem wrapper = new ToolBarContributionItem(newManager, ID_CUSTOM_TOOLBAR_GROUP);
86
			coolBar.add(wrapper);
87
			
88
		}
89
		
90
		if (window == null || coolBar == null) {
91
			safeToRun = false;
92
			DebugUIPlugin.log(new Status(IStatus.ERROR,
93
						 DebugUIPlugin.getUniqueIdentifier(),
94
						 0,"Failed to initialize custom toolbar", null));
95
		}
96
		
97
		customToolbar = ((ToolBarContributionItem)coolBar.find(ID_CUSTOM_TOOLBAR_GROUP)).getToolBarManager();
98
				
99
		displayToolbarButtons(showOnToolbar);
100
	}
101
	
102
	private void reloadToolbar() {
103
					
104
		Vector favList = new Vector();
105
		ILaunchConfiguration configs[] = launchHistory.getFavorites();
106
		ImageDescriptor imgID;				
107
		
108
		//wrap all the configurations as a LaunchConfigAction
109
		for (int i = 0; i < configs.length; i++) {
110
			imgID = CustomImageRegistry.getInstance().getImageDescriptor(configs[i]);
111
			favList.add(new LaunchConfigAction(configs[i],imgID));
112
		}
113
		
114
		customToolbar.removeAll();
115
		//add all the Favourites actions to the Toolbar
116
		Iterator i = favList.iterator();
117
		while (i.hasNext()) {
118
			customToolbar.add((LaunchConfigAction)i.next());
119
		}
120
	}
121
			
122
	/* (non-Javadoc)
123
	 * @see org.eclipse.debug.internal.ui.ILaunchHistoryChangedListener#launchHistoryChanged()
124
	 */
125
	public void launchHistoryChanged() {
126
		displayToolbarButtons(showOnToolbar);
127
	}
128
	
129
	public void displayToolbarButtons(boolean show) {
130
		
131
		if (safeToRun) {
132
			//this is the only method that should be changing the value of show, so we need to update it		
133
			this.showOnToolbar = show;
134
			if (showOnToolbar) {
135
				reloadToolbar();
136
			}
137
			else {
138
				customToolbar.removeAll();
139
			}
140
	
141
			//This is required because of the update Favourites progress dialog
142
			Display.getDefault().syncExec(new Runnable() {
143
				public void run() {
144
					coolBar.update(true);
145
				}
146
			});
147
		}
148
	}
149
150
	/* (non-Javadoc)
151
	 * @see org.eclipse.debug.core.ILaunchConfigurationListener#launchConfigurationAdded(org.eclipse.debug.core.ILaunchConfiguration)
152
	 */
153
	public void launchConfigurationAdded(ILaunchConfiguration configuration) {
154
155
		try {
156
			//if this config is not on the toolbar, don't bother refreshing
157
			List favoriteGroups = configuration.getAttribute(IDebugUIConstants.ATTR_FAVORITE_GROUPS, (List)null);
158
						
159
			if (favoriteGroups != null && 
160
				favoriteGroups.contains(LaunchConfigurationsPreferencePage.EXT_BUILDER_GROUP)) {
161
				
162
				ILaunchConfigurationWorkingCopy newCopy = configuration.getWorkingCopy();
163
				String existingIconPath = (String)toolbarIconPaths.get(newCopy.getName());
164
				//if it's not null, and the attribute is different than the value we have stored, recreate the images.
165
				if (existingIconPath != null && 
166
					!existingIconPath.equals(configuration.getAttribute(ILaunchManager.ATTR_LAUNCH_ICON_PATH, ""))) {
167
						displayToolbarButtons(showOnToolbar);
168
				}
169
			}
170
		} catch (CoreException e) {
171
		}
172
		
173
	}
174
175
	public void launchConfigurationChanged(ILaunchConfiguration configuration) {
176
		
177
	}
178
179
	public void launchConfigurationRemoved(ILaunchConfiguration configuration) {
180
		CustomImageRegistry.getInstance().removeImageDescriptor(configuration);
181
	}	
182
	
183
/**
184
 * @author tmak
185
 * This class is used to wrap actions that will be shown on the custom toolbar.
186
 */
187
class LaunchConfigAction extends Action {
188
	
189
	ILaunchConfiguration config;
190
		
191
	public LaunchConfigAction(ILaunchConfiguration config, ImageDescriptor imgID) {
192
		
193
		this.config = config;
194
		
195
		try {
196
			//store the icon paths in a map, in case a user changes the icon in the External Tools preference page
197
			toolbarIconPaths.put(config.getName(), config.getAttribute(ILaunchManager.ATTR_LAUNCH_ICON_PATH, ""));
198
		}
199
		catch(CoreException e) {
200
		}
201
				
202
		setToolTipText(config.getName());
203
		setImageDescriptor(imgID);
204
		setId(TOOLBAR_CUSTOM_ACTION_ID_PREFIX + config.getName());
205
		
206
    }
207
	
208
	private void updateLaunchConfig() throws CoreException {
209
		
210
		ILaunchConfiguration allLaunchConfigs[] = DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurations();
211
		for (int i = 0; i < allLaunchConfigs.length; i++) {
212
			//since names must be unique throughout all configurations, this should be a safe check
213
			if (this.config.getName().equals(allLaunchConfigs[i].getName())) {
214
				config = allLaunchConfigs[i];
215
				return;
216
			}
217
		}
218
		
219
	}
220
		
221
	public void run() {
222
		//In this run method, query for the most up to date config to run.
223
		try {
224
			updateLaunchConfig();
225
			DebugUITools.launch(config, launchHistory.getLaunchGroup().getMode());
226
		}
227
		catch (CoreException e) {
228
			DebugUIPlugin.log(e);
229
		}
230
	}
231
	
232
}
233
234
}
235
(-)ui/org/eclipse/debug/internal/ui/FileSelectionDialog.java (+244 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2005 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.debug.internal.ui;
12
13
import java.util.ArrayList;
14
import java.util.List;
15
import java.util.regex.Pattern;
16
import org.eclipse.core.resources.IContainer;
17
import org.eclipse.core.resources.IResource;
18
import org.eclipse.core.runtime.CoreException;
19
import org.eclipse.core.runtime.IAdaptable;
20
import org.eclipse.jface.dialogs.IDialogConstants;
21
import org.eclipse.jface.dialogs.MessageDialog;
22
import org.eclipse.jface.viewers.DoubleClickEvent;
23
import org.eclipse.jface.viewers.IDoubleClickListener;
24
import org.eclipse.jface.viewers.ISelectionChangedListener;
25
import org.eclipse.jface.viewers.IStructuredSelection;
26
import org.eclipse.jface.viewers.ITreeContentProvider;
27
import org.eclipse.jface.viewers.SelectionChangedEvent;
28
import org.eclipse.swt.SWT;
29
import org.eclipse.swt.events.ControlEvent;
30
import org.eclipse.swt.events.ControlListener;
31
import org.eclipse.swt.widgets.Composite;
32
import org.eclipse.swt.widgets.Control;
33
import org.eclipse.swt.widgets.Shell;
34
import org.eclipse.swt.widgets.TableColumn;
35
import org.eclipse.ui.PlatformUI;
36
import org.eclipse.ui.model.WorkbenchContentProvider;
37
import org.eclipse.ui.model.WorkbenchLabelProvider;
38
39
/**
40
 * Dialog for selecting a file in the workspace. Derived from
41
 * org.eclipse.ui.dialogs.ResourceSelectionDialog
42
 */
43
public class FileSelectionDialog extends MessageDialog {
44
	// the root element to populate the viewer with
45
	private IAdaptable root;
46
47
	// the visual selection widget group
48
	private TreeAndListGroup selectionGroup;
49
	// constants
50
	private final static int SIZING_SELECTION_WIDGET_WIDTH = 400;
51
	private final static int SIZING_SELECTION_WIDGET_HEIGHT = 300;
52
	/**
53
	 * The file(s) selected by the user.
54
	 */
55
	private IStructuredSelection result = null;
56
57
	private boolean allowMultiselection= false;
58
59
    private Pattern fPattern;
60
	/**
61
	 * Creates a resource selection dialog rooted at the given element.
62
	 * 
63
	 * @param parentShell
64
	 *            the parent shell
65
	 * @param rootElement
66
	 *            the root element to populate this dialog with
67
	 * @param message
68
	 *            the message to be displayed at the top of this dialog, or
69
	 *            <code>null</code> to display a default message
70
	 */
71
	public FileSelectionDialog(Shell parentShell, IAdaptable rootElement, String message) {
72
		super(parentShell, DebugUIMessages.FileSelectionDialog_Choose_Location_1, null, message, MessageDialog.NONE, new String[] { DebugUIMessages.FileSelectionDialog_Ok_2, DebugUIMessages.FileSelectionDialog_Cancel_3}, 0);
73
		root = rootElement;
74
		setShellStyle(getShellStyle() | SWT.RESIZE);
75
	}
76
	
77
	/**
78
	 * Limits the files displayed in this dialog to files matching the given
79
	 * pattern. The string can be a filename or a regular expression containing
80
	 * '*' for any series of characters or '?' for any single character.
81
	 * 
82
	 * @param pattern
83
	 *            a pattern used to filter the displayed files or <code>null</code>
84
	 *            to display all files. If a pattern is supplied, only files
85
	 *            whose names match the given pattern will be available for
86
	 *            selection.
87
	 * @param ignoreCase
88
	 *            if true, case is ignored. If the pattern argument is <code>null</code>,
89
	 *            this argument is ignored.
90
	 */
91
	public void setFileFilter(String pattern, boolean ignoreCase) {
92
	    if (pattern != null) {
93
	        if (ignoreCase) {
94
	            fPattern = Pattern.compile(pattern, Pattern.CASE_INSENSITIVE);
95
	        } else {
96
	            fPattern = Pattern.compile(pattern);
97
	        }
98
	    } else {
99
	        fPattern = null;
100
	    }
101
	}
102
	
103
	/*
104
	 * (non-Javadoc) Method declared in Window.
105
	 */
106
	protected void configureShell(Shell shell) {
107
		super.configureShell(shell);
108
		PlatformUI.getWorkbench().getHelpSystem().setHelp(shell, IDebugHelpContextIds.FILE_SELECTION_DIALOG);
109
	}
110
111
	protected void createButtonsForButtonBar(Composite parent) {
112
		super.createButtonsForButtonBar(parent);
113
		initializeDialog();
114
	}
115
	
116
	/*
117
	 * (non-Javadoc) Method declared on Dialog.
118
	 */
119
	protected Control createDialogArea(Composite parent) {
120
		// page group
121
		Composite composite = (Composite) super.createDialogArea(parent);
122
123
		//create the input element, which has the root resource
124
		//as its only child
125
		selectionGroup =
126
			new TreeAndListGroup(
127
				composite,
128
				root,
129
				getResourceProvider(
130
					IResource.FOLDER | IResource.PROJECT | IResource.ROOT),
131
				new WorkbenchLabelProvider(),
132
				getResourceProvider(IResource.FILE),
133
				new WorkbenchLabelProvider(),
134
				SWT.NONE,
135
				// since this page has no other significantly-sized
136
				// widgets we need to hardcode the combined widget's
137
				// size, otherwise it will open too small
138
				SIZING_SELECTION_WIDGET_WIDTH, SIZING_SELECTION_WIDGET_HEIGHT,
139
				allowMultiselection);
140
		
141
		composite.addControlListener(new ControlListener() {
142
			public void controlMoved(ControlEvent e) {
143
			}
144
			public void controlResized(ControlEvent e) {
145
				//Also try and reset the size of the columns as appropriate
146
				TableColumn[] columns =
147
					selectionGroup.getListTable().getColumns();
148
				for (int i = 0; i < columns.length; i++) {
149
					columns[i].pack();
150
				}
151
			}
152
		});
153
154
		return composite;
155
	}
156
	/**
157
	 * Returns a content provider for <code>IResource</code> s that returns
158
	 * only children of the given resource type.
159
	 */
160
	private ITreeContentProvider getResourceProvider(final int resourceType) {
161
		return new WorkbenchContentProvider() {
162
			public Object[] getChildren(Object o) {
163
				if (o instanceof IContainer) {
164
					IResource[] members = null;
165
					try {
166
						members = ((IContainer) o).members();
167
						List accessibleMembers = new ArrayList(members.length);
168
						for (int i = 0; i < members.length; i++) {
169
							IResource resource = members[i];
170
							if (resource.isAccessible()) {
171
								accessibleMembers.add(resource);
172
							}
173
						}
174
						members =
175
							(IResource[]) accessibleMembers.toArray(
176
								new IResource[accessibleMembers.size()]);
177
					} catch (CoreException e) {
178
						//just return an empty set of children
179
						return new Object[0];
180
					}
181
182
					//filter out the desired resource types
183
					ArrayList results = new ArrayList();
184
					for (int i = 0; i < members.length; i++) {
185
						//And the test bits with the resource types to see if
186
						// they are what we want
187
						if ((members[i].getType() & resourceType) > 0) {
188
							if (members[i].getType() == IResource.FILE
189
								&& fPattern != null
190
								&& !fPattern.matcher(members[i].getName()).find()) {
191
								continue;
192
							}
193
							results.add(members[i]);
194
						}
195
					}
196
					return results.toArray();
197
				}
198
				
199
				return new Object[0];
200
			}
201
		};
202
	}
203
	/**
204
	 * Initializes this dialog's controls.
205
	 */
206
	private void initializeDialog() {
207
		selectionGroup
208
			.addSelectionChangedListener(new ISelectionChangedListener() {
209
			public void selectionChanged(SelectionChangedEvent event) {
210
				getButton(IDialogConstants.OK_ID).setEnabled(
211
					!selectionGroup.getListTableSelection().isEmpty());
212
			}
213
		});
214
		selectionGroup.addDoubleClickListener(new IDoubleClickListener() {
215
			public void doubleClick(DoubleClickEvent event) {
216
				buttonPressed(IDialogConstants.OK_ID);
217
			}
218
		});
219
220
		getButton(IDialogConstants.OK_ID).setEnabled(false);
221
	}
222
223
	/**
224
	 * Returns the file the user chose or <code>null</code> if none.
225
	 */
226
	public IStructuredSelection getResult() {
227
		return result;
228
	}
229
230
	protected void buttonPressed(int buttonId) {
231
		if (buttonId == IDialogConstants.OK_ID) {
232
			result= selectionGroup.getListTableSelection();
233
		}
234
		super.buttonPressed(buttonId);
235
	}
236
	/**
237
	 * Sets whether this dialog will allow multi-selection.
238
	 * Must be called before <code>open</code>
239
	 * @param allowMultiselection whether to allow multi-selection in the dialog
240
	 */
241
	public void setAllowMultiselection(boolean allowMultiselection) {
242
		this.allowMultiselection= allowMultiselection;
243
	}
244
}
(-)External Tools Base/org/eclipse/ui/externaltools/internal/ui/FileSelectionDialog.java (-245 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2005 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ui.externaltools.internal.ui;
12
13
import java.util.ArrayList;
14
import java.util.List;
15
import java.util.regex.Pattern;
16
import org.eclipse.core.resources.IContainer;
17
import org.eclipse.core.resources.IResource;
18
import org.eclipse.core.runtime.CoreException;
19
import org.eclipse.core.runtime.IAdaptable;
20
import org.eclipse.jface.dialogs.IDialogConstants;
21
import org.eclipse.jface.dialogs.MessageDialog;
22
import org.eclipse.jface.viewers.DoubleClickEvent;
23
import org.eclipse.jface.viewers.IDoubleClickListener;
24
import org.eclipse.jface.viewers.ISelectionChangedListener;
25
import org.eclipse.jface.viewers.IStructuredSelection;
26
import org.eclipse.jface.viewers.ITreeContentProvider;
27
import org.eclipse.jface.viewers.SelectionChangedEvent;
28
import org.eclipse.swt.SWT;
29
import org.eclipse.swt.events.ControlEvent;
30
import org.eclipse.swt.events.ControlListener;
31
import org.eclipse.swt.widgets.Composite;
32
import org.eclipse.swt.widgets.Control;
33
import org.eclipse.swt.widgets.Shell;
34
import org.eclipse.swt.widgets.TableColumn;
35
import org.eclipse.ui.PlatformUI;
36
import org.eclipse.ui.externaltools.internal.model.IExternalToolsHelpContextIds;
37
import org.eclipse.ui.model.WorkbenchContentProvider;
38
import org.eclipse.ui.model.WorkbenchLabelProvider;
39
40
/**
41
 * Dialog for selecting a file in the workspace. Derived from
42
 * org.eclipse.ui.dialogs.ResourceSelectionDialog
43
 */
44
public class FileSelectionDialog extends MessageDialog {
45
	// the root element to populate the viewer with
46
	private IAdaptable root;
47
48
	// the visual selection widget group
49
	private TreeAndListGroup selectionGroup;
50
	// constants
51
	private final static int SIZING_SELECTION_WIDGET_WIDTH = 400;
52
	private final static int SIZING_SELECTION_WIDGET_HEIGHT = 300;
53
	/**
54
	 * The file(s) selected by the user.
55
	 */
56
	private IStructuredSelection result = null;
57
58
	private boolean allowMultiselection= false;
59
60
    private Pattern fPattern;
61
	/**
62
	 * Creates a resource selection dialog rooted at the given element.
63
	 * 
64
	 * @param parentShell
65
	 *            the parent shell
66
	 * @param rootElement
67
	 *            the root element to populate this dialog with
68
	 * @param message
69
	 *            the message to be displayed at the top of this dialog, or
70
	 *            <code>null</code> to display a default message
71
	 */
72
	public FileSelectionDialog(Shell parentShell, IAdaptable rootElement, String message) {
73
		super(parentShell, ExternalToolsUIMessages.FileSelectionDialog_Choose_Location_1, null, message, MessageDialog.NONE, new String[] { ExternalToolsUIMessages.FileSelectionDialog_Ok_2, ExternalToolsUIMessages.FileSelectionDialog_Cancel_3}, 0);
74
		root = rootElement;
75
		setShellStyle(getShellStyle() | SWT.RESIZE);
76
	}
77
	
78
	/**
79
	 * Limits the files displayed in this dialog to files matching the given
80
	 * pattern. The string can be a filename or a regular expression containing
81
	 * '*' for any series of characters or '?' for any single character.
82
	 * 
83
	 * @param pattern
84
	 *            a pattern used to filter the displayed files or <code>null</code>
85
	 *            to display all files. If a pattern is supplied, only files
86
	 *            whose names match the given pattern will be available for
87
	 *            selection.
88
	 * @param ignoreCase
89
	 *            if true, case is ignored. If the pattern argument is <code>null</code>,
90
	 *            this argument is ignored.
91
	 */
92
	public void setFileFilter(String pattern, boolean ignoreCase) {
93
	    if (pattern != null) {
94
	        if (ignoreCase) {
95
	            fPattern = Pattern.compile(pattern, Pattern.CASE_INSENSITIVE);
96
	        } else {
97
	            fPattern = Pattern.compile(pattern);
98
	        }
99
	    } else {
100
	        fPattern = null;
101
	    }
102
	}
103
	
104
	/*
105
	 * (non-Javadoc) Method declared in Window.
106
	 */
107
	protected void configureShell(Shell shell) {
108
		super.configureShell(shell);
109
		PlatformUI.getWorkbench().getHelpSystem().setHelp(shell, IExternalToolsHelpContextIds.FILE_SELECTION_DIALOG);
110
	}
111
112
	protected void createButtonsForButtonBar(Composite parent) {
113
		super.createButtonsForButtonBar(parent);
114
		initializeDialog();
115
	}
116
	
117
	/*
118
	 * (non-Javadoc) Method declared on Dialog.
119
	 */
120
	protected Control createDialogArea(Composite parent) {
121
		// page group
122
		Composite composite = (Composite) super.createDialogArea(parent);
123
124
		//create the input element, which has the root resource
125
		//as its only child
126
		selectionGroup =
127
			new TreeAndListGroup(
128
				composite,
129
				root,
130
				getResourceProvider(
131
					IResource.FOLDER | IResource.PROJECT | IResource.ROOT),
132
				new WorkbenchLabelProvider(),
133
				getResourceProvider(IResource.FILE),
134
				new WorkbenchLabelProvider(),
135
				SWT.NONE,
136
				// since this page has no other significantly-sized
137
				// widgets we need to hardcode the combined widget's
138
				// size, otherwise it will open too small
139
				SIZING_SELECTION_WIDGET_WIDTH, SIZING_SELECTION_WIDGET_HEIGHT,
140
				allowMultiselection);
141
		
142
		composite.addControlListener(new ControlListener() {
143
			public void controlMoved(ControlEvent e) {
144
			}
145
			public void controlResized(ControlEvent e) {
146
				//Also try and reset the size of the columns as appropriate
147
				TableColumn[] columns =
148
					selectionGroup.getListTable().getColumns();
149
				for (int i = 0; i < columns.length; i++) {
150
					columns[i].pack();
151
				}
152
			}
153
		});
154
155
		return composite;
156
	}
157
	/**
158
	 * Returns a content provider for <code>IResource</code> s that returns
159
	 * only children of the given resource type.
160
	 */
161
	private ITreeContentProvider getResourceProvider(final int resourceType) {
162
		return new WorkbenchContentProvider() {
163
			public Object[] getChildren(Object o) {
164
				if (o instanceof IContainer) {
165
					IResource[] members = null;
166
					try {
167
						members = ((IContainer) o).members();
168
						List accessibleMembers = new ArrayList(members.length);
169
						for (int i = 0; i < members.length; i++) {
170
							IResource resource = members[i];
171
							if (resource.isAccessible()) {
172
								accessibleMembers.add(resource);
173
							}
174
						}
175
						members =
176
							(IResource[]) accessibleMembers.toArray(
177
								new IResource[accessibleMembers.size()]);
178
					} catch (CoreException e) {
179
						//just return an empty set of children
180
						return new Object[0];
181
					}
182
183
					//filter out the desired resource types
184
					ArrayList results = new ArrayList();
185
					for (int i = 0; i < members.length; i++) {
186
						//And the test bits with the resource types to see if
187
						// they are what we want
188
						if ((members[i].getType() & resourceType) > 0) {
189
							if (members[i].getType() == IResource.FILE
190
								&& fPattern != null
191
								&& !fPattern.matcher(members[i].getName()).find()) {
192
								continue;
193
							}
194
							results.add(members[i]);
195
						}
196
					}
197
					return results.toArray();
198
				}
199
				
200
				return new Object[0];
201
			}
202
		};
203
	}
204
	/**
205
	 * Initializes this dialog's controls.
206
	 */
207
	private void initializeDialog() {
208
		selectionGroup
209
			.addSelectionChangedListener(new ISelectionChangedListener() {
210
			public void selectionChanged(SelectionChangedEvent event) {
211
				getButton(IDialogConstants.OK_ID).setEnabled(
212
					!selectionGroup.getListTableSelection().isEmpty());
213
			}
214
		});
215
		selectionGroup.addDoubleClickListener(new IDoubleClickListener() {
216
			public void doubleClick(DoubleClickEvent event) {
217
				buttonPressed(IDialogConstants.OK_ID);
218
			}
219
		});
220
221
		getButton(IDialogConstants.OK_ID).setEnabled(false);
222
	}
223
224
	/**
225
	 * Returns the file the user chose or <code>null</code> if none.
226
	 */
227
	public IStructuredSelection getResult() {
228
		return result;
229
	}
230
231
	protected void buttonPressed(int buttonId) {
232
		if (buttonId == IDialogConstants.OK_ID) {
233
			result= selectionGroup.getListTableSelection();
234
		}
235
		super.buttonPressed(buttonId);
236
	}
237
	/**
238
	 * Sets whether this dialog will allow multi-selection.
239
	 * Must be called before <code>open</code>
240
	 * @param allowMultiselection whether to allow multi-selection in the dialog
241
	 */
242
	public void setAllowMultiselection(boolean allowMultiselection) {
243
		this.allowMultiselection= allowMultiselection;
244
	}
245
}
(-)External Tools Base/org/eclipse/ui/externaltools/internal/ui/TreeAndListGroup.java (-316 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2005 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ui.externaltools.internal.ui;
12
13
14
import java.util.ArrayList;
15
import java.util.Iterator;
16
import java.util.List;
17
18
import org.eclipse.jface.viewers.DoubleClickEvent;
19
import org.eclipse.jface.viewers.IDoubleClickListener;
20
import org.eclipse.jface.viewers.ILabelProvider;
21
import org.eclipse.jface.viewers.ISelection;
22
import org.eclipse.jface.viewers.ISelectionChangedListener;
23
import org.eclipse.jface.viewers.IStructuredContentProvider;
24
import org.eclipse.jface.viewers.IStructuredSelection;
25
import org.eclipse.jface.viewers.ITreeContentProvider;
26
import org.eclipse.jface.viewers.SelectionChangedEvent;
27
import org.eclipse.jface.viewers.StructuredSelection;
28
import org.eclipse.jface.viewers.TableViewer;
29
import org.eclipse.jface.viewers.TreeViewer;
30
import org.eclipse.jface.viewers.ViewerSorter;
31
import org.eclipse.swt.SWT;
32
import org.eclipse.swt.layout.GridData;
33
import org.eclipse.swt.layout.GridLayout;
34
import org.eclipse.swt.widgets.Composite;
35
import org.eclipse.swt.widgets.Table;
36
import org.eclipse.swt.widgets.Tree;
37
import org.eclipse.ui.views.navigator.ResourceSorter;
38
39
/**
40
 * This class was derived from org.eclipse.ui.internal.misc.CheckboxTreeAndListGroup
41
 *
42
 */
43
public class TreeAndListGroup implements ISelectionChangedListener {
44
	private Object root;
45
	private Object currentTreeSelection;
46
	private List selectionChangedListeners = new ArrayList();
47
	private List doubleClickListeners= new ArrayList();
48
49
	private ITreeContentProvider treeContentProvider;
50
	private IStructuredContentProvider listContentProvider;
51
	private ILabelProvider treeLabelProvider;
52
	private ILabelProvider listLabelProvider;
53
54
	// widgets
55
	private TreeViewer treeViewer;
56
	private TableViewer listViewer;
57
	private boolean allowMultiselection= false;
58
59
	/**
60
	 *	Create an instance of this class.  Use this constructor if you wish to specify
61
	 *	the width and/or height of the combined widget (to only hardcode one of the
62
	 *	sizing dimensions, specify the other dimension's value as -1)
63
	 *
64
	 *	@param parent org.eclipse.swt.widgets.Composite
65
	 *	@param style int
66
	 *  @param rootObject java.lang.Object
67
	 *	@param width int
68
	 *	@param height int
69
	 *  @param allowMultiselection Whether to allow multi-selection in the list viewer.
70
	 */
71
	public TreeAndListGroup(Composite parent, Object rootObject, ITreeContentProvider treeContentProvider, ILabelProvider treeLabelProvider, IStructuredContentProvider listContentProvider, ILabelProvider listLabelProvider, int style, int width, int height, boolean allowMultiselection) {
72
73
		root = rootObject;
74
		this.treeContentProvider = treeContentProvider;
75
		this.listContentProvider = listContentProvider;
76
		this.treeLabelProvider = treeLabelProvider;
77
		this.listLabelProvider = listLabelProvider;
78
		this.allowMultiselection= allowMultiselection;
79
		createContents(parent, width, height, style);
80
	}
81
	/**
82
	 * This method must be called just before this window becomes visible.
83
	 */
84
	public void aboutToOpen() {
85
		currentTreeSelection = null;
86
87
		//select the first element in the list
88
		Object[] elements = treeContentProvider.getElements(root);
89
		Object primary = elements.length > 0 ? elements[0] : null;
90
		if (primary != null) {
91
			treeViewer.setSelection(new StructuredSelection(primary));
92
		}
93
		treeViewer.getControl().setFocus();
94
	}
95
	/**
96
	 *	Add the passed listener to collection of clients
97
	 *	that listen for changes to list viewer selection state
98
	 *
99
	 *	@param listener ISelectionChangedListener
100
	 */
101
	public void addSelectionChangedListener(ISelectionChangedListener listener) {
102
		selectionChangedListeners.add(listener);
103
	}
104
	
105
	/**
106
	 * Add the given listener to the collection of clients that listen to
107
	 * double-click events in the list viewer
108
	 * 
109
	 * @param listener IDoubleClickListener
110
	 */
111
	public void addDoubleClickListener(IDoubleClickListener listener) {
112
		doubleClickListeners.add(listener);
113
	}
114
115
	/**
116
	 * Notify all selection listeners that a selection has occurred in the list
117
	 * viewer
118
	 */
119
	protected void notifySelectionListeners(SelectionChangedEvent event) {
120
		Iterator iter = selectionChangedListeners.iterator();
121
		while (iter.hasNext()) {
122
			 ((ISelectionChangedListener) iter.next()).selectionChanged(event);
123
		}
124
	}
125
	
126
	/**
127
	 * Notify all double click listeners that a double click event has occurred
128
	 * in the list viewer
129
	 */
130
	protected void notifyDoubleClickListeners(DoubleClickEvent event) {
131
		Iterator iter= doubleClickListeners.iterator();
132
		while (iter.hasNext()) {
133
			((IDoubleClickListener) iter.next()).doubleClick(event);
134
		}
135
	}
136
137
	/**
138
	 *	Lay out and initialize self's visual components.
139
	 *
140
	 *	@param parent org.eclipse.swt.widgets.Composite
141
	 *	@param width int
142
	 *	@param height int
143
	 */
144
	protected void createContents(Composite parent, int width, int height, int style) {
145
		// group pane
146
		Composite composite = new Composite(parent, style);
147
		composite.setFont(parent.getFont());
148
		GridLayout layout = new GridLayout();
149
		layout.numColumns = 2;
150
		layout.makeColumnsEqualWidth = true;
151
		layout.marginHeight = 0;
152
		layout.marginWidth = 0;
153
		composite.setLayout(layout);
154
		composite.setLayoutData(new GridData(GridData.FILL_BOTH));
155
156
		createTreeViewer(composite, width / 2, height);
157
		createListViewer(composite, width / 2, height);
158
159
		initialize();
160
	}
161
	/**
162
	 *	Create this group's list viewer.
163
	 */
164
	protected void createListViewer(Composite parent, int width, int height) {
165
		int style;
166
		if (allowMultiselection) {
167
			style= SWT.MULTI;
168
		} else {
169
			style= SWT.SINGLE;
170
		}
171
		listViewer = new TableViewer(parent, SWT.BORDER | style);
172
		GridData data = new GridData(GridData.FILL_BOTH);
173
		data.widthHint = width;
174
		data.heightHint = height;
175
		listViewer.getTable().setLayoutData(data);
176
		listViewer.getTable().setFont(parent.getFont());
177
		listViewer.setContentProvider(listContentProvider);
178
		listViewer.setLabelProvider(listLabelProvider);
179
		listViewer.setSorter(new ResourceSorter(ResourceSorter.NAME));
180
		listViewer.addSelectionChangedListener(new ISelectionChangedListener() {
181
			public void selectionChanged(SelectionChangedEvent event) {
182
				notifySelectionListeners(event);
183
			}
184
		});
185
		listViewer.addDoubleClickListener(new IDoubleClickListener() {
186
			public void doubleClick(DoubleClickEvent event) {
187
				if (!event.getSelection().isEmpty()) {
188
					notifyDoubleClickListeners(event);
189
				}
190
			}
191
		});
192
	}
193
	/**
194
	 *	Create this group's tree viewer.
195
	 */
196
	protected void createTreeViewer(Composite parent, int width, int height) {
197
		Tree tree = new Tree(parent, SWT.BORDER);
198
		GridData data = new GridData(GridData.FILL_BOTH);
199
		data.widthHint = width;
200
		data.heightHint = height;
201
		tree.setLayoutData(data);
202
		tree.setFont(parent.getFont());
203
204
		treeViewer = new TreeViewer(tree);
205
		treeViewer.setContentProvider(treeContentProvider);
206
		treeViewer.setLabelProvider(treeLabelProvider);
207
		treeViewer.setSorter(new ResourceSorter(ResourceSorter.NAME));
208
		treeViewer.addSelectionChangedListener(this);
209
	}
210
	
211
	public Table getListTable() {
212
		return listViewer.getTable();
213
	}
214
	
215
	public IStructuredSelection getListTableSelection() {
216
		ISelection selection=  this.listViewer.getSelection();
217
		if (selection instanceof IStructuredSelection) {
218
			return (IStructuredSelection)selection;
219
		} 
220
		return StructuredSelection.EMPTY;
221
	}
222
	
223
	protected void initialListItem(Object element) {
224
		Object parent = treeContentProvider.getParent(element);
225
		selectAndRevealFolder(parent);
226
	}
227
	
228
	public void selectAndRevealFolder(Object treeElement) {
229
		treeViewer.reveal(treeElement);
230
		IStructuredSelection selection = new StructuredSelection(treeElement);
231
		treeViewer.setSelection(selection);
232
	}
233
	
234
	public void selectAndRevealFile(Object treeElement) {
235
		listViewer.reveal(treeElement);
236
		IStructuredSelection selection = new StructuredSelection(treeElement);
237
		listViewer.setSelection(selection);
238
	}
239
240
	/**
241
	 *	Initialize this group's viewers after they have been laid out.
242
	 */
243
	protected void initialize() {
244
		treeViewer.setInput(root);
245
	}
246
247
	/* (non-Javadoc)
248
	 * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)
249
	 */
250
	public void selectionChanged(SelectionChangedEvent event) {
251
		IStructuredSelection selection = (IStructuredSelection) event.getSelection();
252
		Object selectedElement = selection.getFirstElement();
253
		if (selectedElement == null) {
254
			currentTreeSelection = null;
255
			listViewer.setInput(currentTreeSelection);
256
			return;
257
		}
258
259
		// ie.- if not an item deselection
260
		if (selectedElement != currentTreeSelection) {
261
			listViewer.setInput(selectedElement);
262
		}
263
264
		currentTreeSelection = selectedElement;
265
	}
266
	/**
267
	 *	Set the list viewer's providers to those passed
268
	 *
269
	 *	@param contentProvider ITreeContentProvider
270
	 *	@param labelProvider ILabelProvider
271
	 */
272
	public void setListProviders(IStructuredContentProvider contentProvider, ILabelProvider labelProvider) {
273
		listViewer.setContentProvider(contentProvider);
274
		listViewer.setLabelProvider(labelProvider);
275
	}
276
	/**
277
	 *	Set the sorter that is to be applied to self's list viewer
278
	 */
279
	public void setListSorter(ViewerSorter sorter) {
280
		listViewer.setSorter(sorter);
281
	}
282
	/**
283
	 * Set the root of the widget to be new Root. Regenerate all of the tables and lists from this
284
	 * value.
285
	 * @param newRoot
286
	 */
287
	public void setRoot(Object newRoot) {
288
		this.root = newRoot;
289
		initialize();
290
	}
291
292
	/**
293
	 *	Set the tree viewer's providers to those passed
294
	 *
295
	 *	@param contentProvider ITreeContentProvider
296
	 *	@param labelProvider ILabelProvider
297
	 */
298
	public void setTreeProviders(ITreeContentProvider contentProvider, ILabelProvider labelProvider) {
299
		treeViewer.setContentProvider(contentProvider);
300
		treeViewer.setLabelProvider(labelProvider);
301
	}
302
	/**
303
	 *	Set the sorter that is to be applied to self's tree viewer
304
	 */
305
	public void setTreeSorter(ViewerSorter sorter) {
306
		treeViewer.setSorter(sorter);
307
	}
308
309
	/**
310
	 * Set the focus on to the list widget.
311
	 */
312
	public void setFocus() {
313
314
		this.treeViewer.getTree().setFocus();
315
	}
316
}
(-)External Tools Base/org/eclipse/ui/externaltools/internal/model/IExternalToolsHelpContextIds.java (-1 / +1 lines)
Lines 29-35 Link Here
29
	
29
	
30
	//Dialogs
30
	//Dialogs
31
	public static final String MESSAGE_WITH_TOGGLE_DIALOG = PREFIX + "message_with_toggle_dialog_context"; //$NON-NLS-1$
31
	public static final String MESSAGE_WITH_TOGGLE_DIALOG = PREFIX + "message_with_toggle_dialog_context"; //$NON-NLS-1$
32
	public static final String FILE_SELECTION_DIALOG = PREFIX + "file_selection_dialog_context"; //$NON-NLS-1$
32
	//public static final String FILE_SELECTION_DIALOG = PREFIX + "file_selection_dialog_context"; //$NON-NLS-1$
33
	
33
	
34
	//Launch configuration dialog tabs
34
	//Launch configuration dialog tabs
35
	public static final String EXTERNAL_TOOLS_LAUNCH_CONFIGURATION_DIALOG_BUILDER_TAB = PREFIX + "builders_tab_context"; //$NON-NLS-1$
35
	public static final String EXTERNAL_TOOLS_LAUNCH_CONFIGURATION_DIALOG_BUILDER_TAB = PREFIX + "builders_tab_context"; //$NON-NLS-1$
(-)Program Tools Support/org/eclipse/ui/externaltools/internal/program/launchConfigurations/ProgramMainTab.java (-1 / +1 lines)
Lines 13-24 Link Here
13
13
14
import org.eclipse.core.resources.IFile;
14
import org.eclipse.core.resources.IFile;
15
import org.eclipse.core.resources.ResourcesPlugin;
15
import org.eclipse.core.resources.ResourcesPlugin;
16
import org.eclipse.debug.internal.ui.FileSelectionDialog;
16
import org.eclipse.jface.viewers.IStructuredSelection;
17
import org.eclipse.jface.viewers.IStructuredSelection;
17
import org.eclipse.swt.widgets.Composite;
18
import org.eclipse.swt.widgets.Composite;
18
import org.eclipse.ui.PlatformUI;
19
import org.eclipse.ui.PlatformUI;
19
import org.eclipse.ui.externaltools.internal.launchConfigurations.ExternalToolsMainTab;
20
import org.eclipse.ui.externaltools.internal.launchConfigurations.ExternalToolsMainTab;
20
import org.eclipse.ui.externaltools.internal.model.IExternalToolsHelpContextIds;
21
import org.eclipse.ui.externaltools.internal.model.IExternalToolsHelpContextIds;
21
import org.eclipse.ui.externaltools.internal.ui.FileSelectionDialog;
22
22
23
public class ProgramMainTab extends ExternalToolsMainTab {
23
public class ProgramMainTab extends ExternalToolsMainTab {
24
24
(-)core/org/eclipse/debug/core/ILaunchManager.java (+10 lines)
Lines 68-73 Link Here
68
	public static final String ATTR_APPEND_ENVIRONMENT_VARIABLES = DebugPlugin.getUniqueIdentifier() + ".appendEnvironmentVariables"; //$NON-NLS-1$	
68
	public static final String ATTR_APPEND_ENVIRONMENT_VARIABLES = DebugPlugin.getUniqueIdentifier() + ".appendEnvironmentVariables"; //$NON-NLS-1$	
69
	
69
	
70
	/**
70
	/**
71
	 * Launch configuration attribute name. The value contains a path to the 
72
	 * user specified icon file.  If this attribute is not defined, then the 
73
	 * default icon (the icon that represents this launch configurations type)
74
	 * will be used.
75
	 *  
76
	 * @since 3.2 
77
	 */
78
	public static final String ATTR_LAUNCH_ICON_PATH = DebugPlugin.getUniqueIdentifier() + ".imagePath"; //$NON-NLS-1$
79
	
80
	/**
71
	 * Adds the specified launch and notifies listeners. Has no
81
	 * Adds the specified launch and notifies listeners. Has no
72
	 * effect if an identical launch is already registered.
82
	 * effect if an identical launch is already registered.
73
	 * 
83
	 * 
(-)core/org/eclipse/debug/internal/core/LaunchConfigurationWorkingCopy.java (-1 / +23 lines)
Lines 39-44 Link Here
39
import org.eclipse.debug.core.ILaunchConfiguration;
39
import org.eclipse.debug.core.ILaunchConfiguration;
40
import org.eclipse.debug.core.ILaunchConfigurationType;
40
import org.eclipse.debug.core.ILaunchConfigurationType;
41
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
41
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
42
import org.eclipse.debug.core.ILaunchManager;
42
43
43
/**
44
/**
44
 * A working copy launch configuration
45
 * A working copy launch configuration
Lines 73-78 Link Here
73
	private boolean fRenamed = false;
74
	private boolean fRenamed = false;
74
	
75
	
75
	/**
76
	/**
77
	 * Indicates whether this working copy has had it's icon changed.
78
	 */
79
	private boolean fIconChanged = false;
80
	
81
	/**
76
	 * Suppress change notification until created
82
	 * Suppress change notification until created
77
	 */
83
	 */
78
	private boolean fSuppressChange = true;
84
	private boolean fSuppressChange = true;
Lines 483-489 Link Here
483
	 * location has changed from that of its original
489
	 * location has changed from that of its original
484
	 */
490
	 */
485
	protected boolean isMoved() {
491
	protected boolean isMoved() {
486
		if (isNew() || fRenamed) {
492
		//if the icon has been changed, also treat it as moved
493
		if (isNew() || fRenamed || fIconChanged) {
487
			return true;
494
			return true;
488
		}
495
		}
489
		IContainer newContainer = getContainer();
496
		IContainer newContainer = getContainer();
Lines 575-579 Link Here
575
		setAttribute(LaunchConfiguration.ATTR_MAPPED_RESOURCE_TYPES, types);
582
		setAttribute(LaunchConfiguration.ATTR_MAPPED_RESOURCE_TYPES, types);
576
	}//end setResource
583
	}//end setResource
577
584
585
	/**
586
	 * Changes the Icon path attribute for this working copy
587
	 * @param value the value to set the icon path to
588
	 */
589
	public void changeIconPath(String value) {
590
		//if the icon was left empty, remove/don't set the entry
591
		if (!value.equals("")) {
592
			setAttribute(ILaunchManager.ATTR_LAUNCH_ICON_PATH, value);
593
		}
594
		else {
595
			setAttribute(ILaunchManager.ATTR_LAUNCH_ICON_PATH, (String)null);
596
		}
597
		fIconChanged = true;
598
	}
599
		
578
}//end class
600
}//end class
579
601
(-)Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntMainTab.java (-1 / +1 lines)
Lines 21-26 Link Here
21
import org.eclipse.core.variables.VariablesPlugin;
21
import org.eclipse.core.variables.VariablesPlugin;
22
import org.eclipse.debug.core.ILaunchConfiguration;
22
import org.eclipse.debug.core.ILaunchConfiguration;
23
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
23
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
24
import org.eclipse.debug.internal.ui.FileSelectionDialog;
24
import org.eclipse.debug.ui.ILaunchConfigurationTab;
25
import org.eclipse.debug.ui.ILaunchConfigurationTab;
25
import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
26
import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
26
import org.eclipse.jface.dialogs.Dialog;
27
import org.eclipse.jface.dialogs.Dialog;
Lines 35-41 Link Here
35
import org.eclipse.ui.PlatformUI;
36
import org.eclipse.ui.PlatformUI;
36
import org.eclipse.ui.externaltools.internal.launchConfigurations.ExternalToolsMainTab;
37
import org.eclipse.ui.externaltools.internal.launchConfigurations.ExternalToolsMainTab;
37
import org.eclipse.ui.externaltools.internal.model.IExternalToolConstants;
38
import org.eclipse.ui.externaltools.internal.model.IExternalToolConstants;
38
import org.eclipse.ui.externaltools.internal.ui.FileSelectionDialog;
39
39
40
public class AntMainTab extends ExternalToolsMainTab {
40
public class AntMainTab extends ExternalToolsMainTab {
41
41
(-)Ant Tools Support/org/eclipse/ant/internal/ui/preferences/AddCustomDialog.java (-1 / +1 lines)
Lines 27-32 Link Here
27
import org.eclipse.core.runtime.IPath;
27
import org.eclipse.core.runtime.IPath;
28
import org.eclipse.core.runtime.Path;
28
import org.eclipse.core.runtime.Path;
29
import org.eclipse.core.variables.VariablesPlugin;
29
import org.eclipse.core.variables.VariablesPlugin;
30
import org.eclipse.debug.internal.ui.TreeAndListGroup;
30
import org.eclipse.jface.dialogs.IDialogConstants;
31
import org.eclipse.jface.dialogs.IDialogConstants;
31
import org.eclipse.jface.dialogs.StatusDialog;
32
import org.eclipse.jface.dialogs.StatusDialog;
32
import org.eclipse.jface.viewers.DoubleClickEvent;
33
import org.eclipse.jface.viewers.DoubleClickEvent;
Lines 55-61 Link Here
55
import org.eclipse.swt.widgets.Text;
56
import org.eclipse.swt.widgets.Text;
56
import org.eclipse.ui.PlatformUI;
57
import org.eclipse.ui.PlatformUI;
57
import org.eclipse.ui.dialogs.FileSystemElement;
58
import org.eclipse.ui.dialogs.FileSystemElement;
58
import org.eclipse.ui.externaltools.internal.ui.TreeAndListGroup;
59
import org.eclipse.ui.model.WorkbenchContentProvider;
59
import org.eclipse.ui.model.WorkbenchContentProvider;
60
import org.eclipse.ui.model.WorkbenchLabelProvider;
60
import org.eclipse.ui.model.WorkbenchLabelProvider;
61
import org.eclipse.ui.model.WorkbenchViewerSorter;
61
import org.eclipse.ui.model.WorkbenchViewerSorter;

Return to bug 51003