1 22 package org.enhydra.kelp.jbuilder.wizard; 23 24 import org.enhydra.tool.ToolBoxInfo; 26 27 import org.enhydra.xml.xmlc.XMLCException; 29 30 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 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 import javax.swing.JOptionPane ; 58 import java.awt.Container ; 59 import java.io.File ; 60 import java.util.ResourceBundle ; 61 62 68 abstract public class AbstractBasicWizard extends BasicWizard { 69 static ResourceBundle res = 70 ResourceBundle.getBundle("org.enhydra.kelp.jbuilder.Res"); 72 private JBProject nativeProject = null; 74 75 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 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 119 protected void finish() throws VetoException {} 120 121 129 public static String 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 199 public boolean verifyAllClassPaths(Container owner) { 200 boolean valid = false; 201 202 try { 203 KelpInfo.verifyIDEClassPath(); 204 valid = true; 205 } catch (Exception 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 buf = new StringBuffer (); 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 |