KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > internal > dialogs > NewWizardNewPage


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.ui.internal.dialogs;
12
13 import java.util.ArrayList JavaDoc;
14 import java.util.Arrays JavaDoc;
15 import java.util.HashMap JavaDoc;
16 import java.util.Hashtable JavaDoc;
17 import java.util.Iterator JavaDoc;
18 import java.util.List JavaDoc;
19 import java.util.Map JavaDoc;
20
21 import org.eclipse.core.runtime.CoreException;
22 import org.eclipse.core.runtime.Path;
23 import org.eclipse.jface.dialogs.Dialog;
24 import org.eclipse.jface.dialogs.IDialogSettings;
25 import org.eclipse.jface.resource.ImageDescriptor;
26 import org.eclipse.jface.viewers.DoubleClickEvent;
27 import org.eclipse.jface.viewers.IDoubleClickListener;
28 import org.eclipse.jface.viewers.ISelectionChangedListener;
29 import org.eclipse.jface.viewers.IStructuredSelection;
30 import org.eclipse.jface.viewers.SelectionChangedEvent;
31 import org.eclipse.jface.viewers.StructuredSelection;
32 import org.eclipse.jface.viewers.TreeViewer;
33 import org.eclipse.jface.viewers.ViewerFilter;
34 import org.eclipse.jface.wizard.IWizardContainer;
35 import org.eclipse.jface.wizard.IWizardContainer2;
36 import org.eclipse.swt.SWT;
37 import org.eclipse.swt.custom.CLabel;
38 import org.eclipse.swt.events.DisposeEvent;
39 import org.eclipse.swt.events.DisposeListener;
40 import org.eclipse.swt.events.SelectionAdapter;
41 import org.eclipse.swt.events.SelectionEvent;
42 import org.eclipse.swt.graphics.Font;
43 import org.eclipse.swt.graphics.Image;
44 import org.eclipse.swt.layout.GridData;
45 import org.eclipse.swt.layout.GridLayout;
46 import org.eclipse.swt.widgets.Button;
47 import org.eclipse.swt.widgets.Composite;
48 import org.eclipse.swt.widgets.Control;
49 import org.eclipse.swt.widgets.Label;
50 import org.eclipse.ui.IWorkbenchWizard;
51 import org.eclipse.ui.activities.WorkbenchActivityHelper;
52 import org.eclipse.ui.dialogs.FilteredTree;
53 import org.eclipse.ui.internal.WorkbenchMessages;
54 import org.eclipse.ui.model.AdaptableList;
55 import org.eclipse.ui.model.WorkbenchLabelProvider;
56 import org.eclipse.ui.wizards.IWizardCategory;
57 import org.eclipse.ui.wizards.IWizardDescriptor;
58
59 /**
60  * New wizard selection tab that allows the user to select a registered 'New'
61  * wizard to be launched.
62  */

