001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041: package org.netbeans.modules.xml;
042:
043: import org.openide.loaders.*;
044: import org.openide.filesystems.FileObject;
045: import org.openide.util.HelpCtx;
046: import org.openide.actions.EditAction;
047: import org.openide.util.actions.SystemAction;
048: import org.openide.nodes.Node;
049: import org.openide.nodes.Children;
050: import org.openide.nodes.CookieSet;
051:
052: import org.netbeans.modules.xml.text.TextEditorSupport;
053: import org.netbeans.modules.xml.sync.*;
054: import org.netbeans.modules.xml.cookies.*;
055:
056: import org.netbeans.spi.xml.cookies.*;
057: import org.xml.sax.InputSource;
058:
059: /**
060: * Object that provides main functionality for XML Entity data object.
061: *
062: * @author Libor Kramolis
063: * @version 0.1
064: */
065: public final class EntityDataObject extends MultiDataObject implements
066: XMLDataObjectLook {
067: /** Serial Version UID */
068: private static final long serialVersionUID = 2909112365229995364L;
069:
070: /** Default XML Entity MIME type. */
071: public static final String MIME_TYPE = "text/xml-external-parsed-entity"; // NOI18N
072:
073: /** Delegate sync support */
074: private transient Synchronizator synchronizator;
075:
076: /** Cookie Manager */
077: private transient final DataObjectCookieManager cookieManager;
078:
079: //
080: // init
081: //
082:
083: public EntityDataObject(final FileObject obj,
084: final UniFileLoader loader)
085: throws DataObjectExistsException {
086: super (obj, loader);
087:
088: CookieSet set = getCookieSet();
089: set.add(cookieManager = new DataObjectCookieManager(this , set));
090:
091: TextEditorSupport.TextEditorSupportFactory editorFactory = new TextEditorSupport.TextEditorSupportFactory(
092: this , MIME_TYPE);
093: editorFactory.registerCookies(set);
094:
095: // CookieSet.Factory treeEditorFactory = new TreeEditorCookieImpl.CookieFactoryImpl (this);
096: // set.add (TreeEditorCookie.class, treeEditorFactory);
097:
098: // add check cookie
099: InputSource in = DataObjectAdapters.inputSource(this );
100: set.add(new CheckXMLSupport(in,
101: CheckXMLSupport.CHECK_ENTITY_MODE));
102:
103: // new CookieManager (this, set, EntityCookieFactoryCreator.class);
104: }
105:
106: /**
107: */
108: protected Node createNodeDelegate() {
109: return new EntityDataNode(this );
110: }
111:
112: /** @return provider of sync interface. */
113: public synchronized Synchronizator getSyncInterface() {
114: if (synchronizator == null) {
115: synchronizator = new EntitySyncSupport(this );
116:
117: }
118: return synchronizator;
119: }
120:
121: public DataObjectCookieManager getCookieManager() {
122: return cookieManager;
123: }
124:
125: /**
126: */
127: public HelpCtx getHelpCtx() {
128: //return new HelpCtx (EntityDataObject.class);
129: return HelpCtx.DEFAULT_HELP;
130: }
131:
132: //
133: // class EntityDataNode
134: //
135:
136: /**
137: *
138: */
139: private static class EntityDataNode extends DataNode {
140:
141: /** Create new EntityDataNode. */
142: public EntityDataNode(EntityDataObject obj) {
143: super (obj, Children.LEAF);
144:
145: setDefaultAction(SystemAction.get(EditAction.class));
146: setIconBase("org/netbeans/modules/xml/resources/entObject"); // NOI18N
147: setShortDescription(Util.THIS
148: .getString("PROP_EntityDataNode_desc"));
149: }
150:
151: /**
152: */
153: public HelpCtx getHelpCtx() {
154: //return new HelpCtx (EntityDataObject.class);
155: return HelpCtx.DEFAULT_HELP;
156: }
157:
158: } // end of class EntityDataNode
159:
160: // //
161: // // interface EntityCookieFactoryCreator
162: // //
163:
164: // /**
165: // *
166: // */
167: // public static interface EntityCookieFactoryCreator extends CookieFactoryCreator {
168:
169: // } // end: interface EntityCookieFactoryCreator
170:
171: }
|