KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > websvc > wsitconf > ui > service > ServiceTopComponent


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 2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.websvc.wsitconf.ui.service;
21
22 import javax.swing.undo.UndoManager JavaDoc;
23 import org.netbeans.api.project.FileOwnerQuery;
24 import org.netbeans.api.project.Project;
25 import org.netbeans.modules.websvc.api.jaxws.project.config.JaxWsModel;
26 import org.netbeans.modules.websvc.api.jaxws.project.config.Service;
27 import org.netbeans.modules.xml.multiview.ui.InnerPanelFactory;
28 import org.netbeans.modules.xml.multiview.ui.ToolBarDesignEditor;
29 import org.netbeans.modules.xml.wsdl.model.WSDLModel;
30 import org.openide.nodes.Node;
31 import org.openide.util.NbBundle;
32 import org.openide.windows.TopComponent;
33 import java.awt.*;
34 import java.util.Collection JavaDoc;
35 import org.netbeans.modules.xml.wsdl.model.Binding;
36 import org.netbeans.modules.xml.xam.ModelSource;
37 import org.openide.ErrorManager;
38 import org.openide.filesystems.FileObject;
39
40 /**
41  * @author Martin Grebac
42  */

43 public class ServiceTopComponent extends TopComponent {
44
45     static final long serialVersionUID=6021472310161712674L;
46     private boolean initialized = false;
47
48     private WSDLModel wsdlModel;
49     private UndoManager JavaDoc undoManager;
50     private Node node;
51     private Service service;
52     private JaxWsModel jaxWsModel;
53     private Collection JavaDoc<Binding> bindings;
54     
55     public ServiceTopComponent(Service service,
56                 JaxWsModel jaxWsModel, WSDLModel wsdlModel, Node node, UndoManager JavaDoc undoManager) {
57         setLayout(new BorderLayout());
58         this.wsdlModel = wsdlModel;
59         this.undoManager = undoManager;
60         this.initialized = false;
61         this.node = node;
62         this.service = service;
63         this.jaxWsModel = jaxWsModel;
64     }
65
66     public ServiceTopComponent(WSDLModel wsdlModel, UndoManager JavaDoc undoManager, Collection JavaDoc<Binding> bindings) {
67         setLayout(new BorderLayout());
68         this.wsdlModel = wsdlModel;
69         this.undoManager = undoManager;
70         this.bindings = bindings;
71         this.initialized = false;
72     }
73     
74     @Override JavaDoc
75     protected String JavaDoc preferredID(){
76         return "WSITTopComponent"; //NOI18N
77
}
78     
79     /**
80      * #38900 - lazy addition of GUI components
81      */

82     private void doInitialize() {
83         initAccessibility();
84         ToolBarDesignEditor tb = new ToolBarDesignEditor();
85         if (wsdlModel == null) {
86             ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, new IllegalStateException JavaDoc(" WSDL Model not ready"));
87             return;
88         }
89         ModelSource ms = wsdlModel.getModelSource();
90         FileObject fo = org.netbeans.modules.xml.retriever.catalog.Utilities.getFileObject(ms);
91         Project p = (fo != null) ? FileOwnerQuery.getOwner(fo) : null;
92         InnerPanelFactory panelFactory = new ServicePanelFactory(tb, node, undoManager, p, jaxWsModel);
93         ServiceView mview = new ServiceView(panelFactory, wsdlModel, node, service, bindings);
94         tb.setContentView(mview);
95         add(tb);
96         setFocusable(true);
97     }
98
99     @Override JavaDoc
100     public int getPersistenceType() {
101         return TopComponent.PERSISTENCE_ALWAYS;
102     }
103     
104     private void initAccessibility(){
105         getAccessibleContext().setAccessibleDescription(
106                 NbBundle.getMessage(ServiceTopComponent.class, "ACS_Tab_DESC")); // NOI18N
107
}
108     
109     /**
110      * #38900 - lazy addition of GUI components
111      */

112     @Override JavaDoc
113     public void addNotify() {
114         if (!initialized) {
115             initialized = true;
116             doInitialize();
117         }
118         super.addNotify();
119     }
120     
121     /**
122      * Called when <code>TopComponent</code> is about to be shown.
123      * Shown here means the component is selected or resides in it own cell
124      * in container in its <code>Mode</code>. The container is visible and not minimized.
125      * <p><em>Note:</em> component
126      * is considered to be shown, even its container window
127      * is overlapped by another window.</p>
128      * @since 2.18
129      *
130      * #38900 - lazy addition of GUI components
131      *
132      */

133     @Override JavaDoc
134     protected void componentShowing() {
135         if (!initialized) {
136             initialized = true;
137             doInitialize();
138         }
139         super.componentShowing();
140     }
141 }
142
143
Popular Tags