|
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 |
} |