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