KickJava   Java API By Example, From Geeks To Geeks.

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


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  * RemoveAttributesDialog.java
22  *
23  * Created on May 26, 2006, 4:53 PM
24  */

25
26 package org.netbeans.modules.xml.wsdl.ui.view;
27
28 import java.util.ArrayList JavaDoc;
29 import java.util.List JavaDoc;
30
31 import javax.swing.DefaultComboBoxModel JavaDoc;
32 import javax.swing.JList JavaDoc;
33 import javax.xml.namespace.QName JavaDoc;
34
35 import org.netbeans.modules.xml.wsdl.ui.netbeans.module.Utility;
36
37 /**
38  *
39  * @author skini
40  */

41 public class RemoveAttributesDialog extends javax.swing.JDialog JavaDoc {
42
43     /**
44      *
45      */

46     private static final long serialVersionUID = 9101647145416743883L;
47     /** Creates new form RemoveAttributesDialog */
48     public RemoveAttributesDialog(java.awt.Frame JavaDoc parent, boolean modal) {
49         super(parent, modal);
50         //getContentPane().add(topPanel, BorderLayout.NORTH);
51
initComponents();
52     }
53     
54     /** This method is called from within the constructor to
55      * initialize the form.
56      * WARNING: Do NOT modify this code. The content of this method is
57      * always regenerated by the Form Editor.
58      */

59     // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
60
private void initComponents() {
61         jButton2 = new javax.swing.JButton JavaDoc();
62         jButton1 = new javax.swing.JButton JavaDoc();
63         jList1 = new javax.swing.JList JavaDoc();
64
65         setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
66         java.util.ResourceBundle JavaDoc bundle = java.util.ResourceBundle.getBundle("org/netbeans/modules/xml/wsdl/ui/view/Bundle"); // NOI18N
67
jButton2.setText(bundle.getString("RemoveAttributesPanel_BTN_Delete")); // NOI18N
68
jButton2.setEnabled(false);
69         jButton2.addActionListener(new java.awt.event.ActionListener JavaDoc() {
70             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
71                 jButton2ActionPerformed(evt);
72             }
73         });
74
75         jButton1.setText(bundle.getString("RemoveAttributesPanel_BTN_Cancel")); // NOI18N
76
jButton1.addActionListener(new java.awt.event.ActionListener JavaDoc() {
77             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
78                 jButton1ActionPerformed(evt);
79             }
80         });
81
82         jList1.addListSelectionListener(new javax.swing.event.ListSelectionListener JavaDoc() {
83             public void valueChanged(javax.swing.event.ListSelectionEvent JavaDoc 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     }// </editor-fold>//GEN-END:initComponents
112

113     private void jList1ValueChanged(javax.swing.event.ListSelectionEvent JavaDoc evt) {//GEN-FIRST:event_jList1ValueChanged
114
if (!evt.getValueIsAdjusting()) {
115             JList JavaDoc list = (JList JavaDoc) evt.getSource();
116             Object JavaDoc[] selectedValues = list.getSelectedValues();
117             if (selectedValues != null && selectedValues.length > 0) {
118                 jButton2.setEnabled(true);
119             } else {
120                 jButton2.setEnabled(false);
121             }
122         }
123     }//GEN-LAST:event_jList1ValueChanged
124

125     private void jButton1ActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_jButton1ActionPerformed
126
this.setVisible(false);
127     }//GEN-LAST:event_jButton1ActionPerformed
128

129     private void jButton2ActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_jButton2ActionPerformed
130
attributes = jList1.getSelectedValues();
131         this.setVisible(false);
132     }//GEN-LAST:event_jButton2ActionPerformed
133

134
135     public void setAttributes(List JavaDoc attributeList) {
136         ArrayList JavaDoc<String JavaDoc> list = new ArrayList JavaDoc<String JavaDoc>();
137         if (attributeList != null) {
138             for (int i = 0; i < attributeList.size(); i++) {
139                 QName JavaDoc qname = (QName JavaDoc) attributeList.get(i);
140                 list.add(Utility.fromQNameToString(qname));
141             }
142         }
143         DefaultComboBoxModel JavaDoc model = new DefaultComboBoxModel JavaDoc(list.toArray());
144         jList1.setModel(model);
145     }
146     
147     public Object JavaDoc[] getAttributes() {
148         return attributes;
149     }
150     
151     private Object JavaDoc[] attributes;
152     // Variables declaration - do not modify//GEN-BEGIN:variables
153
private javax.swing.JButton JavaDoc jButton1;
154     private javax.swing.JButton JavaDoc jButton2;
155     private javax.swing.JList JavaDoc jList1;
156     // End of variables declaration//GEN-END:variables
157

158 }
159
Popular Tags