Changeset 3220 in josm for trunk


Ignore:
Timestamp:
2010-05-08T17:04:34+02:00 (9 years ago)
Author:
jttt
Message:

Use checkbox for Show marke layer text/icon, see #4336

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/MarkerLayer.java

    r2884 r3220  
    2121import javax.swing.AbstractAction;
    2222import javax.swing.Icon;
     23import javax.swing.JCheckBoxMenuItem;
    2324import javax.swing.JColorChooser;
    2425import javax.swing.JMenuItem;
     
    282283        Collection<Component> components = new ArrayList<Component>();
    283284        components.add(new JMenuItem(LayerListDialog.getInstance().createShowHideLayerAction(this)));
    284         components.add(new JMenuItem(new ShowHideMarkerText(this)));
     285        JCheckBoxMenuItem showMarkerTextItem = new JCheckBoxMenuItem(new ShowHideMarkerText(this));
     286        showMarkerTextItem.setState(isTextShown());
     287        components.add(showMarkerTextItem);
    285288        components.add(new JMenuItem(LayerListDialog.getInstance().createDeleteLayerAction(this)));
    286289        components.add(new JSeparator());
     
    449452    }
    450453
     454    private boolean isTextShown() {
     455        String current = Main.pref.get("marker.show "+getName(),"show");
     456        return current.equalsIgnoreCase("show");
     457    }
     458
    451459    public static final class ShowHideMarkerText extends AbstractAction {
    452         private final Layer layer;
    453 
    454         public ShowHideMarkerText(Layer layer) {
    455             super(tr("Show/Hide Text/Icons"), ImageProvider.get("dialogs", "showhide"));
     460        private final MarkerLayer layer;
     461
     462        public ShowHideMarkerText(MarkerLayer layer) {
     463            super(tr("Show Text/Icons"), ImageProvider.get("dialogs", "showhide"));
    456464            putValue(SHORT_DESCRIPTION, tr("Toggle visible state of the marker text and icons."));
    457465            putValue("help", "Action/ShowHideTextIcons");
     
    459467        }
    460468
     469
    461470        public void actionPerformed(ActionEvent e) {
    462             String current = Main.pref.get("marker.show "+layer.getName(),"show");
    463             Main.pref.put("marker.show "+layer.getName(), current.equalsIgnoreCase("show") ? "hide" : "show");
     471            Main.pref.put("marker.show "+layer.getName(), layer.isTextShown() ? "hide" : "show");
    464472            Main.map.mapView.repaint();
    465473        }
Note: See TracChangeset for help on using the changeset viewer.