Changeset 6594 in josm for trunk/src/org/openstreetmap/josm/gui/ExtendedDialog.java
- Timestamp:
- 2014-01-02T00:58:33+01:00 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/ExtendedDialog.java
r6443 r6594 20 20 import javax.swing.Icon; 21 21 import javax.swing.JButton; 22 import javax.swing.JCheckBox;23 22 import javax.swing.JComponent; 24 23 import javax.swing.JDialog; … … 79 78 private String togglePref = ""; 80 79 private int toggleValue = -1; 81 private String toggleCheckboxText = tr("Do not show again (remembers choice)"); 82 private JCheckBox toggleCheckbox = null; 80 private ConditionalOptionPaneUtil.MessagePanel togglePanel; 83 81 private Component parent; 84 82 private Component content; … … 372 370 373 371 if (toggleable) { 374 toggleCheckbox = new JCheckBox(toggleCheckboxText); 375 boolean showDialog = Main.pref.getBoolean("message."+ togglePref, true); 376 toggleCheckbox.setSelected(!showDialog); 372 togglePanel = new ConditionalOptionPaneUtil.MessagePanel(null, false); 377 373 gc.gridx = icon != null ? 1 : 0; 378 374 gc.gridy = y++; 379 375 gc.anchor = GridBagConstraints.LINE_START; 380 376 gc.insets = new Insets(5,contentInsets.left,5,contentInsets.right); 381 cp.add(toggle Checkbox, gc);377 cp.add(togglePanel, gc); 382 378 } 383 379 … … 546 542 547 543 /** 548 * Overwrites the default "Don't show again" text of the toggle checkbox549 * if you want to give more information. Only has an effect if550 * <code>toggleEnable</code> is set.551 * @param text The toggle checkbox text552 * @return {@code this}553 */554 public ExtendedDialog setToggleCheckboxText(String text) {555 this.toggleCheckboxText = text;556 return this;557 }558 559 /**560 544 * Sets the button that will react to ENTER. 561 545 * @param defaultButtonIdx The button index (starts to ) … … 597 581 public final boolean toggleCheckState() { 598 582 toggleable = togglePref != null && !togglePref.isEmpty(); 599 600 toggleValue = Main.pref.getInteger("message."+togglePref+".value", -1); 601 // No identifier given, so return false (= show the dialog) 602 if (!toggleable || toggleValue == -1) 603 return false; 604 // The pref is true, if the dialog should be shown. 605 return !(Main.pref.getBoolean("message."+ togglePref, true)); 583 toggleValue = ConditionalOptionPaneUtil.getDialogReturnValue(togglePref); 584 return toggleable && toggleValue != -1; 606 585 } 607 586 … … 612 591 private void toggleSaveState() { 613 592 if (!toggleable || 614 toggle Checkbox== null ||593 togglePanel == null || 615 594 cancelButtonIdx.contains(result) || 616 595 result == ExtendedDialog.DialogClosedOtherwise) 617 596 return; 618 Main.pref.put("message."+ togglePref, !toggleCheckbox.isSelected()); 619 Main.pref.putInteger("message."+togglePref+".value", result); 597 togglePanel.getNotShowAgain().store(togglePref, result); 620 598 } 621 599
Note:
See TracChangeset
for help on using the changeset viewer.
