 |
Gridarta Editor
|
Go to the documentation of this file.
20 package net.sf.gridarta.gui.dialog.plugin;
22 import java.awt.Component;
24 import java.io.IOException;
26 import javax.swing.Action;
27 import javax.swing.JFileChooser;
28 import javax.swing.JOptionPane;
44 import net.
sf.japi.swing.action.ActionBuilder;
45 import net.
sf.japi.swing.action.ActionBuilderFactory;
46 import net.
sf.japi.swing.action.ActionMethod;
47 import net.
sf.japi.swing.action.ReflectionAction;
48 import org.jetbrains.annotations.NotNull;
61 private static final ActionBuilder
ACTION_BUILDER = ActionBuilderFactory.getInstance().getActionBuilder(
"net.sf.gridarta");
105 final String filterName =
"(s)" + plugin.getName();
107 if (plugin.isFilter()) {
109 if (filter !=
null) {
114 if (plugin.isAutoBoot()) {
120 public void pluginUnregistered(@NotNull
final Plugin<G, A, R> plugin) {
121 final String filterName =
"(s)" + plugin.getName();
130 public PluginController(@NotNull
final FilterControl<G, A, R> filterControl, @NotNull
final PluginModel<G, A, R> pluginModel, @NotNull
final PluginParameters pluginParameters, @NotNull
final Component
parent, @NotNull
final PluginParameterViewFactory<G, A, R> pluginParameterViewFactory, @NotNull
final File
pluginsDir, @NotNull
final ResourceIcons resourceIcons) {
146 if (plugin.isModified()) {
147 final int result =
ACTION_BUILDER.showConfirmDialog(
parent, JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE,
"pluginConfirmSaveChanges", plugin.getName());
148 if (result == JOptionPane.YES_OPTION) {
152 }
else if (result == JOptionPane.CANCEL_OPTION || result == JOptionPane.CLOSED_OPTION) {
179 if (!plugin.isModified()) {
184 final File file = plugin.getFile();
192 }
catch (
final IOException ex) {
197 plugin.resetModified();
210 final JFileChooser chooser =
new JFileChooser();
211 final File pluginFile = plugin.getFile();
213 chooser.setDialogTitle(
"save plugin " + plugin.getName());
214 final int result = chooser.showSaveDialog(
null);
215 if (result != JFileChooser.APPROVE_OPTION) {
219 final File file = chooser.getSelectedFile();
220 if (updatePluginFile) {
221 plugin.setFile(file);
227 }
catch (
final IOException ex) {
238 if (runValues ==
null) {
243 if (pluginRunnable ==
null) {
247 final Thread pluginThread =
new Thread(pluginRunnable, clonedPlugin.
getName());
248 pluginThread.start();
255 if (plugin !=
null) {
273 action.putValue(ReflectionAction.REFLECTION_ARGUMENTS,
new Object[] { plugin.getName(), });
274 action.putValue(Action.NAME,
ACTION_BUILDER.format(
"runPlugin.text", plugin.getName()));
279 public void setAction(@NotNull
final Action action, @NotNull
final String
name) {
void saveAllPlugins()
Saves all modified plugins.
PluginController(@NotNull final FilterControl< G, A, R > filterControl, @NotNull final PluginModel< G, A, R > pluginModel, @NotNull final PluginParameters pluginParameters, @NotNull final Component parent, @NotNull final PluginParameterViewFactory< G, A, R > pluginParameterViewFactory, @NotNull final File pluginsDir, @NotNull final ResourceIcons resourceIcons)
Creates a new instance.
final FilterControl< G, A, R > filterControl
Base package of all Gridarta classes.
static void setCurrentDirectory(@NotNull final JFileChooser fileChooser, @Nullable final File dir)
Calls JFileChooser#setCurrentDirectory(File).
void addPluginModelListener(@NotNull final PluginModelListener< G, A, R > listener)
Adds a listener to be informed of changes.
void runPlugin(@NotNull final String name)
BshRunnable< G, A, R > doRunPlugin(@NotNull final Plugin< G, A, R > plugin, @NotNull final ConsoleInterface console, @NotNull final Map< String, Object > parameters)
Runs a plugin model.
Listener interface for scripting related events.
String getName()
Returns the name of this plugin.
Plugin< G, A, R > clonePlugin()
Returns a clone copy of this plugin.
static final ActionBuilder ACTION_BUILDER
Action Builder.
Allows execution of Plugins.
Reflects a game object (object on a map).
Makes basic Gridarta classes available to scripts.
Utility class implementing Action related functions.
void removeFilter(@NotNull String name)
Graphical User Interface of Gridarta.
GameObjects are the objects based on Archetypes found on maps.
Interface for MapArchObjects.
Plugin< G, A, R > getPlugin(@NotNull final String name)
Map< String, Object > getRunValues(@NotNull final Plugin< G, A, R > plugin, @NotNull final Component parent)
Asks the user for input parameter to run a plugin.
void savePlugin(@NotNull final Plugin< G, A, R > plugin, @NotNull final File file)
Saves a plugin to a given file.
Action createRunAction(@NotNull final Plugin< G, A, R > plugin)
Creates an action to run a plugin plugin.
final PluginModelListener< G, A, R > pluginModelListener
The PluginModelListener attached to pluginModel.
PluginView< G, A, R > getView()
void addFilter(@NotNull String name, @NotNull Filter<?, ?> filter)
void setAction(@NotNull final Action action, @NotNull final String name)
Sets the Action instance for this editor action.
Factory for creating PluginParameterView instances.
static Action newAction(@NotNull final ActionBuilder actionBuilder, @NotNull final String category, @NotNull final EditorAction editorAction, @NotNull final String key)
Creates a new Action instance.
Utility class for JFileChooser related functions.
boolean savePlugin(@NotNull final Plugin< G, A, R > plugin)
Saves one plugin.
File pluginsDir
The default directory for saving plugins.
boolean savePluginAs(@NotNull final Plugin< G, A, R > plugin, final boolean updatePluginFile)
Prompts the user for a file name to save a plugin.
Creates ImageIcon instances from resources.
final PluginView< G, A, R > view
boolean canExit()
Prompts the user for all unsaved plugins.
final Component parent
The parent component for dialog boxes.
ConsoleInterface createConsole(@NotNull final String name)
final PluginParameters pluginParameters
void runPlugin(@NotNull final Plugin< G, A, R > plugin)
final PluginModel< G, A, R > pluginModel