1 19 20 25 26 package org.netbeans.modules.xml.wsdl.ui.view; 27 28 import java.util.Collection ; 29 import java.util.Vector ; 30 import javax.swing.DefaultComboBoxModel ; 31 import javax.swing.JList ; 32 import org.netbeans.modules.xml.wsdl.model.Operation; 33 34 38 public class BindingOperationView extends javax.swing.JPanel { 39 40 private Operation mSelectedOperation; 41 42 private Collection <Operation> mOperations; 43 44 private Object [] mSelectedOperations; 45 46 47 50 public BindingOperationView(Collection <Operation> operations) { 51 mOperations = operations; 52 initComponents(); 53 } 54 55 60 private void initComponents() { 62 jScrollPane1 = new javax.swing.JScrollPane (); 63 jList1 = new javax.swing.JList (); 64 65 jList1.setModel(new DefaultComboBoxModel (getAllOperationNames())); 66 jList1.setToolTipText(org.openide.util.NbBundle.getMessage(BindingOperationView.class, "BindingOperationView.jList1.toolTipText")); jList1.addListSelectionListener(new javax.swing.event.ListSelectionListener () { 68 public void valueChanged(javax.swing.event.ListSelectionEvent 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")); 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 } 88 private void jList1ValueChanged(javax.swing.event.ListSelectionEvent evt) { JList list = (JList ) evt.getSource(); 90 if (!list.getValueIsAdjusting()) { 91 mSelectedOperations = jList1.getSelectedValues(); 92 } 93 } 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 o : mSelectedOperations) { 102 OperationDelegate od = (OperationDelegate)o; 103 operations[i] = od.getOperation(); 104 i++; 105 } 106 return operations; 107 } 108 109 private Vector getAllOperationNames() { 110 111 if (mOperations != null) { 112 Vector <OperationDelegate> listData = new Vector <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 toString() { 135 return this.mOperation.getName(); 136 } 137 } 138 139 private javax.swing.JList jList1; 141 private javax.swing.JScrollPane jScrollPane1; 142 144 } 145 | Popular Tags |