20 package net.sf.gridarta.gui.dialog.plugin;
22 import java.awt.Component;
23 import java.awt.event.FocusListener;
24 import java.awt.event.ItemEvent;
25 import java.awt.event.ItemListener;
26 import java.awt.event.MouseListener;
27 import javax.swing.JComboBox;
28 import javax.swing.JTextField;
29 import javax.swing.event.DocumentEvent;
30 import javax.swing.event.DocumentListener;
31 import javax.swing.text.JTextComponent;
41 import org.apache.log4j.Category;
42 import org.apache.log4j.Logger;
43 import org.jetbrains.annotations.NotNull;
106 public <G extends GameObject<G, A, R>, A extends
MapArchObject<A>, R extends
Archetype<G, A, R>>
PluginEditorRow(@NotNull
final Plugin<G, A, R> plugin, @NotNull
final PluginParameter<G, A, R, ?> parameter, @NotNull
final PluginParameterViewFactory<G, A, R> pluginParameterViewFactory, @NotNull
final MouseListener mouseListener, @NotNull
final FocusListener focusListener, @NotNull
final Component parent) {
110 parameterNameEditor = createNameEditor(parameter);
111 parameterDescriptionEditor = createDescriptionEditor(parameter);
112 parameterTypeEditor = createTypeEditor(plugin, parameter);
113 pluginParameterView = createView(parameter, pluginParameterViewFactory, parent);
123 final JTextComponent textField =
new JTextField(parameter.
getName());
124 textField.getDocument().addDocumentListener(
new DocumentListener() {
127 public void insertUpdate(@NotNull
final DocumentEvent e) {
132 public void removeUpdate(@NotNull
final DocumentEvent e) {
137 public void changedUpdate(@NotNull
final DocumentEvent e) {
144 private void change() {
145 parameter.
setName(textField.getText());
160 final JTextComponent textField =
new JTextField(parameter.
getDescription());
161 textField.getDocument().addDocumentListener(
new DocumentListener() {
164 public void changedUpdate(@NotNull
final DocumentEvent e) {
169 public void insertUpdate(@NotNull
final DocumentEvent e) {
174 public void removeUpdate(@NotNull
final DocumentEvent e) {
181 private void change() {
196 private <G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends
Archetype<G, A, R>> Component createTypeEditor(
final Plugin<G, A, R> plugin,
final PluginParameter<G, A, R, ?> parameter) {
199 comboBox.addItemListener(
new ItemListener() {
202 public void itemStateChanged(@NotNull
final ItemEvent e) {
203 if (e.getStateChange() != ItemEvent.SELECTED) {
207 final String newParameterType = (String) e.getItem();
215 LOG.warn(
"Cannot create parameter for " + ex.getMessage());
233 private <G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends
Archetype<G, A, R>>
PluginParameterView createView(
final PluginParameter<G, A, R, ?> parameter,
final PluginParameterViewFactory<G, A, R> pluginParameterViewFactory,
final Component parent) {
292 component.addFocusListener(focusListener);
293 component.addMouseListener(mouseListener);
Component getParameterDescriptionEditor()
Returns the editor component for editing the parameter's description.
final Component parameterDescriptionEditor
The editor component for editing the parameter's description.
PluginParameterView newPluginParameterView(@NotNull final Component parent, @NotNull final PluginParameter< G, A, R, ?> parameter)
Graphical User Interface of Gridarta.
void setName(@NotNull String name)
Sets the name of the parameter.
Factory for Plugin Parameters.
Component getParameterTypeEditor()
Returns the editor component for editing the parameter's type.
Interface for views that display plugin parameters.
final Component parameterTypeEditor
The editor component for editing the parameter's type.
static final Category LOG
The Logger for printing log messages.
String getDescription()
The user-provided description of the value for the user interface.
Base package of all Gridarta classes.
Reflects a game object (object on a map).
final MouseListener mouseListener
The MouseListener that is attached to all editor components.
GameObjects are the objects based on Archetypes found on maps.
final Component parameterNameEditor
The editor component for editing the parameter's name.
void convertType(@NotNull final PluginParameter< G, A, R, ?> pluginParameter, @NotNull final String newType)
Changes the type of a plugin parameter.
String getParameterType()
Returns the parameter type name.
void attachListeners(@NotNull final Component component)
Attaches focusListener and mouseListener to a Component.
Thrown if a parameter does not exist.
Component getConfigComponent()
Returns the editor component for editing the parameter's configuration parameters.
void setDescription(@NotNull String description)
Sets the user-provided description of the value for the user interface.
final FocusListener focusListener
The FocusListener that is attached to all editor components.
A set of components for editing a PluginParameter and its configuration.
Component getParameterNameEditor()
Returns the editor component for editing the parameter's name.
Component getValueComponent()
Returns the editor component for editing the parameter's value.
String getName()
The name of the parameter.
static String [] getTypes()
Returns all available plugin parameter type names.
Factory for creating PluginParameterView instances.
final PluginParameterView pluginParameterView
The PluginParameterView instance for the parameter being edited.
Interface for MapArchObjects.
JComponent getValueComponent()
Returns a JComponent for editing the parameter value.
JComponent getConfigComponent()
Returns a JComponent for editing the parameter configuration.