KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > websvc > customization > multiview > WSPanelFactory


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
20 /*
21  * WSPanelFactory.java
22  *
23  * Created on February 27, 2006, 11:58 AM
24  *
25  * To change this template, choose Tools | Template Manager
26  * and open the template in the editor.
27  */

28
29 package org.netbeans.modules.websvc.customization.multiview;
30
31 import java.util.Collection JavaDoc;
32 import java.util.HashMap JavaDoc;
33 import java.util.Map JavaDoc;
34 import org.netbeans.modules.websvc.api.jaxws.project.config.JaxWsModel;
35 import org.netbeans.modules.websvc.customization.multiview.WSCustomizationView.BindingKey;
36 import org.netbeans.modules.xml.multiview.ui.InnerPanelFactory;
37 import org.netbeans.modules.xml.multiview.ui.SectionInnerPanel;
38 import org.netbeans.modules.xml.multiview.ui.SectionView;
39 import org.netbeans.modules.xml.multiview.ui.ToolBarDesignEditor;
40 import org.netbeans.modules.xml.wsdl.model.Binding;
41 import org.netbeans.modules.xml.wsdl.model.BindingOperation;
42 import org.netbeans.modules.xml.wsdl.model.Definitions;
43 import org.netbeans.modules.xml.wsdl.model.Fault;
44 import org.netbeans.modules.xml.wsdl.model.Operation;
45 import org.netbeans.modules.xml.wsdl.model.Port;
46 import org.netbeans.modules.xml.wsdl.model.PortType;
47 import org.netbeans.modules.xml.wsdl.model.Service;
48 import org.netbeans.modules.xml.wsdl.model.WSDLModel;
49 import org.openide.nodes.Node;
50
51 /**
52  *
53  * @author Roderico Cruz
54  */

55 public class WSPanelFactory implements InnerPanelFactory {
56     private ToolBarDesignEditor editor;
57     private Node node;
58     private JaxWsModel jmodel;
59     
60     private Map JavaDoc<Object JavaDoc, SaveableSectionInnerPanel> panels;
61     
62     //panels
63
private DefinitionsPanel definitionsPanel;
64     private PortTypePanel portTypePanel;
65     private PortTypeOperationPanel portTypeOperationPanel;
66     private PortTypeOperationFaultPanel portTypeOperationFaultPanel;
67     private BindingPanel bindingPanel;
68     private BindingOperationPanel bindingOperationPanel;
69     private ServicePanel servicePanel;
70     private PortPanel portPanel;
71     private ExternalBindingPanel externalBindingPanel;
72     private Definitions primaryDefinitions;
73     /**
74      * Creates a new instance of WSPanelFactory
75      */

76     public WSPanelFactory(ToolBarDesignEditor editor,
77             Node node, Definitions primaryDefinitions, JaxWsModel jmodel) {
78         this.editor = editor;
79         this.node = node;
80         this.primaryDefinitions = primaryDefinitions;
81         this.jmodel = jmodel;
82         
83         panels = new HashMap JavaDoc<Object JavaDoc, SaveableSectionInnerPanel>();
84     }
85     
86     public Collection JavaDoc<SaveableSectionInnerPanel> getPanels(){
87         return panels.values();
88     }
89     
90     public SectionInnerPanel createInnerPanel(Object JavaDoc key) {
91         if(key instanceof Definitions){
92             Definitions definitions = (Definitions)key;
93             definitionsPanel = (DefinitionsPanel)panels.get(definitions);
94             if(definitionsPanel == null){
95                 definitionsPanel = new DefinitionsPanel((SectionView) editor.getContentView(),
96                         definitions, node);
97                 panels.put(definitions, definitionsPanel);
98             }
99             return definitionsPanel;
100         } else if (key instanceof PortType){
101             PortType portType = (PortType)key;
102             portTypePanel = (PortTypePanel)panels.get(portType);
103             if(portTypePanel == null){
104                 portTypePanel = new PortTypePanel((SectionView) editor.getContentView(),
105                         portType, node, primaryDefinitions);
106                 panels.put(portType, portTypePanel);
107             }
108             return portTypePanel;
109         } else if (key instanceof Operation){
110             Operation operation = (Operation)key;
111             portTypeOperationPanel = (PortTypeOperationPanel)panels.get(operation);
112             if(portTypeOperationPanel == null){
113                 portTypeOperationPanel = new PortTypeOperationPanel((SectionView) editor.getContentView(),
114                         operation, node, primaryDefinitions);
115                 panels.put(operation, portTypeOperationPanel);
116             }
117             return portTypeOperationPanel;
118         } else if (key instanceof Fault){
119             Fault fault = (Fault)key;
120             portTypeOperationFaultPanel = (PortTypeOperationFaultPanel)panels.get(fault);
121             if(portTypeOperationFaultPanel == null){
122                 portTypeOperationFaultPanel = new PortTypeOperationFaultPanel((SectionView) editor.getContentView(),
123                         fault);
124                 panels.put(fault, portTypeOperationFaultPanel);
125             }
126             return portTypeOperationFaultPanel;
127         } else if (key instanceof Binding){
128             Binding binding = (Binding)key;
129             bindingPanel = (BindingPanel)panels.get(binding);
130             if(bindingPanel == null){
131                 bindingPanel = new BindingPanel((SectionView) editor.getContentView(),
132                         binding, primaryDefinitions);
133                 panels.put(binding, bindingPanel);
134             }
135             return bindingPanel;
136             
137         } else if (key instanceof BindingOperation){
138             BindingOperation bindingOperation = (BindingOperation)key;
139             bindingOperationPanel = (BindingOperationPanel)panels.get(bindingOperation);
140             if(bindingOperationPanel == null){
141                 bindingOperationPanel = new BindingOperationPanel((SectionView) editor.getContentView(),
142                         bindingOperation, primaryDefinitions);
143                 panels.put(bindingOperation, bindingOperationPanel);
144             }
145             return bindingOperationPanel;
146         } else if (key instanceof Service){
147             Service service = (Service)key;
148             servicePanel = (ServicePanel)panels.get(service);
149             if(servicePanel == null){
150                 servicePanel = new ServicePanel((SectionView) editor.getContentView(),
151                         service);
152                 panels.put(service, servicePanel);
153             }
154             return servicePanel;
155         } else if (key instanceof Port){
156             Port port = (Port)key;
157             portPanel = (PortPanel)panels.get(port);
158             if(portPanel == null){
159                 portPanel = new PortPanel((SectionView) editor.getContentView(),
160                         port, node);
161                 panels.put(port, portPanel);
162             }
163             return portPanel;
164         } else if(key instanceof BindingKey){
165             BindingKey bindingKey = (BindingKey)key;
166             externalBindingPanel = (ExternalBindingPanel)panels.get(bindingKey);
167             if(externalBindingPanel == null){
168                 externalBindingPanel = new ExternalBindingPanel((SectionView) editor.getContentView(),
169                         node, jmodel);
170                 panels.put(bindingKey,externalBindingPanel);
171             }
172             return externalBindingPanel;
173         }
174         return null;
175     }
176 }
177
Popular Tags