KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > core > EntityDataObject


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19 package org.netbeans.modules.xml.core;
20
21 import org.openide.loaders.*;
22 import org.openide.filesystems.FileObject;
23 import org.openide.util.HelpCtx;
24 import org.openide.actions.EditAction;
25 import org.openide.util.actions.SystemAction;
26 import org.openide.nodes.Node;
27 import org.openide.nodes.Children;
28 import org.openide.nodes.CookieSet;
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.netbeans.spi.xml.cookies.*;
35 import org.xml.sax.InputSource JavaDoc;
36
37 /**
38  * Object that provides main functionality for XML Entity data object.
39  *
40  * @author Libor Kramolis
41  * @version 0.1
42  */

43 public final class EntityDataObject extends MultiDataObject implements XMLDataObjectLook {
44     /** Serial Version UID */
45     private static final long serialVersionUID = 2909112365229995364L;
46     
47     /** Default XML Entity MIME type. */
48     public static final String JavaDoc MIME_TYPE = "text/xml-external-parsed-entity"; // NOI18N
49

50     /** Delegate sync support */
51     private transient Synchronizator synchronizator;
52
53     /** Cookie Manager */
54     private transient final DataObjectCookieManager cookieManager;
55
56     
57     //
58
// init
59
//
60

61     public EntityDataObject (final FileObject obj, final UniFileLoader loader) throws DataObjectExistsException {
62         super (obj, loader);
63
64         CookieSet set = getCookieSet();
65         set.add (cookieManager = new DataObjectCookieManager (this, set));
66         
67         TextEditorSupport.TextEditorSupportFactory editorFactory =
68             new TextEditorSupport.TextEditorSupportFactory (this, MIME_TYPE);
69         editorFactory.registerCookies (set);
70
71 // CookieSet.Factory treeEditorFactory = new TreeEditorCookieImpl.CookieFactoryImpl (this);
72
// set.add (TreeEditorCookie.class, treeEditorFactory);
73

74         // add check cookie
75
InputSource JavaDoc in = DataObjectAdapters.inputSource(this);
76         set.add(new CheckXMLSupport(in, CheckXMLSupport.CHECK_ENTITY_MODE));
77         
78 // new CookieManager (this, set, EntityCookieFactoryCreator.class);
79
}
80
81
82     /**
83      */

84     protected Node createNodeDelegate () {
85         return new EntityDataNode (this);
86     }
87
88
89     /** @return provider of sync interface. */
90     public synchronized Synchronizator getSyncInterface() {
91         if (synchronizator == null) {
92             synchronizator = new EntitySyncSupport (this);
93         
94         }
95         return synchronizator;
96     }
97
98     public DataObjectCookieManager getCookieManager() {
99         return cookieManager;
100     }
101
102     
103     /**
104      */

105     public HelpCtx getHelpCtx() {
106         //return new HelpCtx (EntityDataObject.class);
107
return HelpCtx.DEFAULT_HELP;
108     }
109         
110
111     //
112
// class EntityDataNode
113
//
114

115     /**
116      *
117      */

118     private static class EntityDataNode extends DataNode {
119
120         /** Create new EntityDataNode. */
121         public EntityDataNode (EntityDataObject obj) {
122             super (obj, Children.LEAF);
123
124             setDefaultAction (SystemAction.get (EditAction.class));
125             setIconBase ("org/netbeans/modules/xml/core/resources/entObject"); // NOI18N
126
setShortDescription(Util.THIS.getString("PROP_EntityDataNode_desc"));
127         }
128
129         /**
130          */

131         public HelpCtx getHelpCtx() {
132             //return new HelpCtx (EntityDataObject.class);
133
return HelpCtx.DEFAULT_HELP;
134         }
135         
136     } // end of class EntityDataNode
137

138
139 // //
140
// // interface EntityCookieFactoryCreator
141
// //
142

143 // /**
144
// *
145
// */
146
// public static interface EntityCookieFactoryCreator extends CookieFactoryCreator {
147

148 // } // end: interface EntityCookieFactoryCreator
149

150 }
151
Popular Tags