001    // License: GPL. Copyright 2007 by Immanuel Scholz and others
002    package org.openstreetmap.josm.actions;
003    
004    import static org.openstreetmap.josm.gui.help.HelpUtil.ht;
005    import static org.openstreetmap.josm.tools.I18n.tr;
006    
007    import java.awt.event.ActionEvent;
008    import java.awt.event.KeyEvent;
009    
010    import org.openstreetmap.josm.Main;
011    import org.openstreetmap.josm.tools.Shortcut;
012    
013    public class UnselectAllAction extends JosmAction {
014    
015        public UnselectAllAction() {
016            super(tr("Unselect All"), "unselectall", tr("Unselect all objects."),
017                Shortcut.registerShortcut("edit:unselectall", tr("Edit: {0}",
018                tr("Unselect All")), KeyEvent.VK_ESCAPE, Shortcut.DIRECT), true);
019    
020            putValue("help", ht("/Action/UnselectAll"));
021        }
022    
023        public void actionPerformed(ActionEvent e) {
024            if (!isEnabled())
025                return;
026            getCurrentDataSet().setSelected();
027        }
028        /**
029         * Refreshes the enabled state
030         *
031         */
032        @Override
033        protected void updateEnabledState() {
034            setEnabled(getEditLayer() != null);
035        }
036    }