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.RemoteCommandProcessor
m_CommandProcessor
the command processor.protected adams.terminal.application.AbstractTerminalApplication
m_Owner
the 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 int
compareTo(AbstractRemoteCommandAction o)
Uses category and title for sorting.protected adams.scripting.engine.DefaultScriptingEngine
configureEngine(adams.scripting.responsehandler.ResponseHandler responseHandler, int defPort)
Returns new instance of a configured scripting engine.protected abstract void
doRun(com.googlecode.lanterna.gui2.WindowBasedTextGUI context)
Actual execution.boolean
equals(Object obj)
Checks whether the obj is the same definition (using category/title).adams.scripting.processor.RemoteCommandProcessor
getCommandProcessor()
Returns the command processor in use.protected LogTextBox
getLogTextBox()
Returns the LogTextBox to use.adams.terminal.application.AbstractTerminalApplication
getOwner()
Returns the owning application.Runnable
getRunnable(com.googlecode.lanterna.gui2.WindowBasedTextGUI context)
Returns the Runnable to use.abstract String
getTitle()
Returns the title of the action.protected void
initialize()
Initializes members.void
logError(String msg)
Logs the error.void
logError(String msg, Throwable t)
Logs the error.void
logMessage(String msg)
Logs the message.protected void
postRun(com.googlecode.lanterna.gui2.WindowBasedTextGUI context)
Cleans up after the execution.protected void
preRun(com.googlecode.lanterna.gui2.WindowBasedTextGUI context)
Prepares before the execution.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.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.void
setCommandProcessor(adams.scripting.processor.RemoteCommandProcessor value)
Sets the command processor to use.void
setOwner(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:
setCommandProcessor
in interfaceadams.scripting.processor.RemoteCommandProcessorHandler
- Parameters:
value
- the processor
-
getCommandProcessor
public adams.scripting.processor.RemoteCommandProcessor getCommandProcessor()
Returns the command processor in use.- Specified by:
getCommandProcessor
in 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:
compareTo
in 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:
equals
in classObject
- Parameters:
obj
- the object to compare with- Returns:
- true if the same definition
- See Also:
compareTo(AbstractRemoteCommandAction)
-
-