Jtimer-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
September 2009
- 1 participants
- 15 discussions
11 Sep '09
Author: echatellier
Date: 2009-09-11 12:21:53 +0200 (Fri, 11 Sep 2009)
New Revision: 2659
Modified:
trunk/src/main/java/org/chorem/jtimer/ui/widget/DurationEditor.java
Log:
Fix spinner bounds
Modified: trunk/src/main/java/org/chorem/jtimer/ui/widget/DurationEditor.java
===================================================================
--- trunk/src/main/java/org/chorem/jtimer/ui/widget/DurationEditor.java 2009-09-09 11:44:02 UTC (rev 2658)
+++ trunk/src/main/java/org/chorem/jtimer/ui/widget/DurationEditor.java 2009-09-11 10:21:53 UTC (rev 2659)
@@ -70,7 +70,8 @@
public DurationEditor() {
super(new FlowLayout(FlowLayout.CENTER, 0, 0));
- hourSpinnerModel = new SpinnerNumberModel(0, 0, Integer.MAX_VALUE, 1);
+ // hack set 9999 Integer.MAX_VALUE make zone too huge
+ hourSpinnerModel = new SpinnerNumberModel(0, 0, 9999, 1);
hourSpinner = new JSpinner(hourSpinnerModel);
add(hourSpinner);
1
0
r2658 - in trunk/src: main/java/org/chorem/jtimer/ui/alert main/java/org/chorem/jtimer/ui/systray main/java/org/chorem/jtimer/ui/tasks main/resources/org/chorem/jtimer/ui/alert/resources main/resources/org/chorem/jtimer/ui/tasks/resources test/java/org/chorem/jtimer/io
by echatellier@users.chorem.org 09 Sep '09
by echatellier@users.chorem.org 09 Sep '09
09 Sep '09
Author: echatellier
Date: 2009-09-09 13:44:02 +0200 (Wed, 09 Sep 2009)
New Revision: 2658
Added:
trunk/src/main/resources/org/chorem/jtimer/ui/alert/resources/AlertEditor_fr.properties
trunk/src/main/resources/org/chorem/jtimer/ui/tasks/resources/RunTaskJob_fr.properties
Modified:
trunk/src/main/java/org/chorem/jtimer/ui/alert/AlertCellEditor.java
trunk/src/main/java/org/chorem/jtimer/ui/alert/AlertCellRenderer.java
trunk/src/main/java/org/chorem/jtimer/ui/alert/AlertEditor.java
trunk/src/main/java/org/chorem/jtimer/ui/alert/AlertTableModel.java
trunk/src/main/java/org/chorem/jtimer/ui/systray/SystrayManager.java
trunk/src/main/java/org/chorem/jtimer/ui/tasks/RunTaskJob.java
trunk/src/main/resources/org/chorem/jtimer/ui/alert/resources/AlertEditor.properties
trunk/src/main/resources/org/chorem/jtimer/ui/tasks/resources/RunTaskJob.properties
trunk/src/test/java/org/chorem/jtimer/io/GTimerIncrementalSaverTest.java
Log:
Add alert UI i18n, improve alert manipulation.
Modified: trunk/src/main/java/org/chorem/jtimer/ui/alert/AlertCellEditor.java
===================================================================
--- trunk/src/main/java/org/chorem/jtimer/ui/alert/AlertCellEditor.java 2009-09-09 09:32:27 UTC (rev 2657)
+++ trunk/src/main/java/org/chorem/jtimer/ui/alert/AlertCellEditor.java 2009-09-09 11:44:02 UTC (rev 2658)
@@ -45,10 +45,16 @@
/** serialVersionUID. */
private static final long serialVersionUID = -363052829182024180L;
-
+
/** Current editor. */
protected Component editor;
+ /**
+ */
+ public AlertCellEditor() {
+ //super(new JTextField());
+ }
+
/*
* @see javax.swing.CellEditor#getCellEditorValue()
*/
@@ -71,7 +77,7 @@
@Override
public Component getTableCellEditorComponent(JTable table, Object value,
boolean isSelected, int row, int column) {
-
+
switch (column) {
case 0:
JComboBox combo = new JComboBox();
@@ -87,13 +93,19 @@
long duration = ((Long)value).longValue();
durationEditor.setDuration(duration);
durationEditor.addPropertyChangeListener("duration", this);
+ durationEditor.setSize(100, 30);
editor = durationEditor;
break;
-
+
default:
break;
}
+ // restore supercomponent properties
+ if (isSelected) {
+ editor.setBackground(table.getSelectionBackground());
+ }
+
return editor;
}
Modified: trunk/src/main/java/org/chorem/jtimer/ui/alert/AlertCellRenderer.java
===================================================================
--- trunk/src/main/java/org/chorem/jtimer/ui/alert/AlertCellRenderer.java 2009-09-09 09:32:27 UTC (rev 2657)
+++ trunk/src/main/java/org/chorem/jtimer/ui/alert/AlertCellRenderer.java 2009-09-09 11:44:02 UTC (rev 2658)
@@ -47,9 +47,8 @@
@Override
public Component getTableCellRendererComponent(JTable table, Object value,
boolean isSelected, boolean hasFocus, int row, int column) {
-
- super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
-
+
+ Component superComponent = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
Component c = null;
switch (column) {
case 0:
@@ -70,6 +69,9 @@
default:
break;
}
+
+ // restore super properties
+ c.setBackground(superComponent.getBackground());
return c;
}
Modified: trunk/src/main/java/org/chorem/jtimer/ui/alert/AlertEditor.java
===================================================================
--- trunk/src/main/java/org/chorem/jtimer/ui/alert/AlertEditor.java 2009-09-09 09:32:27 UTC (rev 2657)
+++ trunk/src/main/java/org/chorem/jtimer/ui/alert/AlertEditor.java 2009-09-09 11:44:02 UTC (rev 2658)
@@ -37,6 +37,7 @@
import org.chorem.jtimer.data.TimerDataManager;
import org.chorem.jtimer.entities.TimerAlert;
import org.chorem.jtimer.entities.TimerTask;
+import org.chorem.jtimer.entities.TimerAlert.Type;
import org.jdesktop.application.Action;
import org.jdesktop.application.Application;
import org.jdesktop.application.FrameView;
@@ -54,17 +55,23 @@
/** serialVersionUID. */
private static final long serialVersionUID = 5606265095312928490L;
-
+
+ /** Task to manage alert on. */
protected TimerTask task;
+ /** List of cloned task alert list. */
protected List<TimerAlert> alerts;
+ /** Manager to commit alert modification. */
protected TimerDataManager timerDataManager;
+ /** Table to display alerts .*/
protected JTable alertTable;
+ /** Alert model for table. */
protected AlertTableModel alertModel;
+ /** Selected alert property. */
protected boolean selectedAlert;
/**
@@ -88,32 +95,42 @@
// rename frame to get proper position
getFrame().setName("alertFrame");
+ getFrame().setTitle(getResourceMap().getString("alert.title"));
setComponent(getMainComponent());
}
+ /**
+ * Build main component.
+ *
+ * @return main component
+ */
protected JComponent getMainComponent() {
JPanel panel = new JPanel(new GridBagLayout());
- JLabel label = new JLabel("Alerts list :");
- panel.add(label, new GridBagConstraints(0, 0, 3, 1, 1, 0,
+ JLabel label = new JLabel(getResourceMap().getString("alert.alertlist"));
+ panel.add(label, new GridBagConstraints(0, 0, 2, 1, 1, 0,
GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(
1, 1, 1, 1), 0, 0));
- alertTable = new JTable();
- alertModel = new AlertTableModel(alerts);
- alertTable.setModel(alertModel);
- alertTable.setRowHeight(30);
+ // get column labels
+ List<String> columnIdentifiers = new ArrayList<String>();
+ columnIdentifiers.add(getResourceMap().getString("alert.type"));
+ columnIdentifiers.add(getResourceMap().getString("alert.duration"));
+
+ alertModel = new AlertTableModel(alerts, columnIdentifiers);
+ alertTable = new JTable(alertModel);
alertTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
alertTable.getColumnModel().getColumn(0).setCellEditor(new AlertCellEditor());
alertTable.getColumnModel().getColumn(1).setCellEditor(new AlertCellEditor());
alertTable.getColumnModel().getColumn(0).setCellRenderer(new AlertCellRenderer());
alertTable.getColumnModel().getColumn(1).setCellRenderer(new AlertCellRenderer());
+ alertTable.setRowHeight(30);
alertTable.getSelectionModel().addListSelectionListener(this);
JScrollPane sp = new JScrollPane(alertTable);
- panel.add(sp, new GridBagConstraints(0, 1, 3, 1, 1, 1,
+ panel.add(sp, new GridBagConstraints(0, 1, 2, 1, 1, 1,
GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(
1, 1, 1, 1), 0, 0));
@@ -130,12 +147,18 @@
GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
new Insets(1, 1, 1, 1), 0, 0));
- JButton closeButton = new JButton();
- closeButton.setAction(getContext().getActionMap(this).get("close"));
- panel.add(closeButton, new GridBagConstraints(2, 2, 1, 1, 1, 0,
+ JButton cancelButton = new JButton();
+ cancelButton.setAction(getContext().getActionMap(this).get("cancel"));
+ panel.add(cancelButton, new GridBagConstraints(0, 3, 1, 1, 1, 0,
GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
new Insets(1, 1, 1, 1), 0, 0));
+ JButton saveButton = new JButton();
+ saveButton.setAction(getContext().getActionMap(this).get("save"));
+ panel.add(saveButton, new GridBagConstraints(1, 3, 1, 1, 1, 0,
+ GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
+ new Insets(1, 1, 1, 1), 0, 0));
+
return panel;
}
@@ -162,6 +185,8 @@
@Action
public void addAlert() {
TimerAlert alert = new TimerAlert();
+ // set default value, too hard to manage with null values :(
+ alert.setType(Type.REACH_DAILY_TIME);
alerts.add(alert);
alertModel.fireTableDataChanged();
}
@@ -175,17 +200,26 @@
}
@Action
- public void close() {
+ public void save() {
+
+ // filter null type alert (forbidden)
task.setAlert(alerts);
+
timerDataManager.modifyAlert(task);
getApplication().hide(this);
}
+ @Action
+ public void cancel() {
+ getApplication().hide(this);
+ }
+
/*
* @see javax.swing.event.ListSelectionListener#valueChanged(javax.swing.event.ListSelectionEvent)
*/
@Override
public void valueChanged(ListSelectionEvent e) {
+ // used to update remove button property
setSelectedAlert(e.getFirstIndex() >= 0);
}
}
Modified: trunk/src/main/java/org/chorem/jtimer/ui/alert/AlertTableModel.java
===================================================================
--- trunk/src/main/java/org/chorem/jtimer/ui/alert/AlertTableModel.java 2009-09-09 09:32:27 UTC (rev 2657)
+++ trunk/src/main/java/org/chorem/jtimer/ui/alert/AlertTableModel.java 2009-09-09 11:44:02 UTC (rev 2658)
@@ -39,11 +39,21 @@
/** serialVersionUID. */
private static final long serialVersionUID = 4103529427954019924L;
+ /** Table column identifiers. */
+ protected List<String> columnIdentifiers;
+
/** Edition alerts list. */
protected List<TimerAlert> alerts;
- public AlertTableModel(List<TimerAlert> alerts) {
+ /**
+ * Contructor.
+ *
+ * @param alerts alerts list
+ * @param columnIdentifiers columns identifiers
+ */
+ public AlertTableModel(List<TimerAlert> alerts, List<String> columnIdentifiers) {
this.alerts = alerts;
+ this.columnIdentifiers = columnIdentifiers;
}
/*
@@ -60,15 +70,7 @@
@Override
public String getColumnName(int column) {
- String columnName = "";
- switch (column) {
- case 0:
- columnName = "Type";
- break;
- case 1:
- columnName = "Duration";
- break;
- }
+ String columnName = columnIdentifiers.get(column);
return columnName;
}
Modified: trunk/src/main/java/org/chorem/jtimer/ui/systray/SystrayManager.java
===================================================================
--- trunk/src/main/java/org/chorem/jtimer/ui/systray/SystrayManager.java 2009-09-09 09:32:27 UTC (rev 2657)
+++ trunk/src/main/java/org/chorem/jtimer/ui/systray/SystrayManager.java 2009-09-09 11:44:02 UTC (rev 2658)
@@ -29,8 +29,6 @@
import java.awt.event.MouseListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
import java.util.Collection;
import java.util.Date;
import java.util.List;
Modified: trunk/src/main/java/org/chorem/jtimer/ui/tasks/RunTaskJob.java
===================================================================
--- trunk/src/main/java/org/chorem/jtimer/ui/tasks/RunTaskJob.java 2009-09-09 09:32:27 UTC (rev 2657)
+++ trunk/src/main/java/org/chorem/jtimer/ui/tasks/RunTaskJob.java 2009-09-09 11:44:02 UTC (rev 2658)
@@ -111,7 +111,7 @@
TimerDataManager dataManager) {
super(parentApp);
this.parentApp = parentApp;
-
+
// init with False
bWantToStop = Boolean.FALSE;
@@ -377,13 +377,15 @@
for (TimerAlert alert : task.getAlerts()) {
if (!alreadyTrownAlerts.contains(alert)) {
if (alert.getType().equals(Type.REACH_DAILY_TIME) && TimerTaskHelper.getTotalTime(task, now) >= alert.getDuration()) {
- String alertMessage = "Task '%s' has reached %s for current day !";
- displayAlert(String.format(alertMessage, task.getName(), DurationFormatUtils.formatDuration(alert.getDuration() * 1000, "HH:mm:ss")));
+ //String alertMessage = "Task '%s' has reached %s for current day !";
+ //displayAlert(String.format(alertMessage, task.getName(), DurationFormatUtils.formatDuration(alert.getDuration() * 1000, "HH:mm:ss")));
+ displayAlert(task, Type.REACH_DAILY_TIME, alert.getDuration());
alreadyTrownAlerts.add(alert.clone());
}
else if (alert.getType().equals(Type.REACH_TOTAL_TIME) && TimerTaskHelper.getAllTotalTime(task) >= alert.getDuration()) {
- String alertMessage = "Task '%s' has reached %s !";
- displayAlert(String.format(alertMessage, task.getName(), DurationFormatUtils.formatDuration(alert.getDuration() * 1000, "HH:mm:ss")));
+ //String alertMessage = "Task '%s' has reached %s !";
+ //displayAlert(String.format(alertMessage, task.getName(), DurationFormatUtils.formatDuration(alert.getDuration() * 1000, "HH:mm:ss")));
+ displayAlert(task, Type.REACH_TOTAL_TIME, alert.getDuration());
alreadyTrownAlerts.add(alert.clone());
}
}
@@ -402,10 +404,21 @@
*
* @param alertMessage alert message
*/
- protected void displayAlert(final String alertMessage) {
+ protected void displayAlert(final TimerTask task, final Type alertType, final long alertDuration) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
- JOptionPane.showMessageDialog(null, alertMessage, "Alert", JOptionPane.INFORMATION_MESSAGE, getResourceMap().getIcon("alertIcon"));
+ String alertMessage = null;
+ String formattedTime = DurationFormatUtils.formatDuration(alertDuration * 1000, "HH:mm:ss");
+ if (Type.REACH_DAILY_TIME.equals(alertType)) {
+ alertMessage = getResourceMap().getString("alert.dailyAlertMessage", task.getName(), formattedTime);
+ }
+ else if (Type.REACH_TOTAL_TIME.equals(alertType)) {
+ alertMessage = getResourceMap().getString("alert.totalAlertMessage", task.getName(), formattedTime);
+ }
+
+ JOptionPane.showMessageDialog(null, alertMessage,
+ getResourceMap().getString("alert.title"), JOptionPane.INFORMATION_MESSAGE,
+ getResourceMap().getIcon("alert.alertIcon"));
}
});
}
Modified: trunk/src/main/resources/org/chorem/jtimer/ui/alert/resources/AlertEditor.properties
===================================================================
--- trunk/src/main/resources/org/chorem/jtimer/ui/alert/resources/AlertEditor.properties 2009-09-09 09:32:27 UTC (rev 2657)
+++ trunk/src/main/resources/org/chorem/jtimer/ui/alert/resources/AlertEditor.properties 2009-09-09 11:44:02 UTC (rev 2658)
@@ -1,3 +1,9 @@
+alert.title = ${Application.title} - Alerts
+alert.alertlist = Alert list :
+alert.type = Type
+alert.duration = Duration
+
+# buttons
addAlert.Action.text = Add
addAlert.Action.shortDescription = Add
@@ -4,5 +10,8 @@
removeAlert.Action.text = Remove
removeAlert.shortDescription = Remove
-close.Action.text = Close
-close.Action.shortDescription = Close
\ No newline at end of file
+save.Action.text = Save
+save.Action.shortDescription = Save
+
+cancel.Action.text = Cancel
+cancel.Action.shortDescription = Cancel
\ No newline at end of file
Added: trunk/src/main/resources/org/chorem/jtimer/ui/alert/resources/AlertEditor_fr.properties
===================================================================
--- trunk/src/main/resources/org/chorem/jtimer/ui/alert/resources/AlertEditor_fr.properties (rev 0)
+++ trunk/src/main/resources/org/chorem/jtimer/ui/alert/resources/AlertEditor_fr.properties 2009-09-09 11:44:02 UTC (rev 2658)
@@ -0,0 +1,17 @@
+alert.title = ${Application.title} - Alertes
+alert.alertlist = Listes des alertes :
+alert.type = Type
+alert.duration = Dur\u00E9e
+
+# Boutons
+addAlert.Action.text = Ajouter
+addAlert.Action.shortDescription = Ajouter une nouvelle alerte
+
+removeAlert.Action.text = Supprimer
+removeAlert.shortDescription = Supprimer l'alerte
+
+save.Action.text = Sauver
+save.Action.shortDescription = Sauver
+
+cancel.Action.text = Annuler
+cancel.Action.shortDescription = Annuler
\ No newline at end of file
Modified: trunk/src/main/resources/org/chorem/jtimer/ui/tasks/resources/RunTaskJob.properties
===================================================================
--- trunk/src/main/resources/org/chorem/jtimer/ui/tasks/resources/RunTaskJob.properties 2009-09-09 09:32:27 UTC (rev 2657)
+++ trunk/src/main/resources/org/chorem/jtimer/ui/tasks/resources/RunTaskJob.properties 2009-09-09 11:44:02 UTC (rev 2658)
@@ -1 +1,6 @@
-alertIcon=bell48.png
+alert.alertIcon=bell48.png
+
+# messages
+alert.title = Alert
+alert.dailyAlertMessage = Task '%s' has reached %s for current day !
+alert.totalAlertMessage = Task '%s' has reached %s !
Added: trunk/src/main/resources/org/chorem/jtimer/ui/tasks/resources/RunTaskJob_fr.properties
===================================================================
--- trunk/src/main/resources/org/chorem/jtimer/ui/tasks/resources/RunTaskJob_fr.properties (rev 0)
+++ trunk/src/main/resources/org/chorem/jtimer/ui/tasks/resources/RunTaskJob_fr.properties 2009-09-09 11:44:02 UTC (rev 2658)
@@ -0,0 +1,4 @@
+# messages
+alert.title = Alerte
+alert.dailyAlertMessage = La t\u00E2che '%s' a atteint %s pour ce jour !
+alert.totalAlertMessage = La t\u00E2che '%s' a atteint %s !
Modified: trunk/src/test/java/org/chorem/jtimer/io/GTimerIncrementalSaverTest.java
===================================================================
--- trunk/src/test/java/org/chorem/jtimer/io/GTimerIncrementalSaverTest.java 2009-09-09 09:32:27 UTC (rev 2657)
+++ trunk/src/test/java/org/chorem/jtimer/io/GTimerIncrementalSaverTest.java 2009-09-09 11:44:02 UTC (rev 2658)
@@ -49,8 +49,7 @@
public class GTimerIncrementalSaverTest extends AbstractJTimerTest {
/** Class log */
- private static Log log = LogFactory
- .getLog(GTimerIncrementalSaverTest.class);
+ private static Log log = LogFactory.getLog(GTimerIncrementalSaverTest.class);
/**
* Test que saveDirectory a une valeur attendue.
1
0
09 Sep '09
Author: echatellier
Date: 2009-09-09 11:32:27 +0200 (Wed, 09 Sep 2009)
New Revision: 2657
Modified:
trunk/src/main/java/org/chorem/jtimer/ui/widget/DurationEditor.java
Log:
Can set more than 24 hours.
Modified: trunk/src/main/java/org/chorem/jtimer/ui/widget/DurationEditor.java
===================================================================
--- trunk/src/main/java/org/chorem/jtimer/ui/widget/DurationEditor.java 2009-09-09 08:32:30 UTC (rev 2656)
+++ trunk/src/main/java/org/chorem/jtimer/ui/widget/DurationEditor.java 2009-09-09 09:32:27 UTC (rev 2657)
@@ -70,7 +70,7 @@
public DurationEditor() {
super(new FlowLayout(FlowLayout.CENTER, 0, 0));
- hourSpinnerModel = new SpinnerNumberModel(0, 0, 24, 1);
+ hourSpinnerModel = new SpinnerNumberModel(0, 0, Integer.MAX_VALUE, 1);
hourSpinner = new JSpinner(hourSpinnerModel);
add(hourSpinner);
1
0
r2656 - in trunk/src/main: java/org/chorem/jtimer java/org/chorem/jtimer/ui/systray resources/org/chorem/jtimer/ui/systray/resources
by echatellier@users.chorem.org 09 Sep '09
by echatellier@users.chorem.org 09 Sep '09
09 Sep '09
Author: echatellier
Date: 2009-09-09 10:32:30 +0200 (Wed, 09 Sep 2009)
New Revision: 2656
Added:
trunk/src/main/resources/org/chorem/jtimer/ui/systray/resources/SystrayManager.properties
trunk/src/main/resources/org/chorem/jtimer/ui/systray/resources/SystrayManager_fr.properties
Removed:
trunk/src/main/java/org/chorem/jtimer/ui/systray/AWTSystray.java
trunk/src/main/java/org/chorem/jtimer/ui/systray/NoSystray.java
trunk/src/main/resources/org/chorem/jtimer/ui/systray/resources/AWTSystray.properties
trunk/src/main/resources/org/chorem/jtimer/ui/systray/resources/AWTSystray_fr.properties
Modified:
trunk/src/main/java/org/chorem/jtimer/JTimer.java
trunk/src/main/java/org/chorem/jtimer/ui/systray/SystrayManager.java
trunk/src/main/java/org/chorem/jtimer/ui/systray/package-info.java
Log:
New system tray implementation. Install it with AWT event queue.
Can now be hot swapped with no systray implementation.
Modified: trunk/src/main/java/org/chorem/jtimer/JTimer.java
===================================================================
--- trunk/src/main/java/org/chorem/jtimer/JTimer.java 2009-09-07 15:29:18 UTC (rev 2655)
+++ trunk/src/main/java/org/chorem/jtimer/JTimer.java 2009-09-09 08:32:30 UTC (rev 2656)
@@ -165,7 +165,7 @@
}
// Systray mgr
- systrayManager = SystrayManager.getSystray(this);
+ systrayManager = new SystrayManager(this);
core.getData().addDataEventListener(systrayManager);
}
@@ -462,7 +462,7 @@
try {
core.getData().addProject(p);
}
- catch(DataViolationException e) {
+ catch (DataViolationException e) {
displayErrorMessage(e.getExceptionKey());
}
}
@@ -491,7 +491,7 @@
try {
core.getData().editProject(project, newProjectName);
}
- catch(DataViolationException e) {
+ catch (DataViolationException e) {
displayErrorMessage(e.getExceptionKey());
}
}
@@ -527,7 +527,7 @@
try {
core.getData().addTask(selectedTask, t);
}
- catch(DataViolationException e) {
+ catch (DataViolationException e) {
displayErrorMessage(e.getExceptionKey());
}
}
@@ -790,13 +790,18 @@
long newTodayTime = todayTime + increment;
- // check if + negative increment still positive
- if (newTodayTime > 0) {
- core.getData().changeTaskTime(selectedTask, now, newTodayTime);
- } else {
- // force to 0
- core.getData().changeTaskTime(selectedTask, now, 0L);
+ try {
+ // check if + negative increment still positive
+ if (newTodayTime > 0) {
+ core.getData().changeTaskTime(selectedTask, now, newTodayTime);
+ } else {
+ // force to 0
+ core.getData().changeTaskTime(selectedTask, now, 0L);
+ }
}
+ catch(DataViolationException e) {
+ displayErrorMessage(e.getExceptionKey());
+ }
}
}
@@ -823,7 +828,13 @@
.getString("input.mergeTaskTitle"),
JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
if (confirm == JOptionPane.YES_OPTION) {
- core.getData().mergeTasks(destinationTask, otherTasks);
+
+ try {
+ core.getData().mergeTasks(destinationTask, otherTasks);
+ }
+ catch (DataViolationException e) {
+ displayErrorMessage(e.getExceptionKey());
+ }
}
}
@@ -845,7 +856,12 @@
// remove useless spaces
annotation = annotation.trim();
- this.core.getData().addAnnotation(selectedTask, new Date(), annotation);
+ try {
+ core.getData().addAnnotation(selectedTask, new Date(), annotation);
+ }
+ catch (DataViolationException e) {
+ displayErrorMessage(e.getExceptionKey());
+ }
}
}
Deleted: trunk/src/main/java/org/chorem/jtimer/ui/systray/AWTSystray.java
===================================================================
--- trunk/src/main/java/org/chorem/jtimer/ui/systray/AWTSystray.java 2009-09-07 15:29:18 UTC (rev 2655)
+++ trunk/src/main/java/org/chorem/jtimer/ui/systray/AWTSystray.java 2009-09-09 08:32:30 UTC (rev 2656)
@@ -1,382 +0,0 @@
-/* *##%
- * Copyright (C) 2008, 2009 Code Lutin
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *##%*/
-
-package org.chorem.jtimer.ui.systray;
-
-import java.awt.AWTException;
-import java.awt.Image;
-import java.awt.SystemTray;
-import java.awt.TrayIcon;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.awt.event.MouseEvent;
-import java.awt.event.MouseListener;
-import java.awt.event.WindowEvent;
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-
-import javax.swing.JMenuItem;
-import javax.swing.JPopupMenu;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.chorem.jtimer.JTimer;
-import org.chorem.jtimer.entities.TimerTask;
-import org.jdesktop.application.ApplicationContext;
-import org.jdesktop.application.ResourceManager;
-import org.jdesktop.application.ResourceMap;
-
-/**
- * Manager for systray icon.
- *
- * @author chatellier
- * @version $Revision$
- *
- * Last update : $Date$ By : $Author$
- */
-public class AWTSystray extends SystrayManager implements ActionListener,
- MouseListener, PropertyChangeListener {
-
- /** Log */
- private static Log log = LogFactory.getLog(AWTSystray.class);
-
- /** I18n resources map */
- protected ResourceMap resourceMap;
-
- /** Tray icon */
- protected TrayIcon trayIcon;
-
- /** Idle image */
- protected Image idleImage;
- /** Running image */
- protected Image runningImage;
- /** Idle detect image */
- protected Image idleDetectImage;
-
- /** Reference how many tasks are running */
- protected int nbTasksRunning = 0;
-
- /** popup menu instance */
- protected JPopupMenu popup;
-
- /** Menu show */
- protected JMenuItem showItem;
-
- /**
- * Constructor.
- *
- * Protected to be called only by factory.
- *
- * @param parent parent
- */
- protected AWTSystray(JTimer parent) {
-
- super(parent);
-
- // init resources map
- ApplicationContext ctxt = parent.getContext();
- ResourceManager mgr = ctxt.getResourceManager();
- resourceMap = mgr.getResourceMap(AWTSystray.class);
-
- // load an image
- // use FQN to not conflict with annotation
- idleImage = resourceMap.getImageIcon("idleImage").getImage();
- runningImage = resourceMap.getImageIcon("runningImage").getImage();
- idleDetectImage = resourceMap.getImageIcon("idleDetectImage")
- .getImage();
- }
-
- /**
- * Install try icon into systray.
- */
- public void install() {
-
- // get the SystemTray instance
- SystemTray tray = SystemTray.getSystemTray();
-
- // create a action listener to listen for default action executed on
- // the tray icon
- // create a popup menu
- popup = new JPopupMenu();
-
- // show
- showItem = new JMenuItem(resourceMap.getString("hideMenuText"));
- // showItem.setName("trayShowMenu"); seems don't work with awt
- // components
- showItem.addActionListener(this);
- showItem.setActionCommand("showHide");
- popup.add(showItem);
- popup.addSeparator();
-
- // quit
- JMenuItem quitItem = new JMenuItem(resourceMap
- .getString("quitMenuText"));
- // defaultItem.setName("quit");
- quitItem.addActionListener(this);
- quitItem.setActionCommand("quit");
- popup.add(quitItem);
-
- // / ... add other items
- // construct a TrayIcon
-
- trayIcon = new TrayIcon(idleImage, resourceMap
- .getString("tooltipIdleText"), null);
- trayIcon.setImageAutoSize(true);
- trayIcon.addMouseListener(this);
-
- // add the tray image
- try {
- tray.add(trayIcon);
- } catch (AWTException e) {
-
- // exception is throw if systray is currently missing
- // not big deal, we will set it when it'll be ready
- if (log.isWarnEnabled()) {
- log.warn("Error while setting system tray", e);
- }
-
- // add listener
- tray.addPropertyChangeListener("trayIcons", this);
- }
-
- // call to super install
- super.install();
- }
-
- /*
- * @see org.chorem.jtimer.ui.systray.SystrayManager#startTask(org.chorem.jtimer.entities.TimerTask)
- */
- @Override
- public void startTask(TimerTask task) {
- startStopTask(task, true);
- }
-
- /*
- * @see org.chorem.jtimer.ui.systray.SystrayManager#stopTask(org.chorem.jtimer.entities.TimerTask)
- */
- @Override
- public void stopTask(TimerTask task) {
- startStopTask(task, false);
- }
-
- /**
- * Common code for start or stop task.
- *
- * @param task task
- * @param start start(true) or stop(false) task
- */
- protected void startStopTask(TimerTask task, boolean start) {
- // increment or decrement task
- if (start) {
- ++nbTasksRunning;
- } else {
- --nbTasksRunning;
- }
-
- // display message
- String message = null;
- if (nbTasksRunning == 0) {
- message = resourceMap.getString("tooltipIdleText");
-
- trayIcon.setImage(idleImage);
- } else {
- trayIcon.setImage(runningImage);
- if (nbTasksRunning == 1) {
- message = resourceMap.getString("tooltipRunningTaskText",
- nbTasksRunning);
- } else {
- message = resourceMap.getString("tooltipRunningTasksText",
- nbTasksRunning);
- }
- }
- trayIcon.setToolTip(message);
-
- }
-
- /*
- * @see org.chorem.jtimer.ui.systray.SystrayManager#postIdleDetect()
- */
- @Override
- public void postIdleDetect() {
-
- if (log.isDebugEnabled()) {
- log.debug("Post idle detect");
- }
-
- if (nbTasksRunning == 0) {
- trayIcon.setImage(idleImage);
- } else {
- trayIcon.setImage(runningImage);
- }
-
- }
-
- /*
- * @see org.chorem.jtimer.ui.systray.SystrayManager#preIdleDetect()
- */
- @Override
- public void preIdleDetect() {
-
- if (log.isDebugEnabled()) {
- log.debug("Pre idle detect");
- }
-
- trayIcon.setImage(idleDetectImage);
- }
-
- /*
- * @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
- */
- @Override
- public void propertyChange(PropertyChangeEvent evt) {
-
- // get event name
- String event = evt.getPropertyName();
-
- if (log.isDebugEnabled()) {
- log.debug("Property change on system tray : " + event);
- }
-
- // systemTray event is only available in jdk7
- if (event.equals("trayIcons")) {
-
- if (log.isDebugEnabled()) {
- log.debug("Systray event : " + evt.getPropertyName());
- }
-
- SystemTray tray = SystemTray.getSystemTray();
-
- // tray become available
- if (tray != null) {
- try {
- tray.add(trayIcon);
- } catch (AWTException e) {
- if (log.isErrorEnabled()) {
- log.error("System tray seems to become available, but can't set it !",
- e);
- }
- }
- }
- }
- }
-
- /*
- * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
- */
- public void actionPerformed(ActionEvent e) {
-
- String actionCommand = e.getActionCommand();
-
- if ("showHide".equals(actionCommand)) {
- if (parent.getMainFrame().isVisible()) {
- // on la cache
- parent.hide();
- showItem.setText(resourceMap.getString("showMenuText"));
- } else {
- // sinon on la montre
- parent.show();
- showItem.setText(resourceMap.getString("hideMenuText"));
- }
- }
-
- if ("quit".equals(actionCommand)) {
- parent.quit(e);
- }
- }
-
- /*
- * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
- */
- @Override
- public void mouseClicked(MouseEvent e) {
-
- // ne fait pas de double affichage si plus de clics
- // et ne change pas l'affichage si clic droit
- if (e.getClickCount() == 1 && e.getButton() == MouseEvent.BUTTON1) {
-
- // si la fenetre est affichee
- if (parent.getMainFrame().isVisible()) {
- showItem.setText(resourceMap.getString("showMenuText"));
-
- // on la cache
- parent.hide();
-
- } else {
-
- showItem.setText(resourceMap.getString("hideMenuText"));
-
- // sinon on la montre
- // correct iconified bug
- // http://www.java-forums.org/awt-swing/7000-problem-setvisible-linux.html
- //parent.getMainFrame().setExtendedState(JFrame.NORMAL);
- parent.show();
-
- }
- }
-
- }
-
- /*
- * @see java.awt.event.MouseListener#mouseEntered(java.awt.event.MouseEvent)
- */
- @Override
- public void mouseEntered(MouseEvent e) {
-
- }
-
- /*
- * @see java.awt.event.MouseListener#mouseExited(java.awt.event.MouseEvent)
- */
- @Override
- public void mouseExited(MouseEvent e) {
-
- }
-
- /*
- * @see java.awt.event.MouseListener#mousePressed(java.awt.event.MouseEvent)
- */
- @Override
- public void mousePressed(MouseEvent e) {
-
- }
-
- /*
- * @see java.awt.event.MouseListener#mouseReleased(java.awt.event.MouseEvent)
- */
- @Override
- public void mouseReleased(MouseEvent e) {
-
- // use sun workarround http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6285881
- if (e.getClickCount() == 1 && e.getButton() == MouseEvent.BUTTON3) {
- popup.setLocation(e.getX(), e.getY());
- popup.setInvoker(popup);
- popup.setVisible(true);
- }
- }
-
- /*
- * @see java.awt.event.WindowListener#windowClosing(java.awt.event.WindowEvent)
- */
- @Override
- public void windowClosing(WindowEvent e) {
-
- // hide window (without exiting)
- parent.hide();
- showItem.setText(resourceMap.getString("showMenuText"));
- }
-}
Deleted: trunk/src/main/java/org/chorem/jtimer/ui/systray/NoSystray.java
===================================================================
--- trunk/src/main/java/org/chorem/jtimer/ui/systray/NoSystray.java 2009-09-07 15:29:18 UTC (rev 2655)
+++ trunk/src/main/java/org/chorem/jtimer/ui/systray/NoSystray.java 2009-09-09 08:32:30 UTC (rev 2656)
@@ -1,57 +0,0 @@
-/* *##%
- * Copyright (C) 2008, 2009 Code Lutin
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *##%*/
-
-package org.chorem.jtimer.ui.systray;
-
-import java.awt.event.WindowEvent;
-
-import org.chorem.jtimer.JTimer;
-
-/**
- * Systray implementation, for non available systray.
- *
- * @author chatellier
- * @version $Revision$
- *
- * Last update : $Date$
- * By : $Author$
- */
-public class NoSystray extends SystrayManager {
-
- /**
- * Constructor.
- *
- * Protected to be called only by factory.
- *
- * @param parent parent
- */
- protected NoSystray(JTimer parent) {
- super(parent);
- }
-
- /*
- * @see java.awt.event.WindowListener#windowClosing(java.awt.event.WindowEvent)
- */
- @Override
- public void windowClosing(WindowEvent e) {
-
- // just exit here
- parent.exit(e);
-
- }
-}
Modified: trunk/src/main/java/org/chorem/jtimer/ui/systray/SystrayManager.java
===================================================================
--- trunk/src/main/java/org/chorem/jtimer/ui/systray/SystrayManager.java 2009-09-07 15:29:18 UTC (rev 2655)
+++ trunk/src/main/java/org/chorem/jtimer/ui/systray/SystrayManager.java 2009-09-09 08:32:30 UTC (rev 2656)
@@ -18,20 +18,35 @@
package org.chorem.jtimer.ui.systray;
+import java.awt.AWTException;
+import java.awt.EventQueue;
+import java.awt.Image;
import java.awt.SystemTray;
+import java.awt.TrayIcon;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
import java.util.Collection;
import java.util.Date;
import java.util.List;
-import java.util.Timer;
+import javax.swing.JMenuItem;
+import javax.swing.JPopupMenu;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.jtimer.JTimer;
import org.chorem.jtimer.data.DataEventListener;
import org.chorem.jtimer.entities.TimerProject;
import org.chorem.jtimer.entities.TimerTask;
+import org.jdesktop.application.ApplicationContext;
+import org.jdesktop.application.ResourceManager;
+import org.jdesktop.application.ResourceMap;
/**
* Factory to get correct working systray implementation.
@@ -42,56 +57,91 @@
* Last update : $Date$
* By : $Author$
*/
-public abstract class SystrayManager implements DataEventListener,
- WindowListener {
+public class SystrayManager implements ActionListener, DataEventListener,
+ MouseListener, Runnable, WindowListener {
- /** Log */
+ /** Log. */
private static Log log = LogFactory.getLog(SystrayManager.class);
-
- /** Parent reference */
+
+ /** Parent reference. */
protected JTimer parent;
+ /** I18n resources map. */
+ protected ResourceMap resourceMap;
+
+ /** Idle image. */
+ protected Image idleImage;
+
+ /** Running image. */
+ protected Image runningImage;
+
+ /** Idle detect image. */
+ protected Image idleDetectImage;
+
+ /** Tray icon. (null values when tray is non available) */
+ protected TrayIcon trayIcon;
+
+ /** Reference how many tasks are running. */
+ protected int nbTasksRunning = 0;
+
+ /** Popup menu instance. */
+ protected JPopupMenu popup;
+
+ /** Menu show. (used to change text) */
+ protected JMenuItem showItem;
+
/**
* Default constructor.
*
* @param parent parent
*/
- protected SystrayManager(JTimer parent) {
+ public SystrayManager(JTimer parent) {
this.parent = parent;
+
+ // init resources map
+ ApplicationContext ctxt = parent.getContext();
+ ResourceManager mgr = ctxt.getResourceManager();
+ resourceMap = mgr.getResourceMap(SystrayManager.class);
+
+ // load an image
+ // use FQN to not conflict with annotation
+ idleImage = resourceMap.getImageIcon("idleImage").getImage();
+ runningImage = resourceMap.getImageIcon("runningImage").getImage();
+ idleDetectImage = resourceMap.getImageIcon("idleDetectImage").getImage();
+
+ // make popup menu instance
+ buildPopupMenu();
}
/**
- * Get systray.
- *
- * @param parentApp parent application ref
- *
- * @return systray impl
+ * Build popup menu.
*/
- public static SystrayManager getSystray(JTimer parentApp) {
+ private void buildPopupMenu() {
- SystrayManager systray = null;
+ // create a action listener to listen for default action executed on
+ // the tray icon
+ // create a popup menu
+ popup = new JPopupMenu();
- // is awt sytray available ?
- if (SystemTray.isSupported()) {
- if (log.isDebugEnabled()) {
- log.debug("Systray is supported, use AWT systray");
- }
- systray = new AWTSystray(parentApp);
- } else {
- if (log.isDebugEnabled()) {
- log.debug("Systray is not supported, use no systray");
- }
- systray = new NoSystray(parentApp);
- }
+ // show
+ showItem = new JMenuItem(resourceMap.getString("hideMenuText"));
+ // showItem.setName("trayShowMenu"); seems don't work with awt
+ // components
+ showItem.addActionListener(this);
+ showItem.setActionCommand("showHide");
+ popup.add(showItem);
+ popup.addSeparator();
- return systray;
+ // quit
+ JMenuItem quitItem = new JMenuItem(resourceMap.getString("quitMenuText"));
+ // defaultItem.setName("quit");
+ quitItem.addActionListener(this);
+ quitItem.setActionCommand("quit");
+ popup.add(quitItem);
}
/**
- * Default install method.
- *
- * Just remove all windows listener and add this systray
- * instance, the only one.
+ * Install try icon into systray.
*/
public void install() {
@@ -101,8 +151,42 @@
}
// et la reactive de facon personnalisee
parent.getMainFrame().addWindowListener(this);
+
+ EventQueue.invokeLater(this);
}
+ /**
+ * Tray icon installation is make into a thread, put un AWT event
+ * queue.
+ *
+ * @see EventQueue#invokeLater(Runnable)
+ */
+ @Override
+ public void run() {
+ if (SystemTray.isSupported()) {
+ // get the SystemTray instance
+ SystemTray tray = SystemTray.getSystemTray();
+
+ // construct a TrayIcon
+ trayIcon = new TrayIcon(idleImage, resourceMap.getString("tooltipIdleText"), null);
+ trayIcon.setImageAutoSize(true);
+ trayIcon.addMouseListener(this);
+
+ // add listener
+ //tray.addPropertyChangeListener("trayIcons", this);
+
+ // add the tray image
+ try {
+ tray.add(trayIcon);
+ } catch (AWTException e) {
+ // exception is throw if systray is currently missing
+ if (log.isWarnEnabled()) {
+ log.warn("Error while setting system tray", e);
+ }
+ }
+ }
+ }
+
/*
* @see org.chorem.jtimer.data.event.DataEventListener#addProject(org.chorem.jtimer.entities.TimerProject)
*/
@@ -127,7 +211,6 @@
}
-
/*
* @see org.chorem.jtimer.data.DataEventListener#preDeleteProject(org.chorem.jtimer.entities.TimerProject)
*/
@@ -193,22 +276,157 @@
}
/*
- * @see org.chorem.jtimer.data.event.DataEventListener#startTask(org.chorem.jtimer.entities.TimerTask)
+ * @see org.chorem.jtimer.ui.systray.SystrayManager#startTask(org.chorem.jtimer.entities.TimerTask)
*/
@Override
public void startTask(TimerTask task) {
-
+ startStopTask(task, true);
}
/*
- * @see org.chorem.jtimer.data.event.DataEventListener#stopTask(org.chorem.jtimer.entities.TimerTask)
+ * @see org.chorem.jtimer.ui.systray.SystrayManager#stopTask(org.chorem.jtimer.entities.TimerTask)
*/
@Override
public void stopTask(TimerTask task) {
+ startStopTask(task, false);
+ }
+ /**
+ * Common code for start or stop task.
+ *
+ * @param task task
+ * @param start start(true) or stop(false) task
+ */
+ protected void startStopTask(TimerTask task, boolean start) {
+ // increment or decrement task
+ if (start) {
+ ++nbTasksRunning;
+ } else {
+ --nbTasksRunning;
+ }
+
+ // display message
+ String message = null;
+ if (nbTasksRunning == 0) {
+ message = resourceMap.getString("tooltipIdleText");
+
+ trayIcon.setImage(idleImage);
+ } else {
+ trayIcon.setImage(runningImage);
+ if (nbTasksRunning == 1) {
+ message = resourceMap.getString("tooltipRunningTaskText", nbTasksRunning);
+ } else {
+ message = resourceMap.getString("tooltipRunningTasksText", nbTasksRunning);
+ }
+ }
+ trayIcon.setToolTip(message);
+
}
+ /**
+ * Called by main application UI on idle detect.
+ */
+ public void preIdleDetect() {
+
+ if (log.isDebugEnabled()) {
+ log.debug("Pre idle detect");
+ }
+
+ // tray available only if trayIcon != null
+ if (trayIcon != null) {
+ trayIcon.setImage(idleDetectImage);
+ }
+ }
+
+ /**
+ * Called by main application UI after idle detect.
+ */
+ public void postIdleDetect() {
+
+ if (log.isDebugEnabled()) {
+ log.debug("Post idle detect");
+ }
+
+ // tray available only if trayIcon != null
+ if (trayIcon != null) {
+ if (nbTasksRunning == 0) {
+ trayIcon.setImage(idleImage);
+ } else {
+ trayIcon.setImage(runningImage);
+ }
+ }
+ }
+
/*
+ * @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
+ *
+ public void propertyChange(PropertyChangeEvent evt) {
+
+ // get event name
+ String event = evt.getPropertyName();
+
+ if (log.isDebugEnabled()) {
+ log.debug("Property change on system tray : " + event);
+ }
+
+ if (evt.getNewValue() == null) {
+ if (log.isDebugEnabled()) {
+ log.debug("Disable tray icon");
+ }
+ trayIcon = null;
+ }
+ else {
+ SystemTray tray = (SystemTray)evt.getSource();
+
+ boolean alreadyInTray = false;
+ TrayIcon[] installedIcons = tray.getTrayIcons();
+ for (TrayIcon installedIcon : installedIcons) {
+ if (installedIcon.equals(trayIcon)) {
+ alreadyInTray = true;
+ }
+ }
+
+ if (alreadyInTray) {
+ if (log.isDebugEnabled()) {
+ log.debug("Tray icon already installed");
+ }
+ }
+ else {
+ if (log.isDebugEnabled()) {
+ log.debug("Install tray icons");
+ }
+ EventQueue.invokeLater(this);
+ }
+ }
+ }/
+
+ /*
+ * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
+ */
+ public void actionPerformed(ActionEvent e) {
+
+ // This is only popop menu action here
+
+ String actionCommand = e.getActionCommand();
+
+ if ("showHide".equals(actionCommand)) {
+ if (parent.getMainFrame().isVisible()) {
+ // on la cache
+ parent.hide();
+ showItem.setText(resourceMap.getString("showMenuText"));
+ } else {
+ // sinon on la montre
+ parent.show();
+ showItem.setText(resourceMap.getString("hideMenuText"));
+ }
+ }
+
+ if ("quit".equals(actionCommand)) {
+ parent.quit(e);
+ }
+ }
+
+ /*
* @see org.chorem.jtimer.event.DataEventListener#setAnnotation(org.chorem.jtimer.entities.TimerTask, java.util.Date, java.lang.String)
*/
@Override
@@ -252,49 +470,114 @@
* @see org.chorem.jtimer.data.DataEventListener#preMergeTasks(org.chorem.jtimer.entities.TimerTask, java.util.List)
*/
@Override
- public void preMergeTasks(TimerTask destinationTask, List<TimerTask> otherTasks) {
+ public void preMergeTasks(TimerTask destinationTask,
+ List<TimerTask> otherTasks) {
}
- /**
- * Notify idle dtect ended.
+ /*
+ * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
*/
- public void postIdleDetect() {
+ @Override
+ public void mouseClicked(MouseEvent e) {
+ // ne fait pas de double affichage si plus de clics
+ // et ne change pas l'affichage si clic droit
+ if (e.getClickCount() == 1 && e.getButton() == MouseEvent.BUTTON1) {
+
+ // si la fenetre est affichee
+ if (parent.getMainFrame().isVisible()) {
+ showItem.setText(resourceMap.getString("showMenuText"));
+
+ // on la cache
+ parent.hide();
+
+ } else {
+
+ showItem.setText(resourceMap.getString("hideMenuText"));
+
+ // sinon on la montre
+ // correct iconified bug
+ // http://www.java-forums.org/awt-swing/7000-problem-setvisible-linux.html
+ //parent.getMainFrame().setExtendedState(JFrame.NORMAL);
+ parent.show();
+
+ }
+ }
}
- /**
- * Notify idle detect.
+ /*
+ * @see java.awt.event.MouseListener#mouseEntered(java.awt.event.MouseEvent)
*/
- public void preIdleDetect() {
-
+ @Override
+ public void mouseEntered(MouseEvent e) {
+
}
-
+
/*
- * @see java.awt.event.WindowListener#windowActivated(java.awt.event.WindowEvent)
+ * @see java.awt.event.MouseListener#mouseExited(java.awt.event.MouseEvent)
*/
@Override
- public void windowActivated(WindowEvent e) {
+ public void mouseExited(MouseEvent e) {
}
/*
- * @see java.awt.event.WindowListener#windowClosed(java.awt.event.WindowEvent)
+ * @see java.awt.event.MouseListener#mousePressed(java.awt.event.MouseEvent)
*/
@Override
- public void windowClosed(WindowEvent e) {
+ public void mousePressed(MouseEvent e) {
}
/*
+ * @see java.awt.event.MouseListener#mouseReleased(java.awt.event.MouseEvent)
+ */
+ @Override
+ public void mouseReleased(MouseEvent e) {
+
+ // use sun workarround http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6285881
+ if (e.getClickCount() == 1 && e.getButton() == MouseEvent.BUTTON3) {
+ popup.setLocation(e.getX(), e.getY());
+ popup.setInvoker(popup);
+ popup.setVisible(true);
+ }
+ }
+
+ /*
* @see java.awt.event.WindowListener#windowClosing(java.awt.event.WindowEvent)
*/
@Override
public void windowClosing(WindowEvent e) {
+ // tray available only if trayIcon != null
+ if (trayIcon != null) {
+ // hide window (without exiting)
+ parent.hide();
+ showItem.setText(resourceMap.getString("showMenuText"));
+ } else {
+ // just exit here
+ parent.exit(e);
+ }
}
/*
+ * @see java.awt.event.WindowListener#windowActivated(java.awt.event.WindowEvent)
+ */
+ @Override
+ public void windowActivated(WindowEvent e) {
+
+ }
+
+ /*
+ * @see java.awt.event.WindowListener#windowClosed(java.awt.event.WindowEvent)
+ */
+ @Override
+ public void windowClosed(WindowEvent e) {
+
+ }
+
+ /*
* @see java.awt.event.WindowListener#windowDeactivated(java.awt.event.WindowEvent)
*/
@Override
@@ -325,5 +608,4 @@
public void windowOpened(WindowEvent e) {
}
-
-}
+}
\ No newline at end of file
Modified: trunk/src/main/java/org/chorem/jtimer/ui/systray/package-info.java
===================================================================
--- trunk/src/main/java/org/chorem/jtimer/ui/systray/package-info.java 2009-09-07 15:29:18 UTC (rev 2655)
+++ trunk/src/main/java/org/chorem/jtimer/ui/systray/package-info.java 2009-09-09 08:32:30 UTC (rev 2656)
@@ -1,4 +1,4 @@
/**
- * Systray implementations.
+ * System tray implementations.
*/
package org.chorem.jtimer.ui.systray;
Deleted: trunk/src/main/resources/org/chorem/jtimer/ui/systray/resources/AWTSystray.properties
===================================================================
--- trunk/src/main/resources/org/chorem/jtimer/ui/systray/resources/AWTSystray.properties 2009-09-07 15:29:18 UTC (rev 2655)
+++ trunk/src/main/resources/org/chorem/jtimer/ui/systray/resources/AWTSystray.properties 2009-09-09 08:32:30 UTC (rev 2656)
@@ -1,12 +0,0 @@
-#�tray icon
-idleImage = jtimer-40-orange.png
-runningImage = jtimer-40-green.png
-idleDetectImage = jtimer-40-grey.png
-
-# tray i18n
-tooltipIdleText = ${Application.title}
-tooltipRunningTaskText = ${Application.title} - %d task running
-tooltipRunningTasksText = ${Application.title} - %d tasks running
-showMenuText = Show
-hideMenuText = Hide
-quitMenuText = Quit
\ No newline at end of file
Deleted: trunk/src/main/resources/org/chorem/jtimer/ui/systray/resources/AWTSystray_fr.properties
===================================================================
--- trunk/src/main/resources/org/chorem/jtimer/ui/systray/resources/AWTSystray_fr.properties 2009-09-07 15:29:18 UTC (rev 2655)
+++ trunk/src/main/resources/org/chorem/jtimer/ui/systray/resources/AWTSystray_fr.properties 2009-09-09 08:32:30 UTC (rev 2656)
@@ -1,7 +0,0 @@
-# tray i18n
-tooltipIdleText = ${Application.title}
-tooltipRunningTaskText = ${Application.title} - %d t\u00E2che en cours
-tooltipRunningTasksText = ${Application.title} - %d t\u00E2ches en cours
-showMenuText = Montrer
-hideMenuText = Cacher
-quitMenuText = Quitter
\ No newline at end of file
Copied: trunk/src/main/resources/org/chorem/jtimer/ui/systray/resources/SystrayManager.properties (from rev 2643, trunk/src/main/resources/org/chorem/jtimer/ui/systray/resources/AWTSystray.properties)
===================================================================
--- trunk/src/main/resources/org/chorem/jtimer/ui/systray/resources/SystrayManager.properties (rev 0)
+++ trunk/src/main/resources/org/chorem/jtimer/ui/systray/resources/SystrayManager.properties 2009-09-09 08:32:30 UTC (rev 2656)
@@ -0,0 +1,12 @@
+#�tray icon
+idleImage = jtimer-40-orange.png
+runningImage = jtimer-40-green.png
+idleDetectImage = jtimer-40-grey.png
+
+# tray i18n
+tooltipIdleText = ${Application.title}
+tooltipRunningTaskText = ${Application.title} - %d task running
+tooltipRunningTasksText = ${Application.title} - %d tasks running
+showMenuText = Show
+hideMenuText = Hide
+quitMenuText = Quit
\ No newline at end of file
Copied: trunk/src/main/resources/org/chorem/jtimer/ui/systray/resources/SystrayManager_fr.properties (from rev 2643, trunk/src/main/resources/org/chorem/jtimer/ui/systray/resources/AWTSystray_fr.properties)
===================================================================
--- trunk/src/main/resources/org/chorem/jtimer/ui/systray/resources/SystrayManager_fr.properties (rev 0)
+++ trunk/src/main/resources/org/chorem/jtimer/ui/systray/resources/SystrayManager_fr.properties 2009-09-09 08:32:30 UTC (rev 2656)
@@ -0,0 +1,7 @@
+# tray i18n
+tooltipIdleText = ${Application.title}
+tooltipRunningTaskText = ${Application.title} - %d t\u00E2che en cours
+tooltipRunningTasksText = ${Application.title} - %d t\u00E2ches en cours
+showMenuText = Montrer
+hideMenuText = Cacher
+quitMenuText = Quitter
\ No newline at end of file
1
0
Author: echatellier
Date: 2009-09-07 17:29:18 +0200 (Mon, 07 Sep 2009)
New Revision: 2655
Modified:
trunk/src/main/resources/log4j.properties
Log:
Ajout d'un appender rolling pour log4j
Modified: trunk/src/main/resources/log4j.properties
===================================================================
--- trunk/src/main/resources/log4j.properties 2009-08-28 15:11:54 UTC (rev 2654)
+++ trunk/src/main/resources/log4j.properties 2009-09-07 15:29:18 UTC (rev 2655)
@@ -14,6 +14,16 @@
#log4j.appender.fileout.layout=org.apache.log4j.PatternLayout
#log4j.appender.fileout.layout.ConversionPattern=%5p (%F:%L) %m%n
+# Rolling appender
+#log4j.appender.rolling=org.apache.log4j.RollingFileAppender
+#log4j.appender.rolling.File=jtimer.log
+#log4j.appender.rolling.MaxFileSize=100KB
+#log4j.appender.rolling.Append=true
+#log4j.appender.rolling.MaxBackupIndex=30
+#log4j.appender.rolling.Threshold=INFO
+#log4j.appender.rolling.layout=org.apache.log4j.PatternLayout
+#log4j.appender.rolling.layout.ConversionPattern=%d{yyyy/MM/dd hh:mm:ss} %5p (%F:%L) %m%n
+
# package level
#log4j.logger.org.chorem.jtimer=DEBUG
#log4j.logger.org.chorem.jtimer.ws=DEBUG
1
0