View | Details | Raw Unified | Return to bug 165371
Collapse All | Expand All

(-)Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntTabGroup.java (-1 / +2 lines)
Lines 25-30 Link Here
25
import org.eclipse.debug.ui.ILaunchConfigurationTab;
25
import org.eclipse.debug.ui.ILaunchConfigurationTab;
26
import org.eclipse.debug.ui.RefreshTab;
26
import org.eclipse.debug.ui.RefreshTab;
27
import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
27
import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
28
import org.eclipse.ui.externaltools.internal.launchConfigurations.ExternalToolsBuildTab;
28
import org.eclipse.ui.externaltools.internal.model.IExternalToolConstants;
29
import org.eclipse.ui.externaltools.internal.model.IExternalToolConstants;
29
30
30
public class AntTabGroup extends AbstractLaunchConfigurationTabGroup {
31
public class AntTabGroup extends AbstractLaunchConfigurationTabGroup {
Lines 53-59 Link Here
53
		ILaunchConfigurationTab[] tabs = new ILaunchConfigurationTab[] {
54
		ILaunchConfigurationTab[] tabs = new ILaunchConfigurationTab[] {
54
			new AntMainTab(),
55
			new AntMainTab(),
55
			new RefreshTab(),
56
			new RefreshTab(),
56
			new AntBuildTab(),
57
			new ExternalToolsBuildTab(),
57
			new AntTargetsTab(),
58
			new AntTargetsTab(),
58
			new AntClasspathTab(),
59
			new AntClasspathTab(),
59
			new AntPropertiesTab(),
60
			new AntPropertiesTab(),
(-)Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntLaunchConfigurationMessages.java (-10 lines)
Lines 19-34 Link Here
19
	public static String AddVariableStringAction_3;
19
	public static String AddVariableStringAction_3;
20
	public static String AddVariableStringAction_4;
20
	public static String AddVariableStringAction_4;
21
21
22
	public static String AntBuildTab_1;
23
	public static String AntBuildTab_2;
24
	public static String AntBuildTab_3;
25
	public static String AntBuildTab_4;
26
	public static String AntBuildTab_5;
27
	public static String AntBuildTab_6;
28
	public static String AntBuildTab_7;
29
	public static String AntBuildTab_8;
30
	public static String AntBuildTab_9;
31
32
	public static String AntLaunchDelegate_Launching__0__1;
22
	public static String AntLaunchDelegate_Launching__0__1;
33
	public static String AntLaunchDelegate_Running__0__2;
23
	public static String AntLaunchDelegate_Running__0__2;
34
	public static String AntLaunchDelegate_Build_In_Progress;
24
	public static String AntLaunchDelegate_Build_In_Progress;
(-)Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntLaunchConfigurationMessages.properties (-10 lines)
Lines 14-29 Link Here
14
AddVariableStringAction_3=&Variables...
14
AddVariableStringAction_3=&Variables...
15
AddVariableStringAction_4=Add Variable Classpath Entry
15
AddVariableStringAction_4=Add Variable Classpath Entry
16
16
17
AntBuildTab_1=&Build before launch
18
AntBuildTab_2=The &entire workspace
19
AntBuildTab_3=The &project containing the selected resource
20
AntBuildTab_4=&Specific projects
21
AntBuildTab_5=P&rojects...
22
AntBuildTab_6=Include referenced pro&jects
23
AntBuildTab_7=Select &Projects:
24
AntBuildTab_8=Build
25
AntBuildTab_9=No projects specified
26
27
AntLaunchDelegate_Launching__0__1=Launching {0}
17
AntLaunchDelegate_Launching__0__1=Launching {0}
28
AntLaunchDelegate_Running__0__2=Running {0}
18
AntLaunchDelegate_Running__0__2=Running {0}
29
AntLaunchDelegate_Build_In_Progress=Ant build {0} already in progress. Concurrent Ant builds are possible if you specify to build in a separate JRE.
19
AntLaunchDelegate_Build_In_Progress=Ant build {0} already in progress. Concurrent Ant builds are possible if you specify to build in a separate JRE.
(-)Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntBuildTab.java (-382 / +9 lines)
Lines 11-48 Link Here
11
package org.eclipse.ant.internal.ui.launchConfigurations;
11
package org.eclipse.ant.internal.ui.launchConfigurations;
12
12
13
13
14
import java.util.ArrayList;
15
import java.util.Iterator;
16
import java.util.List;
17
import org.eclipse.ant.internal.ui.AntUIImages;
18
import org.eclipse.ant.internal.ui.AntUIPlugin;
14
import org.eclipse.ant.internal.ui.AntUIPlugin;
19
import org.eclipse.ant.internal.ui.IAntUIConstants;
15
import org.eclipse.ui.externaltools.internal.launchConfigurations.ExternalToolsBuildTab;
20
import org.eclipse.ant.internal.ui.IAntUIHelpContextIds;
21
import org.eclipse.core.resources.IProject;
22
import org.eclipse.core.resources.IResource;
23
import org.eclipse.core.resources.IWorkspace;
24
import org.eclipse.core.resources.IWorkspaceRoot;
25
import org.eclipse.core.resources.ResourcesPlugin;
26
import org.eclipse.core.runtime.CoreException;
27
import org.eclipse.debug.core.ILaunchConfiguration;
28
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
29
import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
30
import org.eclipse.debug.ui.DebugUITools;
31
import org.eclipse.jface.viewers.IStructuredContentProvider;
32
import org.eclipse.jface.viewers.Viewer;
33
import org.eclipse.jface.window.Window;
34
import org.eclipse.swt.SWT;
35
import org.eclipse.swt.events.SelectionAdapter;
36
import org.eclipse.swt.events.SelectionEvent;
37
import org.eclipse.swt.graphics.Image;
38
import org.eclipse.swt.layout.GridData;
39
import org.eclipse.swt.layout.GridLayout;
40
import org.eclipse.swt.widgets.Button;
41
import org.eclipse.swt.widgets.Composite;
42
import org.eclipse.swt.widgets.Group;
43
import org.eclipse.ui.PlatformUI;
44
import org.eclipse.ui.dialogs.ListSelectionDialog;
45
import org.eclipse.ui.model.WorkbenchLabelProvider;
46
16
47
/**
17
/**
48
 * A launch configuration tab which allows the user to specify
18
 * A launch configuration tab which allows the user to specify
Lines 53-59 Link Here
53
 * </p>
23
 * </p>
54
 * @since 3.0
24
 * @since 3.0
55
 */
25
 */
56
public class AntBuildTab extends AbstractLaunchConfigurationTab {
26
public class AntBuildTab extends ExternalToolsBuildTab {
57
27
58
	/**
28
	/**
59
	 * String attribute identifying the build scope for this launch configuration.
29
	 * String attribute identifying the build scope for this launch configuration.
Lines 68-427 Link Here
68
	 */
38
	 */
69
	public static final String ATTR_INCLUDE_REFERENCED_PROJECTS = AntUIPlugin.getUniqueIdentifier() + ".ATTR_INCLUDE_REFERENCED_PROJECTS"; //$NON-NLS-1$
39
	public static final String ATTR_INCLUDE_REFERENCED_PROJECTS = AntUIPlugin.getUniqueIdentifier() + ".ATTR_INCLUDE_REFERENCED_PROJECTS"; //$NON-NLS-1$
70
	
40
	
71
	// Check Buttons
72
	private Button fBuildButton;
73
	
74
	// Group box
75
	private Group fGroup;
76
	
77
	// Radio Buttons
78
	private Button fProjectButton;
79
	private Button fSpecificProjectsButton;
80
	private Button fWorkspaceButton;
81
	
82
	// Push Button
83
	private Button fSelectButton;
84
	
85
	// whether to include referenced projects
86
	private Button fReferencedProjects;
87
	
88
	// projects to build (empty if none)
89
	private List fProjects = new ArrayList();
90
	
91
	class ProjectsContentProvider implements IStructuredContentProvider {
92
93
		/* (non-Javadoc)
94
		 * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
95
		 */
96
		public Object[] getElements(Object inputElement) {
97
			return ((IWorkspace)inputElement).getRoot().getProjects();
98
		}
99
100
		/* (non-Javadoc)
101
		 * @see org.eclipse.jface.viewers.IContentProvider#dispose()
102
		 */
103
		public void dispose() {
104
		}
105
106
		/* (non-Javadoc)
107
		 * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
108
		 */
109
		public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
110
		}
111
		
112
	}
113
	/**
114
	 * @see org.eclipse.debug.ui.ILaunchConfigurationTab#createControl(org.eclipse.swt.widgets.Composite)
115
	 */
116
	public void createControl(Composite parent) {
117
		Composite mainComposite = new Composite(parent, SWT.NONE);
118
		setControl(mainComposite);
119
		PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IAntUIHelpContextIds.ANT_BUILD_TAB);
120
		
121
		GridLayout layout = new GridLayout();
122
		GridData gd = new GridData(GridData.FILL_HORIZONTAL);
123
		mainComposite.setLayout(layout);
124
		mainComposite.setLayoutData(gd);
125
		mainComposite.setFont(parent.getFont());
126
		
127
		fBuildButton = createCheckButton(mainComposite, AntLaunchConfigurationMessages.AntBuildTab_1);
128
		fBuildButton.addSelectionListener(new SelectionAdapter() {
129
			public void widgetSelected(SelectionEvent e) {
130
				updateEnabledState();
131
				updateLaunchConfigurationDialog();
132
			}
133
		});
134
		
135
		fGroup = new Group(mainComposite, SWT.NONE);
136
		fGroup.setFont(mainComposite.getFont());
137
		layout = new GridLayout();
138
		layout.numColumns = 2;
139
		layout.makeColumnsEqualWidth = false;
140
		fGroup.setLayout(layout);
141
		gd = new GridData(GridData.FILL_HORIZONTAL);
142
		gd.horizontalSpan = 2;
143
		fGroup.setLayoutData(gd);
144
145
		SelectionAdapter adapter = new SelectionAdapter() {
146
			public void widgetSelected(SelectionEvent e) {
147
				if (((Button)e.getSource()).getSelection()) {
148
					updateEnabledState();
149
					updateLaunchConfigurationDialog();
150
				}
151
			}
152
		};
153
		
154
		fWorkspaceButton = createRadioButton(fGroup, AntLaunchConfigurationMessages.AntBuildTab_2);
155
		gd = new GridData(GridData.FILL_HORIZONTAL);
156
		gd.horizontalSpan = 2;
157
		fWorkspaceButton.setLayoutData(gd);
158
		fWorkspaceButton.addSelectionListener(adapter);
159
		
160
		fProjectButton = createRadioButton(fGroup, AntLaunchConfigurationMessages.AntBuildTab_3);
161
		gd = new GridData(GridData.FILL_HORIZONTAL);
162
		gd.horizontalSpan = 2;
163
		fProjectButton.setLayoutData(gd);		
164
		fProjectButton.addSelectionListener(adapter);
165
				
166
		fSpecificProjectsButton = createRadioButton(fGroup, AntLaunchConfigurationMessages.AntBuildTab_4);
167
		gd = new GridData(GridData.FILL_HORIZONTAL);
168
		gd.horizontalSpan = 1;
169
		fSpecificProjectsButton.setLayoutData(gd);
170
		fSpecificProjectsButton.addSelectionListener(adapter);		
171
		
172
		fSelectButton = createPushButton(fGroup, AntLaunchConfigurationMessages.AntBuildTab_5, null);
173
		gd = (GridData)fSelectButton.getLayoutData();
174
		gd.horizontalAlignment = GridData.HORIZONTAL_ALIGN_END;
175
		fSelectButton.addSelectionListener(new SelectionAdapter() {
176
			public void widgetSelected(SelectionEvent e) {
177
				selectResources();
178
			}
179
		});
180
		
181
		createVerticalSpacer(mainComposite, 1);
182
		fReferencedProjects = createCheckButton(mainComposite, AntLaunchConfigurationMessages.AntBuildTab_6);
183
	}
184
185
	/**
186
	 * Prompts the user to select the projects to build.
187
	 */
188
	private void selectResources() {
189
		ListSelectionDialog dialog = new ListSelectionDialog(getShell(), ResourcesPlugin.getWorkspace(), new ProjectsContentProvider(), new WorkbenchLabelProvider(), AntLaunchConfigurationMessages.AntBuildTab_7);
190
		dialog.setInitialElementSelections(fProjects);
191
		if (dialog.open() == Window.CANCEL) {
192
			return;
193
		}
194
		Object[] res = dialog.getResult();
195
		fProjects = new ArrayList(res.length);
196
		for (int i = 0; i < res.length; i++) {
197
			fProjects.add(res[i]);
198
		}
199
		updateLaunchConfigurationDialog();
200
	}
201
	
202
	/**
203
	 * @see org.eclipse.debug.ui.ILaunchConfigurationTab#setDefaults(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)
204
	 */
205
	public void setDefaults(ILaunchConfigurationWorkingCopy configuration) {
206
	}
207
208
	/**
209
	 * @see org.eclipse.debug.ui.ILaunchConfigurationTab#initializeFrom(org.eclipse.debug.core.ILaunchConfiguration)
210
	 */
211
	public void initializeFrom(ILaunchConfiguration configuration) {
212
		updateScope(configuration);
213
		updateReferencedProjects(configuration);
214
		updateEnabledState();		
215
	}
216
	
217
	private void updateReferencedProjects(ILaunchConfiguration configuration) {
218
		boolean ref = false;
219
		try {
220
			ref = configuration.getAttribute(ATTR_INCLUDE_REFERENCED_PROJECTS, true);
221
		} catch (CoreException e) {
222
			AntUIPlugin.log(AntUIPlugin.newErrorStatus("Exception reading launch configuration", e)); //$NON-NLS-1$
223
		}
224
		fReferencedProjects.setSelection(ref);
225
	}
226
227
	/**
228
	 * Updates the tab to display the build scope specified by the launch config
229
	 */
230
	private void updateScope(ILaunchConfiguration configuration) {
231
		String scope = null;
232
		try {
233
			scope= configuration.getAttribute(ATTR_BUILD_SCOPE, (String)null);
234
		} catch (CoreException ce) {
235
			AntUIPlugin.log(AntUIPlugin.newErrorStatus("Exception reading launch configuration", ce)); //$NON-NLS-1$
236
		}
237
		fBuildButton.setSelection(scope != null);
238
		fWorkspaceButton.setSelection(false);
239
		fProjectButton.setSelection(false);
240
		fSpecificProjectsButton.setSelection(false);
241
		fProjects.clear();
242
		if (scope == null) {
243
			// select the workspace by default
244
			fBuildButton.setSelection(true);
245
			fWorkspaceButton.setSelection(true);
246
		} else {
247
			if (scope.equals("${none}")) { //$NON-NLS-1$
248
				fBuildButton.setSelection(false);
249
			} else if (scope.equals("${project}")) { //$NON-NLS-1$
250
				fProjectButton.setSelection(true);
251
			} else if (scope.startsWith("${projects:")) { //$NON-NLS-1$
252
				fSpecificProjectsButton.setSelection(true);
253
				IProject[] projects = getBuildProjects(scope);
254
				fProjects = new ArrayList(projects.length);
255
				for (int i = 0; i < projects.length; i++) {
256
					fProjects.add(projects[i]);
257
				}
258
			}
259
		}
260
	}
261
	/**
262
	 * @see org.eclipse.debug.ui.ILaunchConfigurationTab#performApply(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)
263
	 */
264
	public void performApply(ILaunchConfigurationWorkingCopy configuration) {
265
		String scope = generateScopeMemento();
266
		configuration.setAttribute(ATTR_BUILD_SCOPE, scope);
267
		if (fReferencedProjects.getSelection()) {
268
			// default is true
269
			configuration.setAttribute(ATTR_INCLUDE_REFERENCED_PROJECTS, (String)null);
270
		} else {
271
			configuration.setAttribute(ATTR_INCLUDE_REFERENCED_PROJECTS, false);
272
		}
273
	}
274
275
	/**
276
	 * Generates a memento for the build scope.
277
	 */
278
	private String generateScopeMemento() {
279
		if (fBuildButton.getSelection()) {
280
			if (fWorkspaceButton.getSelection()) {
281
				return null;
282
			}
283
			if (fProjectButton.getSelection()) {
284
				return "${project}"; //$NON-NLS-1$
285
			}
286
			if (fSpecificProjectsButton.getSelection()) {
287
				return getBuildScopeAttribute(fProjects);
288
			}
289
			return null;
290
			
291
		}
292
		return "${none}"; //$NON-NLS-1$
293
	}
294
295
	/**
296
	 * @see org.eclipse.debug.ui.ILaunchConfigurationTab#getName()
297
	 */
298
	public String getName() {
299
		return AntLaunchConfigurationMessages.AntBuildTab_8;
300
	}
301
	
302
	/**
303
	 * Updates the enablement state of the fields.
304
	 */
305
	private void updateEnabledState() {
306
		boolean enabled= fBuildButton.getSelection();
307
		fGroup.setEnabled(enabled);
308
		fWorkspaceButton.setEnabled(enabled);
309
		fProjectButton.setEnabled(enabled);
310
		fSpecificProjectsButton.setEnabled(enabled);
311
		fSelectButton.setEnabled(enabled && fSpecificProjectsButton.getSelection());
312
		if (!enabled) {
313
			super.setErrorMessage(null);
314
		}
315
		if (enabled) {
316
			if (!fWorkspaceButton.getSelection() && !fProjectButton.getSelection() &&
317
					!fSpecificProjectsButton.getSelection()) {
318
				fWorkspaceButton.setSelection(true);
319
			}
320
		}
321
		fReferencedProjects.setEnabled(fBuildButton.getSelection() && (fProjectButton.getSelection() || fSpecificProjectsButton.getSelection()));
322
	}
323
	
324
	/**
325
	 * @see org.eclipse.debug.ui.ILaunchConfigurationTab#getImage()
326
	 */
327
	public Image getImage() {
328
		return AntUIImages.getImage(IAntUIConstants.IMG_ANT_BUILD_TAB);
329
	}
330
331
	public boolean isValid(ILaunchConfiguration launchConfig) {
332
		setErrorMessage(null);
333
		setMessage(null);
334
		if (fBuildButton.getSelection() && fSpecificProjectsButton.getSelection() && fProjects.isEmpty()) {
335
			setErrorMessage(AntLaunchConfigurationMessages.AntBuildTab_9);
336
			return false;
337
		}
338
		return true;
339
	}
340
	
341
	/**
342
	 * Returns a collection of projects referenced by a build scope attribute.
343
	 * 
344
	 * @param scope build scope attribute (<code>ATTR_BUILD_SCOPE</code>)
345
	 * @return collection of porjects referred to by the scope attribute
346
	 */
347
	public static IProject[] getBuildProjects(String scope) {
348
		if (scope.startsWith("${projects:")) { //$NON-NLS-1$
349
			String pathString = scope.substring(11, scope.length() - 1);
350
			if (pathString.length() > 1) {
351
				String[] names = pathString.split(","); //$NON-NLS-1$
352
				IProject[] projects = new IProject[names.length];
353
				IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
354
				for (int i = 0; i < names.length; i++) {
355
					projects[i] = root.getProject(names[i]);
356
				}
357
				return projects;
358
			}
359
		} else if (scope.equals("${project}")) { //$NON-NLS-1$
360
			IResource resource = DebugUITools.getSelectedResource();
361
			if (resource != null) {
362
				return new IProject[]{resource.getProject()};
363
			}
364
		}
365
		return new IProject[0];
366
	}
367
	
368
	/**
369
	 * Returns the build scope attribute specified by the given launch configuration
370
	 * or <code>null</code> if none.
371
	 * 
372
	 * @param configuration launch configuration
373
	 * @return build scope attribute (<code>ATTR_BUILD_SCOPE</code>)
374
	 * @throws CoreException if unable to access the associated attribute
375
	 */
376
	public static String getBuildScope(ILaunchConfiguration configuration) throws CoreException {
377
		return configuration.getAttribute(ATTR_BUILD_SCOPE, (String) null);
378
	}
379
	
380
	/**
381
	 * Whether referenced projects should be considered when building. Only valid
382
	 * when a set of projects is to be built.
383
	 * 
384
	 * @param configuration
385
	 * @return whether referenced projects should be considerd when building
386
	 * @throws CoreException if unable to access the associated attribute
387
	 */
388
	public static boolean isIncludeReferencedProjects(ILaunchConfiguration configuration) throws CoreException {
389
		return configuration.getAttribute(ATTR_INCLUDE_REFERENCED_PROJECTS, true);
390
	}
391
	
392
	/**
393
	 * Creates and returns a memento for the given project set, to be used as a
394
	 * build scope attribute.
395
	 * 
396
	 * @param projects list of projects
397
	 * @return an equivalent refresh attribute
398
	 */
399
	public static String getBuildScopeAttribute(List projects) {
400
		StringBuffer buf = new StringBuffer();
401
		buf.append("${projects:"); //$NON-NLS-1$
402
		Iterator iterator = projects.iterator();
403
		while (iterator.hasNext()) {
404
			IProject project = (IProject) iterator.next();
405
			buf.append(project.getName());
406
			if (iterator.hasNext()) {
407
				buf.append(","); //$NON-NLS-1$
408
			}
409
		}
410
		buf.append("}"); //$NON-NLS-1$
411
		return buf.toString();
412
	}
413
	
414
	/* (non-Javadoc)
41
	/* (non-Javadoc)
415
	 * @see org.eclipse.debug.ui.ILaunchConfigurationTab#activated(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)
42
	 * @see org.eclipse.ui.externaltools.internal.launchConfigurations.ExternalToolsBuildTab#getAttrIncludeReferencedProjectsId()
416
	 */
43
	 */
417
	public void activated(ILaunchConfigurationWorkingCopy workingCopy) {
44
	protected String getAttrIncludeReferencedProjectsId() {
418
		// do nothing on activation
45
		return ATTR_INCLUDE_REFERENCED_PROJECTS ;
419
	}
46
	}
420
47
	
421
	/* (non-Javadoc)
48
	/* (non-Javadoc)
422
	 * @see org.eclipse.debug.ui.ILaunchConfigurationTab#deactivated(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)
49
	 * @see org.eclipse.ui.externaltools.internal.launchConfigurations.ExternalToolsBuildTab#getAttrBuildScopeId()
423
	 */
50
	 */
424
	public void deactivated(ILaunchConfigurationWorkingCopy workingCopy) {
51
	protected String getAttrBuildScopeId() {
425
		// do nothing on deactivation
52
		return ATTR_BUILD_SCOPE ;
426
	}
53
	}
427
}
54
}
(-)Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntLaunchDelegate.java (-11 / +5 lines)
Lines 66-71 Link Here
66
import org.eclipse.jface.dialogs.MessageDialogWithToggle;
66
import org.eclipse.jface.dialogs.MessageDialogWithToggle;
67
import org.eclipse.jface.preference.IPreferenceStore;
67
import org.eclipse.jface.preference.IPreferenceStore;
68
import org.eclipse.osgi.service.resolver.BundleDescription;
68
import org.eclipse.osgi.service.resolver.BundleDescription;
69
import org.eclipse.ui.externaltools.internal.launchConfigurations.ExternalToolsBuildTab;
69
import org.eclipse.ui.externaltools.internal.launchConfigurations.ExternalToolsUtil;
70
import org.eclipse.ui.externaltools.internal.launchConfigurations.ExternalToolsUtil;
70
import org.eclipse.ui.externaltools.internal.model.IExternalToolConstants;
71
import org.eclipse.ui.externaltools.internal.model.IExternalToolConstants;
71
import org.eclipse.ui.externaltools.internal.program.launchConfigurations.BackgroundResourceRefresher;
72
import org.eclipse.ui.externaltools.internal.program.launchConfigurations.BackgroundResourceRefresher;
Lines 668-684 Link Here
668
	 * @see org.eclipse.debug.core.model.LaunchConfigurationDelegate#getBuildOrder(org.eclipse.debug.core.ILaunchConfiguration, java.lang.String)
669
	 * @see org.eclipse.debug.core.model.LaunchConfigurationDelegate#getBuildOrder(org.eclipse.debug.core.ILaunchConfiguration, java.lang.String)
669
	 */
670
	 */
670
	protected IProject[] getBuildOrder(ILaunchConfiguration configuration, String mode) throws CoreException {
671
	protected IProject[] getBuildOrder(ILaunchConfiguration configuration, String mode) throws CoreException {
671
		String scope = null;
672
		IProject[] projects = ExternalToolsBuildTab.getBuildProjects(configuration, AntBuildTab.ATTR_BUILD_SCOPE);
672
		try {
673
		if (projects == null)
673
			scope = configuration.getAttribute(AntBuildTab.ATTR_BUILD_SCOPE, (String)null);
674
			return null ;
674
		} catch (CoreException e) {
675
		boolean isRef = ExternalToolsBuildTab.isIncludeReferencedProjects(configuration, AntBuildTab.ATTR_INCLUDE_REFERENCED_PROJECTS);
675
			return null;
676
		}
677
		if (scope == null) {
678
			return null;
679
		}
680
		IProject[] projects = AntBuildTab.getBuildProjects(scope);
681
		boolean isRef = AntBuildTab.isIncludeReferencedProjects(configuration);
682
		if (isRef) {
676
		if (isRef) {
683
			return computeReferencedBuildOrder(projects);
677
			return computeReferencedBuildOrder(projects);
684
		}
678
		}
(-)External Tools Base/org/eclipse/ui/externaltools/internal/launchConfigurations/ExternalToolsUtil.java (-1 / +1 lines)
Lines 172-178 Link Here
172
	 * @throws CoreException if an exception occurs while retrieving the resources
172
	 * @throws CoreException if an exception occurs while retrieving the resources
173
	 */
173
	 */
174
	public static IResource[] getResourcesForBuildScope(ILaunchConfiguration configuration) throws CoreException {
174
	public static IResource[] getResourcesForBuildScope(ILaunchConfiguration configuration) throws CoreException {
175
		String scope = configuration.getAttribute(IExternalToolConstants.ATTR_BUILD_SCOPE, (String) null);
175
		String scope = configuration.getAttribute(IExternalToolConstants.ATTR_BUILDER_SCOPE, (String) null);
176
		if (scope == null) {
176
		if (scope == null) {
177
			return null;
177
			return null;
178
		}
178
		}
(-)External Tools Base/org/eclipse/ui/externaltools/internal/launchConfigurations/ExternalToolsBuilderTab.java (-3 / +3 lines)
Lines 316-322 Link Here
316
		String buildScope= null;
316
		String buildScope= null;
317
		try {
317
		try {
318
			buildKindString= configuration.getAttribute(IExternalToolConstants.ATTR_RUN_BUILD_KINDS, ""); //$NON-NLS-1$
318
			buildKindString= configuration.getAttribute(IExternalToolConstants.ATTR_RUN_BUILD_KINDS, ""); //$NON-NLS-1$
319
			buildScope= configuration.getAttribute(IExternalToolConstants.ATTR_BUILD_SCOPE, (String)null);
319
			buildScope= configuration.getAttribute(IExternalToolConstants.ATTR_BUILDER_SCOPE, (String)null);
320
		} catch (CoreException e) {
320
		} catch (CoreException e) {
321
		}
321
		}
322
		
322
		
Lines 426-434 Link Here
426
        }
426
        }
427
		if (workingSetButton.getSelection()) {
427
		if (workingSetButton.getSelection()) {
428
			String scope = RefreshTab.getRefreshAttribute(workingSet);
428
			String scope = RefreshTab.getRefreshAttribute(workingSet);
429
			configuration.setAttribute(IExternalToolConstants.ATTR_BUILD_SCOPE, scope);
429
			configuration.setAttribute(IExternalToolConstants.ATTR_BUILDER_SCOPE, scope);
430
		} else {
430
		} else {
431
			configuration.setAttribute(IExternalToolConstants.ATTR_BUILD_SCOPE, (String)null);
431
			configuration.setAttribute(IExternalToolConstants.ATTR_BUILDER_SCOPE, (String)null);
432
		}
432
		}
433
		configuration.setAttribute(IDebugUIConstants.ATTR_LAUNCH_IN_BACKGROUND, fLaunchInBackgroundButton.getSelection());
433
		configuration.setAttribute(IDebugUIConstants.ATTR_LAUNCH_IN_BACKGROUND, fLaunchInBackgroundButton.getSelection());
434
        
434
        
(-)External Tools Base/org/eclipse/ui/externaltools/internal/launchConfigurations/ExternalToolsLaunchConfigurationMessages.java (+11 lines)
Lines 37-42 Link Here
37
	public static String ExternalToolsMainTab_31;
37
	public static String ExternalToolsMainTab_31;
38
	public static String ExternalToolsMainTab_32;
38
	public static String ExternalToolsMainTab_32;
39
39
40
	public static String ExternalToolsBuildTab_1;
41
	public static String ExternalToolsBuildTab_2;
42
	public static String ExternalToolsBuildTab_3;
43
	public static String ExternalToolsBuildTab_4;
44
	public static String ExternalToolsBuildTab_5;
45
	public static String ExternalToolsBuildTab_6;
46
	public static String ExternalToolsBuildTab_7;
47
	public static String ExternalToolsBuildTab_8;
48
	public static String ExternalToolsBuildTab_9;
49
50
40
	public static String ExternalToolsUtil_Location_not_specified_by__0__1;
51
	public static String ExternalToolsUtil_Location_not_specified_by__0__1;
41
	public static String ExternalToolsUtil_invalidLocation__0_;
52
	public static String ExternalToolsUtil_invalidLocation__0_;
42
	public static String ExternalToolsUtil_invalidDirectory__0_;
53
	public static String ExternalToolsUtil_invalidDirectory__0_;
(-)External Tools Base/org/eclipse/ui/externaltools/internal/launchConfigurations/ExternalToolsLaunchConfigurationMessages.properties (+10 lines)
Lines 32-37 Link Here
32
ExternalToolsMainTab_31=Var&iables...
32
ExternalToolsMainTab_31=Var&iables...
33
ExternalToolsMainTab_32=Varia&bles...
33
ExternalToolsMainTab_32=Varia&bles...
34
34
35
ExternalToolsBuildTab_1=&Build before launch
36
ExternalToolsBuildTab_2=The &entire workspace
37
ExternalToolsBuildTab_3=The &project containing the selected resource
38
ExternalToolsBuildTab_4=&Specific projects
39
ExternalToolsBuildTab_5=P&rojects...
40
ExternalToolsBuildTab_6=Include referenced pro&jects
41
ExternalToolsBuildTab_7=Select &Projects:
42
ExternalToolsBuildTab_8=Build
43
ExternalToolsBuildTab_9=No projects specified
44
35
ExternalToolsUtil_Location_not_specified_by__0__1=Location not specified by {0}
45
ExternalToolsUtil_Location_not_specified_by__0__1=Location not specified by {0}
36
ExternalToolsUtil_invalidLocation__0_ = The file does not exist for the external tool named {0}.
46
ExternalToolsUtil_invalidLocation__0_ = The file does not exist for the external tool named {0}.
37
ExternalToolsUtil_invalidDirectory__0_ = The working directory {0} does not exist for the external tool named {1}.
47
ExternalToolsUtil_invalidDirectory__0_ = The working directory {0} does not exist for the external tool named {1}.
(-)Program Tools Support/org/eclipse/ui/externaltools/internal/program/launchConfigurations/ProgramTabGroup.java (+2 lines)
Lines 16-21 Link Here
16
import org.eclipse.debug.ui.ILaunchConfigurationDialog;
16
import org.eclipse.debug.ui.ILaunchConfigurationDialog;
17
import org.eclipse.debug.ui.ILaunchConfigurationTab;
17
import org.eclipse.debug.ui.ILaunchConfigurationTab;
18
import org.eclipse.debug.ui.RefreshTab;
18
import org.eclipse.debug.ui.RefreshTab;
19
import org.eclipse.ui.externaltools.internal.launchConfigurations.ExternalToolsBuildTab;
19
20
20
public class ProgramTabGroup extends AbstractLaunchConfigurationTabGroup {
21
public class ProgramTabGroup extends AbstractLaunchConfigurationTabGroup {
21
22
Lines 26-31 Link Here
26
		ILaunchConfigurationTab[] tabs = new ILaunchConfigurationTab[] {
27
		ILaunchConfigurationTab[] tabs = new ILaunchConfigurationTab[] {
27
			new ProgramMainTab(),
28
			new ProgramMainTab(),
28
			new RefreshTab(),
29
			new RefreshTab(),
30
			new ExternalToolsBuildTab(),
29
			new EnvironmentTab(),
31
			new EnvironmentTab(),
30
			new CommonTab()
32
			new CommonTab()
31
		};
33
		};
(-)Program Tools Support/org/eclipse/ui/externaltools/internal/program/launchConfigurations/ProgramLaunchDelegate.java (-4 / +19 lines)
Lines 16-21 Link Here
16
import java.util.HashMap;
16
import java.util.HashMap;
17
import java.util.Map;
17
import java.util.Map;
18
18
19
import org.eclipse.core.resources.IProject;
19
import org.eclipse.core.runtime.CoreException;
20
import org.eclipse.core.runtime.CoreException;
20
import org.eclipse.core.runtime.IPath;
21
import org.eclipse.core.runtime.IPath;
21
import org.eclipse.core.runtime.IProgressMonitor;
22
import org.eclipse.core.runtime.IProgressMonitor;
Lines 35-40 Link Here
35
import org.eclipse.ui.IWindowListener;
36
import org.eclipse.ui.IWindowListener;
36
import org.eclipse.ui.IWorkbenchWindow;
37
import org.eclipse.ui.IWorkbenchWindow;
37
import org.eclipse.ui.PlatformUI;
38
import org.eclipse.ui.PlatformUI;
39
import org.eclipse.ui.externaltools.internal.launchConfigurations.ExternalToolsBuildTab;
38
import org.eclipse.ui.externaltools.internal.launchConfigurations.ExternalToolsUtil;
40
import org.eclipse.ui.externaltools.internal.launchConfigurations.ExternalToolsUtil;
39
import org.eclipse.ui.externaltools.internal.model.IExternalToolConstants;
41
import org.eclipse.ui.externaltools.internal.model.IExternalToolConstants;
40
42
Lines 165-175 Link Here
165
		if (p != null) {
167
		if (p != null) {
166
			monitor.beginTask(NLS.bind(ExternalToolsProgramMessages.ProgramLaunchDelegate_3, new String[] {configuration.getName()}), IProgressMonitor.UNKNOWN);
168
			monitor.beginTask(NLS.bind(ExternalToolsProgramMessages.ProgramLaunchDelegate_3, new String[] {configuration.getName()}), IProgressMonitor.UNKNOWN);
167
			process = DebugPlugin.newProcess(launch, p, location.toOSString(), processAttributes);
169
			process = DebugPlugin.newProcess(launch, p, location.toOSString(), processAttributes);
168
			if (process == null) {
170
		}
171
		if (p == null || process == null) {
172
			if (p != null)
169
				p.destroy();
173
				p.destroy();
170
				throw new CoreException(new Status(IStatus.ERROR, IExternalToolConstants.PLUGIN_ID, IExternalToolConstants.ERR_INTERNAL_ERROR, ExternalToolsProgramMessages.ProgramLaunchDelegate_4, null));
174
			throw new CoreException(new Status(IStatus.ERROR, IExternalToolConstants.PLUGIN_ID, IExternalToolConstants.ERR_INTERNAL_ERROR, ExternalToolsProgramMessages.ProgramLaunchDelegate_4, null));
171
			}
172
			
173
		}
175
		}
174
		process.setAttribute(IProcess.ATTR_CMDLINE, generateCommandLine(cmdLine));
176
		process.setAttribute(IProcess.ATTR_CMDLINE, generateCommandLine(cmdLine));
175
		
177
		
Lines 226-229 Link Here
226
		return buf.toString();
228
		return buf.toString();
227
	}	
229
	}	
228
	
230
	
231
    /* (non-Javadoc)
232
	 * @see org.eclipse.debug.core.model.LaunchConfigurationDelegate#getBuildOrder(org.eclipse.debug.core.ILaunchConfiguration, java.lang.String)
233
	 */
234
	protected IProject[] getBuildOrder(ILaunchConfiguration configuration, String mode) throws CoreException {
235
		IProject[] projects = ExternalToolsBuildTab.getBuildProjects(configuration, null);
236
		if (projects == null)
237
			return null ;
238
		boolean isRef = ExternalToolsBuildTab.isIncludeReferencedProjects(configuration, null);
239
		if (isRef) {
240
			return computeReferencedBuildOrder(projects);
241
		}
242
		return computeBuildOrder(projects);
243
	}
229
}
244
}
(-)External Tools Base/org/eclipse/ui/externaltools/internal/model/ExternalToolsImages.java (+1 lines)
Lines 51-56 Link Here
51
	private static void declareImages() {		
51
	private static void declareImages() {		
52
		// Objects
52
		// Objects
53
		declareRegistryImage(IExternalToolConstants.IMG_TAB_MAIN, OBJECT + "main_tab.gif"); //$NON-NLS-1$
53
		declareRegistryImage(IExternalToolConstants.IMG_TAB_MAIN, OBJECT + "main_tab.gif"); //$NON-NLS-1$
54
		declareRegistryImage(IExternalToolConstants.IMG_TAB_BUILD, OBJECT + "build_tab.gif"); //$NON-NLS-1$
54
	}
55
	}
55
56
56
	/**
57
	/**
(-)External Tools Base/org/eclipse/ui/externaltools/internal/model/IExternalToolsHelpContextIds.java (+1 lines)
Lines 34-37 Link Here
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$
36
	public static final String EXTERNAL_TOOLS_LAUNCH_CONFIGURATION_DIALOG_PROGRAM_MAIN_TAB = PREFIX + "program_main_tab_context"; //$NON-NLS-1$
36
	public static final String EXTERNAL_TOOLS_LAUNCH_CONFIGURATION_DIALOG_PROGRAM_MAIN_TAB = PREFIX + "program_main_tab_context"; //$NON-NLS-1$
37
	public static final String EXTERNAL_TOOLS_LAUNCH_CONFIGURATION_DIALOG_BUILD_TAB = PREFIX + "build_tab_context"; //$NON-NLS-1$
37
}
38
}
(-)External Tools Base/org/eclipse/ui/externaltools/internal/model/IExternalToolConstants.java (-3 / +20 lines)
Lines 93-99 Link Here
93
	 * Main tab image.
93
	 * Main tab image.
94
	 */
94
	 */
95
	public static final String IMG_TAB_MAIN = PLUGIN_ID + ".IMG_TAB_MAIN"; //$NON-NLS-1$
95
	public static final String IMG_TAB_MAIN = PLUGIN_ID + ".IMG_TAB_MAIN"; //$NON-NLS-1$
96
	
96
97
	/**
98
	 * Build tab image
99
	 */
100
	public static final String IMG_TAB_BUILD = PLUGIN_ID + ".IMG_TAB_BUILD"; //$NON-NLS-1$
101
97
	// ------- Launch configuration types --------
102
	// ------- Launch configuration types --------
98
	/**
103
	/**
99
	 * Program launch configuration type identifier.
104
	 * Program launch configuration type identifier.
Lines 158-166 Link Here
158
	 * external tool to run. Default value is <code>null</code>
163
	 * external tool to run. Default value is <code>null</code>
159
	 * indicating that the builder will be triggered for all changes.
164
	 * indicating that the builder will be triggered for all changes.
160
	 */
165
	 */
161
	public static final String ATTR_BUILD_SCOPE = PLUGIN_ID + ".ATTR_BUILD_SCOPE"; //$NON-NLS-1$
166
	public static final String ATTR_BUILDER_SCOPE = PLUGIN_ID + ".ATTR_BUILDER_SCOPE"; //$NON-NLS-1$
162
		
167
		
163
	
164
	/**
168
	/**
165
	 * String attribute containing an array of build kinds for which an
169
	 * String attribute containing an array of build kinds for which an
166
	 * external tool builder should be run.
170
	 * external tool builder should be run.
Lines 210-213 Link Here
210
	 * @since 3.1
214
	 * @since 3.1
211
	 */
215
	 */
212
	public static final String ATTR_TRIGGERS_CONFIGURED = PLUGIN_ID + ".ATTR_TRIGGERS_CONFIGURED";		 //$NON-NLS-1$
216
	public static final String ATTR_TRIGGERS_CONFIGURED = PLUGIN_ID + ".ATTR_TRIGGERS_CONFIGURED";		 //$NON-NLS-1$
217
218
	/**
219
	 * String attribute identifying the build scope for this launch configuration.
220
	 * <code>null</code> indicates the default workspace build.
221
	 */
222
	public static final String ATTR_BUILD_SCOPE = PLUGIN_ID + ".ATTR_BUILD_SCOPE"; //$NON-NLS-1$
223
224
	/**
225
	 * Attribute identifier specifying whether referenced projects should be 
226
	 * considered when computing the projects to build. Default value is
227
	 * <code>true</code>.
228
	 */
229
	public static final String ATTR_INCLUDE_REFERENCED_PROJECTS = PLUGIN_ID + ".ATTR_INCLUDE_REFERENCED_PROJECTS"; //$NON-NLS-1$
213
}
230
}
(-)icons/full/obj16/build_tab.gif (+5 lines)
Added Link Here
1
GIF89aæôöüøùüÈÎÝõ÷üôöû¯·Ég}©j€«…“®†“®òõûöøüùúüøùûmƒ­tŠ³s‰²z·€•»–»ŠžÂ…”¯…”®†”®‘žµïóú2]‡œÀ¢Ä‘¥Ç‰–¬²½ÏÞèøóöû˜©Þè÷åíùêðù÷ùüöøûàêøìòúô÷û‘›§âì÷çïøøúü—ž£¡¤œ¦¨™«ª•°­’µ°±­‘¼µŠ¹³Œ¿¶ˆ¼´‰º²ŒàȏԲhÔ²iÚ½|Õ²iÿÿÿ!ù@,ž€@‚ƒ„…ƒ8ˆ‰‰†@8=8†8&
2
3
.&>?”„9';><6„7!*±*±:„4
4
5
4„5ÈÉÊ3„2)ÏÐÑ2„1%%Ö؃0-Ü-Üâæƒ/$ã$æìé‚+,ã,ïõò@"(Û(ïú}äa„ÁƒA| „ ‚,\¨p!A‚;
(-)External (+433 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.ui.externaltools.internal.launchConfigurations;
12
13
14
import java.util.ArrayList;
15
import java.util.Iterator;
16
import java.util.List;
17
18
import org.eclipse.core.resources.IProject;
19
import org.eclipse.core.resources.IResource;
20
import org.eclipse.core.resources.IWorkspace;
21
import org.eclipse.core.resources.IWorkspaceRoot;
22
import org.eclipse.core.resources.ResourcesPlugin;
23
import org.eclipse.core.runtime.CoreException;
24
import org.eclipse.debug.core.ILaunchConfiguration;
25
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
26
import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
27
import org.eclipse.debug.ui.DebugUITools;
28
import org.eclipse.jface.viewers.IStructuredContentProvider;
29
import org.eclipse.jface.viewers.Viewer;
30
import org.eclipse.jface.window.Window;
31
import org.eclipse.swt.SWT;
32
import org.eclipse.swt.events.SelectionAdapter;
33
import org.eclipse.swt.events.SelectionEvent;
34
import org.eclipse.swt.graphics.Image;
35
import org.eclipse.swt.layout.GridData;
36
import org.eclipse.swt.layout.GridLayout;
37
import org.eclipse.swt.widgets.Button;
38
import org.eclipse.swt.widgets.Composite;
39
import org.eclipse.swt.widgets.Group;
40
import org.eclipse.ui.PlatformUI;
41
import org.eclipse.ui.dialogs.ListSelectionDialog;
42
import org.eclipse.ui.externaltools.internal.model.ExternalToolsImages;
43
import org.eclipse.ui.externaltools.internal.model.ExternalToolsPlugin;
44
import org.eclipse.ui.externaltools.internal.model.IExternalToolConstants;
45
import org.eclipse.ui.externaltools.internal.model.IExternalToolsHelpContextIds;
46
import org.eclipse.ui.model.WorkbenchLabelProvider;
47
48
/**
49
 * A launch configuration tab which allows the user to specify
50
 * which resources should be built before a build (a build scope)
51
 * <p>
52
 * This class may be instantiated; this class is not intended
53
 * to be subclassed.
54
 * </p>
55
 * @since 3.0
56
 */
57
public class ExternalToolsBuildTab extends AbstractLaunchConfigurationTab {
58
	// Check Buttons
59
	private Button fBuildButton;
60
	
61
	// Group box
62
	private Group fGroup;
63
	
64
	// Radio Buttons
65
	private Button fProjectButton;
66
	private Button fSpecificProjectsButton;
67
	private Button fWorkspaceButton;
68
	
69
	// Push Button
70
	private Button fSelectButton;
71
	
72
	// whether to include referenced projects
73
	private Button fReferencedProjects;
74
	
75
	// projects to build (empty if none)
76
	private List fProjects = new ArrayList();
77
	
78
	class ProjectsContentProvider implements IStructuredContentProvider {
79
80
		/* (non-Javadoc)
81
		 * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
82
		 */
83
		public Object[] getElements(Object inputElement) {
84
			return ((IWorkspace)inputElement).getRoot().getProjects();
85
		}
86
87
		/* (non-Javadoc)
88
		 * @see org.eclipse.jface.viewers.IContentProvider#dispose()
89
		 */
90
		public void dispose() {
91
		}
92
93
		/* (non-Javadoc)
94
		 * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
95
		 */
96
		public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
97
		}
98
		
99
	}
100
	/**
101
	 * @see org.eclipse.debug.ui.ILaunchConfigurationTab#createControl(org.eclipse.swt.widgets.Composite)
102
	 */
103
	public void createControl(Composite parent) {
104
		Composite mainComposite = new Composite(parent, SWT.NONE);
105
		setControl(mainComposite);
106
		PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IExternalToolsHelpContextIds.EXTERNAL_TOOLS_LAUNCH_CONFIGURATION_DIALOG_BUILD_TAB);
107
		
108
		GridLayout layout = new GridLayout();
109
		GridData gd = new GridData(GridData.FILL_HORIZONTAL);
110
		mainComposite.setLayout(layout);
111
		mainComposite.setLayoutData(gd);
112
		mainComposite.setFont(parent.getFont());
113
		
114
		fBuildButton = createCheckButton(mainComposite, ExternalToolsLaunchConfigurationMessages.ExternalToolsBuildTab_1);
115
		fBuildButton.addSelectionListener(new SelectionAdapter() {
116
			public void widgetSelected(SelectionEvent e) {
117
				updateEnabledState();
118
				updateLaunchConfigurationDialog();
119
			}
120
		});
121
		
122
		fGroup = new Group(mainComposite, SWT.NONE);
123
		fGroup.setFont(mainComposite.getFont());
124
		layout = new GridLayout();
125
		layout.numColumns = 2;
126
		layout.makeColumnsEqualWidth = false;
127
		fGroup.setLayout(layout);
128
		gd = new GridData(GridData.FILL_HORIZONTAL);
129
		gd.horizontalSpan = 2;
130
		fGroup.setLayoutData(gd);
131
132
		SelectionAdapter adapter = new SelectionAdapter() {
133
			public void widgetSelected(SelectionEvent e) {
134
				if (((Button)e.getSource()).getSelection()) {
135
					updateEnabledState();
136
					updateLaunchConfigurationDialog();
137
				}
138
			}
139
		};
140
		
141
		fWorkspaceButton = createRadioButton(fGroup, ExternalToolsLaunchConfigurationMessages.ExternalToolsBuildTab_2);
142
		gd = new GridData(GridData.FILL_HORIZONTAL);
143
		gd.horizontalSpan = 2;
144
		fWorkspaceButton.setLayoutData(gd);
145
		fWorkspaceButton.addSelectionListener(adapter);
146
		
147
		fProjectButton = createRadioButton(fGroup, ExternalToolsLaunchConfigurationMessages.ExternalToolsBuildTab_3);
148
		gd = new GridData(GridData.FILL_HORIZONTAL);
149
		gd.horizontalSpan = 2;
150
		fProjectButton.setLayoutData(gd);		
151
		fProjectButton.addSelectionListener(adapter);
152
				
153
		fSpecificProjectsButton = createRadioButton(fGroup, ExternalToolsLaunchConfigurationMessages.ExternalToolsBuildTab_4);
154
		gd = new GridData(GridData.FILL_HORIZONTAL);
155
		gd.horizontalSpan = 1;
156
		fSpecificProjectsButton.setLayoutData(gd);
157
		fSpecificProjectsButton.addSelectionListener(adapter);		
158
		
159
		fSelectButton = createPushButton(fGroup, ExternalToolsLaunchConfigurationMessages.ExternalToolsBuildTab_5, null);
160
		gd = (GridData)fSelectButton.getLayoutData();
161
		gd.horizontalAlignment = GridData.HORIZONTAL_ALIGN_END;
162
		fSelectButton.addSelectionListener(new SelectionAdapter() {
163
			public void widgetSelected(SelectionEvent e) {
164
				selectResources();
165
			}
166
		});
167
		
168
		createVerticalSpacer(mainComposite, 1);
169
		fReferencedProjects = createCheckButton(mainComposite, ExternalToolsLaunchConfigurationMessages.ExternalToolsBuildTab_6);
170
	}
