001// License: GPL. For details, see LICENSE file.
002package org.openstreetmap.josm.gui.dialogs.layer;
003
004import static org.openstreetmap.josm.tools.I18n.tr;
005
006import java.awt.event.ActionEvent;
007
008import javax.swing.AbstractAction;
009
010import org.openstreetmap.josm.gui.dialogs.LayerListDialog.LayerListModel;
011import org.openstreetmap.josm.tools.ImageProvider;
012
013/**
014 * The action to move down the currently selected entries in the list.
015 */
016public class MoveDownAction extends AbstractAction implements IEnabledStateUpdating {
017    private final LayerListModel model;
018
019    /**
020     * Constructs a new {@code MoveDownAction}.
021     * @param model layer list model
022     */
023    public MoveDownAction(LayerListModel model) {
024        this.model = model;
025        putValue(NAME, tr("Move down"));
026        putValue(SMALL_ICON, ImageProvider.get("dialogs", "down"));
027        putValue(SHORT_DESCRIPTION, tr("Move the selected layer one row down."));
028        updateEnabledState();
029    }
030
031    @Override
032    public void updateEnabledState() {
033        setEnabled(model.canMoveDown());
034    }
035
036    @Override
037    public void actionPerformed(ActionEvent e) {
038        model.moveDown();
039    }
040}