Changeset 16335
- Timestamp:
- 2008-07-10T13:30:55+12:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
gli/trunk/src/org/greenstone/gatherer/gui/WarningDialog.java
r14568 r16335 48 48 private JButton ok_button; 49 49 private JCheckBox show_check; 50 private J TextFieldvalue_field;50 private JComponent value_field; 51 51 private JPanel value_panel; 52 52 private String affected_property; 53 53 private String full_property; 54 55 56 public WarningDialog(String warning_name, String warning_title, String warning_message, String affected_property, boolean can_cancel) 54 /** Whether or not to display the checkbox that will turn off this dialog in future */ 55 private final boolean showcheckbox; 56 57 58 public WarningDialog(String warning_name, String warning_title, String warning_message, String affected_property, boolean can_cancel) 59 { 60 this(warning_name, warning_title, warning_message, affected_property, can_cancel, true); // true for show checkbox 61 } 62 63 64 public WarningDialog(String warning_name, String warning_title, String warning_message, String affected_property, boolean can_cancel, 65 boolean showcheckbox) 57 66 { 58 67 super(Gatherer.g_man, "Warning", true); 68 69 this.showcheckbox = showcheckbox; 59 70 60 71 // Determine the name of this prompt. … … 88 99 value_field = new JTextField(); 89 100 JPanel bottom_pane = new JPanel(); 90 show_check = new JCheckBox(Dictionary.get("WarningDialog.Dont_Show_Again"));91 101 JPanel control_pane = new JPanel(); 92 102 ok_button = new GLIButton(Dictionary.get("General.OK"), Dictionary.get("General.OK_Tooltip")); … … 129 139 bottom_pane.setBorder(BorderFactory.createEmptyBorder(5,0,0,0)); 130 140 bottom_pane.setLayout(new BorderLayout()); 131 bottom_pane.add(show_check, BorderLayout.CENTER);132 141 bottom_pane.add(control_pane, BorderLayout.EAST); 142 if(showcheckbox) { 143 show_check = new JCheckBox(Dictionary.get("WarningDialog.Dont_Show_Again")); 144 bottom_pane.add(show_check, BorderLayout.CENTER); 145 } 133 146 134 147 content_pane.setBorder(BorderFactory.createEmptyBorder(5,5,5,5)); … … 150 163 151 164 public void actionPerformed(ActionEvent event) { 152 boolean bad_value = false;165 boolean valid_value = true; 153 166 if(event.getSource() == ok_button) { 154 167 if(affected_property != null && Configuration.self != null) { 155 String value = value_field.getText(); 156 if(value.length() > 0) { 157 if(value_field instanceof URLField) { 158 bad_value = !((URLField)value_field).validateURL(); 159 } 160 if(!bad_value) { 161 // Store the value of the property 162 Configuration.setString(affected_property, true, value_field.getText()); 163 } 168 valid_value = URLField.validateURL(value_field); 169 if(valid_value) { 170 // Store the value of the property 171 URLField.store(value_field, affected_property); //Configuration.setString(affected_property, true, value); 164 172 } 165 173 } 166 if( !bad_value) {174 if(valid_value) { 167 175 result = JOptionPane.OK_OPTION; 168 176 } 169 } 170 if(!bad_value) { 171 if (Configuration.self != null) { 177 } 178 179 if(valid_value) { 180 if (Configuration.self != null && showcheckbox) { 172 181 // Store the state of the show message checkbox. 173 182 Configuration.set(full_property, true, !show_check.isSelected()); … … 182 191 183 192 /** Gives notification of key events on the buttons */ 184 public void keyPressed(KeyEvent e) { 193 public void keyPressed(KeyEvent e) {} 194 195 public void keyReleased(KeyEvent e) { 185 196 if (e.getKeyCode() == KeyEvent.VK_ENTER) { 186 197 // Enter: Click the button in focus … … 192 203 } 193 204 194 public void keyReleased(KeyEvent e) { } 195 196 public void keyTyped(KeyEvent e) { } 205 public void keyTyped(KeyEvent e) {} 197 206 198 207 … … 216 225 */ 217 226 public void setMessageOnly(boolean message_only) { 227 if(!showcheckbox) { 228 return; 229 } 230 218 231 // If this is a message then change the checkbox 219 232 if(message_only) { … … 229 242 * @param control the JTextField subclass you want to use for the control 230 243 */ 231 public void setValueField(J TextFieldcontrol) {244 public void setValueField(JComponent control) { 232 245 // Remove the current control 233 246 value_panel.remove(value_field); … … 253 266 254 267 public void setValueField(String field_value){ 255 this.value_field.setText(field_value);268 URLField.setText(this.value_field, field_value); 256 269 } 257 270
Note:
See TracChangeset
for help on using the changeset viewer.