171
172
	/**
173
	 * Prompts the user to select the projects to build.
174
	 */
175
	private void selectResources() {
176
		ListSelectionDialog dialog = new ListSelectionDialog(getShell(), ResourcesPlugin.getWorkspace(), new ProjectsContentProvider(), new WorkbenchLabelProvider(), ExternalToolsLaunchConfigurationMessages.ExternalToolsBuildTab_7);
177
		dialog.setInitialElementSelections(fProjects);
178
		if (dialog.open() == Window.CANCEL) {
179
			return;
180
		}
181
		Object[] res = dialog.getResult();
182
		fProjects = new ArrayList(res.length);
183
		for (int i = 0; i < res.length; i++) {
184
			fProjects.add(res[i]);
185
		}
186
		updateLaunchConfigurationDialog();
187
	}
188
	
189
	/**
190
	 * @see org.eclipse.debug.ui.ILaunchConfigurationTab#setDefaults(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)
191
	 */
192
	public void setDefaults(ILaunchConfigurationWorkingCopy configuration) {
193
	}
194
195
	/**
196
	 * @see org.eclipse.debug.ui.ILaunchConfigurationTab#initializeFrom(org.eclipse.debug.core.ILaunchConfiguration)
197
	 */
198
	public void initializeFrom(ILaunchConfiguration configuration) {
199
		updateScope(configuration);
200
		updateReferencedProjects(configuration);
201
		updateEnabledState();		
202
	}
