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
March 2012
- 2 participants
- 47 discussions
r2812 - in trunk/src: main/java/org/chorem/jtimer/ui main/java/org/chorem/jtimer/ui/tasks test/java/org/chorem/jtimer/io
by echatellier@users.chorem.org 07 Mar '12
by echatellier@users.chorem.org 07 Mar '12
07 Mar '12
Author: echatellier
Date: 2012-03-07 18:24:20 +0100 (Wed, 07 Mar 2012)
New Revision: 2812
Url: http://chorem.org/repositories/revision/jtimer/2812
Log:
Fix import/unused code
Modified:
trunk/src/main/java/org/chorem/jtimer/ui/HelpFrame.java
trunk/src/main/java/org/chorem/jtimer/ui/tasks/RunTaskJob.java
trunk/src/test/java/org/chorem/jtimer/io/GTimerIncrementalSaverTest.java
Modified: trunk/src/main/java/org/chorem/jtimer/ui/HelpFrame.java
===================================================================
--- trunk/src/main/java/org/chorem/jtimer/ui/HelpFrame.java 2012-03-07 17:21:15 UTC (rev 2811)
+++ trunk/src/main/java/org/chorem/jtimer/ui/HelpFrame.java 2012-03-07 17:24:20 UTC (rev 2812)
@@ -5,7 +5,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2008 - 2011 CodeLutin, Chatellier Eric
+ * Copyright (C) 2008 - 2012 CodeLutin, Chatellier Eric
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -62,9 +62,6 @@
*/
public class HelpFrame extends FrameView implements HyperlinkListener {
- /** serialVersionUID */
- private static final long serialVersionUID = -8693584537185015506L;
-
/** log */
private static Log log = LogFactory.getLog(HelpFrame.class);
Modified: trunk/src/main/java/org/chorem/jtimer/ui/tasks/RunTaskJob.java
===================================================================
--- trunk/src/main/java/org/chorem/jtimer/ui/tasks/RunTaskJob.java 2012-03-07 17:21:15 UTC (rev 2811)
+++ trunk/src/main/java/org/chorem/jtimer/ui/tasks/RunTaskJob.java 2012-03-07 17:24:20 UTC (rev 2812)
@@ -38,7 +38,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.jtimer.JTimer;
-import org.chorem.jtimer.JTimerFactory;
import org.chorem.jtimer.data.TimerDataManager;
import org.chorem.jtimer.entities.TimerAlert;
import org.chorem.jtimer.entities.TimerTask;
Modified: trunk/src/test/java/org/chorem/jtimer/io/GTimerIncrementalSaverTest.java
===================================================================
--- trunk/src/test/java/org/chorem/jtimer/io/GTimerIncrementalSaverTest.java 2012-03-07 17:21:15 UTC (rev 2811)
+++ trunk/src/test/java/org/chorem/jtimer/io/GTimerIncrementalSaverTest.java 2012-03-07 17:24:20 UTC (rev 2812)
@@ -5,7 +5,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2008 - 2011 CodeLutin, Chatellier Eric
+ * Copyright (C) 2008 - 2012 CodeLutin, Chatellier Eric
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -35,8 +35,6 @@
import java.util.SortedMap;
import java.util.TreeMap;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.chorem.jtimer.AbstractJTimerTest;
import org.chorem.jtimer.entities.TimerAlert;
import org.chorem.jtimer.entities.TimerProject;
@@ -56,9 +54,6 @@
*/
public class GTimerIncrementalSaverTest extends AbstractJTimerTest {
- /** Class log */
- private static Log log = LogFactory.getLog(GTimerIncrementalSaverTest.class);
-
/**
* Test que saveDirectory a une valeur attendue.
*/
1
0
r2811 - in trunk/src/main/java/org/chorem/jtimer: . ui/tasks
by echatellier@users.chorem.org 07 Mar '12
by echatellier@users.chorem.org 07 Mar '12
07 Mar '12
Author: echatellier
Date: 2012-03-07 18:21:15 +0100 (Wed, 07 Mar 2012)
New Revision: 2811
Url: http://chorem.org/repositories/revision/jtimer/2811
Log:
Fix seconds/ms convertion
Modified:
trunk/src/main/java/org/chorem/jtimer/JTimerConfig.java
trunk/src/main/java/org/chorem/jtimer/ui/tasks/IdleDialog.java
trunk/src/main/java/org/chorem/jtimer/ui/tasks/RunTaskJob.java
Modified: trunk/src/main/java/org/chorem/jtimer/JTimerConfig.java
===================================================================
--- trunk/src/main/java/org/chorem/jtimer/JTimerConfig.java 2012-03-07 17:11:12 UTC (rev 2810)
+++ trunk/src/main/java/org/chorem/jtimer/JTimerConfig.java 2012-03-07 17:21:15 UTC (rev 2811)
@@ -1,25 +1,23 @@
/*
* #%L
- *
- *
* $Id$
* $HeadURL$
* %%
* Copyright (C) 2012 Codelutin, Chatellier Eric
* %%
* This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
+ * it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 3 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 Lesser Public License for more details.
+ * GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Lesser Public
+ * You should have received a copy of the GNU General Public
* License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
* #L%
*/
@@ -91,11 +89,21 @@
public String getIOSaverDirectory() {
return appConfig.getOption(JTimerOption.IO_SAVER_DIRECTORY.key);
}
-
+
+ /**
+ * Return auto save delay in seconds.
+ *
+ * @return auto save delay
+ */
public long getIOSaverAutoSaveDelay() {
return appConfig.getOptionAsLong(JTimerOption.IO_SAVER_AUTOSAVEDELAY.key);
}
+ /**
+ * Return user idle time threshold in seconds.
+ *
+ * @return idle time threshold
+ */
public long getIdleTime() {
return appConfig.getOptionAsLong(JTimerOption.UI_IDLE_TIME.key);
}
Modified: trunk/src/main/java/org/chorem/jtimer/ui/tasks/IdleDialog.java
===================================================================
--- trunk/src/main/java/org/chorem/jtimer/ui/tasks/IdleDialog.java 2012-03-07 17:11:12 UTC (rev 2810)
+++ trunk/src/main/java/org/chorem/jtimer/ui/tasks/IdleDialog.java 2012-03-07 17:21:15 UTC (rev 2811)
@@ -160,7 +160,7 @@
// label
JLabel idleLabel = new JLabel(resourceMap.getString("idleMessage", Long
- .valueOf(JTimer.config.getIdleTime() / (60 * 1000))));
+ .valueOf(JTimer.config.getIdleTime() / (60))));
mainComponent.add(idleLabel, new GridBagConstraints(1, 0, 3, 1, 1, 0,
GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
new Insets(5, 0, 0, 3), 0, 0));
Modified: trunk/src/main/java/org/chorem/jtimer/ui/tasks/RunTaskJob.java
===================================================================
--- trunk/src/main/java/org/chorem/jtimer/ui/tasks/RunTaskJob.java 2012-03-07 17:11:12 UTC (rev 2810)
+++ trunk/src/main/java/org/chorem/jtimer/ui/tasks/RunTaskJob.java 2012-03-07 17:21:15 UTC (rev 2811)
@@ -247,7 +247,7 @@
resetTiming();
// get idle time
- long configIdleTime = JTimer.config.getIdleTime();
+ long configIdleTime = JTimer.config.getIdleTime() * 1000;
boolean dontWantToStop = true;
while (dontWantToStop) {
@@ -279,7 +279,7 @@
checkReset();
// if long idleTime is unavailable, if is always false
- if (idleTime >= JTimer.config.getIdleTime()) {
+ if (idleTime >= configIdleTime) {
// to not display negative time near midnight
long idleTimeOffset = Math.min(idleTime, currentTime - taskStartCalendar.getTimeInMillis());
1
0
Author: echatellier
Date: 2012-03-07 18:11:12 +0100 (Wed, 07 Mar 2012)
New Revision: 2810
Url: http://chorem.org/repositories/revision/jtimer/2810
Log:
Fix config file migration (from user home, not /etc)
Modified:
trunk/src/main/java/org/chorem/jtimer/JTimer.java
Modified: trunk/src/main/java/org/chorem/jtimer/JTimer.java
===================================================================
--- trunk/src/main/java/org/chorem/jtimer/JTimer.java 2012-03-07 16:49:27 UTC (rev 2809)
+++ trunk/src/main/java/org/chorem/jtimer/JTimer.java 2012-03-07 17:11:12 UTC (rev 2810)
@@ -206,7 +206,7 @@
// add file migration for configuration file created before version 1.4
File homeDir = new File(System.getProperty("user.home"), ".jtimer");
File oldFile = new File(homeDir, "JTimer.properties");
- File newFile = new File(config.appConfig.getConfigPath(), config.appConfig.getConfigFileName());
+ File newFile = new File(config.appConfig.getUserConfigDirectory(), config.appConfig.getConfigFileName());
if (oldFile.isFile() && !newFile.isFile()) {
if (log.isInfoEnabled()) {
log.info("Migration configuration file location");
1
0
r2809 - in trunk/src: main/java/org/chorem/jtimer test/java/org/chorem/jtimer
by echatellier@users.chorem.org 07 Mar '12
by echatellier@users.chorem.org 07 Mar '12
07 Mar '12
Author: echatellier
Date: 2012-03-07 17:49:27 +0100 (Wed, 07 Mar 2012)
New Revision: 2809
Url: http://chorem.org/repositories/revision/jtimer/2809
Log:
Fix configuration test
Modified:
trunk/src/main/java/org/chorem/jtimer/JTimerConfig.java
trunk/src/test/java/org/chorem/jtimer/JTimerFactoryTest.java
Modified: trunk/src/main/java/org/chorem/jtimer/JTimerConfig.java
===================================================================
--- trunk/src/main/java/org/chorem/jtimer/JTimerConfig.java 2012-03-07 16:46:58 UTC (rev 2808)
+++ trunk/src/main/java/org/chorem/jtimer/JTimerConfig.java 2012-03-07 16:49:27 UTC (rev 2809)
@@ -67,7 +67,7 @@
public Class getServiceClass() {
Class serviceClass = null;
try {
- appConfig.getOptionAsClass(JTimerOption.SERVICE_CLASS.key);
+ serviceClass = appConfig.getOptionAsClass(JTimerOption.SERVICE_CLASS.key);
} catch (Exception ex) {
if (log.isWarnEnabled()) {
log.warn("Can't find service class implementation, sync will not work", ex);
Modified: trunk/src/test/java/org/chorem/jtimer/JTimerFactoryTest.java
===================================================================
--- trunk/src/test/java/org/chorem/jtimer/JTimerFactoryTest.java 2012-03-07 16:46:58 UTC (rev 2808)
+++ trunk/src/test/java/org/chorem/jtimer/JTimerFactoryTest.java 2012-03-07 16:49:27 UTC (rev 2809)
@@ -27,7 +27,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.chorem.jtimer.JTimerConfig.JTimerOption;
import org.chorem.jtimer.io.GTimerIncrementalSaver;
import org.chorem.jtimer.io.Saver;
import org.chorem.jtimer.ws.ProjectManagement;
1
0
Author: echatellier
Date: 2012-03-07 17:46:58 +0100 (Wed, 07 Mar 2012)
New Revision: 2808
Url: http://chorem.org/repositories/revision/jtimer/2808
Log:
#250: Udpate to testng 6.4
#482: Update to freemarker 2.3.19
Modified:
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2012-03-07 16:41:22 UTC (rev 2807)
+++ trunk/pom.xml 2012-03-07 16:46:58 UTC (rev 2808)
@@ -257,7 +257,7 @@
<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
- <version>2.3.18</version>
+ <version>2.3.19</version>
</dependency>
<dependency>
<groupId>org.apache.xmlrpc</groupId>
@@ -307,7 +307,7 @@
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
- <version>6.3.1</version>
+ <version>6.4</version>
<scope>test</scope>
<exclusions>
<exclusion>
1
0
Author: echatellier
Date: 2012-03-07 17:41:22 +0100 (Wed, 07 Mar 2012)
New Revision: 2807
Url: http://chorem.org/repositories/revision/jtimer/2807
Log:
Modify svn:ignore
Modified:
trunk/
Property changes on: trunk
___________________________________________________________________
Modified: svn:ignore
- target
.settings
.project
.classpath
JTimer.properties
THIRD-PARTY.txt
*testng*.xml
*.ipr
*.iws
*.iml
+ target
.settings
.project
.classpath
*.properties
*testng*.xml
*.ipr
*.iws
*.iml
Deleted: svn:mergeinfo
- /branches/1.3.x:2624-2628
1
0
07 Mar '12
Author: echatellier
Date: 2012-03-07 17:38:55 +0100 (Wed, 07 Mar 2012)
New Revision: 2806
Url: http://chorem.org/repositories/revision/jtimer/2806
Log:
#478: Update to commons-lang 3.1
#481: Migration configuration to NuitonUtils's ApplicationConfig
Added:
trunk/src/main/java/org/chorem/jtimer/JTimerConfig.java
trunk/src/test/resources/jtimertest.properties
Removed:
trunk/src/main/resources/JTimer.properties
trunk/src/main/resources/JTimer_default.properties
trunk/src/test/resources/JTimerTestRelatif.properties
Modified:
trunk/pom.xml
trunk/src/main/java/org/chorem/jtimer/JTimer.java
trunk/src/main/java/org/chorem/jtimer/JTimerFactory.java
trunk/src/main/java/org/chorem/jtimer/entities/TimerTask.java
trunk/src/main/java/org/chorem/jtimer/io/GTimerIncrementalSaver.java
trunk/src/main/java/org/chorem/jtimer/io/Saver.java
trunk/src/main/java/org/chorem/jtimer/package-info.java
trunk/src/main/java/org/chorem/jtimer/ui/StatusBar.java
trunk/src/main/java/org/chorem/jtimer/ui/report/ReportUtils.java
trunk/src/main/java/org/chorem/jtimer/ui/tasks/IdleDialog.java
trunk/src/main/java/org/chorem/jtimer/ui/tasks/RunTaskJob.java
trunk/src/main/java/org/chorem/jtimer/ui/treetable/ProjectsAndTasksModel.java
trunk/src/main/java/org/chorem/jtimer/ui/treetable/dnd/TimerTaskTransferHandler.java
trunk/src/main/resources/log4j.properties
trunk/src/test/java/org/chorem/jtimer/AbstractJTimerTest.java
trunk/src/test/java/org/chorem/jtimer/JTimerFactoryTest.java
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2012-02-16 14:27:52 UTC (rev 2805)
+++ trunk/pom.xml 2012-03-07 16:38:55 UTC (rev 2806)
@@ -10,7 +10,7 @@
<groupId>org.chorem</groupId>
<artifactId>jtimer</artifactId>
- <version>1.3.4-SNAPSHOT</version>
+ <version>1.4.0-SNAPSHOT</version>
<name>jTimer</name>
<description>
@@ -172,7 +172,7 @@
<plugins>
<plugin>
<artifactId>maven-checkstyle-plugin</artifactId>
- <version>2.8</version>
+ <version>2.9.1</version>
<configuration>
<configLocation>${maven.src.dir}/main/config/checkstyle.xml
</configLocation>
@@ -206,6 +206,26 @@
<dependencies>
<dependency>
+ <groupId>org.nuiton</groupId>
+ <artifactId>nuiton-utils</artifactId>
+ <version>2.4.4</version>
+ <scope>compile</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>commons-primitives</groupId>
+ <artifactId>commons-primitives</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>commons-jxpath</groupId>
+ <artifactId>commons-jxpath</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.nuiton.i18n</groupId>
+ <artifactId>nuiton-i18n</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
<groupId>org.jdesktop.bsaf</groupId>
<artifactId>bsaf</artifactId>
<version>1.9.2</version>
@@ -265,8 +285,8 @@
<artifactId>commons-collections</artifactId>
</dependency>
<dependency>
- <groupId>commons-lang</groupId>
- <artifactId>commons-lang</artifactId>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-lang3</artifactId>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
Modified: trunk/src/main/java/org/chorem/jtimer/JTimer.java
===================================================================
--- trunk/src/main/java/org/chorem/jtimer/JTimer.java 2012-02-16 14:27:52 UTC (rev 2805)
+++ trunk/src/main/java/org/chorem/jtimer/JTimer.java 2012-03-07 16:38:55 UTC (rev 2806)
@@ -5,7 +5,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2007 - 2011 CodeLutin, Chatellier Eric
+ * Copyright (C) 2007 - 2012 CodeLutin, Chatellier Eric
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -31,6 +31,8 @@
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
+import java.io.File;
+import java.io.IOException;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
@@ -55,7 +57,8 @@
import javax.swing.event.TreeSelectionListener;
import javax.swing.tree.TreePath;
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.jtimer.data.DataViolationException;
@@ -76,6 +79,7 @@
import org.chorem.jtimer.ws.ConnectionDataHandler;
import org.chorem.jtimer.ws.ProjectManagement;
import org.jdesktop.application.Action;
+import org.jdesktop.application.Application;
import org.jdesktop.application.ApplicationContext;
import org.jdesktop.application.ResourceMap;
import org.jdesktop.application.SingleFrameApplication;
@@ -111,6 +115,9 @@
/** I18n resources map. */
protected ResourceMap resourceMap;
+ /** Jtimer application config. */
+ public static JTimerConfig config;
+
/** Single project selection property. */
protected boolean selectedSingleProject;
@@ -161,6 +168,9 @@
// super, but does nothing
super.initialize(args);
+ // load configuration
+ loadConfiguration(args);
+
// init resources map
ApplicationContext ctxt = getContext();
resourceMap = ctxt.getResourceMap();
@@ -185,6 +195,36 @@
}
/**
+ * Load configuration.
+ *
+ * @param args args to parse command line options
+ */
+ protected void loadConfiguration(String[] args) {
+
+ config = new JTimerConfig();
+
+ // add file migration for configuration file created before version 1.4
+ File homeDir = new File(System.getProperty("user.home"), ".jtimer");
+ File oldFile = new File(homeDir, "JTimer.properties");
+ File newFile = new File(config.appConfig.getConfigPath(), config.appConfig.getConfigFileName());
+ if (oldFile.isFile() && !newFile.isFile()) {
+ if (log.isInfoEnabled()) {
+ log.info("Migration configuration file location");
+ }
+ try {
+ FileUtils.copyFile(oldFile, newFile);
+ } catch (IOException ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't copy config file to new location", ex);
+ }
+ }
+ }
+
+ // parse after file migration
+ config.parse(args);
+ }
+
+ /**
* startup.
*
* Create frame menu bar. Create main component.
Added: trunk/src/main/java/org/chorem/jtimer/JTimerConfig.java
===================================================================
--- trunk/src/main/java/org/chorem/jtimer/JTimerConfig.java (rev 0)
+++ trunk/src/main/java/org/chorem/jtimer/JTimerConfig.java 2012-03-07 16:38:55 UTC (rev 2806)
@@ -0,0 +1,122 @@
+/*
+ * #%L
+ *
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 Codelutin, Chatellier Eric
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 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 Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+
+package org.chorem.jtimer;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.util.ApplicationConfig;
+import org.nuiton.util.ArgumentsParserException;
+
+/**
+ * JTimer configuration.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class JTimerConfig {
+
+ private static Log log = LogFactory.getLog(JTimerConfig.class);
+
+ protected ApplicationConfig appConfig;
+
+ public JTimerConfig() {
+ appConfig = new ApplicationConfig();
+ for (JTimerOption o : JTimerOption.values()) {
+ if (o.defaultValue != null) {
+ appConfig.setDefaultOption(o.key, o.defaultValue);
+ }
+ }
+ }
+
+ public void parse(String... args) {
+ try {
+ appConfig.parse(args);
+ } catch (ArgumentsParserException ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't parse configuration", ex);
+ }
+ }
+ }
+
+ public Class getServiceClass() {
+ Class serviceClass = null;
+ try {
+ appConfig.getOptionAsClass(JTimerOption.SERVICE_CLASS.key);
+ } catch (Exception ex) {
+ if (log.isWarnEnabled()) {
+ log.warn("Can't find service class implementation, sync will not work", ex);
+ }
+ }
+ return serviceClass;
+ }
+
+ public String getServiceEndpoint() {
+ return appConfig.getOption(JTimerOption.SERVICE_ENDPOINT.key);
+ }
+
+ public String getServiceResource() {
+ return appConfig.getOption(JTimerOption.SERVICE_RESOURCE.key);
+ }
+
+ public Class getIOSaverClass() {
+ return appConfig.getOptionAsClass(JTimerOption.IO_SAVER_CLASS.key);
+ }
+
+ public String getIOSaverDirectory() {
+ return appConfig.getOption(JTimerOption.IO_SAVER_DIRECTORY.key);
+ }
+
+ public long getIOSaverAutoSaveDelay() {
+ return appConfig.getOptionAsLong(JTimerOption.IO_SAVER_AUTOSAVEDELAY.key);
+ }
+
+ public long getIdleTime() {
+ return appConfig.getOptionAsLong(JTimerOption.UI_IDLE_TIME.key);
+ }
+
+ public enum JTimerOption {
+ CONFIG_FILENAME(ApplicationConfig.CONFIG_FILE_NAME, "jtimer.properties"),
+ SERVICE_CLASS("jtimer.service.class", null),
+ SERVICE_ENDPOINT("jtimer.service.endpoint", null),
+ SERVICE_RESOURCE("jtimer.service.resource", "JTimer"),
+ IO_SAVER_CLASS("jtimer.io.saver.class", "org.chorem.jtimer.io.GTimerIncrementalSaver"),
+ IO_SAVER_DIRECTORY("jtimer.io.saver.directory", "${user.home}/.gtimer"),
+ IO_SAVER_AUTOSAVEDELAY("jtimer.io.saver.autosavedelay", "300"),
+ UI_IDLE_TIME("jtimer.ui.idletime", "300");
+
+ protected String key;
+
+ protected String defaultValue;
+
+ private JTimerOption(String key, String defaultValue) {
+ this.key = key;
+ this.defaultValue = defaultValue;
+ }
+ }
+}
Property changes on: trunk/src/main/java/org/chorem/jtimer/JTimerConfig.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/src/main/java/org/chorem/jtimer/JTimerFactory.java
===================================================================
--- trunk/src/main/java/org/chorem/jtimer/JTimerFactory.java 2012-02-16 14:27:52 UTC (rev 2805)
+++ trunk/src/main/java/org/chorem/jtimer/JTimerFactory.java 2012-03-07 16:38:55 UTC (rev 2806)
@@ -5,7 +5,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2007 - 2011 CodeLutin, Chatellier Eric
+ * Copyright (C) 2007 - 2012 CodeLutin, Chatellier Eric
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -25,16 +25,6 @@
package org.chorem.jtimer;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.net.URL;
-import java.util.Properties;
-
-import org.apache.commons.io.IOUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.jtimer.io.Saver;
@@ -54,15 +44,6 @@
/** Logger */
private static Log log = LogFactory.getLog(JTimerFactory.class);
- /** Default idle time in milliseconds */
- protected static final long DEFAULT_IDLE_TIME = 5 * 60 * 1000; // 5 min
-
- /** Properties */
- protected static Properties props;
-
- /** Configured idle time */
- protected static long idleTime = -1L;
-
/** ProjectManagement */
protected static ProjectManagement projectManagement;
@@ -77,138 +58,6 @@
}
/**
- * Init.
- */
- protected static void init() {
-
- // init once
- if (props == null) {
-
- // change load order here :
- // Take :
- // - classpath one
- // - user home one
- // - ./ one
-
- try {
- props = new Properties();
-
- // read configuration file
- String fileName = getConfigurationFileName();
-
- // use file in classpath
- URL url = JTimerFactory.class.getResource("/" + fileName);
- props.load(url.openStream());
-
- // and override by file in user home
- File homeUserFile = new File(getUserHomeConfigurationFilePath());
- if (homeUserFile.exists()) {
- if (log.isInfoEnabled()) {
- log.info("Use user home configuration in "
- + homeUserFile.getAbsolutePath());
- }
- props.load(new FileInputStream(homeUserFile));
- } else {
-
- // homeUserFile is $HOME/JTimer.properties
- // on linux, parent dir is created by SAF
- // on other, SAF dir is not this one, so
- // could not exists
- if (homeUserFile.getParentFile() != null
- && !homeUserFile.getParentFile().exists()) {
- homeUserFile.getParentFile().mkdirs();
- if (log.isInfoEnabled()) {
- log.info("Creating directory "
- + homeUserFile.getParentFile()
- .getAbsolutePath());
- }
- }
-
- if (log.isInfoEnabled()) {
- log.info("Creating new default configuration file in "
- + homeUserFile.getAbsolutePath());
- }
-
- URL defautFileURL = JTimerFactory.class.getResource("/"
- + getDefaultConfigurationFileName());
- copyConfigurationFile(defautFileURL, homeUserFile);
- }
-
- // read file in current directory
- File currentDirectoryFile = new File(fileName);
- if (currentDirectoryFile.canRead()) {
- props.load(new FileInputStream(currentDirectoryFile));
- }
-
- } catch (IOException e) {
- if (log.isErrorEnabled()) {
- log.error("Can't read configuration file", e);
- }
- }
- }
- }
-
- /**
- * Configuration filepath.
- *
- * @return Configuration filename
- */
- protected static String getUserHomeConfigurationFilePath() {
- // user home
- String filePath = System.getProperty("user.home");
- // + .jtimer directory
- // TODO use saf config
- filePath += File.separator + ".jtimer";
- // add filename
- filePath += File.separator + getConfigurationFileName();
-
- if (log.isDebugEnabled()) {
- log.debug("Look for configuration file in : " + filePath);
- }
-
- return filePath;
- }
-
- /**
- * Configuration filename.
- *
- * @return Configuration filename
- */
- protected static String getConfigurationFileName() {
- String fileName = JTimer.class.getSimpleName() + ".properties";
- return fileName;
- }
-
- /**
- * Default configuration filename.
- *
- * @return Configuration filename
- */
- protected static String getDefaultConfigurationFileName() {
- String fileName = JTimer.class.getSimpleName() + "_default.properties";
- return fileName;
- }
-
- /**
- * Copy copyFrom content in copyTo file.
- *
- * @param copyFrom from
- * @param copyTo to
- * @throws IOException
- */
- protected static void copyConfigurationFile(URL copyFrom, File copyTo)
- throws IOException {
-
- InputStream in = copyFrom.openStream();
- OutputStream out = new FileOutputStream(copyTo);
-
- IOUtils.copy(in, out);
-
- in.close();
- out.close();
- }
-
- /**
* Return an implementation on a distant web service.
*
* Use jtimer.service.class property to found class and
@@ -220,37 +69,26 @@
if (projectManagement == null) {
- // check that init has been done
- init();
+ Class implementationClass = JTimer.config.getServiceClass();
- // get implementation class
- String implementationClass = props
- .getProperty("jtimer.service.class");
- // get service endpoint
- String serviceEndPoint = props
- .getProperty("jtimer.service.endpoint");
- // get service resource name
- String serviceResouceName = props
- .getProperty("jtimer.service.resource");
-
// log
if (log.isInfoEnabled()) {
log.info("Using service class : " + implementationClass);
- log.info(" with service endpoint : " + serviceEndPoint);
- log.info(" with service resource : " + serviceResouceName);
+ log.info(" with service endpoint : " + JTimer.config.getServiceEndpoint());
+ log.info(" with service resource : " + JTimer.config.getServiceResource());
}
// By default jTimer won't synchronize
// so implementationClass can be null
if (implementationClass != null) {
+
try {
// get instance
- projectManagement = (ProjectManagement) Class.forName(
- implementationClass).newInstance();
+ projectManagement = (ProjectManagement)implementationClass.newInstance();
// init instance
- projectManagement.setEndpoint(serviceEndPoint);
- projectManagement.setResourceName(serviceResouceName);
+ projectManagement.setEndpoint(JTimer.config.getServiceEndpoint());
+ projectManagement.setResourceName(JTimer.config.getServiceResource());
} catch (InstantiationException e) {
if (log.isErrorEnabled()) {
log.error("Can't instanciate class : "
@@ -262,11 +100,6 @@
"Can't access class : " + implementationClass,
e);
}
- } catch (ClassNotFoundException e) {
- if (log.isErrorEnabled()) {
- log.error("Can't found class : " + implementationClass,
- e);
- }
}
} else {
if (log.isInfoEnabled()) {
@@ -286,125 +119,37 @@
public static Saver getFileSaver() {
if (saver == null) {
- // check that init has been done
- init();
- // get implementation class
- String implementationClass = props
- .getProperty("jtimer.io.saver.class");
- // get saver directory
- String saverDirectory = props
- .getProperty("jtimer.io.saver.directory");
- // get saver save delay
- String autoSaveDelay = props
- .getProperty("jtimer.io.saver.autosavedelay");
+ Class saverClass = JTimer.config.getIOSaverClass();
- // replace $HOME by user.home
- saverDirectory = getHomeReplacement(saverDirectory);
-
// log
if (log.isInfoEnabled()) {
- log.info("Using saver class : " + implementationClass);
- log.info(" with saver home directory : " + saverDirectory);
- log.info(" with auto save delay : " + autoSaveDelay);
+ log.info("Using saver class : " + saverClass);
+ log.info(" with saver home directory : " + JTimer.config.getIOSaverDirectory());
+ log.info(" with auto save delay : " + JTimer.config.getIOSaverAutoSaveDelay());
}
try {
// get instance
- saver = (Saver) Class.forName(implementationClass)
- .newInstance();
+ saver = (Saver) saverClass.newInstance();
// init instance
- saver.setSaveDirectory(saverDirectory);
+ saver.setSaveDirectory(JTimer.config.getIOSaverDirectory());
// set delay to saver
- try {
- long autoSaveDelayInS = Long.parseLong(autoSaveDelay);
- saver.setAutoSaveDelay(autoSaveDelayInS * 1000);
- } catch (NumberFormatException e) {
- if (log.isWarnEnabled()) {
- log.warn("jtimer.io.saver.autosavedelay is non numeric value",
- e);
- }
- }
+ saver.setAutoSaveDelay(JTimer.config.getIOSaverAutoSaveDelay() * 1000);
+
} catch (InstantiationException e) {
if (log.isErrorEnabled()) {
- log.error("Can't instanciate class : "
- + implementationClass, e);
+ log.error("Can't instanciate class : " + saverClass, e);
}
} catch (IllegalAccessException e) {
if (log.isErrorEnabled()) {
- log.error("Can't access class : " + implementationClass, e);
+ log.error("Can't access class : " + saverClass, e);
}
- } catch (ClassNotFoundException e) {
- if (log.isErrorEnabled()) {
- log.error("Can't found class : " + implementationClass, e);
- }
}
}
return saver;
}
-
- /**
- * Replace $HOME in path.
- *
- * @param path path to replace home
- * @return path without $HOME
- */
- protected static String getHomeReplacement(String path) {
-
- String localPath = path;
-
- // replace $HOME by user.home
- if (localPath != null) {
- // replace / in configuration file by
- // default system file.separator
- // FIXME find better method in 2.0
- localPath = localPath.replace("/", File.separator);
-
- // correct bug on windows system for example
- // \ in path are interpreted on regex
- String escapedUserHome = System.getProperty("user.home")
- .replaceAll("\\\\", "\\\\\\\\");
- localPath = localPath.replaceFirst("\\$HOME", escapedUserHome);
- }
-
- return localPath;
- }
-
- /**
- * Get configuration idle time in ms.
- *
- * @return idle time
- */
- public static long getIdleTime() {
-
- if (idleTime <= 0) {
-
- // check that init has been done
- init();
-
- String idleTimeInS = props.getProperty("jtimer.ui.idletime");
- if (idleTimeInS == null) {
- idleTime = DEFAULT_IDLE_TIME;
- } else {
- try {
- idleTime = Long.parseLong(idleTimeInS) * 1000L;
- } catch (NumberFormatException e) {
- if (log.isWarnEnabled()) {
- log.warn("Can't get idle time as number, using default idle time",
- e);
- }
- idleTime = DEFAULT_IDLE_TIME;
- }
- }
-
- if (log.isInfoEnabled()) {
- log.info("Idle time set to : " + idleTime + "ms");
- }
- }
-
- return idleTime;
- }
}
Modified: trunk/src/main/java/org/chorem/jtimer/entities/TimerTask.java
===================================================================
--- trunk/src/main/java/org/chorem/jtimer/entities/TimerTask.java 2012-02-16 14:27:52 UTC (rev 2805)
+++ trunk/src/main/java/org/chorem/jtimer/entities/TimerTask.java 2012-03-07 16:38:55 UTC (rev 2806)
@@ -5,7 +5,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2007 - 2011 CodeLutin, Chatellier Eric
+ * Copyright (C) 2007 - 2012 CodeLutin, Chatellier Eric
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -32,7 +32,7 @@
import java.util.SortedMap;
import java.util.TreeMap;
-import org.apache.commons.lang.SerializationUtils;
+import org.apache.commons.lang3.SerializationUtils;
import org.chorem.jtimer.utils.DailySortedMap;
/**
Modified: trunk/src/main/java/org/chorem/jtimer/io/GTimerIncrementalSaver.java
===================================================================
--- trunk/src/main/java/org/chorem/jtimer/io/GTimerIncrementalSaver.java 2012-02-16 14:27:52 UTC (rev 2805)
+++ trunk/src/main/java/org/chorem/jtimer/io/GTimerIncrementalSaver.java 2012-03-07 16:38:55 UTC (rev 2806)
@@ -5,7 +5,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2007 - 2011 CodeLutin, Chatellier Eric
+ * Copyright (C) 2007 - 2012 CodeLutin, Chatellier Eric
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -87,9 +87,6 @@
public class GTimerIncrementalSaver extends AbstractSaver implements Saver,
DataEventListener {
- /** serialVersionUID. */
- private static final long serialVersionUID = 4999800626942050992L;
-
/** log. */
private static Log log = LogFactory.getLog(GTimerIncrementalSaver.class);
Modified: trunk/src/main/java/org/chorem/jtimer/io/Saver.java
===================================================================
--- trunk/src/main/java/org/chorem/jtimer/io/Saver.java 2012-02-16 14:27:52 UTC (rev 2805)
+++ trunk/src/main/java/org/chorem/jtimer/io/Saver.java 2012-03-07 16:38:55 UTC (rev 2806)
@@ -5,7 +5,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2007 - 2011 CodeLutin, Chatellier Eric
+ * Copyright (C) 2007 - 2012 CodeLutin, Chatellier Eric
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
Modified: trunk/src/main/java/org/chorem/jtimer/package-info.java
===================================================================
--- trunk/src/main/java/org/chorem/jtimer/package-info.java 2012-02-16 14:27:52 UTC (rev 2805)
+++ trunk/src/main/java/org/chorem/jtimer/package-info.java 2012-03-07 16:38:55 UTC (rev 2806)
@@ -5,7 +5,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2007 - 2011 CodeLutin, Chatellier Eric
+ * Copyright (C) 2007 - 2012 CodeLutin, Chatellier Eric
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
Modified: trunk/src/main/java/org/chorem/jtimer/ui/StatusBar.java
===================================================================
--- trunk/src/main/java/org/chorem/jtimer/ui/StatusBar.java 2012-02-16 14:27:52 UTC (rev 2805)
+++ trunk/src/main/java/org/chorem/jtimer/ui/StatusBar.java 2012-03-07 16:38:55 UTC (rev 2806)
@@ -5,7 +5,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2007 - 2011 CodeLutin, Chatellier Eric
+ * Copyright (C) 2007 - 2012 CodeLutin, Chatellier Eric
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -35,7 +35,7 @@
import javax.swing.JPanel;
import javax.swing.SwingConstants;
-import org.apache.commons.lang.time.DurationFormatUtils;
+import org.apache.commons.lang3.time.DurationFormatUtils;
import org.chorem.jtimer.data.DataEventListener;
import org.chorem.jtimer.data.TimerDataManager;
import org.chorem.jtimer.entities.TimerProject;
Modified: trunk/src/main/java/org/chorem/jtimer/ui/report/ReportUtils.java
===================================================================
--- trunk/src/main/java/org/chorem/jtimer/ui/report/ReportUtils.java 2012-02-16 14:27:52 UTC (rev 2805)
+++ trunk/src/main/java/org/chorem/jtimer/ui/report/ReportUtils.java 2012-03-07 16:38:55 UTC (rev 2806)
@@ -5,7 +5,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2008 - 2011 CodeLutin, Chatellier Eric
+ * Copyright (C) 2008 - 2012 CodeLutin, Chatellier Eric
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -30,7 +30,7 @@
import java.util.Date;
import java.util.List;
-import org.apache.commons.lang.time.DurationFormatUtils;
+import org.apache.commons.lang3.time.DurationFormatUtils;
import org.chorem.jtimer.entities.TimerTask;
import org.chorem.jtimer.entities.TimerTaskHelper;
Modified: trunk/src/main/java/org/chorem/jtimer/ui/tasks/IdleDialog.java
===================================================================
--- trunk/src/main/java/org/chorem/jtimer/ui/tasks/IdleDialog.java 2012-02-16 14:27:52 UTC (rev 2805)
+++ trunk/src/main/java/org/chorem/jtimer/ui/tasks/IdleDialog.java 2012-03-07 16:38:55 UTC (rev 2806)
@@ -5,7 +5,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2009 - 2011 CodeLutin, Chatellier Eric
+ * Copyright (C) 2009 - 2012 CodeLutin, Chatellier Eric
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -40,10 +40,10 @@
import javax.swing.SwingConstants;
import javax.swing.WindowConstants;
-import org.apache.commons.lang.time.DurationFormatUtils;
+import org.apache.commons.lang3.time.DurationFormatUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.chorem.jtimer.JTimerFactory;
+import org.chorem.jtimer.JTimer;
import org.jdesktop.application.Action;
import org.jdesktop.application.ApplicationContext;
import org.jdesktop.application.ResourceManager;
@@ -160,7 +160,7 @@
// label
JLabel idleLabel = new JLabel(resourceMap.getString("idleMessage", Long
- .valueOf(JTimerFactory.getIdleTime() / (60 * 1000))));
+ .valueOf(JTimer.config.getIdleTime() / (60 * 1000))));
mainComponent.add(idleLabel, new GridBagConstraints(1, 0, 3, 1, 1, 0,
GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
new Insets(5, 0, 0, 3), 0, 0));
Modified: trunk/src/main/java/org/chorem/jtimer/ui/tasks/RunTaskJob.java
===================================================================
--- trunk/src/main/java/org/chorem/jtimer/ui/tasks/RunTaskJob.java 2012-02-16 14:27:52 UTC (rev 2805)
+++ trunk/src/main/java/org/chorem/jtimer/ui/tasks/RunTaskJob.java 2012-03-07 16:38:55 UTC (rev 2806)
@@ -5,7 +5,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2007 - 2011 CodeLutin, Chatellier Eric
+ * Copyright (C) 2007 - 2012 CodeLutin, Chatellier Eric
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -34,7 +34,7 @@
import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;
-import org.apache.commons.lang.time.DurationFormatUtils;
+import org.apache.commons.lang3.time.DurationFormatUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.jtimer.JTimer;
@@ -65,7 +65,7 @@
/** Class logger. */
private static Log log = LogFactory.getLog(RunTaskJob.class);
- /** Parent app referenc. */
+ /** Parent app reference. */
protected JTimer parentApp;
/** The task to manage. */
@@ -77,17 +77,18 @@
/** System information (idle...). */
protected SystemInfo systemInfo;
+ /** Already thrown alert. */
+ protected Collection<TimerAlert> alreadyTrownAlerts;
+
/** The today total task time at start time. */
protected long taskTimingBeforeStartInMs;
/** Calendar instance when timing start. */
protected Calendar taskStartCalendar;
- /** Already thrown alert. */
- protected Collection<TimerAlert> alreadyTrownAlerts;
-
/**
- * Offset to adjust time. Include :
+ * Offset to adjust time for current day.
+ * Include :
* - Task idle time (task was running but time not counted)
* - Manual user incremented time
*/
@@ -206,11 +207,7 @@
taskStartCalendar = Calendar.getInstance();
lastPublishTimestamp = taskStartCalendar.getTimeInMillis();
- // need to be 0 here not managedTask.getTime(new Date());
- // for idle detected when 0hOO goes...
- //taskTimingBeforeStartInMs = managedTask.getTime(new Date());
-
- // need to be this for hibernation in same day
+ // need to be this for hibernate in same day
taskTimingBeforeStartInMs = managedTask.getTime(new Date()) * 1000;
offsetTimeInMs = 0;
}
@@ -250,14 +247,14 @@
resetTiming();
// get idle time
- long configIdleTime = JTimerFactory.getIdleTime();
+ long configIdleTime = JTimer.config.getIdleTime();
boolean dontWantToStop = true;
while (dontWantToStop) {
- long loopTimestamp = Calendar.getInstance().getTimeInMillis();
+ long currentTime = Calendar.getInstance().getTimeInMillis();
// try to detect hibernate idle time
- if (loopTimestamp - lastPublishTimestamp >= configIdleTime) {
+ if (currentTime - lastPublishTimestamp >= configIdleTime) {
// hibernate detected
// update time without idle time for specified day
if (log.isInfoEnabled()) {
@@ -266,7 +263,7 @@
resetTiming();
}
- lastPublishTimestamp = loopTimestamp;
+ lastPublishTimestamp = currentTime;
// check user idle time
long idleTime = 0;
@@ -282,18 +279,22 @@
checkReset();
// if long idleTime is unavailable, if is always false
- if (idleTime >= JTimerFactory.getIdleTime()) {
+ if (idleTime >= JTimer.config.getIdleTime()) {
+ // to not display negative time near midnight
+ long idleTimeOffset = Math.min(idleTime, currentTime - taskStartCalendar.getTimeInMillis());
+
// idle detected
// update time without idle time
- offsetTimeInMs -= configIdleTime;
- publish(taskTimingBeforeStartInMs + loopTimestamp - taskStartCalendar.getTimeInMillis() + offsetTimeInMs);
+ // math.min > for idle detected at 0:00
+ offsetTimeInMs -= idleTimeOffset;
+ publish(taskTimingBeforeStartInMs + currentTime - taskStartCalendar.getTimeInMillis() + offsetTimeInMs);
// send idle detect event
JTimer parentApplication = (JTimer)getApplication();
parentApplication.preIdleDetect();
// ask user what to do (long blocking call)
- int option = IdleDialog.showIdleDialog(loopTimestamp - idleTime);
+ int option = IdleDialog.showIdleDialog(currentTime - idleTime);
// send idle detect event
parentApplication.postIdleDetect();
@@ -301,8 +302,8 @@
checkReset();
// get time after user idle
- long currentTime = Calendar.getInstance().getTimeInMillis();
- lastPublishTimestamp = currentTime;
+ long afterIdleTime = Calendar.getInstance().getTimeInMillis();
+ lastPublishTimestamp = afterIdleTime;
switch (option) {
@@ -314,8 +315,8 @@
case IdleDialog.CONTINUE:
// refresh time
// remove idle time previously added
- offsetTimeInMs += configIdleTime;
- publish(taskTimingBeforeStartInMs + currentTime
+ offsetTimeInMs += idleTimeOffset;
+ publish(taskTimingBeforeStartInMs + afterIdleTime
- taskStartCalendar.getTimeInMillis()
+ offsetTimeInMs);
break;
@@ -323,9 +324,9 @@
default: // RESUME
// resume = increment idle time
- offsetTimeInMs -= currentTime - loopTimestamp;
+ offsetTimeInMs -= afterIdleTime - currentTime;
// update time
- publish(taskTimingBeforeStartInMs + currentTime
+ publish(taskTimingBeforeStartInMs + afterIdleTime
- taskStartCalendar.getTimeInMillis()
+ offsetTimeInMs);
break;
@@ -333,7 +334,7 @@
}
} else {
// pas de idle, met a jour le temps
- publish(taskTimingBeforeStartInMs + loopTimestamp
+ publish(taskTimingBeforeStartInMs + currentTime
- taskStartCalendar.getTimeInMillis() + offsetTimeInMs);
}
Modified: trunk/src/main/java/org/chorem/jtimer/ui/treetable/ProjectsAndTasksModel.java
===================================================================
--- trunk/src/main/java/org/chorem/jtimer/ui/treetable/ProjectsAndTasksModel.java 2012-02-16 14:27:52 UTC (rev 2805)
+++ trunk/src/main/java/org/chorem/jtimer/ui/treetable/ProjectsAndTasksModel.java 2012-03-07 16:38:55 UTC (rev 2806)
@@ -5,7 +5,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2007 - 2011 CodeLutin, Chatellier Eric
+ * Copyright (C) 2007 - 2012 CodeLutin, Chatellier Eric
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -36,7 +36,7 @@
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.Predicate;
-import org.apache.commons.lang.time.DurationFormatUtils;
+import org.apache.commons.lang3.time.DurationFormatUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.jtimer.data.DataEventListener;
Modified: trunk/src/main/java/org/chorem/jtimer/ui/treetable/dnd/TimerTaskTransferHandler.java
===================================================================
--- trunk/src/main/java/org/chorem/jtimer/ui/treetable/dnd/TimerTaskTransferHandler.java 2012-02-16 14:27:52 UTC (rev 2805)
+++ trunk/src/main/java/org/chorem/jtimer/ui/treetable/dnd/TimerTaskTransferHandler.java 2012-03-07 16:38:55 UTC (rev 2806)
@@ -5,7 +5,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2008 - 2011 CodeLutin, Chatellier Eric
+ * Copyright (C) 2008 - 2012 CodeLutin, Chatellier Eric
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -36,7 +36,7 @@
import javax.swing.JOptionPane;
import javax.swing.TransferHandler;
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.jtimer.data.DataViolationException;
Deleted: trunk/src/main/resources/JTimer.properties
===================================================================
--- trunk/src/main/resources/JTimer.properties 2012-02-16 14:27:52 UTC (rev 2805)
+++ trunk/src/main/resources/JTimer.properties 2012-03-07 16:38:55 UTC (rev 2806)
@@ -1,51 +0,0 @@
-###
-# #%L
-# jTimer
-#
-# $Id$
-# $HeadURL$
-# %%
-# Copyright (C) 2007 - 2011 CodeLutin, Chatellier Eric
-# %%
-# 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 3 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, see
-# <http://www.gnu.org/licenses/gpl-3.0.html>.
-# #L%
-###
-# JTimer.properties file
-
-##########################
-# Synchronization Services
-##########################
-# Service class
-#jtimer.service.class=org.chorem.jtimer.ws.xmlrpc.ChoremXMLRPCClient
-# Service resource to use for previous class
-#jtimer.service.resource=JTimer
-# Service endpoint to use for previous class
-#jtimer.service.endpoint=http://localhost:8080
-
-##########################
-# UI Options
-##########################
-# Idle time (integer in seconds)
-jtimer.ui.idletime=300
-
-##########################
-# Save options
-##########################
-# jtimer io saver directory
-jtimer.io.saver.class=org.chorem.jtimer.io.GTimerIncrementalSaver
-# Saver directory
-jtimer.io.saver.directory=$HOME/.gtimer
-# Save delay
-jtimer.io.saver.autosavedelay=300
Deleted: trunk/src/main/resources/JTimer_default.properties
===================================================================
--- trunk/src/main/resources/JTimer_default.properties 2012-02-16 14:27:52 UTC (rev 2805)
+++ trunk/src/main/resources/JTimer_default.properties 2012-03-07 16:38:55 UTC (rev 2806)
@@ -1,51 +0,0 @@
-###
-# #%L
-# jTimer
-#
-# $Id$
-# $HeadURL$
-# %%
-# Copyright (C) 2007 - 2011 CodeLutin, Chatellier Eric
-# %%
-# 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 3 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, see
-# <http://www.gnu.org/licenses/gpl-3.0.html>.
-# #L%
-###
-# JTimer.properties file
-
-##########################
-# Synchronization Services
-##########################
-# Service class
-#jtimer.service.class=org.chorem.jtimer.ws.xmlrpc.ChoremXMLRPCClient
-# Service resource to use for previous class
-#jtimer.service.resource=JTimer
-# Service endpoint to use for previous class
-#jtimer.service.endpoint=http://localhost:8080
-
-##########################
-# UI Options
-##########################
-# Idle time (integer in seconds)
-#jtimer.ui.idletime=300
-
-##########################
-# Save options
-##########################
-# jtimer io saver directory
-#jtimer.io.saver.class=org.chorem.jtimer.io.GTimerIncrementalSaver
-# Saver directory
-#jtimer.io.saver.directory=$HOME/.gtimer
-# Save delay
-#jtimer.io.saver.autosavedelay=300
Modified: trunk/src/main/resources/log4j.properties
===================================================================
--- trunk/src/main/resources/log4j.properties 2012-02-16 14:27:52 UTC (rev 2805)
+++ trunk/src/main/resources/log4j.properties 2012-03-07 16:38:55 UTC (rev 2806)
@@ -5,7 +5,7 @@
# $Id$
# $HeadURL$
# %%
-# Copyright (C) 2007 - 2011 CodeLutin, Chatellier Eric
+# Copyright (C) 2007 - 2012 CodeLutin, Chatellier Eric
# %%
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as
Modified: trunk/src/test/java/org/chorem/jtimer/AbstractJTimerTest.java
===================================================================
--- trunk/src/test/java/org/chorem/jtimer/AbstractJTimerTest.java 2012-02-16 14:27:52 UTC (rev 2805)
+++ trunk/src/test/java/org/chorem/jtimer/AbstractJTimerTest.java 2012-03-07 16:38:55 UTC (rev 2806)
@@ -5,7 +5,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2008 - 2011 CodeLutin, Chatellier Eric
+ * Copyright (C) 2008 - 2012 CodeLutin, Chatellier Eric
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -57,10 +57,9 @@
/** Class log */
private static Log log = LogFactory.getLog(AbstractJTimerTest.class);
- protected static final String RELATIF_PROPERTIES_RESOURCE = "/JTimerTestRelatif.properties";
-
/** Saver instance on specific test directory. */
protected Saver testSaver;
+
/** Test directory. */
protected File testDataDirectory;
@@ -86,16 +85,18 @@
*/
protected void initDataDirectory() throws IOException {
- URL testConfigFile = AbstractJTimerTest.class
- .getResource(RELATIF_PROPERTIES_RESOURCE);
+ URL testConfigFile = AbstractJTimerTest.class.getResource("/jtimertest.properties");
+ Properties props = new Properties();
+ props.load(testConfigFile.openStream());
- JTimerFactory.props = new Properties();
- JTimerFactory.props.load(testConfigFile.openStream());
testDataDirectory = new File(getTempDirPath(), String.valueOf(System
.currentTimeMillis()));
- JTimerFactory.props.put("jtimer.io.saver.directory", testDataDirectory
+ props.put("jtimer.io.saver.directory", testDataDirectory
.getAbsolutePath());
+ JTimer.config = new JTimerConfig();
+ JTimer.config.appConfig.setOptions(props); // not call parse in test
+
if (log.isDebugEnabled()) {
log.debug("Copy resource test directory to "
+ testDataDirectory.getAbsolutePath());
Modified: trunk/src/test/java/org/chorem/jtimer/JTimerFactoryTest.java
===================================================================
--- trunk/src/test/java/org/chorem/jtimer/JTimerFactoryTest.java 2012-02-16 14:27:52 UTC (rev 2805)
+++ trunk/src/test/java/org/chorem/jtimer/JTimerFactoryTest.java 2012-03-07 16:38:55 UTC (rev 2806)
@@ -25,12 +25,13 @@
package org.chorem.jtimer;
-import java.util.Properties;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.chorem.jtimer.JTimerConfig.JTimerOption;
+import org.chorem.jtimer.io.GTimerIncrementalSaver;
import org.chorem.jtimer.io.Saver;
import org.chorem.jtimer.ws.ProjectManagement;
+import org.chorem.jtimer.ws.xmlrpc.ChoremXMLRPCClient;
import org.testng.Assert;
import org.testng.annotations.Test;
@@ -49,61 +50,30 @@
private static Log log = LogFactory.getLog(JTimerFactoryTest.class);
/**
- * Test que les proprietes ne sont pas
- * nulles et que les valeures sont bonnes.
+ * Verifie que les options par default sont bien chargées.
*/
@Test
- public void initTest() {
+ public void testInitConfiguration() {
if (log.isInfoEnabled()) {
log.info("Test property loading " + JTimerFactoryTest.class);
}
- Properties props = JTimerFactory.props;
+ Assert.assertEquals(JTimer.config.getServiceClass(), ChoremXMLRPCClient.class);
+ Assert.assertEquals(JTimer.config.getServiceResource(), "JTimer");
+ Assert.assertEquals(JTimer.config.getServiceEndpoint(), "http://localhost:8080");
- Assert.assertEquals(
- "org.chorem.jtimer.ws.xmlrpc.ChoremXMLRPCClient", props
- .getProperty("jtimer.service.class"));
- Assert.assertEquals("JTimer", props
- .getProperty("jtimer.service.resource"));
- Assert.assertEquals("http://localhost:8080", props
- .getProperty("jtimer.service.endpoint"));
+ Assert.assertEquals(JTimer.config.getIdleTime(), 299);
- Assert.assertEquals("299", props.getProperty("jtimer.ui.idletime"));
-
- Assert.assertEquals("org.chorem.jtimer.io.GTimerIncrementalSaver",
- props.getProperty("jtimer.io.saver.class"));
+ Assert.assertEquals(JTimer.config.getIOSaverClass(), GTimerIncrementalSaver.class);
// Temp dir is dynamic
//Assert.assertEquals(AbstractJTimerTest.getTempDirPath() + "/testngdata",
- // props.getProperty("jtimer.io.saver.directory"));
- Assert.assertEquals("199", props
- .getProperty("jtimer.io.saver.autosavedelay"));
+ // JTimer.config.getIOSaverDirectory());
+ Assert.assertEquals(JTimer.config.getIOSaverAutoSaveDelay(), 199);
}
/**
- * Test que le fichier de conf s'appelle bien JTimer.properties.
- */
- @Test
- public void getConfigurationFileName() {
- String name = JTimerFactory.getConfigurationFileName();
- Assert.assertNotNull(name);
- Assert.assertEquals("JTimer.properties", name);
- }
-
- /**
- * Test que le fichier de path du fichier n'est pas null.
- * Le chemin complet est $HOME/.jtimer/getConfigurationFileName().
- * Mais ca depend de $HOME
- */
- @Test
- public void getConfigurationFilePath() {
- String path = JTimerFactory.getUserHomeConfigurationFilePath();
- Assert.assertNotNull(path);
- Assert.assertTrue(path.endsWith("/.jtimer/JTimer.properties"));
- }
-
- /**
* Test que le saver de fichier s'est bien initialise.
*/
@Test
@@ -114,45 +84,14 @@
}
/**
- * Test la valeur de idletime.
- */
- @Test
- public void getIdleTime() {
- long idleTime = JTimerFactory.getIdleTime();
-
- Assert.assertTrue(idleTime > 0L);
- Assert.assertEquals(299000, idleTime);
- }
-
- /**
- * Test que le $HOME est bien remplacé
- */
- @Test
- public void getHomeReplacementTest() {
-
- Assert.assertEquals("/home/test/.gtimer", JTimerFactory
- .getHomeReplacement("/home/test/.gtimer"));
-
- Assert.assertEquals(System.getProperty("user.home") + "/.gtimer",
- JTimerFactory.getHomeReplacement("$HOME/.gtimer"));
-
- Assert.assertEquals(
- "C:\\Documents And Settings\\user\\.gtimer",
- JTimerFactory
- .getHomeReplacement("C:\\Documents And Settings\\user\\.gtimer"));
- }
-
- /**
* Test que le composant gerant les webservices s'est bien initialise.
*/
@Test
public void getProjectManagementService() {
- ProjectManagement projectManagement = JTimerFactory
- .getProjectManagementService();
+ ProjectManagement projectManagement = JTimerFactory.getProjectManagementService();
Assert.assertNotNull(projectManagement);
- Assert.assertEquals("http://localhost:8080", projectManagement
- .getEndpoint());
- Assert.assertEquals("JTimer", projectManagement.getResourceName());
+ Assert.assertEquals(projectManagement.getEndpoint(), "http://localhost:8080");
+ Assert.assertEquals(projectManagement.getResourceName(), "JTimer");
}
}
Deleted: trunk/src/test/resources/JTimerTestRelatif.properties
===================================================================
--- trunk/src/test/resources/JTimerTestRelatif.properties 2012-02-16 14:27:52 UTC (rev 2805)
+++ trunk/src/test/resources/JTimerTestRelatif.properties 2012-03-07 16:38:55 UTC (rev 2806)
@@ -1,40 +0,0 @@
-###
-# #%L
-# jTimer
-#
-# $Id$
-# $HeadURL$
-# %%
-# Copyright (C) 2007 - 2011 CodeLutin, Chatellier Eric
-# %%
-# 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 3 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, see
-# <http://www.gnu.org/licenses/gpl-3.0.html>.
-# #L%
-###
-# Service class
-jtimer.service.class=org.chorem.jtimer.ws.xmlrpc.ChoremXMLRPCClient
-# Service resource to use for previous class
-jtimer.service.resource=JTimer
-# Service endpoint to use for previous class
-jtimer.service.endpoint=http://localhost:8080
-
-# Idle time (integer in seconds)
-jtimer.ui.idletime=299
-
-# jtimer io saver directory
-jtimer.io.saver.class=org.chorem.jtimer.io.GTimerIncrementalSaver
-# Saver directory
-jtimer.io.saver.directory=$HOME/testngdata
-# Save delay
-jtimer.io.saver.autosavedelay=199
\ No newline at end of file
Copied: trunk/src/test/resources/jtimertest.properties (from rev 2803, trunk/src/test/resources/JTimerTestRelatif.properties)
===================================================================
--- trunk/src/test/resources/jtimertest.properties (rev 0)
+++ trunk/src/test/resources/jtimertest.properties 2012-03-07 16:38:55 UTC (rev 2806)
@@ -0,0 +1,40 @@
+###
+# #%L
+# jTimer
+#
+# $Id$
+# $HeadURL$
+# %%
+# Copyright (C) 2007 - 2011 CodeLutin, Chatellier Eric
+# %%
+# 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 3 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, see
+# <http://www.gnu.org/licenses/gpl-3.0.html>.
+# #L%
+###
+# Service class
+jtimer.service.class=org.chorem.jtimer.ws.xmlrpc.ChoremXMLRPCClient
+# Service resource to use for previous class
+jtimer.service.resource=JTimer
+# Service endpoint to use for previous class
+jtimer.service.endpoint=http://localhost:8080
+
+# Idle time (integer in seconds)
+jtimer.ui.idletime=299
+
+# jtimer io saver directory
+jtimer.io.saver.class=org.chorem.jtimer.io.GTimerIncrementalSaver
+# Saver directory
+jtimer.io.saver.directory=${user.home}/testngdata
+# Save delay
+jtimer.io.saver.autosavedelay=199
\ No newline at end of file
1
0