net.sf.jaxodraw.plugin
Class AbstractJaxoPlugin

java.lang.Object
  extended by net.sf.jaxodraw.plugin.AbstractJaxoPlugin
All Implemented Interfaces:
JaxoPlugin, JaxoLocalized
Direct Known Subclasses:
JaxoExportPlugin, JaxoImportPlugin

public abstract class AbstractJaxoPlugin
extends java.lang.Object
implements JaxoPlugin

An abstract superclass for all plugins.

Since:
2.0

Constructor Summary
protected AbstractJaxoPlugin()
          Protected constructor, initialize properties settings.
 
Method Summary
protected  void close(java.io.InputStream inputStream)
          Closes the given InputStream, swallowing any IOException except for logging it in debug mode.
protected  void close(java.io.OutputStream outputStream)
          Closes the given OutputStream, swallowing any IOException except for logging it in debug mode.
protected  void close(java.io.Reader reader)
          Closes the given Reader, swallowing any IOException except for logging it in debug mode.
protected  void close(java.io.Writer writer)
          Closes the given Writer, swallowing any IOException except for logging it in debug mode.
 java.lang.String getClassName()
          Returns the name of this plugin class without the package.
 java.lang.Object getFailure()
          Reason for failure of the last export(), probably an (IO)Exception.
abstract  java.lang.String getFileExtension()
          Extension to be used for plugin files.
abstract  java.lang.String getFileExtensionDescription()
          Description to be used for plugin file extensions.
abstract  java.lang.String getFormatName()
          The name of the plugin (export or import) format.
protected  JaxoPluginDictionary getLang()
          Get a dictionary for this plugin.
protected  JaxoPluginLogger getLog()
          Get a logger for this plugin.
 java.awt.Component getParentComponent()
          Parent component for dialogs.
 java.util.Properties getProperties()
          Return the current set of properties.
 java.lang.String getProperty(java.lang.String key)
          Returns the property for the specified key or null if the property is not found.
 java.lang.String getProperty(java.lang.String key, java.lang.String defaultValue)
          Returns the property for the specified key or the given defaultValue if the property is not found.
 java.lang.String getShortGraphName()
          Returns the short name of the current graph.
 boolean hasFailed()
          Checks if the last export() has failed.
 boolean isSilent()
          If silent, export() will/should not show any error messages.
 void loadProperties()
          Each plugin should be able to load a set of properties from some default location.
 java.lang.String pluginName()
          Return the name of this plugin.
protected  void registerDictionary(java.lang.Class c)
          Register a plugin class for language translations.
protected  void setFailure(java.lang.Object value)
          Sets the reason for an export failure.
 void setParentComponent(java.awt.Component value)
          Sets the parent component of this dialog.
 void setProperty(java.lang.String key, java.lang.String value)
          Sets a property to the given value.
 void setShortGraphName(java.lang.String newName)
          Sets a short name for the current graph.
 void setSilent(boolean value)
          Sets the silent mode.
 void storeProperties()
          Stores the current set of properties in a persistent file, so they are automatically available at every session start-up.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.sf.jaxodraw.plugin.JaxoPlugin
description, getShortName, makeAvailableAtRuntime, pluginId, version
 
Methods inherited from interface net.sf.jaxodraw.util.JaxoLocalized
updateLanguage
 

Constructor Detail

AbstractJaxoPlugin

protected AbstractJaxoPlugin()
Protected constructor, initialize properties settings.

Method Detail

pluginName

public java.lang.String 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:
pluginName in interface JaxoPlugin
Returns:
the name of this plugin.

registerDictionary

protected void registerDictionary(java.lang.Class c)
Register a plugin class for language translations. This method has to be called before any calls to getLang().

Parameters:
c - the class to register for bundle lookup.

getParentComponent

public java.awt.Component getParentComponent()
Parent component for dialogs.

Returns:
The parent component.

setParentComponent

public void setParentComponent(java.awt.Component value)
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

public final java.lang.Object 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

protected void setFailure(java.lang.Object value)
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

public final void setShortGraphName(java.lang.String newName)
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

public final java.lang.String getShortGraphName()
Returns the short name of the current graph.

Returns:
The short name of the current graph.

getProperty

public java.lang.String getProperty(java.lang.String key)
Returns the property for the specified key or null if the property is not found.

Parameters:
key - the property key.
Returns:
the property value or null if this property does not exist.

getProperty

public java.lang.String getProperty(java.lang.String key,
                                    java.lang.String defaultValue)
Returns the property for the specified key or the given defaultValue if the property is not found.

Parameters:
key - the property key.
defaultValue - a default value.
Returns:
the property value.

setProperty

public void setProperty(java.lang.String key,
                        java.lang.String value)
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:
loadProperties in interface JaxoPlugin

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

public java.util.Properties getProperties()
Return the current set of properties.

Returns:
The current set of properties.

getClassName

public final java.lang.String getClassName()
Returns the name of this plugin class without the package.

Returns:
the name of this plugin class without the package.

close

protected void close(java.io.Reader reader)
Closes the given Reader, swallowing any IOException except for logging it in debug mode.

Parameters:
reader - The Reader to close.

close

protected void close(java.io.InputStream inputStream)
Closes the given InputStream, swallowing any IOException except for logging it in debug mode.

Parameters:
inputStream - The InputStream to close.

close

protected void close(java.io.Writer writer)
Closes the given Writer, swallowing any IOException except for logging it in debug mode.

Parameters:
writer - The Writer to close.

close

protected void close(java.io.OutputStream outputStream)
Closes the given OutputStream, swallowing any IOException except for logging it in debug mode.

Parameters:
outputStream - The OutputStream to close.

getLog

protected JaxoPluginLogger getLog()
Get a logger for this plugin.

Returns:
a logger.

getLang

protected JaxoPluginDictionary getLang()
Get a dictionary for this plugin. If no dictionary has yet been registered with registerDictionary(java.lang.Class) then an IllegalStateException is thrown.

Returns:
a dictionary.
See Also:
registerDictionary(java.lang.Class)

getFormatName

public abstract java.lang.String getFormatName()
The name of the plugin (export or import) format.

Returns:
An (internationalized) name of the plugin format.

getFileExtension

public abstract java.lang.String getFileExtension()
Extension to be used for plugin files.

Returns:
The file extension.

getFileExtensionDescription

public abstract java.lang.String getFileExtensionDescription()
Description to be used for plugin file extensions.

Returns:
An (internationalized) description of the file extension.


Licensed under GPL. For more information, see http://jaxodraw.sourceforge.net/license.html or the LICENSE file in the jaxodraw distribution.