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 270626 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/pde/internal/ui/shared/target/EditBundleContainerWizard.java (-52 / +50 lines)
Lines 1-52 Link Here
1
package org.eclipse.pde.internal.ui.shared.target;
1
package org.eclipse.pde.internal.ui.shared.target;
2
2
3
import org.eclipse.jface.dialogs.IDialogSettings;
3
import org.eclipse.jface.dialogs.IDialogSettings;
4
import org.eclipse.jface.wizard.Wizard;
4
import org.eclipse.jface.wizard.Wizard;
5
import org.eclipse.pde.internal.core.target.impl.*;
5
import org.eclipse.pde.internal.core.target.impl.*;
6
import org.eclipse.pde.internal.core.target.provisional.IBundleContainer;
6
import org.eclipse.pde.internal.core.target.provisional.IBundleContainer;
7
import org.eclipse.pde.internal.core.target.provisional.ITargetDefinition;
7
import org.eclipse.pde.internal.ui.PDEPlugin;
8
import org.eclipse.pde.internal.ui.PDEPlugin;
8
9
9
public class EditBundleContainerWizard extends Wizard {
10
public class EditBundleContainerWizard extends Wizard {
10
11
11
	private IBundleContainer fContainer;
12
	private ITargetDefinition fTarget;
12
	private EditDirectoryContainerPage fPage;
13
	private IBundleContainer fContainer;
13
14
	private EditDirectoryContainerPage fPage;
14
	public EditBundleContainerWizard(IBundleContainer container) {
15
15
		fContainer = container;
16
	public EditBundleContainerWizard(ITargetDefinition target, IBundleContainer container) {
16
		IDialogSettings settings = PDEPlugin.getDefault().getDialogSettings().getSection(AddBundleContainerSelectionPage.SETTINGS_SECTION);
17
		fTarget = target;
17
		if (settings == null) {
18
		fContainer = container;
18
			settings = PDEPlugin.getDefault().getDialogSettings().addNewSection(AddBundleContainerSelectionPage.SETTINGS_SECTION);
19
		IDialogSettings settings = PDEPlugin.getDefault().getDialogSettings().getSection(AddBundleContainerSelectionPage.SETTINGS_SECTION);
19
		}
20
		if (settings == null) {
20
		setDialogSettings(settings);
21
			settings = PDEPlugin.getDefault().getDialogSettings().addNewSection(AddBundleContainerSelectionPage.SETTINGS_SECTION);
21
		setWindowTitle(Messages.EditBundleContainerWizard_0);
22
		}
22
	}
23
		setDialogSettings(settings);
23
24
		setWindowTitle(Messages.EditBundleContainerWizard_0);
24
	public void addPages() {
25
	}
25
		if (fContainer instanceof DirectoryBundleContainer) {
26
26
			fPage = new EditDirectoryContainerPage(fContainer);
27
	public void addPages() {
27
			addPage(fPage);
28
		if (fContainer instanceof DirectoryBundleContainer) {
28
		} else if (fContainer instanceof ProfileBundleContainer) {
29
			fPage = new EditDirectoryContainerPage(fTarget, fContainer);
29
			fPage = new EditProfileContainerPage(fContainer);
30
			addPage(fPage);
30
			addPage(fPage);
31
		} else if (fContainer instanceof ProfileBundleContainer) {
31
		} else if (fContainer instanceof FeatureBundleContainer) {
32
			fPage = new EditProfileContainerPage(fTarget, fContainer);
32
			fPage = new EditFeatureContainerPage(fContainer);
33
			addPage(fPage);
33
			addPage(fPage);
34
		} else if (fContainer instanceof FeatureBundleContainer) {
34
		}
35
			fPage = new EditFeatureContainerPage(fTarget, fContainer);
35
	}
36
			addPage(fPage);
36
37
		}
37
	public boolean performFinish() {
38
	}
38
		if (fPage != null) {
39
39
			fPage.storeSettings();
40
	public boolean performFinish() {
40
			fContainer = fPage.getBundleContainer();
41
		if (fPage != null) {
41
			return true;
42
			fContainer = fPage.getBundleContainer();
42
		}
43
			return true;
43
		return false;
44
		}
44
	}
45
		return false;
45
46
	}
46
	public IBundleContainer getBundleContainer() {
47
47
		return fContainer;
48
	public IBundleContainer getBundleContainer() {
48
	}
49
		return fContainer;
49
50
	}
50
}
51
52
}
(-)src/org/eclipse/pde/internal/ui/shared/target/BundleContainerLabelProvider.java (-12 / +1 lines)
Lines 51-59 Link Here
51
		} catch (CoreException e) {
51
		} catch (CoreException e) {
52
			return MessageFormat.format(Messages.BundleContainerTable_4, new String[] {e.getMessage()});
52
			return MessageFormat.format(Messages.BundleContainerTable_4, new String[] {e.getMessage()});
53
		}
53
		}
54
		if (element instanceof IStatus) {
55
			return ((IStatus) element).getMessage();
56
		}
57
		return super.getText(element);
54
		return super.getText(element);
58
	}
55
	}
59
56
Lines 66-72 Link Here
66
			IBundleContainer container = (IBundleContainer) element;
63
			IBundleContainer container = (IBundleContainer) element;
67
			if (container.isResolved()) {
64
			if (container.isResolved()) {
68
				IStatus status = container.getBundleStatus();
65
				IStatus status = container.getBundleStatus();
69
				if (status.getSeverity() == IStatus.WARNING) {
66
				if (status.getSeverity() == IStatus.WARNING || status.getSeverity() == IStatus.INFO) {
70
					flag = SharedLabelProvider.F_WARNING;
67
					flag = SharedLabelProvider.F_WARNING;
71
				} else if (status.getSeverity() == IStatus.ERROR) {
68
				} else if (status.getSeverity() == IStatus.ERROR) {
72
					flag = SharedLabelProvider.F_ERROR;
69
					flag = SharedLabelProvider.F_ERROR;
Lines 80-94 Link Here
80
			} else if (element instanceof ProfileBundleContainer) {
77
			} else if (element instanceof ProfileBundleContainer) {
81
				return PDEPlugin.getDefault().getLabelProvider().get(PDEPluginImages.DESC_PRODUCT_DEFINITION, flag);
78
				return PDEPlugin.getDefault().getLabelProvider().get(PDEPluginImages.DESC_PRODUCT_DEFINITION, flag);
82
			}
79
			}
83
		} else if (element instanceof IStatus) {
84
			int severity = ((IStatus) element).getSeverity();
85
			if (severity == IStatus.WARNING) {
86
				return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_WARN_TSK);
87
			} else if (severity == IStatus.ERROR) {
88
				return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_ERROR_TSK);
89
			}
90
		}
80
		}
91
92
		return super.getImage(element);
81
		return super.getImage(element);
93
	}
82
	}
94
83
(-)src/org/eclipse/pde/internal/ui/shared/target/BundleContainerTable.java (-525 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2009 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.pde.internal.ui.shared.target;
12
13
import java.lang.reflect.InvocationTargetException;
14
import java.util.ArrayList;
15
import org.eclipse.core.runtime.*;
16
import org.eclipse.core.runtime.jobs.Job;
17
import org.eclipse.jface.operation.IRunnableWithProgress;
18
import org.eclipse.jface.viewers.*;
19
import org.eclipse.jface.window.Window;
20
import org.eclipse.jface.wizard.WizardDialog;
21
import org.eclipse.pde.internal.core.target.provisional.*;
22
import org.eclipse.pde.internal.ui.PDEPlugin;
23
import org.eclipse.pde.internal.ui.SWTFactory;
24
import org.eclipse.pde.internal.ui.editor.FormLayoutFactory;
25
import org.eclipse.pde.internal.ui.editor.targetdefinition.TargetEditor;
26
import org.eclipse.swt.SWT;
27
import org.eclipse.swt.events.SelectionAdapter;
28
import org.eclipse.swt.events.SelectionEvent;
29
import org.eclipse.swt.layout.GridData;
30
import org.eclipse.swt.layout.GridLayout;
31
import org.eclipse.swt.widgets.*;
32
import org.eclipse.ui.forms.widgets.FormToolkit;
33
import org.eclipse.ui.progress.UIJob;
34
35
/**
36
 * UI part that can be added to a dialog or to a form editor.  Contains a table displaying
37
 * the bundle containers of a target definition.  Also has buttons to add, edit and remove
38
 * bundle containers of varying types.
39
 * 
40
 * @see TargetEditor
41
 * @see ITargetDefinition
42
 * @see IBundleContainer
43
 */
44
public class BundleContainerTable {
45
46
	private TreeViewer fTreeViewer;
47
	private Button fAddButton;
48
	private Button fEditButton;
49
	private Button fRemoveButton;
50
	private Button fRemoveAllButton;
51
	private Label fShowLabel;
52
	private Button fShowPluginsButton;
53
	private Button fShowSourceButton;
54
	private ViewerFilter fPluginFilter;
55
	private ViewerFilter fSourceFilter;
56
57
	private ITargetDefinition fTarget;
58
	private IBundleContainerTableReporter fReporter;
59
60
	/**
61
	 * Creates this part using the form toolkit and adds it to the given composite.
62
	 * 
63
	 * @param parent parent composite
64
	 * @param toolkit toolkit to create the widgets with
65
	 * @param reporter reporter implementation that will handle resolving and changes to the containers
66
	 * @return generated instance of the table part
67
	 */
68
	public static BundleContainerTable createTableInForm(Composite parent, FormToolkit toolkit, IBundleContainerTableReporter reporter) {
69
		BundleContainerTable contentTable = new BundleContainerTable(reporter);
70
		contentTable.createFormContents(parent, toolkit);
71
		return contentTable;
72
	}
73
74
	/**
75
	 * Creates this part using standard dialog widgets and adds it to the given composite.
76
	 * 
77
	 * @param parent parent composite
78
	 * @param reporter reporter implementation that will handle resolving and changes to the containers
79
	 * @return generated instance of the table part
80
	 */
81
	public static BundleContainerTable createTableInDialog(Composite parent, IBundleContainerTableReporter reporter) {
82
		BundleContainerTable contentTable = new BundleContainerTable(reporter);
83
		contentTable.createDialogContents(parent);
84
		return contentTable;
85
	}
86
87
	/**
88
	 * Private constructor, use one of {@link #createTableInDialog(Composite, IBundleContainerTableReporter)}
89
	 * or {@link #createTableInForm(Composite, FormToolkit, IBundleContainerTableReporter)}.
90
	 * 
91
	 * @param reporter reporter implementation that will handle resolving and changes to the containers
92
	 */
93
	private BundleContainerTable(IBundleContainerTableReporter reporter) {
94
		fReporter = reporter;
95
	}
96
97
	/**
98
	 * Creates the part contents from a toolkit
99
	 * @param parent parent composite
100
	 * @param toolkit form toolkit to create widgets
101
	 */
102
	private void createFormContents(Composite parent, FormToolkit toolkit) {
103
		Composite comp = toolkit.createComposite(parent);
104
		comp.setLayout(FormLayoutFactory.createSectionClientGridLayout(false, 2));
105
		comp.setLayoutData(new GridData(GridData.FILL_BOTH | GridData.GRAB_VERTICAL));
106
107
		Tree atree = toolkit.createTree(comp, SWT.V_SCROLL | SWT.H_SCROLL);
108
		atree.setLayout(new GridLayout());
109
		GridData gd = new GridData(GridData.FILL_BOTH);
110
		atree.setLayoutData(gd);
111
112
		Composite buttonComp = toolkit.createComposite(comp);
113
		GridLayout layout = new GridLayout();
114
		layout.marginWidth = layout.marginHeight = 0;
115
		buttonComp.setLayout(layout);
116
		buttonComp.setLayoutData(new GridData(GridData.FILL_VERTICAL));
117
118
		fAddButton = toolkit.createButton(buttonComp, Messages.BundleContainerTable_0, SWT.PUSH);
119
		fEditButton = toolkit.createButton(buttonComp, Messages.BundleContainerTable_1, SWT.PUSH);
120
		fRemoveButton = toolkit.createButton(buttonComp, Messages.BundleContainerTable_2, SWT.PUSH);
121
		fRemoveAllButton = toolkit.createButton(buttonComp, Messages.BundleContainerTable_3, SWT.PUSH);
122
123
		Composite filterComp = toolkit.createComposite(buttonComp);
124
		layout = new GridLayout();
125
		layout.marginWidth = layout.marginHeight = 0;
126
		filterComp.setLayout(layout);
127
		filterComp.setLayoutData(new GridData(SWT.LEFT, SWT.BOTTOM, true, true));
128
129
		fShowLabel = toolkit.createLabel(filterComp, Messages.BundleContainerTable_9);
130
		fShowPluginsButton = toolkit.createButton(filterComp, Messages.BundleContainerTable_14, SWT.CHECK);
131
		fShowSourceButton = toolkit.createButton(filterComp, Messages.BundleContainerTable_15, SWT.CHECK);
132
133
		initializeTreeViewer(atree);
134
		initializeButtons();
135
		initializeFilters();
136
137
		toolkit.paintBordersFor(comp);
138
	}
139
140
	/**
141
	 * Creates the part contents using SWTFactory
142
	 * @param parent parent composite
143
	 */
144
	private void createDialogContents(Composite parent) {
145
		Composite comp = SWTFactory.createComposite(parent, 2, 1, GridData.FILL_BOTH, 0, 0);
146
147
		Tree atree = new Tree(comp, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER);
148
		atree.setLayout(new GridLayout());
149
		GridData gd = new GridData(GridData.FILL_BOTH);
150
		gd.widthHint = 200;
151
		atree.setLayoutData(gd);
152
153
		Composite buttonComp = SWTFactory.createComposite(comp, 2, 1, GridData.FILL_BOTH);
154
		GridLayout layout = new GridLayout();
155
		layout.marginHeight = 0;
156
		layout.marginWidth = 0;
157
		buttonComp.setLayout(layout);
158
		buttonComp.setLayoutData(new GridData(GridData.FILL_VERTICAL));
159
160
		fAddButton = SWTFactory.createPushButton(buttonComp, Messages.BundleContainerTable_0, null);
161
		fEditButton = SWTFactory.createPushButton(buttonComp, Messages.BundleContainerTable_1, null);
162
		fRemoveButton = SWTFactory.createPushButton(buttonComp, Messages.BundleContainerTable_2, null);
163
		fRemoveAllButton = SWTFactory.createPushButton(buttonComp, Messages.BundleContainerTable_3, null);
164
165
		Composite filterComp = SWTFactory.createComposite(buttonComp, 1, 1, GridData.BEGINNING, 0, 0);
166
		filterComp.setLayoutData(new GridData(SWT.LEFT, SWT.BOTTOM, true, true));
167
168
		fShowLabel = SWTFactory.createLabel(filterComp, Messages.BundleContainerTable_9, 1);
169
		fShowPluginsButton = SWTFactory.createCheckButton(filterComp, Messages.BundleContainerTable_14, null, true, 1);
170
		fShowSourceButton = SWTFactory.createCheckButton(filterComp, Messages.BundleContainerTable_15, null, true, 1);
171
172
		initializeTreeViewer(atree);
173
		initializeButtons();
174
		initializeFilters();
175
	}
176
177
	/**
178
	 * Sets up the tree viewer using the given tree
179
	 * @param tree
180
	 */
181
	private void initializeTreeViewer(Tree tree) {
182
		fTreeViewer = new TreeViewer(tree);
183
		fTreeViewer.setContentProvider(new BundleContainerContentProvider());
184
		fTreeViewer.setLabelProvider(new BundleContainerLabelProvider());
185
		fTreeViewer.setComparator(new ViewerComparator());
186
		fTreeViewer.addSelectionChangedListener(new ISelectionChangedListener() {
187
			public void selectionChanged(SelectionChangedEvent event) {
188
				updateButtons();
189
			}
190
		});
191
		fTreeViewer.addDoubleClickListener(new IDoubleClickListener() {
192
			public void doubleClick(DoubleClickEvent event) {
193
				if (!event.getSelection().isEmpty()) {
194
					handleEdit();
195
				}
196
			}
197
		});
198
		fTreeViewer.setAutoExpandLevel(AbstractTreeViewer.ALL_LEVELS);
199
	}
200
201
	/**
202
	 * Sets up the buttons, the button fields must already be created before calling this method
203
	 */
204
	private void initializeButtons() {
205
		fAddButton.addSelectionListener(new SelectionAdapter() {
206
			public void widgetSelected(SelectionEvent e) {
207
				handleAdd();
208
			}
209
		});
210
		fAddButton.setLayoutData(new GridData());
211
		SWTFactory.setButtonDimensionHint(fAddButton);
212
213
		fEditButton.addSelectionListener(new SelectionAdapter() {
214
			public void widgetSelected(SelectionEvent e) {
215
				handleEdit();
216
			}
217
		});
218
		fEditButton.setLayoutData(new GridData());
219
		fEditButton.setEnabled(false);
220
		SWTFactory.setButtonDimensionHint(fEditButton);
221
222
		fRemoveButton.addSelectionListener(new SelectionAdapter() {
223
			public void widgetSelected(SelectionEvent e) {
224
				handleRemove();
225
			}
226
		});
227
		fRemoveButton.setLayoutData(new GridData());
228
		fRemoveButton.setEnabled(false);
229
		SWTFactory.setButtonDimensionHint(fRemoveButton);
230
231
		fRemoveAllButton.addSelectionListener(new SelectionAdapter() {
232
			public void widgetSelected(SelectionEvent e) {
233
				handleRemoveAll();
234
			}
235
		});
236
		fRemoveAllButton.setLayoutData(new GridData());
237
		SWTFactory.setButtonDimensionHint(fRemoveAllButton);
238
239
		fShowPluginsButton.addSelectionListener(new SelectionAdapter() {
240
			public void widgetSelected(SelectionEvent e) {
241
				if (!fShowPluginsButton.getSelection()) {
242
					fTreeViewer.addFilter(fPluginFilter);
243
				} else {
244
					fTreeViewer.removeFilter(fPluginFilter);
245
				}
246
			}
247
		});
248
		fShowPluginsButton.setSelection(true);
249
		GridData gd = new GridData();
250
		gd.horizontalIndent = 10;
251
		fShowPluginsButton.setLayoutData(gd);
252
253
		fShowSourceButton.addSelectionListener(new SelectionAdapter() {
254
			public void widgetSelected(SelectionEvent e) {
255
				if (!fShowSourceButton.getSelection()) {
256
					fTreeViewer.addFilter(fSourceFilter);
257
				} else {
258
					fTreeViewer.removeFilter(fSourceFilter);
259
				}
260
			}
261
		});
262
		fShowSourceButton.setSelection(true);
263
		gd = new GridData();
264
		gd.horizontalIndent = 10;
265
		fShowSourceButton.setLayoutData(gd);
266
	}
267
268
	private void initializeFilters() {
269
		fSourceFilter = new ViewerFilter() {
270
			public boolean select(Viewer viewer, Object parentElement, Object element) {
271
				if (element instanceof IResolvedBundle) {
272
					if (((IResolvedBundle) element).isSourceBundle()) {
273
						return false;
274
					}
275
				}
276
				return true;
277
			}
278
		};
279
		fPluginFilter = new ViewerFilter() {
280
			public boolean select(Viewer viewer, Object parentElement, Object element) {
281
				if (element instanceof IResolvedBundle) {
282
					if (!((IResolvedBundle) element).isSourceBundle()) {
283
						return false;
284
					}
285
				}
286
				return true;
287
			}
288
		};
289
	}
290
291
	/**
292
	 * Sets the target definition model to use as input for the tree, can be called with different
293
	 * models to change the tree's input.
294
	 * @param target target model
295
	 */
296
	public void setInput(ITargetDefinition target) {
297
		fTarget = target;
298
		refresh();
299
	}
300
301
	/**
302
	 * Refreshes the contents of the table
303
	 */
304
	public void refresh() {
305
		if (!fTarget.isResolved()) {
306
			fReporter.runResolveOperation(new ResolveContainersOperation());
307
		} else {
308
			fTreeViewer.setInput(fTarget);
309
			fTreeViewer.refresh();
310
			updateButtons();
311
		}
312
	}
313
314
	private void setEnabled(boolean enablement) {
315
		fTreeViewer.getControl().setEnabled(enablement);
316
		fAddButton.setEnabled(enablement);
317
318
		fShowLabel.setEnabled(enablement);
319
		fShowPluginsButton.setEnabled(enablement);
320
		fShowSourceButton.setEnabled(enablement);
321
322
		if (enablement) {
323
			updateButtons();
324
		} else {
325
			fRemoveButton.setEnabled(enablement);
326
			fRemoveAllButton.setEnabled(enablement);
327
			fEditButton.setEnabled(enablement);
328
		}
329
	}
330
331
	private void handleAdd() {
332
		AddBundleContainerWizard wizard = new AddBundleContainerWizard(fTarget);
333
		Shell parent = fTreeViewer.getTree().getShell();
334
		WizardDialog dialog = new WizardDialog(parent, wizard);
335
		if (dialog.open() != Window.CANCEL) {
336
			refresh();
337
			contentsChanged();
338
		}
339
	}
340
341
	private void handleEdit() {
342
		IStructuredSelection selection = (IStructuredSelection) fTreeViewer.getSelection();
343
		if (!selection.isEmpty()) {
344
			Object selected = selection.getFirstElement();
345
			IBundleContainer oldContainer = null;
346
			if (selected instanceof IBundleContainer) {
347
				oldContainer = (IBundleContainer) selected;
348
			} else if (selected instanceof IResolvedBundle) {
349
				TreeItem[] treeSelection = fTreeViewer.getTree().getSelection();
350
				if (treeSelection.length > 0) {
351
					Object parent = treeSelection[0].getParentItem().getData();
352
					if (parent instanceof IBundleContainer) {
353
						oldContainer = (IBundleContainer) parent;
354
					}
355
				}
356
			}
357
			if (oldContainer != null) {
358
				Shell parent = fTreeViewer.getTree().getShell();
359
				EditBundleContainerWizard wizard = new EditBundleContainerWizard(fTarget, oldContainer);
360
				WizardDialog dialog = new WizardDialog(parent, wizard);
361
				if (dialog.open() == Window.OK) {
362
					// Replace the old container with the new one
363
					IBundleContainer newContainer = wizard.getBundleContainer();
364
					if (newContainer != null) {
365
						IBundleContainer[] containers = fTarget.getBundleContainers();
366
						java.util.List newContainers = new ArrayList(containers.length);
367
						for (int i = 0; i < containers.length; i++) {
368
							if (!containers[i].equals(oldContainer)) {
369
								newContainers.add(containers[i]);
370
							}
371
						}
372
						newContainers.add(newContainer);
373
						fTarget.setBundleContainers((IBundleContainer[]) newContainers.toArray(new IBundleContainer[newContainers.size()]));
374
375
						// Update the table
376
						refresh();
377
						contentsChanged();
378
						fTreeViewer.setSelection(new StructuredSelection(newContainer), true);
379
					}
380
				}
381
			}
382
		}
383
	}
384
385
	private void handleRemove() {
386
		IStructuredSelection selection = (IStructuredSelection) fTreeViewer.getSelection();
387
		if (!selection.isEmpty()) {
388
			Object selected = selection.getFirstElement();
389
			IBundleContainer container = null;
390
			if (selected instanceof IBundleContainer) {
391
				container = (IBundleContainer) selected;
392
				IBundleContainer[] currentContainers = fTarget.getBundleContainers();
393
				ArrayList newBundleContainers = new ArrayList(currentContainers.length);
394
				for (int i = 0; i < currentContainers.length; i++) {
395
					if (!currentContainers[i].equals(container)) {
396
						newBundleContainers.add(currentContainers[i]);
397
					}
398
				}
399
				fTarget.setBundleContainers((IBundleContainer[]) newBundleContainers.toArray(new IBundleContainer[newBundleContainers.size()]));
400
				contentsChanged();
401
				refresh();
402
			}
403
		}
404
	}
405
406
	private void handleRemoveAll() {
407
		fTarget.setBundleContainers(null);
408
		contentsChanged();
409
		refresh();
410
	}
411
412
	private void updateButtons() {
413
		IStructuredSelection selection = (IStructuredSelection) fTreeViewer.getSelection();
414
		fEditButton.setEnabled(!selection.isEmpty() && (selection.getFirstElement() instanceof IBundleContainer || selection.getFirstElement() instanceof IResolvedBundle));
415
		fRemoveButton.setEnabled(!selection.isEmpty() && selection.getFirstElement() instanceof IBundleContainer);
416
		fRemoveAllButton.setEnabled(fTarget.getBundleContainers() != null && fTarget.getBundleContainers().length > 0);
417
	}
418
419
	/**
420
	 * Informs the reporter for this table that something has changed
421
	 * and is dirty.
422
	 */
423
	private void contentsChanged() {
424
		fReporter.contentsChanged();
425
	}
426
427
	/**
428
	 * Runnable that resolves the target.  Disables the table while running
429
	 */
430
	class ResolveContainersOperation implements IRunnableWithProgress {
431
432
		/* (non-Javadoc)
433
		 * @see org.eclipse.jface.operation.IRunnableWithProgress#run(org.eclipse.core.runtime.IProgressMonitor)
434
		 */
435
		public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
436
			Job job = new UIJob(Messages.BundleContainerTable_16) {
437
				public IStatus runInUIThread(IProgressMonitor monitor) {
438
					if (!fTreeViewer.getControl().isDisposed()) {
439
						setEnabled(false);
440
						fTreeViewer.setInput(Messages.BundleContainerTable_17);
441
						fTreeViewer.refresh();
442
					}
443
					return Status.OK_STATUS;
444
				}
445
			};
446
			job.setSystem(true);
447
			job.schedule();
448
			fTarget.resolve(monitor);
449
			if (!monitor.isCanceled()) {
450
				job = new UIJob(Messages.BundleContainerTable_18) {
451
					public IStatus runInUIThread(IProgressMonitor monitor) {
452
						if (!fTreeViewer.getControl().isDisposed()) {
453
							setEnabled(true);
454
							fTreeViewer.setInput(fTarget);
455
							fTreeViewer.refresh();
456
							updateButtons();
457
						}
458
						return Status.OK_STATUS;
459
					}
460
				};
461
				job.setSystem(true);
462
				job.schedule();
463
			}
464
		}
465
	}
466
467
	/**
468
	 * Content provider for the tree, primary input is a ITargetDefinition, children are IBundleContainers
469
	 */
470
	class BundleContainerContentProvider implements ITreeContentProvider {
471
472
		public Object[] getChildren(Object parentElement) {
473
			if (parentElement instanceof ITargetDefinition) {
474
				IBundleContainer[] containers = ((ITargetDefinition) parentElement).getBundleContainers();
475
				return containers != null ? containers : new Object[0];
476
			} else if (parentElement instanceof IBundleContainer) {
477
				IBundleContainer container = (IBundleContainer) parentElement;
478
				if (container.isResolved()) {
479
					IStatus status = container.getBundleStatus();
480
					if (!status.isOK() && !status.isMultiStatus()) {
481
						return new Object[] {status};
482
					}
483
					return container.getBundles();
484
				}
485
				// We should only be populating the table if the containers are resolved, but just in case
486
				return new Object[] {new Status(IStatus.ERROR, PDEPlugin.getPluginId(), Messages.BundleContainerTable_19)};
487
			} else if (parentElement instanceof IResolvedBundle) {
488
				IStatus status = ((IResolvedBundle) parentElement).getStatus();
489
				if (!status.isOK()) {
490
					return new Object[] {status};
491
				}
492
			}
493
			return new Object[0];
494
		}
495
496
		public Object getParent(Object element) {
497
			return null;
498
		}
499
500
		public boolean hasChildren(Object element) {
501
			// Since we are already resolved we can't be more efficient
502
			return getChildren(element).length > 0;
503
		}
504
505
		public Object[] getElements(Object inputElement) {
506
			if (inputElement instanceof ITargetDefinition) {
507
				IBundleContainer[] containers = ((ITargetDefinition) inputElement).getBundleContainers();
508
				if (containers != null) {
509
					return containers;
510
				}
511
			} else if (inputElement instanceof String) {
512
				return new Object[] {inputElement};
513
			}
514
			return new Object[0];
515
		}
516
517
		public void dispose() {
518
		}
519
520
		public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
521
		}
522
523
	}
524
525
}
(-)src/org/eclipse/pde/internal/ui/shared/target/messages.properties (-8 lines)
Lines 15-21 Link Here
15
AddDirectoryContainerPage_4=Directory
15
AddDirectoryContainerPage_4=Directory
16
AddDirectoryContainerPage_5=Select a directory containing one or more plug-ins.
16
AddDirectoryContainerPage_5=Select a directory containing one or more plug-ins.
17
AddDirectoryContainerPage_6=Location directory does not exist
17
AddDirectoryContainerPage_6=Location directory does not exist
18
AddDirectoryContainerPage_7=< no plug-ins found in the current location >
19
AddDirectoryContainerPage_9=Could not acquire the target platform service to create the new container.
18
AddDirectoryContainerPage_9=Could not acquire the target platform service to create the new container.
20
AddFeatureContainerPage_0=Add Features
19
AddFeatureContainerPage_0=Add Features
21
AddFeatureContainerPage_1=Select features from a directory.
20
AddFeatureContainerPage_1=Select features from a directory.
Lines 61-75 Link Here
61
BundleContainerTable_16=Disable Target Contents
60
BundleContainerTable_16=Disable Target Contents
62
BundleContainerTable_17=Resolving the contents of the target...
61
BundleContainerTable_17=Resolving the contents of the target...
63
BundleContainerTable_18=Enable Target Contents
62
BundleContainerTable_18=Enable Target Contents
64
BundleContainerTable_19=Container has not been resolved
65
# label provider error messages
66
# {0} is the error message
67
BundleContainerTable_4=Error creating label: {0}
63
BundleContainerTable_4=Error creating label: {0}
68
BundleContainerTable_9=Show:
64
BundleContainerTable_9=Show:
69
EditBundleContainerWizard_0=Edit Content
65
EditBundleContainerWizard_0=Edit Content
70
EditDirectoryContainerPage_0=Edit Directory
66
EditDirectoryContainerPage_0=Edit Directory
71
EditDirectoryContainerPage_1=&Variables...
67
EditDirectoryContainerPage_1=&Variables...
72
EditDirectoryContainerPage_2=Included Plug-ins
73
EditDirectoryContainerPage_3=Resolve Container Job
68
EditDirectoryContainerPage_3=Resolve Container Job
74
EditFeatureContainerPage_0=Edit Feature
69
EditFeatureContainerPage_0=Edit Feature
75
EditFeatureContainerPage_1=Edit the plug-ins included in this feature
70
EditFeatureContainerPage_1=Edit the plug-ins included in this feature
Lines 77-83 Link Here
77
EditFeatureContainerPage_3=Feature Version:
72
EditFeatureContainerPage_3=Feature Version:
78
EditFeatureContainerPage_4=Unspecified
73
EditFeatureContainerPage_4=Unspecified
79
EditFeatureContainerPage_5=Location:
74
EditFeatureContainerPage_5=Location:
80
EditProfileContainerPage_0=Configuration Location
81
EditProfileContainerPage_1=Var&iables...
75
EditProfileContainerPage_1=Var&iables...
82
EditProfileContainerPage_2=Select a configuration directory
76
EditProfileContainerPage_2=Select a configuration directory
83
EditProfileContainerPage_3=Edit Installation
77
EditProfileContainerPage_3=Edit Installation
Lines 91-98 Link Here
91
IncludedBundlesTree_3=Dese&lect All
85
IncludedBundlesTree_3=Dese&lect All
92
IncludedBundlesTree_4=Select Re&quired
86
IncludedBundlesTree_4=Select Re&quired
93
# {0}: count of checked plug-ins {1}: total number of plug-ins  example: 12 of 15 included
87
# {0}: count of checked plug-ins {1}: total number of plug-ins  example: 12 of 15 included
94
IncludedBundlesTree_5={0} of {1} selected
95
IncludedBundlesTree_6=Group Plug-ins by location
96
RestrictionsListSelectionDialog_0=Select the plug-ins to include in the target:
88
RestrictionsListSelectionDialog_0=Select the plug-ins to include in the target:
97
RestrictionsListSelectionDialog_1=Plug-in Selection
89
RestrictionsListSelectionDialog_1=Plug-in Selection
98
RestrictionsListSelectionDialog_2=Use specific plug-in version (versus highest available version)
90
RestrictionsListSelectionDialog_2=Use specific plug-in version (versus highest available version)
(-)src/org/eclipse/pde/internal/ui/shared/target/AddFeatureContainersPage.java (-5 / +10 lines)
Lines 21-27 Link Here
21
import org.eclipse.pde.internal.core.feature.ExternalFeatureModel;
21
import org.eclipse.pde.internal.core.feature.ExternalFeatureModel;
22
import org.eclipse.pde.internal.core.ifeature.IFeatureModel;
22
import org.eclipse.pde.internal.core.ifeature.IFeatureModel;
23
import org.eclipse.pde.internal.core.target.provisional.IBundleContainer;
23
import org.eclipse.pde.internal.core.target.provisional.IBundleContainer;
24
import org.eclipse.pde.internal.core.target.provisional.ITargetDefinition;
25
import org.eclipse.pde.internal.ui.*;
24
import org.eclipse.pde.internal.ui.*;
26
import org.eclipse.swt.SWT;
25
import org.eclipse.swt.SWT;
27
import org.eclipse.swt.events.SelectionAdapter;
26
import org.eclipse.swt.events.SelectionAdapter;
Lines 44-53 Link Here
44
	private Button fIncludeVersionButton;
43
	private Button fIncludeVersionButton;
45
	private CheckboxTableViewer fFeatureTable;
44
	private CheckboxTableViewer fFeatureTable;
46
45
47
	protected AddFeatureContainersPage(ITargetDefinition target) {
48
		super(target);
49
	}
50
51
	/* (non-Javadoc)
46
	/* (non-Javadoc)
52
	 * @see org.eclipse.pde.internal.ui.shared.target.EditDirectoryContainerPage#getDefaultTitle()
47
	 * @see org.eclipse.pde.internal.ui.shared.target.EditDirectoryContainerPage#getDefaultTitle()
53
	 */
48
	 */
Lines 63-73 Link Here
63
	}
58
	}
64
59
65
	/* (non-Javadoc)
60
	/* (non-Javadoc)
61
	 * @see org.eclipse.pde.internal.ui.shared.target.EditDirectoryContainerPage#createLocationArea(org.eclipse.swt.widgets.Composite)
62
	 */
63
	protected void createLocationArea(Composite parent) {
64
		super.createLocationArea(parent);
65
		createTableArea(parent);
66
	}
67
68
	/* (non-Javadoc)
66
	 * @see org.eclipse.pde.internal.ui.shared.target.AddDirectoryContainerPage#createTableArea(org.eclipse.swt.widgets.Composite)
69
	 * @see org.eclipse.pde.internal.ui.shared.target.AddDirectoryContainerPage#createTableArea(org.eclipse.swt.widgets.Composite)
67
	 */
70
	 */
