KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > schema > SchemaObject


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.schema;
20
21 import javax.xml.transform.Source JavaDoc;
22
23 import org.openide.loaders.*;
24 import org.openide.filesystems.FileObject;
25 import org.openide.util.HelpCtx;
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.XMLDataObjectLook;
31 import org.netbeans.modules.xml.core.text.TextEditorSupport;
32 import org.netbeans.modules.xml.core.sync.*;
33 import org.netbeans.modules.xml.core.cookies.*;
34
35 import org.netbeans.spi.xml.cookies.*;
36 import org.netbeans.modules.xml.schema.cookies.*;
37 import org.xml.sax.InputSource JavaDoc;
38
39 /**
40  * XML Schema owner. It provides text editing and validation cookies
41  * support.
42  *
43  * @author Petr Kuzel
44  */

45 public final class SchemaObject extends MultiDataObject implements XMLDataObjectLook {
46
47     /** Serial Version UID */
48     private static final long serialVersionUID = 290911236522999000L;
49
50     private static final String JavaDoc SCHEMA_ICON_BASE =
51         "org/netbeans/modules/xml/schema/resources/xmlSchemaObject.gif"; // NOI18N
52

53     private transient final DataObjectCookieManager cookieManager;
54
55     private transient Synchronizator synchronizator;
56     
57     //
58
// init
59
//
60

61     public SchemaObject(final FileObject obj, final UniFileLoader loader) throws DataObjectExistsException {
62         super (obj, loader);
63
64         CookieSet set = getCookieSet();
65         cookieManager = new DataObjectCookieManager (this, set);
66         set.add (cookieManager);
67     
68         // editor support defines MIME type understood by EditorKits registry
69
TextEditorSupport.TextEditorSupportFactory editorFactory =
70             new TextEditorSupport.TextEditorSupportFactory (this, org.netbeans.modules.xml.core.XMLDataObject.MIME_TYPE);
71         editorFactory.registerCookies (set);
72
73         // add check and validate cookies
74
InputSource JavaDoc is = DataObjectAdapters.inputSource(this);
75         set.add(new CheckXMLSupport(is));
76         set.add(new ValidateSchemaSupport(is));
77         
78         // add TransformableCookie
79
Source JavaDoc source = DataObjectAdapters.source(this);
80         set.add (new TransformableSupport (source));
81     }
82
83
84     /**
85      */

86     protected Node createNodeDelegate () {
87         return new SchemaNode (this);
88     }
89
90     
91     /**
92      */

93     public HelpCtx getHelpCtx() {
94         //return new HelpCtx (SchemaObject.class);
95
return HelpCtx.DEFAULT_HELP;
96     }
97
98     // XMLDataObjectLook to be deprecated ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
99

100     public DataObjectCookieManager getCookieManager() {
101         return cookieManager;
102     }
103
104     public synchronized Synchronizator getSyncInterface() {
105         if (synchronizator == null) {
106             synchronizator = new DataObjectSyncSupport(SchemaObject.this);
107         }
108         return synchronizator;
109     }
110     
111     /**
112      * Redefine icon and help.
113      */

114     private static class SchemaNode extends DataNode {
115
116         /** Create new EntityDataNode. */
117         public SchemaNode (SchemaObject obj) {
118             super (obj, Children.LEAF);
119             setIconBaseWithExtension( SCHEMA_ICON_BASE);
120             setShortDescription( Util.THIS.getString("PROP_SchemaNode_desc"));
121         }
122
123         /**
124          */

125         public HelpCtx getHelpCtx() {
126             //return new HelpCtx (SchemaObject.class);
127
return HelpCtx.DEFAULT_HELP;
128         }
129         
130     }
131
132 }
133
Popular Tags