63 class NewWizardNewPage implements ISelectionChangedListener {
64
65     // id constants
66
private static final String JavaDoc DIALOG_SETTING_SECTION_NAME = "NewWizardSelectionPage."; //$NON-NLS-1$
67

68     private final static int SIZING_LISTS_HEIGHT = 200;
69
70     private final static int SIZING_VIEWER_WIDTH = 300;
71
72     private final static String JavaDoc STORE_EXPANDED_CATEGORIES_ID = DIALOG_SETTING_SECTION_NAME
73             + "STORE_EXPANDED_CATEGORIES_ID"; //$NON-NLS-1$
74

75     private final static String JavaDoc STORE_SELECTED_ID = DIALOG_SETTING_SECTION_NAME
76             + "STORE_SELECTED_ID"; //$NON-NLS-1$
77

78     private NewWizardSelectionPage page;
79     
80     private FilteredTree filteredTree;
81     
82     private WizardPatternFilter filteredTreeFilter;
83
84     //Keep track of the wizards we have previously selected
85
private Hashtable JavaDoc selectedWizards = new Hashtable JavaDoc();
86
87     private IDialogSettings settings;
88
89     private Button showAllCheck;
90
91     private IWizardCategory wizardCategories;
92
93     private IWizardDescriptor [] primaryWizards;
94
95     private CLabel descImageCanvas;
96
97     private Map JavaDoc imageTable = new HashMap JavaDoc();
98
99     private IWizardDescriptor selectedElement;
100
101     private WizardActivityFilter filter = new WizardActivityFilter();
102
103     private boolean needShowAll;
104
105     private boolean projectsOnly;
106
107     private ViewerFilter projectFilter = new WizardTagFilter(new String JavaDoc[] {WorkbenchWizardElement.TAG_PROJECT});
108
109     /**
110      * Create an instance of this class
111      * @param mainPage
112      * @param wizardCategories
113      * @param primaryWizards
114      * @param projectsOnly
115      */

116     public NewWizardNewPage(NewWizardSelectionPage mainPage,
117             IWizardCategory wizardCategories,
118             IWizardDescriptor[] primaryWizards, boolean projectsOnly) {
119         this.page = mainPage;
120         this.wizardCategories = wizardCategories;
121         this.primaryWizards = primaryWizards;
122         this.projectsOnly = projectsOnly;
123
124         trimPrimaryWizards();
125
126         if (this.primaryWizards.length > 0) {
127             if (allPrimary(wizardCategories)) {
128                 this.wizardCategories = null; // dont bother considering the categories as all wizards are primary
129
needShowAll = false;
130             } else {
131                 needShowAll = !allActivityEnabled(wizardCategories);
132             }
133         } else {
134             needShowAll = !allActivityEnabled(wizardCategories);
135         }
136     }
137
138     /**
139      * @param category the wizard category
140      * @return whether all of the wizards in the category are enabled via activity filtering
141      */

142     private boolean allActivityEnabled(IWizardCategory category) {
143         IWizardDescriptor [] wizards = category.getWizards();
144         for (int i = 0; i < wizards.length; i++) {
145             IWizardDescriptor wizard = wizards[i];
146             if (WorkbenchActivityHelper.filterItem(wizard)) {
147                 return false;
148             }
149         }
150
151         IWizardCategory [] children = category.getCategories();
152         for (int i = 0; i < children.length; i++) {
153             if (!allActivityEnabled(children[i])) {
154                 return false;
155             }
156         }
157
158         return true;
159     }
160
161     /**
162      * Remove all primary wizards that are not in the wizard collection
163      */

164     private void trimPrimaryWizards() {
165         ArrayList JavaDoc newPrimaryWizards = new ArrayList JavaDoc(primaryWizards.length);
166
167         if (wizardCategories == null) {
168             return;//No categories so nothing to trim
169
}
170
171         for (int i = 0; i < primaryWizards.length; i++) {
172             if (wizardCategories.findWizard(primaryWizards[i].getId()) != null) {
173                 newPrimaryWizards.add(primaryWizards[i]);
174             }
175         }
176
177         primaryWizards = (WorkbenchWizardElement[]) newPrimaryWizards
178                 .toArray(new WorkbenchWizardElement[newPrimaryWizards.size()]);
179     }
180
181     /**
182      * @param category the wizard category
183      * @return whether all wizards in the category are considered primary
184      */

185     private boolean allPrimary(IWizardCategory category) {
186         IWizardDescriptor [] wizards = category.getWizards();
187         for (int i = 0; i < wizards.length; i++) {
188             IWizardDescriptor wizard = wizards[i];
189             if (!isPrimary(wizard)) {
190                 return false;
191             }
192         }
193
194         IWizardCategory [] children = category.getCategories();
195         for (int i = 0; i < children.length; i++) {
196             if (!allPrimary(children[i])) {
197                 return false;
198             }
199         }
200
201         return true;
202     }
203
204     /**
205      * @param wizard
206      * @return whether the given wizard is primary
207      */

208     private boolean isPrimary(IWizardDescriptor wizard) {
209         for (int j = 0; j < primaryWizards.length; j++) {
210             if (primaryWizards[j].equals(wizard)) {
211                 return true;
212             }
213         }
214
215         return false;
216     }
217
218     /**
219      * @since 3.0
220      */

221     public void activate() {
222         page.setDescription(WorkbenchMessages.NewWizardNewPage_description);
223     }
224
225     /**
226      * Create this tab's visual components
227      *
228      * @param parent Composite
229      * @return Control
230      */

231     protected Control createControl(Composite parent) {
232
233         Font wizardFont = parent.getFont();
234         // top level group
235
Composite outerContainer = new Composite(parent, SWT.NONE);
236         GridLayout layout = new GridLayout();
237         outerContainer.setLayout(layout);
238
239         Label wizardLabel = new Label(outerContainer, SWT.NONE);
240         GridData data = new GridData(SWT.BEGINNING, SWT.FILL, false, true);
241         outerContainer.setLayoutData(data);
242         wizardLabel.setFont(wizardFont);
243         wizardLabel.setText(WorkbenchMessages.NewWizardNewPage_wizardsLabel);
244
245         Composite innerContainer = new Composite(outerContainer, SWT.NONE);
246         layout = new GridLayout(2, false);
247         layout.marginHeight = 0;
248         layout.marginWidth = 0;
249         innerContainer.setLayout(layout);
250         innerContainer.setFont(wizardFont);
251         data = new GridData(SWT.FILL, SWT.FILL, true, true);
252         innerContainer.setLayoutData(data);
253
254         filteredTree = createFilteredTree(innerContainer);
255         createOptionsButtons(innerContainer);
256         
257         createImage(innerContainer);
258
259         updateDescription(null);
260
261         // wizard actions pane...create SWT table directly to
262
// get single selection mode instead of multi selection.
263
restoreWidgetValues();
264
265         return outerContainer;
266     }
267
268     /**
269      * Create a new FilteredTree in the parent.
270      *
271      * @param parent the parent <code>Composite</code>.
272      * @since 3.0
273      */

274     protected FilteredTree createFilteredTree(Composite parent){
275         Composite composite = new Composite(parent, SWT.NONE);
276         GridLayout layout = new GridLayout();
277         layout.marginHeight = 0;
278         layout.marginWidth = 0;
279         composite.setLayout(layout);
280         
281         GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
282         data.widthHint = SIZING_VIEWER_WIDTH;
283         data.horizontalSpan = 2;
284         data.grabExcessHorizontalSpace = true;
285         data.grabExcessVerticalSpace = true;
286
287         boolean needsHint = DialogUtil.inRegularFontMode(parent);
288
289         //Only give a height hint if the dialog is going to be too small
290
if (needsHint) {
291             data.heightHint = SIZING_LISTS_HEIGHT;
292         }
293         composite.setLayoutData(data);
294
295         filteredTreeFilter = new WizardPatternFilter();
296         FilteredTree filterTree = new FilteredTree(composite,
297                 SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER, filteredTreeFilter);
298     
299         final TreeViewer treeViewer = filterTree.getViewer();
300         treeViewer.setContentProvider(new WizardContentProvider());
301         treeViewer.setLabelProvider(new WorkbenchLabelProvider());
302         treeViewer.setComparator(NewWizardCollectionComparator.INSTANCE);
303         treeViewer.addSelectionChangedListener(this);
304
305         ArrayList JavaDoc inputArray = new ArrayList JavaDoc();
306
307         for (int i = 0; i < primaryWizards.length; i++) {
308             inputArray.add(primaryWizards[i]);
309         }
310
311         boolean expandTop = false;
312
313         if (wizardCategories != null) {
314             if (wizardCategories.getParent() == null) {
315                 IWizardCategory [] children = wizardCategories.getCategories();
316                 for (int i = 0; i < children.length; i++) {
317                     inputArray.add(children[i]);
318                 }
319             } else {
320                 expandTop = true;
321                 inputArray.add(wizardCategories);
322             }
323         }
324
325         // ensure the category is expanded. If there is a remembered expansion it will be set later.
326
if (expandTop) {
327             treeViewer.setAutoExpandLevel(2);
328         }
329
330         AdaptableList input = new AdaptableList(inputArray);
331
332         treeViewer.setInput(input);
333
334         filterTree.setBackground(parent.getDisplay().getSystemColor(
335                 SWT.COLOR_WIDGET_BACKGROUND));
336
337         treeViewer.getTree().setFont(parent.getFont());
338
339         treeViewer.addDoubleClickListener(new IDoubleClickListener() {
340             /*
341              * (non-Javadoc)
342              *
343              * @see org.eclipse.jface.viewers.IDoubleClickListener#doubleClick(org.eclipse.jface.viewers.DoubleClickEvent)
344              */

345             public void doubleClick(DoubleClickEvent event) {
346                     IStructuredSelection s = (IStructuredSelection) event
347                         .getSelection();
348                 selectionChanged(new SelectionChangedEvent(event.getViewer(), s));
349                 
350                 Object JavaDoc element = s.getFirstElement();
351                 if (treeViewer.isExpandable(element)) {
352                     treeViewer.setExpandedState(element, !treeViewer
353                             .getExpandedState(element));
354                 } else if (element instanceof WorkbenchWizardElement) {
355                     page.advanceToNextPageOrFinish();
356                 }
357             }
358         });
359         
360         treeViewer.addFilter(filter);
361         
362         if (projectsOnly) {
363             treeViewer.addFilter(projectFilter);
364         }
365
366         Dialog.applyDialogFont(filterTree);
367         return filterTree;
368     }
369     
370     /**
371      * Create the Show All and help buttons at the bottom of the page.
372      *
373      * @param parent the parent composite on which to create the widgets
374      */

375     private void createOptionsButtons(Composite parent){
376         if (needShowAll) {
377             showAllCheck = new Button(parent, SWT.CHECK);
378             GridData data = new GridData();
379             showAllCheck.setLayoutData(data);
380             showAllCheck.setFont(parent.getFont());
381             showAllCheck.setText(WorkbenchMessages.NewWizardNewPage_showAll);
382             showAllCheck.setSelection(false);
383
384             // flipping tabs updates the selected node
385
showAllCheck.addSelectionListener(new SelectionAdapter() {
386
387                 // the delta of expanded elements between the last 'show all'
388
// and the current 'no show all'
389
private Object JavaDoc[] delta = new Object JavaDoc[0];
390
391                 public void widgetSelected(SelectionEvent e) {
392                     boolean showAll = showAllCheck.getSelection();
393
394                     if (showAll) {
395                         filteredTree.getViewer().getControl().setRedraw(false);
396                     } else {
397                         // get the inital expanded elements when going from show
398
// all-> no show all.
399
// this isnt really the delta yet, we're just reusing
400
// the variable.
401
delta = filteredTree.getViewer().getExpandedElements();
402                     }
403
404                     try {
405                         if (showAll) {
406                             filteredTree.getViewer().resetFilters();
407                             filteredTree.getViewer().addFilter(filteredTreeFilter);
408                             if (projectsOnly) {
409                                 filteredTree.getViewer().addFilter(projectFilter);
410                             }
411
412                             // restore the expanded elements that were present
413
// in the last show all state but not in the 'no
414
// show all' state.
415
Object JavaDoc[] currentExpanded = filteredTree.getViewer()
416                                     .getExpandedElements();
417                             Object JavaDoc[] expanded = new Object JavaDoc[delta.length
418                                     + currentExpanded.length];
419                             System.arraycopy(currentExpanded, 0, expanded, 0,
420                                     currentExpanded.length);
421                             System.arraycopy(delta, 0, expanded,
422                                     currentExpanded.length, delta.length);
423                             filteredTree.getViewer().setExpandedElements(expanded);
424                         } else {
425                             filteredTree.getViewer().addFilter(filter);
426                             if (projectsOnly) {
427                                 filteredTree.getViewer().addFilter(projectFilter);
428                             }
429                         }
430                         filteredTree.getViewer().refresh(false);
431
432                         if (!showAll) {
433                             // if we're going from show all -> no show all
434
// record the elements that were expanded in the
435
// 'show all' state but not the 'no show all' state
436
// (because they didnt exist).
437
Object JavaDoc[] newExpanded = filteredTree.getViewer().getExpandedElements();
438                             List JavaDoc deltaList = new ArrayList JavaDoc(Arrays.asList(delta));
439                             deltaList.removeAll(Arrays.asList(newExpanded));
440                         }
441                     } finally {
442                         if (showAll) {
443                             filteredTree.getViewer().getControl().setRedraw(true);
444                         }
445                     }
446                 }
447             });
448         }
449     }
450     
451     /**
452      * Create the image controls.
453      *
454      * @param parent the parent <code>Composite</code>.
455      * @since 3.0
456      */

457     private void createImage(Composite parent) {
458         descImageCanvas = new CLabel(parent, SWT.NONE);
459         GridData data = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING
460                 | GridData.VERTICAL_ALIGN_BEGINNING);
461         data.widthHint = 0;
462         data.heightHint = 0;
463         descImageCanvas.setLayoutData(data);
464
465         // hook a listener to get rid of cached images.
466
descImageCanvas.addDisposeListener(new DisposeListener() {
467
468             /* (non-Javadoc)
469              * @see org.eclipse.swt.events.DisposeListener#widgetDisposed(org.eclipse.swt.events.DisposeEvent)
470              */

471             public void widgetDisposed(DisposeEvent e) {
472                 for (Iterator JavaDoc i = imageTable.values().iterator(); i.hasNext();) {
473                     ((Image) i.next()).dispose();
474                 }
475                 imageTable.clear();
476             }
477         });
478     }
479
480     /**
481      * Expands the wizard categories in this page's category viewer that were
482      * expanded last time this page was used. If a category that was previously
483      * expanded no longer exists then it is ignored.
484      */

