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/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/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/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 1687-1697 Link Here
1687
OverviewPage_extensionPageMessageTitle=Extension pages hidden
1687
OverviewPage_extensionPageMessageTitle=Extension pages hidden
1688
OverviewPage_extensionPageMessageBody=The Extension and Extension Point pages are currently hidden, would you like to display them now?
1688
OverviewPage_extensionPageMessageBody=The Extension and Extension Point pages are currently hidden, would you like to display them now?
1689
OverviewPage_environmentDescription=<form>\
1689
OverviewPage_environmentDescription=<form>\
1690
<p>The <a href="environment">Environment</a> section contains the following environment and setup information:</p>\
1690
<p>The <a href="environment">Environment</a> section contains additional settings including: locale, operating system, java runtime, arguments and implicit dependencies.</p>\
1691
<li>Environment settings including locale, processor architecture, operating system and windowing system.</li>\
1692
<li>Java runtime environment.</li>\
1693
<li>Program and VM arguments.</li>\
1694
<li>Implicit plug-ins, which should always be taken into account when calculating dependencies.</li>\
1695
</form>
1691
</form>
1696
OverviewPage_fExtensionContent=<form>\
1692
OverviewPage_fExtensionContent=<form>\
1697
<p>This fragment may define extensions and extension points:</p>\
1693
<p>This fragment may define extensions and extension points:</p>\
Lines 1699-1706 Link Here
1699
<li style="image" value="page" bindent="5"><a href="ex-points">Extension Points</a>: declares new function points this fragment adds to the platform.</li>\
1695
<li style="image" value="page" bindent="5"><a href="ex-points">Extension Points</a>: declares new function points this fragment adds to the platform.</li>\
1700
</form>
1696
</form>
1701
OverviewPage_contentDescription=<form>\
1697
OverviewPage_contentDescription=<form>\
1702
<p>The <a href="content">Content</a> section specifies the make-up of the target platform in terms of plug-ins, features or both.</p>\
1698
<p>The <a href="content">Content</a> section specifies the set of plug-ins that will be included in the target platform.</p>\
1703
<p>An option is also available to simply include all plug-ins from the specified locations into the target platform.</p>\
1704
</form>
1699
</form>
1705
OverviewPage_buildTitle=Build Configuration
1700
OverviewPage_buildTitle=Build Configuration
1706
ClassAttributeRow_dialogTitle=Select Type
1701
ClassAttributeRow_dialogTitle=Select Type
(-)src/org/eclipse/pde/internal/ui/PDEPluginImages.java (+2 lines)
Lines 128-133 Link Here
128
	public static final ImageDescriptor DESC_COMGROUP_OBJ = create(PATH_OBJ, "keygroups_obj.gif"); //$NON-NLS-1$
128
	public static final ImageDescriptor DESC_COMGROUP_OBJ = create(PATH_OBJ, "keygroups_obj.gif"); //$NON-NLS-1$
129
	public static final ImageDescriptor DESC_GENCOM_OBJ = create(PATH_OBJ, "command_obj.gif"); //$NON-NLS-1$
129
	public static final ImageDescriptor DESC_GENCOM_OBJ = create(PATH_OBJ, "command_obj.gif"); //$NON-NLS-1$
130
130
131
	public static final ImageDescriptor DESC_REPOSITORY_OBJ = create(PATH_OBJ, "metadata_repo_obj.gif"); //$NON-NLS-1$
132
131
	public static final ImageDescriptor DESC_PLUGIN_OBJ = create(PATH_OBJ, "plugin_obj.gif"); //$NON-NLS-1$
133
	public static final ImageDescriptor DESC_PLUGIN_OBJ = create(PATH_OBJ, "plugin_obj.gif"); //$NON-NLS-1$
132
	public static final ImageDescriptor DESC_PLUGIN_DIS_OBJ = create(PATH_OBJ, "plugin_dis_obj.gif"); //$NON-NLS-1$
134
	public static final ImageDescriptor DESC_PLUGIN_DIS_OBJ = create(PATH_OBJ, "plugin_dis_obj.gif"); //$NON-NLS-1$
133
	public static final ImageDescriptor DESC_OPERATING_SYSTEM_OBJ = create(PATH_OBJ, "operating_system_obj.gif"); //$NON-NLS-1$
135
	public static final ImageDescriptor DESC_OPERATING_SYSTEM_OBJ = create(PATH_OBJ, "operating_system_obj.gif"); //$NON-NLS-1$
(-)src/org/eclipse/pde/internal/ui/editor/targetdefinition/TargetEditor.java (+79 lines)
Lines 14-19 Link Here
14
import java.util.List;
14
import java.util.List;
15
import org.eclipse.core.resources.*;
15
import org.eclipse.core.resources.*;
16
import org.eclipse.core.runtime.*;
16
import org.eclipse.core.runtime.*;
17
import org.eclipse.core.runtime.jobs.Job;
18
import org.eclipse.core.runtime.jobs.JobChangeAdapter;
17
import org.eclipse.jface.action.Action;
19
import org.eclipse.jface.action.Action;
18
import org.eclipse.jface.action.ControlContribution;
20
import org.eclipse.jface.action.ControlContribution;
19
import org.eclipse.jface.dialogs.IMessageProvider;
21
import org.eclipse.jface.dialogs.IMessageProvider;
Lines 21-26 Link Here
21
import org.eclipse.pde.internal.core.target.impl.WorkspaceFileTargetHandle;
23
import org.eclipse.pde.internal.core.target.impl.WorkspaceFileTargetHandle;
22
import org.eclipse.pde.internal.core.target.provisional.*;
24
import org.eclipse.pde.internal.core.target.provisional.*;
23
import org.eclipse.pde.internal.ui.*;
25
import org.eclipse.pde.internal.ui.*;
26
import org.eclipse.pde.internal.ui.shared.target.*;
24
import org.eclipse.swt.SWT;
27
import org.eclipse.swt.SWT;
25
import org.eclipse.swt.custom.BusyIndicator;
28
import org.eclipse.swt.custom.BusyIndicator;
26
import org.eclipse.swt.widgets.*;
29
import org.eclipse.swt.widgets.*;
Lines 32-37 Link Here
32
import org.eclipse.ui.forms.events.IHyperlinkListener;
35
import org.eclipse.ui.forms.events.IHyperlinkListener;
33
import org.eclipse.ui.forms.widgets.*;
36
import org.eclipse.ui.forms.widgets.*;
34
import org.eclipse.ui.part.FileEditorInput;
37
import org.eclipse.ui.part.FileEditorInput;
38
import org.eclipse.ui.progress.UIJob;
35
39
36
/**
40
/**
37
 * Editor for target definition (*.target) files.  Interacts with the ITargetDefinition model
41
 * Editor for target definition (*.target) files.  Interacts with the ITargetDefinition model
Lines 46-51 Link Here
46
	private ITargetDefinition fTarget;
50
	private ITargetDefinition fTarget;
47
	private List fManagedFormPages = new ArrayList(2);
51
	private List fManagedFormPages = new ArrayList(2);
48
	private FileInputListener fInputListener;
52
	private FileInputListener fInputListener;
53
	private TargetChangedListener fTargetChangedListener;
49
54
50
	/* (non-Javadoc)
55
	/* (non-Javadoc)
51
	 * @see org.eclipse.ui.forms.editor.FormEditor#createToolkit(org.eclipse.swt.widgets.Display)
56
	 * @see org.eclipse.ui.forms.editor.FormEditor#createToolkit(org.eclipse.swt.widgets.Display)
Lines 62-67 Link Here
62
			setActiveEditor(this);
67
			setActiveEditor(this);
63
			setPartName(getEditorInput().getName());
68
			setPartName(getEditorInput().getName());
64
			addPage(new DefinitionPage(this));
69
			addPage(new DefinitionPage(this));
70
			addPage(new ContentPage(this));
65
			addPage(new EnvironmentPage(this));
71
			addPage(new EnvironmentPage(this));
66
		} catch (PartInitException e) {
72
		} catch (PartInitException e) {
67
			PDEPlugin.log(e);
73
			PDEPlugin.log(e);
Lines 147-152 Link Here
147
		if (input instanceof IFileEditorInput) {
153
		if (input instanceof IFileEditorInput) {
148
			fInputListener = new FileInputListener(((IFileEditorInput) input).getFile());
154
			fInputListener = new FileInputListener(((IFileEditorInput) input).getFile());
149
			PDEPlugin.getWorkspace().addResourceChangeListener(fInputListener);
155
			PDEPlugin.getWorkspace().addResourceChangeListener(fInputListener);
156
			getTargetChangedListener().contentsChanged(getTarget(), true);
150
		}
157
		}
151
	}
158
	}
152
159
Lines 198-203 Link Here
198
	}
205
	}
199
206
200
	/**
207
	/**
208
	 * @return a shared listener that will refresh UI components when the target is modified
209
	 */
210
	public TargetChangedListener getTargetChangedListener() {
211
		if (fTargetChangedListener == null) {
212
			fTargetChangedListener = new TargetChangedListener();
213
		}
214
		return fTargetChangedListener;
215
	}
216
217
	/**
201
	 * Handles the revert action
218
	 * Handles the revert action
202
	 */
219
	 */
203
	public void doRevert() {
220
	public void doRevert() {
Lines 303-306 Link Here
303
		}
320
		}
304
	}
321
	}
305
322
323
	class TargetChangedListener implements ITargetChangedListener {
324
		private TargetLocationsGroup fLocationTree;
325
		private TargetContentsGroup fContentTree;
326
327
		public void setLocationTree(TargetLocationsGroup locationTree) {
328
			fLocationTree = locationTree;
329
		}
330
331
		public void setContentTree(TargetContentsGroup contentTree) {
332
			fContentTree = contentTree;
333
		}
334
335
		public void contentsChanged(ITargetDefinition definition, boolean resolve) {
336
			if (resolve) {
337
				if (definition.isResolved()) {
338
					if (fContentTree != null) {
339
						fContentTree.setInput(getTarget());
340
					}
341
					if (fLocationTree != null) {
342
						fLocationTree.setInput(getTarget());
343
					}
344
				} else {
345
					if (fContentTree != null) {
346
						fContentTree.setEnabled(false);
347
					}
348
					if (fLocationTree != null) {
349
						fLocationTree.setInput(null);
350
					}
351
					// TODO Cancel any other started jobs? Bad if we do this every time a checkbox changes
352
					Job resolveJob = new Job("Resolving Target") {
353
						protected IStatus run(IProgressMonitor monitor) {
354
							getTarget().resolve(monitor);
355
							if (monitor.isCanceled()) {
356
								return Status.CANCEL_STATUS;
357
							}
358
							// Don't return any problems because we don't want an error dialog
359
							return Status.OK_STATUS;
360
						}
361
					};
362
					resolveJob.addJobChangeListener(new JobChangeAdapter() {
363
						public void done(org.eclipse.core.runtime.jobs.IJobChangeEvent event) {
364
							UIJob job = new UIJob("Refresh UI") {
365
								public IStatus runInUIThread(IProgressMonitor monitor) {
366
									if (fContentTree != null) {
367
										fContentTree.setInput(getTarget());
368
									}
369
									if (fLocationTree != null) {
370
										fLocationTree.setInput(getTarget());
371
									}
372
									return Status.OK_STATUS;
373
								}
374
							};
375
							job.setSystem(true);
376
							job.schedule();
377
						}
378
					});
379
					resolveJob.schedule();
380
				}
381
			}
382
		}
383
	}
384
306
}
385
}
(-)src/org/eclipse/pde/internal/ui/editor/targetdefinition/ContentSection.java (-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 = TargetContentsGroup.createInForm(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, 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 / +83 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 = TargetContentsGroup.createInDialog(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, boolean resolve) {
168
				if (resolve) {
169
					if (!definition.isResolved()) {
170
						try {
171
							getContainer().run(true, true, new IRunnableWithProgress() {
172
								public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
173
									getTargetDefinition().resolve(monitor);
174
									if (monitor.isCanceled()) {
175
										throw new InterruptedException();
176
									}
177
								}
178
							});
179
						} catch (InvocationTargetException e) {
180
							PDECore.log(e);
181
						} catch (InterruptedException e) {
182
							// Do nothing, op cancelled
183
						}
184
					}
185
					fContentTree.setInput(definition);
186
					fLocationTree.setInput(definition);
187
					if (definition.isResolved() && definition.getBundleStatus().getSeverity() == IStatus.ERROR) {
188
						fLocationTab.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_ERROR_TSK));
189
					} else {
190
						fLocationTab.setImage(null);
191
					}
192
				}
193
			}
194
		};
195
		fContentTree.addTargetChangedListener(listener);
