001// License: GPL. For details, see LICENSE file. 002package org.openstreetmap.josm.actions; 003 004import static org.openstreetmap.josm.gui.help.HelpUtil.ht; 005import static org.openstreetmap.josm.tools.I18n.tr; 006 007import java.awt.event.ActionEvent; 008import java.awt.event.KeyEvent; 009 010import org.openstreetmap.josm.gui.MainApplication; 011import org.openstreetmap.josm.tools.Logging; 012import org.openstreetmap.josm.tools.Shortcut; 013import org.openstreetmap.josm.tools.UserCancelException; 014 015/** 016 * Saves a JOSM session to a new file 017 * @since 4685 018 */ 019public class SessionSaveAsAction extends SessionSaveAction { 020 021 /** 022 * Constructs a new {@code SessionSaveAsAction}. 023 */ 024 public SessionSaveAsAction() { 025 this(true, false); 026 updateEnabledState(); 027 } 028 029 /** 030 * Constructs a new {@code SessionSaveAsAction}. 031 * @param toolbar Register this action for the toolbar preferences? 032 * @param installAdapters False, if you don't want to install layer changed and selection changed adapters 033 */ 034 protected SessionSaveAsAction(boolean toolbar, boolean installAdapters) { 035 036 super(tr("Save Session As..."), "session", tr("Save the current session to a new file."), 037 Shortcut.registerShortcut("system:savesessionas", tr("File: {0}", tr("Save Session As...")), 038 KeyEvent.VK_S, Shortcut.ALT_CTRL_SHIFT), 039 toolbar, "save_as-session", installAdapters); 040 041 setHelpId(ht("/Action/SessionSaveAs")); 042 } 043 044 @Override 045 public void actionPerformed(ActionEvent e) { 046 try { 047 saveSession(true, false); 048 } catch (UserCancelException ignore) { 049 Logging.trace(ignore); 050 } 051 } 052 053 @Override 054 protected void addListeners() { 055 MainApplication.addMapFrameListener(this); 056 } 057 058 @Override 059 protected void removeListeners() { 060 MainApplication.removeMapFrameListener(this); 061 } 062}