org.chorem.jtimer.ui.tasks
Class RunTaskJob

java.lang.Object
  extended by org.jdesktop.swingworker.SwingWorker<T,V>
      extended by org.jdesktop.application.Task<Void,Long>
          extended by org.chorem.jtimer.ui.tasks.RunTaskJob
All Implemented Interfaces:
Runnable, Future<Void>

public class RunTaskJob
extends org.jdesktop.application.Task<Void,Long>

RunTaskJob. Notify every second the core controler.

Version:
$Revision: 2730 $ Last update : $Date: 2010-04-16 17:46:56 +0200 (ven., 16 avril 2010) $ By : $Author: echatellier $
Author:
chatellier

Nested Class Summary
 
Nested classes/interfaces inherited from class org.jdesktop.application.Task
org.jdesktop.application.Task.BlockingScope, org.jdesktop.application.Task.InputBlocker
 
Nested classes/interfaces inherited from class org.jdesktop.swingworker.SwingWorker
org.jdesktop.swingworker.SwingWorker.StateValue
 
Field Summary
protected  Collection<TimerAlert> alreadyTrownAlerts
          Already thrown alert.
protected  Boolean bWantToStop
          Want to stop flag.
protected  TimerDataManager dataManager
          Data manager.
protected  long lastPublishTimestamp
          Last publish time to detect hibernate.
protected  TimerTask managedTask
          The task to manage.
protected  long offsetTimeInMs
          Offset to adjust time.
protected  JTimer parentApp
          Parent app referenc.
protected  SystemInfo systemInfo
          System information (idle...).
protected  Calendar taskStartCalendar
          Calendar instance when timing start.
protected  long taskTimingBeforeStartInMs
          The today total task time at start time.
 
Constructor Summary
RunTaskJob(JTimer parentApp, TimerTask managedTask, TimerDataManager dataManager)
          Constructor.
 
Method Summary
protected  void checkAlreadyThrownAlerts(TimerTask task)
          Check for already thrown alerts.
protected  void checkReset()
          Check if task need to be reset.
protected  void checkTaskAlerts(TimerTask task)
          Check for alert to be fired.
protected  void displayAlert(TimerTask task, TimerAlert.Type alertType, long alertDuration)
          Display alert message without breaking UI.
protected  Void doInBackground()
           
 TimerTask getTask()
          Task getter.
 void incrementTaskTime(long increment)
          Method to increment time while task is running (in ms).
 boolean isStopping()
          Tell if task is trying to stop.
protected  void process(List<Long> durations)
           
 void resetTiming()
          Reset timing.
 void wantToStop()
          Notify that task want to stop
 
Methods inherited from class org.jdesktop.application.Task
addTaskListener, cancelled, done, failed, finished, getApplication, getContext, getDescription, getExecutionDuration, getInputBlocker, getMessage, getMessageDuration, getResourceMap, getTaskListeners, getTaskService, getTitle, getUserCanCancel, interrupted, isPending, isProgressPropertyValid, isStarted, message, removeTaskListener, resourceName, setDescription, setInputBlocker, setMessage, setProgress, setProgress, setProgress, setTitle, setUserCanCancel, succeeded
 
Methods inherited from class org.jdesktop.swingworker.SwingWorker
addPropertyChangeListener, cancel, execute, firePropertyChange, get, get, getProgress, getPropertyChangeSupport, getState, isCancelled, isDone, publish, removePropertyChangeListener, run, setProgress
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

parentApp

protected JTimer parentApp
Parent app referenc.


managedTask

protected TimerTask managedTask
The task to manage.


dataManager

protected TimerDataManager dataManager
Data manager.


systemInfo

protected SystemInfo systemInfo
System information (idle...).


taskTimingBeforeStartInMs

protected long taskTimingBeforeStartInMs
The today total task time at start time.


taskStartCalendar

protected Calendar taskStartCalendar
Calendar instance when timing start.


alreadyTrownAlerts

protected Collection<TimerAlert> alreadyTrownAlerts
Already thrown alert.


offsetTimeInMs

protected long offsetTimeInMs
Offset to adjust time. Include : - Task idle time (task was running but time not counted) - Manual user incremented time


lastPublishTimestamp

protected long lastPublishTimestamp
Last publish time to detect hibernate.


bWantToStop

protected Boolean bWantToStop
Want to stop flag.

Constructor Detail

RunTaskJob

public RunTaskJob(JTimer parentApp,
                  TimerTask managedTask,
                  TimerDataManager dataManager)
Constructor. Take the task to manage

Parameters:
parentApp - parent application
managedTask - task
dataManager - data
Method Detail

checkAlreadyThrownAlerts

protected void checkAlreadyThrownAlerts(TimerTask task)
Check for already thrown alerts. Used to not fired again already fired alerts during previous timing.

Parameters:
task - current task

getTask

public TimerTask getTask()
Task getter.

Returns:
managed task

incrementTaskTime

public void incrementTaskTime(long increment)
Method to increment time while task is running (in ms).

Parameters:
increment - increment, can be negative

resetTiming

public void resetTiming()
Reset timing. For example if task goes over 0h00, need to reset...


checkReset

protected void checkReset()
Check if task need to be reset. Test if today number if different of taskStartCalendar day number


doInBackground

protected Void doInBackground()
                       throws Exception
Specified by:
doInBackground in class org.jdesktop.swingworker.SwingWorker<Void,Long>
Throws:
Exception

process

protected void process(List<Long> durations)
Overrides:
process in class org.jdesktop.application.Task<Void,Long>

checkTaskAlerts

protected void checkTaskAlerts(TimerTask task)
Check for alert to be fired.

Parameters:
task -

displayAlert

protected void displayAlert(TimerTask task,
                            TimerAlert.Type alertType,
                            long alertDuration)
Display alert message without breaking UI.

Parameters:
task - task
alertType - alert type
alertDuration - alert duration

wantToStop

public void wantToStop()
Notify that task want to stop


isStopping

public boolean isStopping()
Tell if task is trying to stop.

Returns:
stopping flag


Copyright © 2007-2012 CodeLutin. All Rights Reserved.