1 19 20 package org.netbeans.modules.project.ui.groups; 21 22 27 public class AdHocGroupEditPanel extends GroupEditPanel { 28 29 private final AdHocGroup g; 30 31 public AdHocGroupEditPanel(AdHocGroup g) { 32 this.g = g; 33 initComponents(); 34 nameField.setText(g.getName()); 35 autoSynchCheckbox.setSelected(g.isAutoSynch()); 36 updateSynchButton(); 37 } 38 39 public void applyChanges() { 40 g.setName(nameField.getText().trim()); 41 g.setAutoSynch(autoSynchCheckbox.isSelected()); 42 } 43 44 private void updateSynchButton() { 45 synchButton.setEnabled(!autoSynchCheckbox.isSelected() && !g.isPristine()); 46 } 47 48 53 private void initComponents() { 55 56 nameLabel = new javax.swing.JLabel (); 57 nameField = new javax.swing.JTextField (); 58 autoSynchCheckbox = new javax.swing.JCheckBox (); 59 synchButton = new javax.swing.JButton (); 60 61 nameLabel.setLabelFor(nameField); 62 org.openide.awt.Mnemonics.setLocalizedText(nameLabel, org.openide.util.NbBundle.getMessage(AdHocGroupEditPanel.class, "AdHocGroupEditPanel.nameLabel.text")); 64 org.openide.awt.Mnemonics.setLocalizedText(autoSynchCheckbox, org.openide.util.NbBundle.getMessage(AdHocGroupEditPanel.class, "AdHocGroupEditPanel.autoSynchCheckbox.text")); autoSynchCheckbox.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); 66 autoSynchCheckbox.setMargin(new java.awt.Insets (0, 0, 0, 0)); 67 autoSynchCheckbox.addActionListener(new java.awt.event.ActionListener () { 68 public void actionPerformed(java.awt.event.ActionEvent evt) { 69 autoSynchCheckboxActionPerformed(evt); 70 } 71 }); 72 73 org.openide.awt.Mnemonics.setLocalizedText(synchButton, org.openide.util.NbBundle.getMessage(AdHocGroupEditPanel.class, "AdHocGroupEditPanel.synchButton.text")); synchButton.addActionListener(new java.awt.event.ActionListener () { 75 public void actionPerformed(java.awt.event.ActionEvent evt) { 76 synchButtonActionPerformed(evt); 77 } 78 }); 79 80 org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this); 81 this.setLayout(layout); 82 layout.setHorizontalGroup( 83 layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 84 .add(layout.createSequentialGroup() 85 .addContainerGap() 86 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 87 .add(layout.createSequentialGroup() 88 .add(nameLabel) 89 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 90 .add(nameField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 363, Short.MAX_VALUE)) 91 .add(autoSynchCheckbox) 92 .add(layout.createSequentialGroup() 93 .add(synchButton) 94 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 272, Short.MAX_VALUE))) 95 .addContainerGap()) 96 ); 97 layout.setVerticalGroup( 98 layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 99 .add(layout.createSequentialGroup() 100 .addContainerGap() 101 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) 102 .add(nameLabel) 103 .add(nameField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) 104 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 105 .add(autoSynchCheckbox) 106 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 107 .add(synchButton) 108 .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) 109 ); 110 } 112 private void synchButtonActionPerformed(java.awt.event.ActionEvent evt) { g.synch(); 114 updateSynchButton(); 115 } 117 private void autoSynchCheckboxActionPerformed(java.awt.event.ActionEvent evt) { updateSynchButton(); 119 } 121 122 private javax.swing.JCheckBox autoSynchCheckbox; 124 private javax.swing.JTextField nameField; 125 private javax.swing.JLabel nameLabel; 126 private javax.swing.JButton synchButton; 127 129 } 130 | Popular Tags |