Mercurial > projects > dwt-addons
annotate dwtx/jface/wizard/WizardSelectionPage.d @ 104:04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
These new wrappers now use the tango.util.containers instead of the tango.util.collections.
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Thu, 07 Aug 2008 15:01:33 +0200 |
parents | ea8ff534f622 |
children |
rev | line source |
---|---|
35 | 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 * Port to the D programming language: | |
11 * Frank Benoit <benoit@tionex.de> | |
12 *******************************************************************************/ | |
13 module dwtx.jface.wizard.WizardSelectionPage; | |
14 | |
15 import dwtx.jface.wizard.IWizardPage; | |
16 import dwtx.jface.wizard.IWizard; | |
17 import dwtx.jface.wizard.WizardPage; | |
18 import dwtx.jface.wizard.IWizardNode; | |
19 | |
20 | |
21 import dwt.dwthelper.utils; | |
104
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
43
diff
changeset
|
22 import dwtx.dwtxhelper.Collection; |
35 | 23 |
24 /** | |
25 * An abstract implementation of a wizard page that manages a | |
26 * set of embedded wizards. | |
27 * <p> | |
28 * A wizard selection page should present a list of wizard nodes | |
29 * corresponding to other wizards. When the end user selects one of | |
30 * them from the list, the first page of the selected wizard becomes | |
31 * the next page. The only new methods introduced by this class are | |
32 * <code>getSelectedNode</code> and <code>setSelectedNode</code>. | |
33 * Otherwise, the subclass contract is the same as <code>WizardPage</code>. | |
34 * </p> | |
35 */ | |
36 public abstract class WizardSelectionPage : WizardPage { | |
37 | |
38 /** | |
39 * The selected node; <code>null</code> if none. | |
40 */ | |
41 private IWizardNode selectedNode = null; | |
42 | |
43 /** | |
44 * List of wizard nodes that have cropped up in the past | |
45 * (element type: <code>IWizardNode</code>). | |
46 */ | |
104
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
43
diff
changeset
|
47 private List selectedWizardNodes; |
35 | 48 |
49 /** | |
50 * Creates a new wizard selection page with the given name, and | |
51 * with no title or image. | |
52 * | |
53 * @param pageName the name of the page | |
54 */ | |
55 protected this(String pageName) { | |
56 super(pageName); | |
104
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
43
diff
changeset
|
57 selectedWizardNodes = new ArrayList(); |
35 | 58 // Cannot finish from this page |
59 setPageComplete(false); | |
60 } | |
61 | |
62 /** | |
63 * Adds the given wizard node to the list of selected nodes if | |
64 * it is not already in the list. | |
65 * | |
66 * @param node the wizard node, or <code>null</code> | |
67 */ | |
68 private void addSelectedNode(IWizardNode node) { | |
69 if (node is null) { | |
70 return; | |
71 } | |
72 | |
73 if (selectedWizardNodes.contains(cast(Object)node)) { | |
74 return; | |
75 } | |
76 | |
104
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
43
diff
changeset
|
77 selectedWizardNodes.add(cast(Object)node); |
35 | 78 } |
79 | |
80 /** | |
81 * The <code>WizardSelectionPage</code> implementation of | |
82 * this <code>IWizardPage</code> method returns <code>true</code> | |
83 * if there is a selected node. | |
84 */ | |
43
ea8ff534f622
Fix override and super aliases
Frank Benoit <benoit@tionex.de>
parents:
35
diff
changeset
|
85 public override bool canFlipToNextPage() { |
35 | 86 return selectedNode !is null; |
87 } | |
88 | |
89 /** | |
90 * The <code>WizardSelectionPage</code> implementation of an <code>IDialogPage</code> | |
91 * method disposes of all nested wizards. Subclasses may extend. | |
92 */ | |
43
ea8ff534f622
Fix override and super aliases
Frank Benoit <benoit@tionex.de>
parents:
35
diff
changeset
|
93 public override void dispose() { |
35 | 94 super.dispose(); |
95 // notify nested wizards | |
96 for (int i = 0; i < selectedWizardNodes.size(); i++) { | |
97 (cast(IWizardNode) selectedWizardNodes.get(i)).dispose(); | |
98 } | |
99 } | |
100 | |
101 /** | |
102 * The <code>WizardSelectionPage</code> implementation of | |
103 * this <code>IWizardPage</code> method returns the first page | |
104 * of the currently selected wizard if there is one. | |
105 */ | |
43
ea8ff534f622
Fix override and super aliases
Frank Benoit <benoit@tionex.de>
parents:
35
diff
changeset
|
106 public override IWizardPage getNextPage() { |
35 | 107 if (selectedNode is null) { |
108 return null; | |
109 } | |
110 | |
111 bool isCreated = selectedNode.isContentCreated(); | |
112 | |
113 IWizard wizard = selectedNode.getWizard(); | |
114 | |
115 if (wizard is null) { | |
116 setSelectedNode(null); | |
117 return null; | |
118 } | |
119 | |
120 if (!isCreated) { | |
121 // Allow the wizard to create its pages | |
122 wizard.addPages(); | |
123 } | |
124 | |
125 return wizard.getStartingPage(); | |
126 } | |
127 | |
128 /** | |
129 * Returns the currently selected wizard node within this page. | |
130 * | |
131 * @return the wizard node, or <code>null</code> if no node is selected | |
132 */ | |
133 public IWizardNode getSelectedNode() { | |
134 return selectedNode; | |
135 } | |
136 | |
137 /** | |
138 * Sets or clears the currently selected wizard node within this page. | |
139 * | |
140 * @param node the wizard node, or <code>null</code> to clear | |
141 */ | |
142 protected void setSelectedNode(IWizardNode node) { | |
143 addSelectedNode(node); | |
144 selectedNode = node; | |
145 if (isCurrentPage()) { | |
146 getContainer().updateButtons(); | |
147 } | |
148 } | |
149 } |