203
	
204
	private void updateReferencedProjects(ILaunchConfiguration configuration) {
205
		boolean ref = false;
206
		try {
207
			ref = configuration.getAttribute(getAttrIncludeReferencedProjectsId(), true);
208
		} catch (CoreException e) {
209
			ExternalToolsPlugin.getDefault().log("Exception reading launch configuration", e); //$NON-NLS-1$
210
		}
211
		fReferencedProjects.setSelection(ref);
212
	}
213
214
	/**
215
	 * Updates the tab to display the build scope specified by the launch config
216
	 */
217
	private void updateScope(ILaunchConfiguration configuration) {
218
		String scope = null;
219
		try {
220
			scope= configuration.getAttribute(getAttrBuildScopeId(), (String)null);
221
		} catch (CoreException ce) {
222
			ExternalToolsPlugin.getDefault().log("Exception reading launch configuration", ce); //$NON-NLS-1$
223
		}
224
		fBuildButton.setSelection(scope != null);
225
		fWorkspaceButton.setSelection(false);
226
		fProjectButton.setSelection(false);
227
		fSpecificProjectsButton.setSelection(false);
228
		fProjects.clear();
229
		if (scope == null) {
230
			// select the workspace by default
231
			fBuildButton.setSelection(true);
232
			fWorkspaceButton.setSelection(true);
233
		} else {
234
			if (scope.equals("${none}")) { //$NON-NLS-1$
235
				fBuildButton.setSelection(false);
236
			} else if (scope.equals("${project}")) { //$NON-NLS-1$
237
				fProjectButton.setSelection(true);
238
			} else if (scope.startsWith("${projects:")) { //$NON-NLS-1$
239
				fSpecificProjectsButton.setSelection(true);
240
				IProject[] projects = getBuildProjects(configuration, getAttrBuildScopeId());
241
				fProjects = new ArrayList(projects.length);
242
				for (int i = 0; i < projects.length; i++) {
243
					fProjects.add(projects[i]);
244
				}
245
			}
246
		}
247
	}
