Gridarta Editor
ExitAction.java
Go to the documentation of this file.
1 /*
2  * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games.
3  * Copyright (C) 2000-2015 The Gridarta Developers.
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  */
19 
20 package net.sf.gridarta.action;
21 
22 import javax.swing.Action;
28 import net.sf.gridarta.utils.Exiter;
29 import net.sf.japi.swing.action.ActionMethod;
30 import org.jetbrains.annotations.NotNull;
31 
35 public class ExitAction implements EditorAction {
36 
37  @NotNull
38  private final Exiter exiter;
39 
40  @NotNull
42 
43  @NotNull
45 
46  @NotNull
48 
49  @NotNull
51 
55  public ExitAction(@NotNull final Exiter exiter, @NotNull final ScriptEditControl scriptEditControl, @NotNull final FileControl<?, ?, ?> fileControl, @NotNull final PickmapChooserControl<?, ?, ?> pickmapChooserControl, @NotNull final PluginController<?, ?, ?> pluginControl) {
56  this.exiter = exiter;
57  this.scriptEditControl = scriptEditControl;
58  this.fileControl = fileControl;
59  this.pickmapChooserControl = pickmapChooserControl;
60  this.pluginControl = pluginControl;
61  }
62 
67  @ActionMethod
68  public void exit() {
69  if (canExit()) {
70  exiter.doExit(0);
71  }
72  }
73 
79  private boolean canExit() {
80  return scriptEditControl.closeAllTabs() && fileControl.closeAllMaps() && pickmapChooserControl.canExit() && pluginControl.canExit();
81  }
82 
83  @Override
84  public void setAction(@NotNull final Action action, @NotNull final String name) {
85  }
86 
87 }
boolean closeAllMaps()
Invoked when the user wants to close all maps.
void exit()
The action method for "exit".
Definition: ExitAction.java:68
Graphical User Interface of Gridarta.
final PickmapChooserControl<?, ?, ?> pickmapChooserControl
Definition: ExitAction.java:47
ExitAction(@NotNull final Exiter exiter, @NotNull final ScriptEditControl scriptEditControl, @NotNull final FileControl<?, ?, ?> fileControl, @NotNull final PickmapChooserControl<?, ?, ?> pickmapChooserControl, @NotNull final PluginController<?, ?, ?> pluginControl)
Creates a new instance.
Definition: ExitAction.java:55
boolean canExit()
Invoked when the user wants to exit the application.
boolean closeAllTabs()
Close all opened script-tabs.
final ScriptEditControl scriptEditControl
Definition: ExitAction.java:41
Base package of all Gridarta classes.
final FileControl<?, ?, ?> fileControl
Definition: ExitAction.java:44
This package contains the classes for the script editor used within the editor to create and modify P...
Definition: Actions.java:20
void doExit(int returnCode)
Exits the application.
boolean canExit()
Prepares existing the application: save modified data (possibly ask the user if applicable).
Definition: ExitAction.java:79
Exits the application.
Definition: Exiter.java:28
A global editor action.
ScriptEditControl - Manages events and data flow for the script editor entity.
final PluginController<?, ?, ?> pluginControl
Definition: ExitAction.java:50
Classes implementing the pickmap chooser.
Manages the pickmap panel and most pickmap-related code in general.
boolean canExit()
Prompts the user for all unsaved plugins.
void setAction(@NotNull final Action action, @NotNull final String name)
Sets the Action instance for this editor action.
Definition: ExitAction.java:84