Package adams.gui.flow
Class FlowWorker
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.gui.flow.FlowWorker
-
- All Implemented Interfaces:
LoggingLevelHandler
,LoggingSupporter
,Pausable
,SizeOfHandler
,StatusMessageHandler
,Stoppable
,Serializable
,Runnable
public class FlowWorker extends CustomLoggingLevelObject implements Runnable, Pausable, Stoppable, StatusMessageHandler
Specialized worker class for executing a flow.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
m_Debug
whether to run in debug mode.protected File
m_File
the current flow file.protected Actor
m_Flow
the flow to execute.protected String
m_Output
generated output.protected FlowWorkerHandler
m_Owner
the panel this flow belongs to.protected boolean
m_Running
whether the flow is still being executed.protected boolean
m_ShowNotification
whether to show a notification.protected long
m_StartTime
the start time.protected String
m_StopMessage
the stop message.protected boolean
m_Stopping
whether the flow is being stopped.-
Fields inherited from class adams.core.logging.LoggingObject
m_Logger, m_LoggingIsEnabled, m_LoggingLevel
-
-
Constructor Summary
Constructors Constructor Description FlowWorker(FlowWorkerHandler owner, Actor flow, File file, boolean showNotification, boolean debug)
Initializes the worker.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Object
doInBackground()
Executes the flow.protected void
done()
Executed on the Event Dispatch Thread after thedoInBackground
method is finished.Actor
getFlow()
Returns the flow.boolean
isPaused()
Returns whether the object is currently paused.boolean
isRunning()
Returns whether a flow is currently running.boolean
isStopping()
Returns whether a flow is currently being stopped.void
pauseExecution()
Pauses the execution.void
resumeExecution()
Resumes the execution.void
run()
Execute the flow.void
showNotification(String msg, FlowPanelNotificationArea.NotificationType type)
Displays the given message in a separate dialog.void
showStatus(String msg)
Displays a message.void
stopExecution()
Stops the execution.protected void
updateTabIcon(String icon)
Updates the tab icon, if possible.-
Methods inherited from class adams.core.logging.CustomLoggingLevelObject
setLoggingLevel
-
Methods inherited from class adams.core.logging.LoggingObject
configureLogger, getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface adams.core.logging.LoggingLevelHandler
getLoggingLevel
-
-
-
-
Field Detail
-
m_Owner
protected FlowWorkerHandler m_Owner
the panel this flow belongs to.
-
m_Flow
protected Actor m_Flow
the flow to execute.
-
m_File
protected File m_File
the current flow file.
-
m_Output
protected String m_Output
generated output.
-
m_StopMessage
protected String m_StopMessage
the stop message.
-
m_ShowNotification
protected boolean m_ShowNotification
whether to show a notification.
-
m_Debug
protected boolean m_Debug
whether to run in debug mode.
-
m_Running
protected boolean m_Running
whether the flow is still being executed.
-
m_Stopping
protected boolean m_Stopping
whether the flow is being stopped.
-
m_StartTime
protected long m_StartTime
the start time.
-
-
Constructor Detail
-
FlowWorker
public FlowWorker(FlowWorkerHandler owner, Actor flow, File file, boolean showNotification, boolean debug)
Initializes the worker.
-
-
Method Detail
-
doInBackground
protected Object doInBackground() throws Exception
Executes the flow.- Returns:
- always null
- Throws:
Exception
- if unable to compute a result
-
done
protected void done()
Executed on the Event Dispatch Thread after thedoInBackground
method is finished.
-
pauseExecution
public void pauseExecution()
Pauses the execution.- Specified by:
pauseExecution
in interfacePausable
-
isPaused
public boolean isPaused()
Returns whether the object is currently paused.
-
resumeExecution
public void resumeExecution()
Resumes the execution.- Specified by:
resumeExecution
in interfacePausable
-
stopExecution
public void stopExecution()
Stops the execution.- Specified by:
stopExecution
in interfaceStoppable
-
isRunning
public boolean isRunning()
Returns whether a flow is currently running.- Returns:
- true if a flow is being executed
-
isStopping
public boolean isStopping()
Returns whether a flow is currently being stopped.- Returns:
- true if a flow is currently being stopped
-
showStatus
public void showStatus(String msg)
Displays a message.- Specified by:
showStatus
in interfaceStatusMessageHandler
- Parameters:
msg
- the message to display
-
showNotification
public void showNotification(String msg, FlowPanelNotificationArea.NotificationType type)
Displays the given message in a separate dialog.- Parameters:
msg
- the message to displaytype
- the type of notification (info/warning/error)
-
getFlow
public Actor getFlow()
Returns the flow.- Returns:
- the flow
-
updateTabIcon
protected void updateTabIcon(String icon)
Updates the tab icon, if possible.- Parameters:
icon
- the icon name, can be null
-
-