1 19 20 package org.netbeans.modules.websvc.wsitconf.ui.service; 21 22 import java.awt.Dialog ; 23 import javax.swing.undo.UndoManager ; 24 import org.netbeans.modules.websvc.wsitconf.ui.service.subpanels.TargetsPanel; 25 import org.netbeans.modules.websvc.wsitconf.util.UndoCounter; 26 import org.netbeans.modules.xml.multiview.ui.SectionInnerPanel; 27 import org.netbeans.modules.xml.multiview.ui.SectionView; 28 import org.netbeans.modules.xml.wsdl.model.Binding; 29 import org.netbeans.modules.xml.wsdl.model.BindingFault; 30 import org.netbeans.modules.xml.wsdl.model.BindingOperation; 31 import org.netbeans.modules.xml.wsdl.model.WSDLModel; 32 import org.openide.DialogDescriptor; 33 import org.openide.DialogDisplayer; 34 import org.openide.nodes.Node; 35 36 import javax.swing.*; 37 import org.netbeans.modules.websvc.wsitconf.wsdlmodelext.SecurityPolicyModelHelper; 38 import org.netbeans.modules.xml.xam.ComponentEvent; 39 import org.netbeans.modules.xml.xam.ComponentListener; 40 import org.openide.util.NbBundle; 41 42 46 public class FaultPanel extends SectionInnerPanel { 47 48 private WSDLModel model; 49 private Node node; 50 private BindingOperation operation; 51 private BindingFault fault; 52 private Binding binding; 53 private UndoManager undoManager; 54 private boolean inSync = false; 55 56 public FaultPanel(SectionView view, Node node, BindingFault fault, UndoManager undoManager) { 57 super(view); 58 this.model = fault.getModel(); 59 this.node = node; 60 this.fault = fault; 61 this.operation = (BindingOperation)fault.getParent(); 62 this.binding = (Binding)operation.getParent(); 63 this.undoManager = undoManager; 64 initComponents(); 65 66 sync(); 67 68 model.addComponentListener(new ComponentListener() { 69 public void valueChanged(ComponentEvent evt) { 70 sync(); 71 } 72 public void childrenAdded(ComponentEvent evt) { 73 sync(); 74 } 75 public void childrenDeleted(ComponentEvent evt) { 76 sync(); 77 } 78 }); 79 } 80 81 private void sync() { 82 inSync = true; 83 84 enableDisable(); 85 86 inSync = false; 87 } 88 89 @Override 90 public void setValue(javax.swing.JComponent source, Object value) { 91 } 92 93 @Override 94 public void documentChanged(javax.swing.text.JTextComponent comp, String value) { 95 SectionView view = getSectionView(); 96 enableDisable(); 97 if (view != null) { 98 view.getErrorPanel().clearError(); 99 } 100 } 101 102 @Override 103 public void rollbackValue(javax.swing.text.JTextComponent source) { 104 } 105 106 @Override 107 protected void endUIChange() { } 108 109 public void linkButtonPressed(Object ddBean, String ddProperty) { } 110 111 public javax.swing.JComponent getErrorComponent(String errorId) { 112 return new JButton(); 113 } 114 115 private void enableDisable() { 116 boolean bSecurityEnabled = SecurityPolicyModelHelper.isSecurityEnabled(binding); 117 boolean oSecurityEnabled = SecurityPolicyModelHelper.isSecurityEnabled(operation); 118 119 boolean securityEnabled = bSecurityEnabled || oSecurityEnabled; 120 targetsButton.setEnabled(securityEnabled); 121 } 122 123 128 private void initComponents() { 130 131 targetsButton = new javax.swing.JButton (); 132 133 org.openide.awt.Mnemonics.setLocalizedText(targetsButton, org.openide.util.NbBundle.getMessage(FaultPanel.class, "LBL_SignEncrypt")); targetsButton.addActionListener(new java.awt.event.ActionListener () { 135 public void actionPerformed(java.awt.event.ActionEvent evt) { 136 targetsButtonActionPerformed(evt); 137 } 138 }); 139 140 org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this); 141 this.setLayout(layout); 142 layout.setHorizontalGroup( 143 layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 144 .add(layout.createSequentialGroup() 145 .addContainerGap() 146 .add(targetsButton) 147 .addContainerGap(156, Short.MAX_VALUE)) 148 ); 149 layout.setVerticalGroup( 150 layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 151 .add(layout.createSequentialGroup() 152 .addContainerGap() 153 .add(targetsButton) 154 .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) 155 ); 156 } 158 private void targetsButtonActionPerformed(java.awt.event.ActionEvent evt) { UndoCounter undoCounter = new UndoCounter(); 160 model.addUndoableEditListener(undoCounter); 161 162 TargetsPanel targetsPanel = new TargetsPanel(fault); DialogDescriptor dlgDesc = new DialogDescriptor(targetsPanel, 164 NbBundle.getMessage(InputPanel.class, "LBL_Targets_Panel_Title")); Dialog dlg = DialogDisplayer.getDefault().createDialog(dlgDesc); 166 167 dlg.setVisible(true); 168 if (dlgDesc.getValue() == dlgDesc.CANCEL_OPTION) { 169 for (int i=0; i<undoCounter.getCounter();i++) { 170 if (undoManager.canUndo()) { 171 undoManager.undo(); 172 } 173 } 174 } else { 175 SecurityPolicyModelHelper.setTargets(fault, targetsPanel.getTargetsModel()); 176 } 177 178 model.removeUndoableEditListener(undoCounter); 179 } 181 private javax.swing.JButton targetsButton; 183 185 } 186 | Popular Tags |