Gridarta Editor
net.sf.gridarta.plugin.Plugin< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R > Class Template Reference
+ Inheritance diagram for net.sf.gridarta.plugin.Plugin< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >:
+ Collaboration diagram for net.sf.gridarta.plugin.Plugin< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >:

Public Member Functions

void addParameter (@NotNull final PluginParameter< G, A, R, ?> pluginParameter)
 
void addPluginListener (@NotNull final PluginListener listener)
 
Plugin< G, A, R > clonePlugin ()
 
void convertType (@NotNull final PluginParameter< G, A, R, ?> pluginParameter, @NotNull final String newType) throws NoSuchParameterException
 
String getCode ()
 
File getFile ()
 
String getName ()
 
int getParameter (@NotNull final String parameterName)
 
PluginParameter< G, A, R, ?> getParameter (final int index) throws NoSuchParameterException
 
Filter<?, ?> getPluginAsFilter (@NotNull final PluginParameters pluginParameters)
 
boolean hasParameters ()
 
boolean isAutoBoot ()
 
boolean isFilter ()
 
boolean isModified ()
 
boolean isScript ()
 
Iterator< PluginParameter< G, A, R, ?> > iterator ()
 
void newParameter ()
 
 Plugin (@NotNull final String name, @NotNull final PluginParameterFactory< G, A, R > pluginParameterFactory)
 
void removeParameter (final int index)
 
void removePluginListener (@NotNull final PluginListener listener)
 
void resetModified ()
 
void runPlugin (@NotNull final PluginParameters pluginParameters)
 
void setAutoBoot (final boolean autoBoot)
 
void setCode (@NotNull final String code)
 
void setFile (@Nullable final File file)
 
void setFilter (final boolean filter)
 
void setScript (final boolean script)
 
String toString ()
 
Node toXML (@NotNull final PluginParameter< G, A, R, ?> pluginParameter)
 

Private Member Functions

void notifyParametersChangedListeners ()
 
void setModified ()
 

Private Attributes

boolean autoBoot
 
String code = ""
 
final PluginParameterCodec< G, A, R > codec = new PluginParameterCodec<>()
 
File file
 
boolean filter
 
final Collection< PluginListenerlisteners = new CopyOnWriteArrayList<>()
 
boolean modified
 
final String name
 
final List< PluginParameter< G, A, R, ?> > parameters = new ArrayList<>()
 
final PluginParameterFactory< G, A, R > pluginParameterFactory
 
final PluginParameterListener pluginParameterListener = this::setModified
 
boolean script
 

Static Private Attributes

static final Category LOG = Logger.getLogger(Plugin.class)
 

Detailed Description

Model for plugins.

Author
tchize
Andreas Kirschbaum

Definition at line 53 of file Plugin.java.

Constructor & Destructor Documentation

◆ Plugin()

net.sf.gridarta.plugin.Plugin< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.Plugin ( @NotNull final String  name,
@NotNull final PluginParameterFactory< G, A, R >  pluginParameterFactory 
)

Creates a new instance.

Parameters
namethe plugin name
pluginParameterFactorythe plugin parameter factory for creating plugin parameters

Definition at line 138 of file Plugin.java.

Member Function Documentation

◆ addParameter()

void net.sf.gridarta.plugin.Plugin< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.addParameter ( @NotNull final PluginParameter< G, A, R, ?>  pluginParameter)

Adds a plugin parameter to this plugin.

Parameters
pluginParameterthe plugin parameter to add

Definition at line 289 of file Plugin.java.

Referenced by net.sf.gridarta.plugin.Plugin< G, A, R >.clonePlugin(), and net.sf.gridarta.plugin.PluginModelParser< G, A, R >.fromXML().

+ Here is the caller graph for this function:

◆ addPluginListener()

void net.sf.gridarta.plugin.Plugin< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.addPluginListener ( @NotNull final PluginListener  listener)

Adds a PluginListener to be notified about changes.

Parameters
listenerthe change listener

Definition at line 235 of file Plugin.java.

Referenced by net.sf.gridarta.gui.dialog.plugin.PluginEditor< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.createParameterTab().

+ Here is the caller graph for this function:

◆ clonePlugin()

Plugin<G, A, R> net.sf.gridarta.plugin.Plugin< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.clonePlugin ( )

Returns a clone copy of this plugin. The copy include name, executable code, type and a clone of each parameter. The change listeners are not copied.

Returns
a clone of this plugin

Definition at line 264 of file Plugin.java.

Referenced by net.sf.gridarta.plugin.PluginExecutor< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.executePlugin(), and net.sf.gridarta.gui.dialog.plugin.PluginController<?, ?, ?>.runPlugin().

+ Here is the caller graph for this function:

◆ convertType()

void net.sf.gridarta.plugin.Plugin< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.convertType ( @NotNull final PluginParameter< G, A, R, ?>  pluginParameter,
@NotNull final String  newType 
) throws NoSuchParameterException

Changes the type of a plugin parameter.

Parameters
pluginParameterthe plugin parameter
newTypethe new type
Exceptions
NoSuchParameterExceptionif the index is invalid

