KickJava   Java API By Example, From Geeks To Geeks.

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


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.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 /**
43  *
44  * @author Martin Grebac
45  */

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

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

163     private void targetsButtonActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_targetsButtonActionPerformed
164
UndoCounter undoCounter = new UndoCounter();
165         model.addUndoableEditListener(undoCounter);
166
167         TargetsPanel targetsPanel = new TargetsPanel(output); //NOI18N
168
DialogDescriptor dlgDesc = new DialogDescriptor(targetsPanel,
169                 NbBundle.getMessage(InputPanel.class, "LBL_Targets_Panel_Title")); //NOI18N
170
Dialog JavaDoc 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     }//GEN-LAST:event_targetsButtonActionPerformed
185

186     // Variables declaration - do not modify//GEN-BEGIN:variables
187
private javax.swing.JButton JavaDoc targetsButton;
188     // End of variables declaration//GEN-END:variables
189

190 }
191
Popular Tags