KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > wsdl > ui > view > BindingOperationView


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 1997-2007 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 /*
21  * BindingOperationView.java
22  *
23  * Created on July 28, 2006, 5:03 PM
24  */

25
26 package org.netbeans.modules.xml.wsdl.ui.view;
27
28 import java.util.Collection JavaDoc;
29 import java.util.Vector JavaDoc;
30 import javax.swing.DefaultComboBoxModel JavaDoc;
31 import javax.swing.JList JavaDoc;
32 import org.netbeans.modules.xml.wsdl.model.Operation;
33
34 /**
35  *
36  * @author skini
37  */

38 public class BindingOperationView extends javax.swing.JPanel JavaDoc {
39     
40     private Operation mSelectedOperation;
41     
42     private Collection JavaDoc<Operation> mOperations;
43     
44     private Object JavaDoc[] mSelectedOperations;
45     
46     
47     /**
48      * Creates new form BindingOperationView
49      */

50     public BindingOperationView(Collection JavaDoc<Operation> operations) {
51         mOperations = operations;
52         initComponents();
53     }
54     
55     /** This method is called from within the constructor to
56      * initialize the form.
57      * WARNING: Do NOT modify this code. The content of this method is
58      * always regenerated by the Form Editor.
59      */

60     // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
61
private void initComponents() {
62         jScrollPane1 = new javax.swing.JScrollPane JavaDoc();
63         jList1 = new javax.swing.JList JavaDoc();
64
65         jList1.setModel(new DefaultComboBoxModel JavaDoc(getAllOperationNames()));
66         jList1.setToolTipText(org.openide.util.NbBundle.getMessage(BindingOperationView.class, "BindingOperationView.jList1.toolTipText")); // NOI18N
67
jList1.addListSelectionListener(new javax.swing.event.ListSelectionListener JavaDoc() {
68             public void valueChanged(javax.swing.event.ListSelectionEvent JavaDoc evt) {
69                 jList1ValueChanged(evt);
70             }
71         });
72
73         jScrollPane1.setViewportView(jList1);
74         jList1.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(BindingOperationView.class, "BindingOperationView.jList1.toolTipText")); // NOI18N
75

76         org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
77         this.setLayout(layout);
78         layout.setHorizontalGroup(
79             layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
80             .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 207, Short.MAX_VALUE)
81         );
82         layout.setVerticalGroup(
83             layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
84             .add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 201, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
85         );
86     }// </editor-fold>//GEN-END:initComponents
87

88     private void jList1ValueChanged(javax.swing.event.ListSelectionEvent JavaDoc evt) {//GEN-FIRST:event_jList1ValueChanged
89
JList JavaDoc list = (JList JavaDoc) evt.getSource();
90         if (!list.getValueIsAdjusting()) {
91             mSelectedOperations = jList1.getSelectedValues();
92         }
93     }//GEN-LAST:event_jList1ValueChanged
94

95     public Operation getSelectedOperation() {
96         return this.mSelectedOperation;
97     }
98     public Operation[] getSelectedOperations() {
99         Operation[] operations = new Operation[mSelectedOperations.length];
100         int i = 0;
101         for(Object JavaDoc o : mSelectedOperations) {
102             OperationDelegate od = (OperationDelegate)o;
103             operations[i] = od.getOperation();
104             i++;
105         }
106         return operations;
107     }
108     
109     private Vector JavaDoc getAllOperationNames() {
110         
111         if (mOperations != null) {
112             Vector JavaDoc<OperationDelegate> listData = new Vector JavaDoc<OperationDelegate>(mOperations.size());
113             for(Operation operation : mOperations) {
114                 OperationDelegate opD = new OperationDelegate(operation);
115                 listData.add(opD);
116             }
117             return listData;
118         }
119         
120         return null;
121     }
122     
123     private class OperationDelegate {
124         private Operation mOperation;
125         
126         OperationDelegate(Operation operation) {
127             this.mOperation = operation;
128         }
129         
130         public Operation getOperation() {
131             return this.mOperation;
132         }
133         
134         public String JavaDoc toString() {
135             return this.mOperation.getName();
136         }
137     }
138     
139     // Variables declaration - do not modify//GEN-BEGIN:variables
140
private javax.swing.JList JavaDoc jList1;
141     private javax.swing.JScrollPane JavaDoc jScrollPane1;
142     // End of variables declaration//GEN-END:variables
143

144 }
145
Popular Tags