485     protected void expandPreviouslyExpandedCategories() {
486         String JavaDoc[] expandedCategoryPaths = settings
487                 .getArray(STORE_EXPANDED_CATEGORIES_ID);
488         if (expandedCategoryPaths == null || expandedCategoryPaths.length == 0) {
489             return;
490         }
491
492         List JavaDoc categoriesToExpand = new ArrayList JavaDoc(expandedCategoryPaths.length);
493
494         if (wizardCategories != null) {
495             for (int i = 0; i < expandedCategoryPaths.length; i++) {
496                 IWizardCategory category = wizardCategories
497                         .findCategory(new Path(expandedCategoryPaths[i]));
498                 if (category != null) {
499                     categoriesToExpand.add(category);
500                 }
501             }
502         }
503
504         if (!categoriesToExpand.isEmpty()) {
505             filteredTree.getViewer().setExpandedElements(categoriesToExpand.toArray());
506         }
507
508     }
509
510     /**
511      * Returns the single selected object contained in the passed
512      * selectionEvent, or <code>null</code> if the selectionEvent contains
513      * either 0 or 2+ selected objects.
514      */

515     protected Object JavaDoc getSingleSelection(IStructuredSelection selection) {
516         return selection.size() == 1 ? selection.getFirstElement() : null;
517     }
518
519     /**
520      * Set self's widgets to the values that they held last time this page was
521      * open
522      *
523      */

