Gridarta Editor
OptionsAction.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 java.awt.Component;
23 import javax.swing.Action;
35 import net.sf.japi.swing.action.ActionMethod;
36 import net.sf.japi.swing.prefs.PreferencesGroup;
37 import net.sf.japi.swing.prefs.PreferencesPane;
38 import org.jetbrains.annotations.NotNull;
39 import org.jetbrains.annotations.Nullable;
40 
44 public class OptionsAction<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> implements EditorAction {
45 
46  @NotNull
48 
49  @NotNull
51 
52  @NotNull
54 
55  @NotNull
57 
58  @NotNull
60 
61  @NotNull
63 
64  @NotNull
66 
67  @NotNull
68  private final Component parent;
69 
74  @Nullable
75  private PreferencesGroup preferencesGroup;
76 
80  public OptionsAction(@NotNull final EditorFactory<G, A, R> editorFactory, @NotNull final ProjectSettings projectSettings, @NotNull final EditorSettings editorSettings, @NotNull final DelegatingMapValidator<G, A, R> validators, @NotNull final AppPreferencesModel appPreferencesModel, @NotNull final ExitConnectorModel exitConnectorModel, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final Component parent) {
81  this.editorFactory = editorFactory;
82  this.projectSettings = projectSettings;
83  this.editorSettings = editorSettings;
84  this.validators = validators;
85  this.appPreferencesModel = appPreferencesModel;
86  this.exitConnectorModel = exitConnectorModel;
87  this.configSourceFactory = configSourceFactory;
88  this.parent = parent;
89  }
90 
94  @ActionMethod
95  public void options() {
96  if (preferencesGroup == null) {
97  preferencesGroup = editorFactory.createPreferencesGroup(projectSettings, editorSettings, validators, appPreferencesModel, exitConnectorModel, configSourceFactory);
98  }
99  PreferencesPane.showPreferencesDialog(parent, preferencesGroup, false);
100  }
101 
102  @Override
103  public void setAction(@NotNull final Action action, @NotNull final String name) {
104  }
105 
106 }
void setAction(@NotNull final Action action, @NotNull final String name)
Sets the Action instance for this editor action.
OptionsAction(@NotNull final EditorFactory< G, A, R > editorFactory, @NotNull final ProjectSettings projectSettings, @NotNull final EditorSettings editorSettings, @NotNull final DelegatingMapValidator< G, A, R > validators, @NotNull final AppPreferencesModel appPreferencesModel, @NotNull final ExitConnectorModel exitConnectorModel, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final Component parent)
Creates a new instance.
Graphical User Interface of Gridarta.
Settings that apply to a project.
This package contains the framework for validating maps.
final ExitConnectorModel exitConnectorModel
void options()
The action method for "options".
Maintains the application preferences state.
PreferencesGroup createPreferencesGroup(@NotNull ProjectSettings projectSettings, @NotNull EditorSettings editorSettings, @NotNull DelegatingMapValidator< G, A, R > validators, @NotNull AppPreferencesModel appPreferencesModel, @NotNull ExitConnectorModel exitConnectorModel, @NotNull ConfigSourceFactory configSourceFactory)
Creates a new PreferencesGroup instance.
Base package of all Gridarta classes.
Reflects a game object (object on a map).
Definition: GameObject.java:36
A global editor action.
This package contains the preferences ui modules.
final ProjectSettings projectSettings
GameObjects are the objects based on Archetypes found on maps.
final EditorFactory< G, A, R > editorFactory
A Map Validator that delegates to other MapValidators.
Stores information needed by the exit connector.
final AppPreferencesModel appPreferencesModel
A factory to create editor-dependent objects.
PreferencesGroup preferencesGroup
The PreferencesGroup instance.
Settings that apply to the editor.
final DelegatingMapValidator< G, A, R > validators
final ConfigSourceFactory configSourceFactory