248
	/**
249
	 * @see org.eclipse.debug.ui.ILaunchConfigurationTab#performApply(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)
250
	 */
251
	public void performApply(ILaunchConfigurationWorkingCopy configuration) {
252
		String scope = generateScopeMemento();
253
		configuration.setAttribute(getAttrBuildScopeId(), scope);
254
		if (fReferencedProjects.getSelection()) {
255
			// default is true
256
			configuration.setAttribute(getAttrIncludeReferencedProjectsId(), (String)null);
257
		} else {
258
			configuration.setAttribute(getAttrIncludeReferencedProjectsId(), false);
259
		}
260
	}
261
262
	/**
263
	 * Generates a memento for the build scope.
264
	 */
265
	private String generateScopeMemento() {
266
		if (fBuildButton.getSelection()) {
267
			if (fWorkspaceButton.getSelection()) {
268
				return null;
269
			}
270
			if (fProjectButton.getSelection()) {
271
				return "${project}"; //$NON-NLS-1$
272
			}
273
			if (fSpecificProjectsButton.getSelection()) {
274
				return getBuildScopeAttribute(fProjects);
275
			}
276
			return null;
277
			
278
		}
279
		return "${none}"; //$NON-NLS-1$
280
	}
281
282
	/**
283
	 * @see org.eclipse.debug.ui.ILaunchConfigurationTab#getName()
284
	 */
