1 19 20 package org.netbeans.modules.autoupdate; 21 22 import javax.swing.JPanel ; 23 import java.beans.*; 24 25 import org.openide.WizardDescriptor; 26 import org.openide.util.NbBundle; 27 28 33 class SetupPanel extends javax.swing.JPanel implements PropertyChangeListener { 34 35 private JPanel lPanel; 36 37 38 public SetupPanel() { 39 initComponents (); 40 jLabel1.setDisplayedMnemonic (getBundle ("AutoCheckInfo.jLabel2.mnemonic").charAt (0)); 41 jLabel1.setLabelFor (periodComboBox); 42 beforeCheckBox.setMnemonic (getBundle ("AutoCheckInfo.jCheckBox1.mnemonic").charAt (0)); 43 negativCheckBox.setMnemonic (getBundle ("AutoCheckInfo.jCheckBox2.mnemonic").charAt (0)); 44 setName(getBundle ("CTL_Settings_Name")); 45 putClientProperty ("WizardPanel_contentData", new String [] {getName ()}); putClientProperty ("WizardPanel_contentSelectedIndex", new Integer (0)); setPreferredSize(new java.awt.Dimension (500, 300)); 48 49 String [] tags = (new Settings.PeriodPropertyEditor()).getTags(); 50 for ( int i = 0; i < tags.length; i++ ) 51 periodComboBox.addItem( tags[i] ); 52 53 beforeCheckBox.getAccessibleContext().setAccessibleDescription(getBundle("ACS_AutoCheckInfo.jCheckBox1.text")); 54 negativCheckBox.getAccessibleContext().setAccessibleDescription(getBundle("ACS_AutoCheckInfo.jCheckBox2.text")); 55 getAccessibleContext().setAccessibleDescription(getBundle("ACS_AutoCheckInfo")); 56 periodComboBox.getAccessibleContext ().setAccessibleDescription (getBundle("ACS_AutoCheckInfo.jLabel2.text")); 58 59 initializePanel(); 60 } 61 62 67 private void initComponents() { java.awt.GridBagConstraints gridBagConstraints; 69 70 periodPanel = new javax.swing.JPanel (); 71 jLabel1 = new javax.swing.JLabel (); 72 periodComboBox = new javax.swing.JComboBox (); 73 checkPanel = new javax.swing.JPanel (); 74 beforeCheckBox = new javax.swing.JCheckBox (); 75 negativCheckBox = new javax.swing.JCheckBox (); 76 77 setLayout(new java.awt.GridBagLayout ()); 78 79 periodPanel.setLayout(new java.awt.GridBagLayout ()); 80 81 jLabel1.setText(getBundle("AutoCheckInfo.jLabel2.text")); 82 gridBagConstraints = new java.awt.GridBagConstraints (); 83 gridBagConstraints.gridx = 0; 84 gridBagConstraints.gridy = 0; 85 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 86 gridBagConstraints.ipadx = 8; 87 gridBagConstraints.ipady = 14; 88 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 89 periodPanel.add(jLabel1, gridBagConstraints); 90 91 gridBagConstraints = new java.awt.GridBagConstraints (); 92 gridBagConstraints.gridx = 1; 93 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 94 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 95 periodPanel.add(periodComboBox, gridBagConstraints); 96 97 gridBagConstraints = new java.awt.GridBagConstraints (); 98 gridBagConstraints.gridx = 0; 99 gridBagConstraints.gridy = 0; 100 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 101 gridBagConstraints.weightx = 1.0; 102 add(periodPanel, gridBagConstraints); 103 104 checkPanel.setLayout(new java.awt.GridBagLayout ()); 105 106 beforeCheckBox.setText(getBundle("AutoCheckInfo.jCheckBox1.text")); 107 gridBagConstraints = new java.awt.GridBagConstraints (); 108 gridBagConstraints.gridx = 0; 109 gridBagConstraints.gridy = 0; 110 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 111 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 112 gridBagConstraints.weightx = 1.0; 113 gridBagConstraints.insets = new java.awt.Insets (12, 20, 0, 0); 114 checkPanel.add(beforeCheckBox, gridBagConstraints); 115 116 negativCheckBox.setText(getBundle("AutoCheckInfo.jCheckBox2.text")); 117 gridBagConstraints = new java.awt.GridBagConstraints (); 118 gridBagConstraints.gridx = 0; 119 gridBagConstraints.gridy = 1; 120 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 121 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 122 gridBagConstraints.weightx = 1.0; 123 gridBagConstraints.insets = new java.awt.Insets (5, 20, 0, 0); 124 checkPanel.add(negativCheckBox, gridBagConstraints); 125 126 gridBagConstraints = new java.awt.GridBagConstraints (); 127 gridBagConstraints.gridx = 0; 128 gridBagConstraints.gridy = 1; 129 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 130 add(checkPanel, gridBagConstraints); 131 132 } 134 135 private javax.swing.JPanel periodPanel; 137 private javax.swing.JCheckBox negativCheckBox; 138 private javax.swing.JCheckBox beforeCheckBox; 139 private javax.swing.JPanel checkPanel; 140 private javax.swing.JComboBox periodComboBox; 141 private javax.swing.JLabel jLabel1; 142 144 146 private void initializePanel() { 147 Settings settings = Settings.getShared(); 148 int period = settings.getPeriod(); 149 150 beforeCheckBox.setSelected( settings.isAskBefore() ); 151 negativCheckBox.setSelected( settings.isNegativeResults() ); 152 153 periodComboBox.setSelectedIndex( period ); 154 155 if ( lPanel != null ) remove(lPanel); 156 lPanel = new ServerPanel(); 157 158 java.awt.GridBagConstraints gridBagConstraints1 = new java.awt.GridBagConstraints (); 159 gridBagConstraints1.gridx = 0; 160 gridBagConstraints1.gridy = 2; 161 gridBagConstraints1.insets = new java.awt.Insets (12, 20, 0, 0); 162 gridBagConstraints1.fill = java.awt.GridBagConstraints.BOTH; 163 gridBagConstraints1.weightx = 1.0; 164 gridBagConstraints1.weighty = 1.0; 165 add(lPanel, gridBagConstraints1); 166 } 167 168 172 public void initFromSettings(WizardDescriptor wd) { 173 wd.addPropertyChangeListener(this); 174 if (Boolean.TRUE.equals(wd.getProperty("initializePanel"))) 175 initializePanel(); 176 } 177 178 180 public void propertyChange(PropertyChangeEvent evt) { 181 if ((evt.getSource() instanceof WizardDescriptor) 182 && (WizardDescriptor.PROP_VALUE.equals(evt.getPropertyName()))) { 183 184 WizardDescriptor wd = (WizardDescriptor)evt.getSource(); 185 if (wd.getValue() == wd.FINISH_OPTION) { 186 wd.removePropertyChangeListener(this); 187 Settings settings = Settings.getShared(); 188 settings.setAskBefore( beforeCheckBox.isSelected() ); 189 settings.setNegativeResults( negativCheckBox.isSelected() ); 190 settings.setPeriod( periodComboBox.getSelectedIndex() ); 191 } 192 } 193 } 194 195 private static String getBundle( String key ) { 196 return NbBundle.getMessage( SetupPanel.class, key ); 197 } 198 } 199 | Popular Tags |