Package adams.terminal.menu
Class AbstractMenuItemDefinition
- java.lang.Object
-
- adams.terminal.menu.AbstractMenuItemDefinition
-
- All Implemented Interfaces:
MenuItem,Serializable,Comparable<AbstractMenuItemDefinition>
- Direct Known Subclasses:
About,AbstractJDKMenuItemDefinition,AbstractURLMenuItemDefinition,FlowEditor,FlowRunner,GarbageCollector,Modules,ProgramExit,RemoteCommands,SystemInfo
public abstract class AbstractMenuItemDefinition extends Object implements Serializable, Comparable<AbstractMenuItemDefinition>, MenuItem
Ancestor for menu items of terminal applications.- Version:
- $Revision$
- Author:
- FracPete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static StringCATEGORY_HELPthe "Help" category.static StringCATEGORY_MAINTENANCEthe "Maintenance" category.static StringCATEGORY_PROGRAMthe "Program" category.static StringCATEGORY_TOOLSthe "Tools" category.protected adams.terminal.application.AbstractTerminalApplicationm_Ownerthe owning application.
-
Constructor Summary
Constructors Constructor Description AbstractMenuItemDefinition()Initializes the menu item with no owner.AbstractMenuItemDefinition(adams.terminal.application.AbstractTerminalApplication owner)Initializes the menu item.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description intcompareTo(AbstractMenuItemDefinition o)Uses category and title for sorting.protected abstract voiddoRun(com.googlecode.lanterna.gui2.WindowBasedTextGUI context)Actual execution.booleanequals(Object obj)Checks whether the obj is the same definition (using category/title).abstract StringgetCategory()Returns the category of the menu item in which it should appear, i.e., the name of the menu.adams.terminal.application.AbstractTerminalApplicationgetOwner()Returns the owning application.RunnablegetRunnable(com.googlecode.lanterna.gui2.WindowBasedTextGUI context)Returns the Runnable to use.abstract StringgetTitle()Returns the title of the window (and text of menuitem).protected voidinitialize()Initializes members.voidlogError(String msg)Logs the error.voidlogError(String msg, Throwable t)Logs the error.voidlogMessage(String msg)Logs the message.protected voidpostRun(com.googlecode.lanterna.gui2.WindowBasedTextGUI context)Cleans up after the execution.protected voidpreRun(com.googlecode.lanterna.gui2.WindowBasedTextGUI context)Prepares before the execution.voidsetOwner(adams.terminal.application.AbstractTerminalApplication value)Sets the owning application.
-
-
-
Field Detail
-
CATEGORY_PROGRAM
public static final String CATEGORY_PROGRAM
the "Program" category.- See Also:
- Constant Field Values
-
CATEGORY_TOOLS
public static final String CATEGORY_TOOLS
the "Tools" category.- See Also:
- Constant Field Values
-
CATEGORY_MAINTENANCE
public static final String CATEGORY_MAINTENANCE
the "Maintenance" category.- See Also:
- Constant Field Values
-
CATEGORY_HELP
public static final String CATEGORY_HELP
the "Help" category.- See Also:
- Constant Field Values
-
m_Owner
protected adams.terminal.application.AbstractTerminalApplication m_Owner
the owning application.
-
-
Constructor Detail
-
AbstractMenuItemDefinition
public AbstractMenuItemDefinition()
Initializes the menu item with no owner.
-
AbstractMenuItemDefinition
public AbstractMenuItemDefinition(adams.terminal.application.AbstractTerminalApplication owner)
Initializes the menu item.- Parameters:
owner- the owning application
-
-
Method Detail
-
initialize
protected void initialize()
Initializes members.
Default implementation does nothing.
-
setOwner
public void setOwner(adams.terminal.application.AbstractTerminalApplication value)
Sets the owning application.- Parameters:
value- the owner
-
getOwner
public adams.terminal.application.AbstractTerminalApplication getOwner()
Returns the owning application.- Returns:
- the owner
-
logMessage
public void logMessage(String msg)
Logs the message.- Parameters:
msg- the message to log
-
logError
public void logError(String msg)
Logs the error.- Parameters:
msg- the error message to log
-
logError
public void logError(String msg, Throwable t)
Logs the error.- Parameters:
msg- the error message to logt- the exception
-
getCategory
public abstract String getCategory()
Returns the category of the menu item in which it should appear, i.e., the name of the menu.- Returns:
- the category/menu name
-
getTitle
public abstract String getTitle()
Returns the title of the window (and text of menuitem).
-
preRun
protected void preRun(com.googlecode.lanterna.gui2.WindowBasedTextGUI context)
Prepares before the execution.- Parameters:
context- the context to use
-
doRun
protected abstract void doRun(com.googlecode.lanterna.gui2.WindowBasedTextGUI context)
Actual execution.- Parameters:
context- the context to use
-
postRun
protected void postRun(com.googlecode.lanterna.gui2.WindowBasedTextGUI context)
Cleans up after the execution.- Parameters:
context- the context to use
-
getRunnable
public Runnable getRunnable(com.googlecode.lanterna.gui2.WindowBasedTextGUI context)
Returns the Runnable to use.- Specified by:
getRunnablein interfaceMenuItem- Parameters:
context- the context to use- Returns:
- the runnable
-
compareTo
public int compareTo(AbstractMenuItemDefinition o)
Uses category and title for sorting.- Specified by:
compareToin interfaceComparable<AbstractMenuItemDefinition>- Parameters:
o- the other definition to compare with- Returns:
- less than zero, zero, or greater than zero if this menuitem is less than, equal to or greater than the other definition
- See Also:
getCategory(),getTitle()
-
equals
public boolean equals(Object obj)
Checks whether the obj is the same definition (using category/title).- Overrides:
equalsin classObject- Parameters:
obj- the object to compare with- Returns:
- true if the same definition
- See Also:
compareTo(AbstractMenuItemDefinition)
-
-