KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xsl > XSLDataObject


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.xsl;
20
21 import org.xml.sax.InputSource JavaDoc;
22 import javax.xml.transform.Source JavaDoc;
23
24 import org.openide.loaders.*;
25 import org.openide.filesystems.FileObject;
26 import org.openide.util.HelpCtx;
27 import org.openide.nodes.Node;
28 import org.openide.nodes.Children;
29 import org.openide.nodes.CookieSet;
30
31 import org.netbeans.spi.xml.cookies.*;
32
33 import org.netbeans.modules.xml.core.XMLDataObjectLook;
34 import org.netbeans.modules.xml.core.text.TextEditorSupport;
35 import org.netbeans.modules.xml.core.sync.*;
36 import org.netbeans.modules.xml.core.cookies.*;
37 import org.netbeans.modules.xsl.cookies.ValidateXSLSupport;
38
39 /**
40  * XSL owner.
41  *
42  * @author Libor Kramolis
43  * @author asgeir@dimonsoftware.com
44  */

45 public final class XSLDataObject extends MultiDataObject implements XMLDataObjectLook {
46     /** Serial Version UID */
47     private static final long serialVersionUID = -3523066651187749549L;
48
49     /** XSLT Mime Type. */
50     public static final String JavaDoc MIME_TYPE = "application/xslt+xml"; // NOI18N
51

52     private static final String JavaDoc XSL_ICON_BASE =
53         "org/netbeans/modules/xsl/resources/xslObject"; // NOI18N
54

55     private transient final DataObjectCookieManager cookieManager;
56
57     private transient Synchronizator synchronizator;
58     
59     
60     //
61
// init
62
//
63

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

93     protected Node createNodeDelegate () {
94         return new XSLDataNode (this);
95     }
96
97     
98     /**
99      */

100     public HelpCtx getHelpCtx() {
101         //return new HelpCtx (XSLDataObject.class);
102
return HelpCtx.DEFAULT_HELP;
103     }
104     
105     // XMLDataObjectLook to be deprecated ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
106

107     public DataObjectCookieManager getCookieManager() {
108         return cookieManager;
109     }
110
111     public synchronized Synchronizator getSyncInterface() {
112         if (synchronizator == null) {
113             synchronizator = new DataObjectSyncSupport (XSLDataObject.this);
114         }
115         return synchronizator;
116     }
117     
118     /**
119      * Redefine icon and help.
120      */

121     private static class XSLDataNode extends DataNode {
122
123         /** Create new XSLDataNode. */
124         public XSLDataNode (XSLDataObject obj) {
125             super (obj, Children.LEAF);
126             setIconBase (XSL_ICON_BASE);
127             setShortDescription(Util.THIS.getString("PROP_XSLDataNode_desc"));
128         }
129
130         /**
131          */

132         public HelpCtx getHelpCtx() {
133             //return new HelpCtx (XSLDataObject.class);
134
return HelpCtx.DEFAULT_HELP;
135         }
136         
137     }
138
139 }
140
Popular Tags