KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > websvc > wsitconf > ui > client > ClientTopComponent


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.client;
21
22 import java.util.Collection JavaDoc;
23 import org.netbeans.modules.websvc.api.jaxws.project.config.Client;
24 import org.netbeans.modules.websvc.api.jaxws.project.config.JaxWsModel;
25 import org.netbeans.modules.xml.multiview.ui.InnerPanelFactory;
26 import org.netbeans.modules.xml.multiview.ui.ToolBarDesignEditor;
27 import org.netbeans.modules.xml.wsdl.model.WSDLModel;
28 import org.openide.nodes.Node;
29 import org.openide.util.NbBundle;
30 import org.openide.windows.TopComponent;
31 import java.awt.*;
32 import java.util.Iterator JavaDoc;
33 import org.netbeans.api.project.FileOwnerQuery;
34 import org.netbeans.api.project.Project;
35
36 /**
37  * @author Martin Grebac
38  */

39 public class ClientTopComponent extends TopComponent {
40
41     static final long serialVersionUID=6021472310161712674L;
42     private boolean initialized = false;
43     private InnerPanelFactory panelFactory = null;
44
45     private JaxWsModel jaxWsModel;
46     private WSDLModel clientWsdlModel;
47     private WSDLModel serviceModel;
48     private Client client;
49     private Node node;
50     
51     public ClientTopComponent(Client client, JaxWsModel jaxWsModel, WSDLModel clientWsdlModel, WSDLModel serviceWsdlModel, Node node) {
52         setLayout(new BorderLayout());
53         this.jaxWsModel = jaxWsModel;
54         this.clientWsdlModel = clientWsdlModel;
55         this.serviceModel = serviceWsdlModel;
56         this.initialized = false;
57         this.client = client;
58         this.node = node;
59     }
60     
61     @Override JavaDoc
62     protected String JavaDoc preferredID(){
63         return "WSITClientTopComponent"; //NOI18N
64
}
65
66     private org.netbeans.modules.xml.wsdl.model.Service getService(String JavaDoc name, WSDLModel m) {
67         if ((name != null) && (m != null)) {
68             Collection JavaDoc services = m.getDefinitions().getServices();
69             if (services != null) {
70                 Iterator JavaDoc i = services.iterator();
71                 org.netbeans.modules.xml.wsdl.model.Service s = null;
72                 while (i.hasNext()) {
73                     s = (org.netbeans.modules.xml.wsdl.model.Service)i.next();
74                     if ((s != null) && ((name.equals(s.getName())) || (services.size() == 1))) {
75                         return s;
76                     }
77                 }
78             }
79         }
80         return null;
81     }
82     
83     /**
84      * #38900 - lazy addition of GUI components
85      */

86     private void doInitialize() {
87         initAccessibility();
88
89         ToolBarDesignEditor tb = new ToolBarDesignEditor();
90         panelFactory = new ClientPanelFactory(tb, clientWsdlModel, node, serviceModel, jaxWsModel);
91         
92         org.netbeans.modules.xml.wsdl.model.Service s = getService(client.getName(), clientWsdlModel); //TODO - the client name just won't work!!!
93
if (s != null) {
94             Project p = FileOwnerQuery.getOwner(jaxWsModel.getJaxWsFile());
95             ClientView mview = new ClientView(panelFactory, clientWsdlModel, serviceModel, s, p, node);
96             tb.setContentView(mview);
97             add(tb);
98         }
99         setFocusable(true);
100     }
101
102     @Override JavaDoc
103     public int getPersistenceType() {
104         return TopComponent.PERSISTENCE_ALWAYS;
105     }
106     
107     private void initAccessibility(){
108         getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(ClientTopComponent.class, "ACS_Tab_DESC")); // NOI18N
109
}
110
111     /**
112      * #38900 - lazy addition of GUI components
113      */

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

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