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