Class AbstractRemoteCommandAction
- java.lang.Object
-
- adams.terminal.menu.remotecommand.AbstractRemoteCommandAction
-
- All Implemented Interfaces:
adams.scripting.processor.RemoteCommandProcessorHandler,Comparable<AbstractRemoteCommandAction>
- Direct Known Subclasses:
AbstractRemoteCommandActionWithGUI,StopListening
public abstract class AbstractRemoteCommandAction extends Object implements Comparable<AbstractRemoteCommandAction>, adams.scripting.processor.RemoteCommandProcessorHandler
Ancestor for remote command actions.- Author:
- FracPete (fracpete at waikato dot ac dot nz)
-
-
Field Summary
Fields Modifier and Type Field Description protected adams.scripting.processor.RemoteCommandProcessorm_CommandProcessorthe command processor.protected adams.terminal.application.AbstractTerminalApplicationm_Ownerthe owning application.
-
Constructor Summary
Constructors Constructor Description AbstractRemoteCommandAction()Initializes the action with no owner.AbstractRemoteCommandAction(adams.terminal.application.AbstractTerminalApplication owner)Initializes the action.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description intcompareTo(AbstractRemoteCommandAction o)Uses category and title for sorting.protected adams.scripting.engine.DefaultScriptingEngineconfigureEngine(adams.scripting.responsehandler.ResponseHandler responseHandler, int defPort)Returns new instance of a configured scripting engine.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).adams.scripting.processor.RemoteCommandProcessorgetCommandProcessor()Returns the command processor in use.protected LogTextBoxgetLogTextBox()Returns the LogTextBox to use.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 action.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.voidsendCommand(adams.scripting.command.RemoteCommand cmd, adams.scripting.processor.RemoteCommandProcessor processor, adams.core.base.BaseHostname remote)Sends the specified command, not waiting for a response.voidsendCommandWithReponse(adams.scripting.command.RemoteCommandWithResponse cmd, adams.scripting.processor.RemoteCommandProcessor processor, adams.scripting.responsehandler.ResponseHandler responseHandler, adams.core.base.BaseHostname local, adams.core.base.BaseHostname remote, int defPort)Sends the specified command and the response handler for intercepting the result.voidsetCommandProcessor(adams.scripting.processor.RemoteCommandProcessor value)Sets the command processor to use.voidsetOwner(adams.terminal.application.AbstractTerminalApplication value)Sets the owning application.
-
-
-
Constructor Detail
-
AbstractRemoteCommandAction
public AbstractRemoteCommandAction()
Initializes the action with no owner.
-
AbstractRemoteCommandAction
public AbstractRemoteCommandAction(adams.terminal.application.AbstractTerminalApplication owner)
Initializes the action.- Parameters:
owner- the owning application
-
-
Method Detail
-
initialize
protected void initialize()
Initializes members.
-
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
-
setCommandProcessor
public void setCommandProcessor(adams.scripting.processor.RemoteCommandProcessor value)
Sets the command processor to use.- Specified by:
setCommandProcessorin interfaceadams.scripting.processor.RemoteCommandProcessorHandler- Parameters:
value- the processor
-
getCommandProcessor
public adams.scripting.processor.RemoteCommandProcessor getCommandProcessor()
Returns the command processor in use.- Specified by:
getCommandProcessorin interfaceadams.scripting.processor.RemoteCommandProcessorHandler- Returns:
- the processor
-
getTitle
public abstract String getTitle()
Returns the title of the action.- Returns:
- the title
-
getLogTextBox
protected LogTextBox getLogTextBox()
Returns the LogTextBox to use.- Returns:
- the log to use
-
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
-
configureEngine
protected adams.scripting.engine.DefaultScriptingEngine configureEngine(adams.scripting.responsehandler.ResponseHandler responseHandler, int defPort)Returns new instance of a configured scripting engine.- Parameters:
responseHandler- the handler to use for intercepting the result, can be nulldefPort- the default port to use- Returns:
- the engine
-
sendCommand
public void sendCommand(adams.scripting.command.RemoteCommand cmd, adams.scripting.processor.RemoteCommandProcessor processor, adams.core.base.BaseHostname remote)Sends the specified command, not waiting for a response.- Parameters:
cmd- the command to sendprocessor- the processor for formatting/parsingremote- the remote host
-
sendCommandWithReponse
public void sendCommandWithReponse(adams.scripting.command.RemoteCommandWithResponse cmd, adams.scripting.processor.RemoteCommandProcessor processor, adams.scripting.responsehandler.ResponseHandler responseHandler, adams.core.base.BaseHostname local, adams.core.base.BaseHostname remote, int defPort)Sends the specified command and the response handler for intercepting the result.- Parameters:
cmd- the command to sendprocessor- the processor for formatting/parsingresponseHandler- the response handler for intercepting the result, can be nulllocal- the local hostremote- the remote hostdefPort- the default port to use
-
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.- Parameters:
context- the context to use- Returns:
- the runnable
-
compareTo
public int compareTo(AbstractRemoteCommandAction o)
Uses category and title for sorting.- Specified by:
compareToin interfaceComparable<AbstractRemoteCommandAction>- 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:
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(AbstractRemoteCommandAction)
-
-