|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.util.TimerTask
org.chorem.jtimer.io.GTimerIncrementalSaver
public class GTimerIncrementalSaver
Charge et sauve les fichiers au format gTimer. Le format de fichier utilisé ici est 1.2. => Format: 1.2 Changes: - contrairement à la premiere version, ce Saver sauve les projets/taches/annotations seulement si elles ont été modifiées.
| Field Summary | |
|---|---|
protected long |
autoSaveDelay
Auto save delay. |
protected Timer |
autoSaveTimer
Timer used for autosave. |
protected FileChannel |
channel
Resource used by lock. |
protected static String |
GTIMER_ANNOTATION_EXTENSION
Extension annotation. |
protected static String |
GTIMER_EMPTY_PROJECT_NAME
Empty gtimer project name. |
protected static String |
GTIMER_FILE_VERSION
Version du format de fichier. |
protected static String |
GTIMER_PROJECT_EXTENSION
Extension project. |
protected static String |
GTIMER_SUBTASK_SEPARATOR
Separateur pour les sous taches. |
protected static String |
GTIMER_TASK_EXTENSION
Extension task. |
protected FileLock |
lock
Resource used by lock. |
protected static String |
LOCK_FILE_NAME
Lock filename. |
protected RandomAccessFile |
raf
Resource used by lock. |
protected Collection<TimerTask> |
runningTasks
Running task list. |
protected String |
saveDirectory
Save directory. |
| Constructor Summary | |
|---|---|
GTimerIncrementalSaver()
Constructor. |
|
| Method Summary | |
|---|---|
void |
addProject(TimerProject project)
Add project event. |
void |
addTask(TimerTask task)
Add task event. |
protected void |
backupGTimerFiles()
For development. |
void |
checkAddProject(TimerProject project)
Check add project. |
void |
checkAddTask(TimerTask parent,
TimerTask task)
Check add task. |
void |
checkChangeClosedState(TimerTask task)
Check change task state. |
void |
checkDeleteProject(TimerProject project)
Check delete project. |
void |
checkDeleteTask(TimerTask task)
Check delete task. |
void |
checkMergeTasks(TimerTask destinationTask,
List<TimerTask> otherTasks)
Check merge task. |
void |
checkModifyProject(TimerProject project)
Check modify project. |
void |
checkModifyTask(TimerTask task)
Check modify task. |
void |
checkMoveTask(TimerTask task,
TimerTask taskToMoveTo)
Check move task. |
protected void |
checkName(TimerTask task)
Check task name. |
protected void |
checkSaveDirectory()
Check that save directory exists. |
void |
checkSetAnnotation(TimerTask task,
Date date,
String value)
Check update task annotation. |
void |
checkSetTaskTime(TimerTask task,
Date date,
Long value)
Check update task time. |
void |
dataLoaded(Collection<TimerProject> projects)
All data loaded. |
void |
deleteProject(TimerProject project)
Delete project. |
void |
deleteTask(TimerTask task)
Delete task. |
protected void |
deleteTaskOrProject(TimerTask taskOrProject,
String extension)
Delete associated file or project files on disk. |
protected TimerTask |
findTask(TimerTask parentTask,
String[] taskNames)
Find a task in task's subtask |
protected TimerProject |
getProjectFromFile(File projectFile)
Load a project in his file. |
protected int |
getUnusedNumber(String extention)
Explore directory and find a non used number for project. |
protected Collection<TimerProject> |
gTimerLoad()
Load from gtimer file format. |
protected boolean |
isGTimerFile(String filename)
Check if a file denoted by his name is a gtimer file. |
Collection<TimerProject> |
load()
Load a project list. |
void |
lock()
Try to lock current saver directory. |
void |
modifyProject(TimerProject project)
Modify project. |
void |
modifyTask(TimerTask task)
Modify task. |
protected void |
parseAnnotations(TimerTask task)
Try to find and load annotations from task. |
protected TimerTask |
parseTaskFromFile(Map<String,TimerProject> mapNumberProject,
File taskFile,
SortedMap<TimerTask,TimerProject> taskToManage)
Parse task file. |
protected void |
parseTaskFromSavedMap(SortedMap<TimerTask,TimerProject> taskToManage)
Post process task to manage subtask loaded before parent task. |
void |
postChangeClosedState(TimerTask task)
Post change task state. |
void |
postMergeTasks(TimerTask destinationTask,
List<TimerTask> otherTasks)
Post merge task. |
void |
postMoveTask(TimerTask task)
Post move task. |
void |
preChangeClosedState(TimerTask task)
Pre change task state. |
void |
preMergeTasks(TimerTask destinationTask,
List<TimerTask> otherTasks)
Pre merge task. |
void |
preMoveTask(TimerTask task)
Pre move task. |
void |
run()
|
protected boolean |
saveProject(TimerProject project)
Save a unique project. |
protected void |
saveRunningTasks()
Save runing tasks. |
protected boolean |
saveTask(TimerTask task)
Save task, found correct prefix, and project. |
protected boolean |
saveTask(TimerTask task,
int associatedToProject,
String taskPrefixName)
Save a task. |
protected void |
saveTaskAnnotation(TimerTask task)
Save annotation for a task. |
void |
setAnnotation(TimerTask task,
Date date,
String annotation)
Add annotation. |
void |
setAutoSaveDelay(long autoSaveDelay)
Set auto save delay (in milliseconds). |
void |
setSaveDirectory(String directory)
Set file directory. |
void |
setTaskTime(TimerTask task,
Date date,
Long time)
Set task time. |
void |
startTask(TimerTask task)
Start task. |
void |
stopTask(TimerTask task)
Stop task. |
void |
unlock()
Try to unlock current saver directory. |
| Methods inherited from class java.util.TimerTask |
|---|
cancel, scheduledExecutionTime |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static final String GTIMER_SUBTASK_SEPARATOR
protected static final String GTIMER_FILE_VERSION
protected static final String GTIMER_PROJECT_EXTENSION
protected static final String GTIMER_TASK_EXTENSION
protected static final String GTIMER_ANNOTATION_EXTENSION
protected static final String GTIMER_EMPTY_PROJECT_NAME
protected static final String LOCK_FILE_NAME
protected String saveDirectory
protected FileLock lock
protected RandomAccessFile raf
protected FileChannel channel
protected Timer autoSaveTimer
protected long autoSaveDelay
protected Collection<TimerTask> runningTasks
| Constructor Detail |
|---|
public GTimerIncrementalSaver()
| Method Detail |
|---|
public void setSaveDirectory(String directory)
Saver
setSaveDirectory in interface Saverdirectory - directorypublic void setAutoSaveDelay(long autoSaveDelay)
Saver
setAutoSaveDelay in interface SaverautoSaveDelay - delay in millisecondsprotected void checkSaveDirectory()
public void lock()
throws DataLockingException
Saver
lock in interface SaverDataLockingException - if can't obtain lock
public void unlock()
throws DataLockingException
Saver
unlock in interface SaverDataLockingException - if there is no lockpublic Collection<TimerProject> load()
Saver
load in interface Saverprotected Collection<TimerProject> gTimerLoad()
protected TimerProject getProjectFromFile(File projectFile)
throws IOException
projectFile - project file
IOException - if ioexception occurs
protected TimerTask parseTaskFromFile(Map<String,TimerProject> mapNumberProject,
File taskFile,
SortedMap<TimerTask,TimerProject> taskToManage)
throws IOException
mapNumberProject - map entre les projets reels et leur numero gtimertaskFile - gtimer task filetaskToManage - sorted map to remember task to post process
IOException - if ioexception occurs
protected void parseAnnotations(TimerTask task)
throws IOException
task - task to load annotations
IOException - if can't read ann fileprotected void parseTaskFromSavedMap(SortedMap<TimerTask,TimerProject> taskToManage)
taskToManage - sorted map of those task
protected TimerTask findTask(TimerTask parentTask,
String[] taskNames)
parentTask - tasktaskNames - names
protected void backupGTimerFiles()
protected boolean isGTimerFile(String filename)
filename - filename
protected boolean saveProject(TimerProject project)
project - project to save
protected boolean saveTask(TimerTask task)
saveTask(TimerTask, int, String)
task - task to save
protected boolean saveTask(TimerTask task,
int associatedToProject,
String taskPrefixName)
task - task to saveassociatedToProject - associated project numbertaskPrefixName - task prefix name
protected void saveTaskAnnotation(TimerTask task)
task - task to save annotationpublic void addProject(TimerProject project)
DataEventListener
addProject in interface DataEventListenerproject - project to addpublic void addTask(TimerTask task)
DataEventListener
addTask in interface DataEventListenertask - task to addprotected int getUnusedNumber(String extention)
extention - to check (ie ".project" or ".task")
public void dataLoaded(Collection<TimerProject> projects)
DataEventListener
dataLoaded in interface DataEventListenerprojects - projects collectionpublic void deleteProject(TimerProject project)
DataEventListener
deleteProject in interface DataEventListenerproject - deleted projectpublic void deleteTask(TimerTask task)
DataEventListener
deleteTask in interface DataEventListenertask - deleted task
protected void deleteTaskOrProject(TimerTask taskOrProject,
String extension)
taskOrProject - task or project to delete fileextension - extension without .public void modifyProject(TimerProject project)
DataEventListener
modifyProject in interface DataEventListenerproject - modified projectpublic void modifyTask(TimerTask task)
DataEventListener
modifyTask in interface DataEventListenertask - modified task
public void setAnnotation(TimerTask task,
Date date,
String annotation)
DataEventListener
setAnnotation in interface DataEventListenertask - task where annotation is changeddate - dateannotation - new annotation value
public void setTaskTime(TimerTask task,
Date date,
Long time)
DataEventListener
setTaskTime in interface DataEventListenertask - task where time is changeddate - datetime - task timepublic void postChangeClosedState(TimerTask task)
DataEventListener
postChangeClosedState in interface DataEventListenertask - taskpublic void preChangeClosedState(TimerTask task)
DataEventListener
preChangeClosedState in interface DataEventListenertask - taskpublic void preMoveTask(TimerTask task)
DataEventListener
preMoveTask in interface DataEventListenertask - taskpublic void postMoveTask(TimerTask task)
DataEventListener
postMoveTask in interface DataEventListenertask - task
public void postMergeTasks(TimerTask destinationTask,
List<TimerTask> otherTasks)
DataEventListener
postMergeTasks in interface DataEventListenerdestinationTask - task where all other task will be mergedotherTasks - other tasks to merge
public void preMergeTasks(TimerTask destinationTask,
List<TimerTask> otherTasks)
DataEventListener
preMergeTasks in interface DataEventListenerdestinationTask - task where all other task will be mergedotherTasks - other tasks to mergepublic void startTask(TimerTask task)
DataEventListener
startTask in interface DataEventListenertask - started taskpublic void stopTask(TimerTask task)
DataEventListener
stopTask in interface DataEventListenertask - stoped taskpublic void run()
run in interface Runnablerun in class TimerTaskprotected void saveRunningTasks()
public void checkSetAnnotation(TimerTask task,
Date date,
String value)
checkSetAnnotation in interface VetoableDataEventListenertask - task to updatedate - day of changevalue - new annotationpublic void checkAddProject(TimerProject project)
checkAddProject in interface VetoableDataEventListenerproject - project to add
public void checkAddTask(TimerTask parent,
TimerTask task)
checkAddTask in interface VetoableDataEventListenerparent - parent tasktask - task to addprotected void checkName(TimerTask task)
task - task to checkpublic void checkChangeClosedState(TimerTask task)
checkChangeClosedState in interface VetoableDataEventListenertask - taskpublic void checkDeleteProject(TimerProject project)
checkDeleteProject in interface VetoableDataEventListenerproject - deleted projectpublic void checkDeleteTask(TimerTask task)
checkDeleteTask in interface VetoableDataEventListenertask - deleted taskpublic void checkModifyProject(TimerProject project)
checkModifyProject in interface VetoableDataEventListenerproject - modified projectpublic void checkModifyTask(TimerTask task)
checkModifyTask in interface VetoableDataEventListenertask - modified task
public void checkMoveTask(TimerTask task,
TimerTask taskToMoveTo)
checkMoveTask in interface VetoableDataEventListenertask - task to movetaskToMoveTo - task to move to
public void checkSetTaskTime(TimerTask task,
Date date,
Long value)
checkSetTaskTime in interface VetoableDataEventListenertask - task to updatedate - day of changevalue - new time in seconds
public void checkMergeTasks(TimerTask destinationTask,
List<TimerTask> otherTasks)
checkMergeTasks in interface VetoableDataEventListenerdestinationTask - task result of mergeotherTasks - other task to merge
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||