285
	public String getName() {
286
		return ExternalToolsLaunchConfigurationMessages.ExternalToolsBuildTab_8;
287
	}
288
	
289
	/**
290
	 * Updates the enablement state of the fields.
291
	 */
292
	private void updateEnabledState() {
293
		boolean enabled= fBuildButton.getSelection();
294
		fGroup.setEnabled(enabled);
295
		fWorkspaceButton.setEnabled(enabled);
296
		fProjectButton.setEnabled(enabled);
297
		fSpecificProjectsButton.setEnabled(enabled);
298
		fSelectButton.setEnabled(enabled && fSpecificProjectsButton.getSelection());
299
		if (!enabled) {
300
			super.setErrorMessage(null);
301
		}
302
		if (enabled) {
303
			if (!fWorkspaceButton.getSelection() && !fProjectButton.getSelection() &&
304
					!fSpecificProjectsButton.getSelection()) {
305
				fWorkspaceButton.setSelection(true);
306
			}
307
		}
308
		fReferencedProjects.setEnabled(fBuildButton.getSelection() && (fProjectButton.getSelection() || fSpecificProjectsButton.getSelection()));
309
	}
310
	
311
	/**
312
	 * @see org.eclipse.debug.ui.ILaunchConfigurationTab#getImage()
313
	 */
