1 19 20 25 26 package org.netbeans.modules.xml.wsdl.ui.view; 27 28 import java.util.ArrayList ; 29 import java.util.List ; 30 31 import javax.swing.DefaultComboBoxModel ; 32 import javax.swing.JList ; 33 import javax.xml.namespace.QName ; 34 35 import org.netbeans.modules.xml.wsdl.ui.netbeans.module.Utility; 36 37 41 public class RemoveAttributesDialog extends javax.swing.JDialog { 42 43 46 private static final long serialVersionUID = 9101647145416743883L; 47 48 public RemoveAttributesDialog(java.awt.Frame parent, boolean modal) { 49 super(parent, modal); 50 initComponents(); 52 } 53 54 59 private void initComponents() { 61 jButton2 = new javax.swing.JButton (); 62 jButton1 = new javax.swing.JButton (); 63 jList1 = new javax.swing.JList (); 64 65 setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); 66 java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("org/netbeans/modules/xml/wsdl/ui/view/Bundle"); jButton2.setText(bundle.getString("RemoveAttributesPanel_BTN_Delete")); jButton2.setEnabled(false); 69 jButton2.addActionListener(new java.awt.event.ActionListener () { 70 public void actionPerformed(java.awt.event.ActionEvent evt) { 71 jButton2ActionPerformed(evt); 72 } 73 }); 74 75 jButton1.setText(bundle.getString("RemoveAttributesPanel_BTN_Cancel")); jButton1.addActionListener(new java.awt.event.ActionListener () { 77 public void actionPerformed(java.awt.event.ActionEvent evt) { 78 jButton1ActionPerformed(evt); 79 } 80 }); 81 82 jList1.addListSelectionListener(new javax.swing.event.ListSelectionListener () { 83 public void valueChanged(javax.swing.event.ListSelectionEvent evt) { 84 jList1ValueChanged(evt); 85 } 86 }); 87 88 org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane()); 89 getContentPane().setLayout(layout); 90 layout.setHorizontalGroup( 91 layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 92 .add(jList1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 236, Short.MAX_VALUE) 93 .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup() 94 .addContainerGap(88, Short.MAX_VALUE) 95 .add(jButton2) 96 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 97 .add(jButton1) 98 .addContainerGap()) 99 ); 100 layout.setVerticalGroup( 101 layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 102 .add(layout.createSequentialGroup() 103 .add(jList1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 241, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) 104 .add(14, 14, 14) 105 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) 106 .add(jButton1) 107 .add(jButton2)) 108 .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) 109 ); 110 pack(); 111 } 113 private void jList1ValueChanged(javax.swing.event.ListSelectionEvent evt) { if (!evt.getValueIsAdjusting()) { 115 JList list = (JList ) evt.getSource(); 116 Object [] selectedValues = list.getSelectedValues(); 117 if (selectedValues != null && selectedValues.length > 0) { 118 jButton2.setEnabled(true); 119 } else { 120 jButton2.setEnabled(false); 121 } 122 } 123 } 125 private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { this.setVisible(false); 127 } 129 private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) { attributes = jList1.getSelectedValues(); 131 this.setVisible(false); 132 } 134 135 public void setAttributes(List attributeList) { 136 ArrayList <String > list = new ArrayList <String >(); 137 if (attributeList != null) { 138 for (int i = 0; i < attributeList.size(); i++) { 139 QName qname = (QName ) attributeList.get(i); 140 list.add(Utility.fromQNameToString(qname)); 141 } 142 } 143 DefaultComboBoxModel model = new DefaultComboBoxModel (list.toArray()); 144 jList1.setModel(model); 145 } 146 147 public Object [] getAttributes() { 148 return attributes; 149 } 150 151 private Object [] attributes; 152 private javax.swing.JButton jButton1; 154 private javax.swing.JButton jButton2; 155 private javax.swing.JList jList1; 156 158 } 159 | Popular Tags |