1 19 20 package org.netbeans.modules.j2ee.ejbjarproject.ui.customizer; 21 22 import java.util.Collections ; 23 import java.util.List ; 24 25 import java.beans.PropertyChangeEvent ; 26 import java.beans.PropertyChangeListener ; 27 28 import javax.swing.JPanel ; 29 import javax.swing.JLabel ; 30 import org.netbeans.modules.websvc.api.client.WsCompileClientEditorSupport; 31 32 import org.w3c.dom.Document ; 33 import org.w3c.dom.Element ; 34 import org.w3c.dom.NodeList ; 35 36 import org.openide.WizardValidationException; 37 import org.openide.util.HelpCtx; 38 import org.openide.util.Lookup; 39 import org.openide.filesystems.FileObject; 40 41 import org.netbeans.spi.project.support.ant.AntProjectHelper; 42 import org.netbeans.modules.j2ee.ejbjarproject.EjbJarProvider; 43 import org.netbeans.modules.j2ee.ejbjarproject.EjbJarProjectType; 44 45 import org.netbeans.modules.websvc.spi.webservices.WebServicesConstants; 46 import org.netbeans.modules.websvc.api.client.WsCompileClientEditorSupport; 47 48 49 56 public class CustomizerWSClientHost extends javax.swing.JPanel 57 implements PropertyChangeListener , HelpCtx.Provider { 59 private EjbJarProjectProperties ejbJarProperties; 60 private WsCompileClientEditorSupport.Panel wsCompileEditor; 61 62 private List serviceSettings; 63 64 public CustomizerWSClientHost(EjbJarProjectProperties ejbJarProperties, List serviceSettings) { 65 assert serviceSettings != null && serviceSettings.size() > 0; 66 initComponents(); 67 68 this.ejbJarProperties = ejbJarProperties; 69 this.wsCompileEditor = null; 70 this.serviceSettings = serviceSettings; 71 72 initValues(); 73 } 74 75 80 private void initComponents() { 82 83 setLayout(new java.awt.BorderLayout ()); 84 85 } 86 88 89 92 public void addNotify() { 93 super.addNotify(); 94 95 JPanel component = wsCompileEditor.getComponent(); 96 97 removeAll(); add(component); 99 100 component.addPropertyChangeListener(WsCompileClientEditorSupport.PROP_FEATURES_CHANGED, this); 101 component.addPropertyChangeListener(WsCompileClientEditorSupport.PROP_OPTIONS_CHANGED, this); 102 } 103 104 public void removeNotify() { 105 super.removeNotify(); 106 107 JPanel component = wsCompileEditor.getComponent(); 108 component.removePropertyChangeListener(WsCompileClientEditorSupport.PROP_FEATURES_CHANGED, this); 109 component.removePropertyChangeListener(WsCompileClientEditorSupport.PROP_OPTIONS_CHANGED, this); 110 } 111 112 public void initValues() { 113 if(wsCompileEditor == null) { 114 WsCompileClientEditorSupport editorSupport = (WsCompileClientEditorSupport) Lookup.getDefault().lookup(WsCompileClientEditorSupport.class); 115 wsCompileEditor = editorSupport.getWsCompileSupport(); 116 } 117 118 wsCompileEditor.initValues(serviceSettings); 119 } 120 121 126 127 public void propertyChange(PropertyChangeEvent evt) { 128 String prop = evt.getPropertyName(); 129 if (WsCompileClientEditorSupport.PROP_FEATURES_CHANGED.equals(prop)) { 130 WsCompileClientEditorSupport.FeatureDescriptor newFeatureDesc = (WsCompileClientEditorSupport.FeatureDescriptor) evt.getNewValue(); 131 String propertyName = "wscompile.client." + newFeatureDesc.getServiceName() + ".features"; 132 ejbJarProperties.putAdditionalProperty(propertyName, newFeatureDesc.getFeatures()); 133 } else if (WsCompileClientEditorSupport.PROP_OPTIONS_CHANGED.equals(prop)) { 134 WsCompileClientEditorSupport.OptionDescriptor oldOptionDesc = (WsCompileClientEditorSupport.OptionDescriptor) evt.getOldValue(); 135 WsCompileClientEditorSupport.OptionDescriptor newOptionDesc = (WsCompileClientEditorSupport.OptionDescriptor) evt.getNewValue(); 136 boolean[] oldOptions = oldOptionDesc.getOptions(); 137 boolean[] newOptions = newOptionDesc.getOptions(); 138 String serviceName = newOptionDesc.getServiceName(); 139 String [] propertyNames=new String []{"verbose","debug","xPrintStackTrace","xSerializable","optimize"}; for (int i=0;i<newOptions.length;i++) { 141 if (oldOptions[i]!=newOptions[i]) 142 ejbJarProperties.putAdditionalProperty("wscompile.client."+serviceName+"."+propertyNames[i], newOptions[i]?"true":"false"); } 145 } 146 } 147 148 public HelpCtx getHelpCtx() { 149 return new HelpCtx(CustomizerWSClientHost.class); 150 } 151 } 152 | Popular Tags |