314
	public Image getImage() {
315
		return ExternalToolsImages.getImage(IExternalToolConstants.IMG_TAB_BUILD);
316
	}
317
318
	public boolean isValid(ILaunchConfiguration launchConfig) {
319
		setErrorMessage(null);
320
		setMessage(null);
321
		if (fBuildButton.getSelection() && fSpecificProjectsButton.getSelection() && fProjects.isEmpty()) {
322
			setErrorMessage(ExternalToolsLaunchConfigurationMessages.ExternalToolsBuildTab_9);
323
			return false;
324
		}
325
		return true;
326
	}
327
	
328
	/**
329
	 * Returns a collection of projects referenced by a build scope attribute.
330
	 * 
331
	 * @return collection of projects referred to by configuration
332
	 */
333
	public static IProject[] getBuildProjects(ILaunchConfiguration configuration, String buildScopeId) {
334
		String scope = null;
335
		String id = buildScopeId ;
336
		if (id == null)
337
			id = IExternalToolConstants.ATTR_BUILD_SCOPE ;
338
		try {
339
			scope = configuration.getAttribute(id, (String)null);
340
		} catch (CoreException e) {
341
			return null;
342
		}
343
		if (scope == null) {
344
			return null;
345
		}
346
		if (scope.startsWith("${projects:")) { //$NON-NLS-1$
347
			String pathString = scope.substring(11, scope.length() - 1);
348
			if (pathString.length() > 1) {
349
				String[] names = pathString.split(","); //$NON-NLS-1$
350
				IProject[] projects = new IProject[names.length];
351
				IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
352
				for (int i = 0; i < names.length; i++) {
353
					projects[i] = root.getProject(names[i]);
354
				}
355
				return projects;
356
			}
357
		} else if (scope.equals("${project}")) { //$NON-NLS-1$
358
			IResource resource = DebugUITools.getSelectedResource();
359
			if (resource != null) {
360
				return new IProject[]{resource.getProject()};
361
			}
362
		}
363
		return new IProject[0];
364
	}
