Package adams.flow.standalone
Class ConsoleWindow
-
- All Implemented Interfaces:
AdditionalInformationHandler
,CleanUpHandler
,Destroyable
,GlobalInfoSupporter
,LoggingLevelHandler
,LoggingSupporter
,OptionHandler
,QuickInfoSupporter
,ShallowCopySupporter<Actor>
,SizeOfHandler
,Stoppable
,StoppableWithFeedback
,TextSupporter
,VariablesInspectionHandler
,VariableChangeListener
,Actor
,DisplayTypeSupporter
,ErrorHandler
,TextSupplier
,MenuBarProvider
,ConsolePanelListener
,SendToActionSupporter
,Serializable
,Comparable
public class ConsoleWindow extends AbstractDisplay implements ConsolePanelListener, MenuBarProvider, TextSupplier, SendToActionSupporter
Displays the messages that are output in the system's 'Console window'.
-logging-level <OFF|SEVERE|WARNING|INFO|CONFIG|FINE|FINER|FINEST> (property: loggingLevel) The logging level for outputting errors and debugging output. default: WARNING
-name <java.lang.String> (property: name) The name of the actor. default: ConsoleWindow
-annotation <adams.core.base.BaseAnnotation> (property: annotations) The annotations to attach to this actor. default:
-skip <boolean> (property: skip) If set to true, transformation is skipped and the input token is just forwarded as it is. default: false
-stop-flow-on-error <boolean> (property: stopFlowOnError) If set to true, the flow gets stopped in case this actor encounters an error; useful for critical actors. default: false
-silent <boolean> (property: silent) If enabled, then no errors are output in the console. default: false
-short-title <boolean> (property: shortTitle) If enabled uses just the name for the title instead of the actor's full name. default: false
-display-in-editor <boolean> (property: displayInEditor) If enabled displays the panel in a tab in the flow editor rather than in a separate frame. default: false
-width <int> (property: width) The width of the dialog. default: 800 minimum: -1
-height <int> (property: height) The height of the dialog. default: 600 minimum: -1
-x <int> (property: x) The X position of the dialog (>=0: absolute, -1: left, -2: center, -3: right ). default: -1 minimum: -3
-y <int> (property: y) The Y position of the dialog (>=0: absolute, -1: top, -2: center, -3: bottom ). default: -1 minimum: -3
-level <OFF|SEVERE|WARNING|INFO|CONFIG|FINE|FINER|FINEST> [-level ...] (property: levels) The logging levels of messages to display. default: INFO, WARNING, SEVERE
-font <java.awt.Font> (property: font) The font of the dialog. default: Monospaced-PLAIN-12
-log-file <adams.core.io.PlaceholderFile> (property: logFile) The file to save the log messages to as they come in; ignored if pointing to a directory. default: ${CWD}
-file-only-output <boolean> (property: fileOnlyOutput) If enabled, log messages are only output to the specified log file, no window with text. default: false
- Version:
- $Revision$
- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static String
BACKUP_INPUT
the key for storing the lookup in the backup.protected TextFileChooser
m_FileChooser
the filedialog for saving the output.protected boolean
m_FileOnlyOutput
whether to only use file output.protected Font
m_Font
the font to use.protected LoggingLevel[]
m_Levels
the logging levels to display.protected PlaceholderFile
m_LogFile
the file to save the log messages to.protected HashSet<LoggingLevel>
m_LookUp
the lookup for the types.protected JMenuBar
m_MenuBar
the menu bar, if used.protected JMenuItem
m_MenuItemFileClear
the "clear" menu item.protected JMenuItem
m_MenuItemFileClose
the "exit" menu item.protected JMenuItem
m_MenuItemFileSaveAs
the "save as" menu item.protected BaseTextArea
m_TextArea
the text area for displaying the messages.-
Fields inherited from class adams.flow.core.AbstractDisplay
m_CreateFrame, m_DisplayType, m_Frame, m_Height, m_InputToken, m_KeepOpen, m_Panel, m_ShortTitle, m_Updating, m_Width, m_X, m_Y
-
Fields inherited from class adams.flow.core.AbstractActor
m_Annotations, m_BackupState, m_DetectedObjectVariables, m_DetectedVariables, m_ErrorHandler, m_Executed, m_Executing, m_ExecutionListeningSupporter, m_FullName, m_LoggingPrefix, m_Name, m_Parent, m_ScopeHandler, m_Self, m_Silent, m_Skip, m_StopFlowOnError, m_StopMessage, m_Stopped, m_StorageHandler, m_VariablesUpdated
-
Fields inherited from class adams.core.option.AbstractOptionHandler
m_OptionManager
-
Fields inherited from class adams.core.logging.LoggingObject
m_Logger, m_LoggingIsEnabled, m_LoggingLevel
-
Fields inherited from interface adams.flow.core.Actor
FILE_EXTENSION, FILE_EXTENSION_GZ
-
-
Constructor Summary
Constructors Constructor Description ConsoleWindow()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Hashtable<String,Object>
backupState()
Backs up the current state of the actor before update the variables.void
cleanUp()
Cleans up after the execution has finished.protected void
cleanUpGUI()
Removes all graphical components.protected void
clear()
Clears the display.void
clearPanel()
Clears the content of the panel.protected void
close()
Closes the dialog or frame.void
consolePanelMessageReceived(ConsolePanelEvent e)
Gets called when theConsolePanel
receives a message.protected JMenu
createFileMenu()
Creates the "File" menu.protected JMenuBar
createMenuBar()
Assembles the menu bar.void
defineOptions()
Adds options to the internal list of options.String
fileOnlyOutputTipText()
Returns the tip text for this property.String
fontTipText()
Returns the tip text for this property.boolean
getCreateFrame()
Returns whether the frame is created as well as the panel.String
getCustomSupplyTextMenuItemCaption()
Returns the text for the menu item.ExtensionFileFilter
getCustomTextFileFilter()
Returns a custom file filter for the file chooser.protected Font
getDefaultFont()
Returns the default font for the dialog.protected TextFileChooser
getFileChooser()
Returns (and initializes if necessary) the file chooser.boolean
getFileOnlyOutput()
Returns whether to output the log messages only to the file and suppress GUI output.Font
getFont()
Returns the currently set font of the dialog.LoggingLevel[]
getLevels()
Returns theLoggingLevel
s to display .PlaceholderFile
getLogFile()
Returns the file to save the log messages to, ignored if directory.JMenuBar
getMenuBar()
Creates a menu bar (singleton per panel object).String
getQuickInfo()
Returns a quick info about the actor, which will be displayed in the GUI.Class[]
getSendToClasses()
Returns the classes that the supporter generates.Object
getSendToItem(Class[] cls)
Returns the object to send.String
globalInfo()
Returns a string describing the object.boolean
hasSendToItem(Class[] cls)
Checks whether something to send is available.protected int
indexOfMenuItem(JMenu menu, JMenuItem menuitem)
Determines the index of the menu item in the specified menu.String
levelsTipText()
Returns the tip text for this property.String
logFileTipText()
Returns the tip text for this property.protected Runnable
newDisplayRunnable()
Returns a runnable that displays frame, etc.protected BasePanel
newPanel()
Creates the panel to display in the dialog.protected void
pruneBackup()
Removes entries from the backup.protected void
reset()
Initializes the actor.protected void
restoreState(Hashtable<String,Object> state)
Restores the state of the actor before the variables got updated.protected void
saveAs()
Saves the setups.void
setFileOnlyOutput(boolean value)
Sets whether to output the log messages only to the file and suppress GUI output.void
setFont(Font value)
Sets the font of the dialog.void
setLevels(LoggingLevel[] value)
Sets theLoggingLevel
s to display.void
setLogFile(PlaceholderFile value)
Sets the file to save the log messages to, ignored if directory.String
setUp()
Initializes the item for flow execution.String
supplyText()
Returns the text to save.protected boolean
supportsClear()
Whether "clear" is supported and shows up in the menu.protected void
updateMenu()
updates the enabled state of the menu items.void
wrapUp()
Cleans up after the execution has finished.-
Methods inherited from class adams.flow.core.AbstractDisplay
cleanUpGUIKeepOpen, closeFrame, createFrame, createTitle, currentInput, deregisterInWrapUp, deregisterWindow, deregisterWithEditor, displayTypeTipText, doCreateFrame, doExecute, getDefaultDisplayType, getDefaultHeight, getDefaultShortTitle, getDefaultWidth, getDefaultX, getDefaultY, getDisplayType, getFrame, getFrameDefaultCloseOperation, getHeight, getKeepOpen, getPanel, getShortTitle, getWidth, getX, getY, hasInput, heightTipText, initialize, input, postCreateFrame, preCreateFrame, registerWindow, registerWithEditor, setCreateFrame, setDisplayType, setHeight, setKeepOpen, setShortTitle, setWidth, setX, setY, shortTitleTipText, stopExecution, widthTipText, xTipText, yTipText
-
Methods inherited from class adams.flow.core.AbstractActor
annotationsTipText, canInspectOptions, canPerformSetUpCheck, compareTo, configureLogger, destroy, equals, execute, finalUpdateVariables, findVariables, findVariables, forceVariables, forCommandLine, forName, forName, getAdditionalInformation, getAnnotations, getDefaultName, getDetectedVariables, getErrorHandler, getFlowActors, getFlowExecutionListeningSupporter, getFullName, getName, getNextSibling, getParent, getParentComponent, getPreviousSibling, getRoot, getScopeHandler, getSilent, getSkip, getStopFlowOnError, getStopMessage, getStorageHandler, getVariables, handleError, handleException, hasErrorHandler, hasStopMessage, index, isBackedUp, isExecuted, isExecuting, isFinished, isHeadless, isStopped, nameTipText, performSetUpChecks, performVariableChecks, postExecute, preExecute, pruneBackup, setAnnotations, setErrorHandler, setName, setParent, setSilent, setSkip, setStopFlowOnError, setVariables, shallowCopy, shallowCopy, silentTipText, sizeOf, skipTipText, stopExecution, stopFlowOnErrorTipText, updateDetectedVariables, updatePrefix, updateVariables, variableChanged
-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, finishInit, getDefaultLoggingLevel, getOptionManager, loggingLevelTipText, newOptionManager, setLoggingLevel, toCommandLine, toString
-
Methods inherited from class adams.core.logging.LoggingObject
getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface adams.flow.core.Actor
compareTo, destroy, equals, execute, findVariables, getAnnotations, getDefaultName, getDetectedVariables, getErrorHandler, getFlowExecutionListeningSupporter, getFullName, getName, getNextSibling, getParent, getParentComponent, getPreviousSibling, getRoot, getScopeHandler, getSilent, getSkip, getStopFlowOnError, getStopMessage, getStorageHandler, getVariables, handleError, hasErrorHandler, hasStopMessage, index, isExecuted, isFinished, isHeadless, isStopped, setAnnotations, setErrorHandler, setName, setParent, setSilent, setSkip, setStopFlowOnError, setVariables, shallowCopy, shallowCopy, sizeOf, stopExecution, toCommandLine, variableChanged
-
Methods inherited from interface adams.core.AdditionalInformationHandler
getAdditionalInformation
-
Methods inherited from interface adams.core.logging.LoggingLevelHandler
getLoggingLevel, setLoggingLevel
-
Methods inherited from interface adams.core.logging.LoggingSupporter
getLogger, isLoggingEnabled
-
Methods inherited from interface adams.core.option.OptionHandler
cleanUpOptions, getOptionManager
-
Methods inherited from interface adams.core.VariablesInspectionHandler
canInspectOptions
-
-
-
-
Field Detail
-
BACKUP_INPUT
public static final String BACKUP_INPUT
the key for storing the lookup in the backup.- See Also:
- Constant Field Values
-
m_Levels
protected LoggingLevel[] m_Levels
the logging levels to display.
-
m_Font
protected Font m_Font
the font to use.
-
m_LogFile
protected PlaceholderFile m_LogFile
the file to save the log messages to.
-
m_FileOnlyOutput
protected boolean m_FileOnlyOutput
whether to only use file output.
-
m_TextArea
protected BaseTextArea m_TextArea
the text area for displaying the messages.
-
m_LookUp
protected HashSet<LoggingLevel> m_LookUp
the lookup for the types.
-
m_MenuBar
protected JMenuBar m_MenuBar
the menu bar, if used.
-
m_MenuItemFileClear
protected JMenuItem m_MenuItemFileClear
the "clear" menu item.
-
m_MenuItemFileSaveAs
protected JMenuItem m_MenuItemFileSaveAs
the "save as" menu item.
-
m_MenuItemFileClose
protected JMenuItem m_MenuItemFileClose
the "exit" menu item.
-
m_FileChooser
protected transient TextFileChooser m_FileChooser
the filedialog for saving the output.
-
-
Method Detail
-
globalInfo
public String globalInfo()
Returns a string describing the object.- Specified by:
globalInfo
in interfaceGlobalInfoSupporter
- Specified by:
globalInfo
in classAbstractOptionHandler
- Returns:
- a description suitable for displaying in the gui
-
defineOptions
public void defineOptions()
Adds options to the internal list of options.- Specified by:
defineOptions
in interfaceOptionHandler
- Overrides:
defineOptions
in classAbstractDisplay
-
reset
protected void reset()
Initializes the actor.- Overrides:
reset
in classAbstractDisplay
-
pruneBackup
protected void pruneBackup()
Removes entries from the backup.- Overrides:
pruneBackup
in classAbstractActor
- See Also:
AbstractActor.reset()
-
backupState
protected Hashtable<String,Object> backupState()
Backs up the current state of the actor before update the variables.- Overrides:
backupState
in classAbstractDisplay
- Returns:
- the backup
- See Also:
AbstractActor.updateVariables()
,AbstractActor.restoreState(Hashtable)
-
restoreState
protected void restoreState(Hashtable<String,Object> state)
Restores the state of the actor before the variables got updated.- Overrides:
restoreState
in classAbstractDisplay
- Parameters:
state
- the backup of the state to restore from- See Also:
AbstractActor.updateVariables()
,AbstractActor.backupState()
-
setLevels
public void setLevels(LoggingLevel[] value)
Sets theLoggingLevel
s to display.- Parameters:
value
- the levels
-
getLevels
public LoggingLevel[] getLevels()
Returns theLoggingLevel
s to display .- Returns:
- the levels
-
levelsTipText
public String levelsTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
getDefaultFont
protected Font getDefaultFont()
Returns the default font for the dialog.- Returns:
- the default font
-
setFont
public void setFont(Font value)
Sets the font of the dialog.- Parameters:
value
- the font
-
getFont
public Font getFont()
Returns the currently set font of the dialog.- Returns:
- the font
-
fontTipText
public String fontTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setLogFile
public void setLogFile(PlaceholderFile value)
Sets the file to save the log messages to, ignored if directory.- Parameters:
value
- the output file
-
getLogFile
public PlaceholderFile getLogFile()
Returns the file to save the log messages to, ignored if directory.- Returns:
- the output file
-
logFileTipText
public String logFileTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setFileOnlyOutput
public void setFileOnlyOutput(boolean value)
Sets whether to output the log messages only to the file and suppress GUI output.- Parameters:
value
- true if only log file output
-
getFileOnlyOutput
public boolean getFileOnlyOutput()
Returns whether to output the log messages only to the file and suppress GUI output.- Returns:
- true if only log file output
-
fileOnlyOutputTipText
public String fileOnlyOutputTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
getQuickInfo
public String getQuickInfo()
Returns a quick info about the actor, which will be displayed in the GUI.- Specified by:
getQuickInfo
in interfaceActor
- Specified by:
getQuickInfo
in interfaceQuickInfoSupporter
- Overrides:
getQuickInfo
in classAbstractDisplay
- Returns:
- null if no info available, otherwise short string
-
getFileChooser
protected TextFileChooser getFileChooser()
Returns (and initializes if necessary) the file chooser.- Returns:
- the file chooser
-
clearPanel
public void clearPanel()
Clears the content of the panel.- Specified by:
clearPanel
in classAbstractDisplay
-
createFileMenu
protected JMenu createFileMenu()
Creates the "File" menu.- Returns:
- the generated menu
-
indexOfMenuItem
protected int indexOfMenuItem(JMenu menu, JMenuItem menuitem)
Determines the index of the menu item in the specified menu.- Parameters:
menu
- the menu to search inmenuitem
- the menu item to get the index for- Returns:
- the index, -1 if not found
-
createMenuBar
protected JMenuBar createMenuBar()
Assembles the menu bar.- Returns:
- the menu bar
-
getMenuBar
public JMenuBar getMenuBar()
Creates a menu bar (singleton per panel object). Can be used in frames.- Specified by:
getMenuBar
in interfaceMenuBarProvider
- Returns:
- the menu bar
-
updateMenu
protected void updateMenu()
updates the enabled state of the menu items.
-
supportsClear
protected boolean supportsClear()
Whether "clear" is supported and shows up in the menu.- Returns:
- true if supported
-
clear
protected void clear()
Clears the display.
-
saveAs
protected void saveAs()
Saves the setups.
-
close
protected void close()
Closes the dialog or frame.
-
getCustomSupplyTextMenuItemCaption
public String getCustomSupplyTextMenuItemCaption()
Returns the text for the menu item.- Specified by:
getCustomSupplyTextMenuItemCaption
in interfaceTextSupplier
- Returns:
- the menu item text, null for default
-
getCustomTextFileFilter
public ExtensionFileFilter getCustomTextFileFilter()
Returns a custom file filter for the file chooser.
Default implementation returns null.- Specified by:
getCustomTextFileFilter
in interfaceTextSupplier
- Returns:
- the file filter, null if to use default one
-
supplyText
public String supplyText()
Returns the text to save.- Specified by:
supplyText
in interfaceTextSupplier
- Specified by:
supplyText
in interfaceTextSupporter
- Returns:
- the text, null if no text available
-
newPanel
protected BasePanel newPanel()
Creates the panel to display in the dialog.- Specified by:
newPanel
in classAbstractDisplay
- Returns:
- the panel
-
getCreateFrame
public boolean getCreateFrame()
Returns whether the frame is created as well as the panel.- Overrides:
getCreateFrame
in classAbstractDisplay
- Returns:
- true if the frame is created as well
-
newDisplayRunnable
protected Runnable newDisplayRunnable()
Returns a runnable that displays frame, etc. Must call notifyAll() on the m_Self object and set m_Updating to false.- Specified by:
newDisplayRunnable
in classAbstractDisplay
- Returns:
- the runnable
- See Also:
AbstractDisplay.m_Updating
-
setUp
public String setUp()
Initializes the item for flow execution. Also calls the reset() method first before anything else.- Specified by:
setUp
in interfaceActor
- Overrides:
setUp
in classAbstractActor
- Returns:
- null if everything is fine, otherwise error message
- See Also:
AbstractActor.reset()
-
consolePanelMessageReceived
public void consolePanelMessageReceived(ConsolePanelEvent e)
Gets called when theConsolePanel
receives a message.- Specified by:
consolePanelMessageReceived
in interfaceConsolePanelListener
- Parameters:
e
- the generated event
-
wrapUp
public void wrapUp()
Cleans up after the execution has finished.- Specified by:
wrapUp
in interfaceActor
- Overrides:
wrapUp
in classAbstractDisplay
-
cleanUpGUI
protected void cleanUpGUI()
Removes all graphical components.- Overrides:
cleanUpGUI
in classAbstractDisplay
-
cleanUp
public void cleanUp()
Cleans up after the execution has finished. Also removes graphical components.- Specified by:
cleanUp
in interfaceActor
- Specified by:
cleanUp
in interfaceCleanUpHandler
- Overrides:
cleanUp
in classAbstractDisplay
-
getSendToClasses
public Class[] getSendToClasses()
Returns the classes that the supporter generates.- Specified by:
getSendToClasses
in interfaceSendToActionSupporter
- Returns:
- the classes
-
hasSendToItem
public boolean hasSendToItem(Class[] cls)
Checks whether something to send is available.- Specified by:
hasSendToItem
in interfaceSendToActionSupporter
- Parameters:
cls
- the classes to retrieve the item for- Returns:
- true if an object is available for sending
-
getSendToItem
public Object getSendToItem(Class[] cls)
Returns the object to send.- Specified by:
getSendToItem
in interfaceSendToActionSupporter
- Parameters:
cls
- the classes to retrieve the item for- Returns:
- the item to send
-
-