524     protected void restoreWidgetValues() {
525         expandPreviouslyExpandedCategories();
526         selectPreviouslySelected();
527     }
528
529     /**
530      * Store the current values of self's widgets so that they can be restored
531      * in the next instance of self
532      *
533      */

534     public void saveWidgetValues() {
535         storeExpandedCategories();
536         storeSelectedCategoryAndWizard();
537     }
538
539     /**
540      * The user selected either new wizard category(s) or wizard element(s).
541      * Proceed accordingly.
542      *
543      * @param selectionEvent ISelection
544      */

545     public void selectionChanged(SelectionChangedEvent selectionEvent) {
546         page.setErrorMessage(null);
547         page.setMessage(null);
548
549         Object JavaDoc selectedObject = getSingleSelection((IStructuredSelection) selectionEvent
550                 .getSelection());
551
552         if (selectedObject instanceof IWizardDescriptor) {
553             if (selectedObject == selectedElement) {
554                 return;
555             }
556             updateWizardSelection((IWizardDescriptor) selectedObject);
557         } else {
558             selectedElement = null;
559             page.setHasPages(false);
560             page.setCanFinishEarly(false);
561             page.selectWizardNode(null);
562             updateDescription(null);
563         }
564     }
565
566     /**
567      * Selects the wizard category and wizard in this page that were selected
568      * last time this page was used. If a category or wizard that was
569      * previously selected no longer exists then it is ignored.
570      */

