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 up the currently selected entries in the list. 016 */ 017public class MoveUpAction extends AbstractAction implements IEnabledStateUpdating { 018 private final LayerListModel model; 019 020 /** 021 * Constructs a new {@code MoveUpAction}. 022 * @param model layer list model 023 */ 024 public MoveUpAction(LayerListModel model) { 025 this.model = model; 026 putValue(NAME, tr("Move up")); 027 new ImageProvider("dialogs", "up").getResource().attachImageIcon(this, true); 028 putValue(SHORT_DESCRIPTION, tr("Move the selected layer one row up.")); 029 updateEnabledState(); 030 } 031 032 @Override 033 public void updateEnabledState() { 034 setEnabled(model.canMoveUp()); 035 } 036 037 @Override 038 public void actionPerformed(ActionEvent e) { 039 model.moveUp(); 040 } 041}