org.chorem.jtimer.ui.systray
Class SystrayManager

java.lang.Object
  extended by org.chorem.jtimer.ui.systray.SystrayManager
All Implemented Interfaces:
ActionListener, MouseListener, WindowListener, Runnable, EventListener, DataEventListener

public class SystrayManager
extends Object
implements ActionListener, DataEventListener, MouseListener, Runnable, WindowListener

Factory to get correct working systray implementation.

Version:
$Revision: 2658 $ Last update : $Date: 2009-09-09 13:44:02 +0200 (mer. 09 sept. 2009) $ By : $Author: echatellier $
Author:
chatellier

Field Summary
protected  Image idleDetectImage
          Idle detect image.
protected  Image idleImage
          Idle image.
protected  int nbTasksRunning
          Reference how many tasks are running.
protected  JTimer parent
          Parent reference.
protected  JPopupMenu popup
          Popup menu instance.
protected  org.jdesktop.application.ResourceMap resourceMap
          I18n resources map.
protected  Image runningImage
          Running image.
protected  JMenuItem showItem
          Menu show.
protected  TrayIcon trayIcon
          Tray icon.
 
Constructor Summary
SystrayManager(JTimer parent)
          Default constructor.
 
Method Summary
 void actionPerformed(ActionEvent e)
           
 void addProject(TimerProject project)
          Add project event.
 void addTask(TimerTask task)
          Add task event.
 void dataLoaded(Collection<TimerProject> projects)
          All data loaded.
 void deleteProject(TimerProject project)
          Delete project.
 void deleteTask(TimerTask task)
          Delete task.
 void install()
          Install try icon into systray.
 void modifyProject(TimerProject project)
          Modify project.
 void modifyTask(TimerTask task)
          Modify task.
 void mouseClicked(MouseEvent e)
           
 void mouseEntered(MouseEvent e)
           
 void mouseExited(MouseEvent e)
           
 void mousePressed(MouseEvent e)
           
 void mouseReleased(MouseEvent e)
           
 void moveTask(TimerTask task)
          Post move task.
 void postChangeClosedState(TimerTask task)
          Post change task state.
 void postIdleDetect()
          Called by main application UI after idle detect.
 void postMergeTasks(TimerTask destinationTask, List<TimerTask> otherTasks)
          Post merge task.
 void preChangeClosedState(TimerTask task)
          Pre change task state.
 void preDeleteProject(TimerProject project)
          Before delete project.
 void preDeleteTask(TimerTask task)
          Before delete task.
 void preIdleDetect()
          Called by main application UI on idle detect.
 void preMergeTasks(TimerTask destinationTask, List<TimerTask> otherTasks)
          Pre merge task.
 void preMoveTask(TimerTask task)
          Pre move task.
 void run()
          Tray icon installation is make into a thread, put un AWT event queue.
 void setAnnotation(TimerTask task, Date date, String annotation)
          Add annotation.
 void setTaskTime(TimerTask task, Date date, Long time)
          Set task time.
protected  void startStopTask(TimerTask task, boolean start)
          Common code for start or stop task.
 void startTask(TimerTask task)
          Start task.
 void stopTask(TimerTask task)
          Stop task.
 void windowActivated(WindowEvent e)
           
 void windowClosed(WindowEvent e)
           
 void windowClosing(WindowEvent e)
           
 void windowDeactivated(WindowEvent e)
           
 void windowDeiconified(WindowEvent e)
           
 void windowIconified(WindowEvent e)
           
 void windowOpened(WindowEvent e)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

parent

protected JTimer parent
Parent reference.


resourceMap

protected org.jdesktop.application.ResourceMap resourceMap
I18n resources map.


idleImage

protected Image idleImage
Idle image.


runningImage

protected Image runningImage
Running image.


idleDetectImage

protected Image idleDetectImage
Idle detect image.


trayIcon

protected TrayIcon trayIcon
Tray icon. (null values when tray is non available)


nbTasksRunning

protected int nbTasksRunning
Reference how many tasks are running.


popup

protected JPopupMenu popup
Popup menu instance.


showItem

protected JMenuItem showItem
Menu show. (used to change text)

Constructor Detail

SystrayManager

public SystrayManager(JTimer parent)
Default constructor.

Parameters:
parent - parent
Method Detail

install

public void install()
Install try icon into systray.


run

public void run()
Tray icon installation is make into a thread, put un AWT event queue.

Specified by:
run in interface Runnable
See Also:
EventQueue.invokeLater(Runnable)

addProject

public void addProject(TimerProject project)
Description copied from interface: DataEventListener
Add project event.

Specified by:
addProject in interface DataEventListener
Parameters:
project - project to add

addTask

public void addTask(TimerTask task)
Description copied from interface: DataEventListener
Add task event.

Specified by:
addTask in interface DataEventListener
Parameters:
task - task to add

dataLoaded

public void dataLoaded(Collection<TimerProject> projects)
Description copied from interface: DataEventListener
All data loaded.

Specified by:
dataLoaded in interface DataEventListener
Parameters:
projects - projects collection

preDeleteProject

