Package adams.gui.plugin
Class AbstractToolPlugin<T extends JPanel>
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.gui.plugin.AbstractToolPlugin<T>
-
- All Implemented Interfaces:
LoggingSupporter
,SizeOfHandler
,Serializable
- Direct Known Subclasses:
AbstractImageViewerPlugin
public abstract class AbstractToolPlugin<T extends JPanel> extends LoggingObject
Ancestor for plugins for a tool panel.- Version:
- $Revision$
- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
m_CanceledByUser
whether the user canceled the operation.protected T
m_CurrentPanel
the current panel.protected static Hashtable<Class,Object>
m_LastSetup
for storing the last setup for a plugin.-
Fields inherited from class adams.core.logging.LoggingObject
m_Logger, m_LoggingIsEnabled, m_LoggingLevel
-
-
Constructor Summary
Constructors Constructor Description AbstractToolPlugin()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract boolean
canExecute(T panel)
Checks whether the plugin can be executed given the specified panel.protected abstract String
createLogEntry()
Creates the log message.protected abstract String
doExecute()
Executes the plugin.protected abstract void
doLog(String msg)
Performs the actual logging.String
execute(T panel)
Executes the plugin.boolean
getCanceledByUser()
Returns whether the operation was canceled by the user.abstract String
getCaption()
Returns the text for the menu item to create.ImageIcon
getIcon()
Returns the icon.String
getIconName()
Returns the icon name.protected Object
getLastSetup()
Returns the last setup for this object's class.String
getMenu()
Returns the text for the menu to place the plugin beneath.protected boolean
hasLastSetup()
Checks whether there is a setup available for the class of this object.protected void
log()
Logs the successful action to the log.protected void
setLastSetup(Object setup)
Stores the setup for this object's class.-
Methods inherited from class adams.core.logging.LoggingObject
configureLogger, getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
-
-
-
-
Method Detail
-
getMenu
public String getMenu()
Returns the text for the menu to place the plugin beneath.- Returns:
- the menu
-
getCaption
public abstract String getCaption()
Returns the text for the menu item to create.- Returns:
- the text
-
getIconName
public String getIconName()
Returns the icon name.- Returns:
- the name, null if none available
-
getIcon
public ImageIcon getIcon()
Returns the icon.- Returns:
- the icon or the empty icon if no icon name available
-
hasLastSetup
protected boolean hasLastSetup()
Checks whether there is a setup available for the class of this object.- Returns:
- true if a setup is available
-
getLastSetup
protected Object getLastSetup()
Returns the last setup for this object's class.- Returns:
- the setup, null if none available
-
setLastSetup
protected void setLastSetup(Object setup)
Stores the setup for this object's class.- Parameters:
setup
- the setup to store
-
getCanceledByUser
public boolean getCanceledByUser()
Returns whether the operation was canceled by the user.- Returns:
- true if the user canceled the operation
-
canExecute
public abstract boolean canExecute(T panel)
Checks whether the plugin can be executed given the specified panel.- Parameters:
panel
- the panel to use as basis for decision- Returns:
- true if plugin can be executed
-
doExecute
protected abstract String doExecute()
Executes the plugin.- Returns:
- null if OK, otherwise error message. Using an empty string will suppress the error message display and the creation of a log entry.
-
createLogEntry
protected abstract String createLogEntry()
Creates the log message.- Returns:
- the message, null if none available
-
doLog
protected abstract void doLog(String msg)
Performs the actual logging.- Parameters:
msg
- the message to log
-
log
protected void log()
Logs the successful action to the log.
-
-