196
		fLocationTree.addTargetChangedListener(listener);
197
		// When  If the page isn't open yet, try running a UI job so the dialog has time to finish opening
198
		new UIJob(PDEUIMessages.TargetDefinitionContentPage_0) {
199
			public IStatus runInUIThread(IProgressMonitor monitor) {
200
				try {
201
					getContainer().run(true, true, new IRunnableWithProgress() {
202
						public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
203
							getTargetDefinition().resolve(monitor);
204
							if (monitor.isCanceled()) {
205
								throw new InterruptedException();
206
							}
207
						}
208
					});
209
				} catch (InvocationTargetException e) {
210
					PDECore.log(e);
211
				} catch (InterruptedException e) {
212
					return Status.CANCEL_STATUS;
213
				}
214
				ITargetDefinition definition = getTargetDefinition();
215
				fContentTree.setInput(definition);
216
				fLocationTree.setInput(definition);
217
				if (definition.isResolved() && definition.getBundleStatus().getSeverity() == IStatus.ERROR) {
218
					fLocationTab.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_ERROR_TSK));
219
				} else {
220
					fLocationTab.setImage(null);
221
				}
222
				return Status.OK_STATUS;
223
			}
224
		}.schedule();
225
226
	}
227
187
	/* (non-Javadoc)
228
	/* (non-Javadoc)
188
	 * @see org.eclipse.pde.internal.ui.wizards.target.TargetDefinitionPage#targetChanged()
229
	 * @see org.eclipse.pde.internal.ui.wizards.target.TargetDefinitionPage#targetChanged()
189
	 */
230
	 */
Lines 200-206 Link Here
200
			else
241
			else
201
				setMessage(PDEUIMessages.TargetDefinitionContentPage_8);
242
				setMessage(PDEUIMessages.TargetDefinitionContentPage_8);
202
243
203
			fTable.setInput(definition);
244
			fLocationTree.setInput(definition);
245
			fContentTree.setInput(definition);
204
246
205
			String presetValue = (definition.getOS() == null) ? EMPTY_STRING : definition.getOS();
247
			String presetValue = (definition.getOS() == null) ? EMPTY_STRING : definition.getOS();
206
			fOSCombo.setText(presetValue);
248
			fOSCombo.setText(presetValue);
(-)src/org/eclipse/pde/internal/ui/util/PDEJavaHelperUI.java (-1 / +1 lines)
Lines 237-243 Link Here
237
		// Set auto activation character to be a '.'
237
		// Set auto activation character to be a '.'
238
		char[] autoActivationChars = new char[] {TypeContentProposalProvider.F_DOT};
238
		char[] autoActivationChars = new char[] {TypeContentProposalProvider.F_DOT};
239
		// Create the adapter
239
		// Create the adapter
240
		ContentAssistCommandAdapter adapter = new ContentAssistCommandAdapter(text, textContentAdapter, proposalProvider, IWorkbenchCommandConstants.EDIT_CONTENT_ASSIST, autoActivationChars);
240
		ContentAssistCommandAdapter adapter = new ContentAssistCommandAdapter(text, textContentAdapter, proposalProvider, IWorkbenchCommandConstants.EDIT_CONTENTASSIST, autoActivationChars);
241
		// Configure the adapter
241
		// Configure the adapter
242
		// Add label provider
242
		// Add label provider
243
		ILabelProvider labelProvider = new TypeProposalLabelProvider();
243
		ILabelProvider labelProvider = new TypeProposalLabelProvider();
(-)plugin.xml (+12 lines)
Lines 69-74 Link Here
69
               id="org.eclipse.pde.ui.TargetPlatformPreferencePage">
69
               id="org.eclipse.pde.ui.TargetPlatformPreferencePage">
70
         </keywordReference>
70
         </keywordReference>
71
      </page>
71
      </page>
72
      <page
73
            category="org.eclipse.pde.ui.MainPreferencePage"
74
            class="org.eclipse.pde.internal.ui.preferences.TargetPlatformPreferencePage"
75
            id="org.eclipse.pde.ui.TargetPlatformPreferencePage"
76
            name="Target 2">
77
         <keywordReference
78
               id="org.eclipse.pde.ui.pde">
79
         </keywordReference>
80
         <keywordReference
81
               id="org.eclipse.pde.ui.TargetPlatformPreferencePage">
82
         </keywordReference>
83
      </page>
72
   </extension>
84
   </extension>
73
   <extension
85
   <extension
74
   		point="org.eclipse.ui.keywords">
86
   		point="org.eclipse.ui.keywords">
