001// License: GPL. For details, see LICENSE file.
002package org.openstreetmap.josm.actions;
003
004import static org.openstreetmap.josm.gui.help.HelpUtil.ht;
005import static org.openstreetmap.josm.tools.I18n.tr;
006
007import java.awt.event.ActionEvent;
008import java.awt.event.KeyEvent;
009
010import org.openstreetmap.josm.tools.Shortcut;
011
012public class SelectAllAction extends JosmAction {
013
014    /**
015     * Constructs a new {@code SelectAllAction}.
016     */
017    public SelectAllAction() {
018        super(tr("Select All"), "selectall", tr("Select all undeleted objects in the data layer. This selects incomplete objects too."),
019                Shortcut.registerShortcut("system:selectall", tr("Edit: {0}", tr("Select All")), KeyEvent.VK_A, Shortcut.CTRL), true);
020        putValue("help", ht("/Action/SelectAll"));
021    }
022
023    @Override
024    public void actionPerformed(ActionEvent e) {
025        if (!isEnabled())
026            return;
027        getCurrentDataSet().setSelected(getCurrentDataSet().allNonDeletedCompletePrimitives());
028    }
029
030    /**
031     * Refreshes the enabled state
032     *
033     */
034    @Override
035    protected void updateEnabledState() {
036        setEnabled(getEditLayer() != null);
037    }
038}