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 (-11 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 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 (-1 / +1 lines)
Lines 356-362 Link Here
356
			}
356
			}
357
			if (oldContainer != null) {
357
			if (oldContainer != null) {
358
				Shell parent = fTreeViewer.getTree().getShell();
358
				Shell parent = fTreeViewer.getTree().getShell();
359
				EditBundleContainerWizard wizard = new EditBundleContainerWizard(fTarget, oldContainer);
359
				EditBundleContainerWizard wizard = new EditBundleContainerWizard(oldContainer);
360
				WizardDialog dialog = new WizardDialog(parent, wizard);
360
				WizardDialog dialog = new WizardDialog(parent, wizard);
361
				if (dialog.open() == Window.OK) {
361
				if (dialog.open() == Window.OK) {
362
					// Replace the old container with the new one
362
					// Replace the old container with the new one
(-)src/org/eclipse/pde/internal/ui/shared/target/messages.properties (-1 lines)
Lines 69-75 Link Here
69
EditBundleContainerWizard_0=Edit Content
69
EditBundleContainerWizard_0=Edit Content
70
EditDirectoryContainerPage_0=Edit Directory
70
EditDirectoryContainerPage_0=Edit Directory
71
EditDirectoryContainerPage_1=&Variables...
71
EditDirectoryContainerPage_1=&Variables...
72
EditDirectoryContainerPage_2=Included Plug-ins
73
EditDirectoryContainerPage_3=Resolve Container Job
72
EditDirectoryContainerPage_3=Resolve Container Job
74
EditFeatureContainerPage_0=Edit Feature
73
EditFeatureContainerPage_0=Edit Feature
75
EditFeatureContainerPage_1=Edit the plug-ins included in this feature
74
EditFeatureContainerPage_1=Edit the plug-ins included in this feature
(-)src/org/eclipse/pde/internal/ui/shared/target/Messages.java (-1 lines)
Lines 63-69 Link Here
63
	public static String EditBundleContainerWizard_0;
63
	public static String EditBundleContainerWizard_0;
64
	public static String EditDirectoryContainerPage_0;
64
	public static String EditDirectoryContainerPage_0;
65
	public static String EditDirectoryContainerPage_1;
65
	public static String EditDirectoryContainerPage_1;
66
	public static String EditDirectoryContainerPage_2;
67
	public static String EditDirectoryContainerPage_3;
66
	public static String EditDirectoryContainerPage_3;
68
	public static String EditFeatureContainerPage_0;
67
	public static String EditFeatureContainerPage_0;
69
	public static String EditFeatureContainerPage_1;
68
	public static String EditFeatureContainerPage_1;
(-)src/org/eclipse/pde/internal/ui/shared/target/IncludedBundlesTree.java (-598 / +598 lines)
Lines 1-598 Link Here
1
package org.eclipse.pde.internal.ui.shared.target;
1
package org.eclipse.pde.internal.ui.shared.target;
2
2
3
import com.ibm.icu.text.MessageFormat;
3
import com.ibm.icu.text.MessageFormat;
4
import java.io.File;
4
import java.io.File;
5
import java.util.*;
5
import java.util.*;
6
import org.eclipse.core.runtime.IStatus;
6
import org.eclipse.core.runtime.IStatus;
7
import org.eclipse.core.runtime.Status;
7
import org.eclipse.core.runtime.Status;
8
import org.eclipse.equinox.internal.provisional.frameworkadmin.BundleInfo;
8
import org.eclipse.equinox.internal.provisional.frameworkadmin.BundleInfo;
9
import org.eclipse.jface.viewers.*;
9
import org.eclipse.jface.viewers.*;
10
import org.eclipse.pde.internal.core.target.impl.AbstractBundleContainer;
10
import org.eclipse.pde.internal.core.target.impl.AbstractBundleContainer;
11
import org.eclipse.pde.internal.core.target.provisional.IBundleContainer;
11
import org.eclipse.pde.internal.core.target.provisional.IResolvedBundle;
12
import org.eclipse.pde.internal.core.target.provisional.IResolvedBundle;
12
import org.eclipse.pde.internal.core.target.provisional.ITargetDefinition;
13
import org.eclipse.pde.internal.ui.PDEPlugin;
13
import org.eclipse.pde.internal.ui.PDEPlugin;
14
import org.eclipse.pde.internal.ui.SWTFactory;
14
import org.eclipse.pde.internal.ui.SWTFactory;
15
import org.eclipse.swt.SWT;
15
import org.eclipse.swt.SWT;
16
import org.eclipse.swt.events.SelectionAdapter;
16
import org.eclipse.swt.events.SelectionAdapter;
17
import org.eclipse.swt.events.SelectionEvent;
17
import org.eclipse.swt.events.SelectionEvent;
18
import org.eclipse.swt.layout.GridData;
18
import org.eclipse.swt.layout.GridData;
19
import org.eclipse.swt.widgets.*;
19
import org.eclipse.swt.widgets.*;
20
import org.eclipse.ui.dialogs.FilteredTree;
20
import org.eclipse.ui.dialogs.FilteredTree;
21
import org.eclipse.ui.dialogs.PatternFilter;
21
import org.eclipse.ui.dialogs.PatternFilter;
22
22
23
public class IncludedBundlesTree extends FilteredTree {
23
public class IncludedBundlesTree extends FilteredTree {
24
24
25
	private CheckboxTreeViewer fTree;
25
	private CheckboxTreeViewer fTree;
26
	private Button fSelectButton;
26
	private Button fSelectButton;
27
	private Button fDeselectButton;
27
	private Button fDeselectButton;
28
	private Button fSelectAllButton;
28
	private Button fSelectAllButton;
29
	private Button fDeselectAllButton;
29
	private Button fDeselectAllButton;
30
//	private Button fSelectRequiredButton;
30
//	private Button fSelectRequiredButton;
31
	private Label fShowLabel;
31
	private Label fShowLabel;
32
	private Button fShowSourceButton;
32
	private Button fShowSourceButton;
33
	private Button fShowPluginsButton;
33
	private Button fShowPluginsButton;
34
	private Label fCountLabel;
34
	private Label fCountLabel;
35
	private ViewerFilter fSourceFilter;
35
	private ViewerFilter fSourceFilter;
36
	private ViewerFilter fPluginFilter;
36
	private ViewerFilter fPluginFilter;
37
	private IResolvedBundle[] fAllBundles;
37
	private IResolvedBundle[] fAllBundles;
38
	private Button fGroupPlugins;
38
	private Button fGroupPlugins;
39
	private HashMap fTreeViewerContents;
39
	private HashMap fTreeViewerContents;
40
	private boolean fIsGroupedByLocation;
40
	private boolean fIsGroupedByLocation;
41
41
42
	public IncludedBundlesTree(Composite parent) {
42
	public IncludedBundlesTree(Composite parent) {
43
		super(parent, SWT.BORDER | SWT.MULTI, new PatternFilter(), true);
43
		super(parent, SWT.BORDER | SWT.MULTI, new PatternFilter(), true);
44
	}
44
	}
45
45
46
	protected Control createTreeControl(Composite parent, int style) {
46
	protected Control createTreeControl(Composite parent, int style) {
47
		fIsGroupedByLocation = false;
47
		fIsGroupedByLocation = false;
48
		Composite treeComp = SWTFactory.createComposite(parent, 2, 1, GridData.FILL_BOTH, 0, 0);
48
		Composite treeComp = SWTFactory.createComposite(parent, 2, 1, GridData.FILL_BOTH, 0, 0);
49
		super.createTreeControl(treeComp, style);
49
		super.createTreeControl(treeComp, style);
50
		((GridData) fTree.getControl().getLayoutData()).heightHint = 300;
50
		((GridData) fTree.getControl().getLayoutData()).heightHint = 300;
51
		createButtons(treeComp);
51
		createButtons(treeComp);
52
		fCountLabel = SWTFactory.createLabel(treeComp, "", 2); //$NON-NLS-1$
52
		fCountLabel = SWTFactory.createLabel(treeComp, "", 2); //$NON-NLS-1$
53
		updateButtons();
53
		updateButtons();
54
		initializeFilters();
54
		initializeFilters();
55
		initializeTreeContents(fAllBundles);
55
		initializeTreeContents(fAllBundles);
56
		return treeComp;
56
		return treeComp;
57
	}
57
	}
58
58
59
	protected void createButtons(Composite parent) {
59
	protected void createButtons(Composite parent) {
60
		Composite buttonComp = SWTFactory.createComposite(parent, 1, 1, GridData.FILL_VERTICAL, 0, 0);
60
		Composite buttonComp = SWTFactory.createComposite(parent, 1, 1, GridData.FILL_VERTICAL, 0, 0);
61
61
62
		// TODO Add Mnemonics
62
		// TODO Add Mnemonics
63
		fSelectButton = SWTFactory.createPushButton(buttonComp, Messages.IncludedBundlesTree_0, null);
63
		fSelectButton = SWTFactory.createPushButton(buttonComp, Messages.IncludedBundlesTree_0, null);
64
		fSelectButton.addSelectionListener(new SelectionAdapter() {
64
		fSelectButton.addSelectionListener(new SelectionAdapter() {
65
			public void widgetSelected(SelectionEvent e) {
65
			public void widgetSelected(SelectionEvent e) {
66
				if (!fTree.getSelection().isEmpty()) {
66
				if (!fTree.getSelection().isEmpty()) {
67
					Object[] selected = ((IStructuredSelection) fTree.getSelection()).toArray();
67
					Object[] selected = ((IStructuredSelection) fTree.getSelection()).toArray();
68
					for (int i = 0; i < selected.length; i++) {
68
					for (int i = 0; i < selected.length; i++) {
69
						if (fIsGroupedByLocation) {
69
						if (fIsGroupedByLocation) {
70
							handleCheck(selected[i], true);
70
							handleCheck(selected[i], true);
71
						} else {
71
						} else {
72
							fTree.setChecked(selected[i], true);
72
							fTree.setChecked(selected[i], true);
73
						}
73
						}
74
					}
74
					}
75
					updateButtons();
75
					updateButtons();
76
				}
76
				}
77
			}
77
			}
78
		});
78
		});
79
		fDeselectButton = SWTFactory.createPushButton(buttonComp, Messages.IncludedBundlesTree_1, null);
79
		fDeselectButton = SWTFactory.createPushButton(buttonComp, Messages.IncludedBundlesTree_1, null);
80
		fDeselectButton.addSelectionListener(new SelectionAdapter() {
80
		fDeselectButton.addSelectionListener(new SelectionAdapter() {
81
			public void widgetSelected(SelectionEvent e) {
81
			public void widgetSelected(SelectionEvent e) {
82
				if (!fTree.getSelection().isEmpty()) {
82
				if (!fTree.getSelection().isEmpty()) {
83
					Object[] selected = ((IStructuredSelection) fTree.getSelection()).toArray();
83
					Object[] selected = ((IStructuredSelection) fTree.getSelection()).toArray();
84
					for (int i = 0; i < selected.length; i++) {
84
					for (int i = 0; i < selected.length; i++) {
85
						if (fIsGroupedByLocation) {
85
						if (fIsGroupedByLocation) {
86
							handleCheck(selected[i], false);
86
							handleCheck(selected[i], false);
87
						} else {
87
						} else {
88
							fTree.setChecked(selected[i], false);
88
							fTree.setChecked(selected[i], false);
89
						}
89
						}
90
					}
90
					}
91
					updateButtons();
91
					updateButtons();
92
				}
92
				}
93
			}
93
			}
94
		});
94
		});
95
95
96
		createEmptySpace(buttonComp);
96
		createEmptySpace(buttonComp);
97
97
98
		fSelectAllButton = SWTFactory.createPushButton(buttonComp, Messages.IncludedBundlesTree_2, null);
98
		fSelectAllButton = SWTFactory.createPushButton(buttonComp, Messages.IncludedBundlesTree_2, null);
99
		fSelectAllButton.addSelectionListener(new SelectionAdapter() {
99
		fSelectAllButton.addSelectionListener(new SelectionAdapter() {
100
			public void widgetSelected(SelectionEvent e) {
100
			public void widgetSelected(SelectionEvent e) {
101
				if (fIsGroupedByLocation) {
101
				if (fIsGroupedByLocation) {
102
					Iterator iter = fTreeViewerContents.keySet().iterator();
102
					Iterator iter = fTreeViewerContents.keySet().iterator();
103
					while (iter.hasNext()) {
103
					while (iter.hasNext()) {
104
						handleCheck(iter.next(), true);
104
						handleCheck(iter.next(), true);
105
					}
105
					}
106
106
107
				} else {
107
				} else {
108
					// We only want to check visible
108
					// We only want to check visible
109
					fTree.setAllChecked(true);
109
					fTree.setAllChecked(true);
110
				}
110
				}
111
111
112
				updateButtons();
112
				updateButtons();
113
			}
113
			}
114
		});
114
		});
115
		fDeselectAllButton = SWTFactory.createPushButton(buttonComp, Messages.IncludedBundlesTree_3, null);
115
		fDeselectAllButton = SWTFactory.createPushButton(buttonComp, Messages.IncludedBundlesTree_3, null);
116
		fDeselectAllButton.addSelectionListener(new SelectionAdapter() {
116
		fDeselectAllButton.addSelectionListener(new SelectionAdapter() {
117
			public void widgetSelected(SelectionEvent e) {
117
			public void widgetSelected(SelectionEvent e) {
118
118
119
				if (fIsGroupedByLocation) {
119
				if (fIsGroupedByLocation) {
120
					Iterator iter = fTreeViewerContents.keySet().iterator();
120
					Iterator iter = fTreeViewerContents.keySet().iterator();
121
					while (iter.hasNext()) {
121
					while (iter.hasNext()) {
122
						handleCheck(iter.next(), false);
122
						handleCheck(iter.next(), false);
123
					}
123
					}
124
124
125
				} else {
125
				} else {
126
					// We only want to uncheck visible
126
					// We only want to uncheck visible
127
					fTree.setAllChecked(false);
127
					fTree.setAllChecked(false);
128
				}
128
				}
129
				updateButtons();
129
				updateButtons();
130
			}
130
			}
131
		});
131
		});
132
132
133
		createEmptySpace(buttonComp);
133
		createEmptySpace(buttonComp);
134
134
135
		// TODO Support selecting required.
135
		// TODO Support selecting required.
136
//		fSelectRequiredButton = SWTFactory.createPushButton(buttonComp, Messages.IncludedBundlesTree_4, null);
136
//		fSelectRequiredButton = SWTFactory.createPushButton(buttonComp, Messages.IncludedBundlesTree_4, null);
137
//		fSelectRequiredButton.addSelectionListener(new SelectionAdapter() {
137
//		fSelectRequiredButton.addSelectionListener(new SelectionAdapter() {
138
//			public void widgetSelected(SelectionEvent e) {
138
//			public void widgetSelected(SelectionEvent e) {
139
//				updateButtons();
139
//				updateButtons();
140
//			}
140
//			}
141
//		});
141
//		});
142
142
143
		Composite filterComp = SWTFactory.createComposite(buttonComp, 1, 1, SWT.NONE, 0, 0);
143
		Composite filterComp = SWTFactory.createComposite(buttonComp, 1, 1, SWT.NONE, 0, 0);
144
		filterComp.setLayoutData(new GridData(SWT.LEFT, SWT.BOTTOM, true, true));
144
		filterComp.setLayoutData(new GridData(SWT.LEFT, SWT.BOTTOM, true, true));
145
145
146
		fGroupPlugins = SWTFactory.createCheckButton(filterComp, Messages.IncludedBundlesTree_6, null, false, 1);
146
		fGroupPlugins = SWTFactory.createCheckButton(filterComp, Messages.IncludedBundlesTree_6, null, false, 1);
147
		fGroupPlugins.addSelectionListener(new SelectionAdapter() {
147
		fGroupPlugins.addSelectionListener(new SelectionAdapter() {
148
			public void widgetSelected(SelectionEvent e) {
148
			public void widgetSelected(SelectionEvent e) {
149
				setEnabled(false);
149
				setEnabled(false);
150
				fIsGroupedByLocation = fGroupPlugins.getSelection();
150
				fIsGroupedByLocation = fGroupPlugins.getSelection();
151
				Object[] checkedElements = fTree.getCheckedElements();
151
				Object[] checkedElements = fTree.getCheckedElements();
152
				fTree.setContentProvider(getContentProviderForTree());
152
				fTree.setContentProvider(getContentProviderForTree());
153
153
154
				if (fIsGroupedByLocation) {
154
				if (fIsGroupedByLocation) {
155
					fTree.expandAll();
155
					fTree.expandAll();
156
					fTree.setCheckedElements(checkedElements);
156
					fTree.setCheckedElements(checkedElements);
157
					Iterator iter = fTreeViewerContents.keySet().iterator();
157
					Iterator iter = fTreeViewerContents.keySet().iterator();
158
					HashMap bundles = null;
158
					HashMap bundles = null;
159
					Object key = null;
159
					Object key = null;
160
160
161
					while (iter.hasNext()) {
161
					while (iter.hasNext()) {
162
						key = iter.next();
162
						key = iter.next();
163
						bundles = (HashMap) fTreeViewerContents.get(key);
163
						bundles = (HashMap) fTreeViewerContents.get(key);
164
164
165
						Iterator childIter = bundles.keySet().iterator();
165
						Iterator childIter = bundles.keySet().iterator();
166
						boolean allChilrenSelected = true;
166
						boolean allChilrenSelected = true;
167
						boolean noneChildrenSelected = true;
167
						boolean noneChildrenSelected = true;
168
						while (childIter.hasNext()) {
168
						while (childIter.hasNext()) {
169
							Object bundle = childIter.next();
169
							Object bundle = childIter.next();
170
							boolean checkedState = ((Boolean) bundles.get(bundle)).booleanValue();
170
							boolean checkedState = ((Boolean) bundles.get(bundle)).booleanValue();
171
							allChilrenSelected = allChilrenSelected && checkedState;
171
							allChilrenSelected = allChilrenSelected && checkedState;
172
							noneChildrenSelected = noneChildrenSelected && !checkedState;
172
							noneChildrenSelected = noneChildrenSelected && !checkedState;
173
173
174
						}
174
						}
175
						fTree.setChecked(key, !noneChildrenSelected);
175
						fTree.setChecked(key, !noneChildrenSelected);
176
						fTree.setGrayed(key, !allChilrenSelected && !noneChildrenSelected);
176
						fTree.setGrayed(key, !allChilrenSelected && !noneChildrenSelected);
177
					}
177
					}
178
				}
178
				}
179
				updateButtons();
179
				updateButtons();
180
				setEnabled(true);
180
				setEnabled(true);
181
			}
181
			}
182
		});
182
		});
183
		fShowLabel = SWTFactory.createLabel(filterComp, Messages.BundleContainerTable_9, 1);
183
		fShowLabel = SWTFactory.createLabel(filterComp, Messages.BundleContainerTable_9, 1);
184
184
185
		fShowPluginsButton = SWTFactory.createCheckButton(filterComp, Messages.BundleContainerTable_14, null, true, 1);
185
		fShowPluginsButton = SWTFactory.createCheckButton(filterComp, Messages.BundleContainerTable_14, null, true, 1);
186
		fShowPluginsButton.addSelectionListener(new SelectionAdapter() {
186
		fShowPluginsButton.addSelectionListener(new SelectionAdapter() {
187
			public void widgetSelected(SelectionEvent e) {
187
			public void widgetSelected(SelectionEvent e) {
188
				if (!fShowPluginsButton.getSelection()) {
188
				if (!fShowPluginsButton.getSelection()) {
189
					fTree.addFilter(fPluginFilter);
189
					fTree.addFilter(fPluginFilter);
190
				} else {
190
				} else {
191
					fTree.removeFilter(fPluginFilter);
191
					fTree.removeFilter(fPluginFilter);
192
				}
192
				}
193
				updateButtons();
193
				updateButtons();
194
			}
194
			}
195
		});
195
		});
196
		fShowPluginsButton.setSelection(true);
196
		fShowPluginsButton.setSelection(true);
197
		GridData gd = new GridData();
197
		GridData gd = new GridData();
198
		gd.horizontalIndent = 10;
198
		gd.horizontalIndent = 10;
199
		fShowPluginsButton.setLayoutData(gd);
199
		fShowPluginsButton.setLayoutData(gd);
200
200
201
		fShowSourceButton = SWTFactory.createCheckButton(filterComp, Messages.BundleContainerTable_15, null, true, 1);
201
		fShowSourceButton = SWTFactory.createCheckButton(filterComp, Messages.BundleContainerTable_15, null, true, 1);
202
		fShowSourceButton.addSelectionListener(new SelectionAdapter() {
202
		fShowSourceButton.addSelectionListener(new SelectionAdapter() {
203
			public void widgetSelected(SelectionEvent e) {
203
			public void widgetSelected(SelectionEvent e) {
204
				if (!fShowSourceButton.getSelection()) {
204
				if (!fShowSourceButton.getSelection()) {
205
					fTree.addFilter(fSourceFilter);
205
					fTree.addFilter(fSourceFilter);
206
				} else {
206
				} else {
207
					fTree.removeFilter(fSourceFilter);
207
					fTree.removeFilter(fSourceFilter);
208
				}
208
				}
209
				updateButtons();
209
				updateButtons();
210
			}
210
			}
211
		});
211
		});
212
		fShowSourceButton.setSelection(true);
212
		fShowSourceButton.setSelection(true);
213
		gd = new GridData();
213
		gd = new GridData();
214
		gd.horizontalIndent = 10;
214
		gd.horizontalIndent = 10;
215
		fShowSourceButton.setLayoutData(gd);
215
		fShowSourceButton.setLayoutData(gd);
216
216
217
	}
217
	}
218
218
219
	/**
219
	/**
220
	 * returns a HashMap which contains all the new File objects representing a new location
220
	 * returns a HashMap which contains all the new File objects representing a new location
221
	 */
221
	 */
222
	protected HashMap initializeTreeContents(IResolvedBundle[] allBundles) {
222
	protected HashMap initializeTreeContents(IResolvedBundle[] allBundles) {
223
		HashMap parents = new HashMap();
223
		HashMap parents = new HashMap();
224
		if (allBundles == null)
224
		if (allBundles == null)
225
			return null;
225
			return null;
226
226
227
		if (fTreeViewerContents == null)
227
		if (fTreeViewerContents == null)
228
			fTreeViewerContents = new HashMap();
228
			fTreeViewerContents = new HashMap();
229
		else
229
		else
230
			fTreeViewerContents.clear();
230
			fTreeViewerContents.clear();
231
231
232
		for (int i = 0; i < allBundles.length; i++) {
232
		for (int i = 0; i < allBundles.length; i++) {
233
			IResolvedBundle bundle = allBundles[i];
233
			IResolvedBundle bundle = allBundles[i];
234
234
235
			String path = bundle.getBundleInfo().getLocation().getRawPath();
235
			String path = bundle.getBundleInfo().getLocation().getRawPath();
236
			if (path != null) {
236
			if (path != null) {
237
				File installFile = new File(path);
237
				File installFile = new File(path);
238
				File parentFile = installFile.getParentFile();
238
				File parentFile = installFile.getParentFile();
239
				HashMap bundles = (HashMap) fTreeViewerContents.get(parentFile);
239
				HashMap bundles = (HashMap) fTreeViewerContents.get(parentFile);
240
				if (bundles == null) {
240
				if (bundles == null) {
241
					bundles = new HashMap();
241
					bundles = new HashMap();
242
					bundles.put(bundle, new Boolean(fTree.getChecked(bundle)));
242
					bundles.put(bundle, new Boolean(fTree.getChecked(bundle)));
243
					fTreeViewerContents.put(parentFile, bundles);
243
					fTreeViewerContents.put(parentFile, bundles);
244
					parents.put(parentFile, Boolean.FALSE);
244
					parents.put(parentFile, Boolean.FALSE);
245
				} else {
245
				} else {
246
					bundles.put(bundle, new Boolean(fTree.getChecked(bundle)));
246
					bundles.put(bundle, new Boolean(fTree.getChecked(bundle)));
247
				}
247
				}
248
			}
248
			}
249
		}
249
		}
250
250
251
		return parents;
251
		return parents;
252
	}
252
	}
253
253
254
	private void initializeFilters() {
254
	private void initializeFilters() {
255
		fSourceFilter = new ViewerFilter() {
255
		fSourceFilter = new ViewerFilter() {
256
			public boolean select(Viewer viewer, Object parentElement, Object element) {
256
			public boolean select(Viewer viewer, Object parentElement, Object element) {
257
				if (element instanceof IResolvedBundle) {
257
				if (element instanceof IResolvedBundle) {
258
					if (((IResolvedBundle) element).isSourceBundle()) {
258
					if (((IResolvedBundle) element).isSourceBundle()) {
259
						return false;
259
						return false;
260
					}
260
					}
261
				}
261
				}
262
				return true;
262
				return true;
263
			}
263
			}
264
		};
264
		};
265
		fPluginFilter = new ViewerFilter() {
265
		fPluginFilter = new ViewerFilter() {
266
			public boolean select(Viewer viewer, Object parentElement, Object element) {
266
			public boolean select(Viewer viewer, Object parentElement, Object element) {
267
				if (element instanceof IResolvedBundle) {
267
				if (element instanceof IResolvedBundle) {
268
					if (!((IResolvedBundle) element).isSourceBundle()) {
268
					if (!((IResolvedBundle) element).isSourceBundle()) {
269
						return false;
269
						return false;
270
					}
270
					}
271
				}
271
				}
272
				return true;
272
				return true;
273
			}
273
			}
274
		};
274
		};
275
	}
275
	}
276
276
277
	private Label createEmptySpace(Composite parent) {
277
	private Label createEmptySpace(Composite parent) {
278
		Label label = new Label(parent, SWT.NONE);
278
		Label label = new Label(parent, SWT.NONE);
279
		GridData gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
279
		GridData gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
280
		gd.widthHint = gd.heightHint = 5;
280
		gd.widthHint = gd.heightHint = 5;
281
		label.setLayoutData(gd);
281
		label.setLayoutData(gd);
282
		return label;
282
		return label;
283
	}
283
	}
284
284
285
	private void updateButtons() {
285
	private void updateButtons() {
286
		if (fAllBundles != null && !fTree.getSelection().isEmpty()) {
286
		if (fAllBundles != null && !fTree.getSelection().isEmpty()) {
287
			Object[] selection = ((IStructuredSelection) fTree.getSelection()).toArray();
287
			Object[] selection = ((IStructuredSelection) fTree.getSelection()).toArray();
288
			boolean allSelected = true;
288
			boolean allSelected = true;
289
			boolean noneSelected = true;
289
			boolean noneSelected = true;
290
			for (int i = 0; i < selection.length; i++) {
290
			for (int i = 0; i < selection.length; i++) {
291
				boolean checked = fTree.getChecked(selection[i]);
291
				boolean checked = fTree.getChecked(selection[i]);
292
				if (checked) {
292
				if (checked) {
293
					noneSelected = false;
293
					noneSelected = false;
294
				} else {
294
				} else {
295
					allSelected = false;
295
					allSelected = false;
296
				}
296
				}
297
			}
297
			}
298
			fSelectButton.setEnabled(!allSelected);
298
			fSelectButton.setEnabled(!allSelected);
299
			fDeselectButton.setEnabled(!noneSelected);
299
			fDeselectButton.setEnabled(!noneSelected);
300
//			fSelectRequiredButton.setEnabled(true);
300
//			fSelectRequiredButton.setEnabled(true);
301
		} else {
301
		} else {
302
			fSelectButton.setEnabled(false);
302
			fSelectButton.setEnabled(false);
303
			fDeselectButton.setEnabled(false);
303
			fDeselectButton.setEnabled(false);
304
//			fSelectRequiredButton.setEnabled(false);
304
//			fSelectRequiredButton.setEnabled(false);
305
		}
305
		}
306
306
307
		int checked;
307
		int checked;
308
		if (fIsGroupedByLocation) {
308
		if (fIsGroupedByLocation) {
309
			checked = fTree.getCheckedElements().length;
309
			checked = fTree.getCheckedElements().length;
310
			Iterator iter = fTreeViewerContents.keySet().iterator();
310
			Iterator iter = fTreeViewerContents.keySet().iterator();
311
			while (iter.hasNext()) {
311
			while (iter.hasNext()) {
312
				if (fTree.getChecked(iter.next())) {
312
				if (fTree.getChecked(iter.next())) {
313
					--checked;
313
					--checked;
314
				}
314
				}
315
			}
315
			}
316
		} else {
316
		} else {
317
			checked = fTree.getCheckedElements().length;
317
			checked = fTree.getCheckedElements().length;
318
		}
318
		}
319
		fSelectAllButton.setEnabled(fAllBundles != null && checked != fTree.getTree().getItemCount());
319
		fSelectAllButton.setEnabled(fAllBundles != null && checked != fTree.getTree().getItemCount());
320
		fDeselectAllButton.setEnabled(fAllBundles != null && checked != 0);
320
		fDeselectAllButton.setEnabled(fAllBundles != null && checked != 0);
321
321
322
		if (fAllBundles != null) {
322
		if (fAllBundles != null) {
323
			fCountLabel.setText(MessageFormat.format(Messages.IncludedBundlesTree_5, new String[] {Integer.toString(checked), Integer.toString(fAllBundles.length)}));
323
			fCountLabel.setText(MessageFormat.format(Messages.IncludedBundlesTree_5, new String[] {Integer.toString(checked), Integer.toString(fAllBundles.length)}));
324
		} else {
324
		} else {
325
			fCountLabel.setText(""); //$NON-NLS-1$
325
			fCountLabel.setText(""); //$NON-NLS-1$
326
		}
326
		}
327
	}
327
	}
328
328
329
	/**
329
	/**
330
	 * Set the container to display in the tree or <code>null</code> to disable the tree 
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>
331
	 * @param input bundle container or <code>null</code>
332
	 */
332
	 */
333
	public void setInput(IBundleContainer input) {
333
	public void setInput(ITargetDefinition input) {
334
		fAllBundles = null;
334
		fAllBundles = null;
335
335
336
		// Check that the input is a container with valid, resolved bundles
336
		// Check that the input is a container with valid, resolved bundles
337
		if (!(input instanceof AbstractBundleContainer)) {
337
		if (!(input instanceof AbstractBundleContainer)) {
338
			fTree.setInput(Messages.AddDirectoryContainerPage_7);
338
			fTree.setInput(Messages.AddDirectoryContainerPage_7);
339
			setEnabled(false);
339
			setEnabled(false);
340
			return;
340
			return;
341
		}
341
		}
342
		if (!input.isResolved()) {
342
		if (!input.isResolved()) {
343
			fTree.setInput(new Status(IStatus.ERROR, PDEPlugin.getPluginId(), Messages.BundleContainerTable_19));
343
			fTree.setInput(new Status(IStatus.ERROR, PDEPlugin.getPluginId(), Messages.BundleContainerTable_19));
344
			setEnabled(false);
344
			setEnabled(false);
345
			return;
345
			return;
346
		}
346
		}
347
		IStatus status = input.getBundleStatus();
347
		IStatus status = input.getBundleStatus();
348
		if (!status.isOK() && !status.isMultiStatus()) {
348
		if (!status.isOK() && !status.isMultiStatus()) {
349
			fTree.setInput(status);
349
			fTree.setInput(status);
350
			setEnabled(false);
350
			setEnabled(false);
351
			return;
351
			return;
352
		}
352
		}
353
		IResolvedBundle[] allResolvedBundles = ((AbstractBundleContainer) input).getAllBundles();
353
		IResolvedBundle[] allResolvedBundles = ((AbstractBundleContainer) input).getAllBundles();
354
		if (allResolvedBundles == null || allResolvedBundles.length == 0) {
354
		if (allResolvedBundles == null || allResolvedBundles.length == 0) {
355
			fTree.setInput(Messages.AddDirectoryContainerPage_7);
355
			fTree.setInput(Messages.AddDirectoryContainerPage_7);
356
			setEnabled(false);
356
			setEnabled(false);
357
			return;
357
			return;
358
		}
358
		}
359
359
360
		// Input is valid, setup the tree
360
		// Input is valid, setup the tree
361
		fAllBundles = allResolvedBundles;
361
		fAllBundles = allResolvedBundles;
362
		fTree.setInput(allResolvedBundles);
362
		fTree.setInput(allResolvedBundles);
363
363
364
		// Check the included bundles
364
		// Check the included bundles
365
		BundleInfo[] included = input.getIncludedBundles();
365
		BundleInfo[] included = input.getIncludedBundles();
366
		if (included == null) {
366
		if (included == null) {
367
			fTree.setCheckedElements(fAllBundles);
367
			fTree.setCheckedElements(fAllBundles);
368
		} else {
368
		} else {
369
			Set includedBundles = new HashSet();
369
			Set includedBundles = new HashSet();
370
			for (int i = 0; i < included.length; i++) {
370
			for (int i = 0; i < included.length; i++) {
371
				includedBundles.add(included[i].getSymbolicName());
371
				includedBundles.add(included[i].getSymbolicName());
372
			}
372
			}
373
			java.util.List toCheck = new ArrayList(includedBundles.size());
373
			java.util.List toCheck = new ArrayList(includedBundles.size());
374
			for (int i = 0; i < allResolvedBundles.length; i++) {
374
			for (int i = 0; i < allResolvedBundles.length; i++) {
375
				if (includedBundles.contains(allResolvedBundles[i].getBundleInfo().getSymbolicName())) {
375
				if (includedBundles.contains(allResolvedBundles[i].getBundleInfo().getSymbolicName())) {
376
					toCheck.add(allResolvedBundles[i]);
376
					toCheck.add(allResolvedBundles[i]);
377
				}
377
				}
378
			}
378
			}
379
			fTree.setCheckedElements(toCheck.toArray());
379
			fTree.setCheckedElements(toCheck.toArray());
380
		}
380
		}
381
381
382
		// Enable the tree and update the buttons
382
		// Enable the tree and update the buttons
383
		setEnabled(true);
383
		setEnabled(true);
384
	}
384
	}
385
385
386
	/* (non-Javadoc)
386
	/* (non-Javadoc)
387
	 * @see org.eclipse.swt.widgets.Control#setEnabled(boolean)
387
	 * @see org.eclipse.swt.widgets.Control#setEnabled(boolean)
388
	 */
388
	 */
389
	public void setEnabled(boolean enabled) {
389
	public void setEnabled(boolean enabled) {
390
		super.setEnabled(enabled);
390
		super.setEnabled(enabled);
391
		if (enabled) {
391
		if (enabled) {
392
			updateButtons();
392
			updateButtons();
393
		} else {
393
		} else {
394
			fSelectButton.setEnabled(false);
394
			fSelectButton.setEnabled(false);
395
			fSelectAllButton.setEnabled(false);
395
			fSelectAllButton.setEnabled(false);
396
			fDeselectButton.setEnabled(false);
396
			fDeselectButton.setEnabled(false);
397
			fDeselectAllButton.setEnabled(false);
397
			fDeselectAllButton.setEnabled(false);
398
//			fSelectRequiredButton.setEnabled(false);
398
//			fSelectRequiredButton.setEnabled(false);
399
			fCountLabel.setText(""); //$NON-NLS-1$
399
			fCountLabel.setText(""); //$NON-NLS-1$
400
		}
400
		}
401
		fShowLabel.setEnabled(enabled);
401
		fShowLabel.setEnabled(enabled);
402
		fShowPluginsButton.setEnabled(enabled);
402
		fShowPluginsButton.setEnabled(enabled);
403
		fShowSourceButton.setEnabled(enabled);
403
		fShowSourceButton.setEnabled(enabled);
404
		super.setEnabled(enabled);
404
		super.setEnabled(enabled);
405
	}
405
	}
406
406
407
	protected TreeViewer doCreateTreeViewer(Composite parent, int style) {
407
	protected TreeViewer doCreateTreeViewer(Composite parent, int style) {
408
		fTree = new CheckboxTreeViewer(parent, style) {
408
		fTree = new CheckboxTreeViewer(parent, style) {
409
			public void refresh(boolean updateLabels) {
409
			public void refresh(boolean updateLabels) {
410
				super.refresh(updateLabels);
410
				super.refresh(updateLabels);
411
				if (updateLabels) {
411
				if (updateLabels) {
412
					// We want to update the labels and buttons as users change the filtering
412
					// We want to update the labels and buttons as users change the filtering
413
					updateButtons();
413
					updateButtons();
414
				}
414
				}
415
			}
415
			}
416
		};
416
		};
417
		fTree.setContentProvider(getContentProviderForTree());
417
		fTree.setContentProvider(getContentProviderForTree());
418
		fTree.setLabelProvider(new BundleInfoLabelProvider(false));
418
		fTree.setLabelProvider(new BundleInfoLabelProvider(false));
419
		fTree.addDoubleClickListener(new IDoubleClickListener() {
419
		fTree.addDoubleClickListener(new IDoubleClickListener() {
420
			public void doubleClick(DoubleClickEvent event) {
420
			public void doubleClick(DoubleClickEvent event) {
421
				IStructuredSelection selection = (IStructuredSelection) event.getSelection();
421
				IStructuredSelection selection = (IStructuredSelection) event.getSelection();
422
				fTree.setChecked(selection.getFirstElement(), !fTree.getChecked(selection.getFirstElement()));
422
				fTree.setChecked(selection.getFirstElement(), !fTree.getChecked(selection.getFirstElement()));
423
				updateButtons();
423
				updateButtons();
424
			}
424
			}
425
		});
425
		});
426
		fTree.addCheckStateListener(new ICheckStateListener() {
426
		fTree.addCheckStateListener(new ICheckStateListener() {
427
427
428
			public void checkStateChanged(CheckStateChangedEvent event) {
428
			public void checkStateChanged(CheckStateChangedEvent event) {
429
				if (fIsGroupedByLocation) {
429
				if (fIsGroupedByLocation) {
430
					handleCheck(event.getElement(), event.getChecked());
430
					handleCheck(event.getElement(), event.getChecked());
431
					updateButtons();
431
					updateButtons();
432
				}
432
				}
433
			}
433
			}
434
		});
434
		});
435
		fTree.addSelectionChangedListener(new ISelectionChangedListener() {
435
		fTree.addSelectionChangedListener(new ISelectionChangedListener() {
436
			public void selectionChanged(SelectionChangedEvent event) {
436
			public void selectionChanged(SelectionChangedEvent event) {
437
				updateButtons();
437
				updateButtons();
438
			}
438
			}
439
		});
439
		});
440
		fTree.setSorter(new ViewerSorter());
440
		fTree.setSorter(new ViewerSorter());
441
		return fTree;
441
		return fTree;
442
	}
442
	}
443
443
444
	/**
444
	/**
445
	 * Marks the check state of <code>element</code> to <code>state</code> when plug-ins are grouped by location 
445
	 * Marks the check state of <code>element</code> to <code>state</code> when plug-ins are grouped by location 
446
	 */
446
	 */
447
	private void handleCheck(Object element, boolean state) {
447
	private void handleCheck(Object element, boolean state) {
448
		if (fTreeViewerContents.containsKey(element)) {
448
		if (fTreeViewerContents.containsKey(element)) {
449
449
450
			HashMap bundles = (HashMap) fTreeViewerContents.get(element);
450
			HashMap bundles = (HashMap) fTreeViewerContents.get(element);
451
			Iterator iter = bundles.keySet().iterator();
451
			Iterator iter = bundles.keySet().iterator();
452
			while (iter.hasNext()) {
452
			while (iter.hasNext()) {
453
				Object key = iter.next();
453
				Object key = iter.next();
454
				bundles.put(key, new Boolean(state));
454
				bundles.put(key, new Boolean(state));
455
				fTree.setChecked(key, state);
455
				fTree.setChecked(key, state);
456
			}
456
			}
457
			fTree.setChecked(element, state);
457
			fTree.setChecked(element, state);
458
			fTree.setGrayed(element, false);
458
			fTree.setGrayed(element, false);
459
			return;
459
			return;
460
		}
460
		}
461
		Iterator iter = fTreeViewerContents.keySet().iterator();
461
		Iterator iter = fTreeViewerContents.keySet().iterator();
462
		HashMap bundles = null;
462
		HashMap bundles = null;
463
		Object key = null;
463
		Object key = null;
464
		while (iter.hasNext()) {
464
		while (iter.hasNext()) {
465
			key = iter.next();
465
			key = iter.next();
466
			bundles = (HashMap) fTreeViewerContents.get(key);
466
			bundles = (HashMap) fTreeViewerContents.get(key);
467
			if (bundles.containsKey(element)) {
467
			if (bundles.containsKey(element)) {
468
				bundles.put(element, new Boolean(state));
468
				bundles.put(element, new Boolean(state));
469
				break;
469
				break;
470
			}
470
			}
471
		}
471
		}
472
		iter = bundles.keySet().iterator();
472
		iter = bundles.keySet().iterator();
473
		boolean allChilrenSelected = true;
473
		boolean allChilrenSelected = true;
474
		boolean noneChildrenSelected = true;
474
		boolean noneChildrenSelected = true;
475
		while (iter.hasNext()) {
475
		while (iter.hasNext()) {
476
			Object bundle = iter.next();
476
			Object bundle = iter.next();
477
			boolean checkedState = ((Boolean) bundles.get(bundle)).booleanValue();
477
			boolean checkedState = ((Boolean) bundles.get(bundle)).booleanValue();
478
			allChilrenSelected = allChilrenSelected && checkedState;
478
			allChilrenSelected = allChilrenSelected && checkedState;
479
			noneChildrenSelected = noneChildrenSelected && !checkedState;
479
			noneChildrenSelected = noneChildrenSelected && !checkedState;
480
		}
480
		}
481
		fTree.setChecked(element, state);
481
		fTree.setChecked(element, state);
482
		fTree.setChecked(key, !noneChildrenSelected);
482
		fTree.setChecked(key, !noneChildrenSelected);
483
		fTree.setGrayed(key, !allChilrenSelected && !noneChildrenSelected);
483
		fTree.setGrayed(key, !allChilrenSelected && !noneChildrenSelected);
484
	}
484
	}
485
485
486
	private ITreeContentProvider getContentProviderForTree() {
486
	private ITreeContentProvider getContentProviderForTree() {
487
		if (fIsGroupedByLocation) {
487
		if (fIsGroupedByLocation) {
488
488
489
			//Content provider for grouped by location
489
			//Content provider for grouped by location
490
			return (new ITreeContentProvider() {
490
			return (new ITreeContentProvider() {
491
491
492
				public Object[] getChildren(Object parentElement) {
492
				public Object[] getChildren(Object parentElement) {
493
					if (parentElement instanceof File) {
493
					if (parentElement instanceof File) {
494
						HashMap files = (HashMap) fTreeViewerContents.get(parentElement);
494
						HashMap files = (HashMap) fTreeViewerContents.get(parentElement);
495
						if (files != null) {
495
						if (files != null) {
496
							Object[] result = files.keySet().toArray();
496
							Object[] result = files.keySet().toArray();
497
							return result;
497
							return result;
498
						}
498
						}
499
					}
499
					}
500
					return new Object[0];
500
					return new Object[0];
501
				}
501
				}
502
502
503
				public Object getParent(Object element) {
503
				public Object getParent(Object element) {
504
					if (element instanceof IResolvedBundle) {
504
					if (element instanceof IResolvedBundle) {
505
						IResolvedBundle bundle = (IResolvedBundle) element;
505
						IResolvedBundle bundle = (IResolvedBundle) element;
506
						String installPath = bundle.getBundleInfo().getLocation().getPath();
506
						String installPath = bundle.getBundleInfo().getLocation().getPath();
507
						if (installPath != null)
507
						if (installPath != null)
508
							return new File(installPath).getParentFile();
508
							return new File(installPath).getParentFile();
509
					}
509
					}
510
					return null;
510
					return null;
511
				}
511
				}
512
512
513
				public boolean hasChildren(Object element) {
513
				public boolean hasChildren(Object element) {
514
					if (element instanceof File)
514
					if (element instanceof File)
515
						return fTreeViewerContents.containsKey(element);
515
						return fTreeViewerContents.containsKey(element);
516
					return false;
516
					return false;
517
				}
517
				}
518
518
519
				public Object[] getElements(Object inputElement) {
519
				public Object[] getElements(Object inputElement) {
520
					if (fTreeViewerContents == null)
520
					if (fTreeViewerContents == null)
521
						return initializeTreeContents(fAllBundles).keySet().toArray();
521
						return initializeTreeContents(fAllBundles).keySet().toArray();
522
					return fTreeViewerContents.keySet().toArray();
522
					return fTreeViewerContents.keySet().toArray();
523
				}
523
				}
524
524
525
				public void dispose() {
525
				public void dispose() {
526
				}
526
				}
527
527
528
				public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
528
				public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
529
				}
529
				}
530
			});
530
			});
531
		}
531
		}
532
532
533
		//ungrouped content provider
533
		//ungrouped content provider
534
		return (new ITreeContentProvider() {
534
		return (new ITreeContentProvider() {
535
			public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
535
			public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
536
			}
536
			}
537
537
538
			public void dispose() {
538
			public void dispose() {
539
			}
539
			}
540
540
541
			public Object[] getElements(Object inputElement) {
541
			public Object[] getElements(Object inputElement) {
542
				if (inputElement instanceof IResolvedBundle[]) {
542
				if (inputElement instanceof IResolvedBundle[]) {
543
					return (IResolvedBundle[]) inputElement;
543
					return (IResolvedBundle[]) inputElement;
544
				}
544
				}
545
				return new Object[] {inputElement};
545
				return new Object[] {inputElement};
546
			}
546
			}
547
547
548
			public boolean hasChildren(Object element) {
548
			public boolean hasChildren(Object element) {
549
				return false;
549
				return false;
550
			}
550
			}
551
551
552
			public Object getParent(Object element) {
552
			public Object getParent(Object element) {
553
				return null;
553
				return null;
554
			}
554
			}
555
555
556
			public Object[] getChildren(Object parentElement) {
556
			public Object[] getChildren(Object parentElement) {
557
				return new Object[0];
557
				return new Object[0];
558
			}
558
			}
559
		});
559
		});
560
	}
560
	}
561
561
562
	/**
562
	/**
563
	 * Return the set of bundles to include in this bundle container based on what is
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
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 
565
	 * a problem getting the bundles from the container, this method will return 
566
	 * <code>null</code>
566
	 * <code>null</code>
567
	 * 
567
	 * 
568
	 * @return set of bundles to include or <code>null</code>
568
	 * @return set of bundles to include or <code>null</code>
569
	 */
569
	 */
570
	public BundleInfo[] getIncludedBundles() {
570
	public BundleInfo[] getIncludedBundles() {
571
		if (fTree.getControl().isEnabled() && fAllBundles != null) {
571
		if (fTree.getControl().isEnabled() && fAllBundles != null) {
572
			Object[] checked = fTree.getCheckedElements();
572
			Object[] checked = fTree.getCheckedElements();
573
			if (fIsGroupedByLocation) {
573
			if (fIsGroupedByLocation) {
574
				int count = fTree.getCheckedElements().length;
574
				int count = fTree.getCheckedElements().length;
575
				Iterator iter = fTreeViewerContents.keySet().iterator();
575
				Iterator iter = fTreeViewerContents.keySet().iterator();
576
				while (iter.hasNext()) {
576
				while (iter.hasNext()) {
577
					if (fTree.getChecked(iter.next())) {
577
					if (fTree.getChecked(iter.next())) {
578
						--count;
578
						--count;
579
					}
579
					}
580
				}
580
				}
581
				if (count == fAllBundles.length)
581
				if (count == fAllBundles.length)
582
					return null;
582
					return null;
583
583
584
			} else if (checked.length == fAllBundles.length) {
584
			} else if (checked.length == fAllBundles.length) {
585
				return null;
585
				return null;
586
			}
586
			}
587
587
588
			java.util.List included = new ArrayList(checked.length);
588
			java.util.List included = new ArrayList(checked.length);
589
			for (int i = 0; i < checked.length; i++) {
589
			for (int i = 0; i < checked.length; i++) {
590
				if (checked[i] instanceof IResolvedBundle) {
590
				if (checked[i] instanceof IResolvedBundle) {
591
					included.add(new BundleInfo(((IResolvedBundle) checked[i]).getBundleInfo().getSymbolicName(), null, null, BundleInfo.NO_LEVEL, false));
591
					included.add(new BundleInfo(((IResolvedBundle) checked[i]).getBundleInfo().getSymbolicName(), null, null, BundleInfo.NO_LEVEL, false));
592
				}
592
				}
593
			}
593
			}
594
			return (BundleInfo[]) included.toArray(new BundleInfo[included.size()]);
594
			return (BundleInfo[]) included.toArray(new BundleInfo[included.size()]);
595
		}
595
		}
596
		return null;
596
		return null;
597
	}
597
	}
598
}
598
}
(-)src/org/eclipse/pde/internal/ui/shared/target/AddBundleContainerSelectionPage.java (-4 / +50 lines)
Lines 163-180 Link Here
163
		standardChoices.add(new AbstractBundleContainerNode(Messages.AddBundleContainerSelectionPage_3, Messages.AddBundleContainerSelectionPage_4, PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FOLDER)) {
163
		standardChoices.add(new AbstractBundleContainerNode(Messages.AddBundleContainerSelectionPage_3, Messages.AddBundleContainerSelectionPage_4, PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FOLDER)) {
164
			public IWizard createWizard() {
164
			public IWizard createWizard() {
165
				Wizard wizard = new Wizard() {
165
				Wizard wizard = new Wizard() {
166
					private EditDirectoryContainerPage fPage1;
167
166
					public void addPages() {
168
					public void addPages() {
167
						IDialogSettings settings = PDEPlugin.getDefault().getDialogSettings().getSection(SETTINGS_SECTION);
169
						IDialogSettings settings = PDEPlugin.getDefault().getDialogSettings().getSection(SETTINGS_SECTION);
168
						if (settings == null) {
170
						if (settings == null) {
169
							settings = PDEPlugin.getDefault().getDialogSettings().addNewSection(SETTINGS_SECTION);
171
							settings = PDEPlugin.getDefault().getDialogSettings().addNewSection(SETTINGS_SECTION);
170
						}
172
						}
171
						setDialogSettings(settings);
173
						setDialogSettings(settings);
172
						addPage(new EditDirectoryContainerPage(fTarget));
174
						fPage1 = new EditDirectoryContainerPage();
175
						addPage(fPage1);
176
						addPage(new PreviewContainerPage(fTarget, fPage1));
177
						setNeedsProgressMonitor(true);
173
					}
178
					}
174
179
175
					public boolean performFinish() {
180
					public boolean performFinish() {
176
						IBundleContainer container = ((EditDirectoryContainerPage) getPages()[0]).getBundleContainer();
181
						IBundleContainer container = fPage1.getBundleContainer();
177
						if (container != null) {
182
						if (container != null) {
183
							fPage1.storeSettings();
178
							IBundleContainer[] oldContainers = fTarget.getBundleContainers();
184
							IBundleContainer[] oldContainers = fTarget.getBundleContainers();
179
							if (oldContainers == null) {
185
							if (oldContainers == null) {
180
								fTarget.setBundleContainers(new IBundleContainer[] {container});
186
								fTarget.setBundleContainers(new IBundleContainer[] {container});
Lines 195-212 Link Here
195
		standardChoices.add(new AbstractBundleContainerNode(Messages.AddBundleContainerSelectionPage_6, Messages.AddBundleContainerSelectionPage_7, PDEPlugin.getDefault().getLabelProvider().get(PDEPluginImages.DESC_PRODUCT_DEFINITION)) {
201
		standardChoices.add(new AbstractBundleContainerNode(Messages.AddBundleContainerSelectionPage_6, Messages.AddBundleContainerSelectionPage_7, PDEPlugin.getDefault().getLabelProvider().get(PDEPluginImages.DESC_PRODUCT_DEFINITION)) {
196
			public IWizard createWizard() {
202
			public IWizard createWizard() {
197
				Wizard wizard = new Wizard() {
203
				Wizard wizard = new Wizard() {
204
					private EditDirectoryContainerPage fPage1;
205
198
					public void addPages() {
206
					public void addPages() {
199
						IDialogSettings settings = PDEPlugin.getDefault().getDialogSettings().getSection(SETTINGS_SECTION);
207
						IDialogSettings settings = PDEPlugin.getDefault().getDialogSettings().getSection(SETTINGS_SECTION);
200
						if (settings == null) {
208
						if (settings == null) {
201
							settings = PDEPlugin.getDefault().getDialogSettings().addNewSection(SETTINGS_SECTION);
209
							settings = PDEPlugin.getDefault().getDialogSettings().addNewSection(SETTINGS_SECTION);
202
						}
210
						}
203
						setDialogSettings(settings);
211
						setDialogSettings(settings);
204
						addPage(new EditProfileContainerPage(fTarget));
212
						setDialogSettings(settings);
213
						fPage1 = new EditProfileContainerPage();
214
						addPage(fPage1);
215
						addPage(new PreviewContainerPage(fTarget, fPage1));
216
						setNeedsProgressMonitor(true);
205
					}
217
					}
206
218
207
					public boolean performFinish() {
219
					public boolean performFinish() {
208
						IBundleContainer container = ((EditProfileContainerPage) getPages()[0]).getBundleContainer();
220
						IBundleContainer container = ((EditProfileContainerPage) getPages()[0]).getBundleContainer();
209
						if (container != null) {
221
						if (container != null) {
222
							((EditProfileContainerPage) getPages()[0]).storeSettings();
210
							IBundleContainer[] oldContainers = fTarget.getBundleContainers();
223
							IBundleContainer[] oldContainers = fTarget.getBundleContainers();
211
							if (oldContainers == null) {
224
							if (oldContainers == null) {
212
								fTarget.setBundleContainers(new IBundleContainer[] {container});
225
								fTarget.setBundleContainers(new IBundleContainer[] {container});
Lines 233-245 Link Here
233
							settings = PDEPlugin.getDefault().getDialogSettings().addNewSection(SETTINGS_SECTION);
246
							settings = PDEPlugin.getDefault().getDialogSettings().addNewSection(SETTINGS_SECTION);
234
						}
247
						}
235
						setDialogSettings(settings);
248
						setDialogSettings(settings);
236
						addPage(new AddFeatureContainersPage(fTarget));
249
						addPage(new AddFeatureContainersPage());
237
					}
250
					}
238
251
239
					public boolean performFinish() {
252
					public boolean performFinish() {
240
						try {
253
						try {
241
							IBundleContainer[] containers = ((AddFeatureContainersPage) getPages()[0]).getBundleContainers();
254
							IBundleContainer[] containers = ((AddFeatureContainersPage) getPages()[0]).getBundleContainers();
242
							if (containers != null) {
255
							if (containers != null) {
256
								((AddFeatureContainersPage) getPages()[0]).storeSettings();
243
								IBundleContainer[] oldContainers = fTarget.getBundleContainers();
257
								IBundleContainer[] oldContainers = fTarget.getBundleContainers();
244
								// TODO: show progress as resolving
258
								// TODO: show progress as resolving
245
								for (int i = 0; i < containers.length; i++) {
259
								for (int i = 0; i < containers.length; i++) {
Lines 266-271 Link Here
266
				return wizard;
280
				return wizard;
267
			}
281
			}
268
		});
282
		});
283
//		standardChoices.add(new AbstractBundleContainerNode("Repository or Update Site", "Download plug-ins from a p2 repository or update site.", PDEPlugin.getDefault().getLabelProvider().get(PDEPluginImages.DESC_REPOSITORY_OBJ)) {
284
//			public IWizard createWizard() {
285
//				Wizard wizard = new Wizard() {
286
//					public void addPages() {
287
//						IDialogSettings settings = PDEPlugin.getDefault().getDialogSettings().getSection(SETTINGS_SECTION);
288
//						if (settings == null) {
289
//							settings = PDEPlugin.getDefault().getDialogSettings().addNewSection(SETTINGS_SECTION);
290
//						}
291
//						setDialogSettings(settings);
292
//						addPage(new AddP2ContainerPage());
293
//					}
294
//
295
//					public boolean performFinish() {
296
//						IBundleContainer container = ((AddP2ContainerPage) getPages()[0]).getBundleContainer();
297
//						if (container != null) {
298
//							IBundleContainer[] oldContainers = fTarget.getBundleContainers();
299
//							if (oldContainers == null) {
300
//								fTarget.setBundleContainers(new IBundleContainer[] {container});
301
//							} else {
302
//								IBundleContainer[] newContainers = new IBundleContainer[oldContainers.length + 1];
303
//								System.arraycopy(oldContainers, 0, newContainers, 0, oldContainers.length);
304
//								newContainers[newContainers.length - 1] = container;
305
//								fTarget.setBundleContainers(newContainers);
306
//							}
307
//						}
308
//						return true;
309
//					}
310
//				};
311
//				wizard.setWindowTitle(Messages.AddBundleContainerSelectionPage_1);
312
//				return wizard;
313
//			}
314
//		});
269
		return standardChoices;
315
		return standardChoices;
270
	}
316
	}
271
317
(-)src/org/eclipse/pde/internal/ui/shared/target/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/EditDirectoryContainerPage.java (-64 / +24 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-307 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);
302
			setPageComplete(false);
307
			return false;
303
			return false;
Lines 313-319 Link Here
313
309
314
		// Check if directory exists
310
		// Check if directory exists
315
		if (!location.isDirectory()) {
311
		if (!location.isDirectory()) {
316
			fBundleTree.setInput(null);
317
			setMessage(Messages.AddDirectoryContainerPage_6, IMessageProvider.WARNING);
312
			setMessage(Messages.AddDirectoryContainerPage_6, IMessageProvider.WARNING);
318
			setPageComplete(true);
313
			setPageComplete(true);
319
		} else {
314
		} else {
Lines 356-379 Link Here
356
		return fTargetService;
351
		return fTargetService;
357
	}
352
	}
358
353
359
	/**
354
	private class CreateContainerJob extends UIJob {
360
	 * Returns the bundle container created by this wizard page with the
355
		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);
356
			super(jobDisplay, name);
378
		}
357
		}
379
358
Lines 387-419 Link Here
387
				if (validateInput()) {
366
				if (validateInput()) {
388
					// Create a container from the input
367
					// Create a container from the input
389
					fContainer = refreshContainer(fContainer);
368
					fContainer = refreshContainer(fContainer);
390
					if (fContainer != null) {
369
					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 {
370
				} else {
411
					fContainer = null;
371
					fContainer = null;
372
					setPageComplete(false);
412
				}
373
				}
413
				return Status.OK_STATUS;
374
				return Status.OK_STATUS;
414
			} catch (CoreException e) {
375
			} catch (CoreException e) {
415
				fContainer = null;
376
				fContainer = null;
416
				fBundleTree.setInput(null);
417
				setErrorMessage(e.getMessage());
377
				setErrorMessage(e.getMessage());
418
				setPageComplete(false);
378
				setPageComplete(false);
419
				return e.getStatus();
379
				return e.getStatus();
(-)src/org/eclipse/pde/internal/ui/shared/target/EditFeatureContainerPage.java (-3 / +2 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)
(-)src/org/eclipse/pde/internal/ui/shared/target/EditProfileContainerPage.java (-7 / +4 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 241-247 Link Here
241
			if (fConfigLocation.isEnabled()) {
240
			if (fConfigLocation.isEnabled()) {
242
				// Check if the text field is blank
241
				// Check if the text field is blank
243
				if (fConfigLocation.getText().trim().length() == 0) {
242
				if (fConfigLocation.getText().trim().length() == 0) {
244
					fBundleTree.setInput(null);
245
					setMessage(Messages.EditProfileContainerPage_2);
243
					setMessage(Messages.EditProfileContainerPage_2);
246
					setPageComplete(false);
244
					setPageComplete(false);
247
					return false;
245
					return false;
Lines 253-259 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);
255
					setPageComplete(true);
259
				} else {
256
				} else {
(-)src/org/eclipse/pde/internal/ui/shared/target/BundleInfoLabelProvider.java (+11 lines)
Lines 18-23 Link Here
18
import org.eclipse.pde.internal.ui.PDEPluginImages;
18
import org.eclipse.pde.internal.ui.PDEPluginImages;
19
import org.eclipse.pde.internal.ui.util.SharedLabelProvider;
19
import org.eclipse.pde.internal.ui.util.SharedLabelProvider;
20
import org.eclipse.swt.graphics.Image;
20
import org.eclipse.swt.graphics.Image;
21
import org.eclipse.ui.ISharedImages;
22
import org.eclipse.ui.PlatformUI;
21
23
22
/**
24
/**
23
 * Provides text and image labels for BundleInfo and IResolveBundle objects.
25
 * Provides text and image labels for BundleInfo and IResolveBundle objects.
Lines 58-63 Link Here
58
			return buf.toString();
60
			return buf.toString();
59
		} else if (element instanceof IResolvedBundle) {
61
		} else if (element instanceof IResolvedBundle) {
60
			return getText(((IResolvedBundle) element).getBundleInfo());
62
			return getText(((IResolvedBundle) element).getBundleInfo());
63
		} else if (element instanceof IStatus) {
64
			return ((IStatus) element).getMessage();
61
		}
65
		}
62
		return super.getText(element);
66
		return super.getText(element);
63
	}
67
	}
Lines 84-89 Link Here
84
			}
88
			}
85
		} else if (element instanceof BundleInfo) {
89
		} else if (element instanceof BundleInfo) {
86
			return PDEPlugin.getDefault().getLabelProvider().get(PDEPluginImages.DESC_PLUGIN_OBJ);
90
			return PDEPlugin.getDefault().getLabelProvider().get(PDEPluginImages.DESC_PLUGIN_OBJ);
91
		} else if (element instanceof IStatus) {
92
			int severity = ((IStatus) element).getSeverity();
93
			if (severity == IStatus.WARNING) {
94
				return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_WARN_TSK);
95
			} else if (severity == IStatus.ERROR) {
96
				return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_ERROR_TSK);
97
			}
87
		}
98
		}
88
		return super.getImage(element);
99
		return super.getImage(element);
89
	}
100
	}
(-)src/org/eclipse/pde/internal/ui/shared/target/AddP2ContainerPage.java (+177 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.AvailableIUGroup;
19
import org.eclipse.equinox.internal.provisional.p2.ui.dialogs.RepositorySelectionGroup;
20
import org.eclipse.equinox.internal.provisional.p2.ui.dialogs.RepositorySelectionGroup.IRepositorySelectionListener;
21
import org.eclipse.equinox.internal.provisional.p2.ui.policy.IUViewQueryContext;
22
import org.eclipse.equinox.internal.provisional.p2.ui.policy.Policy;
23
import org.eclipse.jface.action.IAction;
24
import org.eclipse.jface.viewers.CheckStateChangedEvent;
25
import org.eclipse.jface.viewers.ICheckStateListener;
26
import org.eclipse.jface.window.SameShellProvider;
27
import org.eclipse.jface.wizard.WizardPage;
28
import org.eclipse.pde.internal.core.target.impl.P2BundleContainer;
29
import org.eclipse.pde.internal.core.target.provisional.IBundleContainer;
30
import org.eclipse.pde.internal.ui.*;
31
import org.eclipse.pde.internal.ui.wizards.provisioner.p2.ProvisionerMessages;
32
import org.eclipse.swt.SWT;
33
import org.eclipse.swt.events.SelectionAdapter;
34
import org.eclipse.swt.events.SelectionEvent;
35
import org.eclipse.swt.layout.GridData;
36
import org.eclipse.swt.widgets.*;
37
import org.eclipse.ui.PlatformUI;
38
39
/**
40
 * Wizard page allowing users to select which IUs they would like to download
41
 * 
42
 * @since 3.5
43
 */
44
public class AddP2ContainerPage extends WizardPage {
45
46
	static final IStatus BAD_IU_SELECTION = new Status(IStatus.ERROR, PDEPlugin.getPluginId(), ProvisionerMessages.P2TargetProvisionerWizardPage_1);
47
	IStatus fSelectedIUStatus = BAD_IU_SELECTION;
48
49
	P2BundleContainer fContainer;
50
	IUViewQueryContext fQueryContext;
51
52
	RepositorySelectionGroup fRepoSelector;
53
	AvailableIUGroup fAvailableIUGroup;
54
55
	Button fPropertiesButton;
56
	private IAction fPropertyAction;
57
58
	protected AddP2ContainerPage() {
59
		super("AddP2Container"); //$NON-NLS-1$
60
		// TODO Use the target service to create?
61
		fContainer = new P2BundleContainer();
62
	}
63
64
	/* (non-Javadoc)
65
	 * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
66
	 */
67
	public void createControl(Composite parent) {
68
		setMessage("Select content from a repository to be downloaded and added to your target");
69
		setTitle("Add Repository or Update Site");
70
		Composite composite = SWTFactory.createComposite(parent, 1, 1, GridData.FILL_BOTH, 0, 0);
71
72
		createQueryContext();
73
		createRepositoryComboArea(composite);
74
		createAvailableIUArea(composite);
75
		createDetailsArea(composite);
76
		createCheckboxArea(composite);
77
78
		setPageComplete(false);
79
		restoreWidgetState();
80
		setControl(composite);
81
		PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, IHelpContextIds.P2_PROVISIONING_PAGE);
82
	}
83
84
	private void createCheckboxArea(Composite parent) {
85
		// Categories, provisioning context/store sites/
86
		Composite checkComp = SWTFactory.createComposite(parent, 2, 1, GridData.FILL_HORIZONTAL, 0, 0);
87
		// TODO Update labels with mnemonics
88
		SWTFactory.createCheckButton(checkComp, "Group by Category", null, true, 1);
89
		SWTFactory.createCheckButton(checkComp, "Show only the latest version", null, true, 1);
90
		SWTFactory.createCheckButton(checkComp, "Download all dependencies", null, true, 1);
91
		SWTFactory.createCheckButton(checkComp, "Include the repo location in the target", null, true, 1);
92
93
	}
94
95
	private void createQueryContext() {
96
		fQueryContext = Policy.getDefault().getQueryContext();
97
	}
98
99
	private void createRepositoryComboArea(Composite parent) {
100
		RepositorySelectionGroup repoSelector = new RepositorySelectionGroup(getContainer(), parent, Policy.getDefault().getRepositoryManipulator(), fQueryContext);
101
		repoSelector.addRepositorySelectionListener(new IRepositorySelectionListener() {
102
			public void repositorySelectionChanged(int repoChoice, URI repoLocation) {
103
				fAvailableIUGroup.setRepositoryFilter(repoChoice, repoLocation);
104
			}
105
		});
106
	}
107
108
	/**
109
	 * Create the UI area where the user will be able to select which IUs they
110
	 * would like to download.  There will also be buttons to see properties for
111
	 * the selection and open the manage sites dialog.
112
	 * 
113
	 * @param parent parent composite
114
	 */
115
	private void createAvailableIUArea(Composite parent) {
116
		fAvailableIUGroup = new AvailableIUGroup(parent);
117
		fAvailableIUGroup.getCheckboxTreeViewer().addCheckStateListener(new ICheckStateListener() {
118
			public void checkStateChanged(CheckStateChangedEvent event) {
119
				IInstallableUnit[] units = fAvailableIUGroup.getCheckedLeafIUs();
120
				fPropertiesButton.setEnabled(units.length > 0);
121
				if (units.length > 0) {
122
					fSelectedIUStatus = Status.OK_STATUS;
123
					fContainer.setRequiredUnits(units);
124
				} else {
125
					fSelectedIUStatus = BAD_IU_SELECTION;
126
					fContainer.setRequiredUnits(null);
127
				}
128
				pageChanged();
129
			}
130
		});
131
		fAvailableIUGroup.setUseBoldFontForFilteredItems(true);
132
		GridData data = (GridData) fAvailableIUGroup.getStructuredViewer().getControl().getLayoutData();
133
		data.heightHint = 200;
134
	}
135
136
	private void createDetailsArea(Composite parent) {
137
		Group detailsGroup = SWTFactory.createGroup(parent, "Details", 1, 1, GridData.FILL_HORIZONTAL);
138
139
		fPropertiesButton = new Button(detailsGroup, SWT.PUSH);
140
		fPropertiesButton.setText(ProvisionerMessages.P2TargetProvisionerWizardPage_10);
141
		fPropertiesButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
142
		fPropertiesButton.addSelectionListener(new SelectionAdapter() {
143
			public void widgetSelected(SelectionEvent event) {
144
				fPropertyAction.run();
145
			}
146
		});
147
		fPropertyAction = new PropertyDialogAction(new SameShellProvider(getShell()), fAvailableIUGroup.getStructuredViewer());
148
	}
149
150
	/**
151
	 * Checks if the page is complete, updating messages and finish button.
152
	 */
153
	void pageChanged() {
154
		if (fSelectedIUStatus.getSeverity() == IStatus.ERROR) {
155
			setErrorMessage(fSelectedIUStatus.getMessage());
156
			setPageComplete(false);
157
		} else {
158
			setErrorMessage(null);
159
			setPageComplete(true);
160
		}
161
	}
162
163
	/**
164
	 * Restores the state of the wizard from previous invocations
165
	 */
166
	private void restoreWidgetState() {
167
		// TODO Init check boxes
168
	}
169
170
	/**
171
	 * @return bundle container created by this wizard or <code>null</code>
172
	 */
173
	public IBundleContainer getBundleContainer() {
174
		return fContainer;
175
	}
176
177
}
(-)src/org/eclipse/pde/internal/ui/shared/target/PreviewContainerPage.java (+92 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.swt.layout.GridData;
14
import org.eclipse.swt.widgets.Composite;
15
16
public class PreviewContainerPage extends WizardPage {
17
18
	private ITargetDefinition fTarget;
19
	private EditDirectoryContainerPage fPage1;
20
	protected TableViewer fPreviewTable;
21
	protected Object fInput;
22
23
	protected PreviewContainerPage(ITargetDefinition definition, EditDirectoryContainerPage page1) {
24
		super("ContainerPreviewPage");
25
		setTitle("Preview Contents");
26
		setMessage("The plug-ins found in the container are visible below");
27
		fTarget = definition;
28
		fPage1 = page1;
29
	}
30
31
	/* (non-Javadoc)
32
	 * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
33
	 */
34
	public void createControl(Composite parent) {
35
		fPreviewTable = new TableViewer(parent);
36
		fPreviewTable.setLabelProvider(new BundleInfoLabelProvider(false));
37
		fPreviewTable.setContentProvider(new ArrayContentProvider());
38
		fPreviewTable.getControl().setLayoutData(new GridData(GridData.FILL_BOTH));
39
		setControl(fPreviewTable.getControl());
40
	}
41
42
	/**
43
	 * Refreshes the contents of the preview table, possible resolving the container
44
	 * @param resolve whether the current container should be resolved if it hasn't been already
45
	 */
46
	protected void setInput(final IBundleContainer container) {
47
		if (container == null) {
48
			fInput = null;
49
			fPreviewTable.setInput(null);
50
			return;
51
		}
52
53
		if (container.isResolved()) {
54
			fInput = container.getAllBundles();
55
			fPreviewTable.setInput(fInput);
56
			return;
57
		}
58
59
		try {
60
			getContainer().run(true, true, new IRunnableWithProgress() {
61
				public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
62
					IStatus result = container.resolve(fTarget, monitor);
63
					if (monitor.isCanceled()) {
64
						fInput = null;
65
					} else if (!result.isOK() && !result.isMultiStatus()) {
66
						fInput = new Object[] {result};
67
					} else {
68
						fInput = container.getAllBundles();
69
					}
70
71
				}
72
			});
73
			fPreviewTable.setInput(fInput);
74
		} catch (InvocationTargetException e) {
75
			PDEPlugin.log(e);
76
			setErrorMessage(e.getMessage());
77
		} catch (InterruptedException e) {
78
		}
79
80
	}
81
82
	/* (non-Javadoc)
83
	 * @see org.eclipse.jface.dialogs.DialogPage#setVisible(boolean)
84
	 */
85
	public void setVisible(boolean visible) {
86
		super.setVisible(visible);
87
		if (visible) {
88
			setInput(fPage1.getBundleContainer());
89
		}
90
	}
91
92
}

Return to bug 270626