1 23 package org.enhydra.kelp.forte.actions; 24 25 import org.openide.nodes.Node; 26 import org.openide.TopManager; 27 import org.openide.util.HelpCtx; 28 import org.openide.util.NbBundle; 29 import org.openide.util.actions.CallableSystemAction; 30 import org.openide.util.actions.SystemAction; 31 import org.openide.loaders.DataFolder; 32 import org.openide.loaders.DataObject; 33 import org.openide.src.ClassElement; 34 import org.openide.DialogDescriptor; 35 import org.openide.filesystems.FileSystem; 36 import org.openide.filesystems.FileObject; 37 38 import org.enhydra.tool.common.SwingUtil; 40 import org.enhydra.tool.common.event.HelpEvent; 41 import org.enhydra.tool.common.event.HelpListener; 42 43 import org.enhydra.kelp.KelpInfo; 45 import org.enhydra.kelp.common.xmlc.XMLCButtonListener; 46 import org.enhydra.kelp.common.xmlc.XMLCButtonPanel; 47 import org.enhydra.kelp.common.xmlc.CoreXMLCTool; 48 import org.enhydra.kelp.common.node.OtterDocumentNode; 49 50 import org.enhydra.kelp.forte.node.ForteProject; 52 import org.enhydra.kelp.forte.XMLCSettings; 53 54 import java.awt.Dialog ; 55 import java.awt.Frame ; 56 import java.awt.event.ActionListener ; 57 import java.awt.event.ActionEvent ; 58 import java.net.URL ; 59 import java.net.MalformedURLException ; 60 import java.io.File ; 61 import java.util.Enumeration ; 62 63 import org.enhydra.kelp.common.node.OtterProject; 65 66 71 public class XMLCAction extends CallableSystemAction implements HelpListener { 72 private static String anchor = "xmlcwizard"; 73 74 public void onHelp(HelpEvent event) { 76 URL url = null; 77 String [] home = new String [2]; 78 home[0] = System.getProperty("netbeans.home"); 79 home[1] = System.getProperty("netbeans.user"); 80 StringBuffer buf = new StringBuffer (); 81 buf.append(KelpInfo.getAddinHelpURL(home)); 82 buf.append('#').append(anchor); 83 try { 84 url = new URL (buf.toString()); 85 TopManager.getDefault().showUrl(url); 86 } catch (MalformedURLException e) { 87 e.printStackTrace(System.err); 88 } 89 } 90 91 92 public void performAction() { 93 String [] options = XMLCButtonPanel.getOptions(); 94 CoreXMLCTool tool = new CoreXMLCTool(); 95 XMLCButtonListener listener = new XMLCButtonListener(tool); 96 DialogDescriptor dscr = new DialogDescriptor(tool.getInnerPanel(), 97 tool.getTitle(), true, options, options[0], 98 DialogDescriptor.BOTTOM_ALIGN, HelpCtx.DEFAULT_HELP, 99 listener); 100 Dialog dlg = TopManager.getDefault().createDialog(dscr); 101 tool.setProject(new ForteProject()); 102 tool.addHelpListener(this); 103 dlg.show(); 104 105 ForteProject project = new ForteProject(); 107 String src = XMLCSettings.getDefault().getSource(); 108 if ((src != null) && (src.length() > 0)) 109 { 110 FileObject source = project.getRootFolder().getFileObject(src); 111 source.refresh(); 112 Enumeration kids = source.getChildren(true); 113 while (kids.hasMoreElements()) 114 ((FileObject)kids.nextElement()).refresh(); } 116 117 118 } 119 120 public boolean isEnabled() 121 { 122 ForteProject project = new ForteProject(); 123 if (project.getRootFolder() == null) 124 return false; 126 OtterDocumentNode[] nodes = project.getAllDocuments(); 127 return ((nodes != null) && (nodes.length > 0)); 128 } 129 130 public String getName() { 131 return CoreXMLCTool.getDefaultTitle(); 132 } 133 134 protected String iconResource() { 135 return "smallicon.gif"; 136 } 137 138 public HelpCtx getHelpCtx() { 139 return HelpCtx.DEFAULT_HELP; 140 } 143 144 148 protected void initialize() { 149 super.initialize(); 151 putProperty(javax.swing.Action.SHORT_DESCRIPTION, 152 NbBundle.getMessage(XMLCAction.class, 153 "HINT_XMLC_Action")); 154 } 155 156 } 157 | Popular Tags |