KickJava   Java API By Example, From Geeks To Geeks.

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


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 org.eclipse.jface.viewers.IStructuredSelection;
14 import org.eclipse.jface.viewers.TableViewer;
15 import org.eclipse.jface.wizard.IWizardNode;
16 import org.eclipse.jface.wizard.IWizardPage;
17 import org.eclipse.jface.wizard.WizardSelectionPage;
18 import org.eclipse.ui.IWorkbench;
19 import org.eclipse.ui.activities.ITriggerPoint;
20 import org.eclipse.ui.activities.WorkbenchActivityHelper;
21 import org.eclipse.ui.internal.WorkbenchMessages;
22 import org.eclipse.ui.model.AdaptableList;
23
24 /**
25  * Page for selecting a wizard from a group of available wizards.
26  */

27 public abstract class WorkbenchWizardSelectionPage extends WizardSelectionPage {
28
29     // variables
30
protected IWorkbench workbench;
31
32     protected AdaptableList wizardElements;
33
34     public TableViewer wizardSelectionViewer;
35
36     protected IStructuredSelection currentResourceSelection;
37     
38     protected String JavaDoc triggerPointId;
39
40     /**
41      * Create an instance of this class
42      */

43     public WorkbenchWizardSelectionPage(String JavaDoc name, IWorkbench aWorkbench,
44             IStructuredSelection currentSelection, AdaptableList elements,
45             String JavaDoc triggerPointId) {
46         super(name);
47         this.wizardElements = elements;
48         this.currentResourceSelection = currentSelection;
49         this.workbench = aWorkbench;
50         this.triggerPointId = triggerPointId;
51         setTitle(WorkbenchMessages.Select);
52     }
53
54     /**
55      * Answer the wizard object corresponding to the passed id, or null
56      * if such an object could not be found
57      *
58      * @return WizardElement
59      * @param searchId the id to search on
60      */

61     protected WorkbenchWizardElement findWizard(String JavaDoc searchId) {
62         Object JavaDoc[] children = wizardElements.getChildren();
63         for (int i = 0; i < children.length; ++i) {
64             WorkbenchWizardElement currentWizard = (WorkbenchWizardElement) children[i];
65             if (currentWizard.getId().equals(searchId)) {
66                 return currentWizard;
67             }
68         }
69
70         return null;
71     }
72
73     public IStructuredSelection getCurrentResourceSelection() {
74         return currentResourceSelection;
75     }
76
77     public IWorkbench getWorkbench() {
78         return this.workbench;
79     }
80
81     /**
82      * Specify the passed wizard node as being selected, meaning that if
83      * it's non-null then the wizard to be displayed when the user next
84      * presses the Next button should be determined by asking the passed
85      * node.
86      *
87      * @param node org.eclipse.jface.wizards.IWizardNode
88      */

89     public void selectWizardNode(IWizardNode node) {
90         setSelectedNode(node);
91     }
92
93     /* (non-Javadoc)
94      * @see org.eclipse.jface.wizard.IWizardPage#getNextPage()
95      */

96     public IWizardPage getNextPage() {
97         ITriggerPoint triggerPoint = getWorkbench().getActivitySupport()
98         .getTriggerPointManager().getTriggerPoint(triggerPointId);
99         if (triggerPoint == null || WorkbenchActivityHelper.allowUseOf(triggerPoint, getSelectedNode())) {
100             return super.getNextPage();
101         }
102         return null;
103     }
104 }
105
Popular Tags