1 19 20 package org.netbeans.modules.java.j2seproject.wsclient; 21 import java.util.List ; 22 23 import java.beans.PropertyChangeEvent ; 24 import java.beans.PropertyChangeListener ; 25 26 import javax.swing.JPanel ; 27 import org.netbeans.modules.java.j2seproject.ui.customizer.J2SEProjectProperties; 28 import org.netbeans.modules.websvc.api.client.WsCompileClientEditorSupport; 29 import org.openide.util.HelpCtx; 30 import org.openide.util.Lookup; 31 32 33 40 public class CustomizerWSClientHost extends javax.swing.JPanel implements PropertyChangeListener , HelpCtx.Provider { 41 42 private J2SEProjectProperties j2seProperties; 43 private WsCompileClientEditorSupport.Panel wsCompileEditor; 44 45 private List serviceSettings; 46 47 public CustomizerWSClientHost(J2SEProjectProperties j2seProperties, List serviceSettings) { 48 assert serviceSettings != null; 50 initComponents(); 51 52 this.j2seProperties = j2seProperties; 53 this.wsCompileEditor = null; 54 this.serviceSettings = serviceSettings; 55 56 if (serviceSettings.size() > 0) 57 initValues(); 58 } 59 60 65 private void initComponents() { 67 setLayout(new java.awt.BorderLayout ()); 68 69 } 71 72 75 public void addNotify() { 76 super.addNotify(); 77 78 JPanel component = wsCompileEditor.getComponent(); 80 81 removeAll(); add(component); 83 84 component.addPropertyChangeListener(WsCompileClientEditorSupport.PROP_FEATURES_CHANGED, this); 85 component.addPropertyChangeListener(WsCompileClientEditorSupport.PROP_OPTIONS_CHANGED, this); 86 } 87 88 public void removeNotify() { 89 super.removeNotify(); 90 91 JPanel component = wsCompileEditor.getComponent(); 93 component.removePropertyChangeListener(WsCompileClientEditorSupport.PROP_FEATURES_CHANGED, this); 94 component.removePropertyChangeListener(WsCompileClientEditorSupport.PROP_OPTIONS_CHANGED, this); 95 } 96 97 public void initValues() { 98 if (wsCompileEditor == null) { 100 WsCompileClientEditorSupport editorSupport = (WsCompileClientEditorSupport) Lookup.getDefault().lookup(WsCompileClientEditorSupport.class); 101 wsCompileEditor = editorSupport.getWsCompileSupport(); 102 } 103 104 wsCompileEditor.initValues(serviceSettings); 105 } 106 107 114 public void propertyChange(PropertyChangeEvent evt) { 115 String prop = evt.getPropertyName(); 117 if (WsCompileClientEditorSupport.PROP_FEATURES_CHANGED.equals(prop)) { 118 WsCompileClientEditorSupport.FeatureDescriptor newFeatureDesc = (WsCompileClientEditorSupport.FeatureDescriptor) evt.getNewValue(); 119 String propertyName = "wscompile.client." + newFeatureDesc.getServiceName() + ".features"; 120 j2seProperties.putAdditionalProperty(propertyName, newFeatureDesc.getFeatures()); 121 } else if (WsCompileClientEditorSupport.PROP_OPTIONS_CHANGED.equals(prop)) { 122 WsCompileClientEditorSupport.OptionDescriptor oldOptionDesc = (WsCompileClientEditorSupport.OptionDescriptor) evt.getOldValue(); 123 WsCompileClientEditorSupport.OptionDescriptor newOptionDesc = (WsCompileClientEditorSupport.OptionDescriptor) evt.getNewValue(); 124 boolean[] oldOptions = oldOptionDesc.getOptions(); 125 boolean[] newOptions = newOptionDesc.getOptions(); 126 String serviceName = newOptionDesc.getServiceName(); 127 String [] propertyNames=new String []{"verbose","debug","xPrintStackTrace","xSerializable","optimize"}; for (int i=0;i<newOptions.length;i++) { 129 if (oldOptions[i]!=newOptions[i]) 130 j2seProperties.putAdditionalProperty("wscompile.client."+serviceName+"."+propertyNames[i], newOptions[i]?"true":"false"); } 133 } 134 } 135 136 public HelpCtx getHelpCtx() { 137 return new HelpCtx(CustomizerWSClientHost.class); 138 } 139 140 } 141 | Popular Tags |