1 19 package org.netbeans.modules.xml.tools.generator; 20 21 import java.util.*; 22 import java.beans.*; 23 24 import org.openide.nodes.Node; 25 import org.openide.util.HelpCtx; 26 import org.openide.util.actions.CookieAction; 27 import org.openide.util.RequestProcessor; 28 29 import org.netbeans.modules.xml.core.actions.CollectXMLAction; 30 import org.netbeans.modules.xml.core.actions.CollectDTDAction; 31 32 import org.netbeans.modules.xml.core.lib.GuiUtil; 33 34 public abstract class XMLGenerateAction extends CookieAction { 35 36 37 protected static final long serialVersionUID = -6614874187800576344L; 38 39 40 protected int mode() { 41 return MODE_ALL; 42 } 43 44 48 public abstract String getName(); 49 50 protected Class [] cookieClasses () { 51 return new Class [] { getOwnCookieClass() }; 52 } 53 54 protected Class getOwnCookieClass () { 55 return XMLGenerateCookie.class; 56 } 57 58 protected boolean asynchronous() { 59 return false; 60 } 61 62 65 protected void performAction (final Node[] activatedNodes) { 66 try { 67 for (int i = 0; i < activatedNodes.length; i++) { 68 Class cake = getOwnCookieClass(); 69 XMLGenerateCookie gc = (XMLGenerateCookie)activatedNodes[i].getCookie (cake); 70 if (gc != null) { 71 gc.generate (); 72 } else { 73 throw new IllegalStateException ("Missing cookie " + cake); 74 } 75 } 76 } catch (RuntimeException ex) { 77 String msg = Util.THIS.getString("MSG_action_failed"); GuiUtil.notifyException(msg, ex); 79 } 80 } 81 82 83 public static class GenerateDTDAction extends XMLGenerateAction implements CollectXMLAction.XMLAction { 86 87 private static final long serialVersionUID = 8532990650127561962L; 88 89 93 public String getName () { 94 return Util.THIS.getString ("PROP_GenerateDTD"); 95 } 96 97 100 public HelpCtx getHelpCtx () { 101 return new HelpCtx (GenerateDTDAction.class); 102 } 103 104 protected Class getOwnCookieClass () { 105 return GenerateDTDSupport.class; 106 } 107 } 109 public static class GenerateDocumentHandlerAction extends XMLGenerateAction implements CollectDTDAction.DTDAction { 112 113 private static final long serialVersionUID = 1342753912956042368L; 114 115 119 public String getName () { 120 return Util.THIS.getString ("PROP_GenerateSAXHandler"); 121 } 122 123 126 public HelpCtx getHelpCtx () { 127 return new HelpCtx (GenerateDocumentHandlerAction.class); 128 } 129 130 protected Class getOwnCookieClass () { 131 return SAXGeneratorSupport.class; 132 } 133 } 135 public static class GenerateDOMScannerAction extends XMLGenerateAction implements CollectDTDAction.DTDAction { 138 139 private static final long serialVersionUID = 2567846356902367312L; 140 141 145 public String getName () { 146 return Util.THIS.getString ("PROP_GenerateDOMScanner"); 147 } 148 149 152 public HelpCtx getHelpCtx () { 153 return new HelpCtx (GenerateDOMScannerAction.class); 154 } 155 156 protected Class getOwnCookieClass () { 157 return GenerateDOMScannerSupport.class; 158 } 159 } } 161 | Popular Tags |