1 23 package org.enhydra.kelp.jbuilder.tool; 24 25 import org.enhydra.tool.ToolBoxInfo; 27 import org.enhydra.tool.common.event.HelpEvent; 28 import org.enhydra.tool.common.event.HelpListener; 29 30 import org.enhydra.xml.xmlc.XMLCException; 32 33 import com.borland.jbuilder.JBuilderHelp; 35 import com.borland.jbuilder.JBuilderMenu; 36 import com.borland.jbuilder.node.JBProject; 37 import com.borland.primetime.actions.ActionGroup; 38 import com.borland.primetime.help.ZipHelpBook; 39 import com.borland.primetime.help.ZipHelpTopic; 40 import com.borland.primetime.ide.Browser; 41 import com.borland.primetime.ide.BrowserAction; 42 import com.borland.primetime.node.Project; 43 import com.borland.primetime.wizard.WizardHost; 44 import com.borland.primetime.wizard.WizardPage; 45 46 import org.enhydra.kelp.KelpInfo; 48 import org.enhydra.kelp.common.Constants; 49 import org.enhydra.kelp.common.node.OtterNode; 50 import org.enhydra.kelp.jbuilder.node.PrimeProject; 51 52 import javax.swing.Action ; 54 import javax.swing.JDialog ; 55 import javax.swing.JOptionPane ; 56 import java.awt.Component ; 57 import java.awt.Container ; 58 import java.util.ResourceBundle ; 59 60 abstract public class AbstractBasicTool extends BrowserAction 62 implements HelpListener { 63 private static boolean init = true; 64 65 public static ResourceBundle res = 67 ResourceBundle.getBundle("org.enhydra.kelp.jbuilder.Res"); 69 private JBProject nativeProject = null; 71 72 public static void initAllTools(byte majorVersion, byte minorVersion) { 74 if (AbstractBasicTool.init) { 75 ActionGroup group; 76 77 if (majorVersion != 4) { 79 return; 80 } 81 82 System.out.println("Initializing Kelp Tools"); 84 85 group = new ActionGroup(); 87 group.add(new DodsTool()); 88 group.add(new XMLCTool()); 89 group.add(new DeployTool()); 90 JBuilderMenu.GROUP_Tools.add(group); 91 init = false; 92 } 93 } 94 95 abstract public String getDescription(); 97 abstract public String getTitle(); 98 abstract public String getHelpAnchor(); 99 100 public void onHelp(HelpEvent event) { 102 ZipHelpTopic topic = null; 103 ZipHelpBook book = null; 104 Object source = null; 105 106 source = event.getSource(); 107 book = JBuilderHelp.createBook(Constants.KELP); 108 topic = new ZipHelpTopic(book, getHelpAnchor()); 109 if (source instanceof JDialog ) { 110 topic.show((JDialog ) source); 111 } else if (source instanceof Component ) { 112 topic.show((Component ) source); 113 } else { 114 topic.show(); 115 } 116 } 117 118 public boolean isEnabled() { 120 return (Browser.getActiveBrowser().getActiveProject() != null); 121 } 122 123 public Object getValue(String key) { 125 if (key.equals(Action.NAME)) { 126 return getTitle(); 127 } else if (key.equals(Action.SHORT_DESCRIPTION)) { 128 return getTitle(); 129 } else if (key.equals(Action.LONG_DESCRIPTION)) { 130 return getDescription(); 131 } 132 return (super.getValue(key)); 133 } 134 135 public JBProject getNativeProject() { 136 return nativeProject; 137 } 138 139 public void setNativeProject(JBProject p) { 140 nativeProject = p; 141 } 142 143 public void saveNodes(OtterNode[] nodes) { 144 if (nodes != null) { 145 for (int i = 0; i < nodes.length; i++) { 146 nodes[i].save(); 147 } 148 } 149 } 150 151 public boolean verifyAllClassPaths(Container owner) { 152 boolean valid = false; 153 154 try { 155 KelpInfo.verifyIDEClassPath(); 156 valid = true; 157 } catch (Exception e) { 158 JOptionPane.showMessageDialog(owner, e.getMessage(), 159 KelpInfo.getMessageBoxTitle(), 160 JOptionPane.WARNING_MESSAGE); 161 } 162 if (valid) { 163 valid = 164 nativeProject.getPaths().putClassOnFullPath(ToolBoxInfo.XMLC_VERSION_CLASS); 165 if (!valid) { 166 StringBuffer buf = new StringBuffer (); 167 168 buf.append(res.getString("EnhydraLibError1")); 169 buf.append('\n'); 170 buf.append(res.getString("EnhydraLibError2")); 171 JOptionPane.showMessageDialog(owner, buf.toString(), 172 KelpInfo.getMessageBoxTitle(), 173 JOptionPane.WARNING_MESSAGE); 174 } 175 } 176 return (valid); 177 } 178 179 } 180 | Popular Tags |