public abstract class AbstractWandoraTool extends java.lang.Object implements WandoraTool, java.lang.Runnable
AbstractWandoraTool provides basic services and methods to
all WandoraTool classes. All tools should extend this
abstract class.| Modifier and Type | Field and Description |
|---|---|
private boolean |
internalForceStop |
private WandoraToolLogger |
lastLogger |
private WandoraToolLogger |
logger |
private Wandora |
runAdmin |
private Context |
runContext |
private java.lang.Exception |
toolException |
private static java.util.HashSet<java.lang.Class> |
toolLocks |
private static java.util.HashMap<java.lang.Thread,Tuples.T2<java.lang.Class,java.lang.Long>> |
toolThreads |
| Constructor and Description |
|---|
AbstractWandoraTool() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
addUndoMarker() |
protected void |
addUndoMarker(java.lang.String label) |
boolean |
allowMultipleInvocations()
Should the tool allow more than one running occurrence of same tool class.
|
static void |
clearAllThreads() |
void |
clearThreads() |
static void |
clearThreads(java.lang.Class c) |
boolean |
clearToolLock()
Releases a tool lock for this (extending) tool class.
|
static boolean |
clearToolLock(java.lang.Class c)
Releases a tool lock for a given tool class.
|
static int |
clearToolLocks()
Releases all locks that prevent tools to be executed again.
|
void |
configure(Wandora wandora,
Options options,
java.lang.String prefix)
If the tool is configurable, shows an user interface to configure the tool.
|
void |
execute(Wandora wandora)
Runs the tool.
|
void |
execute(Wandora wandora,
java.awt.event.ActionEvent event)
This is the primary entry point to execute the tool.
|
boolean |
forceStop()
Logger should have a mechanism to receive user interruption.
|
boolean |
forceStop(ConfirmResult result) |
Context |
getContext()
Return tools
Context. |
WandoraToolLogger |
getCurrentLogger() |
WandoraToolLogger |
getDefaultLogger() |
java.lang.String |
getDescription()
AdminToolManager views tool descriptions while user browses available
tools and build user customizable GUI elements such as Tools menu.
|
java.lang.String |
getHistory()
Returns all collected logs as a string.
|
javax.swing.Icon |
getIcon()
All tools may have identifying graphic icon used within tool GUI elements.
|
WandoraToolLogger |
getLastLogger() |
java.lang.String |
getName()
Tools name represent the tool in UI unless the tool has been given
explicitly another GUI name.
|
int |
getState()
Returns logger's current state.
|
java.util.ArrayList<Tuples.T2<java.lang.Thread,java.lang.Long>> |
getThreads() |
static java.util.ArrayList<Tuples.T2<java.lang.Thread,java.lang.Long>> |
getThreads(java.lang.Class c) |
SimpleMenuItem |
getToolMenuItem(Wandora wandora,
java.lang.String instanceName)
WandoraWandoraTool should be GUI independent allowing tool
to be inserted into various type of GUI elements such as menus. |
SimpleMenuItem |
getToolMenuItem(Wandora wandora,
java.lang.String instanceName,
javax.swing.KeyStroke keyStroke) |
static java.lang.String |
getTopicName(Topic t) |
WandoraToolType |
getType()
Tool type is used to categorize tools.
|
void |
hlog(java.lang.String message)
Shortcut to access tool's logger.
|
void |
initialize(Wandora wandora,
Options options,
java.lang.String prefix)
Initializes a tool with options saved in the options.
|
static void |
interruptAllThreads() |
void |
interruptThreads() |
static void |
interruptThreads(java.lang.Class c) |
boolean |
isConfigurable()
Whether this tool is configurable.
|
boolean |
isRunning()
Checks if this (extended) tool is running.
|
boolean |
isRunning(java.lang.Class c)
Checks if given tool is already running and
locked.
|
void |
lockLog(boolean lock)
Should the logger change current log message? If true, the log should
keep the current message visible although new log data is generated.
|
void |
log(java.lang.Error e)
Shortcut to access tool's logger.
|
void |
log(java.lang.Exception e)
Shortcut to access tool's logger.
|
void |
log(java.lang.String message)
Shortcut to access tool's logger.
|
void |
log(java.lang.String message,
java.lang.Exception e)
Shortcut to access tool's logger.
|
boolean |
requiresRefresh()
If any visible topic has been changed during tool execution GUI is
automatically refreshed.
|
void |
run()
Runs the tool.
|
boolean |
runInOwnThread()
Whether or not this tool should fork own thread.
|
void |
setContext(Context context)
Each executed tool has
Context containing context source and
context objects. |
void |
setDefaultLogger()
AbstractWandoraTool provides simple framework for tool-user
communication. |
void |
setLogTitle(java.lang.String title)
Logging system may have a title.
|
void |
setProgress(int n)
Logger may view progress information for operation.
|
void |
setProgressMax(int maxn)
Set the progress point where operation is ready.
|
void |
setState(int state)
Sets logger's current state.
|
void |
setToolLogger(WandoraToolLogger logger)
Sets tools logger.
|
void |
singleLog(java.lang.Exception e) |
void |
singleLog(java.lang.String message) |
void |
singleLog(java.lang.String message,
java.lang.Exception e) |
TopicMap |
solveContextTopicMap(Wandora wandora,
Context context) |
protected java.lang.String |
solveNameForTopicMap(Wandora wandora,
TopicMap topicMap) |
void |
writeOptions(Wandora wandora,
Options options,
java.lang.String prefix)
If the tool is configurable, saves all current tool options.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitexecuteprivate java.lang.Exception toolException
private WandoraToolLogger lastLogger
private WandoraToolLogger logger
private boolean internalForceStop
private Wandora runAdmin
private Context runContext
private static final java.util.HashSet<java.lang.Class> toolLocks
private static final java.util.HashMap<java.lang.Thread,Tuples.T2<java.lang.Class,java.lang.Long>> toolThreads
public void execute(Wandora wandora) throws TopicMapException
WandoraToolexecute in interface WandoraToolTopicMapExceptionpublic void execute(Wandora wandora, java.awt.event.ActionEvent event) throws TopicMapException
WandoraToolActionListener.execute in interface WandoraToolwandora - is the application context.event - is the event triggering the event.TopicMapExceptionpublic void run()
runInOwnThread returns false,
this method is called directly instead of creating a new Thread.
This method passes the execution to extending implementation of
execute.run in interface java.lang.Runnablepublic boolean isRunning()
isRunning in interface WandoraToolpublic boolean isRunning(java.lang.Class c)
public boolean clearToolLock()
public static boolean clearToolLock(java.lang.Class c)
c - Tool class to be released.public static int clearToolLocks()
public void interruptThreads()
public static void interruptThreads(java.lang.Class c)
public static void interruptAllThreads()
public void clearThreads()
public static void clearThreads(java.lang.Class c)
public static void clearAllThreads()
public java.util.ArrayList<Tuples.T2<java.lang.Thread,java.lang.Long>> getThreads()
public static java.util.ArrayList<Tuples.T2<java.lang.Thread,java.lang.Long>> getThreads(java.lang.Class c)
public boolean runInOwnThread()
public WandoraToolType getType()
Tool type is used to categorize tools. Tool type has no real effect today, it is merely an informative property of a tool.
getType in interface WandoraToolpublic java.lang.String getName()
getName in interface WandoraToolpublic java.lang.String getDescription()
getDescription in interface WandoraToolpublic boolean requiresRefresh()
If any visible topic has been changed during tool execution GUI is automatically refreshed. If tool doesn't change topics but GUI still requires refresh, tool should override this method and return true.
For example tools that alter the GUI but change no topics should return true.
requiresRefresh in interface WandoraToolpublic boolean allowMultipleInvocations()
public SimpleMenuItem getToolMenuItem(Wandora wandora, java.lang.String instanceName)
WandoraWandoraTool should be GUI independent allowing tool
to be inserted into various type of GUI elements such as menus.
This method is used to wrap tool into SimpleMenuItem.getToolMenuItem in interface WandoraToolpublic SimpleMenuItem getToolMenuItem(Wandora wandora, java.lang.String instanceName, javax.swing.KeyStroke keyStroke)
public javax.swing.Icon getIcon()
getIcon should return Icon object of
the tool.getIcon in interface WandoraToolpublic void initialize(Wandora wandora, Options options, java.lang.String prefix) throws TopicMapException
initialize in interface WandoraToolTopicMapExceptionpublic boolean isConfigurable()
isConfigurable in interface WandoraToolpublic void configure(Wandora wandora, Options options, java.lang.String prefix) throws TopicMapException
configure in interface WandoraToolTopicMapExceptionpublic void writeOptions(Wandora wandora, Options options, java.lang.String prefix)
writeOptions in interface WandoraToolpublic void setContext(Context context)
Context containing context source and
context objects. Context source is a GUI element that originates the
tool execution. Context object reads context source and
solves context objects available in tool. Generally tools modify context
objects. setContext method is used to set the Context
object that transforms context source into context objects. If tool has
no explicitly set context AbstractWandoraTool uses LayeredTopicContext.setContext in interface WandoraToolcontext - Tool's new context.public Context getContext()
Context. If tool uses default context ie.
setContext has not been called with valid Context
object, tool's context remains undefined (null) until tool
is executed. Tool context is resolved finally during execution. More over
context source and thus context object at least are solved during
execution, not before.getContext in interface WandoraToolpublic void setDefaultLogger()
AbstractWandoraTool provides simple framework for tool-user
communication. If Wandora object is passed to the execute method
logger is simple dialog window capable to output tool
originated messages and progress meter. Default dialog also contains simple
stop button allowing user to interrupt the tool execution (if tool
acknowledges user interrupts). Default logger dialog is activated
with setDefaultLogger method.
Note: If your tool requires rich interaction between user and tool You may not want to activate default logger at the very beginning of your tool.
public WandoraToolLogger getDefaultLogger()
public WandoraToolLogger getCurrentLogger()
public WandoraToolLogger getLastLogger()
public void singleLog(java.lang.String message)
public void singleLog(java.lang.Exception e)
public void singleLog(java.lang.String message,
java.lang.Exception e)
public void setToolLogger(WandoraToolLogger logger)
WandoraToolsetToolLogger in interface WandoraToollogger - is new logger object.public void hlog(java.lang.String message)
WandoraToolhlog in interface WandoraToolhlog in interface WandoraToolLoggerhlog in interface TopicMapLoggermessage - to be logged.public void log(java.lang.String message)
WandoraToollog in interface WandoraToollog in interface WandoraToolLoggerlog in interface TopicMapLoggermessage - to be logged.public void log(java.lang.String message,
java.lang.Exception e)
WandoraToollog in interface WandoraToollog in interface WandoraToolLoggerlog in interface TopicMapLoggermessage - to be logged.e - Exception to be logged.public void log(java.lang.Exception e)
WandoraToollog in interface WandoraToollog in interface WandoraToolLoggerlog in interface TopicMapLoggere - Exception to be logged.public void log(java.lang.Error e)
WandoraToollog in interface WandoraToollog in interface WandoraToolLoggere - Error to be logged.public void setProgress(int n)
WandoraToolLoggersetProgressMax.setProgress in interface WandoraToolLoggersetProgress in interface TopicMapLoggern - is integer value representing the state of current progress.public void setProgressMax(int maxn)
WandoraToolLoggersetProgressMax in interface WandoraToolLoggersetProgressMax in interface TopicMapLoggermaxn - is integer value representing progress when the task is ready.public void setLogTitle(java.lang.String title)
WandoraToolLoggersetLogTitle in interface WandoraToolLoggersetLogTitle in interface TopicMapLoggertitle - is a string viewed as a title of logger window.public void lockLog(boolean lock)
WandoraToolLoggerlockLog in interface WandoraToolLoggerlock - boolean variable that locks or unlocks logger.public java.lang.String getHistory()
WandoraToolLoggergetHistory in interface WandoraToolLoggerpublic void setState(int state)
WandoraToolLoggersetState in interface WandoraToolLoggerstate - of logger.public int getState()
WandoraToolLoggergetState in interface WandoraToolLoggerpublic boolean forceStop()
WandoraToolLogger
Logger should have a mechanism to receive user interruption. Typically this
is realized with a Cancel or Stop button. Whenever the user interrupts the
operation the logger should return true as the return code of forceStop
method.
forceStop mechanism relies that the tool using the logger polls
forceStop method frequently and cancels the operation as soon as
true is returned.
forceStop in interface WandoraToolLoggerforceStop in interface TopicMapLoggerpublic boolean forceStop(ConfirmResult result)
protected java.lang.String solveNameForTopicMap(Wandora wandora, TopicMap topicMap)
public static java.lang.String getTopicName(Topic t)
protected void addUndoMarker()
protected void addUndoMarker(java.lang.String label)
Copyright 2004-2015 Wandora Team