AbstractWandoraTool

From WandoraWiki
Jump to: navigation, search

An abstract class implementing WandoraTool. This tool implements some of the WandoraTool methods with default implementations and provides commonly used methods and helppers for other tools. You should extends this class almost always when you make a new tool. See also Writing your own tool.

Following contains a description of the most relevant methods.

Method Description
execute(Wandora,Context) Main method of the tool. In all cases you must implement this method. It should perform all processing of the tool. You can open dialogs for user input if you want to.
getName() This method returns the name of the tool. You should override this method to return the name of your tool.
getDescription() This method returns a description of what the tool will do. You should override this method to return a proper description of your tool.
getType() This method returns the type of the tool which should be one of "generic", "import", "export" or "extract". Default implementation returns "generic" and unless you are making some other kind of tool you don't need to override this method.
getMenuIcon() This method returns the icon to use in menus. If you want to use something else than the default icon, override this method.
initialize(...) Initializes the tool. This is called always after the tool object is created. The method receives as its parameters the WandoraAdmin object, an Options object containing all saved options and a String containing the prefix this tool should use when accessing and saving options.
isConfigurable() Tells if this tools provides a dialog where user can configure the tool. Default implementation returns false so you need to override this if you want the user to be able to configure the tool.
configure(...) If this tool is configurable, this method must be overridden to show the configuration dialog. After user closes the dialog, all options should be written in the options using the prefix given as a parameter. Best way to do this is to call the next method after the dialog is closed.
writeOptions(...) If this tool is configurable, this method must be overridden to write all current options using the prefix given as parameter. Unlike previous method, this method shouldn't open any dialogs or expect user interaction.
runInOwnThread() Whether the tool should run in its own thread or the thread that executes the tool. Default implementation returns true. Some tools that are guaranteed to finish fast might want to set this to false. Note that even simple topic map operations may be surprisingly time consuming when operating with a remote topic map. Thus nearly all tools doing anything with the topic map itself should run in their own threads.
allowMultipleInvocations() If the tool should allow multiple invocations at the same time. Default implementation returns false. This means that while the tool is running, it cannot be started again. Most normal tools should behave like this.
requiresRefresh() Whether GUI should be refreshed after tool has finished. Default implementation retuns false. Note that if the tool changes any topic visible at the time of execution, GUI will be refreshed automatically regardless of what this method returns. You should override this method and return true if your tool actually changes the GUI itself in some way.
setContext(Context) Sets the context used when executing the tool. Context should be set before the tool is invoked, hence a good place to set it is in the constructor.
getContext() Gets the current active context.
setDefaultLogger() Sets the default logger as active logger. This will also open the tool window which you can use to show messages about tool execution.
log(...) These methods add a line to the logger. If you are using the default logger, the line will also be shown in the tool dialog to provide immediate feedback about execution.
hlog(...) These methods show a message in the default logger but does not add the line in the execution log which the user can view after tool has finished. Use this when you show information like "Processing topic 3400". This is useful information at the time of execution but having hundreds of such lines in the execution log isn't useful at all after the execution has finished.
singleLog(...) These methods are meant for simple tools that don't output anything normally. These methods will first call setDefaultLogger to set the default logger active (and open the message window), then show the message and finally call setState(WandoraToolLogger.WAIT) which will keep the window open until user closes it.
setState(...) This method sets the tool logger state. Usually you will have setState(WandoraToolLogger.WAIT) at the end of a tool if you have used any of the log methods. This will cause the log window to stay open until user closes it. Normally the log window will close when the tool finishes execution.
forceStop() Returns true if user has clicked the abort button. You should poll this method periodically. If it returns true you should abort execution and return from the execute method as soon as possible.


Tool Class

org.wandora.application.tools.AbstractWandoraTool

Personal tools