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 booleanm_Debugwhether to run in debug mode.protected Filem_Filethe current flow file.protected Actorm_Flowthe flow to execute.protected Stringm_Outputgenerated output.protected FlowWorkerHandlerm_Ownerthe panel this flow belongs to.protected booleanm_Runningwhether the flow is still being executed.protected booleanm_ShowNotificationwhether to show a notification.protected longm_StartTimethe start time.protected Stringm_StopMessagethe stop message.protected booleanm_Stoppingwhether 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 ObjectdoInBackground()Executes the flow.protected voiddone()Executed on the Event Dispatch Thread after thedoInBackgroundmethod is finished.ActorgetFlow()Returns the flow.booleanisPaused()Returns whether the object is currently paused.booleanisRunning()Returns whether a flow is currently running.booleanisStopping()Returns whether a flow is currently being stopped.voidpauseExecution()Pauses the execution.voidresumeExecution()Resumes the execution.voidrun()Execute the flow.voidshowNotification(String msg, FlowPanelNotificationArea.NotificationType type)Displays the given message in a separate dialog.voidshowStatus(String msg)Displays a message.voidstopExecution()Stops the execution.protected voidupdateStatusIcon(String icon)Updates the status 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 thedoInBackgroundmethod is finished.
-
pauseExecution
public void pauseExecution()
Pauses the execution.- Specified by:
pauseExecutionin interfacePausable
-
isPaused
public boolean isPaused()
Returns whether the object is currently paused.
-
resumeExecution
public void resumeExecution()
Resumes the execution.- Specified by:
resumeExecutionin interfacePausable
-
stopExecution
public void stopExecution()
Stops the execution.- Specified by:
stopExecutionin 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:
showStatusin 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
-
updateStatusIcon
protected void updateStatusIcon(String icon)
Updates the status icon, if possible.- Parameters:
icon- the icon name, can be null
-
-