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