Changeset 13050 in josm for trunk/src/org/openstreetmap/josm/gui/preferences/DefaultPreferenceSetting.java
- Timestamp:
- 2017-10-29T14:57:41+01:00 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/preferences/DefaultPreferenceSetting.java
r12460 r13050 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.gui.preferences; 3 4 import javax.swing.JCheckBox; 5 import javax.swing.JTextField; 6 7 import org.openstreetmap.josm.spi.preferences.Config; 8 import org.openstreetmap.josm.tools.JosmDecimalFormatSymbolsProvider; 9 import org.openstreetmap.josm.tools.Logging; 3 10 4 11 /** 5 12 * Abstract base class for {@link PreferenceSetting} implementations. 6 13 * 7 * Handles the flag that indicates if a PreferenceSetting is and expert option 8 * or not.14 * Handles the flag that indicates if a PreferenceSetting is and expert option or not. 15 * @since 4968 9 16 */ 10 17 public abstract class DefaultPreferenceSetting implements PreferenceSetting { … … 34 41 return isExpert; 35 42 } 43 44 /** 45 * Saves state from a {@link JCheckBox} to a boolean preference. 46 * @param prefName preference name 47 * @param cb check box 48 * @since 13050 49 */ 50 protected static void saveBoolean(String prefName, JCheckBox cb) { 51 Config.getPref().putBoolean(prefName, cb.isSelected()); 52 } 53 54 /** 55 * Saves text from a {@link JTextField} to a double preference. 56 * @param prefName preference name 57 * @param tf text field 58 * @since 13050 59 */ 60 protected static void saveDouble(String prefName, JTextField tf) { 61 String text = tf.getText(); 62 try { 63 Config.getPref().putDouble(prefName, JosmDecimalFormatSymbolsProvider.parseDouble(text)); 64 } catch (NumberFormatException e) { 65 Logging.warn("Unable to save '" + text + "' as a double value for preference " + prefName); 66 Logging.trace(e); 67 } 68 } 69 70 /** 71 * Saves text from a {@link JTextField} to an integer preference. 72 * @param prefName preference name 73 * @param tf text field 74 * @since 13050 75 */ 76 protected static void saveInt(String prefName, JTextField tf) { 77 String text = tf.getText(); 78 try { 79 Config.getPref().putInt(prefName, Integer.parseInt(text)); 80 } catch (NumberFormatException e) { 81 Logging.warn("Unable to save '" + text + "' as an integer value for preference " + prefName); 82 Logging.trace(e); 83 } 84 } 36 85 }
Note:
See TracChangeset
for help on using the changeset viewer.