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.gui.MainApplication;
|
---|
11 | import org.openstreetmap.josm.tools.Logging;
|
---|
12 | import org.openstreetmap.josm.tools.Shortcut;
|
---|
13 | import org.openstreetmap.josm.tools.UserCancelException;
|
---|
14 |
|
---|
15 | /**
|
---|
16 | * Saves a JOSM session to a new file
|
---|
17 | * @since 4685
|
---|
18 | */
|
---|
19 | public class SessionSaveAsAction extends SessionSaveAction {
|
---|
20 |
|
---|
21 | /**
|
---|
22 | * Constructs a new {@code SessionSaveAsAction}.
|
---|
23 | */
|
---|
24 | public SessionSaveAsAction() {
|
---|
25 | this(true, false);
|
---|
26 | updateEnabledState();
|
---|
27 | }
|
---|
28 |
|
---|
29 | /**
|
---|
30 | * Constructs a new {@code SessionSaveAsAction}.
|
---|
31 | * @param toolbar Register this action for the toolbar preferences?
|
---|
32 | * @param installAdapters False, if you don't want to install layer changed and selection changed adapters
|
---|
33 | */
|
---|
34 | protected SessionSaveAsAction(boolean toolbar, boolean installAdapters) {
|
---|
35 |
|
---|
36 | super(tr("Save Session As..."), "session", tr("Save the current session to a new file."),
|
---|
37 | Shortcut.registerShortcut("system:savesessionas", tr("File: {0}", tr("Save Session As...")),
|
---|
38 | KeyEvent.VK_S, Shortcut.ALT_CTRL_SHIFT),
|
---|
39 | toolbar, "save_as-session", installAdapters);
|
---|
40 |
|
---|
41 | setHelpId(ht("/Action/SessionSaveAs"));
|
---|
42 | }
|
---|
43 |
|
---|
44 | @Override
|
---|
45 | public void actionPerformed(ActionEvent e) {
|
---|
46 | try {
|
---|
47 | saveSession(true, false);
|
---|
48 | } catch (UserCancelException ignore) {
|
---|
49 | Logging.trace(ignore);
|
---|
50 | }
|
---|
51 | }
|
---|
52 |
|
---|
53 | @Override
|
---|
54 | protected void addListeners() {
|
---|
55 | MainApplication.addMapFrameListener(this);
|
---|
56 | }
|
---|
57 |
|
---|
58 | @Override
|
---|
59 | protected void removeListeners() {
|
---|
60 | MainApplication.removeMapFrameListener(this);
|
---|
61 | }
|
---|
62 | }
|
---|