1 19 package org.netbeans.modules.languages.javascript.refactoring; 20 21 import java.awt.Component ; 22 import javax.swing.JPanel ; 23 import javax.swing.event.ChangeListener ; 24 import javax.swing.event.DocumentEvent ; 25 import javax.swing.event.DocumentListener ; 26 import org.netbeans.modules.refactoring.spi.ui.CustomRefactoringPanel; 27 28 29 34 public class RenamePanel extends JPanel implements CustomRefactoringPanel { 35 36 private final transient String oldName; 37 private final transient ChangeListener parent; 38 39 40 public RenamePanel(String oldName, ChangeListener parent, String name) { 41 setName(name); 42 this.oldName = oldName; 43 this.parent = parent; 44 initComponents(); 45 updateReferencesCheckBox.setVisible(false); 46 nameField.requestFocus(); 49 nameField.getDocument().addDocumentListener(new DocumentListener () { 50 public void changedUpdate(DocumentEvent event) { 51 RenamePanel.this.parent.stateChanged(null); 52 } 53 public void insertUpdate(DocumentEvent event) { 54 RenamePanel.this.parent.stateChanged(null); 55 } 56 public void removeUpdate(DocumentEvent event) { 57 RenamePanel.this.parent.stateChanged(null); 58 } 59 }); 60 } 61 62 private boolean initialized = false; 63 public void initialize() { 64 if (initialized) 65 return ; 66 initialized = true; 68 } 69 70 public void requestFocus() { 71 nameField.requestFocus(); 72 } 73 74 79 private void initComponents() { 81 java.awt.GridBagConstraints gridBagConstraints; 82 83 label = new javax.swing.JLabel (); 84 nameField = new javax.swing.JTextField (); 85 jPanel1 = new javax.swing.JPanel (); 86 updateReferencesCheckBox = new javax.swing.JCheckBox (); 87 88 setBorder(javax.swing.BorderFactory.createEmptyBorder(12, 12, 11, 11)); 89 setLayout(new java.awt.GridBagLayout ()); 90 91 label.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); 92 label.setLabelFor(nameField); 93 org.openide.awt.Mnemonics.setLocalizedText(label, org.openide.util.NbBundle.getMessage(RenamePanel.class, "LBL_NewName")); add(label, new java.awt.GridBagConstraints ()); 95 96 nameField.setText(oldName); 97 nameField.selectAll(); 98 gridBagConstraints = new java.awt.GridBagConstraints (); 99 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 100 gridBagConstraints.weightx = 1.0; 101 add(nameField, gridBagConstraints); 102 nameField.getAccessibleContext().setAccessibleDescription(null); 103 104 jPanel1.setMinimumSize(new java.awt.Dimension (0, 0)); 105 jPanel1.setPreferredSize(new java.awt.Dimension (0, 0)); 106 gridBagConstraints = new java.awt.GridBagConstraints (); 107 gridBagConstraints.gridx = 0; 108 gridBagConstraints.gridy = 2; 109 gridBagConstraints.gridwidth = 2; 110 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 111 gridBagConstraints.weightx = 1.0; 112 gridBagConstraints.weighty = 1.0; 113 add(jPanel1, gridBagConstraints); 114 115 updateReferencesCheckBox.setBorder(javax.swing.BorderFactory.createEmptyBorder(4, 4, 0, 4)); 116 updateReferencesCheckBox.setMargin(new java.awt.Insets (2, 2, 0, 2)); 117 updateReferencesCheckBox.addActionListener(new java.awt.event.ActionListener () { 118 public void actionPerformed(java.awt.event.ActionEvent evt) { 119 updateReferencesCheckBoxActionPerformed(evt); 120 } 121 }); 122 gridBagConstraints = new java.awt.GridBagConstraints (); 123 gridBagConstraints.gridx = 0; 124 gridBagConstraints.gridy = 3; 125 gridBagConstraints.gridwidth = 2; 126 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 127 add(updateReferencesCheckBox, gridBagConstraints); 128 } 130 private void updateReferencesCheckBoxActionPerformed(java.awt.event.ActionEvent evt) { } 133 private javax.swing.JPanel jPanel1; 135 private javax.swing.JLabel label; 136 private javax.swing.JTextField nameField; 137 private javax.swing.JCheckBox updateReferencesCheckBox; 138 140 public String getNameValue() { 141 return nameField.getText(); 142 } 143 144 public boolean isUpdateReferences() { 145 if (updateReferencesCheckBox.isVisible() && updateReferencesCheckBox.isSelected()) 146 return false; 147 return true; 148 } 149 150 public Component getComponent() { 151 return this; 152 } 153 } 154 | Popular Tags |