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/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/EditBundleContainerWizard.java (-7 / +5 lines)
Lines 4-20 Link Here
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;
8
import org.eclipse.pde.internal.ui.PDEPlugin;
7
import org.eclipse.pde.internal.ui.PDEPlugin;
9
8
10
public class EditBundleContainerWizard extends Wizard {
9
public class EditBundleContainerWizard extends Wizard {
11
10
12
	private ITargetDefinition fTarget;
13
	private IBundleContainer fContainer;
11
	private IBundleContainer fContainer;
14
	private EditDirectoryContainerPage fPage;
12
	private EditDirectoryContainerPage fPage;
15
13
16
	public EditBundleContainerWizard(ITargetDefinition target, IBundleContainer container) {
14
	public EditBundleContainerWizard(IBundleContainer container) {
17
		fTarget = target;
18
		fContainer = container;
15
		fContainer = container;
19
		IDialogSettings settings = PDEPlugin.getDefault().getDialogSettings().getSection(AddBundleContainerSelectionPage.SETTINGS_SECTION);
16
		IDialogSettings settings = PDEPlugin.getDefault().getDialogSettings().getSection(AddBundleContainerSelectionPage.SETTINGS_SECTION);
20
		if (settings == null) {
17
		if (settings == null) {
Lines 26-44 Link Here
26
23
27
	public void addPages() {
24
	public void addPages() {
28
		if (fContainer instanceof DirectoryBundleContainer) {
25
		if (fContainer instanceof DirectoryBundleContainer) {
29
			fPage = new EditDirectoryContainerPage(fTarget, fContainer);
26
			fPage = new EditDirectoryContainerPage(fContainer);
30
			addPage(fPage);
27
			addPage(fPage);
31
		} else if (fContainer instanceof ProfileBundleContainer) {
28
		} else if (fContainer instanceof ProfileBundleContainer) {
32
			fPage = new EditProfileContainerPage(fTarget, fContainer);
29
			fPage = new EditProfileContainerPage(fContainer);
33
			addPage(fPage);
30
			addPage(fPage);
34
		} else if (fContainer instanceof FeatureBundleContainer) {
31
		} else if (fContainer instanceof FeatureBundleContainer) {
35
			fPage = new EditFeatureContainerPage(fTarget, fContainer);
32
			fPage = new EditFeatureContainerPage(fContainer);
36
			addPage(fPage);
33
			addPage(fPage);
37
		}
34
		}
38
	}
35
	}
39
36
40
	public boolean performFinish() {
37
	public boolean performFinish() {
41
		if (fPage != null) {
38
		if (fPage != null) {
39
			fPage.storeSettings();
42
			fContainer = fPage.getBundleContainer();
40
			fContainer = fPage.getBundleContainer();
43
			return true;
41
			return true;
44
		}
42
		}
(-)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 (-4 / +3 lines)
Lines 3-9 Link Here
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;
7
import org.eclipse.pde.internal.ui.PDEPlugin;
6
import org.eclipse.pde.internal.ui.PDEPlugin;
8
import org.eclipse.pde.internal.ui.SWTFactory;
7
import org.eclipse.pde.internal.ui.SWTFactory;
9
import org.eclipse.swt.SWT;
8
import org.eclipse.swt.SWT;
Lines 13-20 Link Here
13
12
14
public class EditFeatureContainerPage extends EditDirectoryContainerPage {
13
public class EditFeatureContainerPage extends EditDirectoryContainerPage {
15
14
16
	public EditFeatureContainerPage(ITargetDefinition target, IBundleContainer container) {
15
	public EditFeatureContainerPage(IBundleContainer container) {
17
		super(target, container);
16
		super(container);
18
	}
17
	}
19
18
20
	/* (non-Javadoc)
19
	/* (non-Javadoc)
Lines 80-86 Link Here
80
	/* (non-Javadoc)
79
	/* (non-Javadoc)
81
	 * @see org.eclipse.pde.internal.ui.shared.target.EditDirectoryContainerPage#refreshContainer(org.eclipse.pde.internal.core.target.provisional.IBundleContainer)
80
	 * @see org.eclipse.pde.internal.ui.shared.target.EditDirectoryContainerPage#refreshContainer(org.eclipse.pde.internal.core.target.provisional.IBundleContainer)
82
	 */
81
	 */
83
	protected IBundleContainer refreshContainer(IBundleContainer previous) throws CoreException {
82
	protected IBundleContainer createContainer(IBundleContainer previous) throws CoreException {
84
		return getBundleContainer();
83
		return getBundleContainer();
85
	}
84
	}
86
85
(-)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/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/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/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 1698-1708 Link Here
1698
OverviewPage_extensionPageMessageTitle=Extension pages hidden
1698
OverviewPage_extensionPageMessageTitle=Extension pages hidden
1699
OverviewPage_extensionPageMessageBody=The Extension and Extension Point pages are currently hidden, would you like to display them now?
1699
OverviewPage_extensionPageMessageBody=The Extension and Extension Point pages are currently hidden, would you like to display them now?
1700
OverviewPage_environmentDescription=<form>\
1700
OverviewPage_environmentDescription=<form>\
1701
<p>The <a href="environment">Environment</a> section contains the following environment and setup information:</p>\
1701
<p>The <a href="environment">Environment</a> section contains additional settings including: locale, operating system, java runtime, arguments and implicit dependencies.</p>\
1702
<li>Environment settings including locale, processor architecture, operating system and windowing system.</li>\
1703
<li>Java runtime environment.</li>\
1704
<li>Program and VM arguments.</li>\
1705
<li>Implicit plug-ins, which should always be taken into account when calculating dependencies.</li>\
1706
</form>
1702
</form>
1707
OverviewPage_fExtensionContent=<form>\
1703
OverviewPage_fExtensionContent=<form>\
1708
<p>This fragment may define extensions and extension points:</p>\
1704
<p>This fragment may define extensions and extension points:</p>\
Lines 1710-1717 Link Here
1710
<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>\
1706
<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>\
1711
</form>
1707
</form>
1712
OverviewPage_contentDescription=<form>\
1708
OverviewPage_contentDescription=<form>\
1713
<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>\
1709
<p>The <a href="content">Content</a> section specifies the set of plug-ins that will be included in the target platform.</p>\
1714
<p>An option is also available to simply include all plug-ins from the specified locations into the target platform.</p>\
1715
</form>
1710
</form>
1716
OverviewPage_buildTitle=Build Configuration
1711
OverviewPage_buildTitle=Build Configuration
1717
ClassAttributeRow_dialogTitle=Select Type
1712
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 (+77 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(), null, 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, Object source, boolean resolve) {
336
			if (!resolve || definition.isResolved()) {
337
				if (fContentTree != null && source != fContentTree) {
338
					fContentTree.setInput(getTarget());
339
				}
340
				if (fLocationTree != null && source != fLocationTree) {
341
					fLocationTree.setInput(getTarget());
342
				}
343
			} else {
344
				if (fContentTree != null) {
345
					fContentTree.setEnabled(false);
346
				}
347
				if (fLocationTree != null) {
348
					fLocationTree.setInput(null);
349
				}
350
				// TODO Cancel any other started jobs? Bad if we do this every time a checkbox changes
351
				Job resolveJob = new Job("Resolving Target") {
352
					protected IStatus run(IProgressMonitor monitor) {
353
						getTarget().resolve(monitor);
354
						if (monitor.isCanceled()) {
355
							return Status.CANCEL_STATUS;
356
						}
357
						// Don't return any problems because we don't want an error dialog
358
						return Status.OK_STATUS;
359
					}
360
				};
361
				resolveJob.addJobChangeListener(new JobChangeAdapter() {
362
					public void done(org.eclipse.core.runtime.jobs.IJobChangeEvent event) {
363
						UIJob job = new UIJob("Refresh UI") {
364
							public IStatus runInUIThread(IProgressMonitor monitor) {
365
								if (fContentTree != null) {
366
									fContentTree.setInput(getTarget());
367
								}
368
								if (fLocationTree != null) {
369
									fLocationTree.setInput(getTarget());
370
								}
371
								return Status.OK_STATUS;
372
							}
373
						};
374
						job.setSystem(true);
375
						job.schedule();
376
					}
377
				});
378
				resolveJob.schedule();
379
			}
380
		}
381
	}
382
306
}
383
}
(-)src/org/eclipse/pde/internal/ui/editor/targetdefinition/ContentSection.java (-29 / +9 lines)
Lines 10-25 Link Here
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;
14
import org.eclipse.core.runtime.*;
15
import org.eclipse.core.runtime.jobs.Job;
16
import org.eclipse.jface.operation.IRunnableWithProgress;
17
import org.eclipse.pde.internal.core.target.provisional.ITargetDefinition;
13
import org.eclipse.pde.internal.core.target.provisional.ITargetDefinition;
18
import org.eclipse.pde.internal.ui.PDEPlugin;
19
import org.eclipse.pde.internal.ui.PDEUIMessages;
14
import org.eclipse.pde.internal.ui.PDEUIMessages;
20
import org.eclipse.pde.internal.ui.editor.FormLayoutFactory;
15
import org.eclipse.pde.internal.ui.editor.FormLayoutFactory;
21
import org.eclipse.pde.internal.ui.shared.target.BundleContainerTable;
16
import org.eclipse.pde.internal.ui.shared.target.ITargetChangedListener;
22
import org.eclipse.pde.internal.ui.shared.target.IBundleContainerTableReporter;
17
import org.eclipse.pde.internal.ui.shared.target.TargetContentsGroup;
23
import org.eclipse.swt.layout.GridData;
18
import org.eclipse.swt.layout.GridData;
24
import org.eclipse.swt.widgets.Composite;
19
import org.eclipse.swt.widgets.Composite;
25
import org.eclipse.ui.forms.SectionPart;
20
import org.eclipse.ui.forms.SectionPart;
Lines 33-39 Link Here
33
 */
28
 */
34
public class ContentSection extends SectionPart {
29
public class ContentSection extends SectionPart {
35
30
36
	private BundleContainerTable fTable;
31
	private TargetContentsGroup fContentGroup;
37
	private TargetEditor fEditor;
32
	private TargetEditor fEditor;
38
33
39
	public ContentSection(FormPage page, Composite parent) {
34
	public ContentSection(FormPage page, Composite parent) {
Lines 67-92 Link Here
67
		client.setLayout(FormLayoutFactory.createSectionClientGridLayout(false, 1));
62
		client.setLayout(FormLayoutFactory.createSectionClientGridLayout(false, 1));
68
		client.setLayoutData(new GridData(GridData.FILL_BOTH | GridData.GRAB_VERTICAL));
63
		client.setLayoutData(new GridData(GridData.FILL_BOTH | GridData.GRAB_VERTICAL));
69
64
70
		fTable = BundleContainerTable.createTableInForm(client, toolkit, new IBundleContainerTableReporter() {
65
		fContentGroup = new TargetContentsGroup(client, toolkit);
71
			public void runResolveOperation(final IRunnableWithProgress operation) {
66
		fEditor.getTargetChangedListener().setContentTree(fContentGroup);
72
				Job job = new Job(PDEUIMessages.TargetDefinitionContentPage_0) {
67
		fContentGroup.addTargetChangedListener(fEditor.getTargetChangedListener());
73
					protected IStatus run(IProgressMonitor monitor) {
68
		fContentGroup.addTargetChangedListener(new ITargetChangedListener() {
74
						try {
69
			public void contentsChanged(ITargetDefinition definition, Object source, boolean resolve) {
75
76
							operation.run(monitor);
77
							return Status.OK_STATUS;
78
						} catch (InvocationTargetException e) {
79
							return new Status(IStatus.ERROR, PDEPlugin.getPluginId(), PDEUIMessages.TargetDefinitionContentPage_5, e);
80
						} catch (InterruptedException e) {
81
							return Status.CANCEL_STATUS;
82
						}
83
					}
84
				};
85
				job.setUser(true);
86
				job.schedule();
87
			}
88
89
			public void contentsChanged() {
90
				markDirty();
70
				markDirty();
91
			}
71
			}
92
		});
72
		});
Lines 100-106 Link Here
100
	 * @see org.eclipse.ui.forms.AbstractFormPart#refresh()
80
	 * @see org.eclipse.ui.forms.AbstractFormPart#refresh()
101
	 */
81
	 */
102
	public void refresh() {
82
	public void refresh() {
103
		fTable.setInput(getTarget());
83
		fContentGroup.setInput(getTarget());
104
		super.refresh();
84
		super.refresh();
105
	}
85
	}
106
86
(-)src/org/eclipse/pde/internal/ui/editor/targetdefinition/DefinitionPage.java (-6 / +72 lines)
Lines 10-35 Link Here
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.jface.action.IStatusLineManager;
13
import org.eclipse.pde.internal.core.target.provisional.ITargetDefinition;
14
import org.eclipse.pde.internal.core.target.provisional.ITargetDefinition;
14
import org.eclipse.pde.internal.ui.*;
15
import org.eclipse.pde.internal.ui.*;
15
import org.eclipse.pde.internal.ui.editor.FormLayoutFactory;
16
import org.eclipse.pde.internal.ui.editor.FormLayoutFactory;
17
import org.eclipse.pde.internal.ui.editor.target.ContentPage;
18
import org.eclipse.pde.internal.ui.editor.target.EnvironmentPage;
19
import org.eclipse.swt.SWT;
20
import org.eclipse.swt.SWTException;
21
import org.eclipse.swt.layout.GridData;
16
import org.eclipse.swt.widgets.Composite;
22
import org.eclipse.swt.widgets.Composite;
17
import org.eclipse.ui.PlatformUI;
23
import org.eclipse.ui.PlatformUI;
18
import org.eclipse.ui.forms.IManagedForm;
24
import org.eclipse.ui.forms.IManagedForm;
19
import org.eclipse.ui.forms.editor.FormPage;
25
import org.eclipse.ui.forms.editor.FormPage;
20
import org.eclipse.ui.forms.widgets.FormToolkit;
26
import org.eclipse.ui.forms.events.HyperlinkEvent;
21
import org.eclipse.ui.forms.widgets.ScrolledForm;
27
import org.eclipse.ui.forms.events.IHyperlinkListener;
28
import org.eclipse.ui.forms.widgets.*;
22
29
23
/**
30
/**
24
 * First page in the target definition editor.  Allows for editing of the name,
31
 * First page in the target definition editor.  Allows for editing of the name,
25
 * description and content of the target.
32
 * description and content of the target.
26
 * @see TargetEditor
33
 * @see TargetEditor
27
 * @see InformationSection
34
 * @see InformationSection
28
 * @see ContentSection
35
 * @see LocationSection
29
 */
36
 */
30
public class DefinitionPage extends FormPage {
37
public class DefinitionPage extends FormPage implements IHyperlinkListener {
31
38
32
	public static final String PAGE_ID = "overview"; //$NON-NLS-1$
39
	public static final String PAGE_ID = "definition"; //$NON-NLS-1$
33
40
34
	public DefinitionPage(TargetEditor editor) {
41
	public DefinitionPage(TargetEditor editor) {
35
		super(editor, PAGE_ID, PDEUIMessages.DefinitionPage_0);
42
		super(editor, PAGE_ID, PDEUIMessages.DefinitionPage_0);
Lines 73-79 Link Here
73
		Composite body = managedForm.getForm().getBody();
80
		Composite body = managedForm.getForm().getBody();
74
		body.setLayout(FormLayoutFactory.createFormGridLayout(true, 1));
81
		body.setLayout(FormLayoutFactory.createFormGridLayout(true, 1));
75
		managedForm.addPart(new InformationSection(this, body));
82
		managedForm.addPart(new InformationSection(this, body));
76
		managedForm.addPart(new ContentSection(this, body));
83
		managedForm.addPart(new LocationSection(this, body));
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);
77
	}
143
	}
78
144
79
	// TODO Hook up help toolbar action
145
	// TODO Hook up help toolbar action
(-)src/org/eclipse/pde/internal/ui/wizards/target/TargetDefinitionContentPage.java (-41 / +85 lines)
Lines 10-17 Link Here
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;
14
15
import java.lang.reflect.InvocationTargetException;
13
import java.lang.reflect.InvocationTargetException;
16
import java.util.*;
14
import java.util.*;
17
import java.util.List;
15
import java.util.List;
Lines 41-46 Link Here
41
import org.eclipse.swt.layout.GridData;
39
import org.eclipse.swt.layout.GridData;
42
import org.eclipse.swt.layout.GridLayout;
40
import org.eclipse.swt.layout.GridLayout;
43
import org.eclipse.swt.widgets.*;
41
import org.eclipse.swt.widgets.*;
42
import org.eclipse.ui.ISharedImages;
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
Lines 55-61 Link Here
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
	private TargetLocationsGroup fLocationTree;
60
	private TargetContentsGroup fContentTree;
59
61
60
	// Environment pull-downs
62
	// Environment pull-downs
61
	private Combo fOSCombo;
63
	private Combo fOSCombo;
Lines 125-169 Link Here
125
		TabFolder tabs = new TabFolder(comp, SWT.NONE);
127
		TabFolder tabs = new TabFolder(comp, SWT.NONE);
126
		tabs.setLayoutData(new GridData(GridData.FILL_BOTH));
128
		tabs.setLayoutData(new GridData(GridData.FILL_BOTH));
127
129
128
		TabItem pluginsTab = new TabItem(tabs, SWT.NONE);
130
		fLocationTab = new TabItem(tabs, SWT.NONE);
129
		pluginsTab.setText(PDEUIMessages.TargetDefinitionContentPage_6);
131
		fLocationTab.setText("Locations");
130
132
131
		Composite pluginTabContainer = SWTFactory.createComposite(tabs, 1, 1, GridData.FILL_BOTH);
133
		Composite pluginTabContainer = SWTFactory.createComposite(tabs, 1, 1, GridData.FILL_BOTH);
132
134
		SWTFactory.createWrapLabel(pluginTabContainer, "List of locations to look for plug-ins to add to this target.", 2, 400);
133
		SWTFactory.createWrapLabel(pluginTabContainer, PDEUIMessages.ContentSection_1, 2, 400);
135
		fLocationTree = TargetLocationsGroup.createInDialog(pluginTabContainer);
134
136
		fLocationTab.setControl(pluginTabContainer);
135
		fTable = BundleContainerTable.createTableInDialog(pluginTabContainer, new IBundleContainerTableReporter() {
137
136
			public void runResolveOperation(final IRunnableWithProgress operation) {
138
		TabItem contentTab = new TabItem(tabs, SWT.NONE);
137
				if (isControlCreated()) {
139
		contentTab.setText(PDEUIMessages.TargetDefinitionContentPage_6);
138
					try {
140
		Composite contentTabContainer = SWTFactory.createComposite(tabs, 1, 1, GridData.FILL_BOTH);
139
						getContainer().run(true, false, operation);
141
		SWTFactory.createWrapLabel(contentTabContainer, PDEUIMessages.ContentSection_1, 2, 400);
140
					} catch (InvocationTargetException e) {
142
		fContentTree = new TargetContentsGroup(contentTabContainer);
141
						PDEPlugin.log(e);
143
		contentTab.setControl(contentTabContainer);
142
					} catch (InterruptedException e) {
143
						// TODO Cancel the wizard?
144
					}
145
				} else {
146
					// If the page isn't open yet, try running a UI job so the dialog has time to finish opening
147
					new UIJob(PDEUIMessages.TargetDefinitionContentPage_0) {
148
						public IStatus runInUIThread(IProgressMonitor monitor) {
149
							try {
150
								getContainer().run(true, false, operation);
151
								return Status.OK_STATUS;
152
							} catch (InvocationTargetException e) {
153
								return new Status(IStatus.ERROR, PDEPlugin.getPluginId(), PDEUIMessages.TargetDefinitionContentPage_5, e);
154
							} catch (InterruptedException e) {
155
								return Status.CANCEL_STATUS;
156
							}
157
						}
158
					}.schedule();
159
				}
160
			}
161
162
			public void contentsChanged() {
163
				// Do nothing, as wizard will always save when finish is pressed
164
			}
165
		});
166
		pluginsTab.setControl(pluginTabContainer);
167
144
168
		TabItem envTab = new TabItem(tabs, SWT.NONE);
145
		TabItem envTab = new TabItem(tabs, SWT.NONE);
169
		envTab.setText(PDEUIMessages.TargetDefinitionEnvironmentPage_3);
146
		envTab.setText(PDEUIMessages.TargetDefinitionEnvironmentPage_3);
Lines 180-189 Link Here
180
		depTab.setText(PDEUIMessages.TargetDefinitionEnvironmentPage_5);
157
		depTab.setText(PDEUIMessages.TargetDefinitionEnvironmentPage_5);
181
		depTab.setControl(createImplicitTabContents(tabs));
158
		depTab.setControl(createImplicitTabContents(tabs));
182
159
160
		initializeListeners();
183
		targetChanged(getTargetDefinition());
161
		targetChanged(getTargetDefinition());
184
		setControl(comp);
162
		setControl(comp);
185
	}
163
	}
186
164
165
	private void initializeListeners() {
166
		ITargetChangedListener listener = new ITargetChangedListener() {
167
			public void contentsChanged(ITargetDefinition definition, Object source, boolean resolve) {
168
				if (resolve && definition.isResolved()) {
169
					try {
170
						getContainer().run(true, true, new IRunnableWithProgress() {
171
							public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
172
								getTargetDefinition().resolve(monitor);
173
								if (monitor.isCanceled()) {
174
									throw new InterruptedException();
175
								}
176
							}
177
						});
178
					} catch (InvocationTargetException e) {
179
						PDECore.log(e);
180
					} catch (InterruptedException e) {
181
						// Do nothing, op cancelled
182
					}
183
				}
184
				if (fContentTree != source) {
185
					fContentTree.setInput(definition);
186
				}
187
				if (fLocationTree != source) {
188
					fLocationTree.setInput(definition);
189
				}
190
				if (definition.isResolved() && definition.getBundleStatus().getSeverity() == IStatus.ERROR) {
191
					fLocationTab.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_ERROR_TSK));
192
				} else {
193
					fLocationTab.setImage(null);
194
				}
195
			}
196
		};
197
		fContentTree.addTargetChangedListener(listener);
198
		fLocationTree.addTargetChangedListener(listener);
199
		// When  If the page isn't open yet, try running a UI job so the dialog has time to finish opening
200
		new UIJob(PDEUIMessages.TargetDefinitionContentPage_0) {
201
			public IStatus runInUIThread(IProgressMonitor monitor) {
202
				try {
203
					getContainer().run(true, true, new IRunnableWithProgress() {
204
						public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
205
							getTargetDefinition().resolve(monitor);
206
							if (monitor.isCanceled()) {
207
								throw new InterruptedException();
208
							}
209
						}
210
					});
211
				} catch (InvocationTargetException e) {
212
					PDECore.log(e);
213
				} catch (InterruptedException e) {
214
					return Status.CANCEL_STATUS;
215
				}
216
				ITargetDefinition definition = getTargetDefinition();
217
				fContentTree.setInput(definition);
218
				fLocationTree.setInput(definition);
219
				if (definition.isResolved() && definition.getBundleStatus().getSeverity() == IStatus.ERROR) {
220
					fLocationTab.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_ERROR_TSK));
221
				} else {
222
					fLocationTab.setImage(null);
223
				}
224
				return Status.OK_STATUS;
225
			}
226
		}.schedule();
227
228
	}
229
187
	/* (non-Javadoc)
230
	/* (non-Javadoc)
188
	 * @see org.eclipse.pde.internal.ui.wizards.target.TargetDefinitionPage#targetChanged()
231
	 * @see org.eclipse.pde.internal.ui.wizards.target.TargetDefinitionPage#targetChanged()
189
	 */
232
	 */
Lines 200-206 Link Here
200
			else
243
			else
201
				setMessage(PDEUIMessages.TargetDefinitionContentPage_8);
244
				setMessage(PDEUIMessages.TargetDefinitionContentPage_8);
202
245
203
			fTable.setInput(definition);
246
			fLocationTree.setInput(definition);
247
			fContentTree.setInput(definition);
204
248
205
			String presetValue = (definition.getOS() == null) ? EMPTY_STRING : definition.getOS();
249
			String presetValue = (definition.getOS() == null) ? EMPTY_STRING : definition.getOS();
206
			fOSCombo.setText(presetValue);
250
			fOSCombo.setText(presetValue);
(-)src/org/eclipse/pde/internal/ui/shared/target/ITargetChangedListener.java (+36 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 source the ui part that changed the contents, used to avoid unnecessary refreshes
32
	 * @param resolve whether the definition must be resolved to catch up to all changes
33
	 */
34
	public void contentsChanged(ITargetDefinition definition, Object source, boolean resolve);
35
36
}
(-)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, Object source, 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 (+837 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.equinox.internal.provisional.frameworkadmin.BundleInfo;
10
import org.eclipse.jface.viewers.*;
11
import org.eclipse.pde.internal.core.target.provisional.*;
12
import org.eclipse.pde.internal.ui.SWTFactory;
13
import org.eclipse.pde.internal.ui.parts.ComboPart;
14
import org.eclipse.swt.SWT;
15
import org.eclipse.swt.events.SelectionAdapter;
16
import org.eclipse.swt.events.SelectionEvent;
17
import org.eclipse.swt.layout.GridData;
18
import org.eclipse.swt.layout.GridLayout;
19
import org.eclipse.swt.widgets.*;
20
import org.eclipse.ui.dialogs.FilteredTree;
21
import org.eclipse.ui.dialogs.PatternFilter;
22
import org.eclipse.ui.forms.widgets.FormToolkit;
23
import org.eclipse.ui.progress.UIJob;
24
import org.eclipse.ui.progress.WorkbenchJob;
25
26
public class TargetContentsGroup extends FilteredTree {
27
28
	private CheckboxTreeViewer fTree;
29
	private Button fSelectButton;
30
	private Button fDeselectButton;
31
	private Button fSelectAllButton;
32
	private Button fDeselectAllButton;
33
//	private Button fSelectRequiredButton;
34
	private Label fShowLabel;
35
	private Button fShowSourceButton;
36
	private Button fShowPluginsButton;
37
	private Label fCountLabel;
38
	private Label fGroupLabel;
39
	private Combo fGroupCombo;
40
	private ComboPart fGroupComboPart;
41
42
	private ViewerFilter fSourceFilter;
43
	private ViewerFilter fPluginFilter;
44
45
	/*
46
	 * TODO This could likely be done better with fewer datastructures by using a 
47
	 * similar structure to FilteredCheckboxTree.  Instead of storing resolved bundles
48
	 * store a special object which remembers it's check state.
49
	 * 
50
	 * Also, for better visual performance we could try to replicate the styl eof the old
51
	 * preference page, which created a table and a tree and simply made the appropriate one
52
	 * visible (vs recreating all the tree items).
53
	 */
54
	private List fAllBundles;
55
	private Set fAllChecked;
56
	private Map fContainerBundles;
57
	private Map fContainerChecked;
58
	private Map fFileBundles;
59
	private Map fFileChecked;
60
61
	private ITargetDefinition fTargetDefinition;
62
63
	private FormToolkit fToolkit;
64
65
	private int fGrouping;
66
	private static final int GROUP_BY_NONE = 0;
67
	private static final int GROUP_BY_FILE_LOC = 1;
68
	private static final int GROUP_BY_CONTAINER = 2;
69
	private ListenerList fChangeListeners = new ListenerList();
70
71
	public TargetContentsGroup(Composite parent) {
72
		super(parent, SWT.BORDER | SWT.MULTI, new PatternFilter(), true);
73
	}
74
75
	public TargetContentsGroup(Composite parent, FormToolkit toolkit) {
76
		// Hack to setup the toolkit before creating the controls
77
		super(parent, SWT.NONE, null, true);
78
		fToolkit = toolkit;
79
		super.init(SWT.BORDER | SWT.MULTI, new PatternFilter());
80
	}
81
82
	/**
83
	 * Adds a listener to the set of listeners that will be notified when the bundle containers
84
	 * are modified.  This method has no effect if the listener has already been added. 
85
	 * 
86
	 * @param listener target changed listener to add
87
	 */
88
	public void addTargetChangedListener(ITargetChangedListener listener) {
89
		fChangeListeners.add(listener);
90
	}
91
92
	/**
93
	 * Informs the target content listeners that check state has changed
94
	 */
95
	public void contentChanged(Object[] changed) {
96
		Object[] listeners = fChangeListeners.getListeners();
97
		for (int i = 0; i < listeners.length; i++) {
98
			((ITargetChangedListener) listeners[i]).contentsChanged(fTargetDefinition, this, false);
99
		}
100
	}
101
102
	/* (non-Javadoc)
103
	 * @see org.eclipse.ui.dialogs.FilteredTree#init(int, org.eclipse.ui.dialogs.PatternFilter)
104
	 */
105
	protected void init(int treeStyle, PatternFilter filter) {
106
		// Overridden to do nothing to avoid creating the controls when we don't have a form toolkit
107
	}
108
109
	/* (non-Javadoc)
110
	 * @see org.eclipse.ui.dialogs.FilteredTree#createTreeControl(org.eclipse.swt.widgets.Composite, int)
111
	 */
112
	protected Control createTreeControl(Composite parent, int style) {
113
		fGrouping = GROUP_BY_NONE;
114
		Composite treeComp = null;
115
		if (fToolkit != null) {
116
			treeComp = fToolkit.createComposite(parent);
117
			GridLayout layout = new GridLayout(2, false);
118
			layout.marginWidth = layout.marginHeight = 0;
119
			treeComp.setLayout(layout);
120
			treeComp.setLayoutData(new GridData(GridData.FILL_BOTH));
121
		} else {
122
			treeComp = SWTFactory.createComposite(parent, 2, 1, GridData.FILL_BOTH, 0, 0);
123
		}
124
		super.createTreeControl(treeComp, style);
125
		((GridData) fTree.getControl().getLayoutData()).heightHint = 300;
126
		createButtons(treeComp);
127
		createOptions(treeComp);
128
129
		updateButtons();
130
		initializeFilters();
131
		return treeComp;
132
	}
133
134
	/* (non-Javadoc)
135
	 * @see org.eclipse.ui.dialogs.FilteredTree#doCreateRefreshJob()
136
	 */
137
	protected WorkbenchJob doCreateRefreshJob() {
138
		WorkbenchJob job = super.doCreateRefreshJob();
139
		job.addJobChangeListener(new JobChangeAdapter() {
140
			public void done(IJobChangeEvent event) {
141
				if (event.getResult().getSeverity() != IStatus.CANCEL) {
142
					fTree.expandAll();
143
					updateCheckState();
144
				}
145
			}
146
		});
147
		return job;
148
	}
149
150
	/* (non-Javadoc)
151
	 * @see org.eclipse.ui.dialogs.FilteredTree#doCreateTreeViewer(org.eclipse.swt.widgets.Composite, int)
152
	 */
153
	protected TreeViewer doCreateTreeViewer(Composite parent, int style) {
154
		Tree tree = null;
155
		if (fToolkit != null) {
156
			tree = fToolkit.createTree(parent, style);
157
		} else {
158
			tree = new Tree(parent, style);
159
		}
160
161
		fTree = new CheckboxTreeViewer(tree) {
162
			public void refresh(boolean updateLabels) {
163
				super.refresh(updateLabels);
164
				if (updateLabels) {
165
					// We want to update the labels and buttons as users change the filtering
166
					updateButtons();
167
				}
168
			}
169
		};
170
		fTree.setContentProvider(new TreeContentProvider());
171
		fTree.setLabelProvider(new BundleContainerLabelProvider());
172
		fTree.addDoubleClickListener(new IDoubleClickListener() {
173
			public void doubleClick(DoubleClickEvent event) {
174
				IStructuredSelection selection = (IStructuredSelection) event.getSelection();
175
				Object first = selection.getFirstElement();
176
				handleCheck(new Object[] {selection.getFirstElement()}, !fTree.getChecked(first));
177
			}
178
		});
179
		fTree.addCheckStateListener(new ICheckStateListener() {
180
			public void checkStateChanged(CheckStateChangedEvent event) {
181
				handleCheck(new Object[] {event.getElement()}, fTree.getChecked(event.getElement()));
182
			}
183
		});
184
		fTree.addSelectionChangedListener(new ISelectionChangedListener() {
185
			public void selectionChanged(SelectionChangedEvent event) {
186
				updateButtons();
187
			}
188
		});
189
		fTree.setSorter(new ViewerSorter() {
190
			public int compare(Viewer viewer, Object e1, Object e2) {
191
				if (e1 instanceof IResolvedBundle && e2 instanceof IResolvedBundle) {
192
					IStatus status1 = ((IResolvedBundle) e1).getStatus();
193
					IStatus status2 = ((IResolvedBundle) e2).getStatus();
194
					if (!status1.isOK() && status2.isOK()) {
195
						return -1;
196
					}
197
					if (status1.isOK() && !status2.isOK()) {
198
						return 1;
199
					}
200
				}
201
				return super.compare(viewer, e1, e2);
202
			}
203
204
		});
205
		return fTree;
206
	}
207
208
	/* (non-Javadoc)
209
	 * @see org.eclipse.ui.dialogs.FilteredTree#doCreateFilterText(org.eclipse.swt.widgets.Composite)
210
	 */
211
	protected Text doCreateFilterText(Composite parent) {
212
		if (fToolkit != null) {
213
			return fToolkit.createText(parent, null, SWT.SINGLE | SWT.BORDER | SWT.SEARCH | SWT.ICON_CANCEL);
214
		}
215
		return new Text(parent, SWT.SINGLE | SWT.BORDER | SWT.SEARCH | SWT.ICON_CANCEL);
216
	}
217
218
	private void createButtons(Composite parent) {
219
		if (fToolkit != null) {
220
			Composite buttonComp = fToolkit.createComposite(parent);
221
			GridLayout layout = new GridLayout();
222
			layout.marginWidth = layout.marginHeight = 0;
223
			buttonComp.setLayout(layout);
224
			buttonComp.setLayoutData(new GridData(GridData.FILL_VERTICAL));
225
226
			fSelectButton = fToolkit.createButton(buttonComp, Messages.IncludedBundlesTree_0, SWT.PUSH);
227
			fDeselectButton = fToolkit.createButton(buttonComp, Messages.IncludedBundlesTree_1, SWT.PUSH);
228
229
			Label emptySpace = new Label(parent, SWT.NONE);
230
			GridData gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
231
			gd.widthHint = gd.heightHint = 5;
232
			emptySpace.setLayoutData(gd);
233
234
			fSelectAllButton = fToolkit.createButton(buttonComp, Messages.IncludedBundlesTree_2, SWT.PUSH);
235
			fDeselectAllButton = fToolkit.createButton(buttonComp, Messages.IncludedBundlesTree_3, SWT.PUSH);
236
237
			Composite filterComp = fToolkit.createComposite(parent);
238
			layout = new GridLayout();
239
			layout.marginWidth = layout.marginHeight = 0;
240
			filterComp.setLayout(layout);
241
			filterComp.setLayoutData(new GridData(SWT.LEFT, SWT.BOTTOM, true, true));
242
243
			fShowLabel = fToolkit.createLabel(filterComp, Messages.BundleContainerTable_9);
244
245
			fShowPluginsButton = fToolkit.createButton(filterComp, Messages.BundleContainerTable_14, SWT.CHECK);
246
			fShowPluginsButton.setSelection(true);
247
			fShowSourceButton = fToolkit.createButton(filterComp, Messages.BundleContainerTable_15, SWT.CHECK);
248
			fShowSourceButton.setSelection(true);
249
		} else {
250
			Composite buttonComp = SWTFactory.createComposite(parent, 1, 1, GridData.FILL_VERTICAL, 0, 0);
251
			fSelectButton = SWTFactory.createPushButton(buttonComp, Messages.IncludedBundlesTree_0, null);
252
			fDeselectButton = SWTFactory.createPushButton(buttonComp, Messages.IncludedBundlesTree_1, null);
253
254
			Label emptySpace = new Label(parent, SWT.NONE);
255
			GridData gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
256
			gd.widthHint = gd.heightHint = 5;
257
			emptySpace.setLayoutData(gd);
258
259
			fSelectAllButton = SWTFactory.createPushButton(buttonComp, Messages.IncludedBundlesTree_2, null);
260
			fDeselectAllButton = SWTFactory.createPushButton(buttonComp, Messages.IncludedBundlesTree_3, null);
261
262
			Composite filterComp = SWTFactory.createComposite(buttonComp, 1, 1, SWT.NONE, 0, 0);
263
			filterComp.setLayoutData(new GridData(SWT.LEFT, SWT.BOTTOM, true, true));
264
265
			fShowLabel = SWTFactory.createLabel(filterComp, Messages.BundleContainerTable_9, 1);
266
267
			fShowPluginsButton = SWTFactory.createCheckButton(filterComp, Messages.BundleContainerTable_14, null, true, 1);
268
			fShowSourceButton = SWTFactory.createCheckButton(filterComp, Messages.BundleContainerTable_15, null, true, 1);
269
		}
270
271
		fSelectButton.addSelectionListener(new SelectionAdapter() {
272
			public void widgetSelected(SelectionEvent e) {
273
				if (!fTree.getSelection().isEmpty()) {
274
					Object[] selected = ((IStructuredSelection) fTree.getSelection()).toArray();
275
					handleCheck(selected, true);
276
				}
277
			}
278
		});
279
280
		fDeselectButton.addSelectionListener(new SelectionAdapter() {
281
			public void widgetSelected(SelectionEvent e) {
282
				if (!fTree.getSelection().isEmpty()) {
283
					Object[] selected = ((IStructuredSelection) fTree.getSelection()).toArray();
284
					handleCheck(selected, false);
285
				}
286
			}
287
		});
288
289
		fSelectAllButton.addSelectionListener(new SelectionAdapter() {
290
			public void widgetSelected(SelectionEvent e) {
291
				Object[] elements = ((ITreeContentProvider) fTree.getContentProvider()).getElements(fTree.getInput());
292
				handleCheck(elements, true);
293
			}
294
		});
295
296
		fDeselectAllButton.addSelectionListener(new SelectionAdapter() {
297
			public void widgetSelected(SelectionEvent e) {
298
				Object[] elements = ((ITreeContentProvider) fTree.getContentProvider()).getElements(fTree.getInput());
299
				handleCheck(elements, false);
300
			}
301
		});
302
303
		fShowPluginsButton.addSelectionListener(new SelectionAdapter() {
304
			public void widgetSelected(SelectionEvent e) {
305
				if (!fShowPluginsButton.getSelection()) {
306
					fTree.addFilter(fPluginFilter);
307
				} else {
308
					fTree.removeFilter(fPluginFilter);
309
					fTree.expandAll();
310
					updateCheckState();
311
				}
312
				updateButtons();
313
			}
314
		});
315
		fShowPluginsButton.setSelection(true);
316
		GridData gd = new GridData();
317
		gd.horizontalIndent = 10;
318
		fShowPluginsButton.setLayoutData(gd);
319
320
		fShowSourceButton.addSelectionListener(new SelectionAdapter() {
321
			public void widgetSelected(SelectionEvent e) {
322
				if (!fShowSourceButton.getSelection()) {
323
					fTree.addFilter(fSourceFilter);
324
				} else {
325
					fTree.removeFilter(fSourceFilter);
326
					fTree.expandAll();
327
					updateCheckState();
328
				}
329
				updateButtons();
330
			}
331
		});
332
		fShowSourceButton.setSelection(true);
333
		gd = new GridData();
334
		gd.horizontalIndent = 10;
335
		fShowSourceButton.setLayoutData(gd);
336
	}
337
338
	private void createOptions(Composite parent) {
339
		if (fToolkit != null) {
340
			Composite comp = fToolkit.createComposite(parent);
341
			GridLayout layout = new GridLayout(2, false);
342
			layout.marginWidth = layout.marginHeight = 0;
343
			comp.setLayout(layout);
344
			GridData data = new GridData(GridData.FILL_HORIZONTAL);
345
			data.horizontalSpan = 2;
346
			comp.setLayoutData(data);
347
348
			fGroupLabel = fToolkit.createLabel(comp, "Group by:");
349
350
			fGroupComboPart = new ComboPart();
351
			fGroupComboPart.createControl(comp, fToolkit, SWT.SINGLE | SWT.BORDER | SWT.READ_ONLY);
352
			fGroupComboPart.getControl().setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
353
			fGroupComboPart.setItems(new String[] {"None", "File Path", "Plug-in Container"});
354
			fGroupComboPart.setVisibleItemCount(30);
355
			fGroupComboPart.addSelectionListener(new SelectionAdapter() {
356
				public void widgetSelected(SelectionEvent e) {
357
					handleGroupChange();
358
				}
359
			});
360
361
			fCountLabel = fToolkit.createLabel(comp, ""); //$NON-NLS-1$
362
			data = new GridData();
363
			data.horizontalSpan = 2;
364
			fCountLabel.setLayoutData(data);
365
366
		} else {
367
			Composite comp = SWTFactory.createComposite(parent, 2, 2, GridData.FILL_HORIZONTAL, 0, 0);
368
369
			fGroupLabel = SWTFactory.createLabel(comp, "Group by:", 1);
370
			fGroupCombo = SWTFactory.createCombo(comp, SWT.READ_ONLY, 1, new String[] {"None", "File Path", "Plug-in Container"});
371
			fGroupCombo.addSelectionListener(new SelectionAdapter() {
372
				public void widgetSelected(SelectionEvent e) {
373
					handleGroupChange();
374
				}
375
			});
376
377
			fCountLabel = SWTFactory.createLabel(comp, "", 2); //$NON-NLS-1$
378
		}
379
	}
380
381
	private void initializeFilters() {
382
		fSourceFilter = new ViewerFilter() {
383
			public boolean select(Viewer viewer, Object parentElement, Object element) {
384
				if (element instanceof IResolvedBundle) {
385
					if (((IResolvedBundle) element).isSourceBundle()) {
386
						return false;
387
					}
388
				}
389
				return true;
390
			}
391
		};
392
		fPluginFilter = new ViewerFilter() {
393
			public boolean select(Viewer viewer, Object parentElement, Object element) {
394
				if (element instanceof IResolvedBundle) {
395
					if (!((IResolvedBundle) element).isSourceBundle()) {
396
						return false;
397
					}
398
				}
399
				return true;
400
			}
401
		};
402
	}
403
404
	private IPath getParentPath(IResolvedBundle bundle) {
405
		URI location = bundle.getBundleInfo().getLocation();
406
		if (location == null) {
407
			return new Path("Unknown");
408
		}
409
		IPath path = new Path(URIUtil.toUnencodedString(location));
410
		path = path.removeLastSegments(1);
411
		return path;
412
	}
413
414
	private void handleCheck(Object[] changedElements, boolean checkState) {
415
		if (changedElements.length > 0) {
416
			if (changedElements[0] instanceof IResolvedBundle) {
417
				Set changedContainers = new HashSet();
418
				Set changedFiles = new HashSet();
419
				for (int i = 0; i < changedElements.length; i++) {
420
					Object parent = ((IResolvedBundle) changedElements[i]).getParentContainer();
421
					changedContainers.add(parent);
422
					Set containerChecked = ((Set) fContainerChecked.get(parent));
423
424
					parent = getParentPath((IResolvedBundle) changedElements[i]);
425
					changedFiles.add(parent);
426
					Set fileChecked = ((Set) fFileChecked.get(parent));
427
428
					if (checkState) {
429
						fAllChecked.add(changedElements[i]);
430
						containerChecked.add(changedElements[i]);
431
						fileChecked.add(changedElements[i]);
432
					} else {
433
						fAllChecked.remove(changedElements[i]);
434
						containerChecked.remove(changedElements[i]);
435
						fileChecked.remove(changedElements[i]);
436
					}
437
					fTree.setChecked(changedElements[i], checkState);
438
				}
439
				if (fGrouping != GROUP_BY_NONE) {
440
					Iterator iterator = fGrouping == GROUP_BY_CONTAINER ? changedContainers.iterator() : changedFiles.iterator();
441
					while (iterator.hasNext()) {
442
						Object parent = iterator.next();
443
						if (getChecked(parent).size() == 0) {
444
							fTree.setGrayChecked(parent, false);
445
						} else if (getChecked(parent).size() == getBundleChildren(parent).size()) {
446
							fTree.setGrayed(parent, false);
447
							fTree.setChecked(parent, true);
448
						} else {
449
							fTree.setGrayChecked(parent, true);
450
						}
451
					}
452
				}
453
				saveIncludedBundleState(changedContainers.toArray());
454
			} else {
455
				Set totalChanged = new HashSet();
456
				for (int i = 0; i < changedElements.length; i++) {
457
					fTree.setGrayed(changedElements[i], false);
458
					fTree.setChecked(changedElements[i], checkState);
459
					fTree.setSubtreeChecked(changedElements[i], checkState);
460
461
					Set checked;
462
					List all;
463
					if (fGrouping == GROUP_BY_CONTAINER) {
464
						checked = (Set) fContainerChecked.get(changedElements[i]);
465
						all = (List) fContainerBundles.get(changedElements[i]);
466
					} else {
467
						checked = (Set) fFileChecked.get(changedElements[i]);
468
						all = (List) fFileBundles.get(changedElements[i]);
469
					}
470
					if (checkState) {
471
						checked.addAll(all);
472
					} else {
473
						checked.removeAll(all);
474
					}
475
					totalChanged.addAll(all);
476
				}
477
				// Update the maps that we are not currently displaying
478
				Iterator iterator = fGrouping == GROUP_BY_CONTAINER ? fFileChecked.values().iterator() : fContainerChecked.values().iterator();
479
				while (iterator.hasNext()) {
480
					Set current = (Set) iterator.next();
481
					if (checkState) {
482
						current.addAll(totalChanged);
483
					} else {
484
						current.removeAll(totalChanged);
485
					}
486
				}
487
				if (checkState) {
488
					fAllChecked.addAll(totalChanged);
489
				} else {
490
					fAllChecked.removeAll(totalChanged);
491
				}
492
				if (fGrouping == GROUP_BY_CONTAINER) {
493
					saveIncludedBundleState(changedElements);
494
				} else {
495
					// Easier to just save everything than loop through every bundle that changed and find its parent
496
					saveIncludedBundleState(fTargetDefinition.getBundleContainers());
497
				}
498
			}
499
			contentChanged(changedElements);
500
			updateButtons();
501
			// Update the parent container labels with the new count
502
			if (fGrouping == GROUP_BY_CONTAINER) {
503
				fTree.update(fContainerBundles.keySet().toArray(), new String[] {IBasicPropertyConstants.P_TEXT});
504
			}
505
		}
506
	}
507
508
	private void handleGroupChange() {
509
		int index;
510
		if (fGroupCombo != null) {
511
			index = fGroupCombo.getSelectionIndex();
512
		} else {
513
			index = fGroupComboPart.getSelectionIndex();
514
		}
515
		if (index != fGrouping) {
516
			fGrouping = fGroupCombo.getSelectionIndex();
517
			fTree.refresh(false);
518
			fTree.expandAll();
519
			updateCheckState();
520
			updateButtons();
521
		}
522
	}
523
524
	private void updateCheckState() {
525
		for (Iterator iterator = fAllChecked.iterator(); iterator.hasNext();) {
526
			fTree.setChecked(iterator.next(), true);
527
		}
528
		if (fGrouping != GROUP_BY_NONE) {
529
			Map bundleMap = null;
530
			Map checkedMap = null;
531
			if (fGrouping == GROUP_BY_CONTAINER) {
532
				bundleMap = fContainerBundles;
533
				checkedMap = fContainerChecked;
534
			} else if (fGrouping == GROUP_BY_FILE_LOC) {
535
				bundleMap = fFileBundles;
536
				checkedMap = fFileChecked;
537
			}
538
			for (Iterator iterator = bundleMap.keySet().iterator(); iterator.hasNext();) {
539
				Object currentParent = iterator.next();
540
				Set checked = (Set) checkedMap.get(currentParent);
541
				if (checked.size() == 0) {
542
					fTree.setGrayed(currentParent, false);
543
					fTree.setChecked(currentParent, false);
544
				} else if (checked.size() == ((List) bundleMap.get(currentParent)).size()) {
545
					fTree.setGrayed(currentParent, false);
546
					fTree.setChecked(currentParent, true);
547
				} else {
548
					fTree.setGrayChecked(currentParent, true);
549
				}
550
			}
551
		}
552
553
	}
554
555
	private void updateButtons() {
556
		if (fTargetDefinition != null && !fTree.getSelection().isEmpty()) {
557
			Object[] selection = ((IStructuredSelection) fTree.getSelection()).toArray();
558
			boolean hasResolveBundle = false;
559
			boolean hasParent = false;
560
			boolean allSelected = true;
561
			boolean noneSelected = true;
562
			for (int i = 0; i < selection.length; i++) {
563
				if (!hasResolveBundle || !hasParent) {
564
					if (selection[i] instanceof IResolvedBundle) {
565
						hasResolveBundle = true;
566
					} else {
567
						hasParent = true;
568
					}
569
				}
570
				boolean checked = fTree.getChecked(selection[i]);
571
				if (checked) {
572
					noneSelected = false;
573
				} else {
574
					allSelected = false;
575
				}
576
			}
577
			// Selection is available is not everything is already selected and not both a parent and child item are selected
578
			fSelectButton.setEnabled(!allSelected && !(hasResolveBundle && hasParent));
579
			fDeselectButton.setEnabled(!noneSelected && !(hasResolveBundle && hasParent));
580
//			fSelectRequiredButton.setEnabled(true);
581
		} else {
582
			fSelectButton.setEnabled(false);
583
			fDeselectButton.setEnabled(false);
584
//			fSelectRequiredButton.setEnabled(false);
585
		}
586
587
		fSelectAllButton.setEnabled(fTargetDefinition != null && fAllChecked.size() != fAllBundles.size());
588
		fDeselectAllButton.setEnabled(fTargetDefinition != null && fAllChecked.size() != 0);
589
590
		if (fTargetDefinition != null) {
591
			fCountLabel.setText(MessageFormat.format("{0} of {1} selected", new String[] {Integer.toString(fAllChecked.size()), Integer.toString(fAllBundles.size())}));
592
		} else {
593
			fCountLabel.setText(""); //$NON-NLS-1$
594
		}
595
	}
596
597
	/**
598
	 * Set the container to display in the tree or <code>null</code> to disable the tree 
599
	 * @param input bundle container or <code>null</code>
600
	 */
601
	public void setInput(ITargetDefinition input) {
602
		fTargetDefinition = input;
603
604
		if (input == null || !input.isResolved()) {
605
			fTree.setInput("Resolving...");
606
			setEnabled(false);
607
			return;
608
		}
609
610
		IResolvedBundle[] allResolvedBundles = input.getAllBundles();
611
		if (allResolvedBundles == null || allResolvedBundles.length == 0) {
612
			fTree.setInput("< no plug-ins found in the target >");
613
			setEnabled(false);
614
			return;
615
		}
616
617
		fTree.setInput("Initializing...");
618
		setEnabled(false);
619
		Job initJob = new InitalizeJob();
620
		initJob.addJobChangeListener(new JobChangeAdapter() {
621
			public void done(IJobChangeEvent event) {
622
				Job refreshJob = new UIJob("Refreshing Tree") {
623
					public IStatus runInUIThread(IProgressMonitor monitor) {
624
						fTree.setInput(fTargetDefinition);
625
						fTree.expandAll();
626
						updateCheckState();
627
						updateButtons();
628
						setEnabled(true);
629
						return Status.OK_STATUS;
630
					}
631
				};
632
				refreshJob.setSystem(true);
633
				refreshJob.schedule();
634
			}
635
		});
636
		initJob.schedule();
637
	}
638
639
	private class InitalizeJob extends Job {
640
641
		public InitalizeJob() {
642
			super("Initializing Tree");
643
			setSystem(true);
644
		}
645
646
		protected IStatus run(IProgressMonitor monitor) {
647
			fAllBundles = new ArrayList();
648
			fAllChecked = new HashSet();
649
			fContainerBundles = new HashMap();
650
			fContainerChecked = new HashMap();
651
			IBundleContainer[] containers = fTargetDefinition.getBundleContainers();
652
			// Iterate through each container, adding bundles to the map and list
653
			for (int i = 0; i < containers.length; i++) {
654
				Object[] containerBundlesArray = containers[i].getAllBundles();
655
				List containerBundles = new ArrayList(containerBundlesArray.length);
656
				for (int j = 0; j < containerBundlesArray.length; j++) {
657
					containerBundles.add(containerBundlesArray[j]);
658
				}
659
				fAllBundles.addAll(containerBundles);
660
				fContainerBundles.put(containers[i], containerBundles);
661
662
				// Determine which of the bundles are checked (included)
663
				if (containers[i].getIncludedBundles() == null) {
664
					// Everything is included
665
					Set checked = new HashSet();
666
					checked.addAll(containerBundles);
667
					fContainerChecked.put(containers[i], checked);
668
					fAllChecked.addAll(checked);
669
				} else {
670
					// Mark the included bundles as checked
671
					List includedBundles = Arrays.asList(containers[i].getBundles());
672
					// If an included bundle has errors it must be explicitly added to the bundle list as getAllBundles does not return it.
673
					for (Iterator iterator = includedBundles.iterator(); iterator.hasNext();) {
674
						IResolvedBundle currentIncluded = (IResolvedBundle) iterator.next();
675
						if (!currentIncluded.getStatus().isOK()) {
676
							((List) fContainerBundles.get(containers[i])).add(currentIncluded);
677
							fAllBundles.add(currentIncluded);
678
						}
679
					}
680
					Set checked = new HashSet();
681
					checked.addAll(includedBundles);
682
					fContainerChecked.put(containers[i], checked);
683
					fAllChecked.addAll(checked);
684
				}
685
			}
686
687
			// Map the bundles into their file locations
688
			fFileBundles = new HashMap();
689
			fFileChecked = new HashMap();
690
			for (Iterator iterator = fAllBundles.iterator(); iterator.hasNext();) {
691
				IResolvedBundle currentBundle = (IResolvedBundle) iterator.next();
692
				IPath parentPath = getParentPath(currentBundle);
693
				List bundles = (List) fFileBundles.get(parentPath);
694
				if (bundles == null) {
695
					bundles = new ArrayList();
696
					bundles.add(currentBundle);
697
					fFileBundles.put(parentPath, bundles);
698
				} else {
699
					bundles.add(currentBundle);
700
				}
701
				// Determine whether the current bundle is checked
702
				if (fAllChecked.contains(currentBundle)) {
703
					Set checked = (Set) fFileChecked.get(parentPath);
704
					if (checked == null) {
705
						checked = new HashSet();
706
						checked.add(currentBundle);
707
						fFileChecked.put(parentPath, checked);
708
					} else {
709
						checked.add(currentBundle);
710
					}
711
				}
712
			}
713
714
			return Status.OK_STATUS;
715
		}
716
	}
717
718
	private Set getChecked(Object parent) {
719
		Set result = null;
720
		if (parent == null) {
721
			result = fAllChecked;
722
		} else if (fGrouping == GROUP_BY_CONTAINER) {
723
			result = (Set) fContainerChecked.get(parent);
724
		} else if (fGrouping == GROUP_BY_FILE_LOC) {
725
			result = (Set) fFileChecked.get(parent);
726
		}
727
		if (result == null) {
728
			return new HashSet(0);
729
		}
730
		return result;
731
	}
732
733
	private List getBundleChildren(Object parent) {
734
		List result = null;
735
		if (parent == null) {
736
			result = fAllBundles;
737
		} else if (fGrouping == GROUP_BY_CONTAINER) {
738
			result = (List) fContainerBundles.get(parent);
739
		} else if (fGrouping == GROUP_BY_FILE_LOC) {
740
			result = (List) fFileBundles.get(parent);
741
		}
742
		if (result == null) {
743
			return new ArrayList(0);
744
		}
745
		return result;
746
	}
747
748
	/* (non-Javadoc)
749
	 * @see org.eclipse.swt.widgets.Control#setEnabled(boolean)
750
	 */
751
	public void setEnabled(boolean enabled) {
752
		super.setEnabled(enabled);
753
		if (enabled) {
754
			updateButtons();
755
		} else {
756
			fSelectButton.setEnabled(false);
757
			fSelectAllButton.setEnabled(false);
758
			fDeselectButton.setEnabled(false);
759
			fDeselectAllButton.setEnabled(false);
760
//			fSelectRequiredButton.setEnabled(false);
761
			fCountLabel.setText(""); //$NON-NLS-1$
762
		}
763
		fShowLabel.setEnabled(enabled);
764
		fShowPluginsButton.setEnabled(enabled);
765
		fShowSourceButton.setEnabled(enabled);
766
		fGroupLabel.setEnabled(enabled);
767
		if (fGroupCombo != null) {
768
			fGroupCombo.setEnabled(enabled);
769
		} else {
770
			fGroupComboPart.setEnabled(enabled);
771
		}
772
		super.setEnabled(enabled);
773
	}
774
775
	public void saveIncludedBundleState(Object[] changeContainers) {
776
		for (int i = 0; i < changeContainers.length; i++) {
777
			if (changeContainers[i] instanceof IBundleContainer) {
778
				Set checked = (Set) fContainerChecked.get(changeContainers[i]);
779
				if (checked.size() == ((Collection) fContainerBundles.get(changeContainers[i])).size()) {
780
					((IBundleContainer) changeContainers[i]).setIncludedBundles(null);
781
				} else {
782
					List included = new ArrayList(checked.size());
783
					for (Iterator iterator = checked.iterator(); iterator.hasNext();) {
784
						IResolvedBundle currentBundle = (IResolvedBundle) iterator.next();
785
						included.add(new BundleInfo(currentBundle.getBundleInfo().getSymbolicName(), null, null, BundleInfo.NO_BUNDLEID, false));
786
					}
787
					((IBundleContainer) changeContainers[i]).setIncludedBundles((BundleInfo[]) included.toArray(new BundleInfo[included.size()]));
788
				}
789
			}
790
		}
791
	}
792
793
	class TreeContentProvider implements ITreeContentProvider {
794
		public Object[] getChildren(Object parentElement) {
795
			return getBundleChildren(parentElement).toArray();
796
		}
797
798
		public Object getParent(Object element) {
799
//			if (fGrouping == GROUP_BY_CONTAINER && element instanceof IResolvedBundle) {
800
//				return ((IResolvedBundle) element).getParentContainer();
801
//			} else if (fGrouping == GROUP_BY_FILE_LOC && element instanceof IResolvedBundle) {
802
//				return getParentPath((IResolvedBundle) element);
803
//			}
804
			return null;
805
		}
806
807
		public boolean hasChildren(Object element) {
808
			if (fGrouping == GROUP_BY_NONE || element instanceof IResolvedBundle) {
809
				return false;
810
			}
811
			if (element instanceof IBundleContainer || element instanceof IPath) {
812
				return getBundleChildren(element).size() > 0;
813
			}
814
			return false;
815
		}
816
817
		public Object[] getElements(Object inputElement) {
818
			if (inputElement instanceof ITargetDefinition) {
819
				if (fGrouping == GROUP_BY_NONE) {
820
					return fAllBundles.toArray();
821
				} else if (fGrouping == GROUP_BY_CONTAINER) {
822
					return fContainerBundles.keySet().toArray();
823
				} else {
824
					return fFileBundles.keySet().toArray();
825
				}
826
			}
827
			return new Object[] {inputElement};
828
		}
829
830
		public void dispose() {
831
		}
832
833
		public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
834
		}
835
	}
836
837
}
(-)src/org/eclipse/pde/internal/ui/shared/target/TargetLocationsGroup.java (+408 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
		fTreeViewer.setInput(fTarget);
244
		updateButtons();
245
	}
246
247
	private void handleAdd() {
248
		AddBundleContainerWizard wizard = new AddBundleContainerWizard(fTarget);
249
		Shell parent = fTreeViewer.getTree().getShell();
250
		WizardDialog dialog = new WizardDialog(parent, wizard);
251
		if (dialog.open() != Window.CANCEL) {
252
			contentsChanged();
253
			fTreeViewer.refresh();
254
			updateButtons();
255
		}
256
	}
257
258
	private void handleEdit() {
259
		IStructuredSelection selection = (IStructuredSelection) fTreeViewer.getSelection();
260
		if (!selection.isEmpty()) {
261
			Object selected = selection.getFirstElement();
262
			IBundleContainer oldContainer = null;
263
			if (selected instanceof IBundleContainer) {
264
				oldContainer = (IBundleContainer) selected;
265
			} else if (selected instanceof IResolvedBundle) {
266
				TreeItem[] treeSelection = fTreeViewer.getTree().getSelection();
267
				if (treeSelection.length > 0) {
268
					Object parent = treeSelection[0].getParentItem().getData();
269
					if (parent instanceof IBundleContainer) {
270
						oldContainer = (IBundleContainer) parent;
271
					}
272
				}
273
			}
274
			if (oldContainer != null) {
275
				Shell parent = fTreeViewer.getTree().getShell();
276
				EditBundleContainerWizard wizard = new EditBundleContainerWizard(oldContainer);
277
				WizardDialog dialog = new WizardDialog(parent, wizard);
278
				if (dialog.open() == Window.OK) {
279
					// Replace the old container with the new one
280
					IBundleContainer newContainer = wizard.getBundleContainer();
281
					if (newContainer != null) {
282
						IBundleContainer[] containers = fTarget.getBundleContainers();
283
						java.util.List newContainers = new ArrayList(containers.length);
284
						for (int i = 0; i < containers.length; i++) {
285
							if (!containers[i].equals(oldContainer)) {
286
								newContainers.add(containers[i]);
287
							}
288
						}
289
						newContainers.add(newContainer);
290
						fTarget.setBundleContainers((IBundleContainer[]) newContainers.toArray(new IBundleContainer[newContainers.size()]));
291
292
						// Update the table
293
						contentsChanged();
294
						fTreeViewer.refresh();
295
						updateButtons();
296
						fTreeViewer.setSelection(new StructuredSelection(newContainer), true);
297
					}
298
				}
299
			}
300
		}
301
	}
302
303
	private void handleRemove() {
304
		IStructuredSelection selection = (IStructuredSelection) fTreeViewer.getSelection();
305
		if (!selection.isEmpty()) {
306
			Object selected = selection.getFirstElement();
307
			IBundleContainer container = null;
308
			if (selected instanceof IBundleContainer) {
309
				container = (IBundleContainer) selected;
310
				IBundleContainer[] currentContainers = fTarget.getBundleContainers();
311
				ArrayList newBundleContainers = new ArrayList(currentContainers.length);
312
				for (int i = 0; i < currentContainers.length; i++) {
313
					if (!currentContainers[i].equals(container)) {
314
						newBundleContainers.add(currentContainers[i]);
315
					}
316
				}
317
				fTarget.setBundleContainers((IBundleContainer[]) newBundleContainers.toArray(new IBundleContainer[newBundleContainers.size()]));
318
				contentsChanged();
319
				fTreeViewer.refresh(false);
320
				updateButtons();
321
			}
322
		}
323
	}
324
325
	private void handleRemoveAll() {
326
		fTarget.setBundleContainers(null);
327
		contentsChanged();
328
		fTreeViewer.refresh(false);
329
		updateButtons();
330
	}
331
332
	private void updateButtons() {
333
		IStructuredSelection selection = (IStructuredSelection) fTreeViewer.getSelection();
334
		fEditButton.setEnabled(!selection.isEmpty() && selection.getFirstElement() instanceof IBundleContainer);
335
		fRemoveButton.setEnabled(!selection.isEmpty() && selection.getFirstElement() instanceof IBundleContainer);
336
		fRemoveAllButton.setEnabled(fTarget != null && fTarget.getBundleContainers() != null && fTarget.getBundleContainers().length > 0);
337
	}
338
339
	/**
340
	 * Informs the reporter for this table that something has changed
341
	 * and is dirty.
342
	 */
343
	private void contentsChanged() {
344
		Object[] listeners = fChangeListeners.getListeners();
345
		for (int i = 0; i < listeners.length; i++) {
346
			((ITargetChangedListener) listeners[i]).contentsChanged(fTarget, this, true);
347
		}
348
	}
349
350
	/**
351
	 * Content provider for the tree, primary input is a ITargetDefinition, children are IBundleContainers
352
	 */
353
	class BundleContainerContentProvider implements ITreeContentProvider {
354
355
		public Object[] getChildren(Object parentElement) {
356
			if (parentElement instanceof ITargetDefinition) {
357
				IBundleContainer[] containers = ((ITargetDefinition) parentElement).getBundleContainers();
358
				return containers != null ? containers : new Object[0];
359
			} else if (parentElement instanceof IBundleContainer) {
360
				IBundleContainer container = (IBundleContainer) parentElement;
361
				if (container.isResolved()) {
362
					IStatus status = container.getBundleStatus();
363
					if (!status.isOK() && !status.isMultiStatus()) {
364
						return new Object[] {status};
365
					}
366
					if (fShowContentButton.getSelection()) {
367
						return container.getBundles();
368
					} else if (!status.isOK()) {
369
						// Show multi-status children so user can easily see problems
370
						if (status.isMultiStatus()) {
371
							return status.getChildren();
372
						}
373
					}
374
				}
375
			}
376
			return new Object[0];
377
		}
378
379
		public Object getParent(Object element) {
380
			return null;
381
		}
382
383
		public boolean hasChildren(Object element) {
384
			// Since we are already resolved we can't be more efficient
385
			return getChildren(element).length > 0;
386
		}
387
388
		public Object[] getElements(Object inputElement) {
389
			if (inputElement instanceof ITargetDefinition) {
390
				IBundleContainer[] containers = ((ITargetDefinition) inputElement).getBundleContainers();
391
				if (containers != null) {
392
					return containers;
393
				}
394
			} else if (inputElement instanceof String) {
395
				return new Object[] {inputElement};
396
			}
397
			return new Object[0];
398
		}
399
400
		public void dispose() {
401
		}
402
403
		public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
404
		}
405
406
	}
407
408
}
(-)src/org/eclipse/pde/internal/core/target/provisional/IResolvedBundle.java (+7 lines)
Lines 47-52 Link Here
47
	public BundleInfo getBundleInfo();
47
	public BundleInfo getBundleInfo();
48
48
49
	/**
49
	/**
50
	 * Returns the parent bundle container that this bundle belongs to.
51
	 * 
52
	 * @return parent bundle container
53
	 */
54
	public IBundleContainer getParentContainer();
55
56
	/**
50
	 * Returns <code>true</code> if this bundle is a source bundle and 
57
	 * Returns <code>true</code> if this bundle is a source bundle and 
51
	 * <code>false</code> if this bundle is an executable bundle.
58
	 * <code>false</code> if this bundle is an executable bundle.
52
	 * 
59
	 * 
(-)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 / +37 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
						}
Lines 663-666 Link Here
663
		}
663
		}
664
		return fVMArgs;
664
		return fVMArgs;
665
	}
665
	}
666
667
	// Helpful when using working copies, but needs to differentiate between all containers, including different features with same location
668
//	/* (non-Javadoc)
669
//	 * @see java.lang.Object#equals(java.lang.Object)
670
//	 */
671
//	public boolean equals(Object obj) {
672
//		if (obj instanceof AbstractBundleContainer) {
673
//			AbstractBundleContainer container = (AbstractBundleContainer) obj;
674
//			try {
675
//				if (container.getType().equals(getType()) && container.getLocation(false).equals(getLocation(false))) {
676
//					return true;
677
//				}
678
//			} catch (CoreException e) {
679
//				PDECore.log(e);
680
//			}
681
//		}
682
//		return false;
683
//	}
684
//
685
//	/* (non-Javadoc)
686
//	 * @see java.lang.Object#hashCode()
687
//	 */
688
//	public int hashCode() {
689
//		int result = getType().hashCode();
690
//		try {
691
//			result += getLocation(false).hashCode();
692
//		} catch (CoreException e) {
693
//			// Do nothing, caught by equals
694
//		}
695
//		return result;
696
//	}
666
}
697
}
(-)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