Lines 11-17
Link Here
|
11 |
*******************************************************************************/ |
11 |
*******************************************************************************/ |
12 |
package org.eclipse.pde.internal.ui.launcher; |
12 |
package org.eclipse.pde.internal.ui.launcher; |
13 |
|
13 |
|
14 |
import java.util.ArrayList; |
|
|
15 |
import java.util.HashMap; |
14 |
import java.util.HashMap; |
16 |
import java.util.Iterator; |
15 |
import java.util.Iterator; |
17 |
import java.util.Map; |
16 |
import java.util.Map; |
Lines 46-71
Link Here
|
46 |
import org.eclipse.swt.widgets.Widget; |
45 |
import org.eclipse.swt.widgets.Widget; |
47 |
|
46 |
|
48 |
public class OSGiBundleBlock extends AbstractPluginBlock { |
47 |
public class OSGiBundleBlock extends AbstractPluginBlock { |
49 |
|
48 |
|
50 |
private HashMap levelColumnCache = null; |
49 |
private HashMap levelColumnCache = new HashMap(); |
51 |
private HashMap autoColumnCache = null; |
50 |
private HashMap autoColumnCache = new HashMap(); |
52 |
private TreeEditor levelColumnEditor = null; |
51 |
private TreeEditor levelColumnEditor = null; |
53 |
private TreeEditor autoColumnEditor = null; |
52 |
private TreeEditor autoColumnEditor = null; |
54 |
|
53 |
|
55 |
class OSGiLabelProvider extends PDELabelProvider { |
54 |
class OSGiLabelProvider extends PDELabelProvider { |
56 |
public Image getColumnImage(Object obj, int index) { |
55 |
public Image getColumnImage(Object obj, int index) { |
57 |
return index == 0 ? super.getColumnImage(obj, index) : null; |
56 |
return index == 0 ? super.getColumnImage(obj, index) : null; |
58 |
} |
57 |
} |
|
|
58 |
|
59 |
public String getColumnText(Object obj, int index) { |
59 |
public String getColumnText(Object obj, int index) { |
60 |
switch (index) { |
60 |
switch (index) { |
61 |
case 0: |
61 |
case 0: |
62 |
return super.getColumnText(obj, index); |
62 |
return super.getColumnText(obj, index); |
63 |
case 1: |
63 |
case 1: |
64 |
if ( levelColumnCache != null && levelColumnCache.containsKey(obj)) |
64 |
if (levelColumnCache != null && levelColumnCache.containsKey(obj)) |
65 |
return (String) levelColumnCache.get(obj); |
65 |
return (String) levelColumnCache.get(obj); |
66 |
return ""; //$NON-NLS-1$ |
66 |
return ""; //$NON-NLS-1$ |
67 |
case 2: |
67 |
case 2: |
68 |
if ( autoColumnCache != null && autoColumnCache.containsKey(obj)) |
68 |
if (autoColumnCache != null && autoColumnCache.containsKey(obj)) |
69 |
return (String) autoColumnCache.get(obj); |
69 |
return (String) autoColumnCache.get(obj); |
70 |
return ""; //$NON-NLS-1$ |
70 |
return ""; //$NON-NLS-1$ |
71 |
default: |
71 |
default: |
Lines 79-105
Link Here
|
79 |
public OSGiBundleBlock(BundlesTab tab) { |
79 |
public OSGiBundleBlock(BundlesTab tab) { |
80 |
super(tab); |
80 |
super(tab); |
81 |
} |
81 |
} |
82 |
|
82 |
|
83 |
protected void createPluginViewer(Composite composite, int span, int indent) { |
83 |
protected void createPluginViewer(Composite composite, int span, int indent) { |
84 |
super.createPluginViewer(composite, span, indent); |
84 |
super.createPluginViewer(composite, span, indent); |
85 |
Tree tree = fPluginTreeViewer.getTree(); |
85 |
Tree tree = fPluginTreeViewer.getTree(); |
86 |
|
86 |
|
87 |
TreeColumn column1 = new TreeColumn(tree, SWT.LEFT); |
87 |
TreeColumn column1 = new TreeColumn(tree, SWT.LEFT); |
88 |
column1.setText(fTab.getName()); |
88 |
column1.setText(fTab.getName()); |
89 |
column1.setWidth(300); |
89 |
column1.setWidth(300); |
90 |
|
90 |
|
91 |
TreeColumn column2 = new TreeColumn(tree, SWT.CENTER); |
91 |
TreeColumn column2 = new TreeColumn(tree, SWT.CENTER); |
92 |
column2.setText(PDEUIMessages.EquinoxPluginBlock_levelColumn); |
92 |
column2.setText(PDEUIMessages.EquinoxPluginBlock_levelColumn); |
93 |
column2.setWidth(80); |
93 |
column2.setWidth(80); |
94 |
|
94 |
|
95 |
TreeColumn column3 = new TreeColumn(tree, SWT.CENTER); |
95 |
TreeColumn column3 = new TreeColumn(tree, SWT.CENTER); |
96 |
column3.setText(PDEUIMessages.EquinoxPluginBlock_autoColumn); |
96 |
column3.setText(PDEUIMessages.EquinoxPluginBlock_autoColumn); |
97 |
column3.setWidth(80); |
97 |
column3.setWidth(80); |
98 |
tree.setHeaderVisible(true); |
98 |
tree.setHeaderVisible(true); |
99 |
|
99 |
|
100 |
createEditors(); |
100 |
createEditors(); |
101 |
} |
101 |
} |
102 |
|
102 |
|
103 |
private void createEditors() { |
103 |
private void createEditors() { |
104 |
final Tree tree = fPluginTreeViewer.getTree(); |
104 |
final Tree tree = fPluginTreeViewer.getTree(); |
105 |
|
105 |
|
Lines 131-145
Link Here
|
131 |
final Spinner spinner = new Spinner(tree, SWT.BORDER); |
131 |
final Spinner spinner = new Spinner(tree, SWT.BORDER); |
132 |
spinner.setMinimum(0); |
132 |
spinner.setMinimum(0); |
133 |
String level = item.getText(1); |
133 |
String level = item.getText(1); |
134 |
int defaultLevel = level.length() == 0 || "default".equals(level) ? 0 : Integer.parseInt(level); //$NON-NLS-1$ |
134 |
int defaultLevel = level.length() == 0 || "default".equals(level) ? 0 : Integer.parseInt(level); //$NON-NLS-1$ |
135 |
spinner.setSelection(defaultLevel); |
135 |
spinner.setSelection(defaultLevel); |
136 |
spinner.addModifyListener(new ModifyListener() { |
136 |
spinner.addModifyListener(new ModifyListener() { |
137 |
public void modifyText(ModifyEvent e) { |
137 |
public void modifyText(ModifyEvent e) { |
138 |
if (item.getChecked()) { |
138 |
if (item.getChecked()) { |
139 |
int selection = spinner.getSelection(); |
139 |
int selection = spinner.getSelection(); |
140 |
item.setText(1, selection == 0 |
140 |
item.setText(1, selection == 0 ? "default" //$NON-NLS-1$ |
141 |
? "default" //$NON-NLS-1$ |
141 |
: Integer.toString(selection)); |
142 |
: Integer.toString(selection)); |
142 |
levelColumnCache.put(item.getData(), item |
|
|
143 |
.getText(1)); |
143 |
fTab.updateLaunchConfigurationDialog(); |
144 |
fTab.updateLaunchConfigurationDialog(); |
144 |
} |
145 |
} |
145 |
} |
146 |
} |
Lines 147-153
Link Here
|
147 |
levelColumnEditor.setEditor(spinner, item, 1); |
148 |
levelColumnEditor.setEditor(spinner, item, 1); |
148 |
|
149 |
|
149 |
final CCombo combo = new CCombo(tree, SWT.BORDER | SWT.READ_ONLY); |
150 |
final CCombo combo = new CCombo(tree, SWT.BORDER | SWT.READ_ONLY); |
150 |
combo.setItems(new String[] { "default", Boolean.toString(true), Boolean.toString(false) }); //$NON-NLS-1$ |
151 |
combo.setItems(new String[] {"default", Boolean.toString(true), Boolean.toString(false) }); //$NON-NLS-1$ |
151 |
combo.setText(item.getText(2)); |
152 |
combo.setText(item.getText(2)); |
152 |
combo.pack(); |
153 |
combo.pack(); |
153 |
combo.addSelectionListener(new SelectionAdapter() { |
154 |
combo.addSelectionListener(new SelectionAdapter() { |
Lines 155-204
Link Here
|
155 |
if (item.getChecked()) { |
156 |
if (item.getChecked()) { |
156 |
item.setText(2, combo.getText()); |
157 |
item.setText(2, combo.getText()); |
157 |
fTab.updateLaunchConfigurationDialog(); |
158 |
fTab.updateLaunchConfigurationDialog(); |
|
|
159 |
autoColumnCache.put(item.getData(), item.getText(2)); |
158 |
} |
160 |
} |
159 |
} |
161 |
} |
160 |
}); |
162 |
}); |
161 |
autoColumnEditor.setEditor(combo, item, 2); |
163 |
autoColumnEditor.setEditor(combo, item, 2); |
162 |
|
164 |
|
163 |
} |
165 |
} |
164 |
}); |
166 |
}); |
165 |
} |
167 |
} |
166 |
|
168 |
|
167 |
private boolean isEditable(TreeItem item) { |
169 |
private boolean isEditable(TreeItem item) { |
168 |
Object obj = item.getData(); |
170 |
Object obj = item.getData(); |
169 |
if (obj instanceof IPluginModelBase) { |
171 |
if (obj instanceof IPluginModelBase) { |
170 |
IPluginModelBase model = (IPluginModelBase)obj; |
172 |
IPluginModelBase model = (IPluginModelBase) obj; |
171 |
if (!"org.eclipse.osgi".equals(model.getPluginBase().getId())) //$NON-NLS-1$ |
173 |
if (!"org.eclipse.osgi".equals(model.getPluginBase().getId())) //$NON-NLS-1$ |
172 |
return fPluginTreeViewer.getChecked(model); |
174 |
return fPluginTreeViewer.getChecked(model); |
173 |
} |
175 |
} |
174 |
return false; |
176 |
return false; |
175 |
} |
177 |
} |
176 |
|
178 |
|
177 |
protected ILabelProvider getLabelProvider() { |
179 |
protected ILabelProvider getLabelProvider() { |
178 |
return new OSGiLabelProvider(); |
180 |
return new OSGiLabelProvider(); |
179 |
} |
181 |
} |
180 |
|
182 |
|
181 |
protected void savePluginState(ILaunchConfigurationWorkingCopy config) { |
183 |
protected void savePluginState(ILaunchConfigurationWorkingCopy config) { |
182 |
Object[] selected = fPluginTreeViewer.getCheckedElements(); |
184 |
Object[] selected = fPluginTreeViewer.getCheckedElements(); |
183 |
StringBuffer wBuffer = new StringBuffer(); |
185 |
StringBuffer wBuffer = new StringBuffer(); |
184 |
StringBuffer tBuffer = new StringBuffer(); |
186 |
StringBuffer tBuffer = new StringBuffer(); |
185 |
for (int i = 0; i < selected.length; i++) { |
187 |
for (int i = 0; i < selected.length; i++) { |
186 |
if (selected[i] instanceof IPluginModelBase) { |
188 |
if (selected[i] instanceof IPluginModelBase) { |
187 |
IPluginModelBase model = (IPluginModelBase)selected[i]; |
189 |
IPluginModelBase model = (IPluginModelBase) selected[i]; |
188 |
String id = model.getPluginBase().getId(); |
190 |
String id = model.getPluginBase().getId(); |
189 |
TreeItem item = (TreeItem)fPluginTreeViewer.testFindItem(model); |
191 |
//TreeItem item = (TreeItem)fPluginTreeViewer.testFindItem(model); |
190 |
if (model.getUnderlyingResource() == null) { |
192 |
if (model.getUnderlyingResource() == null) { |
191 |
appendToBuffer(tBuffer, id, item); |
193 |
appendToBuffer(tBuffer, id, model); |
192 |
} else { |
194 |
} else { |
193 |
appendToBuffer(wBuffer, id, item); |
195 |
appendToBuffer(wBuffer, id, model); |
194 |
} |
196 |
} |
195 |
} |
197 |
} |
196 |
} |
198 |
} |
197 |
config.setAttribute(IPDELauncherConstants.WORKSPACE_BUNDLES, |
199 |
config.setAttribute(IPDELauncherConstants.WORKSPACE_BUNDLES, wBuffer |
198 |
wBuffer.length() == 0 ? (String)null : wBuffer.toString()); |
200 |
.length() == 0 ? (String) null : wBuffer.toString()); |
199 |
config.setAttribute(IPDELauncherConstants.TARGET_BUNDLES, |
201 |
config.setAttribute(IPDELauncherConstants.TARGET_BUNDLES, tBuffer |
200 |
tBuffer.length() == 0 ? (String)null : tBuffer.toString()); |
202 |
.length() == 0 ? (String) null : tBuffer.toString()); |
201 |
|
203 |
|
202 |
StringBuffer buffer = new StringBuffer(); |
204 |
StringBuffer buffer = new StringBuffer(); |
203 |
if (fAddWorkspaceButton.getSelection()) { |
205 |
if (fAddWorkspaceButton.getSelection()) { |
204 |
for (int i = 0; i < fWorkspaceModels.length; i++) { |
206 |
for (int i = 0; i < fWorkspaceModels.length; i++) { |
Lines 208-228
Link Here
|
208 |
buffer.append(fWorkspaceModels[i].getPluginBase().getId()); |
210 |
buffer.append(fWorkspaceModels[i].getPluginBase().getId()); |
209 |
} |
211 |
} |
210 |
} |
212 |
} |
211 |
} |
213 |
} |
212 |
config.setAttribute(IPDELauncherConstants.DESELECTED_WORKSPACE_PLUGINS, |
214 |
config.setAttribute(IPDELauncherConstants.DESELECTED_WORKSPACE_PLUGINS, |
213 |
buffer.length() > 0 ? buffer.toString() : (String)null); |
215 |
buffer.length() > 0 ? buffer.toString() : (String) null); |
214 |
} |
216 |
} |
215 |
|
217 |
|
216 |
private void appendToBuffer(StringBuffer buffer, String id, TreeItem item) { |
218 |
private void appendToBuffer(StringBuffer buffer, String id, Object element) { |
217 |
if (buffer.length() > 0) |
219 |
if (buffer.length() > 0) |
218 |
buffer.append(","); //$NON-NLS-1$ |
220 |
buffer.append(","); //$NON-NLS-1$ |
219 |
buffer.append(id); |
221 |
buffer.append(id); |
220 |
buffer.append("@"); //$NON-NLS-1$ |
222 |
buffer.append("@"); //$NON-NLS-1$ |
221 |
buffer.append(item.getText(1)); |
223 |
buffer.append(levelColumnCache.get(element)); |
|
|
224 |
// buffer.append(item.getText(1)); |
222 |
buffer.append(":"); //$NON-NLS-1$ |
225 |
buffer.append(":"); //$NON-NLS-1$ |
223 |
buffer.append(item.getText(2)); |
226 |
// buffer.append(item.getText(2)); |
|
|
227 |
buffer.append(autoColumnCache.get(element)); |
224 |
} |
228 |
} |
225 |
|
229 |
|
226 |
public void initializeFrom(ILaunchConfiguration configuration) throws CoreException { |
230 |
public void initializeFrom(ILaunchConfiguration configuration) throws CoreException { |
227 |
super.initializeFrom(configuration); |
231 |
super.initializeFrom(configuration); |
228 |
initWorkspacePluginsState(configuration); |
232 |
initWorkspacePluginsState(configuration); |
Lines 231-248
Link Here
|
231 |
fLaunchConfiguration = configuration; |
235 |
fLaunchConfiguration = configuration; |
232 |
handleFilterButton(); // Once the page is initialized, apply any filtering. |
236 |
handleFilterButton(); // Once the page is initialized, apply any filtering. |
233 |
} |
237 |
} |
234 |
|
238 |
|
235 |
private void initExternalPluginsState(ILaunchConfiguration configuration) |
239 |
private void initExternalPluginsState(ILaunchConfiguration configuration) |
236 |
throws CoreException { |
240 |
throws CoreException { |
237 |
Map map = BundleLauncherHelper.getTargetBundleMap(configuration); |
241 |
Map map = BundleLauncherHelper.getTargetBundleMap(configuration); |
238 |
Iterator iter = map.keySet().iterator(); |
242 |
Iterator iter = map.keySet().iterator(); |
239 |
while (iter.hasNext()) { |
243 |
while (iter.hasNext()) { |
240 |
IPluginModelBase model = (IPluginModelBase)iter.next(); |
244 |
IPluginModelBase model = (IPluginModelBase) iter.next(); |
241 |
if (fPluginTreeViewer.setChecked(model, true)) { |
245 |
if (fPluginTreeViewer.setChecked(model, true)) { |
242 |
setText(model, map.get(model).toString()); |
246 |
setText(model, map.get(model).toString()); |
243 |
} |
247 |
} |
244 |
} |
248 |
} |
245 |
fNumExternalChecked = map.size(); |
249 |
fNumExternalChecked = map.size(); |
246 |
resetGroup(fExternalPlugins); |
250 |
resetGroup(fExternalPlugins); |
247 |
fPluginTreeViewer.setChecked(fExternalPlugins, fNumExternalChecked > 0); |
251 |
fPluginTreeViewer.setChecked(fExternalPlugins, fNumExternalChecked > 0); |
248 |
fPluginTreeViewer.setGrayed(fExternalPlugins, fNumExternalChecked > 0 |
252 |
fPluginTreeViewer.setGrayed(fExternalPlugins, fNumExternalChecked > 0 |
Lines 250-263
Link Here
|
250 |
} |
254 |
} |
251 |
|
255 |
|
252 |
private void resetGroup(NamedElement group) { |
256 |
private void resetGroup(NamedElement group) { |
253 |
Widget widget = fPluginTreeViewer.testFindItem(group); |
257 |
Object[] children = group.getChildren(); |
254 |
if (widget instanceof TreeItem) { |
258 |
if ( children == null ) return; |
255 |
TreeItem[] items = ((TreeItem)widget).getItems(); |
259 |
for (int i = 0; i < children.length; i++) { |
256 |
for (int i = 0; i < items.length; i++) { |
260 |
Object child = children[i]; |
257 |
if (!items[i].getChecked()) { |
261 |
if (child instanceof IPluginModelBase) { |
258 |
resetText(items[i]); |
262 |
if (fPluginTreeViewer.getChecked(child)) { |
|
|
263 |
resetText((IPluginModelBase) child); |
259 |
} |
264 |
} |
260 |
} |
265 |
} |
261 |
} |
266 |
} |
262 |
} |
267 |
} |
263 |
|
268 |
|
Lines 266-272
Link Here
|
266 |
Map map = BundleLauncherHelper.getWorkspaceBundleMap(configuration); |
271 |
Map map = BundleLauncherHelper.getWorkspaceBundleMap(configuration); |
267 |
Iterator iter = map.keySet().iterator(); |
272 |
Iterator iter = map.keySet().iterator(); |
268 |
while (iter.hasNext()) { |
273 |
while (iter.hasNext()) { |
269 |
IPluginModelBase model = (IPluginModelBase)iter.next(); |
274 |
IPluginModelBase model = (IPluginModelBase) iter.next(); |
270 |
if (fPluginTreeViewer.setChecked(model, true)) { |
275 |
if (fPluginTreeViewer.setChecked(model, true)) { |
271 |
setText(model, map.get(model).toString()); |
276 |
setText(model, map.get(model).toString()); |
272 |
} |
277 |
} |
Lines 274-430
Link Here
|
274 |
fNumWorkspaceChecked = map.size(); |
279 |
fNumWorkspaceChecked = map.size(); |
275 |
resetGroup(fWorkspacePlugins); |
280 |
resetGroup(fWorkspacePlugins); |
276 |
|
281 |
|
277 |
fPluginTreeViewer.setChecked(fWorkspacePlugins, fNumWorkspaceChecked > 0); |
282 |
fPluginTreeViewer.setChecked(fWorkspacePlugins, |
278 |
fPluginTreeViewer.setGrayed( |
283 |
fNumWorkspaceChecked > 0); |
279 |
fWorkspacePlugins, |
284 |
fPluginTreeViewer.setGrayed(fWorkspacePlugins, fNumWorkspaceChecked > 0 |
280 |
fNumWorkspaceChecked > 0 && fNumWorkspaceChecked < fWorkspaceModels.length); |
285 |
&& fNumWorkspaceChecked < fWorkspaceModels.length); |
281 |
} |
286 |
} |
282 |
|
287 |
|
283 |
protected void handleGroupStateChanged(Object group, boolean checked) { |
288 |
protected void handleGroupStateChanged(Object group, boolean checked) { |
284 |
super.handleGroupStateChanged(group, checked); |
289 |
super.handleGroupStateChanged(group, checked); |
285 |
Widget item = fPluginTreeViewer.testFindItem(group); |
290 |
if (group instanceof NamedElement) { |
286 |
if (item instanceof TreeItem) { |
291 |
NamedElement namedElement = (NamedElement) group; |
287 |
TreeItem[] items = ((TreeItem)item).getItems(); |
292 |
Object[] children = namedElement.getChildren(); |
288 |
for (int i = 0; i < items.length; i++) { |
293 |
if ( children == null ) return; |
289 |
TreeItem child = items[i]; |
294 |
for (int i = 0; i < children.length; i++) { |
290 |
if (child.getChecked() == (child.getText(1).length() == 0)) |
295 |
Object child = children[i]; |
291 |
resetText(items[i]); |
296 |
if (child instanceof IPluginModelBase) { |
|
|
297 |
if (fPluginTreeViewer.getChecked(child) == (((String)(levelColumnCache.get(child))).length() == 0 )) { |
298 |
resetText((IPluginModelBase) child); |
299 |
} |
300 |
} |
292 |
} |
301 |
} |
293 |
} |
302 |
} |
294 |
} |
303 |
} |
295 |
|
304 |
|
296 |
protected void handleCheckStateChanged(CheckStateChangedEvent event) { |
305 |
protected void handleCheckStateChanged(CheckStateChangedEvent event) { |
297 |
super.handleCheckStateChanged(event); |
306 |
super.handleCheckStateChanged(event); |
298 |
resetText((IPluginModelBase)event.getElement()); |
307 |
resetText((IPluginModelBase) event.getElement()); |
299 |
} |
308 |
} |
300 |
|
309 |
|
301 |
protected void setChecked(IPluginModelBase model, boolean checked) { |
310 |
protected void setChecked(IPluginModelBase model, boolean checked) { |
302 |
super.setChecked(model, checked); |
311 |
super.setChecked(model, checked); |
303 |
resetText(model); |
312 |
resetText(model); |
304 |
} |
313 |
} |
305 |
|
314 |
|
306 |
protected void setCheckedElements(Object[] checked) { |
315 |
protected void setCheckedElements(Object[] checked) { |
307 |
super.setCheckedElements(checked); |
316 |
super.setCheckedElements(checked); |
308 |
updateGroup(fWorkspacePlugins); |
317 |
updateGroup(fWorkspacePlugins); |
309 |
updateGroup(fExternalPlugins); |
318 |
updateGroup(fExternalPlugins); |
310 |
} |
319 |
} |
311 |
|
320 |
|
312 |
private void updateGroup(Object group) { |
321 |
private void updateGroup(Object group) { |
313 |
Widget item = fPluginTreeViewer.testFindItem(group); |
322 |
if (group instanceof NamedElement) { |
314 |
if (item instanceof TreeItem) { |
323 |
NamedElement namedElement = (NamedElement) group; |
315 |
TreeItem[] items = ((TreeItem)item).getItems(); |
324 |
Object[] children = namedElement.getChildren(); |
316 |
for (int i = 0; i < items.length; i++) { |
325 |
if ( children == null ) return; |
317 |
TreeItem child = items[i]; |
326 |
for (int i = 0; i < children.length; i++) { |
318 |
if (child.getChecked() == (child.getText(1).length() == 0)) |
327 |
Object child = children[i]; |
319 |
resetText(items[i]); |
328 |
if (child instanceof IPluginModelBase) { |
|
|
329 |
if (fPluginTreeViewer.getChecked(child) == (((String)(levelColumnCache.get(child))).length() == 0 )) { |
330 |
resetText((IPluginModelBase) child); |
331 |
} |
332 |
} |
320 |
} |
333 |
} |
321 |
} |
334 |
} |
322 |
} |
335 |
} |
323 |
|
336 |
|
324 |
private void setText(IPluginModelBase model, String value) { |
337 |
private void setText(IPluginModelBase model, String value) { |
|
|
338 |
int index = value == null ? -1 : value.indexOf(':'); |
339 |
String levelValue = index == -1 ? "" : value.substring(0, index); //$NON-NLS-1$ |
340 |
String autoValue = index == -1 ? "" : value.substring(index + 1); //$NON-NLS-1$ |
341 |
|
342 |
levelColumnCache.put(model, levelValue); |
343 |
autoColumnCache.put(model, autoValue); |
325 |
Widget widget = fPluginTreeViewer.testFindItem(model); |
344 |
Widget widget = fPluginTreeViewer.testFindItem(model); |
326 |
if (widget instanceof TreeItem) { |
345 |
if (widget instanceof TreeItem) { |
327 |
TreeItem item = (TreeItem)widget; |
346 |
TreeItem item = (TreeItem) widget; |
328 |
int index = value == null ? -1 : value.indexOf(':'); |
347 |
item.setText(1, levelValue); //$NON-NLS-1$ |
329 |
item.setText(1, index == -1 ? "" : value.substring(0, index)); //$NON-NLS-1$ |
348 |
item.setText(2, autoValue); //$NON-NLS-1$ |
330 |
item.setText(2, index == -1 ? "" : value.substring(index + 1)); //$NON-NLS-1$ |
|
|
331 |
} |
349 |
} |
332 |
} |
350 |
} |
333 |
|
351 |
|
|
|
352 |
|
334 |
private void resetText(IPluginModelBase model) { |
353 |
private void resetText(IPluginModelBase model) { |
|
|
354 |
String levelText = null; |
355 |
String autoText = null; |
335 |
Widget widget = fPluginTreeViewer.testFindItem(model); |
356 |
Widget widget = fPluginTreeViewer.testFindItem(model); |
336 |
if (widget instanceof TreeItem) { |
357 |
if (fPluginTreeViewer.getChecked(model)) { |
337 |
resetText((TreeItem)widget); |
|
|
338 |
} |
339 |
} |
340 |
|
341 |
private void resetText(TreeItem item) { |
342 |
if (item.getChecked()) { |
343 |
IPluginModelBase model = (IPluginModelBase)item.getData(); |
344 |
boolean isSystemBundle = "org.eclipse.osgi".equals(model.getPluginBase().getId()); //$NON-NLS-1$ |
358 |
boolean isSystemBundle = "org.eclipse.osgi".equals(model.getPluginBase().getId()); //$NON-NLS-1$ |
345 |
if (!"default".equals(item.getText(1))) //$NON-NLS-1$ |
359 |
if (!"default".equals(levelColumnCache.get(model))) //$NON-NLS-1$ |
346 |
item.setText(1, isSystemBundle ? "" : "default"); //$NON-NLS-1$ //$NON-NLS-2$ |
360 |
levelText = isSystemBundle ? "" : "default"; |
347 |
if (!"default".equals(item.getText(2))) //$NON-NLS-1$ |
361 |
if (!"default".equals(autoColumnCache.get(model))) //$NON-NLS-1$ |
348 |
item.setText(2, isSystemBundle ? "" : "default"); //$NON-NLS-1$ //$NON-NLS-2$ |
362 |
autoText = isSystemBundle ? "" : "default"; |
349 |
} else { |
363 |
} |
350 |
if (item.getText(1).length() > 0) |
364 |
else { |
351 |
item.setText(1, ""); //$NON-NLS-1$ |
365 |
if ( ((String)levelColumnCache.get(model)).length() > 0 ) { |
352 |
if (item.getText(2).length() > 0) |
366 |
levelText = ""; |
353 |
item.setText(2, ""); //$NON-NLS-1$ |
367 |
} |
354 |
} |
368 |
if ( ((String)autoColumnCache.get(model)).length() > 0 ) { |
|
|
369 |
autoText = ""; |
370 |
} |
371 |
} |
372 |
if ( levelText != null ) { |
373 |
levelColumnCache.put(model, levelText); |
374 |
if ( widget instanceof TreeItem ) { |
375 |
((TreeItem)widget).setText(1, levelText); //$NON-NLS-1$ |
376 |
} |
377 |
} |
378 |
if ( autoText != null ) { |
379 |
autoColumnCache.put(model, autoText); |
380 |
if ( widget instanceof TreeItem ) { |
381 |
((TreeItem)widget).setText(2, autoText); //$NON-NLS-1$ |
382 |
} |
383 |
} |
355 |
} |
384 |
} |
356 |
|
385 |
|
357 |
protected void handleRestoreDefaults() { |
386 |
protected void handleRestoreDefaults() { |
358 |
Object[] selected = fPluginTreeViewer.getCheckedElements(); |
387 |
Object[] selected = fPluginTreeViewer.getCheckedElements(); |
359 |
for (int i = 0; i < selected.length; i++) { |
388 |
for (int i = 0; i < selected.length; i++) { |
360 |
if (selected[i] instanceof IPluginModelBase) { |
389 |
if (selected[i] instanceof IPluginModelBase) { |
361 |
resetText((IPluginModelBase)selected[i]); |
390 |
resetText((IPluginModelBase) selected[i]); |
362 |
} |
391 |
} |
363 |
} |
392 |
} |
364 |
} |
393 |
} |
365 |
|
394 |
|
366 |
protected int getTreeViewerStyle() { |
395 |
protected int getTreeViewerStyle() { |
367 |
return super.getTreeViewerStyle() | SWT.FULL_SELECTION; |
396 |
return super.getTreeViewerStyle() | SWT.FULL_SELECTION; |
368 |
} |
397 |
} |
369 |
|
398 |
|
370 |
protected LaunchValidationOperation createValidationOperation() { |
399 |
protected LaunchValidationOperation createValidationOperation() { |
371 |
return new OSGiValidationOperation(fLaunchConfiguration); |
400 |
return new OSGiValidationOperation(fLaunchConfiguration); |
372 |
} |
401 |
} |
373 |
|
402 |
|
374 |
|
|
|
375 |
/** |
403 |
/** |
376 |
* Refreshes the tree viewer. This caches the values of the |
404 |
* Refreshes the tree viewer. This caches the values of the level and auto |
377 |
* level and auto column, and it clears any editors on the view. |
405 |
* column, and it clears any editors on the view. Finally, it sets the |
378 |
* Finally, it sets the selection to the root node. |
406 |
* selection to the root node. |
379 |
*/ |
407 |
*/ |
380 |
protected void refreshTreeView(CheckboxTreeViewer treeView) { |
408 |
protected void refreshTreeView(CheckboxTreeViewer treeView) { |
381 |
// Remove any selection |
409 |
// Remove any selection |
382 |
if ( treeView.getTree().getItemCount() > 0 ) { |
410 |
if (treeView.getTree().getItemCount() > 0) { |
383 |
treeView.getTree().setSelection(treeView.getTree().getItem(0)); |
411 |
treeView.getTree().setSelection(treeView.getTree().getItem(0)); |
|
|
412 |
} else { |
413 |
treeView.setSelection(new StructuredSelection( |
414 |
StructuredSelection.EMPTY)); |
384 |
} |
415 |
} |
385 |
else { |
416 |
|
386 |
treeView.setSelection(new StructuredSelection(StructuredSelection.EMPTY)); |
|
|
387 |
} |
388 |
|
389 |
// Reset any editors on the tree viewer |
417 |
// Reset any editors on the tree viewer |
390 |
if (levelColumnEditor!= null && levelColumnEditor.getEditor() != null && !levelColumnEditor.getEditor().isDisposed()) { |
418 |
if (levelColumnEditor != null && levelColumnEditor.getEditor() != null |
|
|
419 |
&& !levelColumnEditor.getEditor().isDisposed()) { |
391 |
levelColumnEditor.getEditor().dispose(); |
420 |
levelColumnEditor.getEditor().dispose(); |
392 |
} |
421 |
} |
393 |
|
|
|
394 |
|
422 |
|
395 |
if (autoColumnEditor!= null && autoColumnEditor.getEditor() != null && !autoColumnEditor.getEditor().isDisposed()) { |
423 |
if (autoColumnEditor != null && autoColumnEditor.getEditor() != null |
|
|
424 |
&& !autoColumnEditor.getEditor().isDisposed()) { |
396 |
autoColumnEditor.getEditor().dispose(); |
425 |
autoColumnEditor.getEditor().dispose(); |
397 |
} |
426 |
} |
398 |
|
|
|
399 |
// Cache the current text |
400 |
levelColumnCache = new HashMap(); |
401 |
autoColumnCache = new HashMap(); |
402 |
ArrayList allTreeItems = getAllTreeItems(treeView.getTree().getItems()); |
403 |
for (Iterator iterator = allTreeItems.iterator(); iterator.hasNext();) { |
404 |
TreeItem item = (TreeItem) iterator.next(); |
405 |
levelColumnCache.put(item.getData(), item.getText(1)); |
406 |
autoColumnCache.put(item.getData(), item.getText(2)); |
407 |
} |
408 |
} |
427 |
} |
409 |
|
428 |
|
410 |
/** |
|
|
411 |
* This gets all the tree items from a tree. |
412 |
* |
413 |
* This method must exist in some SWT util library, so it can probably be |
414 |
* removed when I find it. |
415 |
* |
416 |
* @param roots |
417 |
* @return |
418 |
*/ |
419 |
private ArrayList getAllTreeItems(TreeItem[] roots) { |
420 |
ArrayList list = new ArrayList(); |
421 |
for (int i = 0; i < roots.length; i++) { |
422 |
TreeItem item = roots[i]; |
423 |
list.add(item); |
424 |
list.addAll(getAllTreeItems(item.getItems())); |
425 |
} |
426 |
return list; |
427 |
} |
428 |
|
429 |
|
430 |
} |
429 |
} |