KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > websphere6 > dd > loaders > webext > WSWebExtDataObject


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

108     
109     public void showElement(Object JavaDoc element) {
110         Object JavaDoc target=null;
111         /*if (element instanceof ResRefBindingsType ||
112                 element instanceof EjbRefBindingsType ||
113                 element instanceof ResEnvRefBindingsType) {
114           */
openView(0);
115             target=element;
116         //}
117
if (target!=null) {
118             final Object JavaDoc key=target;
119             org.netbeans.modules.xml.multiview.Utils.runInAwtDispatchThread(new Runnable JavaDoc() {
120                 public void run() {
121                     getActiveMultiViewElement0().getSectionView().openPanel(key);
122                 }
123             });
124         }
125     }
126     
127 }
128
Popular Tags