571     protected void selectPreviouslySelected() {
572         String JavaDoc selectedId = settings.get(STORE_SELECTED_ID);
573         if (selectedId == null) {
574             return;
575         }
576
577         if (wizardCategories == null) {
578             return;
579         }
580
581         Object JavaDoc selected = wizardCategories.findCategory(new Path(
582                 selectedId));
583
584         if (selected == null) {
585             selected = wizardCategories.findWizard(selectedId);
586
587             if (selected == null) {
588                 // if we cant find either a category or a wizard, abort.
589
return;
590             }
591         }
592
593         //work around for 62039
594
final StructuredSelection selection = new StructuredSelection(selected);
595         filteredTree.getViewer().getControl().getDisplay().asyncExec(new Runnable JavaDoc() {
596             public void run() {
597                 filteredTree.getViewer().setSelection(selection, true);
598             }
599         });
600     }
601
602     /**
603      * Set the dialog store to use for widget value storage and retrieval
604      *
605      * @param settings IDialogSettings
606      */

607     public void setDialogSettings(IDialogSettings settings) {
608         this.settings = settings;
609     }
610
611     /**
612      * Stores the collection of currently-expanded categories in this page's
613      * dialog store, in order to recreate this page's state in the next
614      * instance of this page.
615      */

616     protected void storeExpandedCategories() {
617         Object JavaDoc[] expandedElements = filteredTree.getViewer().getExpandedElements();
618         List JavaDoc expandedElementPaths = new ArrayList JavaDoc(expandedElements.length);
619         for (int i = 0; i < expandedElements.length; ++i) {
620             if (expandedElements[i] instanceof IWizardCategory) {
621                 expandedElementPaths
622                         .add(((IWizardCategory) expandedElements[i])
623                                 .getPath().toString());
624             }
625         }
626         settings.put(STORE_EXPANDED_CATEGORIES_ID,
627                 (String JavaDoc[]) expandedElementPaths
628                         .toArray(new String JavaDoc[expandedElementPaths.size()]));
629     }
630
631     /**
632      * Stores the currently-selected element in this page's dialog store, in
633      * order to recreate this page's state in the next instance of this page.
634      */

