1 19 20 package org.netbeans.modules.java.editor.codegen.ui; 21 22 import java.util.List ; 23 import javax.lang.model.element.Element; 24 import javax.swing.JPanel ; 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 33 public class EqualsHashCodePanel extends JPanel { 34 35 private ElementSelectorPanel equalsSelector; 36 private ElementSelectorPanel hashCodeSelector; 37 38 39 public EqualsHashCodePanel(ElementNode.Description description) { 40 initComponents(); 41 equalsSelector = new ElementSelectorPanel(description, false); 42 java.awt.GridBagConstraints gridBagConstraints = new java.awt.GridBagConstraints (); 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 (0, 12, 0, 12); 49 add(equalsSelector, gridBagConstraints); 50 51 hashCodeSelector = new ElementSelectorPanel( ElementNode.Description.deepCopy(description), false); 52 gridBagConstraints = new java.awt.GridBagConstraints (); 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 (0, 0, 0, 12); 59 add(hashCodeSelector, gridBagConstraints); 60 61 equalsLabel.setText(NbBundle.getMessage(EqualsHashCodeGenerator.class, "LBL_equals_select")); equalsLabel.setLabelFor(equalsSelector); 63 hashCodeLabel.setText(NbBundle.getMessage(EqualsHashCodeGenerator.class, "LBL_hashcode_select")); hashCodeLabel.setLabelFor(hashCodeSelector); 65 } 66 67 68 public List <ElementHandle<? extends Element>> getEqualsVariables() { 69 return ((ElementSelectorPanel)equalsSelector).getSelectedElements(); 70 } 71 72 public List <ElementHandle<? extends Element>> getHashCodeVariables() { 73 return ((ElementSelectorPanel)hashCodeSelector).getSelectedElements(); 74 } 75 76 81 private void initComponents() { 83 java.awt.GridBagConstraints gridBagConstraints; 84 85 equalsLabel = new javax.swing.JLabel (); 86 hashCodeLabel = new javax.swing.JLabel (); 87 88 setLayout(new java.awt.GridBagLayout ()); 89 90 gridBagConstraints = new java.awt.GridBagConstraints (); 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 (12, 12, 6, 12); 97 add(equalsLabel, gridBagConstraints); 98 99 gridBagConstraints = new java.awt.GridBagConstraints (); 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 (12, 0, 6, 12); 106 add(hashCodeLabel, gridBagConstraints); 107 } 109 110 private javax.swing.JLabel equalsLabel; 112 private javax.swing.JLabel hashCodeLabel; 113 115 } 116 | Popular Tags |