Changeset 6327 in josm


Ignore:
Timestamp:
2013-10-27T02:15:10+02:00 (11 years ago)
Author:
Don-vip
Message:

fix #9220 - toggle actions not usable via menu items (regression from r6220)

Location:
trunk/src/org/openstreetmap/josm/actions
Files:
7 edited

Legend:

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

    r6220 r6327  
    4040    @Override
    4141    public void actionPerformed(ActionEvent e) {
    42         toggleSelectedState();
     42        toggleSelectedState(e);
    4343        notifySelectedState();
    4444        if (isSelected()) {
  • trunk/src/org/openstreetmap/josm/actions/DialogsToggleAction.java

    r6220 r6327  
    3838    @Override
    3939    public void actionPerformed(ActionEvent e) {
    40         toggleSelectedState();
     40        toggleSelectedState(e);
    4141        Main.pref.put("draw.dialogspanel", isSelected());
    4242        notifySelectedState();
  • trunk/src/org/openstreetmap/josm/actions/ExpertToggleAction.java

    r6220 r6327  
    140140    @Override
    141141    public void actionPerformed(ActionEvent e) {
    142         toggleSelectedState();
     142        toggleSelectedState(e);
    143143        Main.pref.put("expert", isSelected());
    144144        notifySelectedState();
  • trunk/src/org/openstreetmap/josm/actions/FullscreenToggleAction.java

    r6220 r6327  
    5252    @Override
    5353    public void actionPerformed(ActionEvent e) {
    54         toggleSelectedState();
     54        toggleSelectedState(e);
    5555        Main.pref.put("draw.fullscreen", isSelected());
    5656        notifySelectedState();
  • trunk/src/org/openstreetmap/josm/actions/ToggleAction.java

    r6220 r6327  
    22package org.openstreetmap.josm.actions;
    33
     4import java.awt.event.ActionEvent;
    45import java.util.ArrayList;
    56import java.util.List;
     
    78import javax.swing.ButtonModel;
    89import javax.swing.Icon;
     10import javax.swing.JCheckBox;
     11import javax.swing.JCheckBoxMenuItem;
     12import javax.swing.JRadioButton;
     13import javax.swing.JRadioButtonMenuItem;
     14import javax.swing.JToggleButton;
    915
    1016import org.openstreetmap.josm.tools.Shortcut;
     
    101107    }
    102108
    103     protected final void toggleSelectedState() {
    104         setSelected(!isSelected());
     109    /**
     110     * Toggles the selcted action state, if needed according to the ActionEvent that trigerred the action.
     111     * This method will do nothing if the action event comes from a Swing component supporting the SELECTED_KEY property because the component already set the selected state.
     112     * This method needs to be called especially if the action is associated with a keyboard shortcut to ensure correct selected state.
     113     * @see <a href="https://weblogs.java.net/blog/zixle/archive/2005/11/changes_to_acti.html">Changes to Actions in 1.6</a>
     114     * @see <a href="http://docs.oracle.com/javase/6/docs/api/javax/swing/Action.html">Interface Action</a>
     115     */
     116    protected final void toggleSelectedState(ActionEvent e) {
     117        if (e == null || !(e.getSource() instanceof JToggleButton ||
     118                           e.getSource() instanceof JCheckBox ||
     119                           e.getSource() instanceof JRadioButton ||
     120                           e.getSource() instanceof JCheckBoxMenuItem ||
     121                           e.getSource() instanceof JRadioButtonMenuItem
     122                           )) {
     123            setSelected(!isSelected());
     124        }
    105125    }
    106126}
  • trunk/src/org/openstreetmap/josm/actions/ViewportFollowToggleAction.java

    r6220 r6327  
    3535    @Override
    3636    public void actionPerformed(ActionEvent e) {
    37         toggleSelectedState();
     37        toggleSelectedState(e);
    3838        Main.map.mapView.viewportFollowing = isSelected();
    3939        notifySelectedState();
  • trunk/src/org/openstreetmap/josm/actions/WireframeToggleAction.java

    r6220 r6327  
    4242    @Override
    4343    public void actionPerformed(ActionEvent e) {
    44         toggleSelectedState();
     44        toggleSelectedState(e);
    4545        if (isSelected()) {
    4646            MapRendererFactory.getInstance().activate(WireframeMapRenderer.class);
Note: See TracChangeset for help on using the changeset viewer.