public void preDeleteProject(TimerProject project)
Description copied from interface: DataEventListener
Before delete project. TODO only usefull for UI (can't known on to delete if already deleted)

Specified by:
preDeleteProject in interface DataEventListener
Parameters:
project - deleted project

preDeleteTask

public void preDeleteTask(TimerTask task)
Description copied from interface: DataEventListener
Before delete task. TODO only usefull for UI (can't known on to delete if already deleted)

Specified by:
preDeleteTask in interface DataEventListener
Parameters:
task - deleted task

deleteProject

public void deleteProject(TimerProject project)
Description copied from interface: DataEventListener
Delete project.

Specified by:
deleteProject in interface DataEventListener
Parameters:
project - deleted project

deleteTask

public void deleteTask(TimerTask task)
Description copied from interface: DataEventListener
Delete task.

Specified by:
deleteTask in interface DataEventListener
Parameters:
task - deleted task

modifyProject

public void modifyProject(TimerProject project)
Description copied from interface: DataEventListener
Modify project.

Specified by:
modifyProject in interface DataEventListener
Parameters:
project - modified project

modifyTask

public void modifyTask(TimerTask task)
Description copied from interface: DataEventListener
Modify task.

Specified by:
modifyTask in interface DataEventListener
Parameters:
task - modified task

postChangeClosedState

public void postChangeClosedState(TimerTask task)
Description copied from interface: DataEventListener
Post change task state.

Specified by:
postChangeClosedState in interface DataEventListener
Parameters:
task - task

preChangeClosedState

public void preChangeClosedState(TimerTask task)
Description copied from interface: DataEventListener
Pre change task state.

Specified by:
preChangeClosedState in interface DataEventListener
Parameters:
task - task

startTask

public void startTask(TimerTask task)
Description copied from interface: DataEventListener
Start task.

Specified by:
startTask in interface DataEventListener
Parameters:
task - started task

stopTask

public void stopTask(TimerTask task)
Description copied from interface: DataEventListener
Stop task.

Specified by:
stopTask in interface DataEventListener
Parameters:
task - stoped task

startStopTask

protected void startStopTask(TimerTask task,
                             boolean start)
Common code for start or stop task.

Parameters:
task - task
start - start(true) or stop(false) task

preIdleDetect

public void preIdleDetect()
Called by main application UI on idle detect.


postIdleDetect

public void postIdleDetect()
Called by main application UI after idle detect.


actionPerformed

public void actionPerformed(ActionEvent e)
Specified by:
actionPerformed in interface ActionListener

setAnnotation

public void setAnnotation(TimerTask task,
                          Date date,
                          String annotation)
Description copied from interface: DataEventListener
Add annotation.

Specified by:
setAnnotation in interface DataEventListener
Parameters:
task - task where annotation is changed
date - date
annotation - new annotation value

setTaskTime

public void setTaskTime(TimerTask task,
                        Date date,
                        Long time)
Description copied from interface: DataEventListener
Set task time.

Specified by:
setTaskTime in interface DataEventListener
Parameters:
task - task where time is changed
date - date
time - task time

moveTask

public void moveTask(TimerTask task)
Description copied from interface: DataEventListener
Post move task.

Specified by:
moveTask in interface DataEventListener
Parameters:
task - task

preMoveTask

public void preMoveTask(TimerTask task)
Description copied from interface: DataEventListener
Pre move task.

Specified by:
preMoveTask in interface DataEventListener
Parameters:
task - task

postMergeTasks

public void postMergeTasks(TimerTask destinationTask,
                           List<TimerTask> otherTasks)
Description copied from interface: DataEventListener
Post merge task.

Specified by:
postMergeTasks in interface DataEventListener
Parameters:
destinationTask - task where all other task will be merged
otherTasks - other tasks to merge

preMergeTasks

public void preMergeTasks(TimerTask destinationTask,
                          List<TimerTask> otherTasks)
Description copied from interface: DataEventListener
Pre merge task.

Specified by:
preMergeTasks in interface DataEventListener
Parameters:
destinationTask - task where all other task will be merged
otherTasks - other tasks to merge

mouseClicked

public void mouseClicked(MouseEvent e)
Specified by:
mouseClicked in interface MouseListener

mouseEntered

public void mouseEntered(MouseEvent e)
Specified by:
mouseEntered in interface MouseListener

mouseExited

public void mouseExited(MouseEvent e)
Specified by:
mouseExited in interface MouseListener

mousePressed

public void mousePressed(MouseEvent e)
Specified by:
mousePressed in interface MouseListener

mouseReleased

public void mouseReleased(MouseEvent e)
Specified by:
mouseReleased in interface MouseListener

windowClosing

public void windowClosing(WindowEvent e)
Specified by:
windowClosing in interface WindowListener

windowActivated

public void windowActivated(WindowEvent e)
Specified by:
windowActivated in interface WindowListener

windowClosed

public void windowClosed(WindowEvent e)
Specified by:
windowClosed in interface WindowListener

windowDeactivated

public void windowDeactivated(WindowEvent e)
Specified by:
windowDeactivated in interface WindowListener

windowDeiconified

public void windowDeiconified(WindowEvent e)
Specified by:
windowDeiconified in interface WindowListener

windowIconified

public void windowIconified(WindowEvent e)
Specified by:
windowIconified in interface WindowListener

windowOpened

public void windowOpened(WindowEvent e)
Specified by:
windowOpened in interface WindowListener


Copyright © 2007-2009 CodeLutin. All Rights Reserved.