KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > websphere6 > dd > loaders > appext > WSAppExtDataObject


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

93     
94     public void showElement(Object JavaDoc element) {
95         Object JavaDoc target=null;
96         openView(0);
97         target=element;
98         if (target!=null) {
99             final Object JavaDoc key=target;
100             org.netbeans.modules.xml.multiview.Utils.runInAwtDispatchThread(new Runnable JavaDoc() {
101                 public void run() {
102                     getActiveMultiViewElement0().getSectionView().openPanel(key);
103                 }
104             });
105         }
106     }
107 }
108
Popular Tags