- Timestamp:
- 2009-01-12T11:40:15+13:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
gli/branches/rtl-gli/src/org/greenstone/gatherer/gui/WarningDialog.java
r18297 r18364 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); 59 68 this.setComponentOrientation(Dictionary.getOrientation()); 69 this.showcheckbox = showcheckbox; 70 60 71 // Determine the name of this prompt. 61 72 this.affected_property = affected_property; … … 76 87 JPanel text_pane = new JPanel(); 77 88 text_pane.setComponentOrientation(Dictionary.getOrientation()); 78 JLabel icon_label = new JLabel(JarTools.getImage("gatherer_medium.gif")); 89 90 String gmedium_image = "gatherer_medium.gif"; 91 if (Configuration.fedora_info.isActive()) { 92 gmedium_image = "fli-" + gmedium_image; 93 } 94 95 JLabel icon_label = new JLabel(JarTools.getImage(gmedium_image)); 79 96 icon_label.setComponentOrientation(Dictionary.getOrientation()); 80 97 81 98 JTextArea text_area = new JTextArea(); 82 99 text_area.setComponentOrientation(Dictionary.getOrientation()); … … 96 113 JPanel bottom_pane = new JPanel(); 97 114 bottom_pane.setComponentOrientation(Dictionary.getOrientation()); 98 show_check = new JCheckBox(Dictionary.get("WarningDialog.Dont_Show_Again")); 99 show_check.setComponentOrientation(Dictionary.getOrientation()); 115 100 116 JPanel control_pane = new JPanel(); 101 117 control_pane.setComponentOrientation(Dictionary.getOrientation()); … … 139 155 bottom_pane.setBorder(BorderFactory.createEmptyBorder(5,0,0,0)); 140 156 bottom_pane.setLayout(new BorderLayout()); 141 bottom_pane.add(show_check, BorderLayout.CENTER);142 157 bottom_pane.add(control_pane, BorderLayout.LINE_END); 158 if(showcheckbox) { 159 show_check = new JCheckBox(Dictionary.get("WarningDialog.Dont_Show_Again")); 160 show_check.setComponentOrientation(Dictionary.getOrientation()); 161 bottom_pane.add(show_check, BorderLayout.CENTER); 162 } 143 163 144 164 content_pane.setBorder(BorderFactory.createEmptyBorder(5,5,5,5)); … … 160 180 161 181 public void actionPerformed(ActionEvent event) { 162 boolean bad_value = false;182 boolean valid_value = true; 163 183 if(event.getSource() == ok_button) { 164 184 if(affected_property != null && Configuration.self != null) { 165 String value = value_field.getText(); 166 if(value.length() > 0) { 167 if(value_field instanceof URLField) { 168 bad_value = !((URLField)value_field).validateURL(); 169 } 170 if(!bad_value) { 171 // Store the value of the property 172 Configuration.setString(affected_property, true, value_field.getText()); 173 } 185 valid_value = URLField.validateURL(value_field); 186 if(valid_value) { 187 // Store the value of the property 188 URLField.store(value_field, affected_property); //Configuration.setString(affected_property, true, value); 174 189 } 175 190 } 176 if( !bad_value) {191 if(valid_value) { 177 192 result = JOptionPane.OK_OPTION; 178 193 } 179 } 180 if(!bad_value) { 181 if (Configuration.self != null) { 194 } 195 196 if(valid_value) { 197 if (Configuration.self != null && showcheckbox) { 182 198 // Store the state of the show message checkbox. 183 199 Configuration.set(full_property, true, !show_check.isSelected()); … … 202 218 } 203 219 204 public void keyReleased(KeyEvent e) { 205 206 public void keyTyped(KeyEvent e) { 220 public void keyReleased(KeyEvent e) {} 221 222 public void keyTyped(KeyEvent e) {} 207 223 208 224 … … 226 242 */ 227 243 public void setMessageOnly(boolean message_only) { 244 if(!showcheckbox) { 245 return; 246 } 247 228 248 // If this is a message then change the checkbox 229 249 if(message_only) { … … 239 259 * @param control the JTextField subclass you want to use for the control 240 260 */ 241 public void setValueField(J TextFieldcontrol) {261 public void setValueField(JComponent control) { 242 262 // Remove the current control 243 263 value_panel.remove(value_field); … … 263 283 264 284 public void setValueField(String field_value){ 265 this.value_field.setText(field_value);285 URLField.setText(this.value_field, field_value); 266 286 } 267 287
Note:
See TracChangeset
for help on using the changeset viewer.