(-)src/org/eclipse/pde/internal/ui/shared/target/ITargetChangedListener.java (+35 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.pde.internal.ui.shared.target;
12
13
import org.eclipse.pde.internal.core.target.provisional.ITargetDefinition;
14
import org.eclipse.pde.internal.ui.wizards.target.TargetDefinitionContentPage;
15
16
/**
17
 * Listener for UI components that modify the contents of target definitions.
18
 * Whenever the contents of the target changes the listener will be called so
19
 * the target can be resolved and the UI updated.
20
 * 
21
 * @see TargetLocationsGroup
22
 * @see TargetContentsGroup
23
 * @see TargetDefinitionContentPage
24
 */
25
public interface ITargetChangedListener {
26
27
	/**
28
	 * Informs the listener that the contents of the target have changed
29
	 * and UI elements may need to be refreshed.
30
	 * @param definition target definition whose contents have changed or <code>null</code> if the definition is not available
31
	 * @param resolve whether the definition must be resolved to catch up to all changes
32
	 */
33
	public void contentsChanged(ITargetDefinition definition, boolean resolve);
34
35
}
(-)src/org/eclipse/pde/internal/ui/shared/target/AddP2ContainerPage.java (+175 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.pde.internal.ui.shared.target;
12
13
import java.net.URI;
14
import org.eclipse.core.runtime.IStatus;
15
import org.eclipse.core.runtime.Status;
16
import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit;
17
import org.eclipse.equinox.internal.provisional.p2.ui.actions.PropertyDialogAction;
18
import org.eclipse.equinox.internal.provisional.p2.ui.dialogs.*;
19
import org.eclipse.equinox.internal.provisional.p2.ui.policy.IUViewQueryContext;
20
import org.eclipse.equinox.internal.provisional.p2.ui.policy.Policy;
21
import org.eclipse.jface.action.IAction;
22
import org.eclipse.jface.viewers.CheckStateChangedEvent;
23
import org.eclipse.jface.viewers.ICheckStateListener;
24
import org.eclipse.jface.window.SameShellProvider;
25
import org.eclipse.jface.wizard.WizardPage;
26
import org.eclipse.pde.internal.core.target.impl.P2BundleContainer;
27
import org.eclipse.pde.internal.core.target.provisional.IBundleContainer;
28
import org.eclipse.pde.internal.ui.*;
29
import org.eclipse.pde.internal.ui.wizards.provisioner.p2.ProvisionerMessages;
30
import org.eclipse.swt.SWT;
31
import org.eclipse.swt.events.SelectionAdapter;
32
import org.eclipse.swt.events.SelectionEvent;
33
import org.eclipse.swt.layout.GridData;
34
import org.eclipse.swt.widgets.*;
35
import org.eclipse.ui.PlatformUI;
36
37
/**
38
 * Wizard page allowing users to select which IUs they would like to download
39
 * 
40
 * @since 3.5
41
 */
42
public class AddP2ContainerPage extends WizardPage {
43
44
	static final IStatus BAD_IU_SELECTION = new Status(IStatus.ERROR, PDEPlugin.getPluginId(), ProvisionerMessages.P2TargetProvisionerWizardPage_1);
45
	IStatus fSelectedIUStatus = BAD_IU_SELECTION;
46
47
	P2BundleContainer fContainer;
48
	IUViewQueryContext fQueryContext;
49
50
	RepositorySelectionGroup fRepoSelector;
51
	AvailableIUGroup fAvailableIUGroup;
52
53
	Button fPropertiesButton;
54
	private IAction fPropertyAction;
55
56
	protected AddP2ContainerPage() {
57
		super("AddP2Container"); //$NON-NLS-1$
58
		// TODO Use the target service to create?
59
		fContainer = new P2BundleContainer();
60
	}
61
62
	/* (non-Javadoc)
63
	 * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
64
	 */
65
	public void createControl(Composite parent) {
66
		setMessage("Select content from a repository to be downloaded and added to your target");
67
		setTitle("Add Repository or Update Site");
68
		Composite composite = SWTFactory.createComposite(parent, 1, 1, GridData.FILL_BOTH, 0, 0);
69
70
		createQueryContext();
71
		createRepositoryComboArea(composite);
72
		createAvailableIUArea(composite);
73
		createDetailsArea(composite);
74
		createCheckboxArea(composite);
75
76
		setPageComplete(false);
77
		restoreWidgetState();
78
		setControl(composite);
79
		PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, IHelpContextIds.P2_PROVISIONING_PAGE);
80
	}
81
82
	private void createCheckboxArea(Composite parent) {
83
		// Categories, provisioning context/store sites/
84
		Composite checkComp = SWTFactory.createComposite(parent, 2, 1, GridData.FILL_HORIZONTAL, 0, 0);
85
		// TODO Update labels with mnemonics
86
		SWTFactory.createCheckButton(checkComp, "Group by Category", null, true, 1);
87
		SWTFactory.createCheckButton(checkComp, "Show only the latest version", null, true, 1);
88
		SWTFactory.createCheckButton(checkComp, "Download all dependencies", null, true, 1);
89
		SWTFactory.createCheckButton(checkComp, "Include the repo location in the target", null, true, 1);
90
91
	}
92
93
	private void createQueryContext() {
94
		fQueryContext = Policy.getDefault().getQueryContext();
95
	}
96
97
	private void createRepositoryComboArea(Composite parent) {
98
		RepositorySelectionGroup repoSelector = new RepositorySelectionGroup(getContainer(), parent, Policy.getDefault(), fQueryContext);
99
		repoSelector.addRepositorySelectionListener(new IRepositorySelectionListener() {
100
			public void repositorySelectionChanged(int repoChoice, URI repoLocation) {
101
				fAvailableIUGroup.setRepositoryFilter(repoChoice, repoLocation);
102
			}
103
		});
104
	}
105
106
	/**
107
	 * Create the UI area where the user will be able to select which IUs they
108
	 * would like to download.  There will also be buttons to see properties for
109
	 * the selection and open the manage sites dialog.
110
	 * 
111
	 * @param parent parent composite
112
	 */
113
	private void createAvailableIUArea(Composite parent) {
114
		fAvailableIUGroup = new AvailableIUGroup(parent);
115
		fAvailableIUGroup.getCheckboxTreeViewer().addCheckStateListener(new ICheckStateListener() {
116
			public void checkStateChanged(CheckStateChangedEvent event) {
117
				IInstallableUnit[] units = fAvailableIUGroup.getCheckedLeafIUs();
118
				fPropertiesButton.setEnabled(units.length > 0);
119
				if (units.length > 0) {
120
					fSelectedIUStatus = Status.OK_STATUS;
121
					fContainer.setRequiredUnits(units);
122
				} else {
123
					fSelectedIUStatus = BAD_IU_SELECTION;
124
					fContainer.setRequiredUnits(null);
125
				}
126
				pageChanged();
127
			}
128
		});
129
		fAvailableIUGroup.setUseBoldFontForFilteredItems(true);
130
		GridData data = (GridData) fAvailableIUGroup.getStructuredViewer().getControl().getLayoutData();
131
		data.heightHint = 200;
132
	}
133
134
	private void createDetailsArea(Composite parent) {
135
		Group detailsGroup = SWTFactory.createGroup(parent, "Details", 1, 1, GridData.FILL_HORIZONTAL);
136
137
		fPropertiesButton = new Button(detailsGroup, SWT.PUSH);
138
		fPropertiesButton.setText(ProvisionerMessages.P2TargetProvisionerWizardPage_10);
139
		fPropertiesButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
140
		fPropertiesButton.addSelectionListener(new SelectionAdapter() {
141
			public void widgetSelected(SelectionEvent event) {
142
				fPropertyAction.run();
143
			}
144
		});
145
		fPropertyAction = new PropertyDialogAction(new SameShellProvider(getShell()), fAvailableIUGroup.getStructuredViewer());
146
	}
147
148
	/**
149
	 * Checks if the page is complete, updating messages and finish button.
150
	 */
151
	void pageChanged() {
152
		if (fSelectedIUStatus.getSeverity() == IStatus.ERROR) {
153
			setErrorMessage(fSelectedIUStatus.getMessage());
154
			setPageComplete(false);
155
		} else {
156
			setErrorMessage(null);
157
			setPageComplete(true);
158
		}
159
	}
160
161
	/**
162
	 * Restores the state of the wizard from previous invocations
163
	 */
164
	private void restoreWidgetState() {
165
		// TODO Init check boxes
166
	}
167
168
	/**
169
	 * @return bundle container created by this wizard or <code>null</code>
170
	 */
171
	public IBundleContainer getBundleContainer() {
172
		return fContainer;
173
	}
174
175
}
(-)src/org/eclipse/pde/internal/ui/editor/targetdefinition/ContentPage.java (+83 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.pde.internal.ui.editor.targetdefinition;
12
13
import org.eclipse.pde.internal.core.target.provisional.ITargetDefinition;
14
import org.eclipse.pde.internal.ui.PDEPlugin;
15
import org.eclipse.pde.internal.ui.PDEPluginImages;
16
import org.eclipse.pde.internal.ui.editor.FormLayoutFactory;
17
import org.eclipse.swt.widgets.Composite;
18
import org.eclipse.ui.forms.IManagedForm;
19
import org.eclipse.ui.forms.editor.FormPage;
20
import org.eclipse.ui.forms.widgets.FormToolkit;
21
import org.eclipse.ui.forms.widgets.ScrolledForm;
22
23
/**
24
 * First page in the target definition editor.  Allows for editing of the name,
25
 * description and content of the target.
26
 * @see TargetEditor
27
 * @see InformationSection
28
 * @see LocationSection
29
 */
30
public class ContentPage extends FormPage {
31
32
	public static final String PAGE_ID = "content"; //$NON-NLS-1$
33
34
	public ContentPage(TargetEditor editor) {
35
		super(editor, PAGE_ID, "Content");
36
	}
37
38
	/**
39
	 * @return The target model backing this editor
40
	 */
41
	public ITargetDefinition getTarget() {
42
		return ((TargetEditor) getEditor()).getTarget();
43
	}
44
45
	/* (non-Javadoc)
46
	 * @see org.eclipse.pde.internal.ui.editor.PDEFormPage#createFormContent(org.eclipse.ui.forms.IManagedForm)
47
	 */
48
	protected void createFormContent(IManagedForm managedForm) {
49
		super.createFormContent(managedForm);
50
		ScrolledForm form = managedForm.getForm();
51
		FormToolkit toolkit = managedForm.getToolkit();
52
		form.setText("Target Content");
53
		PDEPlugin.getDefault().getLabelProvider().connect(this);
54
		form.setImage(PDEPlugin.getDefault().getLabelProvider().get(PDEPluginImages.DESC_TARGET_DEFINITION));
55
		toolkit.decorateFormHeading(form.getForm());
56
		fillBody(managedForm, toolkit);
57
		// TODO Finish help
58
		((TargetEditor) getEditor()).contributeToToolbar(managedForm.getForm(), ""); //$NON-NLS-1$
59
		((TargetEditor) getEditor()).addForm(managedForm);
60
		form.updateToolBar();
61
//		PlatformUI.getWorkbench().getHelpSystem().setHelp(form.getBody(), IHelpContextIds.TARGET_OVERVIEW_PAGE);
62
	}
63
64
	/* (non-Javadoc)
65
	 * @see org.eclipse.ui.forms.editor.FormPage#dispose()
66
	 */
67
	public void dispose() {
68
		PDEPlugin.getDefault().getLabelProvider().disconnect(this);
69
		super.dispose();
70
	}
71
72
	private void fillBody(IManagedForm managedForm, FormToolkit toolkit) {
73
		Composite body = managedForm.getForm().getBody();
74
		body.setLayout(FormLayoutFactory.createFormGridLayout(true, 1));
75
		managedForm.addPart(new ContentSection(this, body));
76
	}
77
78
	// TODO Hook up help toolbar action
79
//	protected String getHelpResource() {
80
//		return "/org.eclipse.pde.doc.user/guide/tools/editors/target_definition_editor/overview.htm"; //$NON-NLS-1$
81
//	}
82
83
}
(-)src/org/eclipse/pde/internal/ui/editor/targetdefinition/LocationSection.java (+86 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2005, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.pde.internal.ui.editor.targetdefinition;
12
13
import org.eclipse.pde.internal.core.target.provisional.ITargetDefinition;
14
import org.eclipse.pde.internal.ui.PDEUIMessages;
15
import org.eclipse.pde.internal.ui.editor.FormLayoutFactory;
16
import org.eclipse.pde.internal.ui.shared.target.ITargetChangedListener;
17
import org.eclipse.pde.internal.ui.shared.target.TargetLocationsGroup;
18
import org.eclipse.swt.layout.GridData;
19
import org.eclipse.swt.widgets.Composite;
20
import org.eclipse.ui.forms.SectionPart;
21
import org.eclipse.ui.forms.editor.FormPage;
22
import org.eclipse.ui.forms.widgets.*;
23
24
/**
25
 * Section for editing the content of the target (bundle containers) in the target definition editor
26
 * @see DefinitionPage
27
 * @see TargetEditor
28
 */
29
public class LocationSection extends SectionPart {
30
31
	private TargetLocationsGroup fContainerGroup;
32
	private TargetEditor fEditor;
33
34
	public LocationSection(FormPage page, Composite parent) {
35
		super(parent, page.getManagedForm().getToolkit(), Section.DESCRIPTION | ExpandableComposite.TITLE_BAR);
36
		fEditor = (TargetEditor) page.getEditor();
37
		createClient(getSection(), page.getEditor().getToolkit());
38
	}
39
40
	/**
41
	 * @return The target model backing this editor
42
	 */
43
	private ITargetDefinition getTarget() {
44
		return fEditor.getTarget();
45
	}
46
47
	/**
48
	 * Creates the UI for this section.
49
	 * 
50
	 * @param section section the UI is being added to
51
	 * @param toolkit form toolkit used to create the widgets
52
	 */
53
	protected void createClient(Section section, FormToolkit toolkit) {
54
		section.setLayout(FormLayoutFactory.createClearTableWrapLayout(false, 1));
55
		GridData sectionData = new GridData(GridData.FILL_BOTH | GridData.GRAB_VERTICAL);
56
		sectionData.horizontalSpan = 2;
57
		section.setLayoutData(sectionData);
58
		section.setText("Locations");
59
60
		section.setDescription(PDEUIMessages.ContentSection_1);
61
		Composite client = toolkit.createComposite(section);
62
		client.setLayout(FormLayoutFactory.createSectionClientGridLayout(false, 1));
63
		client.setLayoutData(new GridData(GridData.FILL_BOTH | GridData.GRAB_VERTICAL));
64
65
		fContainerGroup = TargetLocationsGroup.createInForm(client, toolkit);
66
		fEditor.getTargetChangedListener().setLocationTree(fContainerGroup);
67
		fContainerGroup.addTargetChangedListener(fEditor.getTargetChangedListener());
68
		fContainerGroup.addTargetChangedListener(new ITargetChangedListener() {
69
			public void contentsChanged(ITargetDefinition definition, boolean resolve) {
70
				markDirty();
71
			}
72
		});
73
74
		toolkit.paintBordersFor(client);
75
		section.setClient(client);
76
	}
77
78
	/* (non-Javadoc)
79
	 * @see org.eclipse.ui.forms.AbstractFormPart#refresh()
80
	 */
81
	public void refresh() {
82
		fContainerGroup.setInput(getTarget());
83
		super.refresh();
84
	}
85
86
}
(-)src/org/eclipse/pde/internal/ui/shared/target/PreviewContainerPage.java (+95 lines)
Added Link Here
1
package org.eclipse.pde.internal.ui.shared.target;
2
3
import java.lang.reflect.InvocationTargetException;
4
import org.eclipse.core.runtime.IProgressMonitor;
5
import org.eclipse.core.runtime.IStatus;
6
import org.eclipse.jface.operation.IRunnableWithProgress;
7
import org.eclipse.jface.viewers.ArrayContentProvider;
8
import org.eclipse.jface.viewers.TableViewer;
9
import org.eclipse.jface.wizard.WizardPage;
10
import org.eclipse.pde.internal.core.target.provisional.IBundleContainer;
11
import org.eclipse.pde.internal.core.target.provisional.ITargetDefinition;
12
import org.eclipse.pde.internal.ui.PDEPlugin;
13
import org.eclipse.pde.internal.ui.SWTFactory;
14
import org.eclipse.swt.layout.GridData;
15
import org.eclipse.swt.widgets.Composite;
16
17
public class PreviewContainerPage extends WizardPage {
18
19
	private ITargetDefinition fTarget;
20
	private EditDirectoryContainerPage fPage1;
21
	protected TableViewer fPreviewTable;
22
	protected Object fInput;
23
24
	protected PreviewContainerPage(ITargetDefinition definition, EditDirectoryContainerPage page1) {
25
		super("ContainerPreviewPage");
26
		setTitle("Preview Contents");
27
		setMessage("The plug-ins found in the container are visible below");
28
		fTarget = definition;
29
		fPage1 = page1;
30
	}
31
32
	/* (non-Javadoc)
33
	 * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
34
	 */
35
	public void createControl(Composite parent) {
36
		Composite composite = SWTFactory.createComposite(parent, 1, 1, GridData.FILL_BOTH);
37
		SWTFactory.createLabel(composite, "Plug-ins:", 1);
38
		fPreviewTable = new TableViewer(composite);
39
		fPreviewTable.setLabelProvider(new BundleInfoLabelProvider(true));
40
		fPreviewTable.setContentProvider(ArrayContentProvider.getInstance());
41
		fPreviewTable.getControl().setLayoutData(new GridData(GridData.FILL_BOTH));
42
		setControl(composite);
43
	}
44
45
	/**
46
	 * Refreshes the contents of the preview table, possible resolving the container
47
	 * @param resolve whether the current container should be resolved if it hasn't been already
48
	 */
49
	protected void setInput(final IBundleContainer container) {
50
		if (container == null) {
51
			fInput = null;
52
			fPreviewTable.setInput(null);
53
			return;
54
		}
55
56
		if (container.isResolved()) {
57
			fInput = container.getAllBundles();
58
			fPreviewTable.setInput(fInput);
59
			return;
60
		}
61
62
		try {
63
			getContainer().run(true, true, new IRunnableWithProgress() {
64
				public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
65
					IStatus result = container.resolve(fTarget, monitor);
66
					if (monitor.isCanceled()) {
67
						fInput = null;
68
					} else if (!result.isOK() && !result.isMultiStatus()) {
69
						fInput = new Object[] {result};
70
					} else {
71
						fInput = container.getAllBundles();
72
					}
73
74
				}
75
			});
76
			fPreviewTable.setInput(fInput);
77
		} catch (InvocationTargetException e) {
78
			PDEPlugin.log(e);
79
			setErrorMessage(e.getMessage());
80
		} catch (InterruptedException e) {
81
		}
82
83
	}
84
85
	/* (non-Javadoc)
86
	 * @see org.eclipse.jface.dialogs.DialogPage#setVisible(boolean)
87
	 */
88
	public void setVisible(boolean visible) {
89
		super.setVisible(visible);
90
		if (visible) {
91
			setInput(fPage1.getBundleContainer());
92
		}
93
	}
94
95
}
(-)src/org/eclipse/pde/internal/ui/shared/target/TargetContentsGroup.java (+762 lines)
Added Link Here
1
package org.eclipse.pde.internal.ui.shared.target;
2
3
import com.ibm.icu.text.MessageFormat;
4
import java.net.URI;
5
import java.util.*;
6
import java.util.List;
7
import org.eclipse.core.runtime.*;
8
import org.eclipse.core.runtime.jobs.*;
9
import org.eclipse.jface.viewers.*;
10
import org.eclipse.pde.internal.core.target.provisional.*;
11
import org.eclipse.pde.internal.ui.SWTFactory;
12
import org.eclipse.swt.SWT;
13
import org.eclipse.swt.events.SelectionAdapter;
14
import org.eclipse.swt.events.SelectionEvent;
15
import org.eclipse.swt.layout.GridData;
16
import org.eclipse.swt.widgets.*;
17
import org.eclipse.ui.dialogs.FilteredTree;
18
import org.eclipse.ui.dialogs.PatternFilter;
19
import org.eclipse.ui.forms.widgets.FormToolkit;
20
import org.eclipse.ui.progress.UIJob;
21
22
public class TargetContentsGroup extends FilteredTree {
23
24
	private CheckboxTreeViewer fTree;
25
	private Button fSelectButton;
26
	private Button fDeselectButton;
27
	private Button fSelectAllButton;
28
	private Button fDeselectAllButton;
29
//	private Button fSelectRequiredButton;
30
	private Label fShowLabel;
31
	private Button fShowSourceButton;
32
	private Button fShowPluginsButton;
33
	private Label fCountLabel;
34
	private Label fGroupLabel;
35
	private Combo fGroupCombo;
36
37
	private ViewerFilter fSourceFilter;
38
	private ViewerFilter fPluginFilter;
39
40
	private List fAllBundles;
41
	private Set fAllChecked;
42
	private Map fContainerBundles;
43
	private Map fContainerChecked;
44
	private Map fFileBundles;
45
	private Map fFileChecked;
46
47
	private ITargetDefinition fTargetDefinition;
48
49
	private int fGrouping;
50
	private static final int GROUP_BY_NONE = 0;
51
	private static final int GROUP_BY_FILE_LOC = 1;
52
	private static final int GROUP_BY_CONTAINER = 2;
53
	private ListenerList fChangeListeners = new ListenerList();
54
55
	public static TargetContentsGroup createInForm(Composite parent, FormToolkit toolkit) {
56
		// TODO Should we be using the tooklit to create the controls?
57
		TargetContentsGroup control = new TargetContentsGroup(parent);
58
		return control;
59
	}
60
61
	public static TargetContentsGroup createInDialog(Composite parent) {
62
		TargetContentsGroup control = new TargetContentsGroup(parent);
63
		return control;
64
	}
65
66
	private TargetContentsGroup(Composite parent) {
67
		super(parent, SWT.BORDER | SWT.MULTI, new PatternFilter(), true);
68
	}
69
70
	/**
71
	 * Adds a listener to the set of listeners that will be notified when the bundle containers
72
	 * are modified.  This method has no effect if the listener has already been added. 
73
	 * 
74
	 * @param listener target changed listener to add
75
	 */
76
	public void addTargetChangedListener(ITargetChangedListener listener) {
77
		fChangeListeners.add(listener);
78
	}
79
80
	/**
81
	 * Informs the target content listeners that check state has changed
82
	 */
83
	public void contentChanged() {
84
		// TODO Save the included bundles
85
		Object[] listeners = fChangeListeners.getListeners();
86
		for (int i = 0; i < listeners.length; i++) {
87
			((ITargetChangedListener) listeners[i]).contentsChanged(fTargetDefinition, false);
88
		}
89
	}
90
91
	/* (non-Javadoc)
92
	 * @see org.eclipse.ui.dialogs.FilteredTree#createTreeControl(org.eclipse.swt.widgets.Composite, int)
93
	 */
94
	protected Control createTreeControl(Composite parent, int style) {
95
		fGrouping = GROUP_BY_NONE;
96
		Composite treeComp = SWTFactory.createComposite(parent, 2, 1, GridData.FILL_BOTH, 0, 0);
97
		super.createTreeControl(treeComp, style);
98
		((GridData) fTree.getControl().getLayoutData()).heightHint = 300;
99
		createButtons(treeComp);
100
		createOptions(treeComp);
101
102
		updateButtons();
103
		initializeFilters();
104
		return treeComp;
105
	}
106
107
	/* (non-Javadoc)
108
	 * @see org.eclipse.ui.dialogs.FilteredTree#doCreateTreeViewer(org.eclipse.swt.widgets.Composite, int)
109
	 */
110
	protected TreeViewer doCreateTreeViewer(Composite parent, int style) {
111
		fTree = new CheckboxTreeViewer(parent, style) {
112
			public void refresh(boolean updateLabels) {
113
				super.refresh(updateLabels);
114
				if (updateLabels) {
115
					// We want to update the labels and buttons as users change the filtering
116
					updateButtons();
117
				}
118
			}
119
		};
120
		fTree.setContentProvider(new TreeContentProvider());
121
		fTree.setLabelProvider(new BundleContainerLabelProvider());
122
		fTree.addDoubleClickListener(new IDoubleClickListener() {
123
			public void doubleClick(DoubleClickEvent event) {
124
				IStructuredSelection selection = (IStructuredSelection) event.getSelection();
125
				Object first = selection.getFirstElement();
126
				handleCheck(new Object[] {selection.getFirstElement()}, !fTree.getChecked(first));
127
			}
128
		});
129
		fTree.addCheckStateListener(new ICheckStateListener() {
130
			public void checkStateChanged(CheckStateChangedEvent event) {
131
				handleCheck(new Object[] {event.getElement()}, fTree.getChecked(event.getElement()));
132
			}
133
		});
134
		fTree.addSelectionChangedListener(new ISelectionChangedListener() {
135
			public void selectionChanged(SelectionChangedEvent event) {
136
				updateButtons();
137
			}
138
		});
139
		fTree.setSorter(new ViewerSorter() {
140
			public int compare(Viewer viewer, Object e1, Object e2) {
141
				if (e1 instanceof IResolvedBundle && e2 instanceof IResolvedBundle) {
142
					IStatus status1 = ((IResolvedBundle) e1).getStatus();
143
					IStatus status2 = ((IResolvedBundle) e2).getStatus();
144
					if (!status1.isOK() && status2.isOK()) {
145
						return -1;
146
					}
147
					if (status1.isOK() && !status2.isOK()) {
148
						return 1;
149
					}
150
				}
151
				return super.compare(viewer, e1, e2);
152
			}
153
154
		});
155
		return fTree;
156
	}
157
158
	private void createButtons(Composite parent) {
159
		Composite buttonComp = SWTFactory.createComposite(parent, 1, 1, GridData.FILL_VERTICAL, 0, 0);
160
161
		fSelectButton = SWTFactory.createPushButton(buttonComp, Messages.IncludedBundlesTree_0, null);
162
		fSelectButton.addSelectionListener(new SelectionAdapter() {
163
			public void widgetSelected(SelectionEvent e) {
164
				if (!fTree.getSelection().isEmpty()) {
165
					Object[] selected = ((IStructuredSelection) fTree.getSelection()).toArray();
166
					handleCheck(selected, true);
167
				}
168
			}
169
		});
170
		fDeselectButton = SWTFactory.createPushButton(buttonComp, Messages.IncludedBundlesTree_1, null);
171
		fDeselectButton.addSelectionListener(new SelectionAdapter() {
172
			public void widgetSelected(SelectionEvent e) {
173
				if (!fTree.getSelection().isEmpty()) {
174
					Object[] selected = ((IStructuredSelection) fTree.getSelection()).toArray();
175
					handleCheck(selected, false);
176
				}
177
			}
178
		});
179
180
		createEmptySpace(buttonComp);
181
182
		fSelectAllButton = SWTFactory.createPushButton(buttonComp, Messages.IncludedBundlesTree_2, null);
183
		fSelectAllButton.addSelectionListener(new SelectionAdapter() {
184
			public void widgetSelected(SelectionEvent e) {
185
				// TODO
186
//				Object[] elements = ((ITreeContentProvider) fTree.getContentProvider()).getElements(fTree.getInput());
187
//				fTree.setGrayedElements(new Object[0]);
188
//				for (int i = 0; i < elements.length; i++) {
189
//					fTree.setSubtreeChecked(elements[i], true);
190
//				}
191
//				updateParentCheckState(elements);
192
//				contentChanged();
193
//				updateButtons();
194
			}
195
		});
196
		fDeselectAllButton = SWTFactory.createPushButton(buttonComp, Messages.IncludedBundlesTree_3, null);
197
		fDeselectAllButton.addSelectionListener(new SelectionAdapter() {
198
			public void widgetSelected(SelectionEvent e) {
199
				// TODO
200
//				Object[] elements = ((ITreeContentProvider) fTree.getContentProvider()).getElements(fTree.getInput());
201
//				fTree.setGrayedElements(new Object[0]);
202
//				for (int i = 0; i < elements.length; i++) {
203
//					fTree.setSubtreeChecked(elements[i], false);
204
//				}
205
//				updateParentCheckState(elements);
206
//				contentChanged();
207
//				updateButtons();
208
			}
209
		});
210
211
		createEmptySpace(buttonComp);
212
213
		// TODO Support selecting required.
214
//		fSelectRequiredButton = SWTFactory.createPushButton(buttonComp, Messages.IncludedBundlesTree_4, null);
215
//		fSelectRequiredButton.addSelectionListener(new SelectionAdapter() {
216
//			public void widgetSelected(SelectionEvent e) {
217
//				updateButtons();
218
//			}
219
//		});
220
221
		Composite filterComp = SWTFactory.createComposite(buttonComp, 1, 1, SWT.NONE, 0, 0);
222
		filterComp.setLayoutData(new GridData(SWT.LEFT, SWT.BOTTOM, true, true));
223
224
		fShowLabel = SWTFactory.createLabel(filterComp, Messages.BundleContainerTable_9, 1);
225
226
		fShowPluginsButton = SWTFactory.createCheckButton(filterComp, Messages.BundleContainerTable_14, null, true, 1);
227
		fShowPluginsButton.addSelectionListener(new SelectionAdapter() {
228
			public void widgetSelected(SelectionEvent e) {
229
				if (!fShowPluginsButton.getSelection()) {
230
					fTree.addFilter(fPluginFilter);
231
				} else {
232
					fTree.removeFilter(fPluginFilter);
233
				}
234
				updateButtons();
235
			}
236
		});
237
		fShowPluginsButton.setSelection(true);
238
		GridData gd = new GridData();
239
		gd.horizontalIndent = 10;
240
		fShowPluginsButton.setLayoutData(gd);
241
242
		fShowSourceButton = SWTFactory.createCheckButton(filterComp, Messages.BundleContainerTable_15, null, true, 1);
243
		fShowSourceButton.addSelectionListener(new SelectionAdapter() {
244
			public void widgetSelected(SelectionEvent e) {
245
				if (!fShowSourceButton.getSelection()) {
246
					fTree.addFilter(fSourceFilter);
247
				} else {
248
					fTree.removeFilter(fSourceFilter);
249
				}
250
				updateButtons();
251
			}
252
		});
253
		fShowSourceButton.setSelection(true);
254
		gd = new GridData();
255
		gd.horizontalIndent = 10;
256
		fShowSourceButton.setLayoutData(gd);
257
	}
258
259
	private void createOptions(Composite parent) {
260
		Composite comp = SWTFactory.createComposite(parent, 2, 2, GridData.FILL_HORIZONTAL, 0, 0);
261
262
		fGroupLabel = SWTFactory.createLabel(comp, "Group by:", 1);
263
		fGroupCombo = SWTFactory.createCombo(comp, SWT.READ_ONLY, 1, new String[] {"None", "File Path", "Plug-in Container"});
264
		fGroupCombo.addSelectionListener(new SelectionAdapter() {
265
			public void widgetSelected(SelectionEvent e) {
266
				handleGroupChange();
267
			}
268
		});
269
270
		fCountLabel = SWTFactory.createLabel(comp, "", 2); //$NON-NLS-1$
271
	}
272
273
	private void initializeFilters() {
274
		fSourceFilter = new ViewerFilter() {
275
			public boolean select(Viewer viewer, Object parentElement, Object element) {
276
				if (element instanceof IResolvedBundle) {
277
					if (((IResolvedBundle) element).isSourceBundle()) {
278
						return false;
279
					}
280
				}
281
				return true;
282
			}
283
		};
284
		fPluginFilter = new ViewerFilter() {
285
			public boolean select(Viewer viewer, Object parentElement, Object element) {
286
				if (element instanceof IResolvedBundle) {
287
					if (!((IResolvedBundle) element).isSourceBundle()) {
288
						return false;
289
					}
290
				}
291
				return true;
292
			}
293
		};
294
	}
295
296
	private Label createEmptySpace(Composite parent) {
297
		Label label = new Label(parent, SWT.NONE);
298
		GridData gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
299
		gd.widthHint = gd.heightHint = 5;
300
		label.setLayoutData(gd);
301
		return label;
302
	}
303
304
	private IPath getParentPath(IResolvedBundle bundle) {
305
		URI location = bundle.getBundleInfo().getLocation();
306
		if (location == null) {
307
			return new Path("Unknown");
308
		}
309
		IPath path = new Path(URIUtil.toUnencodedString(location));
310
		path = path.removeLastSegments(1);
311
		return path;
312
	}
313
314
	private void handleCheck(Object[] changedElements, boolean checkState) {
315
		if (changedElements.length > 0) {
316
			if (changedElements[0] instanceof IResolvedBundle) {
317
				Set parentsToUpdate = new HashSet();
318
				for (int i = 0; i < changedElements.length; i++) {
319
					Object parent = ((IResolvedBundle) changedElements[i]).getParentContainer();
320
					if (fGrouping == GROUP_BY_CONTAINER) {
321
						parentsToUpdate.add(parent);
322
					}
323
					Set containerChecked = ((Set) fContainerChecked.get(parent));
324
325
					parent = getParentPath((IResolvedBundle) changedElements[i]);
326
					if (fGrouping == GROUP_BY_FILE_LOC) {
327
						parentsToUpdate.add(parent);
328
					}
329
					Set fileChecked = ((Set) fContainerChecked.get(parent));
330
331
					if (checkState) {
332
						fAllChecked.add(changedElements[i]);
333
						containerChecked.add(changedElements[i]);
334
						fileChecked.add(changedElements[i]);
335
					} else {
336
						fAllChecked.remove(changedElements[i]);
337
						containerChecked.remove(changedElements[i]);
338
						fileChecked.remove(changedElements[i]);
339
					}
340
					fTree.setChecked(changedElements, checkState);
341
				}
342
				for (Iterator iterator = parentsToUpdate.iterator(); iterator.hasNext();) {
343
					Object parent = iterator.next();
344
					if (getChecked(parent).size() == 0) {
345
						fTree.setGrayChecked(parent, false);
346
					} else if (getChecked(parent).size() == getBundleChildren(parent).size()) {
347
						fTree.setGrayed(parent, false);
348
						fTree.setChecked(parent, true);
349
					} else {
350
						fTree.setGrayChecked(parent, true);
351
					}
352
				}
353
			} else {
354
				for (int i = 0; i < changedElements.length; i++) {
355
					fTree.setGrayed(changedElements[i], false);
356
					fTree.setChecked(changedElements[i], checkState);
357
					fTree.setSubtreeChecked(changedElements[i], checkState);
358
					
359
					fgetChecked(changedElements[i]).
360
				}
361
			}
362
		}
363
	}
364
365
	/**
366
	 * Update the check state of parent elements when there is grouping.  The list of changed elements must be
367
	 * all IResolvedBundles.
368
	 * 
369
	 * @param changedElements array of IResolvedBundles that have changed
370
	 */
371
	private void updateParentCheckState(Object[] changedElements) {
372
		if (fGrouping != GROUP_BY_NONE && changedElements.length > 0) {
373
			Set changedParents = new HashSet();
374
			if (changedElements[0] instanceof IResolvedBundle) {
375
				if (fGrouping == GROUP_BY_FILE_LOC) {
376
					for (int i = 0; i < changedElements.length; i++) {
377
						changedParents.add(getParentPath((IResolvedBundle) changedElements[i]));
378
					}
379
				} else if (fGrouping == GROUP_BY_CONTAINER) {
380
					for (int i = 0; i < changedElements.length; i++) {
381
						changedParents.add(((IResolvedBundle) changedElements[i]).getParentContainer());
382
					}
383
				}
384
			} else {
385
				changedParents.addAll(Arrays.asList(changedElements));
386
			}
387
			if (fGrouping == GROUP_BY_FILE_LOC) {
388
				for (Iterator iterator = changedParents.iterator(); iterator.hasNext();) {
389
					IPath currentParent = (IPath) iterator.next();
390
					List children = (List) getFileLocationMap().get(currentParent);
391
					updateGrayChecked(currentParent, children);
392
				}
393
			} else if (fGrouping == GROUP_BY_CONTAINER) {
394
				for (Iterator iterator = changedParents.iterator(); iterator.hasNext();) {
395
					IBundleContainer currentParent = (IBundleContainer) iterator.next();
396
					List children = Arrays.asList(currentParent.getAllBundles());
397
					// TODO Get plug-in errors (missing bundles)
398
					updateGrayChecked(currentParent, children);
399
				}
400
			}
401
		}
402
	}
403
404
	/**
405
	 * Updates the children of the changed parent elements.  Also removed the gray state
406
	 * of the parent.
407
	 * 
408
	 * @param changedElements list of changed parents
409
	 * @param state whether the parents are being checked or unchecked
410
	 */
411
	private void updateChildrenCheckState(Object[] changedElements, boolean state) {
412
		for (int i = 0; i < changedElements.length; i++) {
413
			fTree.setSubtreeChecked(changedElements[i], state);
414
			fTree.setGrayed(changedElements[i], false);
415
			fTree.setChecked(changedElements[i], state);
416
		}
417
	}
418
419
	private void updateGrayChecked(Object parent, List children) {
420
		boolean allChecked = true;
421
		boolean noneChecked = true;
422
		for (Iterator iterator2 = children.iterator(); iterator2.hasNext();) {
423
			boolean checked = fTree.getChecked(iterator2.next());
424
			if (checked) {
425
				noneChecked = false;
426
			} else {
427
				allChecked = false;
428
			}
429
			if (!noneChecked && !allChecked) {
430
				break;
431
			}
432
		}
433
		if (!noneChecked && !allChecked) {
434
			fTree.setGrayChecked(parent, true);
435
		} else if (allChecked) {
436
			fTree.setChecked(parent, true);
437
			fTree.setGrayed(parent, false);
438
		} else {
439
			fTree.setChecked(parent, false);
440
			fTree.setGrayed(parent, false);
441
		}
442
	}
443
444
	private void handleGroupChange() {
445
		// TODO
446
		fGrouping = fGroupCombo.getSelectionIndex();
447
		Object[] checked = fTree.getCheckedElements();
448
		fTree.getControl().setRedraw(false);
449
		fTree.refresh(false);
450
		fTree.setCheckedElements(checked);
451
		if (fGrouping == GROUP_BY_CONTAINER) {
452
			updateParentCheckState(fTargetDefinition.getBundleContainers());
453
		} else if (fGrouping == GROUP_BY_FILE_LOC) {
454
			updateParentCheckState(getFileLocationMap().keySet().toArray());
455
		}
456
		fTree.getControl().setRedraw(true);
457
		updateButtons();
458
	}
459
460
	private void updateButtons() {
461
		if (fTargetDefinition != null && !fTree.getSelection().isEmpty()) {
462
			Object[] selection = ((IStructuredSelection) fTree.getSelection()).toArray();
463
			boolean hasResolveBundle = false;
464
			boolean hasParent = false;
465
			boolean allSelected = true;
466
			boolean noneSelected = true;
467
			for (int i = 0; i < selection.length; i++) {
468
				if (!hasResolveBundle || !hasParent) {
469
					if (selection[i] instanceof IResolvedBundle) {
470
						hasResolveBundle = true;
471
					} else {
472
						hasParent = true;
473
					}
474
				}
475
				boolean checked = fTree.getChecked(selection[i]);
476
				if (checked) {
477
					noneSelected = false;
478
				} else {
479
					allSelected = false;
480
				}
481
			}
482
			// Selection is available is not everything is already selected and not both a parent and child item are selected
483
			fSelectButton.setEnabled(!allSelected && !(hasResolveBundle && hasParent));
484
			fDeselectButton.setEnabled(!noneSelected && !(hasResolveBundle && hasParent));
485
//			fSelectRequiredButton.setEnabled(true);
486
		} else {
487
			fSelectButton.setEnabled(false);
488
			fDeselectButton.setEnabled(false);
489
//			fSelectRequiredButton.setEnabled(false);
490
		}
491
492
		// TODO how to handle filtered case
493
		if (fGrouping == GROUP_BY_FILE_LOC) {
494
			boolean allChecked = true;
495
			boolean noneChecked = true;
496
			if (fTree.getGrayedElements().length > 0) {
497
				allChecked = false;
498
				noneChecked = false;
499
			} else {
500
				for (Iterator iterator = getFileLocationMap().keySet().iterator(); iterator.hasNext();) {
501
					boolean checked = fTree.getChecked(iterator.next());
502
					if (checked) {
503
						noneChecked = false;
504
					} else {
505
						allChecked = false;
506
					}
507
					if (!noneChecked && !allChecked) {
508
						break;
509
					}
510
				}
511
			}
512
			fSelectAllButton.setEnabled(fTargetDefinition != null && !allChecked);
513
			fDeselectAllButton.setEnabled(fTargetDefinition != null && !noneChecked);
514
		} else {
515
			int checked = fTree.getCheckedElements().length;
516
			fSelectAllButton.setEnabled(fTargetDefinition != null && checked != fTree.getTree().getItemCount());
517
			fDeselectAllButton.setEnabled(fTargetDefinition != null && checked != 0);
518
		}
519
520
		if (fTargetDefinition != null) {
521
			fCountLabel.setText(MessageFormat.format("{0} of {1} selected", new String[] {Integer.toString(fAllChecked.size()), Integer.toString(fAllBundles.size())}));
522
		} else {
523
			fCountLabel.setText(""); //$NON-NLS-1$
524
		}
525
	}
526
527
	/**
528
	 * Set the container to display in the tree or <code>null</code> to disable the tree 
529
	 * @param input bundle container or <code>null</code>
530
	 */
531
	public void setInput(ITargetDefinition input) {
532
		fTargetDefinition = input;
533
534
		if (input == null || !input.isResolved()) {
535
			fTree.setInput("Resolving...");
536
			setEnabled(false);
537
			return;
538
		}
539
540
		IResolvedBundle[] allResolvedBundles = input.getAllBundles();
541
		if (allResolvedBundles == null || allResolvedBundles.length == 0) {
542
			fTree.setInput("< no plug-ins found in the target >");
543
			setEnabled(false);
544
			return;
545
		}
546
547
		fTree.setInput("Initializing...");
548
		setEnabled(false);
549
		Job initJob = new InitalizeJob();
550
		initJob.addJobChangeListener(new JobChangeAdapter() {
551
			public void done(IJobChangeEvent event) {
552
				Job refreshJob = new UIJob("Refreshing Tree") {
553
					public IStatus runInUIThread(IProgressMonitor monitor) {
554
						fTree.setInput(fTargetDefinition);
555
						// For now we always start with no grouping
556
						fTree.setCheckedElements(getChecked(null).toArray());
557
						setEnabled(true);
558
						return Status.OK_STATUS;
559
					}
560
				};
561
				refreshJob.setSystem(true);
562
				refreshJob.schedule();
563
			}
564
		});
565
		initJob.schedule();
566
	}
567
568
	private class InitalizeJob extends Job {
569
570
		public InitalizeJob() {
571
			super("Initializing Tree");
572
			setSystem(true);
573
		}
574
575
		protected IStatus run(IProgressMonitor monitor) {
576
			fAllBundles = new ArrayList();
577
			fAllChecked = new HashSet();
578
			fContainerBundles = new HashMap();
579
			fContainerChecked = new HashMap();
580
			IBundleContainer[] containers = fTargetDefinition.getBundleContainers();
581
			// Iterate through each container, adding bundles to the map and list
582
			for (int i = 0; i < containers.length; i++) {
583
				List containerBundles = Arrays.asList(containers[i].getAllBundles());
584
				fAllBundles.addAll(containerBundles);
585
				fContainerBundles.put(containers[i], containerBundles);
586
587
				// Determine which of the bundles are checked (included)
588
				if (containers[i].getIncludedBundles() == null) {
589
					// Everything is included
590
					Set checked = new HashSet();
591
					checked.addAll(containerBundles);
592
					fContainerChecked.put(containers[i], checked);
593
					fAllChecked.addAll(checked);
594
				} else {
595
					// Mark the included bundles as checked
596
					List includedBundles = Arrays.asList(containers[i].getBundles());
597
					// If an included bundle has errors it must be explicitly added to the bundle list as getAllBundles does not return it.
598
					for (Iterator iterator = includedBundles.iterator(); iterator.hasNext();) {
599
						IResolvedBundle currentIncluded = (IResolvedBundle) iterator.next();
600
						if (!currentIncluded.getStatus().isOK()) {
601
							((List) fContainerBundles.get(containers[i])).add(currentIncluded);
602
							fAllBundles.add(currentIncluded);
603
						}
604
					}
605
					Set checked = new HashSet();
606
					checked.addAll(includedBundles);
607
					fContainerChecked.put(containers[i], checked);
608
					fAllChecked.addAll(checked);
609
				}
610
			}
611
612
			// Map the bundles into their file locations
613
			fFileBundles = new HashMap();
614
			fFileChecked = new HashMap();
615
			Set allChecked = new HashSet();
616
			allChecked.addAll(fAllChecked);
617
			for (Iterator iterator = fAllBundles.iterator(); iterator.hasNext();) {
618
				IResolvedBundle currentBundle = (IResolvedBundle) iterator.next();
619
				IPath parentPath = getParentPath(currentBundle);
620
				List bundles = (List) fFileBundles.get(parentPath);
621
				if (bundles == null) {
622
					bundles = new ArrayList();
623
					bundles.add(currentBundle);
624
					fFileBundles.put(parentPath, bundles);
625
				} else {
626
					bundles.add(currentBundle);
627
				}
628
				// Determine whether the current bundle is checked
629
				if (allChecked.contains(currentBundle)) {
630
					Set checked = (Set) fFileChecked.get(parentPath);
631
					if (checked == null) {
632
						checked = new HashSet();
633
						checked.add(currentBundle);
634
						fFileChecked.put(parentPath, checked);
635
					} else {
636
						checked.add(currentBundle);
637
					}
638
				}
639
			}
640
641
			return Status.OK_STATUS;
642
		}
643
	}
644
645
	private Set getChecked(Object parent) {
646
		Set result = null;
647
		if (parent == null) {
648
			result = fAllChecked;
649
		} else if (fGrouping == GROUP_BY_CONTAINER) {
650
			result = (Set) fContainerChecked.get(parent);
651
		} else if (fGrouping == GROUP_BY_FILE_LOC) {
652
			result = (Set) fFileChecked.get(parent);
653
		}
654
		if (result == null) {
655
			return new HashSet(0);
656
		}
657
		return result;
658
	}
659
660
	private List getBundleChildren(Object parent) {
661
		List result = null;
662
		if (parent == null) {
663
			result = fAllBundles;
664
		} else if (fGrouping == GROUP_BY_CONTAINER) {
665
			result = (List) fContainerBundles.get(parent);
666
		} else if (fGrouping == GROUP_BY_FILE_LOC) {
667
			result = (List) fFileBundles.get(parent);
668
		}
669
		if (result == null) {
670
			return new ArrayList(0);
671
		}
672
		return result;
673
	}
674
675
	/* (non-Javadoc)
676
	 * @see org.eclipse.swt.widgets.Control#setEnabled(boolean)
677
	 */
678
	public void setEnabled(boolean enabled) {
679
		super.setEnabled(enabled);
680
		if (enabled) {
681
			updateButtons();
682
		} else {
683
			fSelectButton.setEnabled(false);
684
			fSelectAllButton.setEnabled(false);
685
			fDeselectButton.setEnabled(false);
686
			fDeselectAllButton.setEnabled(false);
687
//			fSelectRequiredButton.setEnabled(false);
688
			fCountLabel.setText(""); //$NON-NLS-1$
689
		}
690
		fShowLabel.setEnabled(enabled);
691
		fShowPluginsButton.setEnabled(enabled);
692
		fShowSourceButton.setEnabled(enabled);
693
		fGroupLabel.setEnabled(enabled);
694
		fGroupCombo.setEnabled(enabled);
695
		super.setEnabled(enabled);
696
	}
697
698
	public void saveIncludedBundleState() {
699
		// TODO Simplify with bundle containers
700
//		IBundleContainer[] containers = fTargetDefinition.getBundleContainers();
701
//		for (int i = 0; i < containers.length; i++) {
702
//			IResolvedBundle[] allBundles = containers[i].getAllBundles();
703
//			List included = new ArrayList(allBundles.length);
704
//			for (int j = 0; j < allBundles.length; j++) {
705
//				if (fTree.getChecked(allBundles[j])) {
706
//					included.add(new BundleInfo(allBundles[j].getBundleInfo().getSymbolicName(), null, null, BundleInfo.NO_LEVEL, false));
707
//				}
708
//			}
709
//			if (included.size() == allBundles.length) {
710
//				containers[i].setIncludedBundles(null);
711
//			} else {
712
//				containers[i].setIncludedBundles((BundleInfo[]) included.toArray(new BundleInfo[included.size()]));
713
//			}
714
//		}
715
		// TODO Handle plug-in errors (missing bundles)
716
	}
717
718
	class TreeContentProvider implements ITreeContentProvider {
719
		public Object[] getChildren(Object parentElement) {
720
			return getBundleChildren(parentElement).toArray();
721
		}
722
723
		public Object getParent(Object element) {
724
//			if (fGrouping == GROUP_BY_CONTAINER && element instanceof IResolvedBundle) {
725
//				return ((IResolvedBundle) element).getParentContainer();
726
//			} else if (fGrouping == GROUP_BY_FILE_LOC && element instanceof IResolvedBundle) {
727
//				return getParentPath((IResolvedBundle) element);
728
//			}
729
			return null;
730
		}
731
732
		public boolean hasChildren(Object element) {
733
			if (fGrouping == GROUP_BY_NONE || element instanceof IResolvedBundle) {
734
				return false;
735
			}
736
			if (element instanceof IBundleContainer || element instanceof IPath) {
737
				return getBundleChildren(element).size() > 0;
738
			}
739
			return false;
740
		}
741
742
		public Object[] getElements(Object inputElement) {
743
			if (inputElement instanceof ITargetDefinition) {
744
				if (fGrouping == GROUP_BY_NONE) {
745
					return fAllBundles.toArray();
746
				} else if (fGrouping == GROUP_BY_CONTAINER) {
747
					return fContainerBundles.keySet().toArray();
748
				} else {
749
					return fFileBundles.keySet().toArray();
750
				}
751
			}
752
			return new Object[] {inputElement};
753
		}
754
755
		public void dispose() {
756
		}
757
758
		public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
759
		}
760
	}
761
762
}
(-)src/org/eclipse/pde/internal/ui/shared/target/TargetLocationsGroup.java (+421 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.pde.internal.ui.shared.target;
12
13
import java.util.ArrayList;
14
import org.eclipse.core.runtime.IStatus;
15
import org.eclipse.core.runtime.ListenerList;
16
import org.eclipse.jface.viewers.*;
17
import org.eclipse.jface.window.Window;
18
import org.eclipse.jface.wizard.WizardDialog;
19
import org.eclipse.pde.internal.core.target.provisional.*;
20
import org.eclipse.pde.internal.ui.SWTFactory;
21
import org.eclipse.pde.internal.ui.editor.FormLayoutFactory;
22
import org.eclipse.pde.internal.ui.editor.targetdefinition.TargetEditor;
23
import org.eclipse.swt.SWT;
24
import org.eclipse.swt.events.SelectionAdapter;
25
import org.eclipse.swt.events.SelectionEvent;
26
import org.eclipse.swt.layout.GridData;
27
import org.eclipse.swt.layout.GridLayout;
28
import org.eclipse.swt.widgets.*;
29
import org.eclipse.ui.forms.widgets.FormToolkit;
30
31
/**
32
 * UI part that can be added to a dialog or to a form editor.  Contains a table displaying
33
 * the bundle containers of a target definition.  Also has buttons to add, edit and remove
34
 * bundle containers of varying types.
35
 * 
36
 * @see TargetEditor
37
 * @see ITargetDefinition
38
 * @see IBundleContainer
39
 */
40
public class TargetLocationsGroup {
41
42
	private TreeViewer fTreeViewer;
43
	private Button fAddButton;
44
	private Button fEditButton;
45
	private Button fRemoveButton;
46
	private Button fRemoveAllButton;
47
	private Button fShowContentButton;
48
49
	private ITargetDefinition fTarget;
50
	private ListenerList fChangeListeners = new ListenerList();
51
52
	/**
53
	 * Creates this part using the form toolkit and adds it to the given composite.
54
	 * 
55
	 * @param parent parent composite
56
	 * @param toolkit toolkit to create the widgets with
57
	 * @param reporter reporter implementation that will handle resolving and changes to the containers
58
	 * @return generated instance of the table part
59
	 */
60
	public static TargetLocationsGroup createInForm(Composite parent, FormToolkit toolkit) {
61
		TargetLocationsGroup contentTable = new TargetLocationsGroup();
62
		contentTable.createFormContents(parent, toolkit);
63
		return contentTable;
64
	}
65
66
	/**
67
	 * Creates this part using standard dialog widgets and adds it to the given composite.
68
	 * 
69
	 * @param parent parent composite
70
	 * @param reporter reporter implementation that will handle resolving and changes to the containers
71
	 * @return generated instance of the table part
72
	 */
73
	public static TargetLocationsGroup createInDialog(Composite parent) {
74
		TargetLocationsGroup contentTable = new TargetLocationsGroup();
75
		contentTable.createDialogContents(parent);
76
		return contentTable;
77
	}
78
79
	/**
80
	 * Private constructor, use one of {@link #createTableInDialog(Composite, ITargetChangedListener)}
81
	 * or {@link #createTableInForm(Composite, FormToolkit, ITargetChangedListener)}.
82
	 * 
83
	 * @param reporter reporter implementation that will handle resolving and changes to the containers
84
	 */
85
	private TargetLocationsGroup() {
86
87
	}
88
89
	/**
90
	 * Adds a listener to the set of listeners that will be notified when the bundle containers
91
	 * are modified.  This method has no effect if the listener has already been added. 
92
	 * 
93
	 * @param listener target changed listener to add
94
	 */
95
	public void addTargetChangedListener(ITargetChangedListener listener) {
96
		fChangeListeners.add(listener);
97
	}
98
99
	/**
100
	 * Creates the part contents from a toolkit
101
	 * @param parent parent composite
102
	 * @param toolkit form toolkit to create widgets
103
	 */
104
	private void createFormContents(Composite parent, FormToolkit toolkit) {
105
		Composite comp = toolkit.createComposite(parent);
106
		comp.setLayout(FormLayoutFactory.createSectionClientGridLayout(false, 2));
107
		comp.setLayoutData(new GridData(GridData.FILL_BOTH | GridData.GRAB_VERTICAL));
108
109
		Tree atree = toolkit.createTree(comp, SWT.V_SCROLL | SWT.H_SCROLL);
110
		atree.setLayout(new GridLayout());
111
		GridData gd = new GridData(GridData.FILL_BOTH);
112
		atree.setLayoutData(gd);
113
114
		Composite buttonComp = toolkit.createComposite(comp);
115
		GridLayout layout = new GridLayout();
116
		layout.marginWidth = layout.marginHeight = 0;
117
		buttonComp.setLayout(layout);
118
		buttonComp.setLayoutData(new GridData(GridData.FILL_VERTICAL));
119
120
		fAddButton = toolkit.createButton(buttonComp, Messages.BundleContainerTable_0, SWT.PUSH);
121
		fEditButton = toolkit.createButton(buttonComp, Messages.BundleContainerTable_1, SWT.PUSH);
122
		fRemoveButton = toolkit.createButton(buttonComp, Messages.BundleContainerTable_2, SWT.PUSH);
123
		fRemoveAllButton = toolkit.createButton(buttonComp, Messages.BundleContainerTable_3, SWT.PUSH);
124
125
		fShowContentButton = toolkit.createButton(comp, "Show plug-in content", SWT.CHECK);
126
127
		initializeTreeViewer(atree);
128
		initializeButtons();
129
130
		toolkit.paintBordersFor(comp);
131
	}
132
133
	/**
134
	 * Creates the part contents using SWTFactory
135
	 * @param parent parent composite
136
	 */
137
	private void createDialogContents(Composite parent) {
138
		Composite comp = SWTFactory.createComposite(parent, 2, 1, GridData.FILL_BOTH, 0, 0);
139
140
		Tree atree = new Tree(comp, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER);
141
		atree.setLayout(new GridLayout());
142
		GridData gd = new GridData(GridData.FILL_BOTH);
143
		gd.widthHint = 200;
144
		atree.setLayoutData(gd);
145
146
		Composite buttonComp = SWTFactory.createComposite(comp, 2, 1, GridData.FILL_BOTH);
147
		GridLayout layout = new GridLayout();
148
		layout.marginHeight = 0;
149
		layout.marginWidth = 0;
150
		buttonComp.setLayout(layout);
151
		buttonComp.setLayoutData(new GridData(GridData.FILL_VERTICAL));
152
153
		fAddButton = SWTFactory.createPushButton(buttonComp, Messages.BundleContainerTable_0, null);
154
		fEditButton = SWTFactory.createPushButton(buttonComp, Messages.BundleContainerTable_1, null);
155
		fRemoveButton = SWTFactory.createPushButton(buttonComp, Messages.BundleContainerTable_2, null);
156
		fRemoveAllButton = SWTFactory.createPushButton(buttonComp, Messages.BundleContainerTable_3, null);
157
158
		fShowContentButton = SWTFactory.createCheckButton(comp, "Show Plug-in Content", null, false, 2);
159
160
		initializeTreeViewer(atree);
161
		initializeButtons();
162
	}
163
164
	/**
165
	 * Sets up the tree viewer using the given tree
166
	 * @param tree
167
	 */
168
	private void initializeTreeViewer(Tree tree) {
169
		fTreeViewer = new TreeViewer(tree);
170
		fTreeViewer.setContentProvider(new BundleContainerContentProvider());
171
		fTreeViewer.setLabelProvider(new BundleContainerLabelProvider());
172
		fTreeViewer.setComparator(new ViewerComparator());
173
		fTreeViewer.addSelectionChangedListener(new ISelectionChangedListener() {
174
			public void selectionChanged(SelectionChangedEvent event) {
175
				updateButtons();
176
			}
177
		});
178
		fTreeViewer.addDoubleClickListener(new IDoubleClickListener() {
179
			public void doubleClick(DoubleClickEvent event) {
180
				if (!event.getSelection().isEmpty()) {
181
					handleEdit();
182
				}
183
			}
184
		});
185
		fTreeViewer.setAutoExpandLevel(AbstractTreeViewer.ALL_LEVELS);
186
	}
187
188
	/**
189
	 * Sets up the buttons, the button fields must already be created before calling this method
190
	 */
191
	private void initializeButtons() {
192
		fAddButton.addSelectionListener(new SelectionAdapter() {
193
			public void widgetSelected(SelectionEvent e) {
194
				handleAdd();
195
			}
196
		});
197
		fAddButton.setLayoutData(new GridData());
198
		SWTFactory.setButtonDimensionHint(fAddButton);
199
200
		fEditButton.addSelectionListener(new SelectionAdapter() {
201
			public void widgetSelected(SelectionEvent e) {
202
				handleEdit();
203
			}
204
		});
205
		fEditButton.setLayoutData(new GridData());
206
		fEditButton.setEnabled(false);
207
		SWTFactory.setButtonDimensionHint(fEditButton);
208
209
		fRemoveButton.addSelectionListener(new SelectionAdapter() {
210
			public void widgetSelected(SelectionEvent e) {
211
				handleRemove();
212
			}
213
		});
214
		fRemoveButton.setLayoutData(new GridData());
215
		fRemoveButton.setEnabled(false);
216
		SWTFactory.setButtonDimensionHint(fRemoveButton);
217
218
		fRemoveAllButton.addSelectionListener(new SelectionAdapter() {
219
			public void widgetSelected(SelectionEvent e) {
220
				handleRemoveAll();
221
			}
222
		});
223
		fRemoveAllButton.setLayoutData(new GridData());
224
		SWTFactory.setButtonDimensionHint(fRemoveAllButton);
225
226
		fShowContentButton.addSelectionListener(new SelectionAdapter() {
227
			public void widgetSelected(SelectionEvent e) {
228
				fTreeViewer.refresh();
229
				fTreeViewer.expandAll();
230
			}
231
		});
232
		fShowContentButton.setLayoutData(new GridData());
233
		SWTFactory.setButtonDimensionHint(fShowContentButton);
234
	}
235
236
	/**
237
	 * Sets the target definition model to use as input for the tree, can be called with different
238
	 * models to change the tree's input.
239
	 * @param target target model
240
	 */
241
	public void setInput(ITargetDefinition target) {
242
		fTarget = target;
243
		refresh();
244
	}
245
246
	/**
247
	 * Refreshes the contents of the table
248
	 */
249
	public void refresh() {
250
		fTreeViewer.setInput(fTarget);
251
		updateButtons();
252
	}
253
254
//	private void setEnabled(boolean enablement) {
255
//		fTreeViewer.getControl().setEnabled(enablement);
256
//		fAddButton.setEnabled(enablement);
257
//
258
//		if (enablement) {
259
//			updateButtons();
260
//		} else {
261
//			fRemoveButton.setEnabled(enablement);
262
//			fRemoveAllButton.setEnabled(enablement);
263
//			fEditButton.setEnabled(enablement);
264
//		}
265
//	}
266
267
	private void handleAdd() {
268
		AddBundleContainerWizard wizard = new AddBundleContainerWizard(fTarget);
269
		Shell parent = fTreeViewer.getTree().getShell();
270
		WizardDialog dialog = new WizardDialog(parent, wizard);
271
		if (dialog.open() != Window.CANCEL) {
272
			contentsChanged();
273
		}
274
	}
275
276
	private void handleEdit() {
277
		IStructuredSelection selection = (IStructuredSelection) fTreeViewer.getSelection();
278
		if (!selection.isEmpty()) {
279
			Object selected = selection.getFirstElement();
280
			IBundleContainer oldContainer = null;
281
			if (selected instanceof IBundleContainer) {
282
				oldContainer = (IBundleContainer) selected;
283
			} else if (selected instanceof IResolvedBundle) {
284
				TreeItem[] treeSelection = fTreeViewer.getTree().getSelection();
285
				if (treeSelection.length > 0) {
286
					Object parent = treeSelection[0].getParentItem().getData();
287
					if (parent instanceof IBundleContainer) {
288
						oldContainer = (IBundleContainer) parent;
289
					}
290
				}
291
			}
292
			if (oldContainer != null) {
293
				Shell parent = fTreeViewer.getTree().getShell();
294
				EditBundleContainerWizard wizard = new EditBundleContainerWizard(oldContainer);
295
				WizardDialog dialog = new WizardDialog(parent, wizard);
296
				if (dialog.open() == Window.OK) {
297
					// Replace the old container with the new one
298
					IBundleContainer newContainer = wizard.getBundleContainer();
299
					if (newContainer != null) {
300
						IBundleContainer[] containers = fTarget.getBundleContainers();
301
						java.util.List newContainers = new ArrayList(containers.length);
302
						for (int i = 0; i < containers.length; i++) {
303
							if (!containers[i].equals(oldContainer)) {
304
								newContainers.add(containers[i]);
305
							}
306
						}
307
						newContainers.add(newContainer);
308
						fTarget.setBundleContainers((IBundleContainer[]) newContainers.toArray(new IBundleContainer[newContainers.size()]));
309
310
						// Update the table
311
						contentsChanged();
312
						fTreeViewer.setSelection(new StructuredSelection(newContainer), true);
313
					}
314
				}
315
			}
316
		}
317
	}
318
319
	private void handleRemove() {
320
		IStructuredSelection selection = (IStructuredSelection) fTreeViewer.getSelection();
321
		if (!selection.isEmpty()) {
322
			Object selected = selection.getFirstElement();
323
			IBundleContainer container = null;
324
			if (selected instanceof IBundleContainer) {
325
				container = (IBundleContainer) selected;
326
				IBundleContainer[] currentContainers = fTarget.getBundleContainers();
327
				ArrayList newBundleContainers = new ArrayList(currentContainers.length);
328
				for (int i = 0; i < currentContainers.length; i++) {
329
					if (!currentContainers[i].equals(container)) {
330
						newBundleContainers.add(currentContainers[i]);
331
					}
332
				}
333
				fTarget.setBundleContainers((IBundleContainer[]) newBundleContainers.toArray(new IBundleContainer[newBundleContainers.size()]));
334
				contentsChanged();
335
			}
336
		}
337
	}
338
339
	private void handleRemoveAll() {
340
		fTarget.setBundleContainers(null);
341
		contentsChanged();
342
	}
343
344
	private void updateButtons() {
345
		IStructuredSelection selection = (IStructuredSelection) fTreeViewer.getSelection();
346
		fEditButton.setEnabled(!selection.isEmpty() && selection.getFirstElement() instanceof IBundleContainer);
347
		fRemoveButton.setEnabled(!selection.isEmpty() && selection.getFirstElement() instanceof IBundleContainer);
348
		fRemoveAllButton.setEnabled(fTarget != null && fTarget.getBundleContainers() != null && fTarget.getBundleContainers().length > 0);
349
	}
350
351
	/**
352
	 * Informs the reporter for this table that something has changed
353
	 * and is dirty.
354
	 */
355
	private void contentsChanged() {
356
		Object[] listeners = fChangeListeners.getListeners();
357
		for (int i = 0; i < listeners.length; i++) {
358
			((ITargetChangedListener) listeners[i]).contentsChanged(fTarget, true);
359
		}
360
		refresh();
361
	}
362
363
	/**
364
	 * Content provider for the tree, primary input is a ITargetDefinition, children are IBundleContainers
365
	 */
366
	class BundleContainerContentProvider implements ITreeContentProvider {
367
368
		public Object[] getChildren(Object parentElement) {
369
			if (parentElement instanceof ITargetDefinition) {
370
				IBundleContainer[] containers = ((ITargetDefinition) parentElement).getBundleContainers();
371
				return containers != null ? containers : new Object[0];
372
			} else if (parentElement instanceof IBundleContainer) {
373
				IBundleContainer container = (IBundleContainer) parentElement;
374
				if (container.isResolved()) {
375
					IStatus status = container.getBundleStatus();
376
					if (!status.isOK() && !status.isMultiStatus()) {
377
						return new Object[] {status};
378
					}
379
					if (fShowContentButton.getSelection()) {
380
						return container.getBundles();
381
					} else if (!status.isOK()) {
382
						// Show multi-status children so user can easily see problems
383
						if (status.isMultiStatus()) {
384
							return status.getChildren();
385
						}
386
					}
387
				}
388
			}
389
			return new Object[0];
390
		}
391
392
		public Object getParent(Object element) {
393
			return null;
394
		}
395
396
		public boolean hasChildren(Object element) {
397
			// Since we are already resolved we can't be more efficient
398
			return getChildren(element).length > 0;
399
		}
400
401
		public Object[] getElements(Object inputElement) {
402
			if (inputElement instanceof ITargetDefinition) {
403
				IBundleContainer[] containers = ((ITargetDefinition) inputElement).getBundleContainers();
404
				if (containers != null) {
405
					return containers;
406
				}
407
			} else if (inputElement instanceof String) {
408
				return new Object[] {inputElement};
409
			}
410
			return new Object[0];
411
		}
412
413
		public void dispose() {
414
		}
415
416
		public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
417
		}
418
419
	}
420
421
}
(-)src/org/eclipse/pde/internal/core/target/provisional/IResolvedBundle.java (+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 / +6 lines)
Lines 299-305 Link Here
299
				sev = IStatus.INFO;
299
				sev = IStatus.INFO;
300
				message = NLS.bind(Messages.AbstractBundleContainer_2, new Object[] {info.getVersion(), info.getSymbolicName()});
300
				message = NLS.bind(Messages.AbstractBundleContainer_2, new Object[] {info.getVersion(), info.getSymbolicName()});
301
			}
