KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > websvc > wsdl > WsdlDataObject


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
20 package org.netbeans.modules.websvc.wsdl;
21
22 import org.netbeans.api.xml.cookies.CheckXMLCookie;
23 import org.netbeans.spi.xml.cookies.CheckXMLSupport;
24 import org.netbeans.spi.xml.cookies.DataObjectAdapters;
25 //import org.netbeans.api.xml.cookies.ValidateXMLCookie;
26
import org.openide.cookies.SaveCookie;
27 import org.openide.loaders.MultiDataObject;
28 import org.openide.nodes.CookieSet;
29 import org.openide.nodes.Node;
30 import org.openide.loaders.MultiFileLoader;
31 import org.openide.loaders.DataObjectExistsException;
32 import org.openide.filesystems.FileObject;
33
34
35 import org.xml.sax.InputSource JavaDoc;
36
37
38 /** Loader for Wsdl DataObjects.
39  *
40  * @author Peter Williams
41  */

42 public class WsdlDataObject extends MultiDataObject implements CookieSet.Factory {
43     private static final long serialVersionUID = 1871655333534008660L;
44     public static final String JavaDoc WSDL_EXTENSION = "wsdl"; // NOI18N
45
protected WsdlEditorSupport editor;
46     
47     // If isClientWsdl is true, the WSDL file is in the WSDL folder of a web service
48
// client enabled module and thus will have operations and UI exposed that affect
49
// the service as it exists within the project. E.g. deleting such a file will
50
// actually remove the service from the project, not just delete the file on disk.
51
private boolean clientResolved, isClientWsdl;
52     
53     /** Typical data object constructor.
54      */

55     public WsdlDataObject(FileObject pf, MultiFileLoader loader) throws DataObjectExistsException {
56         super(pf, loader);
57         init();
58     }
59     
60     private void init() {
61         //ValidateXMLCookie validateCookie = new ValidateXMLCookieImpl(this);
62
//getCookieSet().add(validateCookie);
63
getCookieSet().add(WsdlEditorSupport.class, this);
64          // added CheckXMLCookie
65
InputSource JavaDoc in = DataObjectAdapters.inputSource(this);
66         CheckXMLCookie checkCookie = new CheckXMLSupport(in);
67         getCookieSet().add(checkCookie);
68     }
69     
70     /** Implements <code>CookieSet.Factory</code> interface. */
71     public org.openide.nodes.Node.Cookie createCookie(Class JavaDoc clazz) {
72         if(clazz.isAssignableFrom(WsdlEditorSupport.class))
73             return getEditorSupport();
74         else
75             return null;
76     }
77
78     /** Gets editor support for this data object. */
79     protected synchronized WsdlEditorSupport getEditorSupport() {
80         if(editor == null) {
81             editor = new WsdlEditorSupport(this);
82         }
83         return editor;
84     }
85     
86     public boolean isRenameAllowed() {
87         return true;
88     }
89     
90     public boolean isDeleteAllowed() {
91         return true;
92     }
93        
94     /** Create a node to represent the WSDL file. Overrides superclass method.
95      * @return node delegate */

96     protected Node createNodeDelegate() {
97         return new WsdlDataNode(this);
98     }
99     
100     public void addSaveCookie(SaveCookie cookie){
101         getCookieSet().add(cookie);
102     }
103     
104     public void removeSaveCookie(){
105         org.openide.nodes.Node.Cookie cookie = getCookie(SaveCookie.class);
106         if (cookie!=null) getCookieSet().remove(cookie);
107     }
108 }
109
Popular Tags