[3837] | 1 | // License: GPL. For details, see LICENSE file.
|
---|
| 2 | package org.openstreetmap.josm.actions;
|
---|
| 3 |
|
---|
[4701] | 4 | import static org.openstreetmap.josm.gui.help.HelpUtil.ht;
|
---|
[3837] | 5 | import static org.openstreetmap.josm.tools.I18n.tr;
|
---|
| 6 |
|
---|
| 7 | import java.awt.event.ActionEvent;
|
---|
| 8 | import java.awt.event.KeyEvent;
|
---|
| 9 |
|
---|
| 10 | import org.openstreetmap.josm.Main;
|
---|
| 11 | import org.openstreetmap.josm.tools.Shortcut;
|
---|
| 12 |
|
---|
[6220] | 13 | /**
|
---|
| 14 | * This action toggles automatic moving of the map view to last placed node
|
---|
| 15 | * @since 3837
|
---|
| 16 | */
|
---|
| 17 | public class ViewportFollowToggleAction extends ToggleAction {
|
---|
[7509] | 18 |
|
---|
[6220] | 19 | /**
|
---|
[7509] | 20 | * Constructs a new {@code ViewportFollowToggleAction}.
|
---|
[6220] | 21 | */
|
---|
[3837] | 22 | public ViewportFollowToggleAction() {
|
---|
[6220] | 23 | super(tr("Viewport Following"),
|
---|
| 24 | "viewport-follow",
|
---|
| 25 | tr("Enable/disable automatic moving of the map view to last placed node"),
|
---|
| 26 | Shortcut.registerShortcut("menu:view:viewportfollow", tr("Toggle Viewport Following"),
|
---|
| 27 | KeyEvent.VK_F, Shortcut.CTRL_SHIFT),
|
---|
| 28 | true /* register shortcut */
|
---|
[3837] | 29 | );
|
---|
[4700] | 30 | putValue("help", ht("/Action/ViewportFollowing"));
|
---|
[6220] | 31 | setSelected(false);
|
---|
[3837] | 32 | notifySelectedState();
|
---|
| 33 | }
|
---|
| 34 |
|
---|
[6084] | 35 | @Override
|
---|
[3837] | 36 | public void actionPerformed(ActionEvent e) {
|
---|
[6327] | 37 | toggleSelectedState(e);
|
---|
[6220] | 38 | Main.map.mapView.viewportFollowing = isSelected();
|
---|
| 39 | notifySelectedState();
|
---|
[3837] | 40 | }
|
---|
| 41 |
|
---|
| 42 | @Override
|
---|
| 43 | protected void updateEnabledState() {
|
---|
[10453] | 44 | setEnabled(Main.getLayerManager().getEditDataSet() != null);
|
---|
[3837] | 45 | }
|
---|
| 46 | }
|
---|