1 19 20 package org.netbeans.modules.websvc.wsitconf.ui.service.subpanels; 21 22 import java.text.NumberFormat ; 23 import javax.swing.text.DefaultFormatterFactory ; 24 import javax.swing.text.NumberFormatter ; 25 import org.netbeans.modules.websvc.wsitconf.wsdlmodelext.RMMSModelHelper; 26 import org.netbeans.modules.websvc.wsitconf.wsdlmodelext.RMModelHelper; 27 import org.netbeans.modules.xml.wsdl.model.Binding; 28 import org.openide.nodes.Node; 29 30 import javax.swing.*; 31 32 36 public class AdvancedRMPanel extends JPanel { 37 38 private Node node; 39 private Binding binding; 40 private boolean inSync = false; 41 42 private DefaultFormatterFactory inactff = null; 43 private DefaultFormatterFactory maxBufff = null; 44 45 public AdvancedRMPanel(Binding binding) { 46 this.node = node; 47 this.binding = binding; 48 49 inactff = new DefaultFormatterFactory (); 50 NumberFormat inactivityFormat = NumberFormat.getIntegerInstance(); 51 inactivityFormat.setGroupingUsed(false); 52 NumberFormatter inactivityFormatter = new NumberFormatter (inactivityFormat); 53 inactivityFormat.setMaximumIntegerDigits(8); 54 inactivityFormatter.setCommitsOnValidEdit(true); 55 inactivityFormatter.setMinimum(0); 56 inactivityFormatter.setMaximum(99999999); 57 inactff.setDefaultFormatter(inactivityFormatter); 58 59 maxBufff = new DefaultFormatterFactory (); 60 NumberFormat maxBufFormat = NumberFormat.getIntegerInstance(); 61 maxBufFormat.setGroupingUsed(false); 62 NumberFormatter maxBufFormatter = new NumberFormatter (maxBufFormat); 63 maxBufFormat.setMaximumIntegerDigits(8); 64 maxBufFormatter.setCommitsOnValidEdit(true); 65 maxBufFormatter.setMinimum(0); 66 maxBufFormatter.setMaximum(99999999); 67 maxBufff.setDefaultFormatter(maxBufFormatter); 68 69 initComponents(); 70 71 sync(); 72 } 73 74 private void sync() { 75 inSync = true; 76 77 String inactivityTimeout = RMModelHelper.getInactivityTimeout(binding); 78 if (inactivityTimeout == null) { setInactivityTimeout(RMModelHelper.DEFAULT_TIMEOUT); 80 } else { 81 setInactivityTimeout(inactivityTimeout); 82 } 83 84 String maxRcvBufferSize = RMMSModelHelper.getMaxReceiveBufferSize(binding); 85 if (maxRcvBufferSize == null) { setMaxRcvBufferSize(RMModelHelper.DEFAULT_MAXRCVBUFFERSIZE); 87 } else { 88 setMaxRcvBufferSize(maxRcvBufferSize); 89 } 90 91 setFlowControl(RMMSModelHelper.isFlowControlEnabled(binding)); 92 93 enableDisable(); 94 inSync = false; 95 } 96 97 private Number getMaxRcvBufferSize() { 99 return (Number ) this.maxBufTextField.getValue(); 100 } 101 102 private void setMaxRcvBufferSize(String value) { 103 this.maxBufTextField.setText(value); 104 } 105 106 private Number getInactivityTimeout() { 108 return (Number ) this.inactivityTimeoutTextfield.getValue(); 109 } 110 111 private void setInactivityTimeout(String value) { 112 this.inactivityTimeoutTextfield.setText(value); 113 } 114 115 private void setFlowControl(Boolean enable) { 117 if (enable == null) { 118 this.flowControlChBox.setSelected(false); 119 } else { 120 this.flowControlChBox.setSelected(enable); 121 } 122 } 123 124 public Boolean getFlowControl() { 125 if (flowControlChBox.isSelected()) { 126 return Boolean.TRUE; 127 } 128 return Boolean.FALSE; 129 } 130 131 public void storeState() { 132 133 if (flowControlChBox.isSelected()) { 134 if (!(RMMSModelHelper.isFlowControlEnabled(binding))) { 135 RMMSModelHelper.enableFlowControl(binding); 136 } 137 } else { 138 if (RMMSModelHelper.isFlowControlEnabled(binding)) { 139 RMMSModelHelper.disableFlowControl(binding); 140 } 141 } 142 143 Number timeout = getInactivityTimeout(); 144 if ((timeout == null) || (RMModelHelper.DEFAULT_TIMEOUT.equals(timeout.toString()))) { 145 RMModelHelper.setInactivityTimeout(binding, null); 146 } else { 147 RMModelHelper.setInactivityTimeout(binding, timeout.toString()); 148 } 149 150 Number bufSize = getMaxRcvBufferSize(); 151 if ((bufSize == null) || (RMModelHelper.DEFAULT_MAXRCVBUFFERSIZE.equals(bufSize.toString()))) { 152 RMMSModelHelper.setMaxReceiveBufferSize(binding, null); 153 } else { 154 RMMSModelHelper.setMaxReceiveBufferSize(binding, bufSize.toString()); 155 } 156 157 } 158 159 private void enableDisable() { 160 boolean flowSelected = flowControlChBox.isSelected(); 161 maxBufLabel.setEnabled(flowSelected); 162 maxBufTextField.setEnabled(flowSelected); 163 } 164 165 170 private void initComponents() { 172 flowControlChBox = new javax.swing.JCheckBox (); 173 maxBufLabel = new javax.swing.JLabel (); 174 inactivityTimeoutLabel = new javax.swing.JLabel (); 175 inactivityTimeoutTextfield = new javax.swing.JFormattedTextField (); 176 maxBufTextField = new javax.swing.JFormattedTextField (); 177 178 flowControlChBox.setText(org.openide.util.NbBundle.getMessage(AdvancedRMPanel.class, "LBL_AdvancedRM_FlowControlChBox")); 179 flowControlChBox.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); 180 flowControlChBox.setMargin(new java.awt.Insets (0, 0, 0, 0)); 181 flowControlChBox.addActionListener(new java.awt.event.ActionListener () { 182 public void actionPerformed(java.awt.event.ActionEvent evt) { 183 flowControlChBoxActionPerformed(evt); 184 } 185 }); 186 187 maxBufLabel.setText(org.openide.util.NbBundle.getMessage(AdvancedRMPanel.class, "LBL_AdvancedRM_maxBufLabel")); 188 189 inactivityTimeoutLabel.setText(org.openide.util.NbBundle.getMessage(AdvancedRMPanel.class, "LBL_AdvancedRM_InactivityTimeoutLabel")); 190 191 inactivityTimeoutTextfield.setFormatterFactory(inactff); 192 193 maxBufTextField.setColumns(8); 194 maxBufTextField.setFormatterFactory(maxBufff); 195 196 org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this); 197 this.setLayout(layout); 198 layout.setHorizontalGroup( 199 layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 200 .add(layout.createSequentialGroup() 201 .addContainerGap() 202 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 203 .add(flowControlChBox) 204 .add(layout.createSequentialGroup() 205 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 206 .add(maxBufLabel) 207 .add(inactivityTimeoutLabel)) 208 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 209 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 210 .add(inactivityTimeoutTextfield, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 97, Short.MAX_VALUE) 211 .add(maxBufTextField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 97, Short.MAX_VALUE)))) 212 .addContainerGap()) 213 ); 214 layout.setVerticalGroup( 215 layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 216 .add(layout.createSequentialGroup() 217 .addContainerGap() 218 .add(flowControlChBox) 219 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 220 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) 221 .add(maxBufLabel) 222 .add(maxBufTextField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) 223 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 224 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) 225 .add(inactivityTimeoutLabel) 226 .add(inactivityTimeoutTextfield, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) 227 .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) 228 ); 229 } 231 private void flowControlChBoxActionPerformed(java.awt.event.ActionEvent evt) { enableDisable(); 233 } 235 private javax.swing.JCheckBox flowControlChBox; 237 private javax.swing.JLabel inactivityTimeoutLabel; 238 private javax.swing.JFormattedTextField inactivityTimeoutTextfield; 239 private javax.swing.JLabel maxBufLabel; 240 private javax.swing.JFormattedTextField maxBufTextField; 241 243 } 244 | Popular Tags |