Definition at line 377 of file Plugin.java.

◆ getCode()

String net.sf.gridarta.plugin.Plugin< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.getCode ( )

◆ getFile()

File net.sf.gridarta.plugin.Plugin< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.getFile ( )

Returns the location to save this plugin to.

Returns
the location to save to, or
null
if the plugin has no associated location

Definition at line 418 of file Plugin.java.

◆ getName()

String net.sf.gridarta.plugin.Plugin< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.getName ( )

Returns the name of this plugin.

Returns
the name of this plugin

Definition at line 148 of file Plugin.java.

Referenced by net.sf.gridarta.gui.dialog.plugin.PluginManager< G, A, R >.pluginManagerRemoveScript(), and net.sf.gridarta.gui.dialog.plugin.PluginController<?, ?, ?>.runPlugin().

+ Here is the caller graph for this function:

◆ getParameter() [1/2]

int net.sf.gridarta.plugin.Plugin< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.getParameter ( @NotNull final String  parameterName)

Returns the index for a plugin parameter name.

Parameters
parameterNamethe plugin parameter name
Returns
the index or
-1
if the parameter name does not exist

Definition at line 187 of file Plugin.java.

Referenced by net.sf.gridarta.plugin.PluginExecutor< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.executePlugin(), and net.sf.gridarta.gui.dialog.plugin.PluginEditor< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.pluginEditorRemoveParameter().

+ Here is the caller graph for this function:

◆ getParameter() [2/2]

PluginParameter<G, A, R, ?> net.sf.gridarta.plugin.Plugin< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.getParameter ( final int  index) throws NoSuchParameterException

Returns the PluginParameter at a given index.

Parameters
indexthe index of parameter to return; must be between
0
and
getParametersCount()
Returns
the plugin parameter
Exceptions
NoSuchParameterExceptionif the index is invalid

Definition at line 303 of file Plugin.java.

◆ getPluginAsFilter()

Filter<?, ?> net.sf.gridarta.plugin.Plugin< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.getPluginAsFilter ( @NotNull final PluginParameters  pluginParameters)

Definition at line 447 of file Plugin.java.

◆ hasParameters()

boolean net.sf.gridarta.plugin.Plugin< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.hasParameters ( )

Returns whether this plugin has at least one parameter.

Returns
whether this plugin has at least one parameter

Definition at line 178 of file Plugin.java.

◆ isAutoBoot()

boolean net.sf.gridarta.plugin.Plugin< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.isAutoBoot ( )

Returns whether this plugin is run whenever the editor starts.

Returns
whether this plugin is run whenever the editor starts

Definition at line 315 of file Plugin.java.

Referenced by net.sf.gridarta.gui.dialog.plugin.PluginEditor< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.isPluginEditorIsAutoRun().

+ Here is the caller graph for this function:

◆ isFilter()

boolean net.sf.gridarta.plugin.Plugin< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.isFilter ( )

Returns whether this plugin is a filter.

Returns
whether this plugin is a filter

Definition at line 331 of file Plugin.java.

Referenced by net.sf.gridarta.gui.dialog.plugin.PluginEditor< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.isPluginIsEditorFilter().

+ Here is the caller graph for this function:

◆ isModified()

boolean net.sf.gridarta.plugin.Plugin< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.isModified ( )

Returns whether the plugin contents have been modified since last save.

Returns
whether the plugin contents have been modified since last save

Definition at line 394 of file Plugin.java.

◆ isScript()

boolean net.sf.gridarta.plugin.Plugin< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.isScript ( )

Returns whether this plugin is a stand-alone plugin.

Returns
whether this plugin is a stand-alone plugin

Definition at line 323 of file Plugin.java.

Referenced by net.sf.gridarta.gui.dialog.plugin.PluginEditor< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.isPluginIsScript().

+ Here is the caller graph for this function:

◆ iterator()

Iterator<PluginParameter<G, A, R, ?> > net.sf.gridarta.plugin.Plugin< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.iterator ( )

Definition at line 432 of file Plugin.java.

◆ newParameter()

void net.sf.gridarta.plugin.Plugin< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.newParameter ( )

◆ notifyParametersChangedListeners()

void net.sf.gridarta.plugin.Plugin< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.notifyParametersChangedListeners ( )
private

◆ removeParameter()

void net.sf.gridarta.plugin.Plugin< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.removeParameter ( final int  index)

Removes a plugin parameter.

Parameters
indexthe plugin parameter's index

Definition at line 225 of file Plugin.java.

Referenced by net.sf.gridarta.gui.dialog.plugin.PluginEditor< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.pluginEditorRemoveParameter().

+ Here is the caller graph for this function:

◆ removePluginListener()

void net.sf.gridarta.plugin.Plugin< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.removePluginListener ( @NotNull final PluginListener  listener)

Removes a PluginListener to be notified about changes.

Parameters
listenerthe change listener

Definition at line 243 of file Plugin.java.

◆ resetModified()

void net.sf.gridarta.plugin.Plugin< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.resetModified ( )