365
	
366
	/**
367
	 * Whether referenced projects should be considered when building. Only valid
368
	 * when a set of projects is to be built.
369
	 * 
370
	 * @param configuration
371
	 * @return whether referenced projects should be considerd when building
372
	 * @throws CoreException if unable to access the associated attribute
373
	 */
374
	public static boolean isIncludeReferencedProjects(ILaunchConfiguration configuration, String includeReferencedProjectsId) throws CoreException {
375
		String id = includeReferencedProjectsId;
376
		if (id == null)
377
			id = IExternalToolConstants.ATTR_INCLUDE_REFERENCED_PROJECTS ;
378
		return configuration.getAttribute(id, true);
379
	}
380
	
381
	/**
382
	 * Creates and returns a memento for the given project set, to be used as a
383
	 * build scope attribute.
384
	 * 
385
	 * @param projects list of projects
386
	 * @return an equivalent refresh attribute
387
	 */
388
	public static String getBuildScopeAttribute(List projects) {
389
		StringBuffer buf = new StringBuffer();
390
		buf.append("${projects:"); //$NON-NLS-1$
391
		Iterator iterator = projects.iterator();
392
		while (iterator.hasNext()) {
393
			IProject project = (IProject) iterator.next();
394
			buf.append(project.getName());
395
			if (iterator.hasNext()) {
396
				buf.append(","); //$NON-NLS-1$
397
			}
398
		}
399
		buf.append("}"); //$NON-NLS-1$
400
		return buf.toString();
401
	}
402
	
403
	/* (non-Javadoc)
404
	 * @see org.eclipse.debug.ui.ILaunchConfigurationTab#activated(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)
405
	 */
406
	public void activated(ILaunchConfigurationWorkingCopy workingCopy) {
407
		// do nothing on activation
408
	}
409
410
	/* (non-Javadoc)
411
	 * @see org.eclipse.debug.ui.ILaunchConfigurationTab#deactivated(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)
412
	 */
413
	public void deactivated(ILaunchConfigurationWorkingCopy workingCopy) {
414
		// do nothing on deactivation
415
	}
416
417
	/**
418
	 * For backward compatibility - overridden in AntBuildTab
419
	 * @return id for referenced projects
420
	 */
421
	protected String getAttrIncludeReferencedProjectsId() {
422
		return IExternalToolConstants.ATTR_INCLUDE_REFERENCED_PROJECTS;
423
	}
424
425
	/**
426
	 * For backward compatibility - overridden in AntBuildTab
427
	 * @return id for build scope
428
	 */
429
	protected String getAttrBuildScopeId() {
430
		return IExternalToolConstants.ATTR_BUILD_SCOPE;
431
	}
432
433
}

Return to bug 165371