|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
public interface PluginContext
A plug-in context is passed to a plug-in when it is initialized, shown, or hidden. It allows access to functionality and data from the Strange Eons application that may be of use to the plug-in.
| Nested Class Summary | |
|---|---|
static class |
PluginContext.ComponentType
Enumeration type for creating Strange Eons interface components. |
| Field Summary | |
|---|---|
static int |
ALT
A modifier constant indicating that an Alt key was held down. |
static int |
COMMAND
A modifier constant indicating that the Command key (on Apple computers) was held down. |
static int |
CONTROL
A modifier constant indicating that a Control or Ctrl key was held down. |
static int |
CTRL
A modifier constant indicating that a Control or Ctrl key was held down. |
static int |
MENU
A modifier constant indicating that the key used as a menu accelerator key on this platform was held down. |
static int |
META
A modifier constant indicating that a Meta key was held down. |
static int |
SHIFT
A modifier constant indicating that a Shift key was held down. |
| Method Summary | |
|---|---|
void |
addUIText(java.util.Locale locale,
java.lang.String baseName)
This method loads a resource bundle and adds its definitions to the application's UI text database. |
void |
addUIText(java.lang.String baseName)
This method loads a resource bundle and adds its definitions to the application's UI text database. |
void |
breakpoint()
If the debugger is available, generate a breakpoint at the next opportunity. |
boolean |
canInsertMarkup()
Return true if mark-up can be inserted into the current
editor. |
int |
compareMicroversions(java.lang.String lhs,
java.lang.String rhs)
Compares two microversions strings. |
StrangeEonsEditor |
createEditor(java.lang.String classMapKey)
Create a new editor for a game component and open it in Strange Eons. |
java.awt.Component |
createInterfaceComponent(PluginContext.ComponentType type)
Create a Strange Eons user interface component that can be added to the plug-in's user interface. |
GameObject |
getActiveComponent()
Get the game component that is edited by the currently active component editor. |
StrangeEonsEditor |
getActiveEditor()
Returns the game component editor that the user has currently activated. |
StrangeEonsApplication |
getApplication()
Returns a reference to the StrangeEonsApplication
that this plug-in is running within. |
java.util.Locale |
getGameLocale()
Returns the preferred locale for game text (printed on cards). |
IntegerPluralizer |
getGamePluralizer()
Returns a pluralizer for the game locale. |
int |
getMajorVersion()
Returns the major version number of Strange Eons. |
java.lang.String |
getMicroversion()
Returns the microversion of the build of Strange Eons that the plug-in is running within. |
int |
getMinorVersion()
Returns the minor version number of Strange Eons. |
int |
getModifiers()
Returns the modifier keys held down when the plug-in was activated. |
java.lang.Object |
getNamedObject(java.lang.String name)
Gets a named object in the database. |
java.awt.Frame |
getParentFrame()
Returns a Frame that can be used as the parent window
for dialog boxes. |
java.lang.String |
getPluginSetting(java.lang.String settingKey,
java.lang.String defaultValue)
Return the value of one of this plug-in's private settings. |
Settings |
getSettings()
Returns a Settings instance that can be used to read and write
this plug-in's private settings. |
java.util.Locale |
getUILocale()
Returns the preferred locale for user interface (UI) components. |
IntegerPluralizer |
getUIPluralizer()
Returns a pluralizer for the user interface (UI) locale. |
java.lang.String |
getVersion()
Returns the full version description text for the version of Strange Eons the plug-in is running within. |
void |
insertMarkup(java.lang.String markup)
Insert mark-up text into the edit control of the active editor that has input focus. |
void |
insertMarkupTags(java.lang.String prefix,
java.lang.String suffix)
Surround the currently selected text in the active edit control of the active editor with mark-up. |
boolean |
isInformationProbe()
Provides a hint about whether the plug-in should perform expensive initialization operations. |
boolean |
isNameDefined(java.lang.String name)
Returns true if an object has been associated with the given
name. |
void |
removeNamedObject(java.lang.String name)
End the association between name and an object. |
void |
setNamedObject(java.lang.String name,
java.lang.Object object)
Sets a named object in the database. |
void |
setPluginSetting(java.lang.String settingKey,
java.lang.String settingValue)
Set the value of one of this plug-in's private settings. |
java.lang.String |
string(java.lang.String key)
This method returns the value of one of Strange Eons's internal user interface strings. |
java.lang.String |
string(java.lang.String key,
java.lang.Object... formatParameters)
This method returns a formatted string based on the value of one of Strange Eons's internal user interface strings. |
| Field Detail |
|---|
static final int SHIFT
static final int ALT
static final int CONTROL
static final int CTRL
static final int META
static final int COMMAND
static final int MENU
| Method Detail |
|---|
int getMajorVersion()
For example, if the version diplayed in the About dialog is
"1.80 beta 6", the value returned by getMajorVersion
will be 1 and the value returned by getMinorVersion
will be 80.
int getMinorVersion()
getMajorVersion() for additional details.
java.lang.String getVersion()
java.lang.String getMicroversion()
int compareMicroversions(java.lang.String lhs,
java.lang.String rhs)
lhs version
is newer than the rhs version, returns -1. If
the lhs version is older, returns 1. If the versions
are the same, returns 0.
lhs - the "left-hand" microversion string to comparerhs - the "right-hand" microversion string to compare
java.awt.Frame getParentFrame()
Frame that can be used as the parent window
for dialog boxes.
Typically this will be the main application window.
The method might return null, but null
is a valid value when specifying a dialog's parent frame.
java.util.Locale getUILocale()
java.util.Locale getGameLocale()
IntegerPluralizer getUIPluralizer()
IntegerPluralizer getGamePluralizer()
StrangeEonsEditor getActiveEditor()
null.
In most cases, plug-ins will actually want to interact with the
component rather than the component's editor window, and so should
call getActiveComponent() instead.
nullStrangeEonsApplication getApplication()
StrangeEonsApplication
that this plug-in is running within.
GameObject getActiveComponent()
GameObject interface, which can be used
to query and modify the actual component.
To work directly with the component instead of through this adapter,
use getActiveEditor().getGameComponent(). Alternatively,
you may call the GameObject#unwrap() method of the adapter.
null
if no editor is activeint getModifiers()
StrangeEonsEditor createEditor(java.lang.String classMapKey)
classMapKey,
which must be one of the class keys defined in
resources/editors/classmap.txt.
As a convenience, keys that begin with "app-new-" may leave
off this prefix.
Once the editor is created and added, it becomes the active editor. (However, if the plug-in is modeless, the user may activate a different editor at any time.)
classMapKey - the key for the type of editor to create
java.lang.IllegalArgumentException - if the key is not valid
java.lang.String getPluginSetting(java.lang.String settingKey,
java.lang.String defaultValue)
settingKey - the key name to look up a value fordefaultValue - the default value to use if the key is not defined
void setPluginSetting(java.lang.String settingKey,
java.lang.String settingValue)
settingValue is null, then the
key will be deleted if it exists.
settingKey - the key name to set the value ofsettingValue - the value to assign to the key, or null to delete the keySettings getSettings()
Settings instance that can be used to read and write
this plug-in's private settings. Note that this is not related in any
way to the private settings of any game conponent. If this context is
not associated with a plug-in, a shared default settings space is used
instead.
Settings instance that uses this plug-in's private settings spacejava.awt.Component createInterfaceComponent(PluginContext.ComponentType type)
type - the type of component to create
boolean canInsertMarkup()
true if mark-up can be inserted into the current
editor. Mark-up can be inserted when the last text component that had
input focus was a text component on the active editor.
Mark-up is inserted by calling insertMarkup(String).
true if mark-upvoid insertMarkup(java.lang.String markup)
IllegalStateException will be thrown.
Use canInsertMarkup to check whether there is currently
an appropriate target.
markup - the mark-up text to be inserted
java.lang.IllegalStateException - if mark-up text cannot be inserted
void insertMarkupTags(java.lang.String prefix,
java.lang.String suffix)
prefix inserted
before it and suffix inserted after it, and the
selection will be extended to include the newly inserted text.
If the selection already includes the specified
mark-up, then the prefix and suffix
will be removed from the string.
This is most commonly be used to surround the selection
with mark-up tags: for example, calling
insertMarkupTags( "<b>", "</b>" )
would insert mark-up that would cause the current selection
to be displayed in bold.
prefix - the text to insert before the selectionsuffix - the text to insert after the selection
java.lang.IllegalStateException - if mark-up text cannot be insertedjava.lang.String string(java.lang.String key)
ResourceBundle.
However, it might be convenient to re-use Strange Eons's own localized
text where it already provides a string that you need.
Some common examples might be the "cancel", "cut", "copy", and "paste" keys.
If key is not defined in the Strange Eons interface
text resources, this method returns a string equivalent to the
value of "MISSING UI STRING: " + key.
key - the resource string key to create localized text for
key, or an error message string
java.lang.String string(java.lang.String key,
java.lang.Object... formatParameters)
String.format( uiLocale, string(key), formatParameters ),
where uiLocale is a Locale representing the
current user interface locale.
key - the resource string key to create a localized format string forformatParameters - the parameters to substitute into the format string
void addUIText(java.lang.String baseName)
string(java.lang.String) methods will return
the values of any new keys in the bundle, based on the UI locale.
The base name is a relative URL within the resources folder,
except that the file name should consist of only the base name, without
a locale or the ".properties" extension. For example, the following
baseName points to the standard UI text resource bundle:
text/interface/eons-text.
baseName - the base name of the resource bundle to open
void addUIText(java.util.Locale locale,
java.lang.String baseName)
Locale.
For example, to add definitions appropriate for the current game
language, one could use code similar to the following:
PluginContext.addUIText( PluginContext.getGameLocale(), "custom/text/mybundle" );
Any keys that are already
defined in the application will be ignored. After adding the
contents of the bundle, the string(java.lang.String) methods will return
the values of any new keys in the bundle.
The base name is a relative URL within the resources folder,
except that the file name should consist of only the base name, without
a locale or the ".properties" extension. For example, the following
baseName points to the standard UI text resource bundle:
text/interface/eons-text.
baseName - the base name of the resource bundle to open#addUIText(java.lang.String)}boolean isInformationProbe()
true,
then the plug-in is only being initialized to determine its name,
version, description, and/or type. This instance of the plug-in will not
be shown. The plug-in may use this as a hint that it need only
perform enough initialization to provide these services.
true if the plug-in will only be queried for informationvoid breakpoint()
breakpoint() function.
void setNamedObject(java.lang.String name,
java.lang.Object object)
All access to named objects is threadsafe.
Example:
// store an object for later use (a function, but it could be anything)
PluginContext.setNamedObject( "test", function hello() { println( "hello" ); } );
// later, in another script, call the function we stored
PluginContext.getNamedObject( "test" )();
name - an identifier that can be used to recall the specified object laterobject - an arbitrary object that will be associated with name
java.lang.IllegalArgumentException - if an object with this name has already been setjava.lang.Object getNamedObject(java.lang.String name)
All access to named objects is threadsafe.
name - an identifier that can be used to recall the specified object later
name
java.lang.IllegalArgumentException - if an object with this name has not been setboolean isNameDefined(java.lang.String name)
true if an object has been associated with the given
name.
All access to named objects is threadsafe.
name - the identifier to test
true if an object has been set for name, and not removedvoid removeNamedObject(java.lang.String name)
name and an object. Note that
the only way to update an existing object is to first remove it, then
set it again. This helps prevent use of the same name by multiple
plug-ins.
All access to named objects is threadsafe.
name - the identifier to remove
java.lang.IllegalArgumentException - if an object with this name has not been set
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||