KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > websphere6 > dd > loaders > ejbbnd > WSEjbBndDataObject


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

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