1 19 20 package org.netbeans.modules.websvc.wsitconf.ui.client; 21 22 import java.text.NumberFormat ; 23 import javax.swing.JCheckBox ; 24 import javax.swing.text.DefaultFormatterFactory ; 25 import javax.swing.text.NumberFormatter ; 26 import org.netbeans.modules.websvc.wsitconf.wsdlmodelext.PolicyModelHelper; 27 import org.netbeans.modules.websvc.wsitconf.wsdlmodelext.ProprietarySecurityPolicyModelHelper; 28 import org.netbeans.modules.websvc.wsitconf.wsdlmodelext.RMModelHelper; 29 import org.netbeans.modules.websvc.wsitconf.wsdlmodelext.RMSunModelHelper; 30 import org.netbeans.modules.websvc.wsitconf.wsdlmodelext.RequiredConfigurationHelper; 31 import org.netbeans.modules.websvc.wsitconf.wsdlmodelext.SecurityPolicyModelHelper; 32 import org.netbeans.modules.xml.multiview.ui.SectionInnerPanel; 33 import org.netbeans.modules.xml.multiview.ui.SectionView; 34 import org.netbeans.modules.xml.multiview.ui.SectionVisualTheme; 35 import org.netbeans.modules.xml.wsdl.model.Binding; 36 import org.netbeans.modules.xml.wsdl.model.WSDLModel; 37 import org.openide.nodes.Node; 38 39 43 public class AdvancedConfigPanelClient extends SectionInnerPanel { 44 45 private WSDLModel clientModel; 46 private WSDLModel serviceModel; 47 48 private Node node; 49 private Binding binding; 50 private boolean inSync = false; 51 52 private static final String DEFAULT_LIFETIME = "36000"; private static final String DEFAULT_TIMEOUT = "5000"; private static final String DEFAULT_RMRESENDINTERVAL = "2000"; private static final String DEFAULT_RMCLOSETIMEOUT = "0"; private static final String DEFAULT_RMREQUESTACKINTERVAL = "200"; 58 private DefaultFormatterFactory lifetimeDff = null; 59 private DefaultFormatterFactory closeTimeoutDff = null; 60 private DefaultFormatterFactory rmSendDff = null; 61 private DefaultFormatterFactory rmReqDff = null; 62 private DefaultFormatterFactory timeoutDff = null; 63 64 public AdvancedConfigPanelClient(SectionView view, Node node, Binding binding, WSDLModel serviceModel) { 65 super(view); 66 this.clientModel = binding.getModel(); 67 this.serviceModel = serviceModel; 68 this.node = node; 69 this.binding = binding; 70 71 lifetimeDff = new DefaultFormatterFactory (); 72 NumberFormat lifetimeFormat = NumberFormat.getIntegerInstance(); 73 lifetimeFormat.setGroupingUsed(false); 74 lifetimeFormat.setParseIntegerOnly(true); 75 lifetimeFormat.setMaximumFractionDigits(0); 76 NumberFormatter lifetimeFormatter = new NumberFormatter (lifetimeFormat); 77 lifetimeFormatter.setCommitsOnValidEdit(true); 78 lifetimeFormatter.setMinimum(0); 79 lifetimeDff.setDefaultFormatter(lifetimeFormatter); 80 81 rmSendDff = new DefaultFormatterFactory (); 82 NumberFormat rmSendFormat = NumberFormat.getIntegerInstance(); 83 rmSendFormat.setGroupingUsed(false); 84 rmSendFormat.setParseIntegerOnly(true); 85 rmSendFormat.setMaximumFractionDigits(0); 86 NumberFormatter rmSendFormatter = new NumberFormatter (rmSendFormat); 87 rmSendFormatter.setCommitsOnValidEdit(true); 88 rmSendFormatter.setMinimum(0); 89 rmSendDff.setDefaultFormatter(rmSendFormatter); 90 91 rmReqDff = new DefaultFormatterFactory (); 92 NumberFormat rmReqFormat = NumberFormat.getIntegerInstance(); 93 rmReqFormat.setGroupingUsed(false); 94 rmReqFormat.setParseIntegerOnly(true); 95 rmReqFormat.setMaximumFractionDigits(0); 96 NumberFormatter rmReqFormatter = new NumberFormatter (rmReqFormat); 97 rmReqFormatter.setCommitsOnValidEdit(true); 98 rmReqFormatter.setMinimum(0); 99 rmReqDff.setDefaultFormatter(rmReqFormatter); 100 101 timeoutDff = new DefaultFormatterFactory (); 102 NumberFormat timeoutFormat = NumberFormat.getIntegerInstance(); 103 timeoutFormat.setGroupingUsed(false); 104 timeoutFormat.setParseIntegerOnly(true); 105 timeoutFormat.setMaximumFractionDigits(0); 106 NumberFormatter timeoutFormatter = new NumberFormatter (timeoutFormat); 107 timeoutFormatter.setCommitsOnValidEdit(true); 108 timeoutFormatter.setMinimum(0); 109 timeoutDff.setDefaultFormatter(timeoutFormatter); 110 111 closeTimeoutDff = new DefaultFormatterFactory (); 112 NumberFormat rmCloseTimeoutFormat = NumberFormat.getIntegerInstance(); 113 rmCloseTimeoutFormat.setGroupingUsed(false); 114 rmCloseTimeoutFormat.setParseIntegerOnly(true); 115 rmCloseTimeoutFormat.setMaximumFractionDigits(0); 116 NumberFormatter rmCloseTimeoutFormatter = new NumberFormatter (rmCloseTimeoutFormat); 117 rmCloseTimeoutFormatter.setCommitsOnValidEdit(true); 118 rmCloseTimeoutFormatter.setMinimum(0); 119 closeTimeoutDff.setDefaultFormatter(rmCloseTimeoutFormatter); 120 121 initComponents(); 122 123 lifeTimeLabel.setBackground(SectionVisualTheme.getDocumentBackgroundColor()); 124 lifeTimeTextField.setBackground(SectionVisualTheme.getDocumentBackgroundColor()); 125 renewExpiredChBox.setBackground(SectionVisualTheme.getDocumentBackgroundColor()); 128 requireCancelChBox.setBackground(SectionVisualTheme.getDocumentBackgroundColor()); 129 rmAckRequestField.setBackground(SectionVisualTheme.getDocumentBackgroundColor()); 130 rmAckRequestLabel.setBackground(SectionVisualTheme.getDocumentBackgroundColor()); 131 rmResendField.setBackground(SectionVisualTheme.getDocumentBackgroundColor()); 132 rmResendLabel.setBackground(SectionVisualTheme.getDocumentBackgroundColor()); 133 rmCloseTimeoutLabel.setBackground(SectionVisualTheme.getDocumentBackgroundColor()); 134 rmCloseTimeoutField.setBackground(SectionVisualTheme.getDocumentBackgroundColor()); 135 136 addImmediateModifier(rmAckRequestField); 137 addImmediateModifier(rmCloseTimeoutField); 138 addImmediateModifier(rmResendField); 139 addImmediateModifier(lifeTimeTextField); 140 addImmediateModifier(renewExpiredChBox); 142 addImmediateModifier(requireCancelChBox); 143 144 sync(); 145 } 146 147 public void sync() { 148 inSync = true; 149 150 String lifeTime = ProprietarySecurityPolicyModelHelper.getLifeTime(binding, true); 151 if (lifeTime == null) { 152 lifeTimeTextField.setText(DEFAULT_LIFETIME); 153 } else { 154 lifeTimeTextField.setText(lifeTime); 155 } 156 157 164 String rmResendInterval = RMSunModelHelper.getResendInterval(binding); 165 if (rmResendInterval == null) { 166 rmResendField.setText(DEFAULT_RMRESENDINTERVAL); 167 } else { 168 rmResendField.setText(rmResendInterval); 169 } 170 171 String rmCloseTimeout = RMSunModelHelper.getCloseTimeout(binding); 172 if (rmCloseTimeout == null) { 173 rmCloseTimeoutField.setText(DEFAULT_RMCLOSETIMEOUT); 174 } else { 175 rmCloseTimeoutField.setText(rmCloseTimeout); 176 } 177 178 String rmAckRequest = RMSunModelHelper.getAckRequestInterval(binding); 179 if (rmAckRequest == null) { 180 rmAckRequestField.setText(DEFAULT_RMREQUESTACKINTERVAL); 181 } else { 182 rmAckRequestField.setText(rmAckRequest); 183 } 184 185 setChBox(renewExpiredChBox, ProprietarySecurityPolicyModelHelper.isRenewExpired(binding)); 186 setChBox(requireCancelChBox, ProprietarySecurityPolicyModelHelper.isRequireCancel(binding)); 187 188 enableDisable(); 189 190 inSync = false; 191 } 192 193 @Override 194 public void setValue(javax.swing.JComponent source, Object value) { 195 if (!inSync) { 196 if (source.equals(lifeTimeTextField)) { 197 String lifeTime = ((Integer ) lifeTimeTextField.getValue()).toString(); 198 if ((lifeTime == null) || (lifeTime.length() == 0) || (DEFAULT_LIFETIME.equals(lifeTime))) { 199 ProprietarySecurityPolicyModelHelper.setLifeTime(binding, null, true); 200 } else { 201 ProprietarySecurityPolicyModelHelper.setLifeTime(binding, lifeTime, true); 202 } 203 } 204 205 214 if (source.equals(rmResendField)) { 215 String resendInt = ((Integer )rmResendField.getValue()).toString(); 216 if ((resendInt == null) || (resendInt.length() == 0) || (DEFAULT_RMRESENDINTERVAL.equals(resendInt))) { 217 RMSunModelHelper.setResendInterval(binding, null); 218 } else { 219 RMSunModelHelper.setResendInterval(binding, resendInt); 220 } 221 } 222 223 if (source.equals(rmCloseTimeoutField)) { 224 String closeTimeout = ((Integer )rmCloseTimeoutField.getValue()).toString(); 225 if ((closeTimeout == null) || (closeTimeout.length() == 0) || (DEFAULT_RMCLOSETIMEOUT.equals(closeTimeout))) { 226 RMSunModelHelper.setCloseTimeout(binding, null); 227 } else { 228 RMSunModelHelper.setCloseTimeout(binding, closeTimeout); 229 } 230 } 231 232 if (source.equals(rmAckRequestField)) { 233 String ackRequestInt = ((Integer )rmAckRequestField.getValue()).toString(); 234 if ((ackRequestInt == null) || (ackRequestInt.length() == 0) || (DEFAULT_RMREQUESTACKINTERVAL.equals(ackRequestInt))) { 235 RMSunModelHelper.setAckRequestInterval(binding, null); 236 } else { 237 RMSunModelHelper.setAckRequestInterval(binding, ackRequestInt); 238 } 239 } 240 241 if (source.equals(renewExpiredChBox)) { 242 ProprietarySecurityPolicyModelHelper.setRenewExpired(binding, renewExpiredChBox.isSelected()); 243 } 244 245 if (source.equals(requireCancelChBox)) { 246 ProprietarySecurityPolicyModelHelper.setRequireCancel(binding, requireCancelChBox.isSelected()); 247 } 248 } 249 } 250 251 private void enableDisable() { 252 Binding serviceBinding = PolicyModelHelper.getBinding(serviceModel, binding.getName()); 253 boolean rmEnabled = RMModelHelper.isRMEnabled(serviceBinding); 254 boolean timestampEnabled = SecurityPolicyModelHelper.isIncludeTimestamp(serviceBinding); 255 boolean secConvConfigRequired = RequiredConfigurationHelper.isSecureConversationParamRequired(serviceBinding); 256 257 rmAckRequestLabel.setEnabled(rmEnabled); 258 rmAckRequestField.setEnabled(rmEnabled); 259 rmResendLabel.setEnabled(rmEnabled); 260 rmResendField.setEnabled(rmEnabled); 261 rmCloseTimeoutField.setEnabled(rmEnabled); 262 rmCloseTimeoutLabel.setEnabled(rmEnabled); 263 264 lifeTimeTextField.setEnabled(secConvConfigRequired); 265 lifeTimeLabel.setEnabled(secConvConfigRequired); 266 renewExpiredChBox.setEnabled(secConvConfigRequired); 267 requireCancelChBox.setEnabled(secConvConfigRequired); 268 269 } 272 273 private void setChBox(JCheckBox chBox, Boolean enable) { 274 if (enable == null) { 275 chBox.setSelected(false); 276 } else { 277 chBox.setSelected(enable); 278 } 279 } 280 281 @Override 282 public void documentChanged(javax.swing.text.JTextComponent comp, String value) { 283 } 284 285 @Override 286 public void rollbackValue(javax.swing.text.JTextComponent source) { 287 } 288 289 @Override 290 protected void endUIChange() { 291 } 292 293 public void linkButtonPressed(Object ddBean, String ddProperty) { 294 } 295 296 public javax.swing.JComponent getErrorComponent(String errorId) { 297 return null; 298 } 299 300 305 private void initComponents() { 307 308 lifeTimeLabel = new javax.swing.JLabel (); 309 renewExpiredChBox = new javax.swing.JCheckBox (); 310 requireCancelChBox = new javax.swing.JCheckBox (); 311 rmResendLabel = new javax.swing.JLabel (); 312 rmAckRequestLabel = new javax.swing.JLabel (); 313 rmResendField = new javax.swing.JFormattedTextField (); 314 rmAckRequestField = new javax.swing.JFormattedTextField (); 315 lifeTimeTextField = new javax.swing.JFormattedTextField (); 316 rmCloseTimeoutLabel = new javax.swing.JLabel (); 317 rmCloseTimeoutField = new javax.swing.JFormattedTextField (); 318 319 lifeTimeLabel.setLabelFor(lifeTimeTextField); 320 org.openide.awt.Mnemonics.setLocalizedText(lifeTimeLabel, org.openide.util.NbBundle.getMessage(AdvancedConfigPanelClient.class, "LBL_AdvancedConfigPanel_SCTokenLifeTime")); 322 org.openide.awt.Mnemonics.setLocalizedText(renewExpiredChBox, org.openide.util.NbBundle.getMessage(AdvancedConfigPanelClient.class, "LBL_AdvancedConfigPanel_RenewExpired")); renewExpiredChBox.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); 324 renewExpiredChBox.setMargin(new java.awt.Insets (0, 0, 0, 0)); 325 326 org.openide.awt.Mnemonics.setLocalizedText(requireCancelChBox, org.openide.util.NbBundle.getMessage(AdvancedConfigPanelClient.class, "LBL_AdvancedConfigPanel_RequireCancel")); requireCancelChBox.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); 328 requireCancelChBox.setMargin(new java.awt.Insets (0, 0, 0, 0)); 329 330 rmResendLabel.setLabelFor(rmResendField); 331 org.openide.awt.Mnemonics.setLocalizedText(rmResendLabel, org.openide.util.NbBundle.getMessage(AdvancedConfigPanelClient.class, "LBL_AdvancedConfigPanel_ResendInterval")); 333 rmAckRequestLabel.setLabelFor(rmAckRequestField); 334 org.openide.awt.Mnemonics.setLocalizedText(rmAckRequestLabel, org.openide.util.NbBundle.getMessage(AdvancedConfigPanelClient.class, "LBL_AdvancedConfigPanel_AckRequestInterval")); 336 rmResendField.setFormatterFactory(rmSendDff); 337 338 rmAckRequestField.setFormatterFactory(rmReqDff); 339 340 lifeTimeTextField.setFormatterFactory(lifetimeDff); 341 342 rmCloseTimeoutLabel.setLabelFor(rmCloseTimeoutField); 343 org.openide.awt.Mnemonics.setLocalizedText(rmCloseTimeoutLabel, org.openide.util.NbBundle.getMessage(AdvancedConfigPanelClient.class, "LBL_AdvancedConfigPanel_CloseTimeout")); 345 rmCloseTimeoutField.setFormatterFactory(closeTimeoutDff); 346 347 org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this); 348 this.setLayout(layout); 349 layout.setHorizontalGroup( 350 layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 351 .add(layout.createSequentialGroup() 352 .addContainerGap() 353 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 354 .add(layout.createSequentialGroup() 355 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 356 .add(rmResendLabel) 357 .add(rmCloseTimeoutLabel) 358 .add(rmAckRequestLabel)) 359 .add(49, 49, 49) 360 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 361 .add(rmResendField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 69, Short.MAX_VALUE) 362 .add(rmCloseTimeoutField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 69, Short.MAX_VALUE) 363 .add(rmAckRequestField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 69, Short.MAX_VALUE))) 364 .add(layout.createSequentialGroup() 365 .add(lifeTimeLabel) 366 .add(10, 10, 10) 367 .add(lifeTimeTextField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 69, Short.MAX_VALUE)) 368 .add(renewExpiredChBox) 369 .add(requireCancelChBox)) 370 .addContainerGap()) 371 ); 372 layout.setVerticalGroup( 373 layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 374 .add(layout.createSequentialGroup() 375 .addContainerGap() 376 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) 377 .add(rmResendLabel) 378 .add(rmResendField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) 379 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 380 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) 381 .add(rmCloseTimeoutLabel) 382 .add(rmCloseTimeoutField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) 383 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 384 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) 385 .add(rmAckRequestLabel) 386 .add(rmAckRequestField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) 387 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 388 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) 389 .add(lifeTimeLabel) 390 .add(lifeTimeTextField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) 391 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 392 .add(renewExpiredChBox) 393 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 394 .add(requireCancelChBox) 395 .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) 396 ); 397 398 lifeTimeLabel.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(AdvancedConfigPanelClient.class, "ACSN_AdvancedConfigPanel_SCTokenLifeTime")); lifeTimeLabel.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(AdvancedConfigPanelClient.class, "ACSD_AdvancedConfigPanel_SCTokenLifeTime")); renewExpiredChBox.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(AdvancedConfigPanelClient.class, "ACSN_AdvancedConfigPanel_RenewExpired")); renewExpiredChBox.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(AdvancedConfigPanelClient.class, "ACSD_AdvancedConfigPanel_RenewExpired")); requireCancelChBox.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(AdvancedConfigPanelClient.class, "ACSN_AdvancedConfigPanel_RequireCancel")); requireCancelChBox.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(AdvancedConfigPanelClient.class, "ACSD_AdvancedConfigPanel_RequireCancel")); rmResendLabel.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(AdvancedConfigPanelClient.class, "ACSN_AdvancedConfigPanel_ResendInterval")); rmResendLabel.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(AdvancedConfigPanelClient.class, "ACSD_AdvancedConfigPanel_ResendInterval")); rmAckRequestLabel.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(AdvancedConfigPanelClient.class, "ACSN_AdvancedConfigPanel_AckRequestInterval")); rmAckRequestLabel.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(AdvancedConfigPanelClient.class, "ACSD_AdvancedConfigPanel_AckRequestInterval")); rmCloseTimeoutLabel.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(AdvancedConfigPanelClient.class, "ACSN_AdvancedConfigPanel_CloseTimeout")); rmCloseTimeoutLabel.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(AdvancedConfigPanelClient.class, "ACSD_AdvancedConfigPanel_CloseTimeout")); } 412 413 private javax.swing.JLabel lifeTimeLabel; 415 private javax.swing.JFormattedTextField lifeTimeTextField; 416 private javax.swing.JCheckBox renewExpiredChBox; 417 private javax.swing.JCheckBox requireCancelChBox; 418 private javax.swing.JFormattedTextField rmAckRequestField; 419 private javax.swing.JLabel rmAckRequestLabel; 420 private javax.swing.JFormattedTextField rmCloseTimeoutField; 421 private javax.swing.JLabel rmCloseTimeoutLabel; 422 private javax.swing.JFormattedTextField rmResendField; 423 private javax.swing.JLabel rmResendLabel; 424 426 } 427 | Popular Tags |