Ignore:
Timestamp:
2013-12-19T21:01:44+01:00 (6 years ago)
Author:
simon04
Message:

Revert accidentally committed r6499 (to be committed after the stabilization phase)

Location:
trunk/src/org/openstreetmap/josm/actions
Files:
1 deleted
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/PreferenceToggleAction.java

    r6499 r6501  
    77import org.openstreetmap.josm.data.Preferences;
    88import org.openstreetmap.josm.data.Preferences.PreferenceChangedListener;
    9 import org.openstreetmap.josm.data.preferences.BooleanProperty;
    10 import org.openstreetmap.josm.tools.CheckParameterUtil;
    119
    1210public class PreferenceToggleAction extends JosmAction implements PreferenceChangedListener {
    1311
    14     protected final JCheckBoxMenuItem checkbox;
    15     protected final BooleanProperty property;
     12    private final JCheckBoxMenuItem checkbox;
     13    private final String prefKey;
     14    private final boolean prefDefault;
    1615
    1716    public PreferenceToggleAction(String name, String tooltip, String prefKey, boolean prefDefault) {
    18         this(name, tooltip, new BooleanProperty(prefKey, prefDefault));
    19     }
    20 
    21     public PreferenceToggleAction(String name, String tooltip, BooleanProperty property) {
    2217        super(name, null, tooltip, null, false);
    23         CheckParameterUtil.ensureParameterNotNull(property, "property");
    24         putValue("toolbar", "toggle-" + property.getKey());
    25         this.property = property;
     18        putValue("toolbar", "toggle-" + prefKey);
     19        this.prefKey = prefKey;
     20        this.prefDefault = prefDefault;
    2621        this.checkbox = new JCheckBoxMenuItem(this);
    27         this.checkbox.setSelected(property.get());
     22        this.checkbox.setSelected(Main.pref.getBoolean(prefKey, prefDefault));
    2823        Main.pref.addPreferenceChangeListener(this);
    2924    }
     
    3126    @Override
    3227    public void actionPerformed(ActionEvent e) {
    33         property.put(checkbox.isSelected());
     28        Main.pref.put(prefKey, checkbox.isSelected());
    3429    }
    3530
     
    4035    @Override
    4136    public void preferenceChanged(Preferences.PreferenceChangeEvent e) {
    42         if (property.getKey().equals(e.getKey())) {
    43             checkbox.setSelected(property.get());
     37        if (prefKey.equals(e.getKey())) {
     38            checkbox.setSelected(Main.pref.getBoolean(prefKey, prefDefault));
    4439        }
    4540    }
Note: See TracChangeset for help on using the changeset viewer.