68
	protected void createTableArea(Composite parent) {
71
	protected void createTableArea(Composite parent) {
69
		Composite tableComp = SWTFactory.createComposite(parent, 2, 1, GridData.FILL_BOTH, 0, 0);
72
		Composite tableComp = SWTFactory.createComposite(parent, 2, 1, GridData.FILL_BOTH, 0, 0);
70
73
74
		SWTFactory.createLabel(tableComp, "Features:", 2);
75
71
		fFeatureTable = CheckboxTableViewer.newCheckList(tableComp, SWT.BORDER);
76
		fFeatureTable = CheckboxTableViewer.newCheckList(tableComp, SWT.BORDER);
72
		// Connect the label provider
77
		// Connect the label provider
73
		PDEPlugin.getDefault().getLabelProvider().connect(this);
78
		PDEPlugin.getDefault().getLabelProvider().connect(this);
(-)src/org/eclipse/pde/internal/ui/shared/target/EditProfileContainerPage.java (-12 / +7 lines)
Lines 20-26 Link Here
20
import org.eclipse.jface.dialogs.IMessageProvider;
20
import org.eclipse.jface.dialogs.IMessageProvider;
21
import org.eclipse.pde.internal.core.target.impl.ProfileBundleContainer;
21
import org.eclipse.pde.internal.core.target.impl.ProfileBundleContainer;
22
import org.eclipse.pde.internal.core.target.provisional.IBundleContainer;
22
import org.eclipse.pde.internal.core.target.provisional.IBundleContainer;
23
import org.eclipse.pde.internal.core.target.provisional.ITargetDefinition;
24
import org.eclipse.pde.internal.ui.SWTFactory;
23
import org.eclipse.pde.internal.ui.SWTFactory;
25
import org.eclipse.swt.SWT;
24
import org.eclipse.swt.SWT;
26
import org.eclipse.swt.events.*;
25
import org.eclipse.swt.events.*;
Lines 57-68 Link Here
57
	 */
56
	 */
58
	private static final String SETTINGS_CONFIG_3 = "config3"; //$NON-NLS-1$
57
	private static final String SETTINGS_CONFIG_3 = "config3"; //$NON-NLS-1$
59
58
60
	public EditProfileContainerPage(ITargetDefinition target) {
59
	public EditProfileContainerPage() {
61
		super(target);
60
		super();
62
	}
61
	}
63
62
64
	public EditProfileContainerPage(ITargetDefinition target, IBundleContainer container) {
63
	public EditProfileContainerPage(IBundleContainer container) {
65
		super(target, container);
64
		super(container);
66
	}
65
	}
67
66
68
	/* (non-Javadoc)
67
	/* (non-Javadoc)
Lines 88-94 Link Here
88
	protected void createLocationArea(Composite parent) {
87
	protected void createLocationArea(Composite parent) {
89
		super.createLocationArea(parent);
88
		super.createLocationArea(parent);
90
89
91
		Group configComp = SWTFactory.createGroup(parent, Messages.EditProfileContainerPage_0, 2, 1, GridData.FILL_HORIZONTAL);
90
		Composite configComp = SWTFactory.createComposite(parent, 2, 1, GridData.FILL_HORIZONTAL, 0, 0);
92
91
93
		fUseDefaultConfig = new Button(configComp, SWT.CHECK | SWT.RIGHT);
92
		fUseDefaultConfig = new Button(configComp, SWT.CHECK | SWT.RIGHT);
94
		GridData gd = new GridData();
93
		GridData gd = new GridData();
Lines 103-108 Link Here
103
		});
102
		});
104
103
105
		fConfigLabel = SWTFactory.createLabel(configComp, Messages.AddProfileContainerPage_3, 1);
104
		fConfigLabel = SWTFactory.createLabel(configComp, Messages.AddProfileContainerPage_3, 1);
105
		((GridData) fConfigLabel.getLayoutData()).horizontalIndent = 15;
106
106
107
		fConfigLocation = SWTFactory.createCombo(configComp, SWT.BORDER, 1, getConfigComboItems());
107
		fConfigLocation = SWTFactory.createCombo(configComp, SWT.BORDER, 1, getConfigComboItems());
108
		fConfigLocation.addModifyListener(new ModifyListener() {
108
		fConfigLocation.addModifyListener(new ModifyListener() {
Lines 241-249 Link Here
241
			if (fConfigLocation.isEnabled()) {
241
			if (fConfigLocation.isEnabled()) {
242
				// Check if the text field is blank
242
				// Check if the text field is blank
243
				if (fConfigLocation.getText().trim().length() == 0) {
243
				if (fConfigLocation.getText().trim().length() == 0) {
244
					fBundleTree.setInput(null);
245
					setMessage(Messages.EditProfileContainerPage_2);
244
					setMessage(Messages.EditProfileContainerPage_2);
246
					setPageComplete(false);
247
					return false;
245
					return false;
248
				}
246
				}
249
247
Lines 253-264 Link Here
253
251
254
				// Check that the directory exists
252
				// Check that the directory exists
255
				if (!configLocation.isDirectory()) {
253
				if (!configLocation.isDirectory()) {
256
					fBundleTree.setInput(null);
257
					setMessage(Messages.AddProfileContainerPage_8, IMessageProvider.WARNING);
254
					setMessage(Messages.AddProfileContainerPage_8, IMessageProvider.WARNING);
258
					setPageComplete(true);
259
				} else {
255
				} else {
260
					setMessage(getDefaultMessage());
256
					setMessage(getDefaultMessage());
261
					setPageComplete(true);
262
				}
257
				}
263
			}
258
			}
264
		}
259
		}
Lines 268-274 Link Here
268
	/* (non-Javadoc)
263
	/* (non-Javadoc)
269
	 * @see org.eclipse.pde.internal.ui.shared.target.EditDirectoryContainerPage#refreshContainer(org.eclipse.pde.internal.core.target.provisional.IBundleContainer)
264
	 * @see org.eclipse.pde.internal.ui.shared.target.EditDirectoryContainerPage#refreshContainer(org.eclipse.pde.internal.core.target.provisional.IBundleContainer)
270
	 */
265
	 */
271
	protected IBundleContainer refreshContainer(IBundleContainer previous) throws CoreException {
266
	protected IBundleContainer createContainer(IBundleContainer previous) throws CoreException {
272
		IBundleContainer container = getTargetPlatformService().newProfileContainer(fInstallLocation.getText(), fConfigLocation.isEnabled() ? fConfigLocation.getText() : null);
267
		IBundleContainer container = getTargetPlatformService().newProfileContainer(fInstallLocation.getText(), fConfigLocation.isEnabled() ? fConfigLocation.getText() : null);
273
		if (previous instanceof ProfileBundleContainer) {
268
		if (previous instanceof ProfileBundleContainer) {
274
			container.setIncludedBundles(previous.getIncludedBundles());
269
			container.setIncludedBundles(previous.getIncludedBundles());
(-)src/org/eclipse/pde/internal/ui/shared/target/AddBundleContainerWizard.java (-1 / +1 lines)
Lines 18-24 Link Here
18
 * Wizard for adding a bundle container to a target.  Provides a selection page
18
 * Wizard for adding a bundle container to a target.  Provides a selection page
19
 * where the user can choose the type of container to create.
19
 * where the user can choose the type of container to create.
20
 * 
20
 * 
21
 * @see BundleContainerTable
21
 * @see TargetLocationsGroup
22
 * @see IBundleContainer
22
 * @see IBundleContainer
23
 */
23
 */
24
public class AddBundleContainerWizard extends Wizard {
24
public class AddBundleContainerWizard extends Wizard {
(-)src/org/eclipse/pde/internal/ui/shared/target/EditFeatureContainerPage.java (-87 / +86 lines)
Lines 1-87 Link Here
1
package org.eclipse.pde.internal.ui.shared.target;
1
package org.eclipse.pde.internal.ui.shared.target;
2
2
3
import org.eclipse.core.runtime.CoreException;
3
import org.eclipse.core.runtime.CoreException;
4
import org.eclipse.pde.internal.core.target.impl.FeatureBundleContainer;
4
import org.eclipse.pde.internal.core.target.impl.FeatureBundleContainer;
5
import org.eclipse.pde.internal.core.target.provisional.IBundleContainer;
5
import org.eclipse.pde.internal.core.target.provisional.IBundleContainer;
6
import org.eclipse.pde.internal.core.target.provisional.ITargetDefinition;
6
import org.eclipse.pde.internal.ui.PDEPlugin;
7
import org.eclipse.pde.internal.ui.PDEPlugin;
7
import org.eclipse.pde.internal.ui.SWTFactory;
8
import org.eclipse.pde.internal.ui.SWTFactory;
8
import org.eclipse.swt.SWT;
9
import org.eclipse.swt.SWT;
9
import org.eclipse.swt.layout.GridData;
10
import org.eclipse.swt.layout.GridData;
10
import org.eclipse.swt.widgets.Composite;
11
import org.eclipse.swt.widgets.Composite;
11
import org.eclipse.swt.widgets.Text;
12
import org.eclipse.swt.widgets.Text;
12
13
13
public class EditFeatureContainerPage extends EditDirectoryContainerPage {
14
public class EditFeatureContainerPage extends EditDirectoryContainerPage {
14
15
15
	public EditFeatureContainerPage(IBundleContainer container) {
16
	public EditFeatureContainerPage(ITargetDefinition target, IBundleContainer container) {
16
		super(container);
17
		super(target, container);
17
	}
18
	}
18
19
19
	/* (non-Javadoc)
20
	/* (non-Javadoc)
20
	 * @see org.eclipse.pde.internal.ui.shared.target.EditDirectoryContainerPage#getDefaultTitle()
21
	 * @see org.eclipse.pde.internal.ui.shared.target.EditDirectoryContainerPage#getDefaultTitle()
21
	 */
22
	 */
22
	protected String getDefaultTitle() {
23
	protected String getDefaultTitle() {
23
		return Messages.EditFeatureContainerPage_0;
24
		return Messages.EditFeatureContainerPage_0;
24
	}
25
	}
25
26
26
	/* (non-Javadoc)
27
	/* (non-Javadoc)
27
	 * @see org.eclipse.pde.internal.ui.shared.target.EditDirectoryContainerPage#getDefaultMessage()
28
	 * @see org.eclipse.pde.internal.ui.shared.target.EditDirectoryContainerPage#getDefaultMessage()
28
	 */
29
	 */
29
	protected String getDefaultMessage() {
30
	protected String getDefaultMessage() {
30
		return Messages.EditFeatureContainerPage_1;
31
		return Messages.EditFeatureContainerPage_1;
31
	}
32
	}
32
33
33
	/* (non-Javadoc)
34
	/* (non-Javadoc)
34
	 * @see org.eclipse.pde.internal.ui.shared.target.AddDirectoryContainerPage#createLocationArea(org.eclipse.swt.widgets.Composite)
35
	 * @see org.eclipse.pde.internal.ui.shared.target.AddDirectoryContainerPage#createLocationArea(org.eclipse.swt.widgets.Composite)
35
	 */
36
	 */
36
	protected void createLocationArea(Composite parent) {
37
	protected void createLocationArea(Composite parent) {
37
		FeatureBundleContainer container = (FeatureBundleContainer) getBundleContainer();
38
		FeatureBundleContainer container = (FeatureBundleContainer) getBundleContainer();
38
		Composite comp = SWTFactory.createComposite(parent, 2, 1, GridData.FILL_HORIZONTAL);
39
		Composite comp = SWTFactory.createComposite(parent, 2, 1, GridData.FILL_HORIZONTAL);
39
40
40
		SWTFactory.createLabel(comp, Messages.EditFeatureContainerPage_2, 1);
41
		SWTFactory.createLabel(comp, Messages.EditFeatureContainerPage_2, 1);
41
		Text text = SWTFactory.createText(comp, SWT.READ_ONLY | SWT.BORDER, 1);
42
		Text text = SWTFactory.createText(comp, SWT.READ_ONLY | SWT.BORDER, 1);
42
		text.setText(container.getFeatureId());
43
		text.setText(container.getFeatureId());
43
44
44
		SWTFactory.createLabel(comp, Messages.EditFeatureContainerPage_3, 1);
45
		SWTFactory.createLabel(comp, Messages.EditFeatureContainerPage_3, 1);
45
		text = SWTFactory.createText(comp, SWT.READ_ONLY | SWT.BORDER, 1);
46
		text = SWTFactory.createText(comp, SWT.READ_ONLY | SWT.BORDER, 1);
46
		text.setText(container.getFeatureVersion() != null ? container.getFeatureVersion() : Messages.EditFeatureContainerPage_4);
47
		text.setText(container.getFeatureVersion() != null ? container.getFeatureVersion() : Messages.EditFeatureContainerPage_4);
47
48
48
		SWTFactory.createLabel(comp, Messages.EditFeatureContainerPage_5, 1);
49
		SWTFactory.createLabel(comp, Messages.EditFeatureContainerPage_5, 1);
49
		text = SWTFactory.createText(comp, SWT.READ_ONLY | SWT.BORDER, 1);
50
		text = SWTFactory.createText(comp, SWT.READ_ONLY | SWT.BORDER, 1);
50
		try {
51
		try {
51
			text.setText(container.getLocation(false));
52
			text.setText(container.getLocation(false));
52
		} catch (CoreException e) {
53
		} catch (CoreException e) {
53
			setErrorMessage(e.getMessage());
54
			setErrorMessage(e.getMessage());
54
			PDEPlugin.log(e);
55
			PDEPlugin.log(e);
55
		}
56
		}
56
	}
57
	}
57
58
58
	/* (non-Javadoc)
59
	/* (non-Javadoc)
59
	 * @see org.eclipse.pde.internal.ui.shared.target.EditDirectoryContainerPage#initializeInputFields(org.eclipse.pde.internal.core.target.provisional.IBundleContainer)
60
	 * @see org.eclipse.pde.internal.ui.shared.target.EditDirectoryContainerPage#initializeInputFields(org.eclipse.pde.internal.core.target.provisional.IBundleContainer)
60
	 */
61
	 */
61
	protected void initializeInputFields(IBundleContainer container) {
62
	protected void initializeInputFields(IBundleContainer container) {
62
		containerChanged(0);
63
		containerChanged(0);
63
	}
64
	}
64
65
65
	/* (non-Javadoc)
66
	/* (non-Javadoc)
66
	 * @see org.eclipse.pde.internal.ui.shared.target.EditDirectoryContainerPage#storeSettings()
67
	 * @see org.eclipse.pde.internal.ui.shared.target.EditDirectoryContainerPage#storeSettings()
67
	 */
68
	 */
68
	protected void storeSettings() {
69
	protected void storeSettings() {
69
		// Do nothing, no settings
70
		// Do nothing, no settings
70
	}
71
	}
71
72
72
	/* (non-Javadoc)
73
	/* (non-Javadoc)
73
	 * @see org.eclipse.pde.internal.ui.shared.target.EditDirectoryContainerPage#validateInput()
74
	 * @see org.eclipse.pde.internal.ui.shared.target.EditDirectoryContainerPage#validateInput()
74
	 */
75
	 */
75
	protected boolean validateInput() throws CoreException {
76
	protected boolean validateInput() throws CoreException {
76
		return true;
77
		return true;
77
	}
78
	}
78
79
79
	/* (non-Javadoc)
80
	/* (non-Javadoc)
80
	 * @see org.eclipse.pde.internal.ui.shared.target.EditDirectoryContainerPage#refreshContainer(org.eclipse.pde.internal.core.target.provisional.IBundleContainer)
81
	 * @see org.eclipse.pde.internal.ui.shared.target.EditDirectoryContainerPage#refreshContainer(org.eclipse.pde.internal.core.target.provisional.IBundleContainer)
81
	 */
82
	 */
82
	protected IBundleContainer createContainer(IBundleContainer previous) throws CoreException {
83
	protected IBundleContainer refreshContainer(IBundleContainer previous) throws CoreException {
83
		return getBundleContainer();
84
		return getBundleContainer();
84
	}
85
	}
85
86
86
}
87
}
(-)src/org/eclipse/pde/internal/ui/shared/target/BundleInfoLabelProvider.java (-2 / +23 lines)
Lines 10-15 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.pde.internal.ui.shared.target;
11
package org.eclipse.pde.internal.ui.shared.target;
12
12
13
import org.eclipse.core.runtime.IPath;
13
import org.eclipse.core.runtime.IStatus;
14
import org.eclipse.core.runtime.IStatus;
14
import org.eclipse.equinox.internal.provisional.frameworkadmin.BundleInfo;
15
import org.eclipse.equinox.internal.provisional.frameworkadmin.BundleInfo;
15
import org.eclipse.jface.viewers.LabelProvider;
16
import org.eclipse.jface.viewers.LabelProvider;
Lines 18-23 Link Here
18
import org.eclipse.pde.internal.ui.PDEPluginImages;
19
import org.eclipse.pde.internal.ui.PDEPluginImages;
19
import org.eclipse.pde.internal.ui.util.SharedLabelProvider;
20
import org.eclipse.pde.internal.ui.util.SharedLabelProvider;
20
import org.eclipse.swt.graphics.Image;
21
import org.eclipse.swt.graphics.Image;
22
import org.eclipse.ui.ISharedImages;
23
import org.eclipse.ui.PlatformUI;
21
24
22
/**
25
/**
23
 * Provides text and image labels for BundleInfo and IResolveBundle objects.
26
 * Provides text and image labels for BundleInfo and IResolveBundle objects.
Lines 57-63 Link Here
57
			}
60
			}
58
			return buf.toString();
61
			return buf.toString();
59
		} else if (element instanceof IResolvedBundle) {
62
		} else if (element instanceof IResolvedBundle) {
60
			return getText(((IResolvedBundle) element).getBundleInfo());
63
			IResolvedBundle bundle = ((IResolvedBundle) element);
64
			if (!bundle.getStatus().isOK()) {
65
				// TODO Better error message for missing bundles
66
				return bundle.getStatus().getMessage();
67
			}
68
			return getText(bundle.getBundleInfo());
69
		} else if (element instanceof IStatus) {
70
			return ((IStatus) element).getMessage();
71
		} else if (element instanceof IPath) {
72
			return ((IPath) element).removeFirstSegments(1).toString();
61
		}
73
		}
62
		return super.getText(element);
74
		return super.getText(element);
63
	}
75
	}
Lines 69-75 Link Here
69
		if (element instanceof IResolvedBundle) {
81
		if (element instanceof IResolvedBundle) {
70
			IResolvedBundle bundle = (IResolvedBundle) element;
82
			IResolvedBundle bundle = (IResolvedBundle) element;
71
			int flag = 0;
83
			int flag = 0;
72
			if (bundle.getStatus().getSeverity() == IStatus.WARNING) {
84
			if (bundle.getStatus().getSeverity() == IStatus.WARNING || bundle.getStatus().getSeverity() == IStatus.INFO) {
73
				flag = SharedLabelProvider.F_WARNING;
85
				flag = SharedLabelProvider.F_WARNING;
74
			} else if (bundle.getStatus().getSeverity() == IStatus.ERROR) {
86
			} else if (bundle.getStatus().getSeverity() == IStatus.ERROR) {
75
				flag = SharedLabelProvider.F_ERROR;
87
				flag = SharedLabelProvider.F_ERROR;
Lines 84-89 Link Here
84
			}
96
			}
85
		} else if (element instanceof BundleInfo) {
97
		} else if (element instanceof BundleInfo) {
86
			return PDEPlugin.getDefault().getLabelProvider().get(PDEPluginImages.DESC_PLUGIN_OBJ);
98
			return PDEPlugin.getDefault().getLabelProvider().get(PDEPluginImages.DESC_PLUGIN_OBJ);
99
		} else if (element instanceof IStatus) {
100
			int severity = ((IStatus) element).getSeverity();
101
			if (severity == IStatus.WARNING || severity == IStatus.INFO) {
102
				return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_WARN_TSK);
103
			} else if (severity == IStatus.ERROR) {
104
				return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_ERROR_TSK);
105
			}
106
		} else if (element instanceof IPath) {
107
			return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FOLDER);
87
		}
108
		}
88
		return super.getImage(element);
109
		return super.getImage(element);
89
	}
110
	}
(-)src/org/eclipse/pde/internal/ui/shared/target/Messages.java (-6 lines)
Lines 21-27 Link Here
21
	public static String AddDirectoryContainerPage_4;
21
	public static String AddDirectoryContainerPage_4;
22
	public static String AddDirectoryContainerPage_5;
22
	public static String AddDirectoryContainerPage_5;
23
	public static String AddDirectoryContainerPage_6;
23
	public static String AddDirectoryContainerPage_6;
24
	public static String AddDirectoryContainerPage_7;
25
	public static String AddDirectoryContainerPage_9;
24
	public static String AddDirectoryContainerPage_9;
26
	public static String AddFeatureContainerPage_0;
25
	public static String AddFeatureContainerPage_0;
27
	public static String AddFeatureContainerPage_1;
26
	public static String AddFeatureContainerPage_1;
Lines 52-58 Link Here
52
	public static String BundleContainerTable_16;
51
	public static String BundleContainerTable_16;
53
	public static String BundleContainerTable_17;
52
	public static String BundleContainerTable_17;
54
	public static String BundleContainerTable_18;
53
	public static String BundleContainerTable_18;
55
	public static String BundleContainerTable_19;
56
	public static String BundleContainerTable_2;
54
	public static String BundleContainerTable_2;
57
	public static String BundleContainerTable_3;
55
	public static String BundleContainerTable_3;
58
	public static String BundleContainerTable_4;
56
	public static String BundleContainerTable_4;
Lines 63-69 Link Here
63
	public static String EditBundleContainerWizard_0;
61
	public static String EditBundleContainerWizard_0;
64
	public static String EditDirectoryContainerPage_0;
62
	public static String EditDirectoryContainerPage_0;
65
	public static String EditDirectoryContainerPage_1;
63
	public static String EditDirectoryContainerPage_1;
66
	public static String EditDirectoryContainerPage_2;
67
	public static String EditDirectoryContainerPage_3;
64
	public static String EditDirectoryContainerPage_3;
68
	public static String EditFeatureContainerPage_0;
65
	public static String EditFeatureContainerPage_0;
69
	public static String EditFeatureContainerPage_1;
66
	public static String EditFeatureContainerPage_1;
Lines 71-77 Link Here
71
	public static String EditFeatureContainerPage_3;
68
	public static String EditFeatureContainerPage_3;
72
	public static String EditFeatureContainerPage_4;
69
	public static String EditFeatureContainerPage_4;
73
	public static String EditFeatureContainerPage_5;
70
	public static String EditFeatureContainerPage_5;
74
	public static String EditProfileContainerPage_0;
75
	public static String EditProfileContainerPage_1;
71
	public static String EditProfileContainerPage_1;
76
	public static String EditProfileContainerPage_2;
72
	public static String EditProfileContainerPage_2;
77
	public static String EditProfileContainerPage_3;
73
	public static String EditProfileContainerPage_3;
Lines 84-91 Link Here
84
	public static String IncludedBundlesTree_2;
80
	public static String IncludedBundlesTree_2;
85
	public static String IncludedBundlesTree_3;
81
	public static String IncludedBundlesTree_3;
86
	public static String IncludedBundlesTree_4;
82
	public static String IncludedBundlesTree_4;
87
	public static String IncludedBundlesTree_5;
88
	public static String IncludedBundlesTree_6;
89
	public static String RestrictionsListSelectionDialog_0;
83
	public static String RestrictionsListSelectionDialog_0;
90
	public static String RestrictionsListSelectionDialog_1;
84
	public static String RestrictionsListSelectionDialog_1;
91
	public static String RestrictionsListSelectionDialog_2;
85
	public static String RestrictionsListSelectionDialog_2;
(-)src/org/eclipse/pde/internal/ui/shared/target/IBundleContainerTableReporter.java (-40 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2009 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.pde.internal.ui.shared.target;
12
13
import org.eclipse.jface.operation.IRunnableWithProgress;
14
15
/**
16
 * Does container specific actions for the BundleContainerTable.  Allows the resolve
17
 * operation to run differently (job or dialog) if the table is being used in an editor
18
 * or a wizard page.  Allows changes to the bundle containers to be reported properly.
19
 *
20
 * @see BundleContainerTable
21
 */
22
public interface IBundleContainerTableReporter {
23
24
	/**
25
	 * Runs the given operation in a container appropriate fashion.
26
	 * <p>
27
	 * This method may be called from the UI thread so implementors should
28
	 * not block.
29
	 * </p>
30
	 * @param operation the operation to run
31
	 */
32
	public void runResolveOperation(IRunnableWithProgress operation);
33
34
	/**
35
	 * Informs the container that the contents of the target's bundle 
36
	 * containers have changed.  Used to mark the editor dirty.
37
	 */
38
	public void contentsChanged();
39
40
}
(-)src/org/eclipse/pde/internal/ui/shared/target/IncludedBundlesTree.java (-598 lines)
Removed Link Here
1
package org.eclipse.pde.internal.ui.shared.target;
2
3
import com.ibm.icu.text.MessageFormat;
4
import java.io.File;
5
import java.util.*;
6
import org.eclipse.core.runtime.IStatus;
7
import org.eclipse.core.runtime.Status;
8
import org.eclipse.equinox.internal.provisional.frameworkadmin.BundleInfo;
9
import org.eclipse.jface.viewers.*;
10
import org.eclipse.pde.internal.core.target.impl.AbstractBundleContainer;
11
import org.eclipse.pde.internal.core.target.provisional.IBundleContainer;
12
import org.eclipse.pde.internal.core.target.provisional.IResolvedBundle;
13
import org.eclipse.pde.internal.ui.PDEPlugin;
14
import org.eclipse.pde.internal.ui.SWTFactory;
15
import org.eclipse.swt.SWT;
16
import org.eclipse.swt.events.SelectionAdapter;
17
import org.eclipse.swt.events.SelectionEvent;
18
import org.eclipse.swt.layout.GridData;
19
import org.eclipse.swt.widgets.*;
20
import org.eclipse.ui.dialogs.FilteredTree;
21
import org.eclipse.ui.dialogs.PatternFilter;
22
23
public class IncludedBundlesTree extends FilteredTree {
24
25
	private CheckboxTreeViewer fTree;
26
	private Button fSelectButton;
27
	private Button fDeselectButton;
28
	private Button fSelectAllButton;
29
	private Button fDeselectAllButton;
30
//	private Button fSelectRequiredButton;
31
	private Label fShowLabel;
32
	private Button fShowSourceButton;
33
	private Button fShowPluginsButton;
34
	private Label fCountLabel;
35
	private ViewerFilter fSourceFilter;
36
	private ViewerFilter fPluginFilter;
37
	private IResolvedBundle[] fAllBundles;
38
	private Button fGroupPlugins;
39
	private HashMap fTreeViewerContents;
40
	private boolean fIsGroupedByLocation;
41
42
	public IncludedBundlesTree(Composite parent) {
43
		super(parent, SWT.BORDER | SWT.MULTI, new PatternFilter(), true);
44
	}
45
46
	protected Control createTreeControl(Composite parent, int style) {
47
		fIsGroupedByLocation = false;
48
		Composite treeComp = SWTFactory.createComposite(parent, 2, 1, GridData.FILL_BOTH, 0, 0);
49
		super.createTreeControl(treeComp, style);
50
		((GridData) fTree.getControl().getLayoutData()).heightHint = 300;
51
		createButtons(treeComp);
52
		fCountLabel = SWTFactory.createLabel(treeComp, "", 2); //$NON-NLS-1$
53
		updateButtons();
54
		initializeFilters();
55
		initializeTreeContents(fAllBundles);
56
		return treeComp;
57
	}
58
59
	protected void createButtons(Composite parent) {
60
		Composite buttonComp = SWTFactory.createComposite(parent, 1, 1, GridData.FILL_VERTICAL, 0, 0);
61
62
		// TODO Add Mnemonics
63
		fSelectButton = SWTFactory.createPushButton(buttonComp, Messages.IncludedBundlesTree_0, null);
64
		fSelectButton.addSelectionListener(new SelectionAdapter() {
65
			public void widgetSelected(SelectionEvent e) {
66
				if (!fTree.getSelection().isEmpty()) {
67
					Object[] selected = ((IStructuredSelection) fTree.getSelection()).toArray();
68
					for (int i = 0; i < selected.length; i++) {
69
						if (fIsGroupedByLocation) {
70
							handleCheck(selected[i], true);
71
						} else {
72
							fTree.setChecked(selected[i], true);
73
						}
74
					}
75
					updateButtons();
76
				}
77
			}
78
		});
79
		fDeselectButton = SWTFactory.createPushButton(buttonComp, Messages.IncludedBundlesTree_1, null);
80
		fDeselectButton.addSelectionListener(new SelectionAdapter() {
81
			public void widgetSelected(SelectionEvent e) {
82
				if (!fTree.getSelection().isEmpty()) {
83
					Object[] selected = ((IStructuredSelection) fTree.getSelection()).toArray();
84
					for (int i = 0; i < selected.length; i++) {
85
						if (fIsGroupedByLocation) {
86
							handleCheck(selected[i], false);
87
						} else {
88
							fTree.setChecked(selected[i], false);
89
						}
90
					}
91
					updateButtons();
92
				}
93
			}
94
		});
95
96
		createEmptySpace(buttonComp);
97
98
		fSelectAllButton = SWTFactory.createPushButton(buttonComp, Messages.IncludedBundlesTree_2, null);
99
		fSelectAllButton.addSelectionListener(new SelectionAdapter() {
100
			public void widgetSelected(SelectionEvent e) {
101
				if (fIsGroupedByLocation) {
102
					Iterator iter = fTreeViewerContents.keySet().iterator();
103
					while (iter.hasNext()) {
104
						handleCheck(iter.next(), true);
105
					}
106
107
				} else {
108
					// We only want to check visible
109
					fTree.setAllChecked(true);
110
				}
111
112
				updateButtons();
113
			}
114
		});
115
		fDeselectAllButton = SWTFactory.createPushButton(buttonComp, Messages.IncludedBundlesTree_3, null);
116
		fDeselectAllButton.addSelectionListener(new SelectionAdapter() {
117
			public void widgetSelected(SelectionEvent e) {
118
119
				if (fIsGroupedByLocation) {
120
					Iterator iter = fTreeViewerContents.keySet().iterator();
121
					while (iter.hasNext()) {
122
						handleCheck(iter.next(), false);
123
					}
124
125
				} else {
126
					// We only want to uncheck visible
127
					fTree.setAllChecked(false);
128
				}
129
				updateButtons();
130
			}
131
		});
132
133
		createEmptySpace(buttonComp);
134
135
		// TODO Support selecting required.
136
//		fSelectRequiredButton = SWTFactory.createPushButton(buttonComp, Messages.IncludedBundlesTree_4, null);
137
//		fSelectRequiredButton.addSelectionListener(new SelectionAdapter() {
138
//			public void widgetSelected(SelectionEvent e) {
139
//				updateButtons();
140
//			}
141
//		});
142
143
		Composite filterComp = SWTFactory.createComposite(buttonComp, 1, 1, SWT.NONE, 0, 0);
144
		filterComp.setLayoutData(new GridData(SWT.LEFT, SWT.BOTTOM, true, true));
145
146
		fGroupPlugins = SWTFactory.createCheckButton(filterComp, Messages.IncludedBundlesTree_6, null, false, 1);
147
		fGroupPlugins.addSelectionListener(new SelectionAdapter() {
148
			public void widgetSelected(SelectionEvent e) {
149
				setEnabled(false);
150
				fIsGroupedByLocation = fGroupPlugins.getSelection();
151
				Object[] checkedElements = fTree.getCheckedElements();
152
				fTree.setContentProvider(getContentProviderForTree());
153
154
				if (fIsGroupedByLocation) {
155
					fTree.expandAll();
156
					fTree.setCheckedElements(checkedElements);
157
					Iterator iter = fTreeViewerContents.keySet().iterator();
158
					HashMap bundles = null;
159
					Object key = null;
160
161
					while (iter.hasNext()) {
162
						key = iter.next();
163
						bundles = (HashMap) fTreeViewerContents.get(key);
164
165
						Iterator childIter = bundles.keySet().iterator();
166
						boolean allChilrenSelected = true;
167
						boolean noneChildrenSelected = true;
168
						while (childIter.hasNext()) {
169
							Object bundle = childIter.next();
170
							boolean checkedState = ((Boolean) bundles.get(bundle)).booleanValue();
171
							allChilrenSelected = allChilrenSelected && checkedState;
172
							noneChildrenSelected = noneChildrenSelected && !checkedState;
173
174
						}
175
						fTree.setChecked(key, !noneChildrenSelected);
176
						fTree.setGrayed(key, !allChilrenSelected && !noneChildrenSelected);
177
					}
178
				}
179
				updateButtons();
180
				setEnabled(true);
181
			}
182
		});
183
		fShowLabel = SWTFactory.createLabel(filterComp, Messages.BundleContainerTable_9, 1);
184
185
		fShowPluginsButton = SWTFactory.createCheckButton(filterComp, Messages.BundleContainerTable_14, null, true, 1);
186
		fShowPluginsButton.addSelectionListener(new SelectionAdapter() {
187
			public void widgetSelected(SelectionEvent e) {
188
				if (!fShowPluginsButton.getSelection()) {
189
					fTree.addFilter(fPluginFilter);
190
				} else {
191
					fTree.removeFilter(fPluginFilter);
192
				}
193
				updateButtons();
194
			}
195
		});
196
		fShowPluginsButton.setSelection(true);
197
		GridData gd = new GridData();
198
		gd.horizontalIndent = 10;
199
		fShowPluginsButton.setLayoutData(gd);
200
201
		fShowSourceButton = SWTFactory.createCheckButton(filterComp, Messages.BundleContainerTable_15, null, true, 1);
202
		fShowSourceButton.addSelectionListener(new SelectionAdapter() {
203
			public void widgetSelected(SelectionEvent e) {
204
				if (!fShowSourceButton.getSelection()) {
205
					fTree.addFilter(fSourceFilter);
206
				} else {
207
					fTree.removeFilter(fSourceFilter);
208
				}
209
				updateButtons();
210
			}
211
		});
212
		fShowSourceButton.setSelection(true);
213
		gd = new GridData();
214
		gd.horizontalIndent = 10;
215
		fShowSourceButton.setLayoutData(gd);
216
217
	}
218
219
	/**
220
	 * returns a HashMap which contains all the new File objects representing a new location
221
	 */
222
	protected HashMap initializeTreeContents(IResolvedBundle[] allBundles) {
223
		HashMap parents = new HashMap();
224
		if (allBundles == null)
225
			return null;
226
227
		if (fTreeViewerContents == null)
228
			fTreeViewerContents = new HashMap();
229
		else
230
			fTreeViewerContents.clear();
231
232
		for (int i = 0; i < allBundles.length; i++) {
233
			IResolvedBundle bundle = allBundles[i];
234
235
			String path = bundle.getBundleInfo().getLocation().getRawPath();
236
			if (path != null) {
237
				File installFile = new File(path);
238
				File parentFile = installFile.getParentFile();
239
				HashMap bundles = (HashMap) fTreeViewerContents.get(parentFile);
240
				if (bundles == null) {
241
					bundles = new HashMap();
242
					bundles.put(bundle, new Boolean(fTree.getChecked(bundle)));
243
					fTreeViewerContents.put(parentFile, bundles);
244
					parents.put(parentFile, Boolean.FALSE);
245
				} else {
246
					bundles.put(bundle, new Boolean(fTree.getChecked(bundle)));
247
				}
248
			}
249
		}
250
251
		return parents;
252
	}
253
254
	private void initializeFilters() {
255
		fSourceFilter = new ViewerFilter() {
256
			public boolean select(Viewer viewer, Object parentElement, Object element) {
257
				if (element instanceof IResolvedBundle) {
258
					if (((IResolvedBundle) element).isSourceBundle()) {
259
						return false;
260
					}
261
				}
262
				return true;
263
			}
264
		};
265
		fPluginFilter = new ViewerFilter() {
266
			public boolean select(Viewer viewer, Object parentElement, Object element) {
267
				if (element instanceof IResolvedBundle) {
268
					if (!((IResolvedBundle) element).isSourceBundle()) {
269
						return false;
270
					}
271
				}
272
				return true;
273
			}
274
		};
275
	}
276
277
	private Label createEmptySpace(Composite parent) {
278
		Label label = new Label(parent, SWT.NONE);
279
		GridData gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
280
		gd.widthHint = gd.heightHint = 5;
281
		label.setLayoutData(gd);
282
		return label;
283
	}
284
285
	private void updateButtons() {
286
		if (fAllBundles != null && !fTree.getSelection().isEmpty()) {
287
			Object[] selection = ((IStructuredSelection) fTree.getSelection()).toArray();
288
			boolean allSelected = true;
289
			boolean noneSelected = true;
290
			for (int i = 0; i < selection.length; i++) {
291
				boolean checked = fTree.getChecked(selection[i]);
292
				if (checked) {
293
					noneSelected = false;
294
				} else {
295
					allSelected = false;
296
				}
297
			}
298
			fSelectButton.setEnabled(!allSelected);
299
			fDeselectButton.setEnabled(!noneSelected);
300
//			fSelectRequiredButton.setEnabled(true);
301
		} else {
302
			fSelectButton.setEnabled(false);
303
			fDeselectButton.setEnabled(false);
304
//			fSelectRequiredButton.setEnabled(false);
305
		}
306
307
		int checked;
308
		if (fIsGroupedByLocation) {
309
			checked = fTree.getCheckedElements().length;
310
			Iterator iter = fTreeViewerContents.keySet().iterator();
311
			while (iter.hasNext()) {
312
				if (fTree.getChecked(iter.next())) {
313
					--checked;
314
				}
315
			}
316
		} else {
317
			checked = fTree.getCheckedElements().length;
318
		}
319
		fSelectAllButton.setEnabled(fAllBundles != null && checked != fTree.getTree().getItemCount());
320
		fDeselectAllButton.setEnabled(fAllBundles != null && checked != 0);
321
322
		if (fAllBundles != null) {
323
			fCountLabel.setText(MessageFormat.format(Messages.IncludedBundlesTree_5, new String[] {Integer.toString(checked), Integer.toString(fAllBundles.length)}));
324
		} else {
325
			fCountLabel.setText(""); //$NON-NLS-1$
326
		}
327
	}
328
329
	/**
330
	 * Set the container to display in the tree or <code>null</code> to disable the tree 
331
	 * @param input bundle container or <code>null</code>
332
	 */
333
	public void setInput(IBundleContainer input) {
334
		fAllBundles = null;
335
336
		// Check that the input is a container with valid, resolved bundles
337
		if (!(input instanceof AbstractBundleContainer)) {
338
			fTree.setInput(Messages.AddDirectoryContainerPage_7);
339
			setEnabled(false);
340
			return;
341
		}
342
		if (!input.isResolved()) {
343
			fTree.setInput(new Status(IStatus.ERROR, PDEPlugin.getPluginId(), Messages.BundleContainerTable_19));
344
			setEnabled(false);
345
			return;
346
		}
347
		IStatus status = input.getBundleStatus();
348
		if (!status.isOK() && !status.isMultiStatus()) {
349
			fTree.setInput(status);
350
			setEnabled(false);
351
			return;
352
		}
353
		IResolvedBundle[] allResolvedBundles = ((AbstractBundleContainer) input).getAllBundles();
354
		if (allResolvedBundles == null || allResolvedBundles.length == 0) {
355
			fTree.setInput(Messages.AddDirectoryContainerPage_7);
356
			setEnabled(false);
357
			return;
358
		}
359
360
		// Input is valid, setup the tree
361
		fAllBundles = allResolvedBundles;
362
		fTree.setInput(allResolvedBundles);
363
364
		// Check the included bundles
365
		BundleInfo[] included = input.getIncludedBundles();
366
		if (included == null) {
367
			fTree.setCheckedElements(fAllBundles);
368
		} else {
369
			Set includedBundles = new HashSet();
370
			for (int i = 0; i < included.length; i++) {
371
				includedBundles.add(included[i].getSymbolicName());
372
			}
373
			java.util.List toCheck = new ArrayList(includedBundles.size());
374
			for (int i = 0; i < allResolvedBundles.length; i++) {
375
				if (includedBundles.contains(allResolvedBundles[i].getBundleInfo().getSymbolicName())) {
376
					toCheck.add(allResolvedBundles[i]);
377
				}
378
			}
379
			fTree.setCheckedElements(toCheck.toArray());
380
		}
381
382
		// Enable the tree and update the buttons
383
		setEnabled(true);
384
	}
385
386
	/* (non-Javadoc)
387
	 * @see org.eclipse.swt.widgets.Control#setEnabled(boolean)
388
	 */
389
	public void setEnabled(boolean enabled) {
390
		super.setEnabled(enabled);
391
		if (enabled) {
392
			updateButtons();
393
		} else {
394
			fSelectButton.setEnabled(false);
395
			fSelectAllButton.setEnabled(false);
396
			fDeselectButton.setEnabled(false);
397
			fDeselectAllButton.setEnabled(false);
398
//			fSelectRequiredButton.setEnabled(false);
399
			fCountLabel.setText(""); //$NON-NLS-1$
400
		}
401
		fShowLabel.setEnabled(enabled);
402
		fShowPluginsButton.setEnabled(enabled);
403
		fShowSourceButton.setEnabled(enabled);
404
		super.setEnabled(enabled);
405
	}
406
407
	protected TreeViewer doCreateTreeViewer(Composite parent, int style) {
408
		fTree = new CheckboxTreeViewer(parent, style) {
409
			public void refresh(boolean updateLabels) {
410
				super.refresh(updateLabels);
411
				if (updateLabels) {
412
					// We want to update the labels and buttons as users change the filtering
413
					updateButtons();
414
				}
415
			}
416
		};
417
		fTree.setContentProvider(getContentProviderForTree());
418
		fTree.setLabelProvider(new BundleInfoLabelProvider(false));
419
		fTree.addDoubleClickListener(new IDoubleClickListener() {
420
			public void doubleClick(DoubleClickEvent event) {
421
				IStructuredSelection selection = (IStructuredSelection) event.getSelection();
422
				fTree.setChecked(selection.getFirstElement(), !fTree.getChecked(selection.getFirstElement()));
423
				updateButtons();
424
			}
425
		});
426
		fTree.addCheckStateListener(new ICheckStateListener() {
427
428
			public void checkStateChanged(CheckStateChangedEvent event) {
429
				if (fIsGroupedByLocation) {
430
					handleCheck(event.getElement(), event.getChecked());
431
					updateButtons();
432
				}
433
			}
434
		});
435
		fTree.addSelectionChangedListener(new ISelectionChangedListener() {
436
			public void selectionChanged(SelectionChangedEvent event) {
437
				updateButtons();
438
			}
439
		});
440
		fTree.setSorter(new ViewerSorter());
441
		return fTree;
442
	}
443
444
	/**
445
	 * Marks the check state of <code>element</code> to <code>state</code> when plug-ins are grouped by location 
446
	 */
447
	private void handleCheck(Object element, boolean state) {
448
		if (fTreeViewerContents.containsKey(element)) {
449
450
			HashMap bundles = (HashMap) fTreeViewerContents.get(element);
451
			Iterator iter = bundles.keySet().iterator();
452
			while (iter.hasNext()) {
453
				Object key = iter.next();
454
				bundles.put(key, new Boolean(state));
455
				fTree.setChecked(key, state);
456
			}
457
			fTree.setChecked(element, state);
458
			fTree.setGrayed(element, false);
459
			return;
460
		}
461
		Iterator iter = fTreeViewerContents.keySet().iterator();
462
		HashMap bundles = null;
463
		Object key = null;
464
		while (iter.hasNext()) {
465
			key = iter.next();
466
			bundles = (HashMap) fTreeViewerContents.get(key);
467
			if (bundles.containsKey(element)) {
468
				bundles.put(element, new Boolean(state));
469
				break;
470
			}
471
		}
472
		iter = bundles.keySet().iterator();
473
		boolean allChilrenSelected = true;
474
		boolean noneChildrenSelected = true;
475
		while (iter.hasNext()) {
476
			Object bundle = iter.next();
477
			boolean checkedState = ((Boolean) bundles.get(bundle)).booleanValue();
478
			allChilrenSelected = allChilrenSelected && checkedState;
479
			noneChildrenSelected = noneChildrenSelected && !checkedState;
480
		}
481
		fTree.setChecked(element, state);
482
		fTree.setChecked(key, !noneChildrenSelected);
483
		fTree.setGrayed(key, !allChilrenSelected && !noneChildrenSelected);
484
	}
485
486
	private ITreeContentProvider getContentProviderForTree() {
487
		if (fIsGroupedByLocation) {
488
489
			//Content provider for grouped by location
490
			return (new ITreeContentProvider() {
491
492
				public Object[] getChildren(Object parentElement) {
493
					if (parentElement instanceof File) {
494
						HashMap files = (HashMap) fTreeViewerContents.get(parentElement);
495
						if (files != null) {
496
							Object[] result = files.keySet().toArray();
497
							return result;
498
						}
499
					}
500
					return new Object[0];
501
				}
502
503
				public Object getParent(Object element) {
504
					if (element instanceof IResolvedBundle) {
505
						IResolvedBundle bundle = (IResolvedBundle) element;
506
						String installPath = bundle.getBundleInfo().getLocation().getPath();
507
						if (installPath != null)
508
							return new File(installPath).getParentFile();
509
					}
510
					return null;
511
				}
512
513
				public boolean hasChildren(Object element) {
514
					if (element instanceof File)
515
						return fTreeViewerContents.containsKey(element);
516
					return false;
517
				}
518
519
				public Object[] getElements(Object inputElement) {
520
					if (fTreeViewerContents == null)
521
						return initializeTreeContents(fAllBundles).keySet().toArray();
522
					return fTreeViewerContents.keySet().toArray();
523
				}
524
525
				public void dispose() {
526
				}
527
528
				public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
529
				}
530
			});
531
		}
532
533
		//ungrouped content provider
534
		return (new ITreeContentProvider() {
535
			public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
536
			}
537
538
			public void dispose() {
539
			}
540
541
			public Object[] getElements(Object inputElement) {
542
				if (inputElement instanceof IResolvedBundle[]) {
543
					return (IResolvedBundle[]) inputElement;
544
				}
545
				return new Object[] {inputElement};
546
			}
547
548
			public boolean hasChildren(Object element) {
549
				return false;
550
			}
551
552
			public Object getParent(Object element) {
553
				return null;
554
			}
555
556
			public Object[] getChildren(Object parentElement) {
557
				return new Object[0];
558
			}
559
		});
560
	}
561
562
	/**
563
	 * Return the set of bundles to include in this bundle container based on what is
564
	 * checked in the tree.  If all bundles in the container are checked or there was
565
	 * a problem getting the bundles from the container, this method will return 
566
	 * <code>null</code>
567
	 * 
568
	 * @return set of bundles to include or <code>null</code>
569
	 */
570
	public BundleInfo[] getIncludedBundles() {
571
		if (fTree.getControl().isEnabled() && fAllBundles != null) {
572
			Object[] checked = fTree.getCheckedElements();
573
			if (fIsGroupedByLocation) {
574
				int count = fTree.getCheckedElements().length;
575
				Iterator iter = fTreeViewerContents.keySet().iterator();
576
				while (iter.hasNext()) {
577
					if (fTree.getChecked(iter.next())) {
578
						--count;
579
					}
580
				}
581
				if (count == fAllBundles.length)
582
					return null;
583
584
			} else if (checked.length == fAllBundles.length) {
585
				return null;
586
			}
587
588
			java.util.List included = new ArrayList(checked.length);
589
			for (int i = 0; i < checked.length; i++) {
590
				if (checked[i] instanceof IResolvedBundle) {
591
					included.add(new BundleInfo(((IResolvedBundle) checked[i]).getBundleInfo().getSymbolicName(), null, null, BundleInfo.NO_LEVEL, false));
592
				}
593
			}
594
			return (BundleInfo[]) included.toArray(new BundleInfo[included.size()]);
595
		}
596
		return null;
597
	}
598
}
(-)src/org/eclipse/pde/internal/ui/shared/target/AddBundleContainerSelectionPage.java (-4 / +50 lines)
Lines 163-180 Link Here
163
		standardChoices.add(new AbstractBundleContainerNode(Messages.AddBundleContainerSelectionPage_3, Messages.AddBundleContainerSelectionPage_4, PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FOLDER)) {
163
		standardChoices.add(new AbstractBundleContainerNode(Messages.AddBundleContainerSelectionPage_3, Messages.AddBundleContainerSelectionPage_4, PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FOLDER)) {
164
			public IWizard createWizard() {
164
			public IWizard createWizard() {
165
				Wizard wizard = new Wizard() {
165
				Wizard wizard = new Wizard() {
166
					private EditDirectoryContainerPage fPage1;
167
166
					public void addPages() {
168
					public void addPages() {
167
						IDialogSettings settings = PDEPlugin.getDefault().getDialogSettings().getSection(SETTINGS_SECTION);
169
						IDialogSettings settings = PDEPlugin.getDefault().getDialogSettings().getSection(SETTINGS_SECTION);
168
						if (settings == null) {
170
						if (settings == null) {
169
							settings = PDEPlugin.getDefault().getDialogSettings().addNewSection(SETTINGS_SECTION);
171
							settings = PDEPlugin.getDefault().getDialogSettings().addNewSection(SETTINGS_SECTION);
170
						}
172
						}
171
						setDialogSettings(settings);
173
						setDialogSettings(settings);
172
						addPage(new EditDirectoryContainerPage(fTarget));
174
						fPage1 = new EditDirectoryContainerPage();
175
						addPage(fPage1);
176
						addPage(new PreviewContainerPage(fTarget, fPage1));
177
						setNeedsProgressMonitor(true);
173
					}
178
					}
174
179
175
					public boolean performFinish() {
180
					public boolean performFinish() {
176
						IBundleContainer container = ((EditDirectoryContainerPage) getPages()[0]).getBundleContainer();
181
						IBundleContainer container = fPage1.getBundleContainer();
177
						if (container != null) {
182
						if (container != null) {
183
							fPage1.storeSettings();
178
							IBundleContainer[] oldContainers = fTarget.getBundleContainers();
184
							IBundleContainer[] oldContainers = fTarget.getBundleContainers();
179
							if (oldContainers == null) {
185
							if (oldContainers == null) {
180
								fTarget.setBundleContainers(new IBundleContainer[] {container});
186
								fTarget.setBundleContainers(new IBundleContainer[] {container});
Lines 195-212 Link Here
195
		standardChoices.add(new AbstractBundleContainerNode(Messages.AddBundleContainerSelectionPage_6, Messages.AddBundleContainerSelectionPage_7, PDEPlugin.getDefault().getLabelProvider().get(PDEPluginImages.DESC_PRODUCT_DEFINITION)) {
201
		standardChoices.add(new AbstractBundleContainerNode(Messages.AddBundleContainerSelectionPage_6, Messages.AddBundleContainerSelectionPage_7, PDEPlugin.getDefault().getLabelProvider().get(PDEPluginImages.DESC_PRODUCT_DEFINITION)) {
196
			public IWizard createWizard() {
202
			public IWizard createWizard() {
197
				Wizard wizard = new Wizard() {
203
				Wizard wizard = new Wizard() {
204
					private EditDirectoryContainerPage fPage1;
205
198
					public void addPages() {
206
					public void addPages() {
199
						IDialogSettings settings = PDEPlugin.getDefault().getDialogSettings().getSection(SETTINGS_SECTION);
207
						IDialogSettings settings = PDEPlugin.getDefault().getDialogSettings().getSection(SETTINGS_SECTION);
200
						if (settings == null) {
208
						if (settings == null) {
201
							settings = PDEPlugin.getDefault().getDialogSettings().addNewSection(SETTINGS_SECTION);
209
							settings = PDEPlugin.getDefault().getDialogSettings().addNewSection(SETTINGS_SECTION);
202
						}
210
						}
203
						setDialogSettings(settings);
211
						setDialogSettings(settings);
204
						addPage(new EditProfileContainerPage(fTarget));
212
						setDialogSettings(settings);
213
						fPage1 = new EditProfileContainerPage();
214
						addPage(fPage1);
215
						addPage(new PreviewContainerPage(fTarget, fPage1));
216
						setNeedsProgressMonitor(true);
205
					}
217
					}
206
218
207
					public boolean performFinish() {
219
					public boolean performFinish() {
208
						IBundleContainer container = ((EditProfileContainerPage) getPages()[0]).getBundleContainer();
220
						IBundleContainer container = ((EditProfileContainerPage) getPages()[0]).getBundleContainer();
209
						if (container != null) {
221
						if (container != null) {
222
							((EditProfileContainerPage) getPages()[0]).storeSettings();
210
							IBundleContainer[] oldContainers = fTarget.getBundleContainers();
223
							IBundleContainer[] oldContainers = fTarget.getBundleContainers();
211
							if (oldContainers == null) {
224
							if (oldContainers == null) {
212
								fTarget.setBundleContainers(new IBundleContainer[] {container});
225
								fTarget.setBundleContainers(new IBundleContainer[] {container});
Lines 233-245 Link Here
233
							settings = PDEPlugin.getDefault().getDialogSettings().addNewSection(SETTINGS_SECTION);
246
							settings = PDEPlugin.getDefault().getDialogSettings().addNewSection(SETTINGS_SECTION);
234
						}
247
						}
235
						setDialogSettings(settings);
248
						setDialogSettings(settings);
236
						addPage(new AddFeatureContainersPage(fTarget));
249
						addPage(new AddFeatureContainersPage());
237
					}
250
					}
238
251
239
					public boolean performFinish() {
252
					public boolean performFinish() {
240
						try {
253
						try {
241
							IBundleContainer[] containers = ((AddFeatureContainersPage) getPages()[0]).getBundleContainers();
254
							IBundleContainer[] containers = ((AddFeatureContainersPage) getPages()[0]).getBundleContainers();
242
							if (containers != null) {
255
							if (containers != null) {
256
								((AddFeatureContainersPage) getPages()[0]).storeSettings();
243
								IBundleContainer[] oldContainers = fTarget.getBundleContainers();
257
								IBundleContainer[] oldContainers = fTarget.getBundleContainers();
244
								// TODO: show progress as resolving
258
								// TODO: show progress as resolving
245
								for (int i = 0; i < containers.length; i++) {
259
								for (int i = 0; i < containers.length; i++) {
Lines 266-271 Link Here
266
				return wizard;
280
				return wizard;
267
			}
281
			}
268
		});
282
		});
283
		standardChoices.add(new AbstractBundleContainerNode("Repository or Update Site", "Download plug-ins from a p2 repository or update site.", PDEPlugin.getDefault().getLabelProvider().get(PDEPluginImages.DESC_REPOSITORY_OBJ)) {
284
			public IWizard createWizard() {
285
				Wizard wizard = new Wizard() {
286
					public void addPages() {
287
						IDialogSettings settings = PDEPlugin.getDefault().getDialogSettings().getSection(SETTINGS_SECTION);
288
						if (settings == null) {
289
							settings = PDEPlugin.getDefault().getDialogSettings().addNewSection(SETTINGS_SECTION);
290
						}
291
						setDialogSettings(settings);
292
						addPage(new AddP2ContainerPage());
293
					}
294
295
					public boolean performFinish() {
296
						IBundleContainer container = ((AddP2ContainerPage) getPages()[0]).getBundleContainer();
297
						if (container != null) {
298
							IBundleContainer[] oldContainers = fTarget.getBundleContainers();
299
							if (oldContainers == null) {
300
								fTarget.setBundleContainers(new IBundleContainer[] {container});
301
							} else {
302
								IBundleContainer[] newContainers = new IBundleContainer[oldContainers.length + 1];
303
								System.arraycopy(oldContainers, 0, newContainers, 0, oldContainers.length);
304
								newContainers[newContainers.length - 1] = container;
305
								fTarget.setBundleContainers(newContainers);
306
							}
307
						}
308
						return true;
309
					}
310
				};
311
				wizard.setWindowTitle(Messages.AddBundleContainerSelectionPage_1);
312
				return wizard;
313
			}
314
		});
269
		return standardChoices;
315
		return standardChoices;
270
	}
316
	}
271
317
(-)src/org/eclipse/pde/internal/ui/shared/target/EditDirectoryContainerPage.java (-69 / +26 lines)
Lines 23-33 Link Here
23
import org.eclipse.pde.internal.core.PDECore;
23
import org.eclipse.pde.internal.core.PDECore;
24
import org.eclipse.pde.internal.core.target.impl.AbstractBundleContainer;
24
import org.eclipse.pde.internal.core.target.impl.AbstractBundleContainer;
25
import org.eclipse.pde.internal.core.target.impl.DirectoryBundleContainer;
25
import org.eclipse.pde.internal.core.target.impl.DirectoryBundleContainer;
26
import org.eclipse.pde.internal.core.target.provisional.*;
26
import org.eclipse.pde.internal.core.target.provisional.IBundleContainer;
27
import org.eclipse.pde.internal.core.target.provisional.ITargetPlatformService;
27
import org.eclipse.pde.internal.ui.PDEPlugin;
28
import org.eclipse.pde.internal.ui.PDEPlugin;
28
import org.eclipse.pde.internal.ui.SWTFactory;
29
import org.eclipse.pde.internal.ui.SWTFactory;
29
import org.eclipse.swt.SWT;
30
import org.eclipse.swt.SWT;
30
import org.eclipse.swt.custom.BusyIndicator;
31
import org.eclipse.swt.events.*;
31
import org.eclipse.swt.events.*;
32
import org.eclipse.swt.layout.GridData;
32
import org.eclipse.swt.layout.GridData;
33
import org.eclipse.swt.widgets.*;
33
import org.eclipse.swt.widgets.*;
Lines 42-53 Link Here
42
 */
42
 */
43
public class EditDirectoryContainerPage extends WizardPage {
43
public class EditDirectoryContainerPage extends WizardPage {
44
44
45
	protected static final int TYPING_DELAY = 600;
45
	/**
46
	 * How long to wait before validating the directory
47
	 */
48
	protected static final int TYPING_DELAY = 200;
49
46
	private static ITargetPlatformService fTargetService;
50
	private static ITargetPlatformService fTargetService;
47
	protected Combo fInstallLocation;
51
	protected Combo fInstallLocation;
48
	protected IncludedBundlesTree fBundleTree;
49
	protected IBundleContainer fContainer;
52
	protected IBundleContainer fContainer;
50
	private ITargetDefinition fTarget;
51
	private Job fTextChangedJob;
53
	private Job fTextChangedJob;
52
54
53
	/**
55
	/**
Lines 65-78 Link Here
65
	 */
67
	 */
66
	private static final String SETTINGS_LOCATION_3 = "location3"; //$NON-NLS-1$
68
	private static final String SETTINGS_LOCATION_3 = "location3"; //$NON-NLS-1$
67
69
68
	protected EditDirectoryContainerPage(ITargetDefinition target, IBundleContainer container) {
70
	protected EditDirectoryContainerPage(IBundleContainer container) {
69
		this(target);
71
		this();
70
		fContainer = container;
72
		fContainer = container;
71
	}
73
	}
72
74
73
	protected EditDirectoryContainerPage(ITargetDefinition target) {
75
	protected EditDirectoryContainerPage() {
74
		super("EditDirectoryContainer"); //$NON-NLS-1$
76
		super("EditDirectoryContainer"); //$NON-NLS-1$
75
		fTarget = target;
76
	}
77
	}
77
78
78
	/* (non-Javadoc)
79
	/* (non-Javadoc)
Lines 81-89 Link Here
81
	public void createControl(Composite parent) {
82
	public void createControl(Composite parent) {
82
		setMessage(getDefaultMessage());
83
		setMessage(getDefaultMessage());
83
		setTitle(getDefaultTitle());
84
		setTitle(getDefaultTitle());
85
		setPageComplete(false);
84
		Composite comp = SWTFactory.createComposite(parent, 1, 1, GridData.FILL_BOTH, 0, 0);
86
		Composite comp = SWTFactory.createComposite(parent, 1, 1, GridData.FILL_BOTH, 0, 0);
85
		createLocationArea(comp);
87
		createLocationArea(comp);
86
		createTableArea(comp);
87
		setControl(comp);
88
		setControl(comp);
88
		initializeInputFields(fContainer);
89
		initializeInputFields(fContainer);
89
	}
90
	}
Lines 171-188 Link Here
171
	}
172
	}
172
173
173
	/**
174
	/**
174
	 * Creates the area at the bottom of the page.  Contains a table intended to display
175
	 * the current resolved bundles.  This class may be overridden by subclasses to 
176
	 * provide custom widgets.
177
	 * @param parent parent composite
178
	 */
179
	protected void createTableArea(Composite parent) {
180
		Group tableGroup = SWTFactory.createGroup(parent, Messages.EditDirectoryContainerPage_2, 2, 1, GridData.FILL_BOTH);
181
		fBundleTree = new IncludedBundlesTree(tableGroup);
182
		fBundleTree.setInput(null);
183
	}
184
185
	/**
186
	 * Initializes the fields use to describe the container.  They should be filled in using
175
	 * Initializes the fields use to describe the container.  They should be filled in using
187
	 * the given container or set to default values if the container is <code>null</code>.
176
	 * the given container or set to default values if the container is <code>null</code>.
188
	 * @param container bundle container being edited, possibly <code>null</code>
177
	 * @param container bundle container being edited, possibly <code>null</code>
Lines 246-251 Link Here
246
235
247
	/**
236
	/**
248
	 * Store all of the dialog settings for this page
237
	 * Store all of the dialog settings for this page
238
	 * Should be explicitly called during the perform finish call of the wizard
249
	 */
239
	 */
250
	protected void storeSettings() {
240
	protected void storeSettings() {
251
		String newLocation = fInstallLocation.getText().trim();
241
		String newLocation = fInstallLocation.getText().trim();
Lines 275-280 Link Here
275
	}
265
	}
276
266
277
	/**
267
	/**
268
	 * @return bundle container created/edited in this wizard or <code>null</code>
269
	 */
270
	public IBundleContainer getBundleContainer() {
271
		return fContainer;
272
	}
273
274
	/**
278
	 * Called whenever the location or another aspect of the container has changed
275
	 * Called whenever the location or another aspect of the container has changed
279
	 * in the UI.  Will schedule a UIJob to verify and resolve the container 
276
	 * in the UI.  Will schedule a UIJob to verify and resolve the container 
280
	 * reporting any problems to the user.  If a previous job is running or sleeping
277
	 * reporting any problems to the user.  If a previous job is running or sleeping
Lines 284-290 Link Here
284
	 */
281
	 */
285
	protected void containerChanged(long delay) {
282
	protected void containerChanged(long delay) {
286
		if (fTextChangedJob == null) {
283
		if (fTextChangedJob == null) {
287
			fTextChangedJob = new ResolveJob(getShell().getDisplay(), Messages.EditDirectoryContainerPage_3);
284
			fTextChangedJob = new CreateContainerJob(getShell().getDisplay(), Messages.EditDirectoryContainerPage_3);
288
		} else {
285
		} else {
289
			fTextChangedJob.cancel();
286
			fTextChangedJob.cancel();
290
		}
287
		}
Lines 301-309 Link Here
301
	protected boolean validateInput() throws CoreException {
298
	protected boolean validateInput() throws CoreException {
302
		// Check if the text field is blank
299
		// Check if the text field is blank
303
		if (fInstallLocation.getText().trim().length() == 0) {
300
		if (fInstallLocation.getText().trim().length() == 0) {
304
			fBundleTree.setInput(null);
305
			setMessage(getDefaultMessage());
301
			setMessage(getDefaultMessage());
306
			setPageComplete(false);
307
			return false;
302
			return false;
308
		}
303
		}
309
304
Lines 313-324 Link Here
313
308
314
		// Check if directory exists
309
		// Check if directory exists
315
		if (!location.isDirectory()) {
310
		if (!location.isDirectory()) {
316
			fBundleTree.setInput(null);
317
			setMessage(Messages.AddDirectoryContainerPage_6, IMessageProvider.WARNING);
311
			setMessage(Messages.AddDirectoryContainerPage_6, IMessageProvider.WARNING);
318
			setPageComplete(true);
319
		} else {
312
		} else {
320
			setMessage(getDefaultMessage());
313
			setMessage(getDefaultMessage());
321
			setPageComplete(true);
322
		}
314
		}
323
		return true;
315
		return true;
324
	}
316
	}
Lines 332-338 Link Here
332
	 * @return a new or modified bundle container
324
	 * @return a new or modified bundle container
333
	 * @throws CoreException
325
	 * @throws CoreException
334
	 */
326
	 */
335
	protected IBundleContainer refreshContainer(IBundleContainer previous) throws CoreException {
327
	protected IBundleContainer createContainer(IBundleContainer previous) throws CoreException {
336
		IBundleContainer container = getTargetPlatformService().newDirectoryContainer(fInstallLocation.getText());
328
		IBundleContainer container = getTargetPlatformService().newDirectoryContainer(fInstallLocation.getText());
337
		if (previous instanceof DirectoryBundleContainer) {
329
		if (previous instanceof DirectoryBundleContainer) {
338
			container.setIncludedBundles(previous.getIncludedBundles());
330
			container.setIncludedBundles(previous.getIncludedBundles());
Lines 356-379 Link Here
356
		return fTargetService;
348
		return fTargetService;
357
	}
349
	}
358
350
359
	/**
351
	private class CreateContainerJob extends UIJob {
360
	 * Returns the bundle container created by this wizard page with the
352
		public CreateContainerJob(Display jobDisplay, String name) {
361
	 * included bundles set on it based on what is checked in the tree.
362
	 * Will return <code>null</code> if there was a problem creating the
363
	 * bundle container.
364
	 * 
365
	 * @return bundle container or <code>null</code>
366
	 * 
367
	 */
368
	public IBundleContainer getBundleContainer() {
369
		if (fBundleTree != null) {
370
			fContainer.setIncludedBundles(fBundleTree.getIncludedBundles());
371
		}
372
		return fContainer;
373
	}
374
375
	private class ResolveJob extends UIJob {
376
		public ResolveJob(Display jobDisplay, String name) {
377
			super(jobDisplay, name);
353
			super(jobDisplay, name);
378
		}
354
		}
379
355
Lines 386-419 Link Here
386
				// Validate the location and any other text fields
362
				// Validate the location and any other text fields
387
				if (validateInput()) {
363
				if (validateInput()) {
388
					// Create a container from the input
364
					// Create a container from the input
389
					fContainer = refreshContainer(fContainer);
365
					fContainer = createContainer(fContainer);
390
					if (fContainer != null) {
366
					setPageComplete(true);
391
						// Resolve the container
392
						BusyIndicator.showWhile(getDisplay(), new Runnable() {
393
							public void run() {
394
								IStatus result = fContainer.isResolved() ? Status.OK_STATUS : fContainer.resolve(fTarget, null);
395
396
								if (!result.isOK() && !result.isMultiStatus()) {
397
									// There was a specific problem preventing the resolution, warn the user
398
									fBundleTree.setInput(null);
399
									setMessage(result.getMessage(), IMessageProvider.WARNING);
400
								} else {
401
									// Resolution was successful
402
									fBundleTree.setInput(fContainer);
403
									setPageComplete(true);
404
								}
405
							}
406
						});
407
						// Store the input into dialog settings as it is valid
408
						storeSettings();
409
					}
410
				} else {
367
				} else {
411
					fContainer = null;
368
					fContainer = null;
369
					setPageComplete(false);
412
				}
370
				}
413
				return Status.OK_STATUS;
371
				return Status.OK_STATUS;
414
			} catch (CoreException e) {
372
			} catch (CoreException e) {
415
				fContainer = null;
373
				fContainer = null;
416
				fBundleTree.setInput(null);
417
				setErrorMessage(e.getMessage());
374
				setErrorMessage(e.getMessage());
418
				setPageComplete(false);
375
				setPageComplete(false);
419
				return e.getStatus();
376
				return e.getStatus();
(-)src/org/eclipse/pde/internal/ui/pderesources.properties (-8 / +3 lines)
Lines 686-692 Link Here
686
ContentPage_fGroup = Fragment Properties
686
ContentPage_fGroup = Fragment Properties
687
ContentPage_parentPluginGroup = Host Plug-in
687
ContentPage_parentPluginGroup = Host Plug-in
688
ContentSection_0=Content
688
ContentSection_0=Content
689
ContentSection_1=This table lists the plug-ins and source bundles that will be included in the target.  Locations to look for plug-ins can be added, edited and removed.  In addition, a location can be modified to only include a subset of bundles.
689
ContentSection_1=List of plug-ins to include in this target.  Only the plug-ins checked below will be included in the target platform.
690
ContentSection_selectedOnly=Include only plug-ins designated below
690
ContentSection_selectedOnly=Include only plug-ins designated below
691
ContentSection_targetContent=Target Content
691
ContentSection_targetContent=Target Content
692
ContentPage_pClassGroup = Plug-in Options
692
ContentPage_pClassGroup = Plug-in Options
Lines 1687-1697 Link Here
1687
OverviewPage_extensionPageMessageTitle=Extension pages hidden
1687
OverviewPage_extensionPageMessageTitle=Extension pages hidden
1688
OverviewPage_extensionPageMessageBody=The Extension and Extension Point pages are currently hidden, would you like to display them now?
1688
OverviewPage_extensionPageMessageBody=The Extension and Extension Point pages are currently hidden, would you like to display them now?
1689
OverviewPage_environmentDescription=<form>\
1689
OverviewPage_environmentDescription=<form>\
1690
<p>The <a href="environment">Environment</a> section contains the following environment and setup information:</p>\
1690
<p>The <a href="environment">Environment</a> section contains additional settings including: locale, operating system, java runtime, arguments and implicit dependencies.</p>\
1691
<li>Environment settings including locale, processor architecture, operating system and windowing system.</li>\
1692
<li>Java runtime environment.</li>\
1693
<li>Program and VM arguments.</li>\
1694
<li>Implicit plug-ins, which should always be taken into account when calculating dependencies.</li>\
1695
</form>
1691
</form>
1696
OverviewPage_fExtensionContent=<form>\
1692
OverviewPage_fExtensionContent=<form>\
1697
<p>This fragment may define extensions and extension points:</p>\
1693
<p>This fragment may define extensions and extension points:</p>\
Lines 1699-1706 Link Here
1699
<li style="image" value="page" bindent="5"><a href="ex-points">Extension Points</a>: declares new function points this fragment adds to the platform.</li>\
1695
<li style="image" value="page" bindent="5"><a href="ex-points">Extension Points</a>: declares new function points this fragment adds to the platform.</li>\
1700
</form>
1696
</form>
1701
OverviewPage_contentDescription=<form>\
1697
OverviewPage_contentDescription=<form>\
1702
<p>The <a href="content">Content</a> section specifies the make-up of the target platform in terms of plug-ins, features or both.</p>\
1698
<p>The <a href="content">Content</a> section specifies the set of plug-ins that will be included in the target platform.</p>\
1703
<p>An option is also available to simply include all plug-ins from the specified locations into the target platform.</p>\
1704
</form>
1699
</form>
1705
OverviewPage_buildTitle=Build Configuration
1700
OverviewPage_buildTitle=Build Configuration
1706
ClassAttributeRow_dialogTitle=Select Type
1701
ClassAttributeRow_dialogTitle=Select Type
(-)src/org/eclipse/pde/internal/ui/PDEPluginImages.java (+2 lines)
Lines 128-133 Link Here
128
	public static final ImageDescriptor DESC_COMGROUP_OBJ = create(PATH_OBJ, "keygroups_obj.gif"); //$NON-NLS-1$
128
	public static final ImageDescriptor DESC_COMGROUP_OBJ = create(PATH_OBJ, "keygroups_obj.gif"); //$NON-NLS-1$
129
	public static final ImageDescriptor DESC_GENCOM_OBJ = create(PATH_OBJ, "command_obj.gif"); //$NON-NLS-1$
129
	public static final ImageDescriptor DESC_GENCOM_OBJ = create(PATH_OBJ, "command_obj.gif"); //$NON-NLS-1$
130
130
131
	public static final ImageDescriptor DESC_REPOSITORY_OBJ = create(PATH_OBJ, "metadata_repo_obj.gif"); //$NON-NLS-1$
132
131
	public static final ImageDescriptor DESC_PLUGIN_OBJ = create(PATH_OBJ, "plugin_obj.gif"); //$NON-NLS-1$
133
	public static final ImageDescriptor DESC_PLUGIN_OBJ = create(PATH_OBJ, "plugin_obj.gif"); //$NON-NLS-1$
132
	public static final ImageDescriptor DESC_PLUGIN_DIS_OBJ = create(PATH_OBJ, "plugin_dis_obj.gif"); //$NON-NLS-1$
134
	public static final ImageDescriptor DESC_PLUGIN_DIS_OBJ = create(PATH_OBJ, "plugin_dis_obj.gif"); //$NON-NLS-1$
133
	public static final ImageDescriptor DESC_OPERATING_SYSTEM_OBJ = create(PATH_OBJ, "operating_system_obj.gif"); //$NON-NLS-1$
135
	public static final ImageDescriptor DESC_OPERATING_SYSTEM_OBJ = create(PATH_OBJ, "operating_system_obj.gif"); //$NON-NLS-1$
(-)src/org/eclipse/pde/internal/ui/editor/targetdefinition/TargetEditor.java (+79 lines)
Lines 14-19 Link Here
14
import java.util.List;
14
import java.util.List;
15
import org.eclipse.core.resources.*;
15
import org.eclipse.core.resources.*;
16
import org.eclipse.core.runtime.*;
16
import org.eclipse.core.runtime.*;
17
import org.eclipse.core.runtime.jobs.Job;
18
import org.eclipse.core.runtime.jobs.JobChangeAdapter;
17
import org.eclipse.jface.action.Action;
19
import org.eclipse.jface.action.Action;
18
import org.eclipse.jface.action.ControlContribution;
20
import org.eclipse.jface.action.ControlContribution;
19
import org.eclipse.jface.dialogs.IMessageProvider;
21
import org.eclipse.jface.dialogs.IMessageProvider;
Lines 21-26 Link Here
21
import org.eclipse.pde.internal.core.target.impl.WorkspaceFileTargetHandle;
23
import org.eclipse.pde.internal.core.target.impl.WorkspaceFileTargetHandle;
22
import org.eclipse.pde.internal.core.target.provisional.*;
24
import org.eclipse.pde.internal.core.target.provisional.*;
23
import org.eclipse.pde.internal.ui.*;
25
import org.eclipse.pde.internal.ui.*;
26
import org.eclipse.pde.internal.ui.shared.target.*;
24
import org.eclipse.swt.SWT;
27
import org.eclipse.swt.SWT;
25
import org.eclipse.swt.custom.BusyIndicator;
28
import org.eclipse.swt.custom.BusyIndicator;
26
import org.eclipse.swt.widgets.*;
29
import org.eclipse.swt.widgets.*;
Lines 32-37 Link Here
32
import org.eclipse.ui.forms.events.IHyperlinkListener;
35
import org.eclipse.ui.forms.events.IHyperlinkListener;
33
import org.eclipse.ui.forms.widgets.*;
36
import org.eclipse.ui.forms.widgets.*;
34
import org.eclipse.ui.part.FileEditorInput;
37
import org.eclipse.ui.part.FileEditorInput;
38
import org.eclipse.ui.progress.UIJob;
35
39
36
/**
40
/**
37
 * Editor for target definition (*.target) files.  Interacts with the ITargetDefinition model
41
 * Editor for target definition (*.target) files.  Interacts with the ITargetDefinition model
Lines 46-51 Link Here
46
	private ITargetDefinition fTarget;
50
	private ITargetDefinition fTarget;
47
	private List fManagedFormPages = new ArrayList(2);
51
	private List fManagedFormPages = new ArrayList(2);
48
	private FileInputListener fInputListener;
52
	private FileInputListener fInputListener;
53
	private TargetChangedListener fTargetChangedListener;
49
54
50
	/* (non-Javadoc)
55
	/* (non-Javadoc)
51
	 * @see org.eclipse.ui.forms.editor.FormEditor#createToolkit(org.eclipse.swt.widgets.Display)
56
	 * @see org.eclipse.ui.forms.editor.FormEditor#createToolkit(org.eclipse.swt.widgets.Display)
Lines 62-67 Link Here
62
			setActiveEditor(this);
67
			setActiveEditor(this);
63
			setPartName(getEditorInput().getName());
68
			setPartName(getEditorInput().getName());
64
			addPage(new DefinitionPage(this));
69
			addPage(new DefinitionPage(this));
70
			addPage(new ContentPage(this));
65
			addPage(new EnvironmentPage(this));
71
			addPage(new EnvironmentPage(this));
66
		} catch (PartInitException e) {
72
		} catch (PartInitException e) {
67
			PDEPlugin.log(e);
73
			PDEPlugin.log(e);
Lines 147-152 Link Here
147
		if (input instanceof IFileEditorInput) {
153
		if (input instanceof IFileEditorInput) {
148
			fInputListener = new FileInputListener(((IFileEditorInput) input).getFile());
154
			fInputListener = new FileInputListener(((IFileEditorInput) input).getFile());
149
			PDEPlugin.getWorkspace().addResourceChangeListener(fInputListener);
155
			PDEPlugin.getWorkspace().addResourceChangeListener(fInputListener);
156
			getTargetChangedListener().contentsChanged(getTarget(), true);
150
		}
157
		}
151
	}
158
	}
152
159
Lines 198-203 Link Here
198
	}
205
	}
199
206
200
	/**
207
	/**
208
	 * @return a shared listener that will refresh UI components when the target is modified
209
	 */
210
	public TargetChangedListener getTargetChangedListener() {
211
		if (fTargetChangedListener == null) {
212
			fTargetChangedListener = new TargetChangedListener();
213
		}
214
		return fTargetChangedListener;
215
	}
216
217
	/**
201
	 * Handles the revert action
218
	 * Handles the revert action
202
	 */
219
	 */
203
	public void doRevert() {
220
	public void doRevert() {
Lines 303-306 Link Here
303
		}
320
		}
304
	}
321
	}
305
322
323
	class TargetChangedListener implements ITargetChangedListener {
324
		private TargetLocationsGroup fLocationTree;
325
		private TargetContentsGroup fContentTree;
326
327
		public void setLocationTree(TargetLocationsGroup locationTree) {
328
			fLocationTree = locationTree;
329
		}
330
331
		public void setContentTree(TargetContentsGroup contentTree) {
332
			fContentTree = contentTree;
333
		}
334
335
		public void contentsChanged(ITargetDefinition definition, boolean resolve) {
336
			if (resolve) {
337
				if (definition.isResolved()) {
338
					if (fContentTree != null) {
339
						fContentTree.setInput(getTarget());
340
					}
341
					if (fLocationTree != null) {
342
						fLocationTree.setInput(getTarget());
343
					}
344
				} else {
345
					if (fContentTree != null) {
346
						fContentTree.setEnabled(false);
347
					}
348
					if (fLocationTree != null) {
349
						fLocationTree.setInput(null);
350
					}
351
					// TODO Cancel any other started jobs? Bad if we do this every time a checkbox changes
352
					Job resolveJob = new Job("Resolving Target") {
353
						protected IStatus run(IProgressMonitor monitor) {
354
							getTarget().resolve(monitor);
355
							if (monitor.isCanceled()) {
356
								return Status.CANCEL_STATUS;
357
							}
358
							// Don't return any problems because we don't want an error dialog
359
							return Status.OK_STATUS;
360
						}
361
					};
362
					resolveJob.addJobChangeListener(new JobChangeAdapter() {
363
						public void done(org.eclipse.core.runtime.jobs.IJobChangeEvent event) {
364
							UIJob job = new UIJob("Refresh UI") {
365
								public IStatus runInUIThread(IProgressMonitor monitor) {
366
									if (fContentTree != null) {
367
										fContentTree.setInput(getTarget());
368
									}
369
									if (fLocationTree != null) {
370
										fLocationTree.setInput(getTarget());
371
									}
372
									return Status.OK_STATUS;
373
								}
374
							};
375
							job.setSystem(true);
376
							job.schedule();
377
						}
378
					});
379
					resolveJob.schedule();
380
				}
381
			}
382
		}
383
	}
384
306
}
385
}
(-)src/org/eclipse/pde/internal/ui/editor/targetdefinition/ContentSection.java (-107 / +87 lines)
Lines 1-107 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2005, 2009 IBM Corporation and others.
2
 * Copyright (c) 2005, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.pde.internal.ui.editor.targetdefinition;
11
package org.eclipse.pde.internal.ui.editor.targetdefinition;
12
12
13
import java.lang.reflect.InvocationTargetException;
13
import org.eclipse.pde.internal.core.target.provisional.ITargetDefinition;
14
import org.eclipse.core.runtime.*;
14
import org.eclipse.pde.internal.ui.PDEUIMessages;
15
import org.eclipse.core.runtime.jobs.Job;
15
import org.eclipse.pde.internal.ui.editor.FormLayoutFactory;
16
import org.eclipse.jface.operation.IRunnableWithProgress;
16
import org.eclipse.pde.internal.ui.shared.target.ITargetChangedListener;
17
import org.eclipse.pde.internal.core.target.provisional.ITargetDefinition;
17
import org.eclipse.pde.internal.ui.shared.target.TargetContentsGroup;
18
import org.eclipse.pde.internal.ui.PDEPlugin;
18
import org.eclipse.swt.layout.GridData;
19
import org.eclipse.pde.internal.ui.PDEUIMessages;
19
import org.eclipse.swt.widgets.Composite;
20
import org.eclipse.pde.internal.ui.editor.FormLayoutFactory;
20
import org.eclipse.ui.forms.SectionPart;
21
import org.eclipse.pde.internal.ui.shared.target.BundleContainerTable;
21
import org.eclipse.ui.forms.editor.FormPage;
22
import org.eclipse.pde.internal.ui.shared.target.IBundleContainerTableReporter;
22
import org.eclipse.ui.forms.widgets.*;
23
import org.eclipse.swt.layout.GridData;
23
24
import org.eclipse.swt.widgets.Composite;
24
/**
25
import org.eclipse.ui.forms.SectionPart;
25
 * Section for editing the content of the target (bundle containers) in the target definition editor
26
import org.eclipse.ui.forms.editor.FormPage;
26
 * @see DefinitionPage
27
import org.eclipse.ui.forms.widgets.*;
27
 * @see TargetEditor
28
28
 */
29
/**
29
public class ContentSection extends SectionPart {
30
 * Section for editing the content of the target (bundle containers) in the target definition editor
30
31
 * @see DefinitionPage
31
	private TargetContentsGroup fContentGroup;
32
 * @see TargetEditor
32
	private TargetEditor fEditor;
33
 */
33
34
public class ContentSection extends SectionPart {
34
	public ContentSection(FormPage page, Composite parent) {
35
35
		super(parent, page.getManagedForm().getToolkit(), Section.DESCRIPTION | ExpandableComposite.TITLE_BAR);
36
	private BundleContainerTable fTable;
36
		fEditor = (TargetEditor) page.getEditor();
37
	private TargetEditor fEditor;
37
		createClient(getSection(), page.getEditor().getToolkit());
38
38
	}
39
	public ContentSection(FormPage page, Composite parent) {
39
40
		super(parent, page.getManagedForm().getToolkit(), Section.DESCRIPTION | ExpandableComposite.TITLE_BAR);
40
	/**
41
		fEditor = (TargetEditor) page.getEditor();
41
	 * @return The target model backing this editor
42
		createClient(getSection(), page.getEditor().getToolkit());
42
	 */
43
	}
43
	private ITargetDefinition getTarget() {
44
44
		return fEditor.getTarget();
45
	/**
45
	}
46
	 * @return The target model backing this editor
46
47
	 */
47
	/**
48
	private ITargetDefinition getTarget() {
48
	 * Creates the UI for this section.
49
		return fEditor.getTarget();
49
	 * 
50
	}
50
	 * @param section section the UI is being added to
51
51
	 * @param toolkit form toolkit used to create the widgets
52
	/**
52
	 */
53
	 * Creates the UI for this section.
53
	protected void createClient(Section section, FormToolkit toolkit) {
54
	 * 
54
		section.setLayout(FormLayoutFactory.createClearTableWrapLayout(false, 1));
55
	 * @param section section the UI is being added to
55
		GridData sectionData = new GridData(GridData.FILL_BOTH);
56
	 * @param toolkit form toolkit used to create the widgets
56
		sectionData.horizontalSpan = 2;
57
	 */
57
		section.setLayoutData(sectionData);
58
	protected void createClient(Section section, FormToolkit toolkit) {
58
		section.setText(PDEUIMessages.ContentSection_0);
59
		section.setLayout(FormLayoutFactory.createClearTableWrapLayout(false, 1));
59
60
		GridData sectionData = new GridData(GridData.FILL_BOTH);
60
		section.setDescription(PDEUIMessages.ContentSection_1);
61
		sectionData.horizontalSpan = 2;
61
		Composite client = toolkit.createComposite(section);
62
		section.setLayoutData(sectionData);
62
		client.setLayout(FormLayoutFactory.createSectionClientGridLayout(false, 1));
63
		section.setText(PDEUIMessages.ContentSection_0);
63
		client.setLayoutData(new GridData(GridData.FILL_BOTH | GridData.GRAB_VERTICAL));
64
64
65
		section.setDescription(PDEUIMessages.ContentSection_1);
65
		fContentGroup = TargetContentsGroup.createInForm(client, toolkit);
66
		Composite client = toolkit.createComposite(section);
66
		fEditor.getTargetChangedListener().setContentTree(fContentGroup);
67
		client.setLayout(FormLayoutFactory.createSectionClientGridLayout(false, 1));
67
		fContentGroup.addTargetChangedListener(fEditor.getTargetChangedListener());
68
		client.setLayoutData(new GridData(GridData.FILL_BOTH | GridData.GRAB_VERTICAL));
68
		fContentGroup.addTargetChangedListener(new ITargetChangedListener() {
69
69
			public void contentsChanged(ITargetDefinition definition, boolean resolve) {
70
		fTable = BundleContainerTable.createTableInForm(client, toolkit, new IBundleContainerTableReporter() {
70
				markDirty();
71
			public void runResolveOperation(final IRunnableWithProgress operation) {
71
			}
72
				Job job = new Job(PDEUIMessages.TargetDefinitionContentPage_0) {
72
		});
73
					protected IStatus run(IProgressMonitor monitor) {
73
74
						try {
74
		toolkit.paintBordersFor(client);
75
75
76
							operation.run(monitor);
76
		section.setClient(client);
77
							return Status.OK_STATUS;
77
	}
78
						} catch (InvocationTargetException e) {
78
79
							return new Status(IStatus.ERROR, PDEPlugin.getPluginId(), PDEUIMessages.TargetDefinitionContentPage_5, e);
79
	/* (non-Javadoc)
80
						} catch (InterruptedException e) {
80
	 * @see org.eclipse.ui.forms.AbstractFormPart#refresh()
81
							return Status.CANCEL_STATUS;
81
	 */
82
						}
82
	public void refresh() {
83
					}
83
		fContentGroup.setInput(getTarget());
84
				};
84
		super.refresh();
85
				job.setUser(true);
85
	}
86
				job.schedule();
86
87
			}
87
}
88
89
			public void contentsChanged() {
90
				markDirty();
91
			}
92
		});
93
94
		toolkit.paintBordersFor(client);
95
96
		section.setClient(client);
97
	}
98
99
	/* (non-Javadoc)
100
	 * @see org.eclipse.ui.forms.AbstractFormPart#refresh()
101
	 */
102
	public void refresh() {
103
		fTable.setInput(getTarget());
104
		super.refresh();
105
	}
106
107
}
(-)src/org/eclipse/pde/internal/ui/editor/targetdefinition/DefinitionPage.java (-84 / +150 lines)
Lines 1-84 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2009 IBM Corporation and others.
2
 * Copyright (c) 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.pde.internal.ui.editor.targetdefinition;
11
package org.eclipse.pde.internal.ui.editor.targetdefinition;
12
12
13
import org.eclipse.pde.internal.core.target.provisional.ITargetDefinition;
13
import org.eclipse.jface.action.IStatusLineManager;
14
import org.eclipse.pde.internal.ui.*;
14
import org.eclipse.pde.internal.core.target.provisional.ITargetDefinition;
15
import org.eclipse.pde.internal.ui.editor.FormLayoutFactory;
15
import org.eclipse.pde.internal.ui.*;
16
import org.eclipse.swt.widgets.Composite;
16
import org.eclipse.pde.internal.ui.editor.FormLayoutFactory;
17
import org.eclipse.ui.PlatformUI;
17
import org.eclipse.pde.internal.ui.editor.target.ContentPage;
18
import org.eclipse.ui.forms.IManagedForm;
18
import org.eclipse.pde.internal.ui.editor.target.EnvironmentPage;
19
import org.eclipse.ui.forms.editor.FormPage;
19
import org.eclipse.swt.SWT;
20
import org.eclipse.ui.forms.widgets.FormToolkit;
20
import org.eclipse.swt.SWTException;
21
import org.eclipse.ui.forms.widgets.ScrolledForm;
21
import org.eclipse.swt.layout.GridData;
22
22
import org.eclipse.swt.widgets.Composite;
23
/**
23
import org.eclipse.ui.PlatformUI;
24
 * First page in the target definition editor.  Allows for editing of the name,
24
import org.eclipse.ui.forms.IManagedForm;
25
 * description and content of the target.
25
import org.eclipse.ui.forms.editor.FormPage;
26
 * @see TargetEditor
26
import org.eclipse.ui.forms.events.HyperlinkEvent;
27
 * @see InformationSection
27
import org.eclipse.ui.forms.events.IHyperlinkListener;
28
 * @see ContentSection
28
import org.eclipse.ui.forms.widgets.*;
29
 */
29
30
public class DefinitionPage extends FormPage {
30
/**
31
31
 * First page in the target definition editor.  Allows for editing of the name,
32
	public static final String PAGE_ID = "overview"; //$NON-NLS-1$
32
 * description and content of the target.
33
33
 * @see TargetEditor
34
	public DefinitionPage(TargetEditor editor) {
34
 * @see InformationSection
35
		super(editor, PAGE_ID, PDEUIMessages.DefinitionPage_0);
35
 * @see LocationSection
36
	}
36
 */
37
37
public class DefinitionPage extends FormPage implements IHyperlinkListener {
38
	/**
38
39
	 * @return The target model backing this editor
39
	public static final String PAGE_ID = "definition"; //$NON-NLS-1$
40
	 */
40
41
	public ITargetDefinition getTarget() {
41
	public DefinitionPage(TargetEditor editor) {
42
		return ((TargetEditor) getEditor()).getTarget();
42
		super(editor, PAGE_ID, PDEUIMessages.DefinitionPage_0);
43
	}
43
	}
44
44
45
	/* (non-Javadoc)
45
	/**
46
	 * @see org.eclipse.pde.internal.ui.editor.PDEFormPage#createFormContent(org.eclipse.ui.forms.IManagedForm)
46
	 * @return The target model backing this editor
47
	 */
47
	 */
48
	protected void createFormContent(IManagedForm managedForm) {
48
	public ITargetDefinition getTarget() {
49
		super.createFormContent(managedForm);
49
		return ((TargetEditor) getEditor()).getTarget();
50
		ScrolledForm form = managedForm.getForm();
50
	}
51
		FormToolkit toolkit = managedForm.getToolkit();
51
52
		form.setText(PDEUIMessages.DefinitionPage_1);
52
	/* (non-Javadoc)
53
		PDEPlugin.getDefault().getLabelProvider().connect(this);
53
	 * @see org.eclipse.pde.internal.ui.editor.PDEFormPage#createFormContent(org.eclipse.ui.forms.IManagedForm)
54
		form.setImage(PDEPlugin.getDefault().getLabelProvider().get(PDEPluginImages.DESC_TARGET_DEFINITION));
54
	 */
55
		toolkit.decorateFormHeading(form.getForm());
55
	protected void createFormContent(IManagedForm managedForm) {
56
		fillBody(managedForm, toolkit);
56
		super.createFormContent(managedForm);
57
		// TODO Finish help
57
		ScrolledForm form = managedForm.getForm();
58
		((TargetEditor) getEditor()).contributeToToolbar(managedForm.getForm(), ""); //$NON-NLS-1$
58
		FormToolkit toolkit = managedForm.getToolkit();
59
		((TargetEditor) getEditor()).addForm(managedForm);
59
		form.setText(PDEUIMessages.DefinitionPage_1);
60
		form.updateToolBar();
60
		PDEPlugin.getDefault().getLabelProvider().connect(this);
61
		PlatformUI.getWorkbench().getHelpSystem().setHelp(form.getBody(), IHelpContextIds.TARGET_OVERVIEW_PAGE);
61
		form.setImage(PDEPlugin.getDefault().getLabelProvider().get(PDEPluginImages.DESC_TARGET_DEFINITION));
62
	}
62
		toolkit.decorateFormHeading(form.getForm());
63
63
		fillBody(managedForm, toolkit);
64
	/* (non-Javadoc)
64
		// TODO Finish help
65
	 * @see org.eclipse.ui.forms.editor.FormPage#dispose()
65
		((TargetEditor) getEditor()).contributeToToolbar(managedForm.getForm(), ""); //$NON-NLS-1$
66
	 */
66
		((TargetEditor) getEditor()).addForm(managedForm);
67
	public void dispose() {
67
		form.updateToolBar();
68
		PDEPlugin.getDefault().getLabelProvider().disconnect(this);
68
		PlatformUI.getWorkbench().getHelpSystem().setHelp(form.getBody(), IHelpContextIds.TARGET_OVERVIEW_PAGE);
69
		super.dispose();
69
	}
70
	}
70
71
71
	/* (non-Javadoc)
72
	private void fillBody(IManagedForm managedForm, FormToolkit toolkit) {
72
	 * @see org.eclipse.ui.forms.editor.FormPage#dispose()
73
		Composite body = managedForm.getForm().getBody();
73
	 */
74
		body.setLayout(FormLayoutFactory.createFormGridLayout(true, 1));
74
	public void dispose() {
75
		managedForm.addPart(new InformationSection(this, body));
75
		PDEPlugin.getDefault().getLabelProvider().disconnect(this);
76
		managedForm.addPart(new ContentSection(this, body));
76
		super.dispose();
77
	}
77
	}
78
78
79
	// TODO Hook up help toolbar action
79
	private void fillBody(IManagedForm managedForm, FormToolkit toolkit) {
80
//	protected String getHelpResource() {
80
		Composite body = managedForm.getForm().getBody();
81
//		return "/org.eclipse.pde.doc.user/guide/tools/editors/target_definition_editor/overview.htm"; //$NON-NLS-1$
81
		body.setLayout(FormLayoutFactory.createFormGridLayout(true, 1));
82
//	}
82
		managedForm.addPart(new InformationSection(this, body));
83
83
		managedForm.addPart(new LocationSection(this, body));
84
}
84
		Composite linkComposite = toolkit.createComposite(body);
85
		linkComposite.setLayout(FormLayoutFactory.createFormGridLayout(true, 2));
86
		linkComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
87
		createContentsSection(linkComposite, toolkit);
88
		createEnvironmentSection(linkComposite, toolkit);
89
	}
90
91
	private void createContentsSection(Composite parent, FormToolkit toolkit) {
92
		Section section = createSection(parent, toolkit, PDEUIMessages.OverviewPage_contentTitle);
93
		createText(section, PDEUIMessages.OverviewPage_contentDescription, toolkit);
94
	}
95
96
	private void createEnvironmentSection(Composite parent, FormToolkit toolkit) {
97
		Section section = createSection(parent, toolkit, PDEUIMessages.OverviewPage_environmentTitle);
98
		createText(section, PDEUIMessages.OverviewPage_environmentDescription, toolkit);
99
	}
100
101
	private Section createSection(Composite parent, FormToolkit toolkit, String title) {
102
		Section section = toolkit.createSection(parent, ExpandableComposite.TITLE_BAR);
103
		section.clientVerticalSpacing = FormLayoutFactory.SECTION_HEADER_VERTICAL_SPACING;
104
		section.setText(title);
105
		section.setLayout(FormLayoutFactory.createClearTableWrapLayout(false, 1));
106
		section.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING));
107
		return section;
108
	}
109
110
	private FormText createText(Section section, String content, FormToolkit toolkit) {
111
		Composite container = toolkit.createComposite(section, SWT.NONE);
112
		container.setLayout(FormLayoutFactory.createSectionClientTableWrapLayout(false, 1));
113
		section.setClient(container);
114
		FormText text = toolkit.createFormText(container, true);
115
		try {
116
			text.setText(content, true, false);
117
		} catch (SWTException e) {
118
			text.setText(e.getMessage(), false, false);
119
		}
120
		TableWrapData data = new TableWrapData(TableWrapData.FILL_GRAB);
121
		data.maxWidth = 250;
122
		text.setLayoutData(data);
123
		text.addHyperlinkListener(this);
124
		return text;
125
	}
126
127
	public void linkActivated(HyperlinkEvent e) {
128
		String href = (String) e.getHref();
129
		if (href.equals("content")) //$NON-NLS-1$
130
			getEditor().setActivePage(ContentPage.PAGE_ID);
131
		else if (href.equals("environment")) //$NON-NLS-1$
132
			getEditor().setActivePage(EnvironmentPage.PAGE_ID);
133
	}
134
135
	public void linkEntered(HyperlinkEvent e) {
136
		IStatusLineManager mng = getEditor().getEditorSite().getActionBars().getStatusLineManager();
137
		mng.setMessage(e.getLabel());
138
	}
139
140
	public void linkExited(HyperlinkEvent e) {
141
		IStatusLineManager mng = getEditor().getEditorSite().getActionBars().getStatusLineManager();
142
		mng.setMessage(null);
143
	}
144
145
	// TODO Hook up help toolbar action
146
//	protected String getHelpResource() {
147
//		return "/org.eclipse.pde.doc.user/guide/tools/editors/target_definition_editor/overview.htm"; //$NON-NLS-1$
148
//	}
149
150
}
(-)src/org/eclipse/pde/internal/ui/wizards/target/TargetDefinitionContentPage.java (-712 / +754 lines)
Lines 1-712 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2009 IBM Corporation and others.
2
 * Copyright (c) 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.pde.internal.ui.wizards.target;
11
package org.eclipse.pde.internal.ui.wizards.target;
12
12
13
import org.eclipse.pde.internal.ui.PDEUIMessages;
13
import java.lang.reflect.InvocationTargetException;
14
14
import java.util.*;
15
import java.lang.reflect.InvocationTargetException;
15
import java.util.List;
16
import java.util.*;
16
import org.eclipse.core.runtime.*;
17
import java.util.List;
17
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
18
import org.eclipse.core.runtime.*;
18
import org.eclipse.core.runtime.preferences.InstanceScope;
19
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
19
import org.eclipse.debug.ui.StringVariableSelectionDialog;
20
import org.eclipse.core.runtime.preferences.InstanceScope;
20
import org.eclipse.equinox.internal.provisional.frameworkadmin.BundleInfo;
21
import org.eclipse.debug.ui.StringVariableSelectionDialog;
21
import org.eclipse.jdt.launching.JavaRuntime;
22
import org.eclipse.equinox.internal.provisional.frameworkadmin.BundleInfo;
22
import org.eclipse.jdt.launching.environments.IExecutionEnvironment;
23
import org.eclipse.jdt.launching.JavaRuntime;
23
import org.eclipse.jdt.launching.environments.IExecutionEnvironmentsManager;
24
import org.eclipse.jdt.launching.environments.IExecutionEnvironment;
24
import org.eclipse.jface.operation.IRunnableWithProgress;
25
import org.eclipse.jdt.launching.environments.IExecutionEnvironmentsManager;
25
import org.eclipse.jface.viewers.*;
26
import org.eclipse.jface.operation.IRunnableWithProgress;
26
import org.eclipse.jface.window.Window;
27
import org.eclipse.jface.viewers.*;
27
import org.eclipse.pde.internal.core.ICoreConstants;
28
import org.eclipse.jface.window.Window;
28
import org.eclipse.pde.internal.core.PDECore;
29
import org.eclipse.pde.internal.core.ICoreConstants;
29
import org.eclipse.pde.internal.core.target.provisional.IResolvedBundle;
30
import org.eclipse.pde.internal.core.PDECore;
30
import org.eclipse.pde.internal.core.target.provisional.ITargetDefinition;
31
import org.eclipse.pde.internal.core.target.provisional.IResolvedBundle;
31
import org.eclipse.pde.internal.core.util.VMUtil;
32
import org.eclipse.pde.internal.core.target.provisional.ITargetDefinition;
32
import org.eclipse.pde.internal.ui.*;
33
import org.eclipse.pde.internal.core.util.VMUtil;
33
import org.eclipse.pde.internal.ui.elements.DefaultTableProvider;
34
import org.eclipse.pde.internal.ui.*;
34
import org.eclipse.pde.internal.ui.shared.target.*;
35
import org.eclipse.pde.internal.ui.elements.DefaultTableProvider;
35
import org.eclipse.pde.internal.ui.util.LocaleUtil;
36
import org.eclipse.pde.internal.ui.shared.target.*;
36
import org.eclipse.pde.internal.ui.util.SWTUtil;
37
import org.eclipse.pde.internal.ui.util.LocaleUtil;
37
import org.eclipse.swt.SWT;
38
import org.eclipse.pde.internal.ui.util.SWTUtil;
38
import org.eclipse.swt.events.*;
39
import org.eclipse.swt.SWT;
39
import org.eclipse.swt.layout.GridData;
40
import org.eclipse.swt.events.*;
40
import org.eclipse.swt.layout.GridLayout;
41
import org.eclipse.swt.layout.GridData;
41
import org.eclipse.swt.widgets.*;
42
import org.eclipse.swt.layout.GridLayout;
42
import org.eclipse.ui.ISharedImages;
43
import org.eclipse.swt.widgets.*;
43
import org.eclipse.ui.PlatformUI;
44
import org.eclipse.ui.dialogs.ElementListSelectionDialog;
44
import org.eclipse.ui.dialogs.ElementListSelectionDialog;
45
import org.eclipse.ui.progress.UIJob;
45
import org.eclipse.ui.progress.UIJob;
46
46
47
/**
47
/**
48
 * Wizard page for editing the content of a target platform using a tab layout
48
 * Wizard page for editing the content of a target platform using a tab layout
49
 * 
49
 * 
50
 * @see NewTargetDefinitionWizard2
50
 * @see NewTargetDefinitionWizard2
51
 * @see EditTargetDefinitionWizard
51
 * @see EditTargetDefinitionWizard
52
 */
52
 */
53
public class TargetDefinitionContentPage extends TargetDefinitionPage {
53
public class TargetDefinitionContentPage extends TargetDefinitionPage {
54
54
55
	private static final String EMPTY_STRING = ""; //$NON-NLS-1$
55
	private static final String EMPTY_STRING = ""; //$NON-NLS-1$
56
56
57
	private Text fNameText;
57
	private Text fNameText;
58
	private BundleContainerTable fTable;
58
	private TabItem fLocationTab;
59
59
	private TargetLocationsGroup fLocationTree;
60
	// Environment pull-downs
60
	private TargetContentsGroup fContentTree;
61
	private Combo fOSCombo;
61
62
	private Combo fWSCombo;
62
	// Environment pull-downs
63
	private Combo fArchCombo;
63
	private Combo fOSCombo;
64
	private Combo fNLCombo;
64
	private Combo fWSCombo;
65
65
	private Combo fArchCombo;
66
	// Choices for each pull-down
66
	private Combo fNLCombo;
67
	private TreeSet fNLChoices;
67
68
	private TreeSet fOSChoices;
68
	// Choices for each pull-down
69
	private TreeSet fWSChoices;
69
	private TreeSet fNLChoices;
70
	private TreeSet fArchChoices;
70
	private TreeSet fOSChoices;
71
71
	private TreeSet fWSChoices;
72
	// JRE section
72
	private TreeSet fArchChoices;
73
	private Button fDefaultJREButton;
73
74
	private Button fNamedJREButton;
74
	// JRE section
75
	private Button fExecEnvButton;
75
	private Button fDefaultJREButton;
76
	private Combo fNamedJREsCombo;
76
	private Button fNamedJREButton;
77
	private Combo fExecEnvsCombo;
77
	private Button fExecEnvButton;
78
	private TreeSet fExecEnvChoices;
78
	private Combo fNamedJREsCombo;
79
79
	private Combo fExecEnvsCombo;
80
	// argument controls
80
	private TreeSet fExecEnvChoices;
81
	private Text fProgramArgs;
81
82
	private Text fVMArgs;
82
	// argument controls
83
83
	private Text fProgramArgs;
84
	// implicit dependencies tab
84
	private Text fVMArgs;
85
	private TableViewer fElementViewer;
85
86
	private Button fAddButton;
86
	// implicit dependencies tab
87
	private Button fRemoveButton;
87
	private TableViewer fElementViewer;
88
	private Button fRemoveAllButton;
88
	private Button fAddButton;
89
89
	private Button fRemoveButton;
90
	/**
90
	private Button fRemoveAllButton;
91
	 * @param pageName
91
92
	 */
92
	/**
93
	public TargetDefinitionContentPage(ITargetDefinition target) {
93
	 * @param pageName
94
		super("targetContent", target); //$NON-NLS-1$
94
	 */
95
		setTitle(PDEUIMessages.TargetDefinitionContentPage_1);
95
	public TargetDefinitionContentPage(ITargetDefinition target) {
96
		setDescription(PDEUIMessages.TargetDefinitionContentPage_2);
96
		super("targetContent", target); //$NON-NLS-1$
97
		setImageDescriptor(PDEPluginImages.DESC_TARGET_WIZ);
97
		setTitle(PDEUIMessages.TargetDefinitionContentPage_1);
98
	}
98
		setDescription(PDEUIMessages.TargetDefinitionContentPage_2);
99
99
		setImageDescriptor(PDEPluginImages.DESC_TARGET_WIZ);
100
	/* (non-Javadoc)
100
	}
101
	 * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
101
102
	 */
102
	/* (non-Javadoc)
103
	public void createControl(Composite parent) {
103
	 * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
104
		Composite comp = SWTFactory.createComposite(parent, 1, 1, GridData.FILL_BOTH, 0, 0);
104
	 */
105
105
	public void createControl(Composite parent) {
106
		Composite nameComp = SWTFactory.createComposite(comp, 2, 1, GridData.FILL_HORIZONTAL, 0, 0);
106
		Composite comp = SWTFactory.createComposite(parent, 1, 1, GridData.FILL_BOTH, 0, 0);
107
107
108
		SWTFactory.createLabel(nameComp, PDEUIMessages.TargetDefinitionContentPage_4, 1);
108
		Composite nameComp = SWTFactory.createComposite(comp, 2, 1, GridData.FILL_HORIZONTAL, 0, 0);
109
109
110
		fNameText = SWTFactory.createSingleText(nameComp, 1);
110
		SWTFactory.createLabel(nameComp, PDEUIMessages.TargetDefinitionContentPage_4, 1);
111
		fNameText.addModifyListener(new ModifyListener() {
111
112
			public void modifyText(ModifyEvent e) {
112
		fNameText = SWTFactory.createSingleText(nameComp, 1);
113
				String name = fNameText.getText().trim();
113
		fNameText.addModifyListener(new ModifyListener() {
114
				if (name.length() == 0) {
114
			public void modifyText(ModifyEvent e) {
115
					setErrorMessage(PDEUIMessages.TargetDefinitionContentPage_7);
115
				String name = fNameText.getText().trim();
116
				} else {
116
				if (name.length() == 0) {
117
					setErrorMessage(null);
117
					setErrorMessage(PDEUIMessages.TargetDefinitionContentPage_7);
118
					setMessage(PDEUIMessages.TargetDefinitionContentPage_2);
118
				} else {
119
				}
119
					setErrorMessage(null);
120
				getTargetDefinition().setName(name);
120
					setMessage(PDEUIMessages.TargetDefinitionContentPage_2);
121
				setPageComplete(isPageComplete());
121
				}
122
			}
122
				getTargetDefinition().setName(name);
123
		});
123
				setPageComplete(isPageComplete());
124
124
			}
125
		TabFolder tabs = new TabFolder(comp, SWT.NONE);
125
		});
126
		tabs.setLayoutData(new GridData(GridData.FILL_BOTH));
126
127
127
		TabFolder tabs = new TabFolder(comp, SWT.NONE);
128
		TabItem pluginsTab = new TabItem(tabs, SWT.NONE);
128
		tabs.setLayoutData(new GridData(GridData.FILL_BOTH));
129
		pluginsTab.setText(PDEUIMessages.TargetDefinitionContentPage_6);
129
130
130
		fLocationTab = new TabItem(tabs, SWT.NONE);
131
		Composite pluginTabContainer = SWTFactory.createComposite(tabs, 1, 1, GridData.FILL_BOTH);
131
		fLocationTab.setText("Locations");
132
132
133
		SWTFactory.createWrapLabel(pluginTabContainer, PDEUIMessages.ContentSection_1, 2, 400);
133
		Composite pluginTabContainer = SWTFactory.createComposite(tabs, 1, 1, GridData.FILL_BOTH);
134
134
		SWTFactory.createWrapLabel(pluginTabContainer, "List of locations to look for plug-ins to add to this target.", 2, 400);
135
		fTable = BundleContainerTable.createTableInDialog(pluginTabContainer, new IBundleContainerTableReporter() {
135
		fLocationTree = TargetLocationsGroup.createInDialog(pluginTabContainer);
136
			public void runResolveOperation(final IRunnableWithProgress operation) {
136
		fLocationTab.setControl(pluginTabContainer);
137
				if (isControlCreated()) {
137
138
					try {
138
		TabItem contentTab = new TabItem(tabs, SWT.NONE);
139
						getContainer().run(true, false, operation);
139
		contentTab.setText(PDEUIMessages.TargetDefinitionContentPage_6);
140
					} catch (InvocationTargetException e) {
140
		Composite contentTabContainer = SWTFactory.createComposite(tabs, 1, 1, GridData.FILL_BOTH);
141
						PDEPlugin.log(e);
141
		SWTFactory.createWrapLabel(contentTabContainer, PDEUIMessages.ContentSection_1, 2, 400);
142
					} catch (InterruptedException e) {
142
		fContentTree = TargetContentsGroup.createInDialog(contentTabContainer);
143
						// TODO Cancel the wizard?
143
		contentTab.setControl(contentTabContainer);
144
					}
144
145
				} else {
145
		TabItem envTab = new TabItem(tabs, SWT.NONE);
146
					// If the page isn't open yet, try running a UI job so the dialog has time to finish opening
146
		envTab.setText(PDEUIMessages.TargetDefinitionEnvironmentPage_3);
147
					new UIJob(PDEUIMessages.TargetDefinitionContentPage_0) {
147
		Composite envTabContainer = SWTFactory.createComposite(tabs, 1, 1, GridData.FILL_BOTH);
148
						public IStatus runInUIThread(IProgressMonitor monitor) {
148
		createTargetEnvironmentGroup(envTabContainer);
149
							try {
149
		createJREGroup(envTabContainer);
150
								getContainer().run(true, false, operation);
150
		envTab.setControl(envTabContainer);
151
								return Status.OK_STATUS;
151
152
							} catch (InvocationTargetException e) {
152
		TabItem argsTab = new TabItem(tabs, SWT.NONE);
153
								return new Status(IStatus.ERROR, PDEPlugin.getPluginId(), PDEUIMessages.TargetDefinitionContentPage_5, e);
153
		argsTab.setText(PDEUIMessages.TargetDefinitionEnvironmentPage_4);
154
							} catch (InterruptedException e) {
154
		argsTab.setControl(createArgumentsGroup(tabs));
155
								return Status.CANCEL_STATUS;
155
156
							}
156
		TabItem depTab = new TabItem(tabs, SWT.NONE);
157
						}
157
		depTab.setText(PDEUIMessages.TargetDefinitionEnvironmentPage_5);
158
					}.schedule();
158
		depTab.setControl(createImplicitTabContents(tabs));
159
				}
159
160
			}
160
		initializeListeners();
161
161
		targetChanged(getTargetDefinition());
162
			public void contentsChanged() {
162
		setControl(comp);
163
				// Do nothing, as wizard will always save when finish is pressed
163
	}
164
			}
164
165
		});
165
	private void initializeListeners() {
166
		pluginsTab.setControl(pluginTabContainer);
166
		ITargetChangedListener listener = new ITargetChangedListener() {
167
167
			public void contentsChanged(ITargetDefinition definition, boolean resolve) {
168
		TabItem envTab = new TabItem(tabs, SWT.NONE);
168
				if (resolve) {
169
		envTab.setText(PDEUIMessages.TargetDefinitionEnvironmentPage_3);
169
					if (!definition.isResolved()) {
170
		Composite envTabContainer = SWTFactory.createComposite(tabs, 1, 1, GridData.FILL_BOTH);
170
						try {
171
		createTargetEnvironmentGroup(envTabContainer);
171
							getContainer().run(true, true, new IRunnableWithProgress() {
172
		createJREGroup(envTabContainer);
172
								public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
173
		envTab.setControl(envTabContainer);
173
									getTargetDefinition().resolve(monitor);
174
174
									if (monitor.isCanceled()) {
175
		TabItem argsTab = new TabItem(tabs, SWT.NONE);
175
										throw new InterruptedException();
176
		argsTab.setText(PDEUIMessages.TargetDefinitionEnvironmentPage_4);
176
									}
177
		argsTab.setControl(createArgumentsGroup(tabs));
177
								}
178
178
							});
179
		TabItem depTab = new TabItem(tabs, SWT.NONE);
179
						} catch (InvocationTargetException e) {
180
		depTab.setText(PDEUIMessages.TargetDefinitionEnvironmentPage_5);
180
							PDECore.log(e);
181
		depTab.setControl(createImplicitTabContents(tabs));
181
						} catch (InterruptedException e) {
182
182
							// Do nothing, op cancelled
183
		targetChanged(getTargetDefinition());
183
						}
184
		setControl(comp);
184
					}
185
	}
185
					fContentTree.setInput(definition);
186
186
					fLocationTree.setInput(definition);
187
	/* (non-Javadoc)
187
					if (definition.isResolved() && definition.getBundleStatus().getSeverity() == IStatus.ERROR) {
188
	 * @see org.eclipse.pde.internal.ui.wizards.target.TargetDefinitionPage#targetChanged()
188
						fLocationTab.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_ERROR_TSK));
189
	 */
189
					} else {
190
	protected void targetChanged(ITargetDefinition definition) {
190
						fLocationTab.setImage(null);
191
		super.targetChanged(definition);
191
					}
192
		if (definition != null) {
192
				}
193
			String name = definition.getName();
193
			}
194
			if (name == null) {
194
		};
195
				name = EMPTY_STRING;
195
		fContentTree.addTargetChangedListener(listener);
196
			}
196
		fLocationTree.addTargetChangedListener(listener);
197
197
		// When  If the page isn't open yet, try running a UI job so the dialog has time to finish opening
198
			if (name.trim().length() > 0)
198
		new UIJob(PDEUIMessages.TargetDefinitionContentPage_0) {
199
				fNameText.setText(name);
199
			public IStatus runInUIThread(IProgressMonitor monitor) {
200
			else
200
				try {
201
				setMessage(PDEUIMessages.TargetDefinitionContentPage_8);
201
					getContainer().run(true, true, new IRunnableWithProgress() {
202
202
						public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
203
			fTable.setInput(definition);
203
							getTargetDefinition().resolve(monitor);
204
204
							if (monitor.isCanceled()) {
205
			String presetValue = (definition.getOS() == null) ? EMPTY_STRING : definition.getOS();
205
								throw new InterruptedException();
206
			fOSCombo.setText(presetValue);
206
							}
207
			presetValue = (definition.getWS() == null) ? EMPTY_STRING : definition.getWS();
207
						}
208
			fWSCombo.setText(presetValue);
208
					});
209
			presetValue = (definition.getArch() == null) ? EMPTY_STRING : definition.getArch();
209
				} catch (InvocationTargetException e) {
210
			fArchCombo.setText(presetValue);
210
					PDECore.log(e);
211
			presetValue = (definition.getNL() == null) ? EMPTY_STRING : LocaleUtil.expandLocaleName(definition.getNL());
211
				} catch (InterruptedException e) {
212
			fNLCombo.setText(presetValue);
212
					return Status.CANCEL_STATUS;
213
213
				}
214
			IPath jrePath = definition.getJREContainer();
214
				ITargetDefinition definition = getTargetDefinition();
215
			if (jrePath == null || jrePath.equals(JavaRuntime.newDefaultJREContainerPath())) {
215
				fContentTree.setInput(definition);
216
				fDefaultJREButton.setSelection(true);
216
				fLocationTree.setInput(definition);
217
			} else {
217
				if (definition.isResolved() && definition.getBundleStatus().getSeverity() == IStatus.ERROR) {
218
				String ee = JavaRuntime.getExecutionEnvironmentId(jrePath);
218
					fLocationTab.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_ERROR_TSK));
219
				if (ee != null) {
219
				} else {
220
					fExecEnvButton.setSelection(true);
220
					fLocationTab.setImage(null);
221
					fExecEnvsCombo.select(fExecEnvsCombo.indexOf(ee));
221
				}
222
				} else {
222
				return Status.OK_STATUS;
223
					String vm = JavaRuntime.getVMInstallName(jrePath);
223
			}
224
					if (vm != null) {
224
		}.schedule();
225
						fNamedJREButton.setSelection(true);
225
226
						fNamedJREsCombo.select(fNamedJREsCombo.indexOf(vm));
226
	}
227
					}
227
228
				}
228
	/* (non-Javadoc)
229
			}
229
	 * @see org.eclipse.pde.internal.ui.wizards.target.TargetDefinitionPage#targetChanged()
230
230
	 */
231
			if (fExecEnvsCombo.getSelectionIndex() == -1)
231
	protected void targetChanged(ITargetDefinition definition) {
232
				fExecEnvsCombo.setText(fExecEnvChoices.first().toString());
232
		super.targetChanged(definition);
233
233
		if (definition != null) {
234
			if (fNamedJREsCombo.getSelectionIndex() == -1)
234
			String name = definition.getName();
235
				fNamedJREsCombo.setText(VMUtil.getDefaultVMInstallName());
235
			if (name == null) {
236
236
				name = EMPTY_STRING;
237
			updateJREWidgets();
237
			}
238
238
239
			presetValue = (definition.getProgramArguments() == null) ? EMPTY_STRING : definition.getProgramArguments();
239
			if (name.trim().length() > 0)
240
			fProgramArgs.setText(presetValue);
240
				fNameText.setText(name);
241
			presetValue = (definition.getVMArguments() == null) ? EMPTY_STRING : definition.getVMArguments();
241
			else
242
			fVMArgs.setText(presetValue);
242
				setMessage(PDEUIMessages.TargetDefinitionContentPage_8);
243
243
244
			fElementViewer.refresh();
244
			fLocationTree.setInput(definition);
245
		}
245
			fContentTree.setInput(definition);
246
	}
246
247
247
			String presetValue = (definition.getOS() == null) ? EMPTY_STRING : definition.getOS();
248
	private void createTargetEnvironmentGroup(Composite container) {
248
			fOSCombo.setText(presetValue);
249
		Group group = SWTFactory.createGroup(container, PDEUIMessages.EnvironmentBlock_targetEnv, 2, 1, GridData.FILL_HORIZONTAL);
249
			presetValue = (definition.getWS() == null) ? EMPTY_STRING : definition.getWS();
250
250
			fWSCombo.setText(presetValue);
251
		initializeChoices();
251
			presetValue = (definition.getArch() == null) ? EMPTY_STRING : definition.getArch();
252
252
			fArchCombo.setText(presetValue);
253
		SWTFactory.createLabel(group, PDEUIMessages.Preferences_TargetEnvironmentPage_os, 1);
253
			presetValue = (definition.getNL() == null) ? EMPTY_STRING : LocaleUtil.expandLocaleName(definition.getNL());
254
254
			fNLCombo.setText(presetValue);
255
		fOSCombo = SWTFactory.createCombo(group, SWT.SINGLE | SWT.BORDER, 1, (String[]) fOSChoices.toArray(new String[fOSChoices.size()]));
255
256
		fOSCombo.addModifyListener(new ModifyListener() {
256
			IPath jrePath = definition.getJREContainer();
257
			public void modifyText(ModifyEvent e) {
257
			if (jrePath == null || jrePath.equals(JavaRuntime.newDefaultJREContainerPath())) {
258
				getTargetDefinition().setOS(getModelValue(fOSCombo.getText()));
258
				fDefaultJREButton.setSelection(true);
259
			}
259
			} else {
260
		});
260
				String ee = JavaRuntime.getExecutionEnvironmentId(jrePath);
261
261
				if (ee != null) {
262
		SWTFactory.createLabel(group, PDEUIMessages.Preferences_TargetEnvironmentPage_ws, 1);
262
					fExecEnvButton.setSelection(true);
263
263
					fExecEnvsCombo.select(fExecEnvsCombo.indexOf(ee));
264
		fWSCombo = SWTFactory.createCombo(group, SWT.SINGLE | SWT.BORDER, 1, (String[]) fWSChoices.toArray(new String[fWSChoices.size()]));
264
				} else {
265
		fWSCombo.addModifyListener(new ModifyListener() {
265
					String vm = JavaRuntime.getVMInstallName(jrePath);
266
			public void modifyText(ModifyEvent e) {
266
					if (vm != null) {
267
				getTargetDefinition().setWS(getModelValue(fWSCombo.getText()));
267
						fNamedJREButton.setSelection(true);
268
			}
268
						fNamedJREsCombo.select(fNamedJREsCombo.indexOf(vm));
269
		});
269
					}
270
270
				}
271
		SWTFactory.createLabel(group, PDEUIMessages.Preferences_TargetEnvironmentPage_arch, 1);
271
			}
272
272
273
		fArchCombo = SWTFactory.createCombo(group, SWT.SINGLE | SWT.BORDER, 1, (String[]) fArchChoices.toArray(new String[fArchChoices.size()]));
273
			if (fExecEnvsCombo.getSelectionIndex() == -1)
274
		fArchCombo.addModifyListener(new ModifyListener() {
274
				fExecEnvsCombo.setText(fExecEnvChoices.first().toString());
275
			public void modifyText(ModifyEvent e) {
275
276
				getTargetDefinition().setArch(getModelValue(fArchCombo.getText()));
276
			if (fNamedJREsCombo.getSelectionIndex() == -1)
277
			}
277
				fNamedJREsCombo.setText(VMUtil.getDefaultVMInstallName());
278
		});
278
279
279
			updateJREWidgets();
280
		SWTFactory.createLabel(group, PDEUIMessages.Preferences_TargetEnvironmentPage_nl, 1);
280
281
281
			presetValue = (definition.getProgramArguments() == null) ? EMPTY_STRING : definition.getProgramArguments();
282
		fNLCombo = SWTFactory.createCombo(group, SWT.SINGLE | SWT.BORDER, 1, (String[]) fNLChoices.toArray(new String[fNLChoices.size()]));
282
			fProgramArgs.setText(presetValue);
283
		fNLCombo.addModifyListener(new ModifyListener() {
283
			presetValue = (definition.getVMArguments() == null) ? EMPTY_STRING : definition.getVMArguments();
284
			public void modifyText(ModifyEvent e) {
284
			fVMArgs.setText(presetValue);
285
				String value = fNLCombo.getText();
285
286
				int index = value.indexOf("-"); //$NON-NLS-1$
286
			fElementViewer.refresh();
287
				if (index > 0)
287
		}
288
					value = value.substring(0, index);
288
	}
289
				getTargetDefinition().setNL(getModelValue(value));
289
290
			}
290
	private void createTargetEnvironmentGroup(Composite container) {
291
		});
291
		Group group = SWTFactory.createGroup(container, PDEUIMessages.EnvironmentBlock_targetEnv, 2, 1, GridData.FILL_HORIZONTAL);
292
292
293
	}
293
		initializeChoices();
294
294
295
	/**
295
		SWTFactory.createLabel(group, PDEUIMessages.Preferences_TargetEnvironmentPage_os, 1);
296
	 * Returns the given string or <code>null</code> if the string is empty.
296
297
	 * Used when setting a value in the target definition.
297
		fOSCombo = SWTFactory.createCombo(group, SWT.SINGLE | SWT.BORDER, 1, (String[]) fOSChoices.toArray(new String[fOSChoices.size()]));
298
	 * 
298
		fOSCombo.addModifyListener(new ModifyListener() {
299
	 * @param value
299
			public void modifyText(ModifyEvent e) {
300
	 * @return trimmed value or <code>null</code>
300
				getTargetDefinition().setOS(getModelValue(fOSCombo.getText()));
301
	 */
301
			}
302
	private String getModelValue(String value) {
302
		});
303
		if (value != null) {
303
304
			value = value.trim();
304
		SWTFactory.createLabel(group, PDEUIMessages.Preferences_TargetEnvironmentPage_ws, 1);
305
			if (value.length() == 0) {
305
306
				return null;
306
		fWSCombo = SWTFactory.createCombo(group, SWT.SINGLE | SWT.BORDER, 1, (String[]) fWSChoices.toArray(new String[fWSChoices.size()]));
307
			}
307
		fWSCombo.addModifyListener(new ModifyListener() {
308
		}
308
			public void modifyText(ModifyEvent e) {
309
		return value;
309
				getTargetDefinition().setWS(getModelValue(fWSCombo.getText()));
310
	}
310
			}
311
311
		});
312
	/**
312
313
	* Delimits a comma separated preference and add the items to the given set
313
		SWTFactory.createLabel(group, PDEUIMessages.Preferences_TargetEnvironmentPage_arch, 1);
314
	* @param set
314
315
	* @param preference
315
		fArchCombo = SWTFactory.createCombo(group, SWT.SINGLE | SWT.BORDER, 1, (String[]) fArchChoices.toArray(new String[fArchChoices.size()]));
316
	*/
316
		fArchCombo.addModifyListener(new ModifyListener() {
317
	private void addExtraChoices(Set set, String preference) {
317
			public void modifyText(ModifyEvent e) {
318
		StringTokenizer tokenizer = new StringTokenizer(preference, ","); //$NON-NLS-1$
318
				getTargetDefinition().setArch(getModelValue(fArchCombo.getText()));
319
		while (tokenizer.hasMoreTokens()) {
319
			}
320
			set.add(tokenizer.nextToken().trim());
320
		});
321
		}
321
322
	}
322
		SWTFactory.createLabel(group, PDEUIMessages.Preferences_TargetEnvironmentPage_nl, 1);
323
323
324
	/**
324
		fNLCombo = SWTFactory.createCombo(group, SWT.SINGLE | SWT.BORDER, 1, (String[]) fNLChoices.toArray(new String[fNLChoices.size()]));
325
	 * Loads combo choices fromt he platform and from PDE core preferences
325
		fNLCombo.addModifyListener(new ModifyListener() {
326
	 */
326
			public void modifyText(ModifyEvent e) {
327
	private void initializeChoices() {
327
				String value = fNLCombo.getText();
328
		IEclipsePreferences node = new InstanceScope().getNode(PDECore.PLUGIN_ID);
328
				int index = value.indexOf("-"); //$NON-NLS-1$
329
329
				if (index > 0)
330
		fOSChoices = new TreeSet();
330
					value = value.substring(0, index);
331
		String[] os = Platform.knownOSValues();
331
				getTargetDefinition().setNL(getModelValue(value));
332
		for (int i = 0; i < os.length; i++) {
332
			}
333
			fOSChoices.add(os[i]);
333
		});
334
		}
334
335
		String pref = node.get(ICoreConstants.OS_EXTRA, EMPTY_STRING);
335
	}
336
		if (!EMPTY_STRING.equals(pref)) {
336
337
			addExtraChoices(fOSChoices, pref);
337
	/**
338
		}
338
	 * Returns the given string or <code>null</code> if the string is empty.
339
339
	 * Used when setting a value in the target definition.
340
		fWSChoices = new TreeSet();
340
	 * 
341
		String[] ws = Platform.knownWSValues();
341
	 * @param value
342
		for (int i = 0; i < ws.length; i++) {
342
	 * @return trimmed value or <code>null</code>
343
			fWSChoices.add(ws[i]);
343
	 */
344
		}
344
	private String getModelValue(String value) {
345
		pref = node.get(ICoreConstants.WS_EXTRA, EMPTY_STRING);
345
		if (value != null) {
346
		if (!EMPTY_STRING.equals(pref)) {
346
			value = value.trim();
347
			addExtraChoices(fWSChoices, pref);
347
			if (value.length() == 0) {
348
		}
348
				return null;
349
349
			}
350
		fArchChoices = new TreeSet();
350
		}
351
		String[] arch = Platform.knownOSArchValues();
351
		return value;
352
		for (int i = 0; i < arch.length; i++) {
352
	}
353
			fArchChoices.add(arch[i]);
353
354
		}
354
	/**
355
		pref = node.get(ICoreConstants.ARCH_EXTRA, EMPTY_STRING);
355
	* Delimits a comma separated preference and add the items to the given set
356
		if (!EMPTY_STRING.equals(pref)) {
356
	* @param set
357
			addExtraChoices(fArchChoices, pref);
357
	* @param preference
358
		}
358
	*/
359
359
	private void addExtraChoices(Set set, String preference) {
360
		fNLChoices = new TreeSet();
360
		StringTokenizer tokenizer = new StringTokenizer(preference, ","); //$NON-NLS-1$
361
		String[] nl = LocaleUtil.getLocales();
361
		while (tokenizer.hasMoreTokens()) {
362
		for (int i = 0; i < nl.length; i++) {
362
			set.add(tokenizer.nextToken().trim());
363
			fNLChoices.add(nl[i]);
363
		}
364
		}
364
	}
365
		pref = node.get(ICoreConstants.NL_EXTRA, EMPTY_STRING);
365
366
		if (!EMPTY_STRING.equals(pref)) {
366
	/**
367
			addExtraChoices(fNLChoices, pref);
367
	 * Loads combo choices fromt he platform and from PDE core preferences
368
		}
368
	 */
369
	}
369
	private void initializeChoices() {
370
370
		IEclipsePreferences node = new InstanceScope().getNode(PDECore.PLUGIN_ID);
371
	private void createJREGroup(Composite container) {
371
372
		Group group = SWTFactory.createGroup(container, PDEUIMessages.EnvironmentBlock_jreTitle, 2, 1, GridData.FILL_HORIZONTAL);
372
		fOSChoices = new TreeSet();
373
373
		String[] os = Platform.knownOSValues();
374
		initializeJREValues();
374
		for (int i = 0; i < os.length; i++) {
375
375
			fOSChoices.add(os[i]);
376
		SWTFactory.createWrapLabel(group, PDEUIMessages.JRESection_description, 2);
376
		}
377
377
		String pref = node.get(ICoreConstants.OS_EXTRA, EMPTY_STRING);
378
		fDefaultJREButton = SWTFactory.createRadioButton(group, PDEUIMessages.JRESection_defaultJRE, 2);
378
		if (!EMPTY_STRING.equals(pref)) {
379
		fDefaultJREButton.addSelectionListener(new SelectionAdapter() {
379
			addExtraChoices(fOSChoices, pref);
380
			public void widgetSelected(SelectionEvent e) {
380
		}
381
				updateJREWidgets();
381
382
				getTargetDefinition().setJREContainer(JavaRuntime.newDefaultJREContainerPath());
382
		fWSChoices = new TreeSet();
383
			}
383
		String[] ws = Platform.knownWSValues();
384
		});
384
		for (int i = 0; i < ws.length; i++) {
385
385
			fWSChoices.add(ws[i]);
386
		fNamedJREButton = SWTFactory.createRadioButton(group, PDEUIMessages.JRESection_JREName);
386
		}
387
		fNamedJREButton.addSelectionListener(new SelectionAdapter() {
387
		pref = node.get(ICoreConstants.WS_EXTRA, EMPTY_STRING);
388
			public void widgetSelected(SelectionEvent e) {
388
		if (!EMPTY_STRING.equals(pref)) {
389
				updateJREWidgets();
389
			addExtraChoices(fWSChoices, pref);
390
				getTargetDefinition().setJREContainer(JavaRuntime.newJREContainerPath(VMUtil.getVMInstall(fNamedJREsCombo.getText())));
390
		}
391
			}
391
392
		});
392
		fArchChoices = new TreeSet();
393
393
		String[] arch = Platform.knownOSArchValues();
394
		fNamedJREsCombo = SWTFactory.createCombo(group, SWT.SINGLE | SWT.BORDER | SWT.READ_ONLY, 1, VMUtil.getVMInstallNames());
394
		for (int i = 0; i < arch.length; i++) {
395
		fNamedJREsCombo.addModifyListener(new ModifyListener() {
395
			fArchChoices.add(arch[i]);
396
			public void modifyText(ModifyEvent e) {
396
		}
397
				getTargetDefinition().setJREContainer(JavaRuntime.newJREContainerPath(VMUtil.getVMInstall(fNamedJREsCombo.getText())));
397
		pref = node.get(ICoreConstants.ARCH_EXTRA, EMPTY_STRING);
398
			}
398
		if (!EMPTY_STRING.equals(pref)) {
399
		});
399
			addExtraChoices(fArchChoices, pref);
400
400
		}
401
		fExecEnvButton = SWTFactory.createRadioButton(group, PDEUIMessages.JRESection_ExecutionEnv);
401
402
		fExecEnvButton.addSelectionListener(new SelectionAdapter() {
402
		fNLChoices = new TreeSet();
403
			public void widgetSelected(SelectionEvent e) {
403
		String[] nl = LocaleUtil.getLocales();
404
				updateJREWidgets();
404
		for (int i = 0; i < nl.length; i++) {
405
				getTargetDefinition().setJREContainer(JavaRuntime.newJREContainerPath(VMUtil.getExecutionEnvironment(fExecEnvsCombo.getText())));
405
			fNLChoices.add(nl[i]);
406
			}
406
		}
407
		});
407
		pref = node.get(ICoreConstants.NL_EXTRA, EMPTY_STRING);
408
408
		if (!EMPTY_STRING.equals(pref)) {
409
		fExecEnvsCombo = SWTFactory.createCombo(group, SWT.SINGLE | SWT.BORDER | SWT.READ_ONLY, 1, (String[]) fExecEnvChoices.toArray(new String[fExecEnvChoices.size()]));
409
			addExtraChoices(fNLChoices, pref);
410
		fExecEnvsCombo.addModifyListener(new ModifyListener() {
410
		}
411
			public void modifyText(ModifyEvent e) {
411
	}
412
				getTargetDefinition().setJREContainer(JavaRuntime.newJREContainerPath(VMUtil.getExecutionEnvironment(fExecEnvsCombo.getText())));
412
413
			}
413
	private void createJREGroup(Composite container) {
414
		});
414
		Group group = SWTFactory.createGroup(container, PDEUIMessages.EnvironmentBlock_jreTitle, 2, 1, GridData.FILL_HORIZONTAL);
415
415
416
	}
416
		initializeJREValues();
417
417
418
	/**
418
		SWTFactory.createWrapLabel(group, PDEUIMessages.JRESection_description, 2);
419
	 * Initializes the combo with possible execution environments
419
420
	 */
420
		fDefaultJREButton = SWTFactory.createRadioButton(group, PDEUIMessages.JRESection_defaultJRE, 2);
421
	protected void initializeJREValues() {
421
		fDefaultJREButton.addSelectionListener(new SelectionAdapter() {
422
		fExecEnvChoices = new TreeSet();
422
			public void widgetSelected(SelectionEvent e) {
423
		IExecutionEnvironmentsManager manager = JavaRuntime.getExecutionEnvironmentsManager();
423
				updateJREWidgets();
424
		IExecutionEnvironment[] envs = manager.getExecutionEnvironments();
424
				getTargetDefinition().setJREContainer(JavaRuntime.newDefaultJREContainerPath());
425
		for (int i = 0; i < envs.length; i++)
425
			}
426
			fExecEnvChoices.add(envs[i].getId());
426
		});
427
	}
427
428
428
		fNamedJREButton = SWTFactory.createRadioButton(group, PDEUIMessages.JRESection_JREName);
429
	protected void updateJREWidgets() {
429
		fNamedJREButton.addSelectionListener(new SelectionAdapter() {
430
		fNamedJREsCombo.setEnabled(fNamedJREButton.getSelection());
430
			public void widgetSelected(SelectionEvent e) {
431
		fExecEnvsCombo.setEnabled(fExecEnvButton.getSelection());
431
				updateJREWidgets();
432
	}
432
				getTargetDefinition().setJREContainer(JavaRuntime.newJREContainerPath(VMUtil.getVMInstall(fNamedJREsCombo.getText())));
433
433
			}
434
	private Control createArgumentsGroup(Composite parent) {
434
		});
435
		Composite container = SWTFactory.createComposite(parent, 1, 1, GridData.FILL_BOTH);
435
436
436
		fNamedJREsCombo = SWTFactory.createCombo(group, SWT.SINGLE | SWT.BORDER | SWT.READ_ONLY, 1, VMUtil.getVMInstallNames());
437
		SWTFactory.createWrapLabel(container, PDEUIMessages.JavaArgumentsTab_description, 1);
437
		fNamedJREsCombo.addModifyListener(new ModifyListener() {
438
438
			public void modifyText(ModifyEvent e) {
439
		Group programGroup = SWTFactory.createGroup(container, PDEUIMessages.JavaArgumentsTab_progamArgsGroup, 1, 1, GridData.FILL_HORIZONTAL);
439
				getTargetDefinition().setJREContainer(JavaRuntime.newJREContainerPath(VMUtil.getVMInstall(fNamedJREsCombo.getText())));
440
440
			}
441
		fProgramArgs = SWTFactory.createText(programGroup, SWT.MULTI | SWT.WRAP | SWT.BORDER | SWT.V_SCROLL, 1, 200, 60, GridData.FILL_BOTH);
441
		});
442
		fProgramArgs.addModifyListener(new ModifyListener() {
442
443
			public void modifyText(ModifyEvent e) {
443
		fExecEnvButton = SWTFactory.createRadioButton(group, PDEUIMessages.JRESection_ExecutionEnv);
444
				getTargetDefinition().setProgramArguments(fProgramArgs.getText().trim());
444
		fExecEnvButton.addSelectionListener(new SelectionAdapter() {
445
			}
445
			public void widgetSelected(SelectionEvent e) {
446
		});
446
				updateJREWidgets();
447
447
				getTargetDefinition().setJREContainer(JavaRuntime.newJREContainerPath(VMUtil.getExecutionEnvironment(fExecEnvsCombo.getText())));
448
		Button programVars = new Button(programGroup, SWT.NONE);
448
			}
449
		programVars.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
449
		});
450
		programVars.setText(PDEUIMessages.JavaArgumentsTab_programVariables);
450
451
		programVars.addSelectionListener(getVariablesListener(fProgramArgs));
451
		fExecEnvsCombo = SWTFactory.createCombo(group, SWT.SINGLE | SWT.BORDER | SWT.READ_ONLY, 1, (String[]) fExecEnvChoices.toArray(new String[fExecEnvChoices.size()]));
452
452
		fExecEnvsCombo.addModifyListener(new ModifyListener() {
453
		Group vmGroup = new Group(container, SWT.NONE);
453
			public void modifyText(ModifyEvent e) {
454
		vmGroup.setLayout(new GridLayout(1, false));
454
				getTargetDefinition().setJREContainer(JavaRuntime.newJREContainerPath(VMUtil.getExecutionEnvironment(fExecEnvsCombo.getText())));
455
		vmGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
455
			}
456
		vmGroup.setText(PDEUIMessages.JavaArgumentsTab_vmArgsGroup);
456
		});
457
457
458
		fVMArgs = SWTFactory.createText(vmGroup, SWT.MULTI | SWT.WRAP | SWT.BORDER | SWT.V_SCROLL, 1, 200, 60, GridData.FILL_BOTH);
458
	}
459
		fVMArgs.addModifyListener(new ModifyListener() {
459
460
			public void modifyText(ModifyEvent e) {
460
	/**
461
				getTargetDefinition().setVMArguments(fVMArgs.getText().trim());
461
	 * Initializes the combo with possible execution environments
462
			}
462
	 */
463
		});
463
	protected void initializeJREValues() {
464
464
		fExecEnvChoices = new TreeSet();
465
		Composite buttons = SWTFactory.createComposite(vmGroup, 2, 1, GridData.HORIZONTAL_ALIGN_END, 0, 0);
465
		IExecutionEnvironmentsManager manager = JavaRuntime.getExecutionEnvironmentsManager();
466
466
		IExecutionEnvironment[] envs = manager.getExecutionEnvironments();
467
		Button vmArgs = SWTFactory.createPushButton(buttons, PDEUIMessages.JavaArgumentsTab_addVMArgs, null, GridData.HORIZONTAL_ALIGN_END);
467
		for (int i = 0; i < envs.length; i++)
468
		vmArgs.addSelectionListener(getVMArgsListener(fVMArgs));
468
			fExecEnvChoices.add(envs[i].getId());
469
469
	}
470
		Button vmVars = SWTFactory.createPushButton(buttons, PDEUIMessages.JavaArgumentsTab_vmVariables, null, GridData.HORIZONTAL_ALIGN_END);
470
471
		vmVars.addSelectionListener(getVariablesListener(fVMArgs));
471
	protected void updateJREWidgets() {
472
472
		fNamedJREsCombo.setEnabled(fNamedJREButton.getSelection());
473
		return container;
473
		fExecEnvsCombo.setEnabled(fExecEnvButton.getSelection());
474
	}
474
	}
475
475
476
	/**
476
	private Control createArgumentsGroup(Composite parent) {
477
	 * Provide a listener for the Add VM Arguments button.
477
		Composite container = SWTFactory.createComposite(parent, 1, 1, GridData.FILL_BOTH);
478
	 * The listener invokes the <code>VMArgumentsSelectionDialog</code> and 
478
479
	 * updates the selected VM Arguments back in the VM Arguments Text Box
479
		SWTFactory.createWrapLabel(container, PDEUIMessages.JavaArgumentsTab_description, 1);
480
	 * 
480
481
	 * @param textControl
481
		Group programGroup = SWTFactory.createGroup(container, PDEUIMessages.JavaArgumentsTab_progamArgsGroup, 1, 1, GridData.FILL_HORIZONTAL);
482
	 * @return	<code>SelectionListener</code> for the Add VM Arguments button
482
483
	 */
483
		fProgramArgs = SWTFactory.createText(programGroup, SWT.MULTI | SWT.WRAP | SWT.BORDER | SWT.V_SCROLL, 1, 200, 60, GridData.FILL_BOTH);
484
	private SelectionListener getVMArgsListener(final Text textControl) {
484
		fProgramArgs.addModifyListener(new ModifyListener() {
485
		return new SelectionAdapter() {
485
			public void modifyText(ModifyEvent e) {
486
			public void widgetSelected(SelectionEvent e) {
486
				getTargetDefinition().setProgramArguments(fProgramArgs.getText().trim());
487
				ArgumentsFromContainerSelectionDialog dialog = new ArgumentsFromContainerSelectionDialog(getShell(), getTargetDefinition());
487
			}
488
				if (dialog.open() == Window.OK) {
488
		});
489
					String[] args = dialog.getSelectedArguments();
489
490
					if (args != null && args.length > 0) {
490
		Button programVars = new Button(programGroup, SWT.NONE);
491
						StringBuffer resultBuffer = new StringBuffer();
491
		programVars.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
492
						for (int index = 0; index < args.length; ++index) {
492
		programVars.setText(PDEUIMessages.JavaArgumentsTab_programVariables);
493
							resultBuffer.append(args[index] + " "); //$NON-NLS-1$
493
		programVars.addSelectionListener(getVariablesListener(fProgramArgs));
494
						}
494
495
						fVMArgs.insert(resultBuffer.toString());
495
		Group vmGroup = new Group(container, SWT.NONE);
496
					}
496
		vmGroup.setLayout(new GridLayout(1, false));
497
				}
497
		vmGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
498
			}
498
		vmGroup.setText(PDEUIMessages.JavaArgumentsTab_vmArgsGroup);
499
		};
499
500
	}
500
		fVMArgs = SWTFactory.createText(vmGroup, SWT.MULTI | SWT.WRAP | SWT.BORDER | SWT.V_SCROLL, 1, 200, 60, GridData.FILL_BOTH);
501
501
		fVMArgs.addModifyListener(new ModifyListener() {
502
	/**
502
			public void modifyText(ModifyEvent e) {
503
	 * Provide a listener for the Variables button.
503
				getTargetDefinition().setVMArguments(fVMArgs.getText().trim());
504
	 * The listener invokes the <code>StringVariableSelectionDialog</code> and 
504
			}
505
	 * updates the selected Variables back in the VM Arguments Text Box
505
		});
506
	 * 
506
507
	 * @param textControl
507
		Composite buttons = SWTFactory.createComposite(vmGroup, 2, 1, GridData.HORIZONTAL_ALIGN_END, 0, 0);
508
	 * @return	<code>SelectionListener</code> for the Variables button
508
509
	 */
509
		Button vmArgs = SWTFactory.createPushButton(buttons, PDEUIMessages.JavaArgumentsTab_addVMArgs, null, GridData.HORIZONTAL_ALIGN_END);
510
	private SelectionListener getVariablesListener(final Text textControl) {
510
		vmArgs.addSelectionListener(getVMArgsListener(fVMArgs));
511
		return new SelectionAdapter() {
511
512
			public void widgetSelected(SelectionEvent e) {
512
		Button vmVars = SWTFactory.createPushButton(buttons, PDEUIMessages.JavaArgumentsTab_vmVariables, null, GridData.HORIZONTAL_ALIGN_END);
513
				StringVariableSelectionDialog dialog = new StringVariableSelectionDialog(getShell());
513
		vmVars.addSelectionListener(getVariablesListener(fVMArgs));
514
				dialog.open();
514
515
				String variable = dialog.getVariableExpression();
515
		return container;
516
				if (variable != null) {
516
	}
517
					textControl.insert(variable);
517
518
				}
518
	/**
519
			}
519
	 * Provide a listener for the Add VM Arguments button.
520
		};
520
	 * The listener invokes the <code>VMArgumentsSelectionDialog</code> and 
521
	}
521
	 * updates the selected VM Arguments back in the VM Arguments Text Box
522
522
	 * 
523
	private Control createImplicitTabContents(Composite parent) {
523
	 * @param textControl
524
		Composite container = new Composite(parent, SWT.NONE);
524
	 * @return	<code>SelectionListener</code> for the Add VM Arguments button
525
		GridLayout layout = new GridLayout(2, false);
525
	 */
526
		container.setLayout(layout);
526
	private SelectionListener getVMArgsListener(final Text textControl) {
527
		container.setLayoutData(new GridData(GridData.FILL_BOTH));
527
		return new SelectionAdapter() {
528
528
			public void widgetSelected(SelectionEvent e) {
529
		createImpLabel(container);
529
				ArgumentsFromContainerSelectionDialog dialog = new ArgumentsFromContainerSelectionDialog(getShell(), getTargetDefinition());
530
		createImpTable(container);
530
				if (dialog.open() == Window.OK) {
531
		createImpButtons(container);
531
					String[] args = dialog.getSelectedArguments();
532
		// TODO: PlatformUI.getWorkbench().getHelpSystem().setHelp(container, IHelpContextIds.IMPLICIT_PLUGINS_PREFERENCE_PAGE);
532
					if (args != null && args.length > 0) {
533
		return container;
533
						StringBuffer resultBuffer = new StringBuffer();
534
	}
534
						for (int index = 0; index < args.length; ++index) {
535
535
							resultBuffer.append(args[index] + " "); //$NON-NLS-1$
536
	private void createImpLabel(Composite container) {
536
						}
537
		Label label = new Label(container, SWT.NONE);
537
						fVMArgs.insert(resultBuffer.toString());
538
		label.setText(PDEUIMessages.TargetImplicitPluginsTab_desc);
538
					}
539
		GridData gd = new GridData(GridData.FILL_HORIZONTAL);
539
				}
540
		gd.horizontalSpan = 2;
540
			}
541
		label.setLayoutData(gd);
541
		};
542
	}
542
	}
543
543
544
	private void createImpTable(Composite container) {
544
	/**
545
		fElementViewer = new TableViewer(container, SWT.MULTI | SWT.V_SCROLL | SWT.BORDER);
545
	 * Provide a listener for the Variables button.
546
		GridData gd = new GridData(GridData.FILL_BOTH);
546
	 * The listener invokes the <code>StringVariableSelectionDialog</code> and 
547
		gd.heightHint = 250;
547
	 * updates the selected Variables back in the VM Arguments Text Box
548
		fElementViewer.getControl().setLayoutData(gd);
548
	 * 
549
		fElementViewer.setContentProvider(new DefaultTableProvider() {
549
	 * @param textControl
550
			public Object[] getElements(Object inputElement) {
550
	 * @return	<code>SelectionListener</code> for the Variables button
551
				ITargetDefinition target = getTargetDefinition();
551
	 */
552
				if (target != null) {
552
	private SelectionListener getVariablesListener(final Text textControl) {
553
					BundleInfo[] bundles = target.getImplicitDependencies();
553
		return new SelectionAdapter() {
554
					if (bundles != null) {
554
			public void widgetSelected(SelectionEvent e) {
555
						return bundles;
555
				StringVariableSelectionDialog dialog = new StringVariableSelectionDialog(getShell());
556
					}
556
				dialog.open();
557
				}
557
				String variable = dialog.getVariableExpression();
558
				return new BundleInfo[0];
558
				if (variable != null) {
559
			}
559
					textControl.insert(variable);
560
		});
560
				}
561
		fElementViewer.setLabelProvider(new BundleInfoLabelProvider(false));
561
			}
562
		fElementViewer.setInput(PDEPlugin.getDefault());
562
		};
563
		fElementViewer.setComparator(new ViewerComparator() {
563
	}
564
			public int compare(Viewer viewer, Object e1, Object e2) {
564
565
				BundleInfo bundle1 = (BundleInfo) e1;
565
	private Control createImplicitTabContents(Composite parent) {
566
				BundleInfo bundle2 = (BundleInfo) e2;
566
		Composite container = new Composite(parent, SWT.NONE);
567
				return super.compare(viewer, bundle1.getSymbolicName(), bundle2.getSymbolicName());
567
		GridLayout layout = new GridLayout(2, false);
568
			}
568
		container.setLayout(layout);
569
		});
569
		container.setLayoutData(new GridData(GridData.FILL_BOTH));
570
		fElementViewer.addSelectionChangedListener(new ISelectionChangedListener() {
570
571
			public void selectionChanged(SelectionChangedEvent event) {
571
		createImpLabel(container);
572
				updateImpButtons();
572
		createImpTable(container);
573
			}
573
		createImpButtons(container);
574
		});
574
		// TODO: PlatformUI.getWorkbench().getHelpSystem().setHelp(container, IHelpContextIds.IMPLICIT_PLUGINS_PREFERENCE_PAGE);
575
		fElementViewer.getTable().addKeyListener(new KeyAdapter() {
575
		return container;
576
			public void keyPressed(KeyEvent e) {
576
	}
577
				if (e.character == SWT.DEL && e.stateMask == 0) {
577
578
					handleRemove();
578
	private void createImpLabel(Composite container) {
579
				}
579
		Label label = new Label(container, SWT.NONE);
580
			}
580
		label.setText(PDEUIMessages.TargetImplicitPluginsTab_desc);
581
		});
581
		GridData gd = new GridData(GridData.FILL_HORIZONTAL);
582
	}
582
		gd.horizontalSpan = 2;
583
583
		label.setLayoutData(gd);
584
	private void createImpButtons(Composite container) {
584
	}
585
		Composite buttonContainer = SWTFactory.createComposite(container, 1, 1, GridData.FILL_VERTICAL, 0, 0);
585
586
586
	private void createImpTable(Composite container) {
587
		fAddButton = new Button(buttonContainer, SWT.PUSH);
587
		fElementViewer = new TableViewer(container, SWT.MULTI | SWT.V_SCROLL | SWT.BORDER);
588
		fAddButton.setText(PDEUIMessages.SourceBlock_add);
588
		GridData gd = new GridData(GridData.FILL_BOTH);
589
		fAddButton.setLayoutData(new GridData(GridData.FILL | GridData.VERTICAL_ALIGN_BEGINNING));
589
		gd.heightHint = 250;
590
		SWTUtil.setButtonDimensionHint(fAddButton);
590
		fElementViewer.getControl().setLayoutData(gd);
591
		fAddButton.addSelectionListener(new SelectionAdapter() {
591
		fElementViewer.setContentProvider(new DefaultTableProvider() {
592
			public void widgetSelected(SelectionEvent e) {
592
			public Object[] getElements(Object inputElement) {
593
				handleAdd();
593
				ITargetDefinition target = getTargetDefinition();
594
			}
594
				if (target != null) {
595
		});
595
					BundleInfo[] bundles = target.getImplicitDependencies();
596
596
					if (bundles != null) {
597
		fRemoveButton = new Button(buttonContainer, SWT.PUSH);
597
						return bundles;
598
		fRemoveButton.setText(PDEUIMessages.SourceBlock_remove);
598
					}
599
		fRemoveButton.setLayoutData(new GridData(GridData.FILL | GridData.VERTICAL_ALIGN_BEGINNING));
599
				}
600
		SWTUtil.setButtonDimensionHint(fRemoveButton);
600
				return new BundleInfo[0];
601
		fRemoveButton.addSelectionListener(new SelectionAdapter() {
601
			}
602
			public void widgetSelected(SelectionEvent e) {
602
		});
603
				handleRemove();
603
		fElementViewer.setLabelProvider(new BundleInfoLabelProvider(false));
604
			}
604
		fElementViewer.setInput(PDEPlugin.getDefault());
605
		});
605
		fElementViewer.setComparator(new ViewerComparator() {
606
606
			public int compare(Viewer viewer, Object e1, Object e2) {
607
		fRemoveAllButton = new Button(buttonContainer, SWT.PUSH);
607
				BundleInfo bundle1 = (BundleInfo) e1;
608
		fRemoveAllButton.setText(PDEUIMessages.TargetImplicitPluginsTab_removeAll3);
608
				BundleInfo bundle2 = (BundleInfo) e2;
609
		fRemoveAllButton.setLayoutData(new GridData(GridData.FILL | GridData.VERTICAL_ALIGN_BEGINNING));
609
				return super.compare(viewer, bundle1.getSymbolicName(), bundle2.getSymbolicName());
610
		SWTUtil.setButtonDimensionHint(fRemoveAllButton);
610
			}
611
		fRemoveAllButton.addSelectionListener(new SelectionAdapter() {
611
		});
612
			public void widgetSelected(SelectionEvent e) {
612
		fElementViewer.addSelectionChangedListener(new ISelectionChangedListener() {
613
				handleRemoveAll();
613
			public void selectionChanged(SelectionChangedEvent event) {
614
			}
614
				updateImpButtons();
615
		});
615
			}
616
		updateImpButtons();
616
		});
617
	}
617
		fElementViewer.getTable().addKeyListener(new KeyAdapter() {
618
618
			public void keyPressed(KeyEvent e) {
619
	protected void handleAdd() {
619
				if (e.character == SWT.DEL && e.stateMask == 0) {
620
		ElementListSelectionDialog dialog = new ElementListSelectionDialog(PDEPlugin.getActiveWorkbenchShell(), new BundleInfoLabelProvider(false));
620
					handleRemove();
621
621
				}
622
		try {
622
			}
623
			dialog.setElements(getValidBundles());
623
		});
624
		} catch (CoreException e) {
624
	}
625
			dialog.setMessage(e.getMessage());
625
626
		}
626
	private void createImpButtons(Composite container) {
627
627
		Composite buttonContainer = SWTFactory.createComposite(container, 1, 1, GridData.FILL_VERTICAL, 0, 0);
628
		dialog.setTitle(PDEUIMessages.PluginSelectionDialog_title);
628
629
		dialog.setMessage(PDEUIMessages.PluginSelectionDialog_message);
629
		fAddButton = new Button(buttonContainer, SWT.PUSH);
630
		dialog.setMultipleSelection(true);
630
		fAddButton.setText(PDEUIMessages.SourceBlock_add);
631
		if (dialog.open() == Window.OK) {
631
		fAddButton.setLayoutData(new GridData(GridData.FILL | GridData.VERTICAL_ALIGN_BEGINNING));
632
632
		SWTUtil.setButtonDimensionHint(fAddButton);
633
			Object[] models = dialog.getResult();
633
		fAddButton.addSelectionListener(new SelectionAdapter() {
634
			ArrayList pluginsToAdd = new ArrayList();
634
			public void widgetSelected(SelectionEvent e) {
635
			for (int i = 0; i < models.length; i++) {
635
				handleAdd();
636
				BundleInfo desc = ((BundleInfo) models[i]);
636
			}
637
				pluginsToAdd.add(new BundleInfo(desc.getSymbolicName(), null, null, BundleInfo.NO_LEVEL, false));
637
		});
638
			}
638
639
			Set allDependencies = new HashSet();
639
		fRemoveButton = new Button(buttonContainer, SWT.PUSH);
640
			allDependencies.addAll(pluginsToAdd);
640
		fRemoveButton.setText(PDEUIMessages.SourceBlock_remove);
641
			BundleInfo[] currentBundles = getTargetDefinition().getImplicitDependencies();
641
		fRemoveButton.setLayoutData(new GridData(GridData.FILL | GridData.VERTICAL_ALIGN_BEGINNING));
642
			if (currentBundles != null) {
642
		SWTUtil.setButtonDimensionHint(fRemoveButton);
643
				allDependencies.addAll(Arrays.asList(currentBundles));
643
		fRemoveButton.addSelectionListener(new SelectionAdapter() {
644
			}
644
			public void widgetSelected(SelectionEvent e) {
645
			getTargetDefinition().setImplicitDependencies((BundleInfo[]) allDependencies.toArray(new BundleInfo[allDependencies.size()]));
645
				handleRemove();
646
			fElementViewer.refresh();
646
			}
647
		}
647
		});
648
	}
648
649
649
		fRemoveAllButton = new Button(buttonContainer, SWT.PUSH);
650
	/**
650
		fRemoveAllButton.setText(PDEUIMessages.TargetImplicitPluginsTab_removeAll3);
651
	 * Gets a list of all the bundles that can be added as implicit dependencies
651
		fRemoveAllButton.setLayoutData(new GridData(GridData.FILL | GridData.VERTICAL_ALIGN_BEGINNING));
652
	 * @return list of possible dependencies
652
		SWTUtil.setButtonDimensionHint(fRemoveAllButton);
653
	 */
653
		fRemoveAllButton.addSelectionListener(new SelectionAdapter() {
654
	protected BundleInfo[] getValidBundles() throws CoreException {
654
			public void widgetSelected(SelectionEvent e) {
655
		BundleInfo[] current = getTargetDefinition().getImplicitDependencies();
655
				handleRemoveAll();
656
		Set currentBundles = new HashSet();
656
			}
657
		if (current != null) {
657
		});
658
			for (int i = 0; i < current.length; i++) {
658
		updateImpButtons();
659
				currentBundles.add(current[i].getSymbolicName());
659
	}
660
			}
660
661
		}
661
	protected void handleAdd() {
662
662
		ElementListSelectionDialog dialog = new ElementListSelectionDialog(PDEPlugin.getActiveWorkbenchShell(), new BundleInfoLabelProvider(false));
663
		List targetBundles = new ArrayList();
663
664
		IResolvedBundle[] allTargetBundles = getTargetDefinition().getBundles();
664
		try {
665
		if (allTargetBundles == null || allTargetBundles.length == 0) {
665
			dialog.setElements(getValidBundles());
666
			throw new CoreException(new Status(IStatus.WARNING, PDEPlugin.getPluginId(), PDEUIMessages.ImplicitDependenciesSection_0));
666
		} catch (CoreException e) {
667
		}
667
			dialog.setMessage(e.getMessage());
668
		for (int i = 0; i < allTargetBundles.length; i++) {
668
		}
669
			if (!currentBundles.contains(allTargetBundles[i].getBundleInfo().getSymbolicName())) {
669
670
				targetBundles.add(allTargetBundles[i].getBundleInfo());
670
		dialog.setTitle(PDEUIMessages.PluginSelectionDialog_title);
671
			}
671
		dialog.setMessage(PDEUIMessages.PluginSelectionDialog_message);
672
		}
672
		dialog.setMultipleSelection(true);
673
673
		if (dialog.open() == Window.OK) {
674
		return (BundleInfo[]) targetBundles.toArray(new BundleInfo[targetBundles.size()]);
674
675
	}
675
			Object[] models = dialog.getResult();
676
676
			ArrayList pluginsToAdd = new ArrayList();
677
	private void handleRemove() {
677
			for (int i = 0; i < models.length; i++) {
678
		LinkedList bundles = new LinkedList();
678
				BundleInfo desc = ((BundleInfo) models[i]);
679
		bundles.addAll(Arrays.asList(getTargetDefinition().getImplicitDependencies()));
679
				pluginsToAdd.add(new BundleInfo(desc.getSymbolicName(), null, null, BundleInfo.NO_LEVEL, false));
680
		Object[] removeBundles = ((IStructuredSelection) fElementViewer.getSelection()).toArray();
680
			}
681
		if (removeBundles.length > 0) {
681
			Set allDependencies = new HashSet();
682
			for (int i = 0; i < removeBundles.length; i++) {
682
			allDependencies.addAll(pluginsToAdd);
683
				if (removeBundles[i] instanceof BundleInfo) {
683
			BundleInfo[] currentBundles = getTargetDefinition().getImplicitDependencies();
684
					bundles.remove(removeBundles[i]);
684
			if (currentBundles != null) {
685
				}
685
				allDependencies.addAll(Arrays.asList(currentBundles));
686
			}
686
			}
687
			getTargetDefinition().setImplicitDependencies((BundleInfo[]) bundles.toArray((new BundleInfo[bundles.size()])));
687
			getTargetDefinition().setImplicitDependencies((BundleInfo[]) allDependencies.toArray(new BundleInfo[allDependencies.size()]));
688
			fElementViewer.refresh();
688
			fElementViewer.refresh();
689
		}
689
		}
690
	}
690
	}
691
691
692
	private void handleRemoveAll() {
692
	/**
693
		getTargetDefinition().setImplicitDependencies(null);
693
	 * Gets a list of all the bundles that can be added as implicit dependencies
694
		fElementViewer.refresh();
694
	 * @return list of possible dependencies
695
	}
695
	 */
696
696
	protected BundleInfo[] getValidBundles() throws CoreException {
697
	private void updateImpButtons() {
697
		BundleInfo[] current = getTargetDefinition().getImplicitDependencies();
698
		boolean empty = fElementViewer.getSelection().isEmpty();
698
		Set currentBundles = new HashSet();
699
		fRemoveButton.setEnabled(!empty);
699
		if (current != null) {
700
		boolean hasElements = fElementViewer.getTable().getItemCount() > 0;
700
			for (int i = 0; i < current.length; i++) {
701
		fRemoveAllButton.setEnabled(hasElements);
701
				currentBundles.add(current[i].getSymbolicName());
702
	}
702
			}
703
703
		}
704
	/* (non-Javadoc)
704
705
	 * @see org.eclipse.jface.wizard.WizardPage#isPageComplete()
705
		List targetBundles = new ArrayList();
706
	 */
706
		IResolvedBundle[] allTargetBundles = getTargetDefinition().getBundles();
707
	public boolean isPageComplete() {
707
		if (allTargetBundles == null || allTargetBundles.length == 0) {
708
		if (fNameText.getText().trim().length() == 0)
708
			throw new CoreException(new Status(IStatus.WARNING, PDEPlugin.getPluginId(), PDEUIMessages.ImplicitDependenciesSection_0));
709
			return false;
709
		}
710
		return true;
710
		for (int i = 0; i < allTargetBundles.length; i++) {
711
	}
711
			if (!currentBundles.contains(allTargetBundles[i].getBundleInfo().getSymbolicName())) {
712
}
712
				targetBundles.add(allTargetBundles[i].getBundleInfo());
713
			}
714
		}
715
716
		return (BundleInfo[]) targetBundles.toArray(new BundleInfo[targetBundles.size()]);
717
	}
718
719
	private void handleRemove() {
720
		LinkedList bundles = new LinkedList();
721
		bundles.addAll(Arrays.asList(getTargetDefinition().getImplicitDependencies()));
722
		Object[] removeBundles = ((IStructuredSelection) fElementViewer.getSelection()).toArray();
723
		if (removeBundles.length > 0) {
724
			for (int i = 0; i < removeBundles.length; i++) {
725
				if (removeBundles[i] instanceof BundleInfo) {
726
					bundles.remove(removeBundles[i]);
727
				}
728
			}
729
			getTargetDefinition().setImplicitDependencies((BundleInfo[]) bundles.toArray((new BundleInfo[bundles.size()])));
730
			fElementViewer.refresh();
731
		}
732
	}
733
734
	private void handleRemoveAll() {
735
		getTargetDefinition().setImplicitDependencies(null);
736
		fElementViewer.refresh();
737
	}
738
739
	private void updateImpButtons() {
740
		boolean empty = fElementViewer.getSelection().isEmpty();
741
		fRemoveButton.setEnabled(!empty);
742
		boolean hasElements = fElementViewer.getTable().getItemCount() > 0;
743
		fRemoveAllButton.setEnabled(hasElements);
744
	}
745
746
	/* (non-Javadoc)
747
	 * @see org.eclipse.jface.wizard.WizardPage#isPageComplete()
748
	 */
749
	public boolean isPageComplete() {
750
		if (fNameText.getText().trim().length() == 0)
751
			return false;
752
		return true;
753
	}
754
}
(-)plugin.xml (+12 lines)
Lines 69-74 Link Here
69
               id="org.eclipse.pde.ui.TargetPlatformPreferencePage">
69
               id="org.eclipse.pde.ui.TargetPlatformPreferencePage">
70
         </keywordReference>
70
         </keywordReference>
71
      </page>
71
      </page>
72
      <page
73
            category="org.eclipse.pde.ui.MainPreferencePage"
74
            class="org.eclipse.pde.internal.ui.preferences.TargetPlatformPreferencePage"
75
            id="org.eclipse.pde.ui.TargetPlatformPreferencePage"
76
            name="Target 2">
77
         <keywordReference
78
               id="org.eclipse.pde.ui.pde">
79
         </keywordReference>
80
         <keywordReference
81
               id="org.eclipse.pde.ui.TargetPlatformPreferencePage">
82
         </keywordReference>
83
      </page>
72
   </extension>
84
   </extension>
73
   <extension
85
   <extension
74
   		point="org.eclipse.ui.keywords">
86
   		point="org.eclipse.ui.keywords">
(-)src/org/eclipse/pde/internal/ui/shared/target/ITargetChangedListener.java (+35 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2009 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.pde.internal.ui.shared.target;
12
13
import org.eclipse.pde.internal.core.target.provisional.ITargetDefinition;
14
import org.eclipse.pde.internal.ui.wizards.target.TargetDefinitionContentPage;
15
16
/**
17
 * Listener for UI components that modify the contents of target definitions.
18
 * Whenever the contents of the target changes the listener will be called so
19
 * the target can be resolved and the UI updated.
20
 * 
21
 * @see TargetLocationsGroup
22
 * @see TargetContentsGroup
23
 * @see TargetDefinitionContentPage
24
 */
25
public interface ITargetChangedListener {
26
27
	/**
28
	 * Informs the listener that the contents of the target have changed
29
	 * and UI elements may need to be refreshed.
30
	 * @param definition target definition whose contents have changed or <code>null</code> if the definition is not available
31
	 * @param resolve whether the definition must be resolved to catch up to all changes
32
	 */
33
	public void contentsChanged(ITargetDefinition definition, boolean resolve);
34
35
}
(-)src/org/eclipse/pde/internal/ui/shared/target/AddP2ContainerPage.java (+175 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2009 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.pde.internal.ui.shared.target;
12
13
import java.net.URI;
14
import org.eclipse.core.runtime.IStatus;
15
import org.eclipse.core.runtime.Status;
16
import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit;
17
import org.eclipse.equinox.internal.provisional.p2.ui.actions.PropertyDialogAction;
18
import org.eclipse.equinox.internal.provisional.p2.ui.dialogs.*;
19
import org.eclipse.equinox.internal.provisional.p2.ui.policy.IUViewQueryContext;
20
import org.eclipse.equinox.internal.provisional.p2.ui.policy.Policy;
21
import org.eclipse.jface.action.IAction;
22
import org.eclipse.jface.viewers.CheckStateChangedEvent;
23
import org.eclipse.jface.viewers.ICheckStateListener;
24
import org.eclipse.jface.window.SameShellProvider;
25
import org.eclipse.jface.wizard.WizardPage;
26
import org.eclipse.pde.internal.core.target.impl.P2BundleContainer;
27
import org.eclipse.pde.internal.core.target.provisional.IBundleContainer;
28
import org.eclipse.pde.internal.ui.*;
29
import org.eclipse.pde.internal.ui.wizards.provisioner.p2.ProvisionerMessages;
30
import org.eclipse.swt.SWT;
31
import org.eclipse.swt.events.SelectionAdapter;
32
import org.eclipse.swt.events.SelectionEvent;
33
import org.eclipse.swt.layout.GridData;
34
import org.eclipse.swt.widgets.*;
35
import org.eclipse.ui.PlatformUI;
36
37
/**
38
 * Wizard page allowing users to select which IUs they would like to download
39
 * 
40
 * @since 3.5
41
 */
42
public class AddP2ContainerPage extends WizardPage {
43
44
	static final IStatus BAD_IU_SELECTION = new Status(IStatus.ERROR, PDEPlugin.getPluginId(), ProvisionerMessages.P2TargetProvisionerWizardPage_1);
45
	IStatus fSelectedIUStatus = BAD_IU_SELECTION;
46
47
	P2BundleContainer fContainer;
48
	IUViewQueryContext fQueryContext;
49
50
	RepositorySelectionGroup fRepoSelector;
51
	AvailableIUGroup fAvailableIUGroup;
52
53
	Button fPropertiesButton;
54
	private IAction fPropertyAction;
55
56
	protected AddP2ContainerPage() {
57
		super("AddP2Container"); //$NON-NLS-1$
58
		// TODO Use the target service to create?
59
		fContainer = new P2BundleContainer();
60
	}
61
62
	/* (non-Javadoc)
63
	 * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
64
	 */
65
	public void createControl(Composite parent) {
66
		setMessage("Select content from a repository to be downloaded and added to your target");
67
		setTitle("Add Repository or Update Site");
68
		Composite composite = SWTFactory.createComposite(parent, 1, 1, GridData.FILL_BOTH, 0, 0);
69
70
		createQueryContext();
71
		createRepositoryComboArea(composite);
72
		createAvailableIUArea(composite);
73
		createDetailsArea(composite);
74
		createCheckboxArea(composite);
75
76
		setPageComplete(false);
77
		restoreWidgetState();
78
		setControl(composite);
79
		PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, IHelpContextIds.P2_PROVISIONING_PAGE);
80
	}
81
82
	private void createCheckboxArea(Composite parent) {
83
		// Categories, provisioning context/store sites/
84
		Composite checkComp = SWTFactory.createComposite(parent, 2, 1, GridData.FILL_HORIZONTAL, 0, 0);
85
		// TODO Update labels with mnemonics
86
		SWTFactory.createCheckButton(checkComp, "Group by Category", null, true, 1);
87
		SWTFactory.createCheckButton(checkComp, "Show only the latest version", null, true, 1);
88
		SWTFactory.createCheckButton(checkComp, "Download all dependencies", null, true, 1);
89
		SWTFactory.createCheckButton(checkComp, "Include the repo location in the target", null, true, 1);
90
91
	}
92
93
	private void createQueryContext() {
94
		fQueryContext = Policy.getDefault().getQueryContext();
95
	}
96
97
	private void createRepositoryComboArea(Composite parent) {
98
		RepositorySelectionGroup repoSelector = new RepositorySelectionGroup(getContainer(), parent, Policy.getDefault(), fQueryContext);
99
		repoSelector.addRepositorySelectionListener(new IRepositorySelectionListener() {
100
			public void repositorySelectionChanged(int repoChoice, URI repoLocation) {
101
				fAvailableIUGroup.setRepositoryFilter(repoChoice, repoLocation);
102
			}
103
		});
104
	}
105
106
	/**
107
	 * Create the UI area where the user will be able to select which IUs they
108
	 * would like to download.  There will also be buttons to see properties for
109
	 * the selection and open the manage sites dialog.
110
	 * 
111
	 * @param parent parent composite
112
	 */
113
	private void createAvailableIUArea(Composite parent) {
114
		fAvailableIUGroup = new AvailableIUGroup(parent);
115
		fAvailableIUGroup.getCheckboxTreeViewer().addCheckStateListener(new ICheckStateListener() {
116
			public void checkStateChanged(CheckStateChangedEvent event) {
117
				IInstallableUnit[] units = fAvailableIUGroup.getCheckedLeafIUs();
118
				fPropertiesButton.setEnabled(units.length > 0);
119
				if (units.length > 0) {
120
					fSelectedIUStatus = Status.OK_STATUS;
121
					fContainer.setRequiredUnits(units);
122
				} else {
123
					fSelectedIUStatus = BAD_IU_SELECTION;
124
					fContainer.setRequiredUnits(null);
125
				}
126
				pageChanged();
127
			}
128
		});
129
		fAvailableIUGroup.setUseBoldFontForFilteredItems(true);
130
		GridData data = (GridData) fAvailableIUGroup.getStructuredViewer().getControl().getLayoutData();
131
		data.heightHint = 200;
132
	}
133
134
	private void createDetailsArea(Composite parent) {
135
		Group detailsGroup = SWTFactory.createGroup(parent, "Details", 1, 1, GridData.FILL_HORIZONTAL);
136
137
		fPropertiesButton = new Button(detailsGroup, SWT.PUSH);
138
		fPropertiesButton.setText(ProvisionerMessages.P2TargetProvisionerWizardPage_10);
139
		fPropertiesButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
140
		fPropertiesButton.addSelectionListener(new SelectionAdapter() {
141
			public void widgetSelected(SelectionEvent event) {
142
				fPropertyAction.run();
143
			}
144
		});
145
		fPropertyAction = new PropertyDialogAction(new SameShellProvider(getShell()), fAvailableIUGroup.getStructuredViewer());
146
	}
147
148
	/**
149
	 * Checks if the page is complete, updating messages and finish button.
150
	 */
151
	void pageChanged() {
152
		if (fSelectedIUStatus.getSeverity() == IStatus.ERROR) {
153
			setErrorMessage(fSelectedIUStatus.getMessage());
154
			setPageComplete(false);
155
		} else {
156
			setErrorMessage(null);
157
			setPageComplete(true);
158
		}
159
	}
160
161
	/**
162
	 * Restores the state of the wizard from previous invocations
163
	 */
164
	private void restoreWidgetState() {
165
		// TODO Init check boxes
166
	}
167
168
	/**
169
	 * @return bundle container created by this wizard or <code>null</code>
170
	 */
171
	public IBundleContainer getBundleContainer() {
172
		return fContainer;
173
	}
174
175
}
(-)src/org/eclipse/pde/internal/ui/editor/targetdefinition/ContentPage.java (+83 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2009 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.pde.internal.ui.editor.targetdefinition;
12
13
import org.eclipse.pde.internal.core.target.provisional.ITargetDefinition;
14
import org.eclipse.pde.internal.ui.PDEPlugin;
15
import org.eclipse.pde.internal.ui.PDEPluginImages;
16
import org.eclipse.pde.internal.ui.editor.FormLayoutFactory;
17
import org.eclipse.swt.widgets.Composite;
18
import org.eclipse.ui.forms.IManagedForm;
19
import org.eclipse.ui.forms.editor.FormPage;
20
import org.eclipse.ui.forms.widgets.FormToolkit;
21
import org.eclipse.ui.forms.widgets.ScrolledForm;
22
23
/**
24
 * First page in the target definition editor.  Allows for editing of the name,
25
 * description and content of the target.
26
 * @see TargetEditor
27
 * @see InformationSection
28
 * @see LocationSection
29
 */
30
public class ContentPage extends FormPage {
31
32
	public static final String PAGE_ID = "content"; //$NON-NLS-1$
33
34
	public ContentPage(TargetEditor editor) {
35
		super(editor, PAGE_ID, "Content");
36
	}
37
38
	/**
39
	 * @return The target model backing this editor
40
	 */
41
	public ITargetDefinition getTarget() {
42
		return ((TargetEditor) getEditor()).getTarget();
43
	}
44
45
	/* (non-Javadoc)
46
	 * @see org.eclipse.pde.internal.ui.editor.PDEFormPage#createFormContent(org.eclipse.ui.forms.IManagedForm)
47
	 */
48
	protected void createFormContent(IManagedForm managedForm) {
49
		super.createFormContent(managedForm);
50
		ScrolledForm form = managedForm.getForm();
51
		FormToolkit toolkit = managedForm.getToolkit();
52
		form.setText("Target Content");
53
		PDEPlugin.getDefault().getLabelProvider().connect(this);
54
		form.setImage(PDEPlugin.getDefault().getLabelProvider().get(PDEPluginImages.DESC_TARGET_DEFINITION));
55
		toolkit.decorateFormHeading(form.getForm());
56
		fillBody(managedForm, toolkit);
57
		// TODO Finish help
58
		((TargetEditor) getEditor()).contributeToToolbar(managedForm.getForm(), ""); //$NON-NLS-1$
59
		((TargetEditor) getEditor()).addForm(managedForm);
60
		form.updateToolBar();
61
//		PlatformUI.getWorkbench().getHelpSystem().setHelp(form.getBody(), IHelpContextIds.TARGET_OVERVIEW_PAGE);
62
	}
63
64
	/* (non-Javadoc)
65
	 * @see org.eclipse.ui.forms.editor.FormPage#dispose()
66
	 */
67
	public void dispose() {
68
		PDEPlugin.getDefault().getLabelProvider().disconnect(this);
69
		super.dispose();
70
	}
71
72
	private void fillBody(IManagedForm managedForm, FormToolkit toolkit) {
73
		Composite body = managedForm.getForm().getBody();
74
		body.setLayout(FormLayoutFactory.createFormGridLayout(true, 1));
75
		managedForm.addPart(new ContentSection(this, body));
76
	}
77
78
	// TODO Hook up help toolbar action
79
//	protected String getHelpResource() {
80
//		return "/org.eclipse.pde.doc.user/guide/tools/editors/target_definition_editor/overview.htm"; //$NON-NLS-1$
81
//	}
82
83
}
(-)src/org/eclipse/pde/internal/ui/editor/targetdefinition/LocationSection.java (+86 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2005, 2009 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.pde.internal.ui.editor.targetdefinition;
12
13
import org.eclipse.pde.internal.core.target.provisional.ITargetDefinition;
14
import org.eclipse.pde.internal.ui.PDEUIMessages;
15
import org.eclipse.pde.internal.ui.editor.FormLayoutFactory;
16
import org.eclipse.pde.internal.ui.shared.target.ITargetChangedListener;
17
import org.eclipse.pde.internal.ui.shared.target.TargetLocationsGroup;
18
import org.eclipse.swt.layout.GridData;
19
import org.eclipse.swt.widgets.Composite;
20
import org.eclipse.ui.forms.SectionPart;
21
import org.eclipse.ui.forms.editor.FormPage;
22
import org.eclipse.ui.forms.widgets.*;
23
24
/**
25
 * Section for editing the content of the target (bundle containers) in the target definition editor
26
 * @see DefinitionPage
27
 * @see TargetEditor
28
 */
29
public class LocationSection extends SectionPart {
30
31
	private TargetLocationsGroup fContainerGroup;
32
	private TargetEditor fEditor;
33
34
	public LocationSection(FormPage page, Composite parent) {
35
		super(parent, page.getManagedForm().getToolkit(), Section.DESCRIPTION | ExpandableComposite.TITLE_BAR);
36
		fEditor = (TargetEditor) page.getEditor();
37
		createClient(getSection(), page.getEditor().getToolkit());
38
	}
39
40
	/**
41
	 * @return The target model backing this editor
42
	 */
43
	private ITargetDefinition getTarget() {
44
		return fEditor.getTarget();
45
	}
46
47
	/**
48
	 * Creates the UI for this section.
49
	 * 
50
	 * @param section section the UI is being added to
51
	 * @param toolkit form toolkit used to create the widgets
52
	 */
53
	protected void createClient(Section section, FormToolkit toolkit) {
54
		section.setLayout(FormLayoutFactory.createClearTableWrapLayout(false, 1));
55
		GridData sectionData = new GridData(GridData.FILL_BOTH | GridData.GRAB_VERTICAL);
56
		sectionData.horizontalSpan = 2;
57
		section.setLayoutData(sectionData);
58
		section.setText("Locations");
59
60
		section.setDescription(PDEUIMessages.ContentSection_1);
61
		Composite client = toolkit.createComposite(section);
62
		client.setLayout(FormLayoutFactory.createSectionClientGridLayout(false, 1));
63
		client.setLayoutData(new GridData(GridData.FILL_BOTH | GridData.GRAB_VERTICAL));
64
65
		fContainerGroup = TargetLocationsGroup.createInForm(client, toolkit);
66
		fEditor.getTargetChangedListener().setLocationTree(fContainerGroup);
67
		fContainerGroup.addTargetChangedListener(fEditor.getTargetChangedListener());
68
		fContainerGroup.addTargetChangedListener(new ITargetChangedListener() {
69
			public void contentsChanged(ITargetDefinition definition, boolean resolve) {
70
				markDirty();
71
			}
72
		});
73
74
		toolkit.paintBordersFor(client);
75
		section.setClient(client);
76
	}
77
78
	/* (non-Javadoc)
79
	 * @see org.eclipse.ui.forms.AbstractFormPart#refresh()
80
	 */
81
	public void refresh() {
82
		fContainerGroup.setInput(getTarget());
83
		super.refresh();
84
	}
85
86
}
(-)src/org/eclipse/pde/internal/ui/shared/target/PreviewContainerPage.java (+95 lines)
Added Link Here
1
package org.eclipse.pde.internal.ui.shared.target;
2
3
import java.lang.reflect.InvocationTargetException;
4
import org.eclipse.core.runtime.IProgressMonitor;
5
import org.eclipse.core.runtime.IStatus;
6
import org.eclipse.jface.operation.IRunnableWithProgress;
7
import org.eclipse.jface.viewers.ArrayContentProvider;
8
import org.eclipse.jface.viewers.TableViewer;
9
import org.eclipse.jface.wizard.WizardPage;
10
import org.eclipse.pde.internal.core.target.provisional.IBundleContainer;
11
import org.eclipse.pde.internal.core.target.provisional.ITargetDefinition;
12
import org.eclipse.pde.internal.ui.PDEPlugin;
13
import org.eclipse.pde.internal.ui.SWTFactory;
14
import org.eclipse.swt.layout.GridData;
15
import org.eclipse.swt.widgets.Composite;
16
17
public class PreviewContainerPage extends WizardPage {
18
19
	private ITargetDefinition fTarget;
20
	private EditDirectoryContainerPage fPage1;
21
	protected TableViewer fPreviewTable;
22
	protected Object fInput;
23
24
	protected PreviewContainerPage(ITargetDefinition definition, EditDirectoryContainerPage page1) {
25
		super("ContainerPreviewPage");
26
		setTitle("Preview Contents");
27
		setMessage("The plug-ins found in the container are visible below");
28
		fTarget = definition;
29
		fPage1 = page1;
30
	}
31
32
	/* (non-Javadoc)
33
	 * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
34
	 */
35
	public void createControl(Composite parent) {
36
		Composite composite = SWTFactory.createComposite(parent, 1, 1, GridData.FILL_BOTH);
37
		SWTFactory.createLabel(composite, "Plug-ins:", 1);
38
		fPreviewTable = new TableViewer(composite);
39
		fPreviewTable.setLabelProvider(new BundleInfoLabelProvider(true));
40
		fPreviewTable.setContentProvider(ArrayContentProvider.getInstance());
41
		fPreviewTable.getControl().setLayoutData(new GridData(GridData.FILL_BOTH));
42
		setControl(composite);
43
	}
44
45
	/**
46
	 * Refreshes the contents of the preview table, possible resolving the container
47
	 * @param resolve whether the current container should be resolved if it hasn't been already
48
	 */
49
	protected void setInput(final IBundleContainer container) {
50
		if (container == null) {
51
			fInput = null;
52
			fPreviewTable.setInput(null);
53
			return;
54
		}
55
56
		if (container.isResolved()) {
57
			fInput = container.getAllBundles();
58
			fPreviewTable.setInput(fInput);
59
			return;
60
		}
61
62
		try {
63
			getContainer().run(true, true, new IRunnableWithProgress() {
64
				public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
65
					IStatus result = container.resolve(fTarget, monitor);
66
					if (monitor.isCanceled()) {
67
						fInput = null;
68
					} else if (!result.isOK() && !result.isMultiStatus()) {
69
						fInput = new Object[] {result};
70
					} else {
71
						fInput = container.getAllBundles();
72
					}
73
74
				}
75
			});
76
			fPreviewTable.setInput(fInput);
77
		} catch (InvocationTargetException e) {
78
			PDEPlugin.log(e);
79
			setErrorMessage(e.getMessage());
80
		} catch (InterruptedException e) {
81
		}
82
83
	}
84
85
	/* (non-Javadoc)
86
	 * @see org.eclipse.jface.dialogs.DialogPage#setVisible(boolean)
87
	 */
88
	public void setVisible(boolean visible) {
89
		super.setVisible(visible);
90
		if (visible) {
91
			setInput(fPage1.getBundleContainer());
92
		}
93
	}
94
95
}
(-)src/org/eclipse/pde/internal/ui/shared/target/TargetContentsGroup.java (+798 lines)
Added Link Here
1
package org.eclipse.pde.internal.ui.shared.target;
2
3
import com.ibm.icu.text.MessageFormat;
4
import java.net.URI;
5
import java.util.*;
6
import java.util.List;
7
import org.eclipse.core.runtime.*;
8
import org.eclipse.core.runtime.jobs.*;
9
import org.eclipse.jface.viewers.*;
10
import org.eclipse.pde.internal.core.target.provisional.*;
11
import org.eclipse.pde.internal.ui.SWTFactory;
12
import org.eclipse.swt.SWT;
13
import org.eclipse.swt.events.SelectionAdapter;
14
import org.eclipse.swt.events.SelectionEvent;
15
import org.eclipse.swt.layout.GridData;
16
import org.eclipse.swt.widgets.*;
17
import org.eclipse.ui.dialogs.FilteredTree;
18
import org.eclipse.ui.dialogs.PatternFilter;
19
import org.eclipse.ui.forms.widgets.FormToolkit;
20
import org.eclipse.ui.progress.UIJob;
21
22
public class TargetContentsGroup extends FilteredTree {
23
24
	private CheckboxTreeViewer fTree;
25
	private Button fSelectButton;
26
	private Button fDeselectButton;
27
	private Button fSelectAllButton;
28
	private Button fDeselectAllButton;
29
//	private Button fSelectRequiredButton;
30
	private Label fShowLabel;
31
	private Button fShowSourceButton;
32
	private Button fShowPluginsButton;
33
	private Label fCountLabel;
34
	private Label fGroupLabel;
35
	private Combo fGroupCombo;
36
37
	private ViewerFilter fSourceFilter;
38
	private ViewerFilter fPluginFilter;
39
40
	private List fAllBundles;
41
	private Set fAllChecked;
42
	private Map fContainerBundles;
43
	private Map fContainerChecked;
44
	private Map fFileBundles;
45
	private Map fFileChecked;
46
47
	private ITargetDefinition fTargetDefinition;
48
49
	private int fGrouping;
50
	private static final int GROUP_BY_NONE = 0;
51
	private static final int GROUP_BY_FILE_LOC = 1;
52
	private static final int GROUP_BY_CONTAINER = 2;
53
	private ListenerList fChangeListeners = new ListenerList();
54
55
	public static TargetContentsGroup createInForm(Composite parent, FormToolkit toolkit) {
56
		// TODO Should we be using the tooklit to create the controls?
57
		TargetContentsGroup control = new TargetContentsGroup(parent);
58
		return control;
59
	}
60
61
	public static TargetContentsGroup createInDialog(Composite parent) {
62
		TargetContentsGroup control = new TargetContentsGroup(parent);
63
		return control;
64
	}
65
66
	private TargetContentsGroup(Composite parent) {
67
		super(parent, SWT.BORDER | SWT.MULTI, new PatternFilter(), true);
68
	}
69
70
	/**
71
	 * Adds a listener to the set of listeners that will be notified when the bundle containers
72
	 * are modified.  This method has no effect if the listener has already been added. 
73
	 * 
74
	 * @param listener target changed listener to add
75
	 */
76
	public void addTargetChangedListener(ITargetChangedListener listener) {
77
		fChangeListeners.add(listener);
78
	}
79
80
	/**
81
	 * Informs the target content listeners that check state has changed
82
	 */
83
	public void contentChanged() {
84
		// TODO Save the included bundles
85
		Object[] listeners = fChangeListeners.getListeners();
86
		for (int i = 0; i < listeners.length; i++) {
87
			((ITargetChangedListener) listeners[i]).contentsChanged(fTargetDefinition, false);
88
		}
89
	}
90
91
	/* (non-Javadoc)
92
	 * @see org.eclipse.ui.dialogs.FilteredTree#createTreeControl(org.eclipse.swt.widgets.Composite, int)
93
	 */
94
	protected Control createTreeControl(Composite parent, int style) {
95
		fGrouping = GROUP_BY_NONE;
96
		Composite treeComp = SWTFactory.createComposite(parent, 2, 1, GridData.FILL_BOTH, 0, 0);
97
		super.createTreeControl(treeComp, style);
98
		((GridData) fTree.getControl().getLayoutData()).heightHint = 300;
99
		createButtons(treeComp);
100
		createOptions(treeComp);
101
102
		updateButtons();
103
		initializeFilters();
104
		return treeComp;
105
	}
106
107
	/* (non-Javadoc)
108
	 * @see org.eclipse.ui.dialogs.FilteredTree#doCreateTreeViewer(org.eclipse.swt.widgets.Composite, int)
109
	 */
110
	protected TreeViewer doCreateTreeViewer(Composite parent, int style) {
111
		fTree = new CheckboxTreeViewer(parent, style) {
112
			public void refresh(boolean updateLabels) {
113
				super.refresh(updateLabels);
114
				if (updateLabels) {
115
					// We want to update the labels and buttons as users change the filtering
116
					updateButtons();
117
				}
118
			}
119
		};
120
		fTree.setContentProvider(new TreeContentProvider());
121
		fTree.setLabelProvider(new BundleContainerLabelProvider());
122
		fTree.addDoubleClickListener(new IDoubleClickListener() {
123
			public void doubleClick(DoubleClickEvent event) {
124
				IStructuredSelection selection = (IStructuredSelection) event.getSelection();
125
				Object first = selection.getFirstElement();
126
				handleCheck(new Object[] {selection.getFirstElement()}, !fTree.getChecked(first));
127
			}
128
		});
129
		fTree.addCheckStateListener(new ICheckStateListener() {
130
			public void checkStateChanged(CheckStateChangedEvent event) {
131
				handleCheck(new Object[] {event.getElement()}, fTree.getChecked(event.getElement()));
132
			}
133
		});
134
		fTree.addSelectionChangedListener(new ISelectionChangedListener() {
135
			public void selectionChanged(SelectionChangedEvent event) {
136
				updateButtons();
137
			}
138
		});
139
		fTree.setSorter(new ViewerSorter() {
140
			public int compare(Viewer viewer, Object e1, Object e2) {
141
				if (e1 instanceof IResolvedBundle && e2 instanceof IResolvedBundle) {
142
					IStatus status1 = ((IResolvedBundle) e1).getStatus();
143
					IStatus status2 = ((IResolvedBundle) e2).getStatus();
144
					if (!status1.isOK() && status2.isOK()) {
145
						return -1;
146
					}
147
					if (status1.isOK() && !status2.isOK()) {
148
						return 1;
149
					}
150
				}
151
				return super.compare(viewer, e1, e2);
152
			}
153
154
		});
155
		return fTree;
156
	}
157
158
	private void createButtons(Composite parent) {
159
		Composite buttonComp = SWTFactory.createComposite(parent, 1, 1, GridData.FILL_VERTICAL, 0, 0);
160
161
		fSelectButton = SWTFactory.createPushButton(buttonComp, Messages.IncludedBundlesTree_0, null);
162
		fSelectButton.addSelectionListener(new SelectionAdapter() {
163
			public void widgetSelected(SelectionEvent e) {
164
				if (!fTree.getSelection().isEmpty()) {
165
					Object[] selected = ((IStructuredSelection) fTree.getSelection()).toArray();
166
					handleCheck(selected, true);
167
				}
168
			}
169
		});
170
		fDeselectButton = SWTFactory.createPushButton(buttonComp, Messages.IncludedBundlesTree_1, null);
171
		fDeselectButton.addSelectionListener(new SelectionAdapter() {
172
			public void widgetSelected(SelectionEvent e) {
173
				if (!fTree.getSelection().isEmpty()) {
174
					Object[] selected = ((IStructuredSelection) fTree.getSelection()).toArray();
175
					handleCheck(selected, false);
176
				}
177
			}
178
		});
179
180
		createEmptySpace(buttonComp);
181
182
		fSelectAllButton = SWTFactory.createPushButton(buttonComp, Messages.IncludedBundlesTree_2, null);
183
		fSelectAllButton.addSelectionListener(new SelectionAdapter() {
184
			public void widgetSelected(SelectionEvent e) {
185
				Object[] elements = ((ITreeContentProvider) fTree.getContentProvider()).getElements(fTree.getInput());
186
				fTree.setGrayedElements(new Object[0]);
187
				fTree.expandAll();
188
				for (int i = 0; i < elements.length; i++) {
189
					fTree.setSubtreeChecked(elements[i], true);
190
				}
191
				fAllChecked.addAll(fAllBundles);
192
				for (Iterator iterator = fContainerChecked.keySet().iterator(); iterator.hasNext();) {
193
					Object key = iterator.next();
194
					((Set) fContainerChecked.get(key)).addAll((Collection) fContainerBundles.get(key));
195
				}
196
				for (Iterator iterator = fFileChecked.keySet().iterator(); iterator.hasNext();) {
197
					Object key = iterator.next();
198
					((Set) fFileChecked.get(key)).addAll((Collection) fFileBundles.get(key));
199
				}
200
				contentChanged();
201
				updateButtons();
202
			}
203
		});
204
		fDeselectAllButton = SWTFactory.createPushButton(buttonComp, Messages.IncludedBundlesTree_3, null);
205
		fDeselectAllButton.addSelectionListener(new SelectionAdapter() {
206
			public void widgetSelected(SelectionEvent e) {
207
				Object[] elements = ((ITreeContentProvider) fTree.getContentProvider()).getElements(fTree.getInput());
208
				fTree.setGrayedElements(new Object[0]);
209
				fTree.expandAll();
210
				for (int i = 0; i < elements.length; i++) {
211
					fTree.setSubtreeChecked(elements[i], false);
212
				}
213
				fAllChecked.clear();
214
				for (Iterator iterator = fContainerChecked.values().iterator(); iterator.hasNext();) {
215
					((Set) iterator.next()).clear();
216
				}
217
				for (Iterator iterator = fFileChecked.values().iterator(); iterator.hasNext();) {
218
					((Set) iterator.next()).clear();
219
				}
220
				contentChanged();
221
				updateButtons();
222
			}
223
		});
224
225
		createEmptySpace(buttonComp);
226
227
		// TODO Support selecting required.
228
//		fSelectRequiredButton = SWTFactory.createPushButton(buttonComp, Messages.IncludedBundlesTree_4, null);
229
//		fSelectRequiredButton.addSelectionListener(new SelectionAdapter() {
230
//			public void widgetSelected(SelectionEvent e) {
231
//				updateButtons();
232
//			}
233
//		});
234
235
		Composite filterComp = SWTFactory.createComposite(buttonComp, 1, 1, SWT.NONE, 0, 0);
236
		filterComp.setLayoutData(new GridData(SWT.LEFT, SWT.BOTTOM, true, true));
237
238
		fShowLabel = SWTFactory.createLabel(filterComp, Messages.BundleContainerTable_9, 1);
239
240
		fShowPluginsButton = SWTFactory.createCheckButton(filterComp, Messages.BundleContainerTable_14, null, true, 1);
241
		fShowPluginsButton.addSelectionListener(new SelectionAdapter() {
242
			public void widgetSelected(SelectionEvent e) {
243
				if (!fShowPluginsButton.getSelection()) {
244
					fTree.addFilter(fPluginFilter);
245
				} else {
246
					fTree.removeFilter(fPluginFilter);
247
				}
248
				updateButtons();
249
			}
250
		});
251
		fShowPluginsButton.setSelection(true);
252
		GridData gd = new GridData();
253
		gd.horizontalIndent = 10;
254
		fShowPluginsButton.setLayoutData(gd);
255
256
		fShowSourceButton = SWTFactory.createCheckButton(filterComp, Messages.BundleContainerTable_15, null, true, 1);
257
		fShowSourceButton.addSelectionListener(new SelectionAdapter() {
258
			public void widgetSelected(SelectionEvent e) {
259
				if (!fShowSourceButton.getSelection()) {
260
					fTree.addFilter(fSourceFilter);
261
				} else {
262
					fTree.removeFilter(fSourceFilter);
263
				}
264
				updateButtons();
265
			}
266
		});
267
		fShowSourceButton.setSelection(true);
268
		gd = new GridData();
269
		gd.horizontalIndent = 10;
270
		fShowSourceButton.setLayoutData(gd);
271
	}
272
273
	private void createOptions(Composite parent) {
274
		Composite comp = SWTFactory.createComposite(parent, 2, 2, GridData.FILL_HORIZONTAL, 0, 0);
275
276
		fGroupLabel = SWTFactory.createLabel(comp, "Group by:", 1);
277
		fGroupCombo = SWTFactory.createCombo(comp, SWT.READ_ONLY, 1, new String[] {"None", "File Path", "Plug-in Container"});
278
		fGroupCombo.addSelectionListener(new SelectionAdapter() {
279
			public void widgetSelected(SelectionEvent e) {
280
				handleGroupChange();
281
			}
282
		});
283
284
		fCountLabel = SWTFactory.createLabel(comp, "", 2); //$NON-NLS-1$
285
	}
286
287
	private void initializeFilters() {
288
		fSourceFilter = new ViewerFilter() {
289
			public boolean select(Viewer viewer, Object parentElement, Object element) {
290
				if (element instanceof IResolvedBundle) {
291
					if (((IResolvedBundle) element).isSourceBundle()) {
292
						return false;
293
					}
294
				}
295
				return true;
296
			}
297
		};
298
		fPluginFilter = new ViewerFilter() {
299
			public boolean select(Viewer viewer, Object parentElement, Object element) {
300
				if (element instanceof IResolvedBundle) {
301
					if (!((IResolvedBundle) element).isSourceBundle()) {
302
						return false;
303
					}
304
				}
305
				return true;
306
			}
307
		};
308
	}
309
310
	private Label createEmptySpace(Composite parent) {
311
		Label label = new Label(parent, SWT.NONE);
312
		GridData gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
313
		gd.widthHint = gd.heightHint = 5;
314
		label.setLayoutData(gd);
315
		return label;
316
	}
317
318
	private IPath getParentPath(IResolvedBundle bundle) {
319
		URI location = bundle.getBundleInfo().getLocation();
320
		if (location == null) {
321
			return new Path("Unknown");
322
		}
323
		IPath path = new Path(URIUtil.toUnencodedString(location));
324
		path = path.removeLastSegments(1);
325
		return path;
326
	}
327
328
	private void handleCheck(Object[] changedElements, boolean checkState) {
329
		if (changedElements.length > 0) {
330
			if (changedElements[0] instanceof IResolvedBundle) {
331
				Set parentsToUpdate = new HashSet();
332
				for (int i = 0; i < changedElements.length; i++) {
333
					Object parent = ((IResolvedBundle) changedElements[i]).getParentContainer();
334
					if (fGrouping == GROUP_BY_CONTAINER) {
335
						parentsToUpdate.add(parent);
336
					}
337
					Set containerChecked = ((Set) fContainerChecked.get(parent));
338
339
					parent = getParentPath((IResolvedBundle) changedElements[i]);
340
					if (fGrouping == GROUP_BY_FILE_LOC) {
341
						parentsToUpdate.add(parent);
342
					}
343
					Set fileChecked = ((Set) fFileChecked.get(parent));
344
345
					if (checkState) {
346
						fAllChecked.add(changedElements[i]);
347
						containerChecked.add(changedElements[i]);
348
						fileChecked.add(changedElements[i]);
349
					} else {
350
						fAllChecked.remove(changedElements[i]);
351
						containerChecked.remove(changedElements[i]);
352
						fileChecked.remove(changedElements[i]);
353
					}
354
					fTree.setChecked(changedElements, checkState);
355
				}
356
				for (Iterator iterator = parentsToUpdate.iterator(); iterator.hasNext();) {
357
					Object parent = iterator.next();
358
					if (getChecked(parent).size() == 0) {
359
						fTree.setGrayChecked(parent, false);
360
					} else if (getChecked(parent).size() == getBundleChildren(parent).size()) {
361
						fTree.setGrayed(parent, false);
362
						fTree.setChecked(parent, true);
363
					} else {
364
						fTree.setGrayChecked(parent, true);
365
					}
366
				}
367
			} else {
368
				Set totalChanged = new HashSet();
369
				for (int i = 0; i < changedElements.length; i++) {
370
					fTree.setGrayed(changedElements[i], false);
371
					fTree.setChecked(changedElements[i], checkState);
372
					fTree.setSubtreeChecked(changedElements[i], checkState);
373
374
					Set checked;
375
					List all;
376
					if (fGrouping == GROUP_BY_CONTAINER) {
377
						checked = (Set) fContainerChecked.get(changedElements[i]);
378
						all = (List) fContainerBundles.get(changedElements[i]);
379
					} else {
380
						checked = (Set) fFileChecked.get(changedElements[i]);
381
						all = (List) fFileBundles.get(changedElements[i]);
382
					}
383
					if (checkState) {
384
						checked.addAll(all);
385
					} else {
386
						checked.removeAll(all);
387
					}
388
					totalChanged.addAll(all);
389
				}
390
				// Update the maps that we are not currently displaying
391
				Iterator iterator = fGrouping == GROUP_BY_CONTAINER ? fFileChecked.values().iterator() : fContainerChecked.values().iterator();
392
				while (iterator.hasNext()) {
393
					Set current = (Set) iterator.next();
394
					if (checkState) {
395
						current.addAll(totalChanged);
396
					} else {
397
						current.removeAll(totalChanged);
398
					}
399
				}
400
				if (checkState) {
401
					fAllChecked.addAll(totalChanged);
402
				} else {
403
					fAllChecked.removeAll(totalChanged);
404
				}
405
			}
406
		}
407
	}
408
409
//	/**
410
//	 * Update the check state of parent elements when there is grouping.  The list of changed elements must be
411
//	 * all IResolvedBundles.
412
//	 * 
413
//	 * @param changedElements array of IResolvedBundles that have changed
414
//	 */
415
//	private void updateParentCheckState(Object[] changedElements) {
416
//		if (fGrouping != GROUP_BY_NONE && changedElements.length > 0) {
417
//			Set changedParents = new HashSet();
418
//			if (changedElements[0] instanceof IResolvedBundle) {
419
//				if (fGrouping == GROUP_BY_FILE_LOC) {
420
//					for (int i = 0; i < changedElements.length; i++) {
421
//						changedParents.add(getParentPath((IResolvedBundle) changedElements[i]));
422
//					}
423
//				} else if (fGrouping == GROUP_BY_CONTAINER) {
424
//					for (int i = 0; i < changedElements.length; i++) {
425
//						changedParents.add(((IResolvedBundle) changedElements[i]).getParentContainer());
426
//					}
427
//				}
428
//			} else {
429
//				changedParents.addAll(Arrays.asList(changedElements));
430
//			}
431
//			if (fGrouping == GROUP_BY_FILE_LOC) {
432
//				for (Iterator iterator = changedParents.iterator(); iterator.hasNext();) {
433
//					IPath currentParent = (IPath) iterator.next();
434
//					List children = (List) getFileLocationMap().get(currentParent);
435
//					updateGrayChecked(currentParent, children);
436
//				}
437
//			} else if (fGrouping == GROUP_BY_CONTAINER) {
438
//				for (Iterator iterator = changedParents.iterator(); iterator.hasNext();) {
439
//					IBundleContainer currentParent = (IBundleContainer) iterator.next();
440
//					List children = Arrays.asList(currentParent.getAllBundles());
441
//					// TODO Get plug-in errors (missing bundles)
442
//					updateGrayChecked(currentParent, children);
443
//				}
444
//			}
445
//		}
446
//	}
447
//
448
//	/**
449
//	 * Updates the children of the changed parent elements.  Also removed the gray state
450
//	 * of the parent.
451
//	 * 
452
//	 * @param changedElements list of changed parents
453
//	 * @param state whether the parents are being checked or unchecked
454
//	 */
455
//	private void updateChildrenCheckState(Object[] changedElements, boolean state) {
456
//		for (int i = 0; i < changedElements.length; i++) {
457
//			fTree.setSubtreeChecked(changedElements[i], state);
458
//			fTree.setGrayed(changedElements[i], false);
459
//			fTree.setChecked(changedElements[i], state);
460
//		}
461
//	}
462
463
//	private void updateGrayChecked(Object parent, List children) {
464
//		boolean allChecked = true;
465
//		boolean noneChecked = true;
466
//		for (Iterator iterator2 = children.iterator(); iterator2.hasNext();) {
467
//			boolean checked = fTree.getChecked(iterator2.next());
468
//			if (checked) {
469
//				noneChecked = false;
470
//			} else {
471
//				allChecked = false;
472
//			}
473
//			if (!noneChecked && !allChecked) {
474
//				break;
475
//			}
476
//		}
477
//		if (!noneChecked && !allChecked) {
478
//			fTree.setGrayChecked(parent, true);
479
//		} else if (allChecked) {
480
//			fTree.setChecked(parent, true);
481
//			fTree.setGrayed(parent, false);
482
//		} else {
483
//			fTree.setChecked(parent, false);
484
//			fTree.setGrayed(parent, false);
485
//		}
486
//	}
487
488
	private void handleGroupChange() {
489
		if (fGroupCombo.getSelectionIndex() != fGrouping) {
490
			fGrouping = fGroupCombo.getSelectionIndex();
491
			fTree.refresh(false);
492
			fTree.expandAll();
493
			fTree.setCheckedElements(fAllChecked.toArray());
494
495
			if (fGrouping != GROUP_BY_NONE) {
496
				Map bundleMap = null;
497
				Map checkedMap = null;
498
				if (fGrouping == GROUP_BY_CONTAINER) {
499
					bundleMap = fContainerBundles;
500
					checkedMap = fContainerChecked;
501
				} else if (fGrouping == GROUP_BY_FILE_LOC) {
502
					bundleMap = fFileBundles;
503
					checkedMap = fFileChecked;
504
				}
505
				for (Iterator iterator = bundleMap.keySet().iterator(); iterator.hasNext();) {
506
					Object currentParent = iterator.next();
507
					Set checked = (Set) checkedMap.get(currentParent);
508
					if (checked.size() == 0) {
509
						fTree.setGrayed(currentParent, false);
510
						fTree.setChecked(currentParent, false);
511
					} else if (checked.size() == ((List) bundleMap.get(currentParent)).size()) {
512
						fTree.setGrayed(currentParent, false);
513
						fTree.setChecked(currentParent, true);
514
					} else {
515
						fTree.setGrayChecked(currentParent, true);
516
					}
517
				}
518
			}
519
			updateButtons();
520
		}
521
	}
522
523
	private void updateButtons() {
524
		if (fTargetDefinition != null && !fTree.getSelection().isEmpty()) {
525
			Object[] selection = ((IStructuredSelection) fTree.getSelection()).toArray();
526
			boolean hasResolveBundle = false;
527
			boolean hasParent = false;
528
			boolean allSelected = true;
529
			boolean noneSelected = true;
530
			for (int i = 0; i < selection.length; i++) {
531
				if (!hasResolveBundle || !hasParent) {
532
					if (selection[i] instanceof IResolvedBundle) {
533
						hasResolveBundle = true;
534
					} else {
535
						hasParent = true;
536
					}
537
				}
538
				boolean checked = fTree.getChecked(selection[i]);
539
				if (checked) {
540
					noneSelected = false;
541
				} else {
542
					allSelected = false;
543
				}
544
			}
545
			// Selection is available is not everything is already selected and not both a parent and child item are selected
546
			fSelectButton.setEnabled(!allSelected && !(hasResolveBundle && hasParent));
547
			fDeselectButton.setEnabled(!noneSelected && !(hasResolveBundle && hasParent));
548
//			fSelectRequiredButton.setEnabled(true);
549
		} else {
550
			fSelectButton.setEnabled(false);
551
			fDeselectButton.setEnabled(false);
552
//			fSelectRequiredButton.setEnabled(false);
553
		}
554
555
		fSelectAllButton.setEnabled(fTargetDefinition != null && fAllChecked.size() == fAllBundles.size());
556
		fDeselectAllButton.setEnabled(fTargetDefinition != null && fAllChecked.size() == 0);
557
558
		if (fTargetDefinition != null) {
559
			fCountLabel.setText(MessageFormat.format("{0} of {1} selected", new String[] {Integer.toString(fAllChecked.size()), Integer.toString(fAllBundles.size())}));
560
		} else {
561
			fCountLabel.setText(""); //$NON-NLS-1$
562
		}
563
	}
564
565
	/**
566
	 * Set the container to display in the tree or <code>null</code> to disable the tree 
567
	 * @param input bundle container or <code>null</code>
568
	 */
569
	public void setInput(ITargetDefinition input) {
570
		fTargetDefinition = input;
571
572
		if (input == null || !input.isResolved()) {
573
			fTree.setInput("Resolving...");
574
			setEnabled(false);
575
			return;
576
		}
577
578
		IResolvedBundle[] allResolvedBundles = input.getAllBundles();
579
		if (allResolvedBundles == null || allResolvedBundles.length == 0) {
580
			fTree.setInput("< no plug-ins found in the target >");
581
			setEnabled(false);
582
			return;
583
		}
584
585
		fTree.setInput("Initializing...");
586
		setEnabled(false);
587
		Job initJob = new InitalizeJob();
588
		initJob.addJobChangeListener(new JobChangeAdapter() {
589
			public void done(IJobChangeEvent event) {
590
				Job refreshJob = new UIJob("Refreshing Tree") {
591
					public IStatus runInUIThread(IProgressMonitor monitor) {
592
						fTree.setInput(fTargetDefinition);
593
						// For now we always start with no grouping
594
						fTree.setCheckedElements(fAllChecked.toArray());
595
						setEnabled(true);
596
						return Status.OK_STATUS;
597
					}
598
				};
599
				refreshJob.setSystem(true);
600
				refreshJob.schedule();
601
			}
602
		});
603
		initJob.schedule();
604
	}
605
606
	private class InitalizeJob extends Job {
607
608
		public InitalizeJob() {
609
			super("Initializing Tree");
610
			setSystem(true);
611
		}
612
613
		protected IStatus run(IProgressMonitor monitor) {
614
			fAllBundles = new ArrayList();
615
			fAllChecked = new HashSet();
616
			fContainerBundles = new HashMap();
617
			fContainerChecked = new HashMap();
618
			IBundleContainer[] containers = fTargetDefinition.getBundleContainers();
619
			// Iterate through each container, adding bundles to the map and list
620
			for (int i = 0; i < containers.length; i++) {
621
				List containerBundles = Arrays.asList(containers[i].getAllBundles());
622
				fAllBundles.addAll(containerBundles);
623
				fContainerBundles.put(containers[i], containerBundles);
624
625
				// Determine which of the bundles are checked (included)
626
				if (containers[i].getIncludedBundles() == null) {
627
					// Everything is included
628
					Set checked = new HashSet();
629
					checked.addAll(containerBundles);
630
					fContainerChecked.put(containers[i], checked);
631
					fAllChecked.addAll(checked);
632
				} else {
633
					// Mark the included bundles as checked
634
					List includedBundles = Arrays.asList(containers[i].getBundles());
635
					// If an included bundle has errors it must be explicitly added to the bundle list as getAllBundles does not return it.
636
					for (Iterator iterator = includedBundles.iterator(); iterator.hasNext();) {
637
						IResolvedBundle currentIncluded = (IResolvedBundle) iterator.next();
638
						if (!currentIncluded.getStatus().isOK()) {
639
							((List) fContainerBundles.get(containers[i])).add(currentIncluded);
640
							fAllBundles.add(currentIncluded);
641
						}
642
					}
643
					Set checked = new HashSet();
644
					checked.addAll(includedBundles);
645
					fContainerChecked.put(containers[i], checked);
646
					fAllChecked.addAll(checked);
647
				}
648
			}
649
650
			// Map the bundles into their file locations
651
			fFileBundles = new HashMap();
652
			fFileChecked = new HashMap();
653
			for (Iterator iterator = fAllBundles.iterator(); iterator.hasNext();) {
654
				IResolvedBundle currentBundle = (IResolvedBundle) iterator.next();
655
				IPath parentPath = getParentPath(currentBundle);
656
				List bundles = (List) fFileBundles.get(parentPath);
657
				if (bundles == null) {
658
					bundles = new ArrayList();
659
					bundles.add(currentBundle);
660
					fFileBundles.put(parentPath, bundles);
661
				} else {
662
					bundles.add(currentBundle);
663
				}
664
				// Determine whether the current bundle is checked
665
				if (fAllChecked.contains(currentBundle)) {
666
					Set checked = (Set) fFileChecked.get(parentPath);
667
					if (checked == null) {
668
						checked = new HashSet();
669
						checked.add(currentBundle);
670
						fFileChecked.put(parentPath, checked);
671
					} else {
672
						checked.add(currentBundle);
673
					}
674
				}
675
			}
676
677
			return Status.OK_STATUS;
678
		}
679
	}
680
681
	private Set getChecked(Object parent) {
682
		Set result = null;
683
		if (parent == null) {
684
			result = fAllChecked;
685
		} else if (fGrouping == GROUP_BY_CONTAINER) {
686
			result = (Set) fContainerChecked.get(parent);
687
		} else if (fGrouping == GROUP_BY_FILE_LOC) {
688
			result = (Set) fFileChecked.get(parent);
689
		}
690
		if (result == null) {
691
			return new HashSet(0);
692
		}
693
		return result;
694
	}
695
696
	private List getBundleChildren(Object parent) {
697
		List result = null;
698
		if (parent == null) {
699
			result = fAllBundles;
700
		} else if (fGrouping == GROUP_BY_CONTAINER) {
701
			result = (List) fContainerBundles.get(parent);
702
		} else if (fGrouping == GROUP_BY_FILE_LOC) {
703
			result = (List) fFileBundles.get(parent);
704
		}
705
		if (result == null) {
706
			return new ArrayList(0);
707
		}
708
		return result;
709
	}
710
711
	/* (non-Javadoc)
712
	 * @see org.eclipse.swt.widgets.Control#setEnabled(boolean)
713
	 */
714
	public void setEnabled(boolean enabled) {
715
		super.setEnabled(enabled);
716
		if (enabled) {
717
			updateButtons();
718
		} else {
719
			fSelectButton.setEnabled(false);
720
			fSelectAllButton.setEnabled(false);
721
			fDeselectButton.setEnabled(false);
722
			fDeselectAllButton.setEnabled(false);
723
//			fSelectRequiredButton.setEnabled(false);
724
			fCountLabel.setText(""); //$NON-NLS-1$
725
		}
726
		fShowLabel.setEnabled(enabled);
727
		fShowPluginsButton.setEnabled(enabled);
728
		fShowSourceButton.setEnabled(enabled);
729
		fGroupLabel.setEnabled(enabled);
730
		fGroupCombo.setEnabled(enabled);
731
		super.setEnabled(enabled);
732
	}
733
734
	public void saveIncludedBundleState() {
735
		// TODO Simplify with bundle containers
736
//		IBundleContainer[] containers = fTargetDefinition.getBundleContainers();
737
//		for (int i = 0; i < containers.length; i++) {
738
//			IResolvedBundle[] allBundles = containers[i].getAllBundles();
739
//			List included = new ArrayList(allBundles.length);
740
//			for (int j = 0; j < allBundles.length; j++) {
741
//				if (fTree.getChecked(allBundles[j])) {
742
//					included.add(new BundleInfo(allBundles[j].getBundleInfo().getSymbolicName(), null, null, BundleInfo.NO_LEVEL, false));
743
//				}
744
//			}
745
//			if (included.size() == allBundles.length) {
746
//				containers[i].setIncludedBundles(null);
747
//			} else {
748
//				containers[i].setIncludedBundles((BundleInfo[]) included.toArray(new BundleInfo[included.size()]));
749
//			}
750
//		}
751
		// TODO Handle plug-in errors (missing bundles)
752
	}
753
754
	class TreeContentProvider implements ITreeContentProvider {
755
		public Object[] getChildren(Object parentElement) {
756
			return getBundleChildren(parentElement).toArray();
757
		}
758
759
		public Object getParent(Object element) {
760
//			if (fGrouping == GROUP_BY_CONTAINER && element instanceof IResolvedBundle) {
761
//				return ((IResolvedBundle) element).getParentContainer();
762
//			} else if (fGrouping == GROUP_BY_FILE_LOC && element instanceof IResolvedBundle) {
763
//				return getParentPath((IResolvedBundle) element);
764
//			}
765
			return null;
766
		}
767
768
		public boolean hasChildren(Object element) {
769
			if (fGrouping == GROUP_BY_NONE || element instanceof IResolvedBundle) {
770
				return false;
771
			}
772
			if (element instanceof IBundleContainer || element instanceof IPath) {
773
				return getBundleChildren(element).size() > 0;
774
			}
775
			return false;
776
		}
777
778
		public Object[] getElements(Object inputElement) {
779
			if (inputElement instanceof ITargetDefinition) {
780
				if (fGrouping == GROUP_BY_NONE) {
781
					return fAllBundles.toArray();
782
				} else if (fGrouping == GROUP_BY_CONTAINER) {
783
					return fContainerBundles.keySet().toArray();
784
				} else {
785
					return fFileBundles.keySet().toArray();
786
				}
787
			}
788
			return new Object[] {inputElement};
789
		}
790
791
		public void dispose() {
792
		}
793
794
		public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
795
		}
796
	}
797
798
}
(-)src/org/eclipse/pde/internal/ui/shared/target/TargetLocationsGroup.java (+421 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2009 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.pde.internal.ui.shared.target;
12
13
import java.util.ArrayList;
14
import org.eclipse.core.runtime.IStatus;
15
import org.eclipse.core.runtime.ListenerList;
16
import org.eclipse.jface.viewers.*;
17
import org.eclipse.jface.window.Window;
18
import org.eclipse.jface.wizard.WizardDialog;
19
import org.eclipse.pde.internal.core.target.provisional.*;
20
import org.eclipse.pde.internal.ui.SWTFactory;
21
import org.eclipse.pde.internal.ui.editor.FormLayoutFactory;
22
import org.eclipse.pde.internal.ui.editor.targetdefinition.TargetEditor;
23
import org.eclipse.swt.SWT;
24
import org.eclipse.swt.events.SelectionAdapter;
25
import org.eclipse.swt.events.SelectionEvent;
26
import org.eclipse.swt.layout.GridData;
27
import org.eclipse.swt.layout.GridLayout;
28
import org.eclipse.swt.widgets.*;
29
import org.eclipse.ui.forms.widgets.FormToolkit;
30
31
/**
32
 * UI part that can be added to a dialog or to a form editor.  Contains a table displaying
33
 * the bundle containers of a target definition.  Also has buttons to add, edit and remove
34
 * bundle containers of varying types.
35
 * 
36
 * @see TargetEditor
37
 * @see ITargetDefinition
38
 * @see IBundleContainer
39
 */
40
public class TargetLocationsGroup {
41
42
	private TreeViewer fTreeViewer;
43
	private Button fAddButton;
44
	private Button fEditButton;
45
	private Button fRemoveButton;
46
	private Button fRemoveAllButton;
47
	private Button fShowContentButton;
48
49
	private ITargetDefinition fTarget;
50
	private ListenerList fChangeListeners = new ListenerList();
51
52
	/**
53
	 * Creates this part using the form toolkit and adds it to the given composite.
54
	 * 
55
	 * @param parent parent composite
56
	 * @param toolkit toolkit to create the widgets with
57
	 * @param reporter reporter implementation that will handle resolving and changes to the containers
58
	 * @return generated instance of the table part
59
	 */
60
	public static TargetLocationsGroup createInForm(Composite parent, FormToolkit toolkit) {
61
		TargetLocationsGroup contentTable = new TargetLocationsGroup();
62
		contentTable.createFormContents(parent, toolkit);
63
		return contentTable;
64
	}
65
66
	/**
67
	 * Creates this part using standard dialog widgets and adds it to the given composite.
68
	 * 
69
	 * @param parent parent composite
70
	 * @param reporter reporter implementation that will handle resolving and changes to the containers
71
	 * @return generated instance of the table part
72
	 */
73
	public static TargetLocationsGroup createInDialog(Composite parent) {
74
		TargetLocationsGroup contentTable = new TargetLocationsGroup();
75
		contentTable.createDialogContents(parent);
76
		return contentTable;
77
	}
78
79
	/**
80
	 * Private constructor, use one of {@link #createTableInDialog(Composite, ITargetChangedListener)}
81
	 * or {@link #createTableInForm(Composite, FormToolkit, ITargetChangedListener)}.
82
	 * 
83
	 * @param reporter reporter implementation that will handle resolving and changes to the containers
84
	 */
85
	private TargetLocationsGroup() {
86
87
	}
88
89
	/**
90
	 * Adds a listener to the set of listeners that will be notified when the bundle containers
91
	 * are modified.  This method has no effect if the listener has already been added. 
92
	 * 
93
	 * @param listener target changed listener to add
94
	 */
95
	public void addTargetChangedListener(ITargetChangedListener listener) {
96
		fChangeListeners.add(listener);
97
	}
98
99
	/**
100
	 * Creates the part contents from a toolkit
101
	 * @param parent parent composite
102
	 * @param toolkit form toolkit to create widgets
103
	 */
104
	private void createFormContents(Composite parent, FormToolkit toolkit) {
105
		Composite comp = toolkit.createComposite(parent);
106
		comp.setLayout(FormLayoutFactory.createSectionClientGridLayout(false, 2));
107
		comp.setLayoutData(new GridData(GridData.FILL_BOTH | GridData.GRAB_VERTICAL));
108
109
		Tree atree = toolkit.createTree(comp, SWT.V_SCROLL | SWT.H_SCROLL);
110
		atree.setLayout(new GridLayout());
111
		GridData gd = new GridData(GridData.FILL_BOTH);
112
		atree.setLayoutData(gd);
113
114
		Composite buttonComp = toolkit.createComposite(comp);
115
		GridLayout layout = new GridLayout();
116
		layout.marginWidth = layout.marginHeight = 0;
117
		buttonComp.setLayout(layout);
118
		buttonComp.setLayoutData(new GridData(GridData.FILL_VERTICAL));
119
120
		fAddButton = toolkit.createButton(buttonComp, Messages.BundleContainerTable_0, SWT.PUSH);
121
		fEditButton = toolkit.createButton(buttonComp, Messages.BundleContainerTable_1, SWT.PUSH);
122
		fRemoveButton = toolkit.createButton(buttonComp, Messages.BundleContainerTable_2, SWT.PUSH);
123
		fRemoveAllButton = toolkit.createButton(buttonComp, Messages.BundleContainerTable_3, SWT.PUSH);
124
125
		fShowContentButton = toolkit.createButton(comp, "Show plug-in content", SWT.CHECK);
126
127
		initializeTreeViewer(atree);
128
		initializeButtons();
129
130
		toolkit.paintBordersFor(comp);
131
	}
132
133
	/**
134
	 * Creates the part contents using SWTFactory
135
	 * @param parent parent composite
136
	 */
137
	private void createDialogContents(Composite parent) {
138
		Composite comp = SWTFactory.createComposite(parent, 2, 1, GridData.FILL_BOTH, 0, 0);
139
140
		Tree atree = new Tree(comp, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER);
141
		atree.setLayout(new GridLayout());
142
		GridData gd = new GridData(GridData.FILL_BOTH);
143
		gd.widthHint = 200;
144
		atree.setLayoutData(gd);
145
146
		Composite buttonComp = SWTFactory.createComposite(comp, 2, 1, GridData.FILL_BOTH);
147
		GridLayout layout = new GridLayout();
148
		layout.marginHeight = 0;
149
		layout.marginWidth = 0;
150
		buttonComp.setLayout(layout);
151
		buttonComp.setLayoutData(new GridData(GridData.FILL_VERTICAL));
152
153
		fAddButton = SWTFactory.createPushButton(buttonComp, Messages.BundleContainerTable_0, null);
154
		fEditButton = SWTFactory.createPushButton(buttonComp, Messages.BundleContainerTable_1, null);
155
		fRemoveButton = SWTFactory.createPushButton(buttonComp, Messages.BundleContainerTable_2, null);
156
		fRemoveAllButton = SWTFactory.createPushButton(buttonComp, Messages.BundleContainerTable_3, null);
157
158
		fShowContentButton = SWTFactory.createCheckButton(comp, "Show Plug-in Content", null, false, 2);
159
160
		initializeTreeViewer(atree);
161
		initializeButtons();
162
	}
163
164
	/**
165
	 * Sets up the tree viewer using the given tree
166
	 * @param tree
167
	 */
168
	private void initializeTreeViewer(Tree tree) {
169
		fTreeViewer = new TreeViewer(tree);
170
		fTreeViewer.setContentProvider(new BundleContainerContentProvider());
171
		fTreeViewer.setLabelProvider(new BundleContainerLabelProvider());
172
		fTreeViewer.setComparator(new ViewerComparator());
173
		fTreeViewer.addSelectionChangedListener(new ISelectionChangedListener() {
174
			public void selectionChanged(SelectionChangedEvent event) {
175
				updateButtons();
176
			}
177
		});
178
		fTreeViewer.addDoubleClickListener(new IDoubleClickListener() {
179
			public void doubleClick(DoubleClickEvent event) {
180
				if (!event.getSelection().isEmpty()) {
181
					handleEdit();
182
				}
183
			}
184
		});
185
		fTreeViewer.setAutoExpandLevel(AbstractTreeViewer.ALL_LEVELS);
186
	}
187
188
	/**
189
	 * Sets up the buttons, the button fields must already be created before calling this method
190
	 */
191
	private void initializeButtons() {
192
		fAddButton.addSelectionListener(new SelectionAdapter() {
193
			public void widgetSelected(SelectionEvent e) {
194
				handleAdd();
195
			}
196
		});
197
		fAddButton.setLayoutData(new GridData());
198
		SWTFactory.setButtonDimensionHint(fAddButton);
199
200
		fEditButton.addSelectionListener(new SelectionAdapter() {
201
			public void widgetSelected(SelectionEvent e) {
202
				handleEdit();
203
			}
204
		});
205
		fEditButton.setLayoutData(new GridData());
206
		fEditButton.setEnabled(false);
207
		SWTFactory.setButtonDimensionHint(fEditButton);
208
209
		fRemoveButton.addSelectionListener(new SelectionAdapter() {
210
			public void widgetSelected(SelectionEvent e) {
211
				handleRemove();
212
			}
213
		});
214
		fRemoveButton.setLayoutData(new GridData());
215
		fRemoveButton.setEnabled(false);
216
		SWTFactory.setButtonDimensionHint(fRemoveButton);
217
218
		fRemoveAllButton.addSelectionListener(new SelectionAdapter() {
219
			public void widgetSelected(SelectionEvent e) {
220
				handleRemoveAll();
221
			}
222
		});
223
		fRemoveAllButton.setLayoutData(new GridData());
224
		SWTFactory.setButtonDimensionHint(fRemoveAllButton);
225
226
		fShowContentButton.addSelectionListener(new SelectionAdapter() {
227
			public void widgetSelected(SelectionEvent e) {
228
				fTreeViewer.refresh();
229
				fTreeViewer.expandAll();
230
			}
231
		});
232
		fShowContentButton.setLayoutData(new GridData());
233
		SWTFactory.setButtonDimensionHint(fShowContentButton);
234
	}
235
236
	/**
237
	 * Sets the target definition model to use as input for the tree, can be called with different
238
	 * models to change the tree's input.
239
	 * @param target target model
240
	 */
241
	public void setInput(ITargetDefinition target) {
242
		fTarget = target;
243
		refresh();
244
	}
245
246
	/**
247
	 * Refreshes the contents of the table
248
	 */
249
	public void refresh() {
250
		fTreeViewer.setInput(fTarget);
251
		updateButtons();
252
	}
253
254
//	private void setEnabled(boolean enablement) {
255
//		fTreeViewer.getControl().setEnabled(enablement);
256
//		fAddButton.setEnabled(enablement);
257
//
258
//		if (enablement) {
259
//			updateButtons();
260
//		} else {
261
//			fRemoveButton.setEnabled(enablement);
262
//			fRemoveAllButton.setEnabled(enablement);
263
//			fEditButton.setEnabled(enablement);
264
//		}
265
//	}
266
267
	private void handleAdd() {
268
		AddBundleContainerWizard wizard = new AddBundleContainerWizard(fTarget);
269
		Shell parent = fTreeViewer.getTree().getShell();
270
		WizardDialog dialog = new WizardDialog(parent, wizard);
271
		if (dialog.open() != Window.CANCEL) {
272
			contentsChanged();
273
		}
274
	}
275
276
	private void handleEdit() {
277
		IStructuredSelection selection = (IStructuredSelection) fTreeViewer.getSelection();
278
		if (!selection.isEmpty()) {
279
			Object selected = selection.getFirstElement();
280
			IBundleContainer oldContainer = null;
281
			if (selected instanceof IBundleContainer) {
282
				oldContainer = (IBundleContainer) selected;
283
			} else if (selected instanceof IResolvedBundle) {
284
				TreeItem[] treeSelection = fTreeViewer.getTree().getSelection();
285
				if (treeSelection.length > 0) {
286
					Object parent = treeSelection[0].getParentItem().getData();
287
					if (parent instanceof IBundleContainer) {
288
						oldContainer = (IBundleContainer) parent;
289
					}
290
				}
291
			}
292
			if (oldContainer != null) {
293
				Shell parent = fTreeViewer.getTree().getShell();
294
				EditBundleContainerWizard wizard = new EditBundleContainerWizard(oldContainer);
295
				WizardDialog dialog = new WizardDialog(parent, wizard);
296
				if (dialog.open() == Window.OK) {
297
					// Replace the old container with the new one
298
					IBundleContainer newContainer = wizard.getBundleContainer();
299
					if (newContainer != null) {
300
						IBundleContainer[] containers = fTarget.getBundleContainers();
301
						java.util.List newContainers = new ArrayList(containers.length);
302
						for (int i = 0; i < containers.length; i++) {
303
							if (!containers[i].equals(oldContainer)) {
304
								newContainers.add(containers[i]);
305
							}
306
						}
307
						newContainers.add(newContainer);
308
						fTarget.setBundleContainers((IBundleContainer[]) newContainers.toArray(new IBundleContainer[newContainers.size()]));
309
310
						// Update the table
311
						contentsChanged();
312
						fTreeViewer.setSelection(new StructuredSelection(newContainer), true);
313
					}
314
				}
315
			}
316
		}
317
	}
318
319
	private void handleRemove() {
320
		IStructuredSelection selection = (IStructuredSelection) fTreeViewer.getSelection();
321
		if (!selection.isEmpty()) {
322
			Object selected = selection.getFirstElement();
323
			IBundleContainer container = null;
324
			if (selected instanceof IBundleContainer) {
325
				container = (IBundleContainer) selected;
326
				IBundleContainer[] currentContainers = fTarget.getBundleContainers();
327
				ArrayList newBundleContainers = new ArrayList(currentContainers.length);
328
				for (int i = 0; i < currentContainers.length; i++) {
329
					if (!currentContainers[i].equals(container)) {
330
						newBundleContainers.add(currentContainers[i]);
331
					}
332
				}
333
				fTarget.setBundleContainers((IBundleContainer[]) newBundleContainers.toArray(new IBundleContainer[newBundleContainers.size()]));
334
				contentsChanged();
335
			}
336
		}
337
	}
338
339
	private void handleRemoveAll() {
340
		fTarget.setBundleContainers(null);
341
		contentsChanged();
342
	}
343
344
	private void updateButtons() {
345
		IStructuredSelection selection = (IStructuredSelection) fTreeViewer.getSelection();
346
		fEditButton.setEnabled(!selection.isEmpty() && selection.getFirstElement() instanceof IBundleContainer);
347
		fRemoveButton.setEnabled(!selection.isEmpty() && selection.getFirstElement() instanceof IBundleContainer);
348
		fRemoveAllButton.setEnabled(fTarget != null && fTarget.getBundleContainers() != null && fTarget.getBundleContainers().length > 0);
349
	}
350
351
	/**
352
	 * Informs the reporter for this table that something has changed
353
	 * and is dirty.
354
	 */
355
	private void contentsChanged() {
356
		Object[] listeners = fChangeListeners.getListeners();
357
		for (int i = 0; i < listeners.length; i++) {
358
			((ITargetChangedListener) listeners[i]).contentsChanged(fTarget, true);
359
		}
360
		refresh();
361
	}
362
363
	/**
364
	 * Content provider for the tree, primary input is a ITargetDefinition, children are IBundleContainers
365
	 */
366
	class BundleContainerContentProvider implements ITreeContentProvider {
367
368
		public Object[] getChildren(Object parentElement) {
369
			if (parentElement instanceof ITargetDefinition) {
370
				IBundleContainer[] containers = ((ITargetDefinition) parentElement).getBundleContainers();
371
				return containers != null ? containers : new Object[0];
372
			} else if (parentElement instanceof IBundleContainer) {
373
				IBundleContainer container = (IBundleContainer) parentElement;
374
				if (container.isResolved()) {
375
					IStatus status = container.getBundleStatus();
376
					if (!status.isOK() && !status.isMultiStatus()) {
377
						return new Object[] {status};
378
					}
379
					if (fShowContentButton.getSelection()) {
380
						return container.getBundles();
381
					} else if (!status.isOK()) {
382
						// Show multi-status children so user can easily see problems
383
						if (status.isMultiStatus()) {
384
							return status.getChildren();
385
						}
386
					}
387
				}
388
			}
389
			return new Object[0];
390
		}
391
392
		public Object getParent(Object element) {
393
			return null;
394
		}
395
396
		public boolean hasChildren(Object element) {
397
			// Since we are already resolved we can't be more efficient
398
			return getChildren(element).length > 0;
399
		}
400
401
		public Object[] getElements(Object inputElement) {
402
			if (inputElement instanceof ITargetDefinition) {
403
				IBundleContainer[] containers = ((ITargetDefinition) inputElement).getBundleContainers();
404
				if (containers != null) {
405
					return containers;
406
				}
407
			} else if (inputElement instanceof String) {
408
				return new Object[] {inputElement};
409
			}
410
			return new Object[0];
411
		}
412
413
		public void dispose() {
414
		}
415
416
		public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
417
		}
418
419
	}
420
421
}
(-)src/org/eclipse/pde/internal/core/target/provisional/IResolvedBundle.java (-78 / +85 lines)
Lines 1-78 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2009 IBM Corporation and others.
2
 * Copyright (c) 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.pde.internal.core.target.provisional;
11
package org.eclipse.pde.internal.core.target.provisional;
12
12
13
import org.eclipse.core.runtime.IStatus;
13
import org.eclipse.core.runtime.IStatus;
14
import org.eclipse.equinox.internal.provisional.frameworkadmin.BundleInfo;
14
import org.eclipse.equinox.internal.provisional.frameworkadmin.BundleInfo;
15
15
16
/**
16
/**
17
 * A resolved bundle contained in a bundle container of a target definition.
17
 * A resolved bundle contained in a bundle container of a target definition.
18
 * A resolved bundle is created by resolving a bundle container or target
18
 * A resolved bundle is created by resolving a bundle container or target
19
 * definition.
19
 * definition.
20
 * 
20
 * 
21
 * @since 3.5
21
 * @since 3.5
22
 */
22
 */
23
public interface IResolvedBundle {
23
public interface IResolvedBundle {
24
24
25
	/**
25
	/**
26
	 * Status code indicating that a required bundle does not exist.
26
	 * Status code indicating that a required bundle does not exist.
27
	 */
27
	 */
28
	public static final int STATUS_DOES_NOT_EXIST = 100;
28
	public static final int STATUS_DOES_NOT_EXIST = 100;
29
29
30
	/**
30
	/**
31
	 * Status code indicating that a required bundle version does not exist (a bundle
31
	 * Status code indicating that a required bundle version does not exist (a bundle
32
	 * with the correct symbolic name is present, but the specified version was not
32
	 * with the correct symbolic name is present, but the specified version was not
33
	 * found).
33
	 * found).
34
	 */
34
	 */
35
	public static final int STATUS_VERSION_DOES_NOT_EXIST = 101;
35
	public static final int STATUS_VERSION_DOES_NOT_EXIST = 101;
36
36
37
	/**
37
	/**
38
	 * Status code indicating that a bundle's manifest could not be read, or did not exist. 
38
	 * Status code indicating that a bundle's manifest could not be read, or did not exist. 
39
	 */
39
	 */
40
	public static final int STATUS_INVALID_MANIFEST = 102;
40
	public static final int STATUS_INVALID_MANIFEST = 102;
41
41
42
	/**
42
	/**
43
	 * Returns the underlying bundle this resolution describes.
43
	 * Returns the underlying bundle this resolution describes.
44
	 * 
44
	 * 
45
	 * @return the underlying bundle this resolution describes
45
	 * @return the underlying bundle this resolution describes
46
	 */
46
	 */
47
	public BundleInfo getBundleInfo();
47
	public BundleInfo getBundleInfo();
48
48
49
	/**
49
	/**
50
	 * Returns <code>true</code> if this bundle is a source bundle and 
50
	 * Returns the parent bundle container that this bundle belongs to.
51
	 * <code>false</code> if this bundle is an executable bundle.
51
	 * 
52
	 * 
52
	 * @return parent bundle container
53
	 * @return whether the resolved bundle is a source bundle
53
	 */
54
	 */
54
	public IBundleContainer getParentContainer();
55
	public boolean isSourceBundle();
55
56
56
	/**
57
	/**
57
	 * Returns <code>true</code> if this bundle is a source bundle and 
58
	 * Returns the resolution status of this bundle.
58
	 * <code>false</code> if this bundle is an executable bundle.
59
	 * 
59
	 * 
60
	 * @return resolution status
60
	 * @return whether the resolved bundle is a source bundle
61
	 */
61
	 */
62
	public IStatus getStatus();
62
	public boolean isSourceBundle();
63
63
64
	/**
64
	/**
65
	 * Returns whether this bundle is optional in its target definition.
65
	 * Returns the resolution status of this bundle.
66
	 * Returns <code>true</code> if optional and <code>false</code> if it is required.
66
	 * 
67
	 *  
67
	 * @return resolution status
68
	 * @return whether this bundle is optional in its target definition
68
	 */
69
	 */
69
	public IStatus getStatus();
70
	public boolean isOptional();
70
71
71
	/**
72
	/**
72
	 * Returns whether this bundle is optional in its target definition.
73
	 * Returns whether this bundle is a fragment.
73
	 * Returns <code>true</code> if optional and <code>false</code> if it is required.
74
	 * 
74
	 *  
75
	 * @return whether this bundle is a fragment
75
	 * @return whether this bundle is optional in its target definition
76
	 */
76
	 */
77
	public boolean isFragment();
77
	public boolean isOptional();
78
}
78
79
	/**
80
	 * Returns whether this bundle is a fragment.
81
	 * 
82
	 * @return whether this bundle is a fragment
83
	 */
84
	public boolean isFragment();
85
}
(-)src/org/eclipse/pde/internal/core/target/impl/Messages.java (-1 lines)
Lines 22-28 Link Here
22
	public static String AbstractBundleContainer_2;
22
	public static String AbstractBundleContainer_2;
23
	public static String AbstractBundleContainer_3;
23
	public static String AbstractBundleContainer_3;
24
	public static String AbstractBundleContainer_4;
24
	public static String AbstractBundleContainer_4;
25
	public static String AbstractBundleContainer_5;
26
	public static String DirectoryBundleContainer_0;
25
	public static String DirectoryBundleContainer_0;
27
	public static String DirectoryBundleContainer_1;
26
	public static String DirectoryBundleContainer_1;
28
	public static String DirectoryBundleContainer_2;
27
	public static String DirectoryBundleContainer_2;
(-)src/org/eclipse/pde/internal/core/target/impl/ResolvedBundle.java (-1 / +22 lines)
Lines 13-18 Link Here
13
import org.eclipse.core.runtime.IStatus;
13
import org.eclipse.core.runtime.IStatus;
14
import org.eclipse.core.runtime.Status;
14
import org.eclipse.core.runtime.Status;
15
import org.eclipse.equinox.internal.provisional.frameworkadmin.BundleInfo;
15
import org.eclipse.equinox.internal.provisional.frameworkadmin.BundleInfo;
16
import org.eclipse.pde.internal.core.target.provisional.IBundleContainer;
16
import org.eclipse.pde.internal.core.target.provisional.IResolvedBundle;
17
import org.eclipse.pde.internal.core.target.provisional.IResolvedBundle;
17
18
18
/**
19
/**
Lines 23-28 Link Here
23
public class ResolvedBundle implements IResolvedBundle {
24
public class ResolvedBundle implements IResolvedBundle {
24
25
25
	private BundleInfo fInfo;
26
	private BundleInfo fInfo;
27
	private IBundleContainer fContainer;
26
	private boolean fIsSource = false;
28
	private boolean fIsSource = false;
27
	private IStatus fStatus;
29
	private IStatus fStatus;
28
	private boolean fIsOptional = false;
30
	private boolean fIsOptional = false;
Lines 39-46 Link Here
39
	 * @param optional whether the bundle is optional
41
	 * @param optional whether the bundle is optional
40
	 * @param whether the bundle is a fragment
42
	 * @param whether the bundle is a fragment
41
	 */
43
	 */
42
	ResolvedBundle(BundleInfo info, IStatus status, boolean source, boolean optional, boolean fragment) {
44
	ResolvedBundle(BundleInfo info, IBundleContainer parentContainer, IStatus status, boolean source, boolean optional, boolean fragment) {
43
		fInfo = info;
45
		fInfo = info;
46
		fContainer = parentContainer;
44
		if (status == null) {
47
		if (status == null) {
45
			fStatus = Status.OK_STATUS;
48
			fStatus = Status.OK_STATUS;
46
		} else {
49
		} else {
Lines 59-64 Link Here
59
	}
62
	}
60
63
61
	/* (non-Javadoc)
64
	/* (non-Javadoc)
65
	 * @see org.eclipse.pde.internal.core.target.provisional.IResolvedBundle#getParentContainer()
66
	 */
67
	public IBundleContainer getParentContainer() {
68
		return fContainer;
69
	}
70
71
	/* (non-Javadoc)
62
	 * @see org.eclipse.pde.internal.core.target.provisional.IResolvedBundle#getStatus()
72
	 * @see org.eclipse.pde.internal.core.target.provisional.IResolvedBundle#getStatus()
63
	 */
73
	 */
64
	public IStatus getStatus() {
74
	public IStatus getStatus() {
Lines 113-116 Link Here
113
	public String getSourcePath() {
123
	public String getSourcePath() {
114
		return fSourcePath;
124
		return fSourcePath;
115
	}
125
	}
126
127
	/* (non-Javadoc)
128
	 * @see java.lang.Object#toString()
129
	 */
130
	public String toString() {
131
		StringBuffer result = new StringBuffer().append(fInfo.toString());
132
		if (fStatus != null && !fStatus.isOK()) {
133
			result = result.append(' ').append(fStatus.toString());
134
		}
135
		return result.toString();
136
	}
116
}
137
}
(-)src/org/eclipse/pde/internal/core/target/impl/AbstractBundleContainer.java (-6 / +6 lines)
Lines 299-305 Link Here
299
				sev = IStatus.INFO;
299
				sev = IStatus.INFO;
300
				message = NLS.bind(Messages.AbstractBundleContainer_2, new Object[] {info.getVersion(), info.getSymbolicName()});
300
				message = NLS.bind(Messages.AbstractBundleContainer_2, new Object[] {info.getVersion(), info.getSymbolicName()});
301
			}
301
			}
302
			return new ResolvedBundle(info, new Status(sev, PDECore.PLUGIN_ID, IResolvedBundle.STATUS_VERSION_DOES_NOT_EXIST, message, null), false, optional, false);
302
			return new ResolvedBundle(info, null, new Status(sev, PDECore.PLUGIN_ID, IResolvedBundle.STATUS_VERSION_DOES_NOT_EXIST, message, null), false, optional, false);
303
		}
303
		}
304
		// DOES NOT EXIST
304
		// DOES NOT EXIST
305
		int sev = IStatus.ERROR;
305
		int sev = IStatus.ERROR;
Lines 308-314 Link Here
308
			sev = IStatus.INFO;
308
			sev = IStatus.INFO;
309
			message = NLS.bind(Messages.AbstractBundleContainer_4, info.getSymbolicName());
309
			message = NLS.bind(Messages.AbstractBundleContainer_4, info.getSymbolicName());
310
		}
310
		}
311
		return new ResolvedBundle(info, new Status(sev, PDECore.PLUGIN_ID, IResolvedBundle.STATUS_DOES_NOT_EXIST, message, null), false, optional, false);
311
		return new ResolvedBundle(info, null, new Status(sev, PDECore.PLUGIN_ID, IResolvedBundle.STATUS_DOES_NOT_EXIST, message, null), false, optional, false);
312
	}
312
	}
313
313
314
	/**
314
	/**
Lines 405-413 Link Here
405
			}
405
			}
406
			return ManifestElement.parseBundleManifest(manifestStream, new Hashtable(10));
406
			return ManifestElement.parseBundleManifest(manifestStream, new Hashtable(10));
407
		} catch (BundleException e) {
407
		} catch (BundleException e) {
408
			throw new CoreException(new Status(IStatus.ERROR, PDECore.PLUGIN_ID, IResolvedBundle.STATUS_INVALID_MANIFEST, Messages.AbstractBundleContainer_5, e));
408
			throw new CoreException(new Status(IStatus.ERROR, PDECore.PLUGIN_ID, IResolvedBundle.STATUS_INVALID_MANIFEST, NLS.bind(Messages.DirectoryBundleContainer_3, bundle.getSymbolicName()), e));
409
		} catch (IOException e) {
409
		} catch (IOException e) {
410
			throw new CoreException(new Status(IStatus.ERROR, PDECore.PLUGIN_ID, IResolvedBundle.STATUS_INVALID_MANIFEST, Messages.AbstractBundleContainer_5, e));
410
			throw new CoreException(new Status(IStatus.ERROR, PDECore.PLUGIN_ID, IResolvedBundle.STATUS_INVALID_MANIFEST, NLS.bind(Messages.DirectoryBundleContainer_3, bundle.getSymbolicName()), e));
411
		} finally {
411
		} finally {
412
			closeZipFileAndStream(manifestStream, jarFile);
412
			closeZipFileAndStream(manifestStream, jarFile);
413
		}
413
		}
Lines 501-507 Link Here
501
		} catch (CoreException e) {
501
		} catch (CoreException e) {
502
			status = e.getStatus();
502
			status = e.getStatus();
503
		}
503
		}
504
		return new ResolvedBundle(info, status, source, false, fragment);
504
		return new ResolvedBundle(info, this, status, source, false, fragment);
505
	}
505
	}
506
506
507
	/**
507
	/**
Lines 542-548 Link Here
542
							}
542
							}
543
							boolean source = isSourceBundle(file, name, manifest);
543
							boolean source = isSourceBundle(file, name, manifest);
544
							boolean fragment = manifest.containsKey(Constants.FRAGMENT_HOST);
544
							boolean fragment = manifest.containsKey(Constants.FRAGMENT_HOST);
545
							ResolvedBundle rb = new ResolvedBundle(info, null, source, false, fragment);
545
							ResolvedBundle rb = new ResolvedBundle(info, this, null, source, false, fragment);
546
							rb.setSourcePath(fSourcePath);
546
							rb.setSourcePath(fSourcePath);
547
							return rb;
547
							return rb;
548
						}
548
						}
(-)src/org/eclipse/pde/internal/core/target/impl/Messages.properties (-5 / +4 lines)
Lines 10-20 Link Here
10
###############################################################################
10
###############################################################################
11
11
12
AbstractBundleContainer_0=Problems occurred while resolving plug-ins in the target
12
AbstractBundleContainer_0=Problems occurred while resolving plug-ins in the target
13
AbstractBundleContainer_2=Missing version {0} of optional plug-in: {1}
13
AbstractBundleContainer_2=Optional plug-in with version {0} could not be found: {1}
14
AbstractBundleContainer_3=Missing required plug-in: {0}
14
AbstractBundleContainer_3=Required plug-in could not be found: {0}
15
AbstractBundleContainer_4=Missing optional plug-in: {0}
15
AbstractBundleContainer_4=Optional plug-in could not be found: {0}
16
AbstractBundleContainer_5=Error reading bundle manifest
16
AbstractBundleContainer_1=Required plug-in with version {0} not found: {1}
17
AbstractBundleContainer_1=Missing required version {0} of plug-in: {1}
18
DirectoryBundleContainer_0=Reading bundles...
17
DirectoryBundleContainer_0=Reading bundles...
19
DirectoryBundleContainer_1=Directory does not exist: {0}
18
DirectoryBundleContainer_1=Directory does not exist: {0}
20
DirectoryBundleContainer_2=Error converting manifest for {0}
19
DirectoryBundleContainer_2=Error converting manifest for {0}
(-)src/org/eclipse/pde/internal/core/target/impl/ProfileBundleContainer.java (-1 / +6 lines)
Lines 89-99 Link Here
89
	 * @see org.eclipse.pde.internal.core.target.impl.AbstractBundleContainer#resolveBundles(org.eclipse.pde.internal.core.target.provisional.ITargetDefinition, org.eclipse.core.runtime.IProgressMonitor)
89
	 * @see org.eclipse.pde.internal.core.target.impl.AbstractBundleContainer#resolveBundles(org.eclipse.pde.internal.core.target.provisional.ITargetDefinition, org.eclipse.core.runtime.IProgressMonitor)
90
	 */
90
	 */
91
	protected IResolvedBundle[] resolveBundles(ITargetDefinition definition, IProgressMonitor monitor) throws CoreException {
91
	protected IResolvedBundle[] resolveBundles(ITargetDefinition definition, IProgressMonitor monitor) throws CoreException {
92
		URL configUrl = getConfigurationArea();
93
		String home = resolveHomeLocation().toOSString();
92
		String home = resolveHomeLocation().toOSString();
94
		if (!new File(home).isDirectory()) {
93
		if (!new File(home).isDirectory()) {
95
			throw new CoreException(new Status(IStatus.ERROR, PDECore.PLUGIN_ID, NLS.bind(Messages.ProfileBundleContainer_0, home)));
94
			throw new CoreException(new Status(IStatus.ERROR, PDECore.PLUGIN_ID, NLS.bind(Messages.ProfileBundleContainer_0, home)));
96
		}
95
		}
96
97
		URL configUrl = getConfigurationArea();
98
		if (!new File(configUrl.getFile()).isDirectory()) {
99
			throw new CoreException(new Status(IStatus.ERROR, PDECore.PLUGIN_ID, NLS.bind("Configuration directory does not exist: {0}", home)));
100
		}
101
97
		BundleInfo[] infos = P2Utils.readBundles(home, configUrl);
102
		BundleInfo[] infos = P2Utils.readBundles(home, configUrl);
98
		if (infos == null) {
103
		if (infos == null) {
99
			IResolvedBundle[] platformXML = resolvePlatformXML(definition, home, monitor);
104
			IResolvedBundle[] platformXML = resolvePlatformXML(definition, home, monitor);
(-)src/org/eclipse/pde/internal/core/plugin/PluginObject.java (-16 / +13 lines)
Lines 13-32 Link Here
13
import java.io.PrintWriter;
13
import java.io.PrintWriter;
14
import java.io.Serializable;
14
import java.io.Serializable;
15
import java.util.Vector;
15
import java.util.Vector;
16
16
import org.eclipse.core.runtime.*;
17
import org.eclipse.core.runtime.CoreException;
17
import org.eclipse.pde.core.*;
18
import org.eclipse.core.runtime.IStatus;
18
import org.eclipse.pde.core.plugin.*;
19
import org.eclipse.core.runtime.PlatformObject;
20
import org.eclipse.core.runtime.Status;
21
import org.eclipse.pde.core.IModel;
22
import org.eclipse.pde.core.IModelChangeProvider;
23
import org.eclipse.pde.core.IModelChangedEvent;
24
import org.eclipse.pde.core.ISourceObject;
25
import org.eclipse.pde.core.ModelChangedEvent;
26
import org.eclipse.pde.core.plugin.IPluginBase;
27
import org.eclipse.pde.core.plugin.IPluginModelBase;
28
import org.eclipse.pde.core.plugin.IPluginObject;
29
import org.eclipse.pde.core.plugin.ISharedPluginModel;
30
import org.eclipse.pde.internal.core.PDECore;
19
import org.eclipse.pde.internal.core.PDECore;
31
import org.eclipse.pde.internal.core.PDECoreMessages;
20
import org.eclipse.pde.internal.core.PDECoreMessages;
32
import org.eclipse.pde.internal.core.ibundle.IBundlePluginModelProvider;
21
import org.eclipse.pde.internal.core.ibundle.IBundlePluginModelProvider;
Lines 184-191 Link Here
184
	}
173
	}
185
174
186
	public String toString() {
175
	public String toString() {
187
		if (fName != null)
176
		String result = null;
188
			return fName;
177
		if (fName != null) {
178
			result = fName;
179
		}
180
		if ((result == null || result.indexOf('%') >= 0) && fModel != null) {
181
			result = fModel.toString();
182
		}
183
		if (result != null) {
184
			return result;
185
		}
189
		return super.toString();
186
		return super.toString();
190
	}
187
	}
191
188
(-)META-INF/MANIFEST.MF (-1 / +5 lines)
Lines 58-64 Link Here
58
 org.eclipse.ant.core;bundle-version="[3.1.0,4.0.0)",
58
 org.eclipse.ant.core;bundle-version="[3.1.0,4.0.0)",
59
 org.eclipse.equinox.simpleconfigurator.manipulator;bundle-version="[1.0.100,2.0.0)",
59
 org.eclipse.equinox.simpleconfigurator.manipulator;bundle-version="[1.0.100,2.0.0)",
60
 org.eclipse.equinox.frameworkadmin;bundle-version="[1.0.100,2.0.0)",
60
 org.eclipse.equinox.frameworkadmin;bundle-version="[1.0.100,2.0.0)",
61
 org.eclipse.debug.core;bundle-version="[3.5.0,4.0.0)"
61
 org.eclipse.debug.core;bundle-version="[3.5.0,4.0.0)",
62
 org.eclipse.equinox.p2.metadata;bundle-version="[1.0.0,2.0.0)",
63
 org.eclipse.equinox.p2.director;bundle-version="[1.0.100,2.0.0)",
64
 org.eclipse.equinox.p2.core;bundle-version="[1.0.100,2.0.0)",
65
 org.eclipse.equinox.p2.repository.tools;bundle-version="[1.0.0,2.0.0)"
62
Eclipse-LazyStart: true
66
Eclipse-LazyStart: true
63
Bundle-RequiredExecutionEnvironment: J2SE-1.4
67
Bundle-RequiredExecutionEnvironment: J2SE-1.4
64
Import-Package: com.ibm.icu.util
68
Import-Package: com.ibm.icu.util
(-)src/org/eclipse/pde/internal/core/target/impl/P2BundleContainer.java (+92 lines)
Added Link Here
1
package org.eclipse.pde.internal.core.target.impl;
2
3
import org.eclipse.core.runtime.CoreException;
4
import org.eclipse.core.runtime.IProgressMonitor;
5
import org.eclipse.equinox.internal.p2.director.PermissiveSlicer;
6
import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit;
7
import org.eclipse.equinox.p2.internal.repository.tools.Repo2Runnable;
8
import org.eclipse.equinox.p2.internal.repository.tools.RepositoryDescriptor;
9
import org.eclipse.pde.internal.core.target.provisional.IResolvedBundle;
10
import org.eclipse.pde.internal.core.target.provisional.ITargetDefinition;
11
12
public class P2BundleContainer extends AbstractBundleContainer {
13
14
	/**
15
	 * Constant describing the type of bundle container 
16
	 */
17
	public static final String TYPE = "P2Repo"; //$NON-NLS-1$
18
19
	private IInstallableUnit[] fUnits;
20
	private String fDownloadDir;
21
	private String[] fSourceRepos = null;
22
23
	public P2BundleContainer() {
24
		fDownloadDir = "/home/cwindatt/Desktop/Export";
25
	}
26
27
	/* (non-Javadoc)
28
	 * @see org.eclipse.pde.internal.core.target.impl.AbstractBundleContainer#getLocation(boolean)
29
	 */
30
	public String getLocation(boolean resolve) throws CoreException {
31
		// TODO We are breaking getVMArguments and other places this method is used
32
		return fDownloadDir;
33
	}
34
35
	public String[] getSourceRepos() {
36
		return fSourceRepos;
37
	}
38
39
	public void setSourceRepos(String[] sourceRepos) {
40
		fSourceRepos = sourceRepos;
41
	}
42
43
	public IInstallableUnit[] getRequiredUnits() {
44
		return fUnits;
45
	}
46
47
	public void setRequiredUnits(IInstallableUnit[] units) {
48
		fUnits = units;
49
	}
50
51
	/* (non-Javadoc)
52
	 * @see org.eclipse.pde.internal.core.target.impl.AbstractBundleContainer#getType()
53
	 */
54
	public String getType() {
55
		return TYPE;
56
	}
57
58
	/* (non-Javadoc)
59
	 * @see org.eclipse.pde.internal.core.target.impl.AbstractBundleContainer#resolveBundles(org.eclipse.pde.internal.core.target.provisional.ITargetDefinition, org.eclipse.core.runtime.IProgressMonitor)
60
	 */
61
	protected IResolvedBundle[] resolveBundles(ITargetDefinition definition, IProgressMonitor monitor) throws CoreException {
62
		// Create queryable for all source repos
63
64
		// Use the slicer to get the complete list of ius to grab
65
		PermissiveSlicer slicer = new PermissiveSlicer(null, null, true, true, true, true);
66
		slicer.slice(fUnits, monitor);
67
68
		// We need to get the features as well'
69
//		org.eclipse.update.install.features=true
70
71
		// Download artifacts to the folder
72
		Repo2Runnable runnable = new Repo2Runnable();
73
		runnable.addDestination(new RepositoryDescriptor());
74
		runnable.run(monitor);
75
76
//		try {
77
//			Repo2Runnable tool = new Repo2Runnable();
78
//			tool.setDestinationArtifactRepository(fInstallDir.toString());
79
//			tool.setDestinationMetadataRepository(fInstallDir.toString());
80
//			tool.setSourceIUs(Arrays.asList(fUnits));
81
//			IStatus result = tool.run(SubMonitor.convert(monitor, 1));
82
//			if (result.matches(IStatus.ERROR))
83
//				throw new ProvisionException(result);
84
//			fLocations = new File[] {fInstallDir};
85
//		} catch (ProvisionException e) {
86
//			throw new InvocationTargetException(e);
87
//		}
88
89
		// Use the iu's to create resolved bundles
90
		return new IResolvedBundle[0];
91
	}
92
}

Return to bug 270626