Gridarta Editor
AbstractPluginParameter.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.plugin.parameter;
21 
26 import org.jetbrains.annotations.NotNull;
27 
32 public abstract class AbstractPluginParameter<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>, V> implements PluginParameter<G, A, R, V> {
33 
37  @NotNull
39 
43  @NotNull
44  private String name = "[name]";
45 
49  @NotNull
50  private String description = "[description]";
51 
56  }
57 
58  @Override
59  public void addPluginParameterListener(@NotNull final PluginParameterListener listener) {
60  listeners.add(listener);
61  }
62 
63  @Override
64  public void removePluginParameterListener(@NotNull final PluginParameterListener listener) {
65  listeners.remove(listener);
66  }
67 
68  @NotNull
69  @Override
70  public String getName() {
71  return name;
72  }
73 
74  @Override
75  public void setName(@NotNull final String name) {
76  if (this.name.equals(name)) {
77  return;
78  }
79  this.name = name;
80  changed();
81  }
82 
83  @NotNull
84  @Override
85  public String getDescription() {
86  return description;
87  }
88 
89  @Override
90  public void setDescription(@NotNull final String description) {
91  if (this.description.equals(description)) {
92  return;
93  }
94  this.description = description;
95  changed();
96  }
97 
101  protected void changed() {
102  for (final PluginParameterListener listener : listeners.getListeners()) {
103  listener.changed();
104  }
105  }
106 
107 }
String description
The user-provided description of the value for the user interface.
void addPluginParameterListener(@NotNull final PluginParameterListener listener)
T [] getListeners()
Returns an array of all the listeners.
final EventListenerList2< PluginParameterListener > listeners
The listeners to notify.
void removePluginParameterListener(@NotNull final PluginParameterListener listener)
String name
The name of the parameter for the plugin script.
Base package of all Gridarta classes.
Reflects a game object (object on a map).
Definition: GameObject.java:36
void remove(@NotNull final T listener)
Removes a listener.
GameObjects are the objects based on Archetypes found on maps.
Interface for listeners interested in PluginParameter related events.
void add(@NotNull final T listener)
Adds a listener.
Type-safe version of EventListenerList.
void changed()
Notifies all listeners that this plugin parameter has changed.