301
			}
302
			return new ResolvedBundle(info, new Status(sev, PDECore.PLUGIN_ID, IResolvedBundle.STATUS_VERSION_DOES_NOT_EXIST, message, null), false, optional, false);
302
			return new ResolvedBundle(info, null, new Status(sev, PDECore.PLUGIN_ID, IResolvedBundle.STATUS_VERSION_DOES_NOT_EXIST, message, null), false, optional, false);
303
		}
303
		}
304
		// DOES NOT EXIST
304
		// DOES NOT EXIST
305
		int sev = IStatus.ERROR;
305
		int sev = IStatus.ERROR;
Lines 308-314 Link Here
308
			sev = IStatus.INFO;
308
			sev = IStatus.INFO;
309
			message = NLS.bind(Messages.AbstractBundleContainer_4, info.getSymbolicName());
309
			message = NLS.bind(Messages.AbstractBundleContainer_4, info.getSymbolicName());
310
		}
310
		}
311
		return new ResolvedBundle(info, new Status(sev, PDECore.PLUGIN_ID, IResolvedBundle.STATUS_DOES_NOT_EXIST, message, null), false, optional, false);
311
		return new ResolvedBundle(info, null, new Status(sev, PDECore.PLUGIN_ID, IResolvedBundle.STATUS_DOES_NOT_EXIST, message, null), false, optional, false);
