KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > java > editor > codegen > ui > EqualsHashCodePanel


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

19
20 package org.netbeans.modules.java.editor.codegen.ui;
21
22 import java.util.List JavaDoc;
23 import javax.lang.model.element.Element;
24 import javax.swing.JPanel JavaDoc;
25 import org.netbeans.api.java.source.ElementHandle;
26 import org.netbeans.modules.java.editor.codegen.EqualsHashCodeGenerator;
27 import org.openide.util.NbBundle;
28
29 /**
30  *
31  * @author Dusan Balek
32  */

33 public class EqualsHashCodePanel extends JPanel JavaDoc {
34
35     private ElementSelectorPanel equalsSelector;
36     private ElementSelectorPanel hashCodeSelector;
37
38     /** Creates new form EqualsHashCodePanel */
39     public EqualsHashCodePanel(ElementNode.Description description) {
40         initComponents();
41         equalsSelector = new ElementSelectorPanel(description, false);
42         java.awt.GridBagConstraints JavaDoc gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
43         gridBagConstraints.gridx = 0;
44         gridBagConstraints.gridy = 1;
45         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
46         gridBagConstraints.weightx = 0.5;
47         gridBagConstraints.weighty = 1.0;
48         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 12, 0, 12);
49         add(equalsSelector, gridBagConstraints);
50         
51         hashCodeSelector = new ElementSelectorPanel( ElementNode.Description.deepCopy(description), false);
52         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
53         gridBagConstraints.gridx = 1;
54         gridBagConstraints.gridy = 1;
55         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
56         gridBagConstraints.weightx = 0.5;
57         gridBagConstraints.weighty = 1.0;
58         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 0, 0, 12);
59         add(hashCodeSelector, gridBagConstraints);
60         
61         equalsLabel.setText(NbBundle.getMessage(EqualsHashCodeGenerator.class, "LBL_equals_select")); //NOI18N
62
equalsLabel.setLabelFor(equalsSelector);
63         hashCodeLabel.setText(NbBundle.getMessage(EqualsHashCodeGenerator.class, "LBL_hashcode_select")); //NOI18N
64
hashCodeLabel.setLabelFor(hashCodeSelector);
65     }
66     
67     
68     public List JavaDoc<ElementHandle<? extends Element>> getEqualsVariables() {
69         return ((ElementSelectorPanel)equalsSelector).getSelectedElements();
70     }
71
72     public List JavaDoc<ElementHandle<? extends Element>> getHashCodeVariables() {
73         return ((ElementSelectorPanel)hashCodeSelector).getSelectedElements();
74     }
75
76     /** This method is called from within the constructor to
77      * initialize the form.
78      * WARNING: Do NOT modify this code. The content of this method is
79      * always regenerated by the Form Editor.
80      */

81     // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
82
private void initComponents() {
83         java.awt.GridBagConstraints JavaDoc gridBagConstraints;
84
85         equalsLabel = new javax.swing.JLabel JavaDoc();
86         hashCodeLabel = new javax.swing.JLabel JavaDoc();
87
88         setLayout(new java.awt.GridBagLayout JavaDoc());
89
90         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
91         gridBagConstraints.gridx = 0;
92         gridBagConstraints.gridy = 0;
93         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
94         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
95         gridBagConstraints.weightx = 0.5;
96         gridBagConstraints.insets = new java.awt.Insets JavaDoc(12, 12, 6, 12);
97         add(equalsLabel, gridBagConstraints);
98
99         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
100         gridBagConstraints.gridx = 1;
101         gridBagConstraints.gridy = 0;
102         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
103         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
104         gridBagConstraints.weightx = 0.5;
105         gridBagConstraints.insets = new java.awt.Insets JavaDoc(12, 0, 6, 12);
106         add(hashCodeLabel, gridBagConstraints);
107     }// </editor-fold>//GEN-END:initComponents
108

109     
110     // Variables declaration - do not modify//GEN-BEGIN:variables
111
private javax.swing.JLabel JavaDoc equalsLabel;
112     private javax.swing.JLabel JavaDoc hashCodeLabel;
113     // End of variables declaration//GEN-END:variables
114

115 }
116
Popular Tags