20 package net.sf.gridarta.gui.scripts;
22 import java.awt.Component;
23 import java.awt.Container;
24 import java.awt.FlowLayout;
25 import java.awt.Frame;
26 import java.awt.event.ActionEvent;
27 import java.awt.event.ActionListener;
29 import javax.swing.AbstractButton;
30 import javax.swing.BorderFactory;
31 import javax.swing.Box;
32 import javax.swing.BoxLayout;
33 import javax.swing.JButton;
34 import javax.swing.JDialog;
35 import javax.swing.JLabel;
36 import javax.swing.JPanel;
37 import javax.swing.JTextField;
38 import javax.swing.WindowConstants;
39 import javax.swing.text.JTextComponent;
48 import net.
sf.japi.swing.action.ActionBuilder;
49 import net.
sf.japi.swing.action.ActionBuilderFactory;
50 import org.jetbrains.annotations.NotNull;
62 private static final ActionBuilder
ACTION_BUILDER = ActionBuilderFactory.getInstance().getActionBuilder(
"net.sf.gridarta");
103 final File scriptFile;
104 if (scriptPath.startsWith(
"/")) {
106 scriptFile =
new File(projectSettings.
getMapsDirectory(), scriptPath.substring(1));
109 scriptFile =
new File(mapManager.getLocalMapDir(), scriptPath);
113 if (scriptFile.exists() && scriptFile.isFile()) {
114 final String path = scriptFile.getAbsolutePath();
118 ACTION_BUILDER.showMessageDialog(parent,
"openScriptNotFound", scriptFile);
130 pathFrame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
132 final JPanel mainPanel =
new JPanel();
133 mainPanel.setLayout(
new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
134 mainPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 2, 5));
137 final Container line1 =
new JPanel(
new FlowLayout(FlowLayout.RIGHT));
140 inputScriptPath =
new JTextField(scriptedEvent.getScriptPath(), 20);
141 line1.add(inputScriptPath);
142 mainPanel.add(line1);
145 final Container line2 =
new JPanel(
new FlowLayout(FlowLayout.RIGHT));
148 inputOptions =
new JTextField(scriptedEvent.getOptions(), 20);
149 line2.add(inputOptions);
150 mainPanel.add(line2);
151 mainPanel.add(Box.createVerticalStrut(5));
154 final Container line3 =
new JPanel(
new FlowLayout(FlowLayout.RIGHT));
157 inputPluginName =
new JTextField(scriptedEvent.getPluginName(), 20);
158 line3.add(inputPluginName);
159 mainPanel.add(line3);
160 mainPanel.add(Box.createVerticalStrut(5));
163 final Container line4 =
new JPanel(
new FlowLayout(FlowLayout.RIGHT));
165 okButton.addActionListener(
new ActionListener() {
168 public void actionPerformed(@NotNull
final ActionEvent e) {
169 scriptedEvent.modifyEventPath();
177 cancelButton.addActionListener(
new ActionListener() {
180 public void actionPerformed(@NotNull
final ActionEvent e) {
185 line4.add(cancelButton);
186 mainPanel.add(line4);
188 pathFrame.getContentPane().add(mainPanel);
190 pathFrame.setLocationRelativeTo(parent);
191 pathFrame.setVisible(
true);
196 return inputScriptPath.getText().trim();
201 return inputPluginName.getText().trim();
206 return inputOptions.getText().trim();
JTextComponent inputPluginName
Dialog to edit events linked to item scripting.
Package with common types for event archetypes.
A MapManager manages all opened maps.
final ProjectSettings projectSettings
The project settings instance.
Settings that apply to a project.
void openScriptFile(@NotNull final String pathName)
Open a new empty script document.
static String getString(@NotNull final ActionBuilder actionBuilder, @NotNull final String key, @NotNull final String defaultValue)
Returns the value of a key.
Base package of all Gridarta classes.
This package contains the classes for the script editor used within the editor to create and modify P...
Reflects a game object (object on a map).
void openScript(@NotNull final MapManager<?, ?, ?> mapManager, @NotNull final String scriptPath, @NotNull final Component parent)
Opens the script pad to display a script.
static final ActionBuilder ACTION_BUILDER
Action Builder.
GameObjects are the objects based on Archetypes found on maps.
JTextComponent inputScriptPath
ScriptedEventEditor(@NotNull final ProjectSettings projectSettings, @NotNull final ScriptEditControl scriptEditControl)
Creates a new instance.
final ScriptEditControl scriptEditControl
The ScriptEditControl to use.
ScriptEditControl - Manages events and data flow for the script editor entity.
Utility class for ActionBuilder related functions.
void editParameters(@NotNull final ScriptedEvent< G, A, R > scriptedEvent, @NotNull final Frame parent)
Edit path and plugin name for an event.
String getInputPluginName()
File getMapsDirectory()
Returns the default maps directory.
static JLabel newLabel(@NotNull final ActionBuilder actionBuilder, @NotNull final String key)
Creates a new JLabel from a resource key.
String getInputScriptPath()
JTextComponent inputOptions
Interface for MapArchObjects.
Class which stores information about one scripted event.