1 19 20 package org.netbeans.modules.websvc.wsitconf.ui.service; 21 22 import javax.swing.undo.UndoManager ; 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 ; 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 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 undoManager; 50 private Node node; 51 private Service service; 52 private JaxWsModel jaxWsModel; 53 private Collection <Binding> bindings; 54 55 public ServiceTopComponent(Service service, 56 JaxWsModel jaxWsModel, WSDLModel wsdlModel, Node node, UndoManager 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 undoManager, Collection <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 75 protected String preferredID(){ 76 return "WSITTopComponent"; } 78 79 82 private void doInitialize() { 83 initAccessibility(); 84 ToolBarDesignEditor tb = new ToolBarDesignEditor(); 85 if (wsdlModel == null) { 86 ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, new IllegalStateException (" 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 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")); } 108 109 112 @Override 113 public void addNotify() { 114 if (!initialized) { 115 initialized = true; 116 doInitialize(); 117 } 118 super.addNotify(); 119 } 120 121 133 @Override 134 protected void componentShowing() { 135 if (!initialized) { 136 initialized = true; 137 doInitialize(); 138 } 139 super.componentShowing(); 140 } 141 } 142 143 | Popular Tags |