635     protected void storeSelectedCategoryAndWizard() {
636         Object JavaDoc selected = getSingleSelection((IStructuredSelection) filteredTree
637                 .getViewer().getSelection());
638
639         if (selected != null) {
640             if (selected instanceof IWizardCategory) {
641                 settings.put(STORE_SELECTED_ID,
642                         ((IWizardCategory) selected).getPath()
643                                 .toString());
644             } else {
645                 // else its a wizard
646
settings.put(STORE_SELECTED_ID,
647                         ((IWizardDescriptor) selected).getId());
648             }
649         }
650     }
651
652     /**
653      * Update the current description controls.
654      *
655      * @param selectedObject the new wizard
656      * @since 3.0
657      */

658     private void updateDescription(IWizardDescriptor selectedObject) {
659         String JavaDoc string = ""; //$NON-NLS-1$
660
if (selectedObject != null) {
661             string = selectedObject.getDescription();
662         }
663
664         page.setDescription(string);
665
666         if (hasImage(selectedObject)) {
667             ImageDescriptor descriptor = null;
668             if (selectedObject != null) {
669                 descriptor = selectedObject.getDescriptionImage();
670             }
671
672             if (descriptor != null) {
673                 GridData data = (GridData)descImageCanvas.getLayoutData();
674                 data.widthHint = SWT.DEFAULT;
675                 data.heightHint = SWT.DEFAULT;
676                 Image image = (Image) imageTable.get(descriptor);
677                 if (image == null) {
678                     image = descriptor.createImage(false);
679                     imageTable.put(descriptor, image);
680                 }
681                 descImageCanvas.setImage(image);
682             }
683         } else {
684             GridData data = (GridData)descImageCanvas.getLayoutData();
685             data.widthHint = 0;
686             data.heightHint = 0;
687             descImageCanvas.setImage(null);
688         }
689
690         descImageCanvas.getParent().layout(true);
691
692         IWizardContainer container = page.getWizard().getContainer();
693         if (container instanceof IWizardContainer2) {
694             ((IWizardContainer2) container).updateSize();
695         }
696     }
697
698     /**
699      * Tests whether the given wizard has an associated image.
700      *
701      * @param selectedObject the wizard to test
702      * @return whether the given wizard has an associated image
703      */

704     private boolean hasImage(IWizardDescriptor selectedObject) {
705         if (selectedObject == null) {
706             return false;
707         }
708
709         if (selectedObject.getDescriptionImage() != null) {
710             return true;
711         }
712
713         return false;
714     }
715
716     /**
717      * @param selectedObject
718      */

719     private void updateWizardSelection(IWizardDescriptor selectedObject) {
720         selectedElement = selectedObject;
721         WorkbenchWizardNode selectedNode;
722         if (selectedWizards.containsKey(selectedObject)) {
723             selectedNode = (WorkbenchWizardNode) selectedWizards
724                     .get(selectedObject);
725         } else {
726             selectedNode = new WorkbenchWizardNode(page, selectedObject) {
727                 public IWorkbenchWizard createWizard() throws CoreException {
728                     return wizardElement.createWizard();
729                 }
730             };
731             selectedWizards.put(selectedObject, selectedNode);
732         }
733
734         page.setCanFinishEarly(selectedObject.canFinishEarly());
735         page.setHasPages(selectedObject.hasPages());
736         page.selectWizardNode(selectedNode);
737
738         updateDescription(selectedObject);
739     }
740 }
741
Popular Tags