54
55
import org.eclipse.cdt.internal.ui.newui.Messages;
56
public class CDTMainWizardPage extends WizardNewProjectCreationPage implements IWizardItemsListListener {
57
private static final Image IMG_CATEGORY = CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_SEARCHFOLDER);
58
private static final Image IMG_ITEM = CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_VARIABLE);
60
public static final String PAGE_ID = "org.eclipse.cdt.managedbuilder.ui.wizard.NewModelProjectWizardPage"; //$NON-NLS-1$
62
private static final String EXTENSION_POINT_ID = "org.eclipse.cdt.ui.CDTWizard"; //$NON-NLS-1$
63
private static final String ELEMENT_NAME = "wizard"; //$NON-NLS-1$
64
private static final String CLASS_NAME = "class"; //$NON-NLS-1$
65
public static final String DESC = "EntryDescriptor"; //$NON-NLS-1$
69
private Composite right;
70
private Button show_sup;
71
private Label right_label;
73
public CWizardHandler h_selected = null;
74
private Label categorySelectedLabel;
77
* Creates a new project creation wizard page.
79
* @param pageName the name of this page
81
public CDTMainWizardPage(String pageName) {
83
setPageComplete(false);
87
* Method declared on IDialogPage.
90
public void createControl(Composite parent) {
91
super.createControl(parent);
93
createDynamicGroup((Composite)getControl());
94
switchTo(updateData(tree, right, show_sup, CDTMainWizardPage.this, getWizard()),
97
setPageComplete(validatePage());
98
setErrorMessage(null);
102
private void createDynamicGroup(Composite parent) {
103
Composite c = new Composite(parent, SWT.NONE);
104
c.setLayoutData(new GridData(GridData.FILL_BOTH));
105
c.setLayout(new GridLayout(2, true));
107
Label l1 = new Label(c, SWT.NONE);
108
l1.setText(Messages.CMainWizardPage_0);
109
l1.setFont(parent.getFont());
110
l1.setLayoutData(new GridData(GridData.BEGINNING));
112
right_label = new Label(c, SWT.NONE);
113
right_label.setFont(parent.getFont());
114
right_label.setLayoutData(new GridData(GridData.BEGINNING));
116
tree = new Tree(c, SWT.SINGLE | SWT.BORDER);
117
tree.setLayoutData(new GridData(GridData.FILL_BOTH));
118
tree.addSelectionListener(new SelectionAdapter() {
120
public void widgetSelected(SelectionEvent e) {
121
TreeItem[] tis = tree.getSelection();
122
if (tis == null || tis.length == 0) return;
123
switchTo((CWizardHandler)tis[0].getData(), (EntryDescriptor)tis[0].getData(DESC));
124
setPageComplete(validatePage());
126
tree.getAccessible().addAccessibleListener(
127
new AccessibleAdapter() {
129
public void getName(AccessibleEvent e) {
130
for (int i = 0; i < tree.getItemCount(); i++) {
131
if (tree.getItem(i).getText().equals(e.result))
134
e.result = Messages.CMainWizardPage_0;
138
right = new Composite(c, SWT.NONE);
139
right.setLayoutData(new GridData(GridData.FILL_BOTH));
140
right.setLayout(new PageLayout());
142
show_sup = new Button(c, SWT.CHECK);
143
show_sup.setText(Messages.CMainWizardPage_1);
144
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
145
gd.horizontalSpan = 2;
146
show_sup.setLayoutData(gd);
147
show_sup.addSelectionListener(new SelectionAdapter() {
149
public void widgetSelected(SelectionEvent e) {
150
if (h_selected != null)
151
h_selected.setSupportedOnly(show_sup.getSelection());
152
switchTo(updateData(tree, right, show_sup, CDTMainWizardPage.this, getWizard()),
153
getDescriptor(tree));
156
// restore settings from preferences
157
show_sup.setSelection(!CDTPrefUtil.getBool(CDTPrefUtil.KEY_NOSUPP));
161
public IWizardPage getNextPage() {
162
return (h_selected == null) ? null : h_selected.getSpecificPage();
165
public URI getProjectLocation() {
166
return useDefaults() ? null : getLocationURI();
170
* Returns whether this page's controls currently all contain valid
173
* @return <code>true</code> if all controls are valid, and
174
* <code>false</code> if at least one is invalid
177
protected boolean validatePage() {
179
if (!super.validatePage())
182
if (getProjectName().indexOf('#') >= 0) {
183
setErrorMessage(Messages.CDTMainWizardPage_0);
187
boolean bad = true; // should we treat existing project as error
189
IProject handle = getProjectHandle();
190
if (handle.exists()) {
191
if (getWizard() instanceof IWizardWithMemory) {
192
IWizardWithMemory w = (IWizardWithMemory)getWizard();
193
if (w.getLastProjectName() != null && w.getLastProjectName().equals(getProjectName()))
197
setErrorMessage(Messages.CMainWizardPage_10);
202
if (bad) { // skip this check if project already created
205
URI p = getProjectLocation();
207
fs = EFS.getStore(ResourcesPlugin.getWorkspace().getRoot().getLocationURI());
208
fs = fs.getChild(getProjectName());
210
fs = EFS.getStore(p);
211
IFileInfo f = fs.fetchInfo();
213
if (f.isDirectory()) {
214
if (f.getAttribute(EFS.ATTRIBUTE_READ_ONLY)) {
215
setErrorMessage(Messages.CMainWizardPage_DirReadOnlyError);
219
setMessage(Messages.CMainWizardPage_7, IMessageProvider.WARNING);
221
setErrorMessage(Messages.CMainWizardPage_6);
225
} catch (CoreException e) {
226
CUIPlugin.log(e.getStatus());
230
if (!useDefaults()) {
231
IStatus locationStatus = ResourcesPlugin.getWorkspace().validateProjectLocationURI(handle,
233
if (!locationStatus.isOK()) {
234
setErrorMessage(locationStatus.getMessage());
239
if (tree.getItemCount() == 0) {
240
setErrorMessage(Messages.CMainWizardPage_3);
244
// it is not an error, but we cannot continue
245
if (h_selected == null) {
246
setErrorMessage(null);
250
String s = h_selected.getErrorMessage();
256
setErrorMessage(null);
267
* @return : selected Wizard Handler.
269
public static CWizardHandler updateData(Tree tree, Composite right, Button show_sup, IWizardItemsListListener ls, IWizard wizard) {
270
// remember selected item
271
TreeItem[] selection = tree.getSelection();
272
TreeItem selectedItem = selection.length>0 ? selection[0] : null;
273
String savedLabel = selectedItem!=null ? selectedItem.getText() : null;
274
String savedParentLabel = getParentText(selectedItem);
277
IExtensionPoint extensionPoint =
278
Platform.getExtensionRegistry().getExtensionPoint(EXTENSION_POINT_ID);
279
if (extensionPoint == null) return null;
280
IExtension[] extensions = extensionPoint.getExtensions();
281
if (extensions == null) return null;
283
List<EntryDescriptor> items = new ArrayList<EntryDescriptor>();
284
for (int i = 0; i < extensions.length; ++i) {
285
IConfigurationElement[] elements = extensions[i].getConfigurationElements();
286
for (IConfigurationElement element : elements) {
287
if (element.getName().equals(ELEMENT_NAME)) {
290
w = (CNewWizard) element.createExecutableExtension(CLASS_NAME);
291
} catch (CoreException e) {
292
System.out.println(Messages.CMainWizardPage_5 + e.getLocalizedMessage());
57
public class CDTMainWizardPage extends WizardNewProjectCreationPage implements IWizardItemsListListener {
58
public static final String PAGE_ID = "org.eclipse.cdt.managedbuilder.ui.wizard.NewModelProjectWizardPage"; //$NON-NLS-1$
60
private static final String EXTENSION_POINT_ID = "org.eclipse.cdt.ui.CDTWizard"; //$NON-NLS-1$
61
private static final String ELEMENT_NAME = "wizard"; //$NON-NLS-1$
62
private static final String CLASS_NAME = "class"; //$NON-NLS-1$
63
public static final String DESC = "EntryDescriptor"; //$NON-NLS-1$
67
private Composite right;
68
private Button showSup;
69
private Label rightLabel;
71
public CWizardHandler h_selected;
72
private Label categorySelectedLabel;
75
* Creates a new project creation wizard page.
77
* @param pageName the name of this page
79
public CDTMainWizardPage(String pageName) {
81
setPageComplete(false);
85
public void createControl(Composite parent) {
86
super.createControl(parent);
88
createDynamicGroup((Composite)getControl());
89
switchTo(updateData(tree, right, showSup, CDTMainWizardPage.this, getWizard()),
92
setPageComplete(validatePage());
93
setErrorMessage(null);
97
private void createDynamicGroup(Composite parent) {
98
Composite c = new Composite(parent, SWT.NONE);
99
c.setLayoutData(new GridData(GridData.FILL_BOTH));
100
c.setLayout(new GridLayout(2, true));
102
Label l1 = new Label(c, SWT.NONE);
103
l1.setText(Messages.CMainWizardPage_0);
104
l1.setFont(parent.getFont());
105
l1.setLayoutData(new GridData(GridData.BEGINNING));
107
rightLabel = new Label(c, SWT.NONE);
108
rightLabel.setFont(parent.getFont());
109
rightLabel.setLayoutData(new GridData(GridData.BEGINNING));
111
tree = new Tree(c, SWT.SINGLE | SWT.BORDER);
112
tree.setLayoutData(new GridData(GridData.FILL_BOTH));
113
tree.addSelectionListener(new SelectionAdapter() {
115
public void widgetSelected(SelectionEvent e) {
116
TreeItem[] tis = tree.getSelection();
117
if (tis == null || tis.length == 0) return;
118
switchTo((CWizardHandler)tis[0].getData(), (EntryDescriptor)tis[0].getData(DESC));
119
setPageComplete(validatePage());
121
tree.getAccessible().addAccessibleListener(new AccessibleAdapter() {
123
public void getName(AccessibleEvent e) {
124
for (int i = 0; i < tree.getItemCount(); i++) {
125
if (tree.getItem(i).getText().equals(e.result))
128
e.result = Messages.CMainWizardPage_0;
130
right = new Composite(c, SWT.NONE);
131
right.setLayoutData(new GridData(GridData.FILL_BOTH));
132
right.setLayout(new PageLayout());
134
showSup = new Button(c, SWT.CHECK);
135
showSup.setText(Messages.CMainWizardPage_1);
136
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
137
gd.horizontalSpan = 2;
138
showSup.setLayoutData(gd);
139
showSup.addSelectionListener(new SelectionAdapter() {
141
public void widgetSelected(SelectionEvent e) {
142
if (h_selected != null)
143
h_selected.setSupportedOnly(showSup.getSelection());
144
switchTo(updateData(tree, right, showSup, CDTMainWizardPage.this, getWizard()),
145
getDescriptor(tree));
148
// restore settings from preferences
149
showSup.setSelection(!CDTPrefUtil.getBool(CDTPrefUtil.KEY_NOSUPP));
153
public IWizardPage getNextPage() {
154
return (h_selected == null) ? null : h_selected.getSpecificPage();
157
public URI getProjectLocation() {
158
return useDefaults() ? null : getLocationURI();
162
* Returns whether this page's controls currently all contain valid
165
* @return <code>true</code> if all controls are valid, and
166
* <code>false</code> if at least one is invalid
169
protected boolean validatePage() {
171
if (!super.validatePage())
174
if (getProjectName().indexOf('#') >= 0) {
175
setErrorMessage(Messages.CDTMainWizardPage_0);
179
boolean bad = true; // should we treat existing project as error
181
IProject handle = getProjectHandle();
182
if (handle.exists()) {
183
if (getWizard() instanceof IWizardWithMemory) {
184
IWizardWithMemory w = (IWizardWithMemory)getWizard();
185
if (w.getLastProjectName() != null && w.getLastProjectName().equals(getProjectName()))
189
setErrorMessage(Messages.CMainWizardPage_10);
194
if (bad) { // Skip this check if project already created
197
URI p = getProjectLocation();
199
fs = EFS.getStore(ResourcesPlugin.getWorkspace().getRoot().getLocationURI());
200
fs = fs.getChild(getProjectName());
202
fs = EFS.getStore(p);
203
IFileInfo f = fs.fetchInfo();
205
if (f.isDirectory()) {
206
if (f.getAttribute(EFS.ATTRIBUTE_READ_ONLY)) {
207
setErrorMessage(Messages.CMainWizardPage_DirReadOnlyError);
295
if (w == null) return null;
296
w.setDependentControl(right, ls);
297
for (EntryDescriptor ed : w.createItems(show_sup.getSelection(), wizard))
302
// If there is a EntryDescriptor which is default for category, make sure it
303
// is in the front of the list.
304
for (int i = 0; i < items.size(); ++i)
306
EntryDescriptor ed = items.get(i);
307
if (ed.isDefaultForCategory())
315
// bug # 211935 : allow items filtering.
316
if (ls != null) // NULL means call from prefs
317
items = ls.filterItems(items);
318
addItemsToTree(tree, items);
320
if (tree.getItemCount() > 0) {
321
TreeItem target = null;
322
// try to search item which was selected before
323
if (savedLabel != null) {
324
target = findItem(tree, savedLabel, savedParentLabel);
326
if (target == null) {
327
// Default selection associated with "org.eclipse.cdt.build.core.buildArtefactType.exe" project type
328
target = findItem(tree, Messages.CDTMainWizardPage_DefaultProjectType, Messages.CDTMainWizardPage_DefaultProjectCategory);
329
if (target == null) {
330
CUIPlugin.log(new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID, "Default project not found in New C/C++ Project Wizard")); //$NON-NLS-1$
333
if (target == null) {
334
target = tree.getItem(0);
335
if (target.getItemCount() != 0)
336
target = target.getItem(0);
338
tree.setSelection(target);
339
return (CWizardHandler)target.getData();
344
private static String getParentText(TreeItem item) {
345
if (item==null || item.getParentItem()==null)
346
return ""; //$NON-NLS-1$
347
return item.getParentItem().getText();
350
private static TreeItem findItem(Tree tree, String label, String parentLabel) {
351
for (TreeItem item : tree.getItems()) {
352
TreeItem foundItem = findTreeItem(item, label, parentLabel);
359
private static TreeItem findTreeItem(TreeItem item, String label, String parentLabel) {
360
if (item.getText().equals(label) && getParentText(item).equals(parentLabel))
363
for (TreeItem child : item.getItems()) {
364
TreeItem foundItem = findTreeItem(child, label, parentLabel);
371
private static void addItemsToTree(Tree tree, List<EntryDescriptor> items) {
211
setMessage(Messages.CMainWizardPage_7, IMessageProvider.WARNING);
213
setErrorMessage(Messages.CMainWizardPage_6);
217
} catch (CoreException e) {
218
CUIPlugin.log(e.getStatus());
222
if (!useDefaults()) {
223
IStatus locationStatus =
224
ResourcesPlugin.getWorkspace().validateProjectLocationURI(handle, getLocationURI());
225
if (!locationStatus.isOK()) {
226
setErrorMessage(locationStatus.getMessage());
231
if (tree.getItemCount() == 0) {
232
setErrorMessage(Messages.CMainWizardPage_3);
236
// it is not an error, but we cannot continue
237
if (h_selected == null) {
238
setErrorMessage(null);
242
String s = h_selected.getErrorMessage();
248
setErrorMessage(null);
259
* @return : selected Wizard Handler.
261
public static CWizardHandler updateData(Tree tree, Composite right, Button show_sup,
262
IWizardItemsListListener ls, IWizard wizard) {
263
// Remember selected item
264
TreeItem[] selection = tree.getSelection();
265
TreeItem selectedItem = selection.length > 0 ? selection[0] : null;
266
String savedLabel = selectedItem != null ? selectedItem.getText() : null;
267
String savedParentLabel = getParentText(selectedItem);
270
IExtensionPoint extensionPoint =
271
Platform.getExtensionRegistry().getExtensionPoint(EXTENSION_POINT_ID);
272
if (extensionPoint == null) return null;
273
IExtension[] extensions = extensionPoint.getExtensions();
274
if (extensions == null) return null;
276
List<EntryDescriptor> items = new ArrayList<EntryDescriptor>();
277
for (int i = 0; i < extensions.length; ++i) {
278
IConfigurationElement[] elements = extensions[i].getConfigurationElements();
279
for (IConfigurationElement element : elements) {
280
if (element.getName().equals(ELEMENT_NAME)) {
283
w = (CNewWizard) element.createExecutableExtension(CLASS_NAME);
284
} catch (CoreException e) {
285
System.out.println(Messages.CMainWizardPage_5 + e.getLocalizedMessage());
290
w.setDependentControl(right, ls);
291
for (EntryDescriptor ed : w.createItems(show_sup.getSelection(), wizard))
296
// If there is a EntryDescriptor which is default for category, make sure it
297
// is in the front of the list.
298
for (int i = 0; i < items.size(); ++i) {
299
EntryDescriptor ed = items.get(i);
300
if (ed.isDefaultForCategory()) {
307
// bug # 211935 : allow items filtering.
308
if (ls != null) // NULL means call from prefs
309
items = ls.filterItems(items);
310
addItemsToTree(tree, items);
312
if (tree.getItemCount() > 0) {
313
TreeItem target = null;
314
// Try to search item which was selected before
315
if (savedLabel != null) {
316
target = findItem(tree, savedLabel, savedParentLabel);
318
if (target == null) {
319
// Default selection associated with "org.eclipse.cdt.build.core.buildArtefactType.exe" project type
320
target = findItem(tree, Messages.CDTMainWizardPage_DefaultProjectType,
321
Messages.CDTMainWizardPage_DefaultProjectCategory);
322
if (target == null) {
323
CUIPlugin.log(new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID,
324
"Default project not found in New C/C++ Project Wizard")); //$NON-NLS-1$
327
if (target == null) {
328
target = tree.getItem(0);
329
if (target.getItemCount() != 0)
330
target = target.getItem(0);
332
tree.setSelection(target);
333
return (CWizardHandler)target.getData();
338
private static String getParentText(TreeItem item) {
339
if (item == null || item.getParentItem() == null)
340
return ""; //$NON-NLS-1$
341
return item.getParentItem().getText();
344
private static TreeItem findItem(Tree tree, String label, String parentLabel) {
345
for (TreeItem item : tree.getItems()) {
346
TreeItem foundItem = findTreeItem(item, label, parentLabel);
353
private static TreeItem findTreeItem(TreeItem item, String label, String parentLabel) {
354
if (item.getText().equals(label) && getParentText(item).equals(parentLabel))
357
for (TreeItem child : item.getItems()) {
358
TreeItem foundItem = findTreeItem(child, label, parentLabel);
365
private static void addItemsToTree(Tree tree, List<EntryDescriptor> items) {
372
366
// Sorting is disabled because of users requests
373
367
// Collections.sort(items, CDTListComparator.getInstance());
375
ArrayList<TreeItem> placedTreeItemsList = new ArrayList<TreeItem>(items.size());
376
ArrayList<EntryDescriptor> placedEntryDescriptorsList = new ArrayList<EntryDescriptor>(items.size());
377
for (EntryDescriptor wd : items) {
378
if (wd.getParentId() == null) {
379
wd.setPath(wd.getId());
380
TreeItem ti = new TreeItem(tree, SWT.NONE);
381
ti.setText(TextProcessor.process(wd.getName()));
382
ti.setData(wd.getHandler());
383
ti.setData(DESC, wd);
384
ti.setImage(calcImage(wd));
385
placedTreeItemsList.add(ti);
386
placedEntryDescriptorsList.add(wd);
369
ArrayList<TreeItem> placedTreeItemsList = new ArrayList<TreeItem>(items.size());
370
ArrayList<EntryDescriptor> placedEntryDescriptorsList = new ArrayList<EntryDescriptor>(items.size());
371
for (EntryDescriptor wd : items) {
372
if (wd.getParentId() == null) {
373
wd.setPath(wd.getId());
374
TreeItem ti = new TreeItem(tree, SWT.NONE);
375
ti.setText(TextProcessor.process(wd.getName()));
376
ti.setData(wd.getHandler());
377
ti.setData(DESC, wd);
378
ti.setImage(calcImage(wd));
379
placedTreeItemsList.add(ti);
380
placedEntryDescriptorsList.add(wd);
390
boolean found = false;
391
Iterator<EntryDescriptor> it2 = items.iterator();
392
while (it2.hasNext()) {
393
EntryDescriptor wd1 = it2.next();
394
if (wd1.getParentId() == null) continue;
395
for (int i = 0; i< placedEntryDescriptorsList.size(); i++) {
396
EntryDescriptor wd2 = placedEntryDescriptorsList.get(i);
397
if (wd2.getId().equals(wd1.getParentId())) {
399
wd1.setParentId(null);
400
CWizardHandler h = wd2.getHandler();
401
/* If neither wd1 itself, nor its parent (wd2) have a handler
402
* associated with them, and the item is not a category,
403
* then skip it. If it's category, then it's possible that
404
* children will have a handler associated with them.
406
if (h == null && wd1.getHandler() == null && !wd1.isCategory())
384
boolean found = false;
385
Iterator<EntryDescriptor> it2 = items.iterator();
386
while (it2.hasNext()) {
387
EntryDescriptor wd1 = it2.next();
388
if (wd1.getParentId() == null) continue;
389
for (int i = 0; i < placedEntryDescriptorsList.size(); i++) {
390
EntryDescriptor wd2 = placedEntryDescriptorsList.get(i);
391
if (wd2.getId().equals(wd1.getParentId())) {
393
wd1.setParentId(null);
394
CWizardHandler h = wd2.getHandler();
395
/* If neither wd1 itself, nor its parent (wd2) have a handler
396
* associated with them, and the item is not a category,
397
* then skip it. If it's category, then it's possible that
398
* children will have a handler associated with them.
400
if (h == null && wd1.getHandler() == null && !wd1.isCategory())
403
wd1.setPath(wd2.getPath() + "/" + wd1.getId()); //$NON-NLS-1$
406
if (wd1.getHandler() == null && !wd1.isCategory())
407
wd1.setHandler((CWizardHandler)h.clone());
408
if (!h.isApplicable(wd1))
409
wd1.setPath(wd2.getPath() + "/" + wd1.getId()); //$NON-NLS-1$
412
if (wd1.getHandler() == null && !wd1.isCategory())
413
wd1.setHandler((CWizardHandler)h.clone());
414
if (!h.isApplicable(wd1))
418
TreeItem p = placedTreeItemsList.get(i);
419
TreeItem ti = new TreeItem(p, SWT.NONE);
420
ti.setText(wd1.getName());
421
ti.setData(wd1.getHandler());
422
ti.setData(DESC, wd1);
423
ti.setImage(calcImage(wd1));
424
placedTreeItemsList.add(ti);
425
placedEntryDescriptorsList.add(wd1);
430
// repeat iterations until all items are placed.
433
// orphan elements (with not-existing parentId) are ignored
436
private void switchTo(CWizardHandler h, EntryDescriptor ed) {
444
} catch (CoreException e) {
447
if (h_selected != null)
448
h_selected.handleUnSelection();
451
if (ed.isCategory()) {
452
if (categorySelectedLabel == null) {
453
categorySelectedLabel = new Label(right, SWT.WRAP);
454
categorySelectedLabel.setText(
455
Messages.CDTMainWizardPage_1);
458
categorySelectedLabel.setVisible(true);
462
right_label.setText(h_selected.getHeader());
463
if (categorySelectedLabel != null)
464
categorySelectedLabel.setVisible(false);
465
h_selected.handleSelection();
466
h_selected.setSupportedOnly(show_sup.getSelection());
470
public static EntryDescriptor getDescriptor(Tree _tree) {
471
TreeItem[] sel = _tree.getSelection();
472
if (sel == null || sel.length == 0)
474
return (EntryDescriptor)sel[0].getData(DESC);
478
public void toolChainListChanged(int count) {
479
setPageComplete(validatePage());
480
getWizard().getContainer().updateButtons();
484
public boolean isCurrent() { return isCurrentPage(); }
486
private static Image calcImage(EntryDescriptor ed) {
487
if (ed.getImage() != null) return ed.getImage();
488
if (ed.isCategory()) return IMG_CATEGORY;
493
@SuppressWarnings({ "unchecked", "rawtypes" })
494
public List filterItems(List items) {
412
TreeItem p = placedTreeItemsList.get(i);
413
TreeItem ti = new TreeItem(p, SWT.NONE);
414
ti.setText(wd1.getName());
415
ti.setData(wd1.getHandler());
416
ti.setData(DESC, wd1);
417
ti.setImage(calcImage(wd1));
418
placedTreeItemsList.add(ti);
419
placedEntryDescriptorsList.add(wd1);
424
// repeat iterations until all items are placed.
427
// orphan elements (with not-existing parentId) are ignored
430
private void switchTo(CWizardHandler h, EntryDescriptor ed) {
438
} catch (CoreException e) {
441
if (h_selected != null)
442
h_selected.handleUnSelection();
445
if (ed.isCategory()) {
446
if (categorySelectedLabel == null) {
447
categorySelectedLabel = new Label(right, SWT.WRAP);
448
categorySelectedLabel.setText(Messages.CDTMainWizardPage_1);
451
categorySelectedLabel.setVisible(true);
455
rightLabel.setText(h_selected.getHeader());
456
if (categorySelectedLabel != null)
457
categorySelectedLabel.setVisible(false);
458
h_selected.handleSelection();
459
h_selected.setSupportedOnly(showSup.getSelection());
462
public static EntryDescriptor getDescriptor(Tree tree) {
463
TreeItem[] sel = tree.getSelection();
464
if (sel == null || sel.length == 0)
466
return (EntryDescriptor) sel[0].getData(DESC);
470
public void toolChainListChanged(int count) {
471
setPageComplete(validatePage());
472
getWizard().getContainer().updateButtons();
476
public boolean isCurrent() {
477
return isCurrentPage();
480
private static Image calcImage(EntryDescriptor ed) {
481
Image image = ed.getImage();
485
return CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_SEARCHFOLDER);
486
return CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_VARIABLE);
490
@SuppressWarnings({ "unchecked", "rawtypes" })
491
public List filterItems(List items) {