1 19 20 package org.netbeans.modules.web.project.ui.customizer; 21 22 import java.util.List ; 23 24 import java.beans.PropertyChangeEvent ; 25 import java.beans.PropertyChangeListener ; 26 27 import javax.swing.JPanel ; 28 import org.netbeans.modules.websvc.api.client.WsCompileClientEditorSupport; 29 30 import org.openide.util.HelpCtx; 31 import org.openide.util.Lookup; 32 33 40 public class CustomizerWSClientHost extends javax.swing.JPanel implements PropertyChangeListener , HelpCtx.Provider { 41 42 private WebProjectProperties webProperties; 43 private WsCompileClientEditorSupport.Panel wsCompileEditor; 44 45 private List serviceSettings; 46 47 public CustomizerWSClientHost(WebProjectProperties webProperties, List serviceSettings) { 48 assert serviceSettings != null; 50 initComponents(); 51 52 this.webProperties = webProperties; 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 89 public void removeNotify() { 90 super.removeNotify(); 91 92 JPanel component = wsCompileEditor.getComponent(); 94 component.removePropertyChangeListener(WsCompileClientEditorSupport.PROP_FEATURES_CHANGED, this); 95 component.removePropertyChangeListener(WsCompileClientEditorSupport.PROP_OPTIONS_CHANGED, this); 96 } 97 98 private void initValues() { 99 if(wsCompileEditor == null) { 101 WsCompileClientEditorSupport editorSupport = (WsCompileClientEditorSupport) Lookup.getDefault().lookup(WsCompileClientEditorSupport.class); 102 wsCompileEditor = editorSupport.getWsCompileSupport(); 103 } 104 105 wsCompileEditor.initValues(serviceSettings); 106 } 107 108 115 public void propertyChange(PropertyChangeEvent evt) { 116 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 webProperties.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 webProperties.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 |