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.data.osm.DataSet; 011import org.openstreetmap.josm.tools.Shortcut; 012 013public class SelectAllAction extends JosmAction { 014 015 /** 016 * Constructs a new {@code SelectAllAction}. 017 */ 018 public SelectAllAction() { 019 super(tr("Select All"), "selectall", tr("Select all undeleted objects in the data layer. This selects incomplete objects too."), 020 Shortcut.registerShortcut("system:selectall", tr("Edit: {0}", tr("Select All")), KeyEvent.VK_A, Shortcut.CTRL), true); 021 putValue("help", ht("/Action/SelectAll")); 022 } 023 024 @Override 025 public void actionPerformed(ActionEvent e) { 026 if (!isEnabled()) 027 return; 028 DataSet ds = getLayerManager().getEditDataSet(); 029 ds.setSelected(ds.allNonDeletedCompletePrimitives()); 030 } 031 032 /** 033 * Refreshes the enabled state 034 * 035 */ 036 @Override 037 protected void updateEnabledState() { 038 setEnabled(getLayerManager().getEditLayer() != null); 039 } 040}