Changeset 11708 in josm


Ignore:
Timestamp:
2017-03-09T13:32:31+01:00 (5 months ago)
Author:
bastiK
Message:

make "Discourage/encourage upload" a checkbox menu entry

File:
1 edited

Legend:

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

    r9692 r11708  
    44import static org.openstreetmap.josm.tools.I18n.tr;
    55
     6import java.awt.Component;
    67import java.awt.event.ActionEvent;
     8import java.util.List;
    79
    810import javax.swing.AbstractAction;
     11import javax.swing.JCheckBoxMenuItem;
    912
    1013import org.openstreetmap.josm.gui.dialogs.LayerListDialog;
     14import org.openstreetmap.josm.gui.layer.Layer;
     15import org.openstreetmap.josm.gui.layer.Layer.LayerAction;
    1116import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    1217import org.openstreetmap.josm.tools.ImageProvider;
     
    1621 * of the layer specified in the constructor.
    1722 */
    18 public class ToggleUploadDiscouragedLayerAction extends AbstractAction {
     23public class ToggleUploadDiscouragedLayerAction extends AbstractAction implements LayerAction {
    1924
    2025    private final transient OsmDataLayer layer;
     
    2530     */
    2631    public ToggleUploadDiscouragedLayerAction(OsmDataLayer layer) {
    27         super(tr("Encourage/discourage upload"), ImageProvider.get("no_upload"));
     32        super(tr("Discourage upload"), ImageProvider.get("no_upload"));
    2833        this.layer = layer;
    2934    }
     
    3439        LayerListDialog.getInstance().repaint();
    3540    }
     41
     42    @Override
     43    public Component createMenuComponent() {
     44        JCheckBoxMenuItem item = new JCheckBoxMenuItem(this);
     45        item.setSelected(layer.isUploadDiscouraged());
     46        return item;
     47    }
     48
     49    @Override
     50    public boolean supportLayers(List<Layer> layers) {
     51        return layers.size() == 1 && layers.get(0) instanceof OsmDataLayer;
     52    }
    3653}
Note: See TracChangeset for help on using the changeset viewer.