Ignore:
Timestamp:
2011-11-28T11:00:32+01:00 (13 years ago)
Author:
larry0ua
Message:

'PicLayer - removed hiding buttons from PicLayer main menu - this is in core responsibility now'

Location:
applications/editors/josm/plugins/piclayer
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/piclayer/build.xml

    r27152 r27166  
    2222-->
    2323<project name="PicLayer" default="dist" basedir=".">
    24     <property name="commit.message" value="PicLayer - changed shortcut to prevent conflict with Imagery menu, #7084"/>
     24    <property name="commit.message" value="PicLayer - removed hiding buttons from PicLayer main menu - this is in core responsibility now"/>
    2525    <property name="plugin.main.version" value="4549"/>
    2626    <!--
  • applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/ActionVisibilityChangeMenu.java

    r27122 r27166  
    55import java.awt.event.ActionEvent;
    66
    7 import javax.swing.AbstractAction;
    87import javax.swing.JCheckBoxMenuItem;
    98import javax.swing.JMenu;
    109
    1110import org.openstreetmap.josm.Main;
     11import org.openstreetmap.josm.actions.JosmAction;
    1212
    1313enum PicActions {MOVE_PICTURE, MOVE_POINT, TRANSFORM_POINT, SCALEX, SCALEY, SCALEXY, SHEAR, ROTATE}
     
    2929        super();
    3030        setSelected(Main.pref.getBoolean(button.getVisibilityKey(), button.getDefVisibility()));
    31         setAction(new AbstractAction() {
    32             @Override
    33             public void actionPerformed(ActionEvent e) {
    34                 boolean val = !Main.pref.getBoolean(button.getVisibilityKey(), button.getDefVisibility());
    35                 Main.pref.put(button.getVisibilityKey(), val);
    36                 SwitchVisibilityMenuItem.this.setSelected(val);
    37                 button.setVisible(val);
    38             }
    39         });
    40         setText(tr(button.getBtnName()));
     31        setAction(new ButtonAction(button));
     32    }
     33    class ButtonAction extends JosmAction {
     34        private PicToggleButton button;
     35
     36        public ButtonAction(PicToggleButton button) {
     37            super(button.getBtnName(), null, button.getBtnName(), null, false, false);
     38            this.button = button;
     39        }
     40
     41        @Override
     42        public void actionPerformed(ActionEvent e) {
     43            boolean val = !Main.pref.getBoolean(button.getVisibilityKey(), button.getDefVisibility());
     44            Main.pref.put(button.getVisibilityKey(), val);
     45            SwitchVisibilityMenuItem.this.setSelected(val);
     46            button.setVisible(val);
     47        }
     48
    4149    }
    4250}
  • applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/PicLayerPlugin.java

    r27152 r27166  
    2323import static org.openstreetmap.josm.gui.help.HelpUtil.ht;
    2424import static org.openstreetmap.josm.tools.I18n.marktr;
     25import static org.openstreetmap.josm.tools.I18n.tr;
    2526
    2627import java.awt.event.KeyEvent;
     
    5960    // Plugin menu
    6061    private JMenu menu = null;
    61     private ActionVisibilityChangeMenu actionVisibility;
    6262
    6363    /**
     
    102102
    103103            buttonList = new ArrayList<PicToggleButton>(7);
    104             buttonList.add(new PicToggleButton(movePictureAction, "Move Picture", "piclayer.actionvisibility.move", true));
    105             buttonList.add(new PicToggleButton(movePointAction, "Move Point", "piclayer.actionvisibility.movepoint", true));
    106             buttonList.add(new PicToggleButton(transformPointAction, "Transform Point", "piclayer.actionvisibility.transformpoint", true));
    107             buttonList.add(new PicToggleButton(rotatePictureAction, "Rotate", "piclayer.actionvisibility.rotate", false));
    108             buttonList.add(new PicToggleButton(scaleXYPictureAction, "Scale", "piclayer.actionvisibility.scale", false));
    109             buttonList.add(new PicToggleButton(scaleXPictureAction, "Scale X", "piclayer.actionvisibility.scalex", false));
    110             buttonList.add(new PicToggleButton(scaleYPictureAction, "Scale Y", "piclayer.actionvisibility.scaley", false));
    111             buttonList.add(new PicToggleButton(shearPictureAction, "Shear", "piclayer.actionvisibility.shear", false));
     104            buttonList.add(new PicToggleButton(movePictureAction, tr("Move Picture"), "piclayer.actionvisibility.move", true));
     105            buttonList.add(new PicToggleButton(movePointAction, tr("Move Point"), "piclayer.actionvisibility.movepoint", true));
     106            buttonList.add(new PicToggleButton(transformPointAction, tr("Transform Point"), "piclayer.actionvisibility.transformpoint", true));
     107            buttonList.add(new PicToggleButton(rotatePictureAction, tr("Rotate"), "piclayer.actionvisibility.rotate", false));
     108            buttonList.add(new PicToggleButton(scaleXYPictureAction, tr("Scale"), "piclayer.actionvisibility.scale", false));
     109            buttonList.add(new PicToggleButton(scaleXPictureAction, tr("Scale X"), "piclayer.actionvisibility.scalex", false));
     110            buttonList.add(new PicToggleButton(scaleYPictureAction, tr("Scale Y"), "piclayer.actionvisibility.scaley", false));
     111            buttonList.add(new PicToggleButton(shearPictureAction, tr("Shear"), "piclayer.actionvisibility.shear", false));
    112112
    113113            for(IconToggleButton btn : buttonList) {
    114114                newFrame.addMapMode(btn);
    115115            }
    116 
    117             if (actionVisibility == null)
    118                 menu.add(actionVisibility = new ActionVisibilityChangeMenu());
    119116        }
    120117    }
     
    129126        // actually that should be not enough - JOSM should hide all buttons that are disabled for current layer!
    130127        if (oldPic && !newPic || oldLayer == null && !newPic) { // leave picture layer - hide all controls
    131             for (PicToggleButton btn : buttonList)
     128            for (PicToggleButton btn : buttonList) {
     129                btn.writeVisible();
    132130                btn.setVisible(false);
     131            }
    133132        }
    134133        if (!oldPic && newPic) { // enter picture layer - reset visibility of controls
  • applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/PicToggleButton.java

    r27122 r27166  
    3434        setVisible(Main.pref.getBoolean(getVisibilityKey(), getDefVisibility()));
    3535    }
     36    public void writeVisible() {
     37        Main.pref.put(getVisibilityKey(), isVisible());
     38    }
    3639
    3740}
Note: See TracChangeset for help on using the changeset viewer.