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 booleanm_CanceledByUserwhether the user canceled the operation.protected Tm_CurrentPanelthe current panel.protected static Hashtable<Class,Object>m_LastSetupfor 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 booleancanExecute(T panel)Checks whether the plugin can be executed given the specified panel.protected abstract StringcreateLogEntry()Creates the log message.protected abstract StringdoExecute()Executes the plugin.protected abstract voiddoLog(String msg)Performs the actual logging.Stringexecute(T panel)Executes the plugin.booleangetCanceledByUser()Returns whether the operation was canceled by the user.abstract StringgetCaption()Returns the text for the menu item to create.ImageIcongetIcon()Returns the icon.StringgetIconName()Returns the icon name.protected ObjectgetLastSetup()Returns the last setup for this object's class.StringgetMenu()Returns the text for the menu to place the plugin beneath.protected booleanhasLastSetup()Checks whether there is a setup available for the class of this object.protected voidlog()Logs the successful action to the log.protected voidsetLastSetup(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.
-
-