KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > websphere6 > dd > loaders > appbnd > WSAppBndDataObject


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.appbnd;
20
21 import java.awt.Image JavaDoc;
22 import java.io.IOException JavaDoc;
23 import org.netbeans.core.spi.multiview.MultiViewElement;
24 import org.netbeans.modules.j2ee.websphere6.dd.beans.WSAppBnd;
25 import org.netbeans.modules.j2ee.websphere6.dd.beans.DDXmi;
26 import org.netbeans.modules.xml.multiview.DesignMultiViewDesc;
27 import org.openide.filesystems.FileObject;
28 import org.openide.filesystems.FileUtil;
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.netbeans.modules.j2ee.websphere6.dd.loaders.WSMultiViewDataObject;
35
36 public class WSAppBndDataObject extends WSMultiViewDataObject {
37     
38     public WSAppBndDataObject(FileObject pf, WSAppBndDataLoader loader) throws DataObjectExistsException, IOException JavaDoc {
39         super(pf, loader);
40     }
41     
42     protected Node createNodeDelegate() {
43         return new WSAppBndDataNode(this);
44     }
45      public DDXmi getDD() throws java.io.IOException JavaDoc {
46         if (ddBaseBean==null) {
47             ddBaseBean = new WSAppBnd(FileUtil.toFile(getPrimaryFile()),false);
48         }
49         return (WSAppBnd)ddBaseBean;
50     }
51     public WSAppBnd getAppBnd() throws java.io.IOException JavaDoc{
52         return (WSAppBnd)getDD();
53     }
54     
55     protected DDXmi createDDXmiFromDataCache() {
56         return new WSAppBnd(getInputStream(), false);
57     }
58     protected DesignMultiViewDesc[] getMultiViewDesc() {
59         designView = new DesignView(this);
60         return new DesignMultiViewDesc[]{designView};
61     }
62     
63     public WSAppBndToolBarMVElement getEBTB() {
64         return ((DesignView)designView).getEBTB();
65     }
66     
67     protected class DesignView extends WSDesignView {
68         private WSAppBndToolBarMVElement ebtb;
69         private static final long serialVersionUID=7209502130942350230L;
70         DesignView(WSAppBndDataObject dObj) {
71             super(dObj);
72         }
73         
74         public org.netbeans.core.spi.multiview.MultiViewElement createElement() {
75             WSAppBndDataObject dObj = (WSAppBndDataObject)getDataObject();
76             ebtb=new WSAppBndToolBarMVElement(dObj);
77             return ebtb;
78         }
79         
80         public String JavaDoc preferredID() {
81             return "appbnd_multiview_design";
82         }
83         public WSAppBndToolBarMVElement getEBTB() {
84             return ebtb;
85             
86         }
87         public java.awt.Image JavaDoc getIcon() {
88             return org.openide.util.Utilities.loadImage("org/netbeans/modules/j2ee/websphere6/dd/resources/ws1.gif"); //NOI18N
89
}
90     }
91     
92     /** Enable to focus specific object in Multiview Editor
93      * The default implementation opens the XML View
94      */

95     
96     public void showElement(Object JavaDoc element) {
97         Object JavaDoc target=null;
98         /*if (element instanceof ResRefBindingsType ||
99                 element instanceof AppRefBindingsType ||
100                 element instanceof ResEnvRefBindingsType) {
101           */
openView(0);
102             target=element;
103         //}
104
if (target!=null) {
105             final Object JavaDoc key=target;
106             org.netbeans.modules.xml.multiview.Utils.runInAwtDispatchThread(new Runnable JavaDoc() {
107                 public void run() {
108                     getActiveMultiViewElement0().getSectionView().openPanel(key);
109                 }
110             });
111         }
112     }
113 }
114
Popular Tags