Class AbstractJaxoPlugin
java.lang.Object
net.sf.jaxodraw.plugin.AbstractJaxoPlugin
- All Implemented Interfaces:
JaxoPlugin, JaxoLocalized
- Direct Known Subclasses:
JaxoExportPlugin, JaxoImportPlugin
An abstract superclass for all plugins.
- Since:
- 2.0
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedProtected constructor, initialize properties settings. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidCloses the given Closeable, swallowing any IOException except for logging it in debug mode.final StringReturns the name of this plugin class without the package.final ObjectReason for failure of the last export(), probably an (IO)Exception.abstract StringExtension to be used for plugin files.abstract StringDescription to be used for plugin file extensions.abstract StringThe name of the plugin (export or import) format.protected JaxoPluginDictionarygetLang()Get a dictionary for this plugin.protected JaxoPluginLoggergetLog()Get a logger for this plugin.Parent component for dialogs.Return the current set of properties.getProperty(String key) Returns the property for the specified key ornullif the property is not found.getProperty(String key, String defaultValue) Returns the property for the specified key or the given defaultValue if the property is not found.final StringReturns the short name of the current graph.final booleanChecks if the last export() has failed.final booleanisSilent()If silent, export() will/should not show any error messages.voidEach plugin should be able to load a set of properties from some default location.Return the name of this plugin.protected voidregisterDictionary(Class<?> c) Register a plugin class for language translations.protected voidsetFailure(Object value) Sets the reason for an export failure.voidsetParentComponent(Component value) Sets the parent component of this dialog.voidsetProperty(String key, String value) Sets a property to the given value.final voidsetShortGraphName(String newName) Sets a short name for the current graph.voidsetSilent(boolean value) Sets the silent mode.voidStores the current set of properties in a persistent file, so they are automatically available at every session start-up.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface JaxoLocalized
updateLanguageMethods inherited from interface JaxoPlugin
description, getShortName, makeAvailableAtRuntime, pluginId, version
-
Constructor Details
-
AbstractJaxoPlugin
protected AbstractJaxoPlugin()Protected constructor, initialize properties settings.
-
-
Method Details
-
pluginName
Return the name of this plugin. This is the name that will be presented in the JaxoDraw user interface. For standard plugins the name should be of the form "jaxodraw-" + getShortName() + "-plugin", but it can be anything else.- Specified by:
pluginNamein interfaceJaxoPlugin- Returns:
- the name of this plugin.
-
registerDictionary
-
getParentComponent
-
setParentComponent
Sets the parent component of this dialog.- Parameters:
value- The parent component to set.
-
hasFailed
public final boolean hasFailed()Checks if the last export() has failed.- Returns:
- True if the last export has failed.
-
getFailure
Reason for failure of the last export(), probably an (IO)Exception. This is reset to 'null' at the beginning of export().- Returns:
- The cause of the failure.
-
setFailure
Sets the reason for an export failure.- Parameters:
value- The reason to set.
-
isSilent
public final boolean isSilent()If silent, export() will/should not show any error messages.- Returns:
- True if silent mode is on.
-
setSilent
public void setSilent(boolean value) Sets the silent mode.- Parameters:
value- True for silent mode on.
-
setShortGraphName
Sets a short name for the current graph. This is used eg as titles in preview windows, etc.- Parameters:
newName- The name to set.
-
getShortGraphName
Returns the short name of the current graph.- Returns:
- The short name of the current graph.
-
getProperty
-
getProperty
-
setProperty
Sets a property to the given value. Internally the key will be prepended with the pluginId() because plugins with the same short name can share the same properties file.- Parameters:
key- the key of the property.value- the value corresponding to key.
-
loadProperties
public void loadProperties()Each plugin should be able to load a set of properties from some default location. The default JaxoDraw property files are stored in the plugins cache directory and named like "jaxodraw-JaxoPlugin.getShortName()-plugin.properties".- Specified by:
loadPropertiesin interfaceJaxoPlugin
-
storeProperties
public void storeProperties()Stores the current set of properties in a persistent file, so they are automatically available at every session start-up. -
getProperties
Return the current set of properties.- Returns:
- The current set of properties.
-
getClassName
Returns the name of this plugin class without the package.- Returns:
- the name of this plugin class without the package.
-
close
Closes the given Closeable, swallowing any IOException except for logging it in debug mode.- Parameters:
closeable- The Closeable to close.
-
getLog
-
getLang
Get a dictionary for this plugin. If no dictionary has yet been registered withregisterDictionary(java.lang.Class)then an IllegalStateException is thrown.- Returns:
- a dictionary.
- See Also:
-
getFormatName
The name of the plugin (export or import) format.- Returns:
- An (internationalized) name of the plugin format.
-
getFileExtension
Extension to be used for plugin files.- Returns:
- The file extension.
-
getFileExtensionDescription
Description to be used for plugin file extensions.- Returns:
- An (internationalized) description of the file extension.
-