1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.actions;
|
---|
3 |
|
---|
4 | import static org.openstreetmap.josm.gui.help.HelpUtil.ht;
|
---|
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.ImageProvider;
|
---|
12 | import org.openstreetmap.josm.tools.Shortcut;
|
---|
13 |
|
---|
14 | /**
|
---|
15 | * This action toggles visibility of dialogs panel and other panels to free more space for drawing (GIMP-like)
|
---|
16 | * @author cmuelle8
|
---|
17 | * @since 5965
|
---|
18 | */
|
---|
19 | public class DialogsToggleAction extends ToggleAction {
|
---|
20 |
|
---|
21 | /**
|
---|
22 | * Constructs a new {@code DialogsToggleAction}.
|
---|
23 | */
|
---|
24 | public DialogsToggleAction() {
|
---|
25 | super(tr("Toggle dialogs panel"),
|
---|
26 | (ImageProvider) null, /* no icon */
|
---|
27 | tr("Toggle dialogs panel, maximize mapview"),
|
---|
28 | Shortcut.registerShortcut("menu:view:dialogspanel", tr("Toggle dialogs panel"), KeyEvent.VK_TAB, Shortcut.DIRECT),
|
---|
29 | true, "dialogspanel", /* register in toolbar */
|
---|
30 | false
|
---|
31 | );
|
---|
32 | putValue("help", ht("/Action/ToggleDialogsPanel"));
|
---|
33 | setSelected(Main.pref.getBoolean("draw.dialogspanel", true));
|
---|
34 | notifySelectedState();
|
---|
35 | }
|
---|
36 |
|
---|
37 | @Override
|
---|
38 | public void actionPerformed(ActionEvent e) {
|
---|
39 | toggleSelectedState(e);
|
---|
40 | Main.pref.put("draw.dialogspanel", isSelected());
|
---|
41 | notifySelectedState();
|
---|
42 | setMode();
|
---|
43 | }
|
---|
44 |
|
---|
45 | /**
|
---|
46 | * To call if this action must be initially run at JOSM startup.
|
---|
47 | */
|
---|
48 | public void initial() {
|
---|
49 | if (isSelected()) {
|
---|
50 | setMode();
|
---|
51 | }
|
---|
52 | }
|
---|
53 |
|
---|
54 | protected void setMode() {
|
---|
55 | if (Main.isDisplayingMapView()) {
|
---|
56 | boolean selected = isSelected();
|
---|
57 | Main.map.setDialogsPanelVisible(selected);
|
---|
58 | Main.map.statusLine.setVisible(selected || Main.pref.getBoolean("statusbar.always-visible", true));
|
---|
59 | Main.main.menu.setVisible(selected || Main.pref.getBoolean("menu.always-visible", true));
|
---|
60 | // Toolbars listen to preference changes, use it here
|
---|
61 | if (!Main.pref.getBoolean("toolbar.always-visible", true)) {
|
---|
62 | Main.pref.put("toolbar.visible", selected);
|
---|
63 | }
|
---|
64 | if (!Main.pref.getBoolean("sidetoolbar.always-visible", true)) {
|
---|
65 | Main.pref.put("sidetoolbar.visible", selected);
|
---|
66 | }
|
---|
67 | Main.map.mapView.rememberLastPositionOnScreen();
|
---|
68 | }
|
---|
69 | }
|
---|
70 | }
|
---|