KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > kelp > jbuilder > wizard > AbstractBasicWizard


1 /*
2  * Enhydra Java Application Server Project
3  *
4  * The contents of this file are subject to the Enhydra Public License
5  * Version 1.1 (the "License"); you may not use this file except in
6  * compliance with the License. You may obtain a copy of the License on
7  * the Enhydra web site ( http://www.enhydra.org/ ).
8  *
9  * Software distributed under the License is distributed on an "AS IS"
10  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
11  * the License for the specific terms governing rights and limitations
12  * under the License.
13  *
14  * The Initial Developer of the Enhydra Application Server is Lutris
15  * Technologies, Inc. The Enhydra Application Server and portions created
16  * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
17  * All Rights Reserved.
18  *
19  * Contributor(s):
20  *
21  */

22 package org.enhydra.kelp.jbuilder.wizard;
23
24 // ToolBox imports
25
import org.enhydra.tool.ToolBoxInfo;
26
27 // Enhydra imports
28
import org.enhydra.xml.xmlc.XMLCException;
29
30 // JBuilder imports
31
import com.borland.jbuilder.JBuilderHelp;
32 import com.borland.jbuilder.node.JBProject;
33 import com.borland.jbuilder.node.HTMLFileNode;
34 import com.borland.primetime.help.ZipHelpBook;
35 import com.borland.primetime.help.ZipHelpTopic;
36 import com.borland.primetime.ide.Browser;
37 import com.borland.primetime.ide.BrowserListener;
38 import com.borland.primetime.ide.NodeViewer;
39 import com.borland.primetime.node.Node;
40 import com.borland.primetime.node.Project;
41 import com.borland.primetime.wizard.BasicWizard;
42 import com.borland.primetime.wizard.Wizard;
43 import com.borland.primetime.wizard.WizardAction;
44 import com.borland.primetime.wizard.WizardHost;
45 import com.borland.primetime.wizard.WizardManager;
46 import com.borland.primetime.wizard.WizardPage;
47 import com.borland.primetime.util.VetoException;
48 import com.borland.primetime.vfs.InvalidUrlException;
49
50 // Kelp imports
51
import org.enhydra.kelp.KelpInfo;
52 import org.enhydra.kelp.common.Constants;
53 import org.enhydra.kelp.common.node.OtterNode;
54 import org.enhydra.kelp.jbuilder.node.PrimeProject;
55
56 // Standard imports
57
import javax.swing.JOptionPane JavaDoc;
58 import java.awt.Container JavaDoc;
59 import java.io.File JavaDoc;
60 import java.util.ResourceBundle JavaDoc;
61
62 /**
63  * Class declaration
64  *
65  *
66  * @author Paul Mahar
67  */

68 abstract public class AbstractBasicWizard extends BasicWizard {
69     static ResourceBundle JavaDoc res =
70         ResourceBundle.getBundle("org.enhydra.kelp.jbuilder.Res"); // nores
71

72     //
73
private JBProject nativeProject = null;
74
75     //
76
public static boolean enableMenu = true;
77     public static BrowserListener browserListener =
78         new AbstractBasicWizardBrowserListener();
79
80     public JBProject getNativeProject() {
81         return nativeProject;
82     }
83
84     public void setNativeProject(JBProject p) {
85         nativeProject = p;
86     }
87
88     public void saveNodes(OtterNode[] nodes) {
89         if (nodes != null) {
90             for (int i = 0; i < nodes.length; i++) {
91                 nodes[i].save();
92             }
93         }
94     }
95
96     public abstract String JavaDoc getHelpTopic();
97     public void help(WizardPage wizardPage, WizardHost wizardHost) {
98         ZipHelpTopic topic = null;
99         ZipHelpBook book = null;
100
101         book = JBuilderHelp.createBook(Constants.KELP);
102         topic = new ZipHelpTopic(book, getHelpTopic());
103         topic.show(wizardPage.getPageComponent(wizardHost));
104     }
105
106     public WizardPage invokeWizard(WizardHost host) {
107         setWizardTitle(getName());
108         return super.invokeWizard(host);
109     }
110
111     /**
112      * Method declaration
113      *
114      *
115      * @throws VetoException
116      *
117      * @see
118      */

119     protected void finish() throws VetoException {}
120
121     /**
122      * Method declaration
123      *
124      *
125      * @return
126      *
127      * @see
128      */

129     public static String JavaDoc getName() {
130         return "Enhydra Wizard";
131     }
132
133     public static class AbstractBasicWizardBrowserListener
134         implements BrowserListener {
135         public void browserActivated(Browser browser) {
136             refreshMenu(browser);
137         }
138
139         public void browserClosed(Browser browser) {
140             refreshMenu(browser);
141         }
142
143         public void browserClosing(Browser browser) throws VetoException {
144             refreshMenu(browser);
145         }
146
147         public void browserDeactivated(Browser browser) {
148             refreshMenu(browser);
149         }
150
151         public void browserOpened(Browser browser) {
152             refreshMenu(browser);
153         }
154
155         public void browserProjectActivated(Browser browser,
156                                             Project project) {
157             refreshMenu(browser);
158         }
159
160         public void browserProjectClosed(Browser browser, Project project) {
161             refreshMenu(browser);
162         }
163
164         public void browserNodeActivated(Browser browser, Node node) {
165             refreshMenu(browser);
166         }
167
168         public void browserNodeClosed(Browser browser, Node node) {
169             refreshMenu(browser);
170         }
171
172         public void browserViewerActivated(Browser b, Node n, NodeViewer v) {
173             refreshMenu(b);
174         }
175
176         public void browserViewerDeactivating(Browser b, Node n, NodeViewer v)
177                 throws VetoException {
178             refreshMenu(b);
179         }
180
181         private void refreshMenu(Browser b) {
182             Project ap = b.getActiveProject();
183
184             AbstractBasicWizard.enableMenu = (ap != null);
185         }
186
187     }
188
189     /**
190      * Method declaration
191      *
192      *
193      * @param projectClassPath
194      *
195      * @return
196      *
197      * @see
198      */

199     public boolean verifyAllClassPaths(Container JavaDoc owner) {
200         boolean valid = false;
201
202         try {
203            KelpInfo.verifyIDEClassPath();
204            valid = true;
205         } catch (Exception JavaDoc e) {
206            JOptionPane.showMessageDialog(owner,
207                       e.getMessage(),
208                       KelpInfo.getMessageBoxTitle(),
209                       JOptionPane.ERROR_MESSAGE);
210         }
211         if (valid) {
212             valid =
213                 nativeProject.getPaths().putClassOnFullPath(ToolBoxInfo.XMLC_VERSION_CLASS);
214             if (!valid) {
215                 StringBuffer JavaDoc buf = new StringBuffer JavaDoc();
216
217                 buf.append(res.getString("EnhydraLibError1"));
218                 buf.append('\n');
219                 buf.append(res.getString("EnhydraLibError2"));
220                 JOptionPane.showMessageDialog(owner, buf.toString(),
221                                               Constants.KELP,
222                                               JOptionPane.WARNING_MESSAGE);
223             }
224         }
225         return (valid);
226     }
227
228 }
229
Popular Tags