312
	}
312
	}
313
313
314
	/**
314
	/**
Lines 405-413 Link Here
405
			}
405
			}
406
			return ManifestElement.parseBundleManifest(manifestStream, new Hashtable(10));
406
			return ManifestElement.parseBundleManifest(manifestStream, new Hashtable(10));
407
		} catch (BundleException e) {
407
		} catch (BundleException e) {
408
			throw new CoreException(new Status(IStatus.ERROR, PDECore.PLUGIN_ID, IResolvedBundle.STATUS_INVALID_MANIFEST, Messages.AbstractBundleContainer_5, e));
408
			throw new CoreException(new Status(IStatus.ERROR, PDECore.PLUGIN_ID, IResolvedBundle.STATUS_INVALID_MANIFEST, NLS.bind(Messages.DirectoryBundleContainer_3, bundle.getSymbolicName()), e));
409
		} catch (IOException e) {
409
		} catch (IOException e) {
410
			throw new CoreException(new Status(IStatus.ERROR, PDECore.PLUGIN_ID, IResolvedBundle.STATUS_INVALID_MANIFEST, Messages.AbstractBundleContainer_5, e));
410
			throw new CoreException(new Status(IStatus.ERROR, PDECore.PLUGIN_ID, IResolvedBundle.STATUS_INVALID_MANIFEST, NLS.bind(Messages.DirectoryBundleContainer_3, bundle.getSymbolicName()), e));
411
		} finally {
411
		} finally {
412
			closeZipFileAndStream(manifestStream, jarFile);
412
			closeZipFileAndStream(manifestStream, jarFile);
413
		}
413
		}
Lines 501-507 Link Here
501
		} catch (CoreException e) {
501
		} catch (CoreException e) {
502
			status = e.getStatus();
502
			status = e.getStatus();
503
		}
503
		}
504
		return new ResolvedBundle(info, status, source, false, fragment);
504
		return new ResolvedBundle(info, this, status, source, false, fragment);
505
	}
505
	}
506
506
507
	/**
507
	/**
Lines 542-548 Link Here
542
							}
542
							}
543
							boolean source = isSourceBundle(file, name, manifest);
543
							boolean source = isSourceBundle(file, name, manifest);
544
							boolean fragment = manifest.containsKey(Constants.FRAGMENT_HOST);
544
							boolean fragment = manifest.containsKey(Constants.FRAGMENT_HOST);
545
							ResolvedBundle rb = new ResolvedBundle(info, null, source, false, fragment);
545
							ResolvedBundle rb = new ResolvedBundle(info, this, null, source, false, fragment);
546
							rb.setSourcePath(fSourcePath);
546
							rb.setSourcePath(fSourcePath);
547
							return rb;
547
							return rb;
548
						}
548
						}
(-)src/org/eclipse/pde/internal/core/target/impl/Messages.properties (-5 / +4 lines)
Lines 10-20 Link Here
10
###############################################################################
10
###############################################################################
11
11
12
AbstractBundleContainer_0=Problems occurred while resolving plug-ins in the target
12
AbstractBundleContainer_0=Problems occurred while resolving plug-ins in the target
13
AbstractBundleContainer_2=Missing version {0} of optional plug-in: {1}
13
AbstractBundleContainer_2=Optional plug-in with version {0} could not be found: {1}
14
AbstractBundleContainer_3=Missing required plug-in: {0}
14
AbstractBundleContainer_3=Required plug-in could not be found: {0}
15
AbstractBundleContainer_4=Missing optional plug-in: {0}
15
AbstractBundleContainer_4=Optional plug-in could not be found: {0}
16
AbstractBundleContainer_5=Error reading bundle manifest
16
AbstractBundleContainer_1=Required plug-in with version {0} not found: {1}
17
AbstractBundleContainer_1=Missing required version {0} of plug-in: {1}
18
DirectoryBundleContainer_0=Reading bundles...
17
DirectoryBundleContainer_0=Reading bundles...
19
DirectoryBundleContainer_1=Directory does not exist: {0}
18
DirectoryBundleContainer_1=Directory does not exist: {0}
20
DirectoryBundleContainer_2=Error converting manifest for {0}
19
DirectoryBundleContainer_2=Error converting manifest for {0}
(-)src/org/eclipse/pde/internal/core/target/impl/ProfileBundleContainer.java (-1 / +6 lines)
Lines 89-99 Link Here
89
	 * @see org.eclipse.pde.internal.core.target.impl.AbstractBundleContainer#resolveBundles(org.eclipse.pde.internal.core.target.provisional.ITargetDefinition, org.eclipse.core.runtime.IProgressMonitor)
89
	 * @see org.eclipse.pde.internal.core.target.impl.AbstractBundleContainer#resolveBundles(org.eclipse.pde.internal.core.target.provisional.ITargetDefinition, org.eclipse.core.runtime.IProgressMonitor)
90
	 */
