KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > websphere6 > dd > loaders > webbnd > WSWebBndDataObject


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.j2ee.websphere6.dd.loaders.webbnd;
20
21 import org.netbeans.api.xml.cookies.CheckXMLCookie;
22 import org.netbeans.api.xml.cookies.ValidateXMLCookie;
23 import org.netbeans.modules.j2ee.websphere6.dd.beans.EjbRefBindingsType;
24 import org.netbeans.modules.j2ee.websphere6.dd.beans.ResEnvRefBindingsType;
25 import org.netbeans.modules.j2ee.websphere6.dd.beans.ResRefBindingsType;
26 import org.netbeans.modules.j2ee.websphere6.dd.loaders.DDUtils;
27 import org.netbeans.modules.xml.multiview.*;
28 import org.netbeans.modules.schema2beans.*;
29 import java.io.IOException JavaDoc;
30 import org.openide.filesystems.FileObject;
31 import org.openide.loaders.DataObjectExistsException;
32 import org.openide.loaders.MultiDataObject;
33 import org.openide.nodes.CookieSet;
34 import org.openide.nodes.Node;
35 import org.openide.text.DataEditorSupport;
36 import org.netbeans.modules.j2ee.websphere6.dd.beans.WSWebBnd;
37 import org.netbeans.modules.j2ee.websphere6.dd.beans.DDXmi;
38 import org.netbeans.modules.j2ee.websphere6.dd.loaders.WSMultiViewDataObject;
39 import org.netbeans.spi.xml.cookies.*;
40 import org.openide.filesystems.FileObject;
41 import org.openide.filesystems.FileUtil;
42 import java.nio.channels.FileLock JavaDoc;
43 import org.openide.ErrorManager;
44 import java.io.StringWriter JavaDoc;
45 import java.io.Writer JavaDoc;
46 import javax.xml.parsers.*;
47 import org.xml.sax.*;
48
49 public class WSWebBndDataObject extends WSMultiViewDataObject /*MultiDataObject*/
50         /*implements PropertyChangeListener */{
51     
52     
53     public static final String JavaDoc WEBBND_DATA_MULTIVIEW_PREFIX="webbnd_data";
54     public static final String JavaDoc WEBBND_MULTIVIEW_ATTR="attr";
55     
56     public WSWebBndDataObject(FileObject pf, WSWebBndDataLoader loader) throws DataObjectExistsException, IOException JavaDoc {
57         super(pf, loader);
58     }
59     
60     protected Node createNodeDelegate() {
61         return new WSWebBndDataNode(this);
62     }
63     
64     public WSWebBnd getWebBnd() throws java.io.IOException JavaDoc{
65         return (WSWebBnd)getDD();
66     }
67     
68     public DDXmi getDD() throws java.io.IOException JavaDoc {
69         if (ddBaseBean==null) {
70             ddBaseBean = new WSWebBnd(FileUtil.toFile(getPrimaryFile()),false);
71         }
72         return (WSWebBnd)ddBaseBean;
73     }
74
75     protected DDXmi createDDXmiFromDataCache() {
76         return new WSWebBnd(getInputStream(), false);
77     }
78     
79     protected DesignMultiViewDesc[] getMultiViewDesc() {
80         designView = new DesignView(this);
81         return new DesignMultiViewDesc[]{designView};
82     }
83     
84     
85     
86     public WSWebBndToolBarMVElement getWBTB() {
87         return ((DesignView)designView).getWBTB();
88     }
89     
90     protected class DesignView extends WSDesignView {
91         private WSWebBndToolBarMVElement wbtb;
92         private static final long serialVersionUID=7209572130942350230L;
93         DesignView(WSWebBndDataObject dObj) {
94             super(dObj);
95         }
96         
97         public org.netbeans.core.spi.multiview.MultiViewElement createElement() {
98             WSWebBndDataObject dObj = (WSWebBndDataObject)getDataObject();
99             wbtb=new WSWebBndToolBarMVElement(dObj);
100             return wbtb;
101         }
102         
103         public String JavaDoc preferredID() {
104             return "webbnd_multiview_design";
105         }
106         public WSWebBndToolBarMVElement getWBTB() {
107             return wbtb;
108         }
109         public java.awt.Image JavaDoc getIcon() {
110             return org.openide.util.Utilities.loadImage("org/netbeans/modules/j2ee/websphere6/dd/resources/ws5.gif"); //NOI18N
111
}
112     }
113     
114     /** Enable to focus specific object in Multiview Editor
115      * The default implementation opens the XML View
116      */

117     
118     public void showElement(Object JavaDoc element) {
119         Object JavaDoc target=null;
120         if (element instanceof ResRefBindingsType ||
121                 element instanceof EjbRefBindingsType ||
122                 element instanceof ResEnvRefBindingsType) {
123             openView(0);
124             target=element;
125         }
126         if (target!=null) {
127             final Object JavaDoc key=target;
128             org.netbeans.modules.xml.multiview.Utils.runInAwtDispatchThread(new Runnable JavaDoc() {
129                 public void run() {
130                     getActiveMultiViewElement0().getSectionView().openPanel(key);
131                 }
132             });
133         }
134     }
135     
136     
137     
138     
139 }
140
Popular Tags