 |
Gridarta Editor
|
Go to the documentation of this file.
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.MouseListener;
26 import javax.swing.JComboBox;
27 import javax.swing.JTextField;
28 import javax.swing.event.DocumentEvent;
29 import javax.swing.event.DocumentListener;
30 import javax.swing.text.JTextComponent;
40 import org.apache.log4j.Category;
41 import org.apache.log4j.Logger;
42 import org.jetbrains.annotations.NotNull;
105 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) {
122 final JTextComponent textField =
new JTextField(parameter.
getName());
123 textField.getDocument().addDocumentListener(
new DocumentListener() {
126 public void insertUpdate(@NotNull
final DocumentEvent e) {
131 public void removeUpdate(@NotNull
final DocumentEvent e) {
136 public void changedUpdate(@NotNull
final DocumentEvent e) {
143 private void change() {
144 parameter.
setName(textField.getText());
159 final JTextComponent textField =
new JTextField(parameter.
getDescription());
160 textField.getDocument().addDocumentListener(
new DocumentListener() {
163 public void changedUpdate(@NotNull
final DocumentEvent e) {
168 public void insertUpdate(@NotNull
final DocumentEvent e) {
173 public void removeUpdate(@NotNull
final DocumentEvent e) {
180 private void change() {
195 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) {
198 comboBox.addItemListener(e -> {
199 if (e.getStateChange() != ItemEvent.SELECTED) {
203 final String newParameterType = (String) e.getItem();
209 plugin.convertType(parameter, newParameterType);
211 LOG.warn(
"Cannot create parameter for " + ex.getMessage());
227 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) {
JComponent getConfigComponent()
Returns a JComponent for editing the parameter configuration.
final PluginParameterView pluginParameterView
The PluginParameterView instance for the parameter being edited.
String getParameterType()
Returns the parameter type name.
Component getValueComponent()
Returns the editor component for editing the parameter's value.
Component getParameterDescriptionEditor()
Returns the editor component for editing the parameter's description.
Base package of all Gridarta classes.
A set of components for editing a PluginParameter and its configuration.
final Component parameterTypeEditor
The editor component for editing the parameter's type.
String getDescription()
The user-provided description of the value for the user interface.
JComponent getValueComponent()
Returns a JComponent for editing the parameter value.
final Component parameterNameEditor
The editor component for editing the parameter's name.
PluginParameterView newPluginParameterView(@NotNull final Component parent, @NotNull final PluginParameter< G, A, R, ?> parameter)
Reflects a game object (object on a map).
Component getParameterTypeEditor()
Returns the editor component for editing the parameter's type.
Graphical User Interface of Gridarta.
final Component parameterDescriptionEditor
The editor component for editing the parameter's description.
Thrown if a parameter does not exist.
GameObjects are the objects based on Archetypes found on maps.
final FocusListener focusListener
The FocusListener that is attached to all editor components.
private< G extends GameObject< G, A, R >, A extends MapArchObject< A >, R extends Archetype< G, A, R > > Component createDescriptionEditor(final PluginParameter< G, A, R, ?> parameter)
Creates an editor component for a plugin parameter's description.
Interface for MapArchObjects.
Component getConfigComponent()
Returns the editor component for editing the parameter's configuration parameters.
String getName()
The name of the parameter.
private< G extends GameObject< G, A, R >, A extends MapArchObject< A >, R extends Archetype< G, A, R > > Component createNameEditor(final PluginParameter< G, A, R, ?> parameter)
Creates an editor component for a plugin parameter's name.
Component getParameterNameEditor()
Returns the editor component for editing the parameter's name.
static final Category LOG
The Logger for printing log messages.
Factory for creating PluginParameterView instances.
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)
Creates a PluginParameterView instance for a parameter.
void setDescription(@NotNull String description)
Sets the user-provided description of the value for the user interface.
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)
Creates a new instance.
static String[] getTypes()
Returns all available plugin parameter type names.
Factory for Plugin Parameters.
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)
Creates an editor component for a plugin parameter's type.
void attachListeners(@NotNull final Component component)
Attaches focusListener and mouseListener to a {}.
Interface for views that display plugin parameters.
final MouseListener mouseListener
The MouseListener that is attached to all editor components.
void setName(@NotNull String name)
Sets the name of the parameter.