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 UnselectAllAction extends JosmAction { 013 014 /** 015 * Constructs a new {@code UnselectAllAction}. 016 */ 017 public UnselectAllAction() { 018 super(tr("Unselect All"), "unselectall", tr("Unselect all objects."), 019 Shortcut.registerShortcut("edit:unselectall", tr("Edit: {0}", 020 tr("Unselect All")), KeyEvent.VK_ESCAPE, Shortcut.DIRECT), true); 021 022 putValue("help", ht("/Action/UnselectAll")); 023 } 024 025 @Override 026 public void actionPerformed(ActionEvent e) { 027 if (!isEnabled()) 028 return; 029 getCurrentDataSet().setSelected(); 030 } 031 032 /** 033 * Refreshes the enabled state 034 */ 035 @Override 036 protected void updateEnabledState() { 037 setEnabled(getEditLayer() != null); 038 } 039}