KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > websvc > wsitconf > ui > service > FaultPanel


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.websvc.wsitconf.ui.service;
21
22 import java.awt.Dialog JavaDoc;
23 import javax.swing.undo.UndoManager JavaDoc;
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 /**
43  *
44  * @author Martin Grebac
45  */

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 JavaDoc undoManager;
54     private boolean inSync = false;
55
56     public FaultPanel(SectionView view, Node node, BindingFault fault, UndoManager JavaDoc 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 JavaDoc
90     public void setValue(javax.swing.JComponent JavaDoc source, Object JavaDoc value) {
91     }
92     
93     @Override JavaDoc
94     public void documentChanged(javax.swing.text.JTextComponent JavaDoc comp, String JavaDoc value) {
95         SectionView view = getSectionView();
96         enableDisable();
97         if (view != null) {
98             view.getErrorPanel().clearError();
99         }
100     }
101
102     @Override JavaDoc
103     public void rollbackValue(javax.swing.text.JTextComponent JavaDoc source) {
104     }
105     
106     @Override JavaDoc
107     protected void endUIChange() { }
108
109     public void linkButtonPressed(Object JavaDoc ddBean, String JavaDoc ddProperty) { }
110
111     public javax.swing.JComponent JavaDoc getErrorComponent(String JavaDoc 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     /** This method is called from within the constructor to
124      * initialize the form.
125      * WARNING: Do NOT modify this code. The content of this method is
126      * always regenerated by the Form Editor.
127      */

128     // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
129
private void initComponents() {
130
131         targetsButton = new javax.swing.JButton JavaDoc();
132
133         org.openide.awt.Mnemonics.setLocalizedText(targetsButton, org.openide.util.NbBundle.getMessage(FaultPanel.class, "LBL_SignEncrypt")); // NOI18N
134
targetsButton.addActionListener(new java.awt.event.ActionListener JavaDoc() {
135             public void actionPerformed(java.awt.event.ActionEvent JavaDoc 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     }// </editor-fold>//GEN-END:initComponents
157

158     private void targetsButtonActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_targetsButtonActionPerformed
159
UndoCounter undoCounter = new UndoCounter();
160         model.addUndoableEditListener(undoCounter);
161
162         TargetsPanel targetsPanel = new TargetsPanel(fault); //NOI18N
163
DialogDescriptor dlgDesc = new DialogDescriptor(targetsPanel,
164                 NbBundle.getMessage(InputPanel.class, "LBL_Targets_Panel_Title")); //NOI18N
165
Dialog JavaDoc 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     }//GEN-LAST:event_targetsButtonActionPerformed
180

181     // Variables declaration - do not modify//GEN-BEGIN:variables
182
private javax.swing.JButton JavaDoc targetsButton;
183     // End of variables declaration//GEN-END:variables
184

185 }
186
Popular Tags