1 19 20 package org.netbeans.modules.j2ee.clientproject.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.j2ee.clientproject.ui.customizer.AppClientProjectProperties; 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 AppClientProjectProperties j2seProperties; 43 private WsCompileClientEditorSupport.Panel wsCompileEditor; 44 45 private List serviceSettings; 46 47 public CustomizerWSClientHost(AppClientProjectProperties 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 System.out.println("WSClientCustomizer: propertyChange - " + evt.getPropertyName()); 116 117 String prop = evt.getPropertyName(); 118 if (WsCompileClientEditorSupport.PROP_FEATURES_CHANGED.equals(prop)) { 119 WsCompileClientEditorSupport.FeatureDescriptor newFeatureDesc = (WsCompileClientEditorSupport.FeatureDescriptor) evt.getNewValue(); 120 String propertyName = "wscompile.client." + newFeatureDesc.getServiceName() + ".features"; 121 j2seProperties.putAdditionalProperty(propertyName, newFeatureDesc.getFeatures()); 122 } else if (WsCompileClientEditorSupport.PROP_OPTIONS_CHANGED.equals(prop)) { 123 WsCompileClientEditorSupport.OptionDescriptor oldOptionDesc = (WsCompileClientEditorSupport.OptionDescriptor) evt.getOldValue(); 124 WsCompileClientEditorSupport.OptionDescriptor newOptionDesc = (WsCompileClientEditorSupport.OptionDescriptor) evt.getNewValue(); 125 boolean[] oldOptions = oldOptionDesc.getOptions(); 126 boolean[] newOptions = newOptionDesc.getOptions(); 127 String serviceName = newOptionDesc.getServiceName(); 128 String [] propertyNames=new String []{"verbose","debug","xPrintStackTrace","xSerializable","optimize"}; for (int i=0;i<newOptions.length;i++) { 130 if (oldOptions[i]!=newOptions[i]) 131 j2seProperties.putAdditionalProperty("wscompile.client."+serviceName+"."+propertyNames[i], newOptions[i]?"true":"false"); } 134 } 135 } 136 137 public HelpCtx getHelpCtx() { 138 return new HelpCtx(CustomizerWSClientHost.class); 139 } 140 141 } 142 | Popular Tags |