001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041: package org.netbeans.modules.j2ee.websphere6.dd.loaders.appbnd;
042:
043: import java.awt.Image;
044: import java.io.IOException;
045: import org.netbeans.core.spi.multiview.MultiViewElement;
046: import org.netbeans.modules.j2ee.websphere6.dd.beans.WSAppBnd;
047: import org.netbeans.modules.j2ee.websphere6.dd.beans.DDXmi;
048: import org.netbeans.modules.xml.multiview.DesignMultiViewDesc;
049: import org.openide.filesystems.FileObject;
050: import org.openide.filesystems.FileUtil;
051: import org.openide.loaders.DataObjectExistsException;
052: import org.openide.loaders.MultiDataObject;
053: import org.openide.nodes.CookieSet;
054: import org.openide.nodes.Node;
055: import org.openide.text.DataEditorSupport;
056: import org.netbeans.modules.j2ee.websphere6.dd.loaders.WSMultiViewDataObject;
057:
058: public class WSAppBndDataObject extends WSMultiViewDataObject {
059:
060: public WSAppBndDataObject(FileObject pf, WSAppBndDataLoader loader)
061: throws DataObjectExistsException, IOException {
062: super (pf, loader);
063: }
064:
065: protected Node createNodeDelegate() {
066: return new WSAppBndDataNode(this );
067: }
068:
069: public DDXmi getDD() throws java.io.IOException {
070: if (ddBaseBean == null) {
071: ddBaseBean = new WSAppBnd(
072: FileUtil.toFile(getPrimaryFile()), false);
073: }
074: return (WSAppBnd) ddBaseBean;
075: }
076:
077: public WSAppBnd getAppBnd() throws java.io.IOException {
078: return (WSAppBnd) getDD();
079: }
080:
081: protected DDXmi createDDXmiFromDataCache() {
082: return new WSAppBnd(getInputStream(), false);
083: }
084:
085: protected DesignMultiViewDesc[] getMultiViewDesc() {
086: designView = new DesignView(this );
087: return new DesignMultiViewDesc[] { designView };
088: }
089:
090: public WSAppBndToolBarMVElement getEBTB() {
091: return ((DesignView) designView).getEBTB();
092: }
093:
094: protected class DesignView extends WSDesignView {
095: private WSAppBndToolBarMVElement ebtb;
096: private static final long serialVersionUID = 7209502130942350230L;
097:
098: DesignView(WSAppBndDataObject dObj) {
099: super (dObj);
100: }
101:
102: public org.netbeans.core.spi.multiview.MultiViewElement createElement() {
103: WSAppBndDataObject dObj = (WSAppBndDataObject) getDataObject();
104: ebtb = new WSAppBndToolBarMVElement(dObj);
105: return ebtb;
106: }
107:
108: public String preferredID() {
109: return "appbnd_multiview_design";
110: }
111:
112: public WSAppBndToolBarMVElement getEBTB() {
113: return ebtb;
114:
115: }
116:
117: public java.awt.Image getIcon() {
118: return org.openide.util.Utilities
119: .loadImage("org/netbeans/modules/j2ee/websphere6/dd/resources/ws1.gif"); //NOI18N
120: }
121: }
122:
123: /** Enable to focus specific object in Multiview Editor
124: * The default implementation opens the XML View
125: */
126:
127: public void showElement(Object element) {
128: Object target = null;
129: /*if (element instanceof ResRefBindingsType ||
130: element instanceof AppRefBindingsType ||
131: element instanceof ResEnvRefBindingsType) {
132: */openView(0);
133: target = element;
134: //}
135: if (target != null) {
136: final Object key = target;
137: org.netbeans.modules.xml.multiview.Utils
138: .runInAwtDispatchThread(new Runnable() {
139: public void run() {
140: getActiveMultiViewElement0()
141: .getSectionView().openPanel(key);
142: }
143: });
144: }
145: }
146: }
|