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.IEnabledStateUpdating; 011import org.openstreetmap.josm.gui.dialogs.LayerListDialog.LayerListModel; 012import org.openstreetmap.josm.tools.ImageProvider; 013 014/** 015 * The action to move down the currently selected entries in the list. 016 */ 017public class MoveDownAction extends AbstractAction implements IEnabledStateUpdating { 018 private final LayerListModel model; 019 020 /** 021 * Constructs a new {@code MoveDownAction}. 022 * @param model layer list model 023 */ 024 public MoveDownAction(LayerListModel model) { 025 this.model = model; 026 putValue(NAME, tr("Move down")); 027 new ImageProvider("dialogs", "down").getResource().attachImageIcon(this, true); 028 putValue(SHORT_DESCRIPTION, tr("Move the selected layer one row down.")); 029 updateEnabledState(); 030 } 031 032 @Override 033 public void updateEnabledState() { 034 setEnabled(model.canMoveDown()); 035 } 036 037 @Override 038 public void actionPerformed(ActionEvent e) { 039 model.moveDown(); 040 } 041}