Marks the plugin as unmodified since last save.

Definition at line 401 of file Plugin.java.

Referenced by net.sf.gridarta.plugin.PluginModelParser< G, A, R >.fromXML().

+ Here is the caller graph for this function:

◆ runPlugin()

void net.sf.gridarta.plugin.Plugin< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.runPlugin ( @NotNull final PluginParameters  pluginParameters)

Definition at line 436 of file Plugin.java.

◆ setAutoBoot()

void net.sf.gridarta.plugin.Plugin< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.setAutoBoot ( final boolean  autoBoot)

Sets whether this plugin is run whenever the editor starts.

Parameters
autoBootwhether this plugin is run whenever the editor starts

Definition at line 339 of file Plugin.java.

Referenced by net.sf.gridarta.plugin.PluginModelParser< G, A, R >.fromXML(), and net.sf.gridarta.gui.dialog.plugin.PluginEditor< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.setPluginEditorIsAutoRun().

+ Here is the caller graph for this function:

◆ setCode()

void net.sf.gridarta.plugin.Plugin< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.setCode ( @NotNull final String  code)

Sets the executable code of this plugin.

Parameters
codethe executable code of this plugin

Definition at line 165 of file Plugin.java.

Referenced by net.sf.gridarta.gui.dialog.plugin.PluginEditor< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.createCode(), net.sf.gridarta.plugin.PluginModelParser< G, A, R >.fromXML(), and net.sf.gridarta.plugin.PluginModel< G, A, R >.newPlugin().

+ Here is the caller graph for this function:

◆ setFile()

void net.sf.gridarta.plugin.Plugin< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.setFile ( @Nullable final File  file)

Sets the location to save this plugin to.

Parameters
filethe save location or
null

Definition at line 426 of file Plugin.java.

◆ setFilter()

void net.sf.gridarta.plugin.Plugin< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.setFilter ( final boolean  filter)

Sets whether this plugin is a filter.

Parameters
filterwhether this plugin is a filter

Definition at line 363 of file Plugin.java.

Referenced by net.sf.gridarta.plugin.PluginModelParser< G, A, R >.fromXML(), and net.sf.gridarta.gui.dialog.plugin.PluginEditor< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.setPluginIsEditorFilter().

+ Here is the caller graph for this function:

◆ setModified()

◆ setScript()

void net.sf.gridarta.plugin.Plugin< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.setScript ( final boolean  script)

Sets whether this plugin is a stand-alone plugin.

Parameters
scriptwhether this plugin is a stand-alone plugin

Definition at line 351 of file Plugin.java.

Referenced by net.sf.gridarta.plugin.PluginModelParser< G, A, R >.fromXML(), and net.sf.gridarta.gui.dialog.plugin.PluginEditor< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.setPluginIsScript().

+ Here is the caller graph for this function:

◆ toString()

String net.sf.gridarta.plugin.Plugin< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.toString ( )

Definition at line 200 of file Plugin.java.

◆ toXML()

Node net.sf.gridarta.plugin.Plugin< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.toXML ( @NotNull final PluginParameter< G, A, R, ?>  pluginParameter)

Returns XML representation for a PluginParameter.

Parameters
pluginParameterthe plugin parameter
Returns
the plugin parameter in XML representation

Definition at line 466 of file Plugin.java.

Member Data Documentation

◆ autoBoot

boolean net.sf.gridarta.plugin.Plugin< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.autoBoot
private

◆ code

◆ codec

final PluginParameterCodec<G, A, R> net.sf.gridarta.plugin.Plugin< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.codec = new PluginParameterCodec<>()
private

The PluginParameterCodec for converting PluginParameters to or from XML representation.

Definition at line 90 of file Plugin.java.

Referenced by net.sf.gridarta.plugin.Plugin< G, A, R >.clonePlugin(), and net.sf.gridarta.plugin.Plugin< G, A, R >.toXML().

◆ file

File net.sf.gridarta.plugin.Plugin< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.file
private

The location to save this plugin to; set to

null

if the plugin has no associated location.

Definition at line 118 of file Plugin.java.

Referenced by net.sf.gridarta.plugin.Plugin< G, A, R >.clonePlugin(), net.sf.gridarta.plugin.Plugin< G, A, R >.getFile(), and net.sf.gridarta.plugin.Plugin< G, A, R >.setFile().

◆ filter

boolean net.sf.gridarta.plugin.Plugin< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.filter
private

◆ listeners

final Collection<PluginListener> net.sf.gridarta.plugin.Plugin< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.listeners = new CopyOnWriteArrayList<>()
private

◆ LOG

final Category net.sf.gridarta.plugin.Plugin< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.LOG = Logger.getLogger(Plugin.class)
staticprivate

◆ modified

boolean net.sf.gridarta.plugin.Plugin< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.modified
private

◆ name

◆ parameters

◆ pluginParameterFactory

◆ pluginParameterListener

◆ script

boolean net.sf.gridarta.plugin.Plugin< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.script
private

The documentation for this class was generated from the following file: