1 19 package org.netbeans.modules.xml.core; 20 21 import org.openide.filesystems.*; 22 import org.openide.loaders.*; 23 import org.openide.cookies.*; 24 import org.openide.actions.*; 25 import org.openide.util.*; 26 import org.openide.util.actions.*; 27 import org.openide.nodes.*; 28 import org.openide.windows.CloneableOpenSupport; 29 30 import org.netbeans.modules.xml.core.text.TextEditorSupport; 31 import org.netbeans.modules.xml.core.sync.*; 32 import org.netbeans.modules.xml.core.cookies.*; 33 34 import org.xml.sax.*; 35 36 import org.netbeans.spi.xml.cookies.*; 37 import org.xml.sax.InputSource ; 38 39 45 public final class DTDDataObject extends MultiDataObject implements XMLDataObjectLook { 46 47 48 private static final long serialVersionUID = 2890472952957502631L; 49 50 51 public static final String MIME_TYPE = "application/xml-dtd"; 53 54 private final DTDSyncSupport sync; 55 56 57 private final DataObjectCookieManager cookieManager; 58 59 60 64 public DTDDataObject (final FileObject obj, final UniFileLoader loader) throws DataObjectExistsException { 65 super (obj, loader); 66 67 69 CookieSet set = getCookieSet(); 70 set.add (cookieManager = new DataObjectCookieManager (this, set)); 71 72 sync = new DTDSyncSupport(this); 73 74 TextEditorSupport.TextEditorSupportFactory editorFactory = 75 TextEditorSupport.findEditorSupportFactory (this, MIME_TYPE); 76 editorFactory.registerCookies (set); 77 78 InputSource in = DataObjectAdapters.inputSource(this); 79 set.add(new CheckXMLSupport(in, CheckXMLSupport.CHECK_PARAMETER_ENTITY_MODE)); 80 81 new CookieManager (this, set, DTDCookieFactoryCreator.class); 83 } 84 85 93 94 96 protected Node createNodeDelegate () { 97 if ( Util.THIS.isLoggable() ) Util.THIS.debug ("--> DTDDataObject.createNodeDelegate: this = " + this); 98 99 DataNodeCreator dataNodeCreator = (DataNodeCreator) Lookup.getDefault().lookup (DataNodeCreator.class); 100 DataNode dataNode = null; 101 102 if ( Util.THIS.isLoggable() ) Util.THIS.debug ("-*- DTDD O .createNodeDelegate: dataNodeCreator = " + dataNodeCreator); 103 104 if ( dataNodeCreator != null ) { 105 dataNode = dataNodeCreator.createDataNode (this); 106 } else { 107 dataNode = new DTDDataNode (this); 108 } 109 110 if ( Util.THIS.isLoggable() ) Util.THIS.debug ("<-- DTDDataObject.createNodeDelegate: dataNode = " + dataNode); 111 112 return dataNode; 113 } 114 115 116 public Synchronizator getSyncInterface() { 117 return sync; 118 } 119 120 122 123 124 public Node.Cookie getCookie(Class klass) { 125 126 Node.Cookie cake = null; 127 boolean change = false; 128 129 synchronized (this) { 132 cake = super.getCookie (klass); 133 134 if ( ( cake == null ) && 135 ( CloneableOpenSupport.class == klass ) ) { cake = super.getCookie (OpenCookie.class); 137 } 138 } 139 140 if ( Util.THIS.isLoggable() ) Util.THIS.debug ("DTD cookie query " + klass + " => " + cake); 142 return cake; 143 } 144 145 146 public DataObjectCookieManager getCookieManager () { 147 return cookieManager; 148 } 149 150 151 public HelpCtx getHelpCtx() { 152 return HelpCtx.DEFAULT_HELP; 154 } 155 156 157 161 164 private static class DTDDataNode extends DataNode { 165 166 167 public DTDDataNode (DTDDataObject obj) { 168 super (obj, Children.LEAF); 169 170 setDefaultAction (SystemAction.get (EditAction.class)); 171 setIconBase ("org/netbeans/modules/xml/core/resources/dtdObject"); setShortDescription (Util.THIS.getString ("PROP_DTDDataNode_description")); 173 } 174 175 public HelpCtx getHelpCtx() { 176 return HelpCtx.DEFAULT_HELP; 178 } 179 180 } 182 183 184 188 191 public static interface DataNodeCreator { 192 193 195 public DataNode createDataNode (DTDDataObject dtdDO); 196 197 } 199 200 201 205 208 public static interface DTDCookieFactoryCreator extends CookieFactoryCreator { 209 210 } 212 } 213 | Popular Tags |