90
	 */
91
	protected IResolvedBundle[] resolveBundles(ITargetDefinition definition, IProgressMonitor monitor) throws CoreException {
91
	protected IResolvedBundle[] resolveBundles(ITargetDefinition definition, IProgressMonitor monitor) throws CoreException {
92
		URL configUrl = getConfigurationArea();
93
		String home = resolveHomeLocation().toOSString();
92
		String home = resolveHomeLocation().toOSString();
94
		if (!new File(home).isDirectory()) {
93
		if (!new File(home).isDirectory()) {
95
			throw new CoreException(new Status(IStatus.ERROR, PDECore.PLUGIN_ID, NLS.bind(Messages.ProfileBundleContainer_0, home)));
94
			throw new CoreException(new Status(IStatus.ERROR, PDECore.PLUGIN_ID, NLS.bind(Messages.ProfileBundleContainer_0, home)));
96
		}
95
		}
96
97
		URL configUrl = getConfigurationArea();
98
		if (!new File(configUrl.getFile()).isDirectory()) {
99
			throw new CoreException(new Status(IStatus.ERROR, PDECore.PLUGIN_ID, NLS.bind("Configuration directory does not exist: {0}", home)));
100
		}
101
97
		BundleInfo[] infos = P2Utils.readBundles(home, configUrl);
102
		BundleInfo[] infos = P2Utils.readBundles(home, configUrl);
98
		if (infos == null) {
103
		if (infos == null) {
99
			IResolvedBundle[] platformXML = resolvePlatformXML(definition, home, monitor);
104
			IResolvedBundle[] platformXML = resolvePlatformXML(definition, home, monitor);
(-)src/org/eclipse/pde/internal/core/plugin/PluginObject.java (-16 / +13 lines)
Lines 13-32 Link Here
13
import java.io.PrintWriter;
13
import java.io.PrintWriter;
14
import java.io.Serializable;
14
import java.io.Serializable;
15
import java.util.Vector;
15
import java.util.Vector;
16
16
import org.eclipse.core.runtime.*;
17
import org.eclipse.core.runtime.CoreException;
17
import org.eclipse.pde.core.*;
18
import org.eclipse.core.runtime.IStatus;
18
import org.eclipse.pde.core.plugin.*;
19
import org.eclipse.core.runtime.PlatformObject;
20
import org.eclipse.core.runtime.Status;
21
import org.eclipse.pde.core.IModel;
22
import org.eclipse.pde.core.IModelChangeProvider;
23
import org.eclipse.pde.core.IModelChangedEvent;
24
import org.eclipse.pde.core.ISourceObject;
25
import org.eclipse.pde.core.ModelChangedEvent;
26
import org.eclipse.pde.core.plugin.IPluginBase;
27
import org.eclipse.pde.core.plugin.IPluginModelBase;
28
import org.eclipse.pde.core.plugin.IPluginObject;
29
import org.eclipse.pde.core.plugin.ISharedPluginModel;
30
import org.eclipse.pde.internal.core.PDECore;
19
import org.eclipse.pde.internal.core.PDECore;
31
import org.eclipse.pde.internal.core.PDECoreMessages;
20
import org.eclipse.pde.internal.core.PDECoreMessages;
32
import org.eclipse.pde.internal.core.ibundle.IBundlePluginModelProvider;
21
import org.eclipse.pde.internal.core.ibundle.IBundlePluginModelProvider;
Lines 184-191 Link Here
184
	}
173
	}
185
174
186
	public String toString() {
175
	public String toString() {
187
		if (fName != null)
176
		String result = null;
188
			return fName;
177
		if (fName != null) {
178
			result = fName;
179
		}
180
		if ((result == null || result.indexOf('%') >= 0) && fModel != null) {
181
			result = fModel.toString();
182
		}
183
		if (result != null) {
184
			return result;
185
		}
189
		return super.toString();
186
		return super.toString();
190
	}
187
	}
191
188
(-)META-INF/MANIFEST.MF (-1 / +5 lines)
Lines 58-64 Link Here
58
 org.eclipse.ant.core;bundle-version="[3.1.0,4.0.0)",
58
 org.eclipse.ant.core;bundle-version="[3.1.0,4.0.0)",
59
 org.eclipse.equinox.simpleconfigurator.manipulator;bundle-version="[1.0.100,2.0.0)",
59
 org.eclipse.equinox.simpleconfigurator.manipulator;bundle-version="[1.0.100,2.0.0)",
60
 org.eclipse.equinox.frameworkadmin;bundle-version="[1.0.100,2.0.0)",
60
 org.eclipse.equinox.frameworkadmin;bundle-version="[1.0.100,2.0.0)",
61
 org.eclipse.debug.core;bundle-version="[3.5.0,4.0.0)"
61
 org.eclipse.debug.core;bundle-version="[3.5.0,4.0.0)",
62
 org.eclipse.equinox.p2.metadata;bundle-version="[1.0.0,2.0.0)",
63
 org.eclipse.equinox.p2.director;bundle-version="[1.0.100,2.0.0)",
64
 org.eclipse.equinox.p2.core;bundle-version="[1.0.100,2.0.0)",
65
 org.eclipse.equinox.p2.repository.tools;bundle-version="[1.0.0,2.0.0)"
62
Eclipse-LazyStart: true
66
Eclipse-LazyStart: true
63
Bundle-RequiredExecutionEnvironment: J2SE-1.4
67
Bundle-RequiredExecutionEnvironment: J2SE-1.4
64
Import-Package: com.ibm.icu.util
68
Import-Package: com.ibm.icu.util
(-)src/org/eclipse/pde/internal/core/target/impl/P2BundleContainer.java (+92 lines)
Added Link Here
1
package org.eclipse.pde.internal.core.target.impl;
2
3
import org.eclipse.core.runtime.CoreException;
4
import org.eclipse.core.runtime.IProgressMonitor;
5
import org.eclipse.equinox.internal.p2.director.PermissiveSlicer;
6
import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit;
7
import org.eclipse.equinox.p2.internal.repository.tools.Repo2Runnable;
8
import org.eclipse.equinox.p2.internal.repository.tools.RepositoryDescriptor;
9
import org.eclipse.pde.internal.core.target.provisional.IResolvedBundle;
10
import org.eclipse.pde.internal.core.target.provisional.ITargetDefinition;
11
12
public class P2BundleContainer extends AbstractBundleContainer {
13
14
	/**
15
	 * Constant describing the type of bundle container 
16
	 */
17
	public static final String TYPE = "P2Repo"; //$NON-NLS-1$
18
19
	private IInstallableUnit[] fUnits;
20
	private String fDownloadDir;
21
	private String[] fSourceRepos = null;
22
23
	public P2BundleContainer() {
24
		fDownloadDir = "/home/cwindatt/Desktop/Export";
25
	}
26
27
	/* (non-Javadoc)
28
	 * @see org.eclipse.pde.internal.core.target.impl.AbstractBundleContainer#getLocation(boolean)
29
	 */
30
	public String getLocation(boolean resolve) throws CoreException {
31
		// TODO We are breaking getVMArguments and other places this method is used
32
		return fDownloadDir;
33
	}
34
35
	public String[] getSourceRepos() {
36
		return fSourceRepos;
37
	}
38
39
	public void setSourceRepos(String[] sourceRepos) {
40
		fSourceRepos = sourceRepos;
41
	}
42
43
	public IInstallableUnit[] getRequiredUnits() {
44
		return fUnits;
45
	}
46
47
	public void setRequiredUnits(IInstallableUnit[] units) {
48
		fUnits = units;
49
	}
50
51
	/* (non-Javadoc)
52
	 * @see org.eclipse.pde.internal.core.target.impl.AbstractBundleContainer#getType()
53
	 */
54
	public String getType() {
55
		return TYPE;
56
	}
57
58
	/* (non-Javadoc)
59
	 * @see org.eclipse.pde.internal.core.target.impl.AbstractBundleContainer#resolveBundles(org.eclipse.pde.internal.core.target.provisional.ITargetDefinition, org.eclipse.core.runtime.IProgressMonitor)
60
	 */
61
	protected IResolvedBundle[] resolveBundles(ITargetDefinition definition, IProgressMonitor monitor) throws CoreException {
62
		// Create queryable for all source repos
63
64
		// Use the slicer to get the complete list of ius to grab
65
		PermissiveSlicer slicer = new PermissiveSlicer(null, null, true, true, true, true);
66
		slicer.slice(fUnits, monitor);
67
68
		// We need to get the features as well'
69
//		org.eclipse.update.install.features=true
70
71
		// Download artifacts to the folder
72
		Repo2Runnable runnable = new Repo2Runnable();
73
		runnable.addDestination(new RepositoryDescriptor());
74
		runnable.run(monitor);
75
76
//		try {
77
//			Repo2Runnable tool = new Repo2Runnable();
78
//			tool.setDestinationArtifactRepository(fInstallDir.toString());
79
//			tool.setDestinationMetadataRepository(fInstallDir.toString());
80
//			tool.setSourceIUs(Arrays.asList(fUnits));
81
//			IStatus result = tool.run(SubMonitor.convert(monitor, 1));
82
//			if (result.matches(IStatus.ERROR))
83
//				throw new ProvisionException(result);
84
//			fLocations = new File[] {fInstallDir};
85
//		} catch (ProvisionException e) {
86
//			throw new InvocationTargetException(e);
87
//		}
88
89
		// Use the iu's to create resolved bundles
90
		return new IResolvedBundle[0];
91
	}
92
}

Return to bug 270626