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
July 2013
- 2 participants
- 16 discussions
r2907 - in branches/ng-jtimer: . jtimer-client jtimer-server jtimer-server/src/main/java/org/chorem/jtimer jtimer-server/src/main/java/org/chorem/jtimer/web jtimer-server/src/main/resources jtimer-server/src/main/webapp/web/scripts
by echatellier@users.chorem.org 19 Jul '13
by echatellier@users.chorem.org 19 Jul '13
19 Jul '13
Author: echatellier
Date: 2013-07-19 16:40:13 +0200 (Fri, 19 Jul 2013)
New Revision: 2907
Url: http://chorem.org/projects/jtimer/repository/revisions/2907
Log:
Add rest controller using webmotion
Added:
branches/ng-jtimer/jtimer-server/src/main/java/org/chorem/jtimer/services/
branches/ng-jtimer/jtimer-server/src/main/java/org/chorem/jtimer/web/
branches/ng-jtimer/jtimer-server/src/main/java/org/chorem/jtimer/web/RestController.java
branches/ng-jtimer/jtimer-server/src/main/resources/mapping
Removed:
branches/ng-jtimer/jtimer-server/src/main/java/org/chorem/jtimer/ProxyService.java
Modified:
branches/ng-jtimer/jtimer-client/
branches/ng-jtimer/jtimer-server/pom.xml
branches/ng-jtimer/jtimer-server/src/main/webapp/web/scripts/controllers.js
branches/ng-jtimer/pom.xml
Property changes on: branches/ng-jtimer/jtimer-client
___________________________________________________________________
Added: svn:ignore
+ .settings
target
.classpath
.project
Modified: branches/ng-jtimer/jtimer-server/pom.xml
===================================================================
--- branches/ng-jtimer/jtimer-server/pom.xml 2013-07-19 14:01:18 UTC (rev 2906)
+++ branches/ng-jtimer/jtimer-server/pom.xml 2013-07-19 14:40:13 UTC (rev 2907)
@@ -27,21 +27,13 @@
<version>2.2.4</version>
</dependency>
<dependency>
- <groupId>org.apache.geronimo.specs</groupId>
- <artifactId>geronimo-servlet_3.0_spec</artifactId>
+ <groupId>org.debux.webmotion</groupId>
+ <artifactId>webmotion</artifactId>
+ <version>2.4-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
- <resources>
- <resource>
- <directory>src/main/webapp</directory>
- <includes>
- <include>web/*.html</include>
- </includes>
- </resource>
- </resources>
-
<plugins>
<plugin>
<groupId>org.eclipse.jetty</groupId>
Deleted: branches/ng-jtimer/jtimer-server/src/main/java/org/chorem/jtimer/ProxyService.java
===================================================================
--- branches/ng-jtimer/jtimer-server/src/main/java/org/chorem/jtimer/ProxyService.java 2013-07-19 14:01:18 UTC (rev 2906)
+++ branches/ng-jtimer/jtimer-server/src/main/java/org/chorem/jtimer/ProxyService.java 2013-07-19 14:40:13 UTC (rev 2907)
@@ -1,85 +0,0 @@
-package org.chorem.jtimer;
-
-import java.io.IOException;
-import java.lang.reflect.Method;
-
-import javax.servlet.ServletException;
-import javax.servlet.ServletOutputStream;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.chorem.jtimer.storage.Storage;
-
-import com.google.gson.Gson;
-
-public class ProxyService extends HttpServlet {
-
- /** serialVersionUID. */
- private static final long serialVersionUID = -5180281013629027617L;
-
- protected Storage storage;
-
- protected Gson gson;
-
- public ProxyService() {
- storage = new Storage();
- gson = new Gson();
- }
-
- @Override
- protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- callMethod("get", req, resp);
- }
-
- @Override
- protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- callMethod("get", req, resp);
- }
-
- @Override
- protected void doPut(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- callMethod("get", req, resp);
- }
-
- @Override
- protected void doDelete(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- callMethod("get", req, resp);
- }
-
- protected void callMethod(String prefix, HttpServletRequest req, HttpServletResponse resp) throws IOException {
-
- String contextPath = req.getContextPath();
- String requestUri = req.getRequestURI();
-
- String query = requestUri;
- System.out.println("requestUri = " + requestUri);
- if (query.startsWith("/rest/")) {
- query = query.substring("/rest/".length());
- }
-
- String methodName = prefix + Character.toTitleCase(query.charAt(0)) + query.substring(1);
- System.out.println("Callling method " + methodName);
- Method[] methods = Storage.class.getMethods();
- Method method = null;
- for (Method m : methods) {
- if (m.getName().equalsIgnoreCase(methodName)) {
- method = m;
- }
- }
-
- if (method == null) {
- resp.sendError(HttpServletResponse.SC_NOT_FOUND);
- } else {
- try {
- Object result = method.invoke(storage);
- String json = gson.toJson(result);
- resp.setContentType("application/json");
- ServletOutputStream out = resp.getOutputStream();
- out.print(json);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }
-}
Added: branches/ng-jtimer/jtimer-server/src/main/java/org/chorem/jtimer/web/RestController.java
===================================================================
--- branches/ng-jtimer/jtimer-server/src/main/java/org/chorem/jtimer/web/RestController.java (rev 0)
+++ branches/ng-jtimer/jtimer-server/src/main/java/org/chorem/jtimer/web/RestController.java 2013-07-19 14:40:13 UTC (rev 2907)
@@ -0,0 +1,27 @@
+package org.chorem.jtimer.web;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.chorem.jtimer.entities.TimerProject;
+import org.debux.webmotion.server.WebMotionController;
+import org.debux.webmotion.server.render.Render;
+
+public class RestController extends WebMotionController {
+
+ protected List<TimerProject> projects;
+
+ public RestController() {
+ projects = new ArrayList<>();
+ projects.add(new TimerProject("jTimer"));
+ projects.add(new TimerProject("Chorem"));
+ projects.add(new TimerProject("Wikitty"));
+ projects.add(new TimerProject("Nuiton-js"));
+ projects.add(new TimerProject("Angular"));
+ projects.add(new TimerProject("Isis-Fish"));
+ }
+
+ public Render getProjects() {
+ return renderJSON(projects);
+ }
+}
Property changes on: branches/ng-jtimer/jtimer-server/src/main/java/org/chorem/jtimer/web/RestController.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: branches/ng-jtimer/jtimer-server/src/main/resources/mapping
===================================================================
--- branches/ng-jtimer/jtimer-server/src/main/resources/mapping (rev 0)
+++ branches/ng-jtimer/jtimer-server/src/main/resources/mapping 2013-07-19 14:40:13 UTC (rev 2907)
@@ -0,0 +1,5 @@
+[config]
+package.base=org.chorem.jtimer.web
+
+[actions]
+GET /rest/projects RestController.getProjects
Modified: branches/ng-jtimer/jtimer-server/src/main/webapp/web/scripts/controllers.js
===================================================================
--- branches/ng-jtimer/jtimer-server/src/main/webapp/web/scripts/controllers.js 2013-07-19 14:01:18 UTC (rev 2906)
+++ branches/ng-jtimer/jtimer-server/src/main/webapp/web/scripts/controllers.js 2013-07-19 14:40:13 UTC (rev 2907)
@@ -2,7 +2,7 @@
function JTimerController($scope, $http, $timeout) {
$scope.projects;
- $http.post("http://localhost:8888/rest/projects").
+ $http.get("/rest/projects").
success(function(data, status, headers, config) {
$scope.projects = data;
});
Modified: branches/ng-jtimer/pom.xml
===================================================================
--- branches/ng-jtimer/pom.xml 2013-07-19 14:01:18 UTC (rev 2906)
+++ branches/ng-jtimer/pom.xml 2013-07-19 14:40:13 UTC (rev 2907)
@@ -120,4 +120,11 @@
</dependency>
</dependencies>
</dependencyManagement>
+
+ <repositories>
+ <repository>
+ <id>sonatype</id>
+ <url>https://oss.sonatype.org/content/groups/public/</url>
+ </repository>
+ </repositories>
</project>
1
0
r2906 - in branches/ng-jtimer: . jtimer-server jtimer-server/src/main/webapp jtimer-server/src/main/webapp/WEB-INF jtimer-server/src/main/webapp/web
by echatellier@users.chorem.org 19 Jul '13
by echatellier@users.chorem.org 19 Jul '13
19 Jul '13
Author: echatellier
Date: 2013-07-19 16:01:18 +0200 (Fri, 19 Jul 2013)
New Revision: 2906
Url: http://chorem.org/projects/jtimer/repository/revisions/2906
Log:
Unbuild client, package server as war.
Added:
branches/ng-jtimer/jtimer-server/src/main/webapp/WEB-INF/
branches/ng-jtimer/jtimer-server/src/main/webapp/WEB-INF/web.xml
Modified:
branches/ng-jtimer/jtimer-server/pom.xml
branches/ng-jtimer/jtimer-server/src/main/webapp/web/index.html
branches/ng-jtimer/pom.xml
Modified: branches/ng-jtimer/jtimer-server/pom.xml
===================================================================
--- branches/ng-jtimer/jtimer-server/pom.xml 2013-07-19 13:36:34 UTC (rev 2905)
+++ branches/ng-jtimer/jtimer-server/pom.xml 2013-07-19 14:01:18 UTC (rev 2906)
@@ -10,7 +10,7 @@
<groupId>org.chorem.jtimer</groupId>
<artifactId>jtimer-server</artifactId>
- <packaging>jar</packaging>
+ <packaging>war</packaging>
<dependencies>
<dependency>
@@ -44,6 +44,11 @@
<plugins>
<plugin>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-maven-plugin</artifactId>
+ <version>9.0.4.v20130625</version>
+ </plugin>
+ <plugin>
<groupId>ro.isdc.wro4j</groupId>
<artifactId>wro4j-maven-plugin</artifactId>
<executions>
Added: branches/ng-jtimer/jtimer-server/src/main/webapp/WEB-INF/web.xml
===================================================================
--- branches/ng-jtimer/jtimer-server/src/main/webapp/WEB-INF/web.xml (rev 0)
+++ branches/ng-jtimer/jtimer-server/src/main/webapp/WEB-INF/web.xml 2013-07-19 14:01:18 UTC (rev 2906)
@@ -0,0 +1,4 @@
+<web-app xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
+ version="3.0" />
\ No newline at end of file
Property changes on: branches/ng-jtimer/jtimer-server/src/main/webapp/WEB-INF/web.xml
___________________________________________________________________
Added: svn:mime-type
+ text/xml
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: branches/ng-jtimer/jtimer-server/src/main/webapp/web/index.html
===================================================================
--- branches/ng-jtimer/jtimer-server/src/main/webapp/web/index.html 2013-07-19 13:36:34 UTC (rev 2905)
+++ branches/ng-jtimer/jtimer-server/src/main/webapp/web/index.html 2013-07-19 14:01:18 UTC (rev 2906)
@@ -4,15 +4,14 @@
<title>jTimer (browser)</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
- <!-- <link type="text/css" rel="stylesheet" href="styles/jtimer.css" />
+ <link type="text/css" rel="stylesheet" href="styles/jtimer.css" />
<link type="text/css" rel="stylesheet" href="//twitter.github.io/bootstrap/assets/css/bootstrap.css" />
<script type="text/javascript" src="//code.jquery.com/jquery-2.0.3.min.js"></script>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/angularjs/1.1.5/angular.min.js"></script>
<script type="text/javascript" src="scripts/app.js"></script>
- <script type="text/javascript" src="scripts/controllers.js"></script> -->
-
- <link type="text/css" rel="stylesheet" href="css/jtimer.css" />
- <script type="text/javascript" src="js/jtimer.js"></script>
+ <script type="text/javascript" src="scripts/controllers.js"></script>
+ <!-- <link type="text/css" rel="stylesheet" href="css/jtimer.css" />
+ <script type="text/javascript" src="js/jtimer.js"></script> -->
<script type="text/javascript" src="//angular-ui.github.io/bootstrap/ui-bootstrap-tpls-0.4.0.js"></script>
<script type="text/ng-template" id="tree_item_renderer_name.html">
Modified: branches/ng-jtimer/pom.xml
===================================================================
--- branches/ng-jtimer/pom.xml 2013-07-19 13:36:34 UTC (rev 2905)
+++ branches/ng-jtimer/pom.xml 2013-07-19 14:01:18 UTC (rev 2906)
@@ -21,7 +21,6 @@
<modules>
<module>jtimer-server</module>
- <module>jtimer-client</module>
</modules>
<licenses>
1
0
Author: echatellier
Date: 2013-07-19 15:36:34 +0200 (Fri, 19 Jul 2013)
New Revision: 2905
Url: http://chorem.org/projects/jtimer/repository/revisions/2905
Log:
Initial v2 import
Added:
branches/ng-jtimer/
branches/ng-jtimer/LICENSE.txt
branches/ng-jtimer/README.txt
branches/ng-jtimer/jtimer-client/
branches/ng-jtimer/jtimer-client/LICENSE.txt
branches/ng-jtimer/jtimer-client/README.txt
branches/ng-jtimer/jtimer-client/pom.xml
branches/ng-jtimer/jtimer-client/src/
branches/ng-jtimer/jtimer-client/src/main/
branches/ng-jtimer/jtimer-client/src/main/java/
branches/ng-jtimer/jtimer-client/src/main/java/org/
branches/ng-jtimer/jtimer-client/src/main/java/org/chorem/
branches/ng-jtimer/jtimer-client/src/main/java/org/chorem/jtimer/
branches/ng-jtimer/jtimer-client/src/main/java/org/chorem/jtimer/JTimer.java
branches/ng-jtimer/jtimer-client/src/main/java/org/chorem/jtimer/ResourcesServlet.java
branches/ng-jtimer/jtimer-client/src/main/java/org/chorem/jtimer/system/
branches/ng-jtimer/jtimer-client/src/main/java/org/chorem/jtimer/system/SystemInfo.java
branches/ng-jtimer/jtimer-client/src/main/java/org/chorem/jtimer/system/SystemInfoFactory.java
branches/ng-jtimer/jtimer-client/src/main/java/org/chorem/jtimer/system/UnsupportedSystemInfoException.java
branches/ng-jtimer/jtimer-client/src/main/java/org/chorem/jtimer/system/macos/
branches/ng-jtimer/jtimer-client/src/main/java/org/chorem/jtimer/system/macos/ApplicationServices.java
branches/ng-jtimer/jtimer-client/src/main/java/org/chorem/jtimer/system/macos/MacOSSystemInfo.java
branches/ng-jtimer/jtimer-client/src/main/java/org/chorem/jtimer/system/macos/package-info.java
branches/ng-jtimer/jtimer-client/src/main/java/org/chorem/jtimer/system/package-info.java
branches/ng-jtimer/jtimer-client/src/main/java/org/chorem/jtimer/system/unix/
branches/ng-jtimer/jtimer-client/src/main/java/org/chorem/jtimer/system/unix/UnixSystemInfo.java
branches/ng-jtimer/jtimer-client/src/main/java/org/chorem/jtimer/system/unix/X11.java
branches/ng-jtimer/jtimer-client/src/main/java/org/chorem/jtimer/system/unix/Xss.java
branches/ng-jtimer/jtimer-client/src/main/java/org/chorem/jtimer/system/unix/package-info.java
branches/ng-jtimer/jtimer-client/src/main/java/org/chorem/jtimer/system/win32/
branches/ng-jtimer/jtimer-client/src/main/java/org/chorem/jtimer/system/win32/Kernel32.java
branches/ng-jtimer/jtimer-client/src/main/java/org/chorem/jtimer/system/win32/User32.java
branches/ng-jtimer/jtimer-client/src/main/java/org/chorem/jtimer/system/win32/Win32SystemInfo.java
branches/ng-jtimer/jtimer-client/src/main/java/org/chorem/jtimer/system/win32/package-info.java
branches/ng-jtimer/jtimer-client/src/main/resources/
branches/ng-jtimer/jtimer-client/src/test/
branches/ng-jtimer/jtimer-client/src/test/java/
branches/ng-jtimer/jtimer-client/src/test/resources/
branches/ng-jtimer/jtimer-server/
branches/ng-jtimer/jtimer-server/LICENSE.txt
branches/ng-jtimer/jtimer-server/README.txt
branches/ng-jtimer/jtimer-server/pom.xml
branches/ng-jtimer/jtimer-server/src/
branches/ng-jtimer/jtimer-server/src/main/
branches/ng-jtimer/jtimer-server/src/main/config/
branches/ng-jtimer/jtimer-server/src/main/config/wro.properties
branches/ng-jtimer/jtimer-server/src/main/config/wro.xml
branches/ng-jtimer/jtimer-server/src/main/java/
branches/ng-jtimer/jtimer-server/src/main/java/org/
branches/ng-jtimer/jtimer-server/src/main/java/org/chorem/
branches/ng-jtimer/jtimer-server/src/main/java/org/chorem/jtimer/
branches/ng-jtimer/jtimer-server/src/main/java/org/chorem/jtimer/ProxyService.java
branches/ng-jtimer/jtimer-server/src/main/java/org/chorem/jtimer/entities/
branches/ng-jtimer/jtimer-server/src/main/java/org/chorem/jtimer/entities/TimerProject.java
branches/ng-jtimer/jtimer-server/src/main/java/org/chorem/jtimer/entities/TimerTask.java
branches/ng-jtimer/jtimer-server/src/main/java/org/chorem/jtimer/storage/
branches/ng-jtimer/jtimer-server/src/main/java/org/chorem/jtimer/storage/Storage.java
branches/ng-jtimer/jtimer-server/src/main/java/org/chorem/jtimer/storage/StorageException.java
branches/ng-jtimer/jtimer-server/src/main/resources/
branches/ng-jtimer/jtimer-server/src/main/webapp/
branches/ng-jtimer/jtimer-server/src/main/webapp/web/
branches/ng-jtimer/jtimer-server/src/main/webapp/web/index.html
branches/ng-jtimer/jtimer-server/src/main/webapp/web/scripts/
branches/ng-jtimer/jtimer-server/src/main/webapp/web/scripts/app.js
branches/ng-jtimer/jtimer-server/src/main/webapp/web/scripts/controllers.js
branches/ng-jtimer/jtimer-server/src/main/webapp/web/styles/
branches/ng-jtimer/jtimer-server/src/main/webapp/web/styles/jtimer.css
branches/ng-jtimer/jtimer-server/src/test/
branches/ng-jtimer/jtimer-server/src/test/java/
branches/ng-jtimer/jtimer-server/src/test/resources/
branches/ng-jtimer/pom.xml
Added: branches/ng-jtimer/LICENSE.txt
===================================================================
Added: branches/ng-jtimer/README.txt
===================================================================
Added: branches/ng-jtimer/jtimer-client/LICENSE.txt
===================================================================
Added: branches/ng-jtimer/jtimer-client/README.txt
===================================================================
Added: branches/ng-jtimer/jtimer-client/pom.xml
===================================================================
--- branches/ng-jtimer/jtimer-client/pom.xml (rev 0)
+++ branches/ng-jtimer/jtimer-client/pom.xml 2013-07-19 13:36:34 UTC (rev 2905)
@@ -0,0 +1,92 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.chorem</groupId>
+ <artifactId>jtimer</artifactId>
+ <version>2.0.0-SNAPSHOT</version>
+ </parent>
+
+ <groupId>org.chorem.jtimer</groupId>
+ <artifactId>jtimer-client</artifactId>
+ <packaging>jar</packaging>
+
+ <properties>
+ <maven.jar.main.class>org.chorem.jtimer.JTimer</maven.jar.main.class>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.chorem.jtimer</groupId>
+ <artifactId>jtimer-server</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>com.nativelibs4java</groupId>
+ <artifactId>bridj</artifactId>
+ <classifier>c-only</classifier>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.jetty.websocket</groupId>
+ <artifactId>websocket-server</artifactId>
+ <version>9.0.4.v20130625</version>
+</dependency>
+<dependency>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-server</artifactId>
+ <version>9.0.4.v20130625</version>
+</dependency>
+<dependency>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-servlet</artifactId>
+ <version>9.0.4.v20130625</version>
+</dependency>
+ <dependency>
+ <groupId>org.jboss.resteasy</groupId>
+ <artifactId>tjws</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-servlet_3.0_spec</artifactId>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.oracle</groupId>
+ <artifactId>javafx</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>javax</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>7.0</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <executions>
+ <execution>
+ <phase>verify</phase>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ <configuration>
+ <archive>
+ <manifest>
+ <mainClass>${maven.jar.main.class}</mainClass>
+ </manifest>
+ </archive>
+ <descriptorRefs>
+ <descriptorRef>jar-with-dependencies</descriptorRef>
+ </descriptorRefs>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
Property changes on: branches/ng-jtimer/jtimer-client/pom.xml
___________________________________________________________________
Added: svn:mime-type
+ text/xml
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: branches/ng-jtimer/jtimer-client/src/main/java/org/chorem/jtimer/JTimer.java
===================================================================
--- branches/ng-jtimer/jtimer-client/src/main/java/org/chorem/jtimer/JTimer.java (rev 0)
+++ branches/ng-jtimer/jtimer-client/src/main/java/org/chorem/jtimer/JTimer.java 2013-07-19 13:36:34 UTC (rev 2905)
@@ -0,0 +1,122 @@
+package org.chorem.jtimer;
+
+import java.util.Properties;
+
+import javafx.application.Application;
+import javafx.scene.Scene;
+import javafx.scene.web.WebEngine;
+import javafx.scene.web.WebView;
+import javafx.stage.Stage;
+
+import org.eclipse.jetty.server.Server;
+import org.eclipse.jetty.servlet.ServletHandler;
+
+import Acme.Serve.Serve;
+
+public class JTimer extends Application {
+
+ public static final int PORT = 8888;
+
+ protected static Serve server;
+
+ public static void main(String[] args) throws Exception {
+
+ JTimer jtimer = new JTimer();
+ int port = jtimer.startLocalServer(args);
+ jtimer.startClient(port, args);
+ }
+
+ /**
+ * Start server, return port.
+ *
+ * @param args args
+ * @return port
+ */
+ protected int startLocalServer(String[] args) throws Exception {
+
+ server = new Serve();
+ // properties
+ Properties properties = new Properties();
+ properties.put("port", PORT);
+ server.arguments = properties;
+ // resources
+ server.addDefaultServlets(null);
+ server.addServlet("/web/*", new ResourcesServlet(""));
+ server.addServlet("/rest/*", new ProxyService());
+
+ Thread thread = new Thread() {
+ public void run() {
+ System.out.println("Starting server...");
+ server.serve();
+ server.destroyAllServlets();
+ System.out.println("Server stopped, exiting...");
+ }
+ };
+ thread.start();
+ return PORT;
+ }
+
+ /**
+ * Start server, return port.
+ *
+ * @param args args
+ * @return port
+ */
+ protected int startLocalServer2(String[] args) throws Exception {
+
+ Server server = new Server(PORT);
+
+ ServletHandler handler = new ServletHandler();
+ server.setHandler(handler);
+
+ handler.addServletWithMapping(ResourcesServlet.class, "/web/*");
+ handler.addServletWithMapping(ProxyService.class, "/rest/*");
+
+ server.start();
+ server.join();
+
+ return PORT;
+ }
+
+ protected void startClient(int port, String[] args) throws Exception {
+ if (args.length == 1) {
+ startChrome(port, args);
+ } else {
+ startWebView(port, args);
+ }
+ }
+
+ protected void startWebView(int port, String[] args) {
+ launch(args);
+ }
+
+ @Override
+ public void start(Stage stage) throws Exception {
+ stage.setTitle("jTimer (jfx)");
+ WebView browser = new WebView();
+ WebEngine webEngine = browser.getEngine();
+ webEngine.load("http://localhost:8888/web/index.html");
+
+ Scene scene = new Scene(browser, 460, 510);
+ stage.setScene(scene);
+ stage.show();
+ }
+
+ @Override
+ public void stop() throws Exception {
+ System.out.println("Stopping server...");
+ server.notifyStop();
+ }
+
+ protected void startChrome(int port, String[] args) throws Exception {
+ System.out.println("Starting client");
+ ProcessBuilder processBuilder = new ProcessBuilder("chromium",
+ "-app=http://localhost:" + port + "/web/index.html",
+ "--user-data-dir=" + System.getProperty("user.home") + "/.jtimer/chrome");
+ processBuilder.redirectErrorStream(true);
+ Process process = processBuilder.start();
+ int status = process.waitFor();
+ System.out.println("Client stopped with status " + status);
+ stop();
+ }
+}
Property changes on: branches/ng-jtimer/jtimer-client/src/main/java/org/chorem/jtimer/JTimer.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: branches/ng-jtimer/jtimer-client/src/main/java/org/chorem/jtimer/ResourcesServlet.java
===================================================================
--- branches/ng-jtimer/jtimer-client/src/main/java/org/chorem/jtimer/ResourcesServlet.java (rev 0)
+++ branches/ng-jtimer/jtimer-client/src/main/java/org/chorem/jtimer/ResourcesServlet.java 2013-07-19 13:36:34 UTC (rev 2905)
@@ -0,0 +1,62 @@
+package org.chorem.jtimer;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * Static resources servlet.
+ *
+ * @author Eric Chatellier
+ */
+public class ResourcesServlet extends HttpServlet {
+
+ /** serialVersionUID. */
+ private static final long serialVersionUID = -7599418973752605746L;
+
+ protected String classPathPrefix;
+
+ public ResourcesServlet(String classPathPrefix) {
+ if (classPathPrefix.endsWith("/")) {
+ classPathPrefix += "/";
+ }
+ this.classPathPrefix = classPathPrefix;
+ }
+
+ @Override
+ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+ String contextPath = req.getContextPath();
+ String requestUri = req.getRequestURI();
+
+ System.out.println("contextPath = " + contextPath);
+ System.out.println("Request uri = " + requestUri);
+
+ InputStream is = ResourcesServlet.class.getResourceAsStream(classPathPrefix + requestUri);
+
+ if (is == null) {
+ resp.sendError(HttpServletResponse.SC_NOT_FOUND);
+ } else {
+ OutputStream out = resp.getOutputStream();
+ copyLarge(is, out, new byte[4096]);
+ }
+ }
+
+ /**
+ * {@link IOUtils#copyLarge(InputStream, OutputStream)}.
+ */
+ protected long copyLarge(InputStream input, OutputStream output, byte[] buffer)
+ throws IOException {
+ long count = 0;
+ int n = 0;
+ while (-1 != (n = input.read(buffer))) {
+ output.write(buffer, 0, n);
+ count += n;
+ }
+ return count;
+ }
+}
Property changes on: branches/ng-jtimer/jtimer-client/src/main/java/org/chorem/jtimer/ResourcesServlet.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: branches/ng-jtimer/jtimer-client/src/main/java/org/chorem/jtimer/system/SystemInfo.java
===================================================================
--- branches/ng-jtimer/jtimer-client/src/main/java/org/chorem/jtimer/system/SystemInfo.java (rev 0)
+++ branches/ng-jtimer/jtimer-client/src/main/java/org/chorem/jtimer/system/SystemInfo.java 2013-07-19 13:36:34 UTC (rev 2905)
@@ -0,0 +1,45 @@
+/*
+ * #%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%
+ */
+
+package org.chorem.jtimer.system;
+
+/**
+ * System info interface for all systems.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public interface SystemInfo {
+
+ /**
+ * Get system idle time in milliseconds.
+ *
+ * @return system idle time in milliseconds
+ */
+ public long getIdleTime();
+}
Property changes on: branches/ng-jtimer/jtimer-client/src/main/java/org/chorem/jtimer/system/SystemInfo.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: branches/ng-jtimer/jtimer-client/src/main/java/org/chorem/jtimer/system/SystemInfoFactory.java
===================================================================
--- branches/ng-jtimer/jtimer-client/src/main/java/org/chorem/jtimer/system/SystemInfoFactory.java (rev 0)
+++ branches/ng-jtimer/jtimer-client/src/main/java/org/chorem/jtimer/system/SystemInfoFactory.java 2013-07-19 13:36:34 UTC (rev 2905)
@@ -0,0 +1,94 @@
+/*
+ * #%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%
+ */
+
+package org.chorem.jtimer.system;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.bridj.Platform;
+import org.chorem.jtimer.system.macos.MacOSSystemInfo;
+import org.chorem.jtimer.system.unix.UnixSystemInfo;
+import org.chorem.jtimer.system.win32.Win32SystemInfo;
+
+/**
+ * Build system info determined from system.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class SystemInfoFactory {
+
+ /** log */
+ private static Log log = LogFactory.getLog(SystemInfoFactory.class);
+
+ /** Single instance */
+ protected static SystemInfo instance;
+
+ /**
+ * SystemInfoFactory Constructor.
+ */
+ protected SystemInfoFactory() {
+
+ }
+
+ /**
+ * Return system info depending on system.
+ *
+ * @return SystemInfo instance
+ * @see SystemInfo
+ * @throws UnsupportedSystemInfoException if system info is not supported
+ * for system
+ */
+ public static SystemInfo getSystemInfo()
+ throws UnsupportedSystemInfoException {
+
+ if (instance == null) {
+ String os = System.getProperty("os.name");
+
+ // log it
+ if (log.isInfoEnabled()) {
+ log.info("Try do build system info for system : " + os);
+ }
+
+ // try windows
+ if (Platform.isWindows()) {
+ instance = new Win32SystemInfo();
+ } else if (Platform.isLinux()) {
+ instance = new UnixSystemInfo();
+ } else if (Platform.isMacOSX()) {
+ instance = new MacOSSystemInfo();
+ } else {
+ // system unknown
+ throw new UnsupportedSystemInfoException(
+ "Can't get system info for " + os);
+ }
+ }
+
+ return instance;
+ }
+}
Property changes on: branches/ng-jtimer/jtimer-client/src/main/java/org/chorem/jtimer/system/SystemInfoFactory.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: branches/ng-jtimer/jtimer-client/src/main/java/org/chorem/jtimer/system/UnsupportedSystemInfoException.java
===================================================================
--- branches/ng-jtimer/jtimer-client/src/main/java/org/chorem/jtimer/system/UnsupportedSystemInfoException.java (rev 0)
+++ branches/ng-jtimer/jtimer-client/src/main/java/org/chorem/jtimer/system/UnsupportedSystemInfoException.java 2013-07-19 13:36:34 UTC (rev 2905)
@@ -0,0 +1,69 @@
+/*
+ * #%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%
+ */
+
+package org.chorem.jtimer.system;
+
+/**
+ * Exception thrown when system info is not available.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class UnsupportedSystemInfoException extends Exception {
+
+ /** serialVersionUID. */
+ private static final long serialVersionUID = 138458861335881500L;
+
+ /**
+ * Constructor.
+ *
+ * @param message message
+ * @param cause cause
+ */
+ public UnsupportedSystemInfoException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param message message
+ */
+ public UnsupportedSystemInfoException(String message) {
+ super(message);
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param cause cause.
+ */
+ public UnsupportedSystemInfoException(Throwable cause) {
+ super(cause);
+ }
+}
Property changes on: branches/ng-jtimer/jtimer-client/src/main/java/org/chorem/jtimer/system/UnsupportedSystemInfoException.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: branches/ng-jtimer/jtimer-client/src/main/java/org/chorem/jtimer/system/macos/ApplicationServices.java
===================================================================
--- branches/ng-jtimer/jtimer-client/src/main/java/org/chorem/jtimer/system/macos/ApplicationServices.java (rev 0)
+++ branches/ng-jtimer/jtimer-client/src/main/java/org/chorem/jtimer/system/macos/ApplicationServices.java 2013-07-19 13:36:34 UTC (rev 2905)
@@ -0,0 +1,66 @@
+/*
+ * #%L
+ * jTimer
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2010 - 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
+ * 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%
+ */
+
+package org.chorem.jtimer.system.macos;
+
+import org.bridj.BridJ;
+import org.bridj.ann.Library;
+
+/**
+ * Mac OS X Bridj library.
+ *
+ * @author chatellier
+ * @version $Revision$
+ * @since 1.3.2
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+@Library("ApplicationServices")
+public class ApplicationServices {
+ static {
+ BridJ.register();
+ }
+
+ /** Constants that specify an input event. */
+ public static final int kCGAnyInputEventType = ~0;
+ /** Specifies that an event source should use a private event state table. */
+ public static final int kCGEventSourceStatePrivate = -1;
+ /** Specifies that an event source should use the event state table that reflects the combined state of all event sources posting to the current user login session. */
+ public static final int kCGEventSourceStateCombinedSessionState = 0;
+ /** Specifies that an event source should use the event state table that reflects the combined state of all hardware event sources posting from the HID system. */
+ public static final int kCGEventSourceStateHIDSystemState = 1;
+
+ /**
+ * Returns the elapsed time since the last event for a Quartz event source.
+ *
+ * @param sourceStateId The source state to access
+ * @param eventType The event type to access
+ * @return the time in seconds since the previous input event of the specified type
+ *
+ * @see <a href="http://developer.apple.com/mac/library/documentation/Carbon/Reference/Quart…">Quartz API</a>
+ */
+ public static native double CGEventSourceSecondsSinceLastEventType(int source, int eventType);
+}
Property changes on: branches/ng-jtimer/jtimer-client/src/main/java/org/chorem/jtimer/system/macos/ApplicationServices.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: branches/ng-jtimer/jtimer-client/src/main/java/org/chorem/jtimer/system/macos/MacOSSystemInfo.java
===================================================================
--- branches/ng-jtimer/jtimer-client/src/main/java/org/chorem/jtimer/system/macos/MacOSSystemInfo.java (rev 0)
+++ branches/ng-jtimer/jtimer-client/src/main/java/org/chorem/jtimer/system/macos/MacOSSystemInfo.java 2013-07-19 13:36:34 UTC (rev 2905)
@@ -0,0 +1,56 @@
+/*
+ * #%L
+ * jTimer
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2010 - 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
+ * 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%
+ */
+
+package org.chorem.jtimer.system.macos;
+
+import org.chorem.jtimer.system.SystemInfo;
+
+/**
+ * MacOSSystemInfo
+ *
+ * Source : http://ochafik.free.fr/blog/?p=98#comment-17694
+ *
+ * @author chatellier
+ * @version $Revision$
+ * @since 1.3.2
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class MacOSSystemInfo implements SystemInfo {
+
+ /*
+ * @see org.chorem.jtimer.ui.system.SystemInfo#getIdleTime()
+ */
+ @Override
+ public long getIdleTime() {
+ double idleTimeSeconds = ApplicationServices
+ .CGEventSourceSecondsSinceLastEventType(
+ ApplicationServices.kCGEventSourceStateCombinedSessionState,
+ ApplicationServices.kCGAnyInputEventType);
+ return (long) (idleTimeSeconds * 1000);
+ }
+
+}
Property changes on: branches/ng-jtimer/jtimer-client/src/main/java/org/chorem/jtimer/system/macos/MacOSSystemInfo.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: branches/ng-jtimer/jtimer-client/src/main/java/org/chorem/jtimer/system/macos/package-info.java
===================================================================
--- branches/ng-jtimer/jtimer-client/src/main/java/org/chorem/jtimer/system/macos/package-info.java (rev 0)
+++ branches/ng-jtimer/jtimer-client/src/main/java/org/chorem/jtimer/system/macos/package-info.java 2013-07-19 13:36:34 UTC (rev 2905)
@@ -0,0 +1,28 @@
+/*
+ * #%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%
+ */
+/**
+ * Mac OS specific system info implementation.
+ */
+package org.chorem.jtimer.system.macos;
Property changes on: branches/ng-jtimer/jtimer-client/src/main/java/org/chorem/jtimer/system/macos/package-info.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: branches/ng-jtimer/jtimer-client/src/main/java/org/chorem/jtimer/system/package-info.java
===================================================================
--- branches/ng-jtimer/jtimer-client/src/main/java/org/chorem/jtimer/system/package-info.java (rev 0)
+++ branches/ng-jtimer/jtimer-client/src/main/java/org/chorem/jtimer/system/package-info.java 2013-07-19 13:36:34 UTC (rev 2905)
@@ -0,0 +1,28 @@
+/*
+ * #%L
+ * jTimer
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * 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
+ * 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%
+ */
+/**
+ * System interface using Bridj to get system information.
+ */
+package org.chorem.jtimer.system;
Property changes on: branches/ng-jtimer/jtimer-client/src/main/java/org/chorem/jtimer/system/package-info.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: branches/ng-jtimer/jtimer-client/src/main/java/org/chorem/jtimer/system/unix/UnixSystemInfo.java
===================================================================
--- branches/ng-jtimer/jtimer-client/src/main/java/org/chorem/jtimer/system/unix/UnixSystemInfo.java (rev 0)
+++ branches/ng-jtimer/jtimer-client/src/main/java/org/chorem/jtimer/system/unix/UnixSystemInfo.java 2013-07-19 13:36:34 UTC (rev 2905)
@@ -0,0 +1,111 @@
+/*
+ * #%L
+ * jTimer
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * 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
+ * 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%
+ */
+
+package org.chorem.jtimer.system.unix;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.bridj.Pointer;
+import org.chorem.jtimer.system.SystemInfo;
+
+/**
+ * Linux system info.
+ *
+ * Based on
+ * http://java.net/projects/jdic/sources/svn/content/trunk/src/incubator/syste… source code.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class UnixSystemInfo implements SystemInfo {
+
+ /** log. */
+ private static Log log = LogFactory.getLog(UnixSystemInfo.class);
+
+ /*
+ * @see org.chorem.jtimer.ui.system.SystemInfo#getIdleTime()
+ */
+ @Override
+ public long getIdleTime() {
+
+ long idleTime = 0;
+
+ try {
+ idleTime = getXssIdleTime();
+ } catch (Exception e) {
+ // TODO catch more specific exception
+ if (log.isErrorEnabled()) {
+ log.error("Can't detect idle time : ", e);
+ }
+ idleTime = 0;
+ }
+
+ return idleTime;
+ }
+
+ /**
+ * Get idle time via Xss.
+ *
+ * @return idle time
+ */
+ protected long getXssIdleTime() {
+
+ long idleTime = 0;
+
+ // get X11 display
+ X11.Display display = X11.XOpenDisplay(null);
+ if (display == null) {
+ log.error("Can't open X11 display");
+ } else {
+ // Display is opened
+ Pointer<Xss.XScreenSaverInfo> screenSaverInfo = Xss.XScreenSaverAllocInfo();
+
+ if (screenSaverInfo == null) {
+ log.error("Could not alloc screen saver info");
+ } else {
+ // get root window
+ X11.Window rootWindow = X11.XDefaultRootWindow(display);
+ int flag = Xss.XScreenSaverQueryInfo(display, rootWindow, screenSaverInfo);
+ if (flag == 0) {
+ log.error("Can't get user idle time");
+ } else {
+ idleTime = screenSaverInfo.get().idle();
+ }
+
+ // free resources
+ X11.XFree(screenSaverInfo);
+ }
+
+ // free resources
+ X11.XCloseDisplay(display);
+ }
+
+ return idleTime;
+ }
+
+}
Property changes on: branches/ng-jtimer/jtimer-client/src/main/java/org/chorem/jtimer/system/unix/UnixSystemInfo.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: branches/ng-jtimer/jtimer-client/src/main/java/org/chorem/jtimer/system/unix/X11.java
===================================================================
--- branches/ng-jtimer/jtimer-client/src/main/java/org/chorem/jtimer/system/unix/X11.java (rev 0)
+++ branches/ng-jtimer/jtimer-client/src/main/java/org/chorem/jtimer/system/unix/X11.java 2013-07-19 13:36:34 UTC (rev 2905)
@@ -0,0 +1,60 @@
+package org.chorem.jtimer.system.unix;
+
+import org.bridj.BridJ;
+import org.bridj.Pointer;
+import org.bridj.TypedPointer;
+import org.bridj.ann.Library;
+
+/**
+ * Unix X11 Bridj library.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+@Library("X11")
+public class X11 {
+ static {
+ BridJ.register();
+ }
+
+ public static class Drawable extends TypedPointer {
+ public Drawable(long peer) {
+ super(peer);
+ }
+
+ public Drawable(Pointer<?> ptr) {
+ super(ptr);
+ }
+ }
+
+ public static class Window extends Drawable {
+ public Window(long peer) {
+ super(peer);
+ }
+
+ public Window(Pointer<?> ptr) {
+ super(ptr);
+ }
+ }
+
+ public static class Display extends TypedPointer {
+ public Display(long peer) {
+ super(peer);
+ }
+
+ public Display(Pointer<?> ptr) {
+ super(ptr);
+ }
+ }
+
+ public static native Display XOpenDisplay(Pointer<Byte> name);
+
+ public static native Window XDefaultRootWindow(Display display);
+
+ public static native int XFree(Pointer data);
+
+ public static native int XCloseDisplay(Display display);
+}
Property changes on: branches/ng-jtimer/jtimer-client/src/main/java/org/chorem/jtimer/system/unix/X11.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: branches/ng-jtimer/jtimer-client/src/main/java/org/chorem/jtimer/system/unix/Xss.java
===================================================================
--- branches/ng-jtimer/jtimer-client/src/main/java/org/chorem/jtimer/system/unix/Xss.java (rev 0)
+++ branches/ng-jtimer/jtimer-client/src/main/java/org/chorem/jtimer/system/unix/Xss.java 2013-07-19 13:36:34 UTC (rev 2905)
@@ -0,0 +1,156 @@
+/*
+ * #%L
+ * jTimer
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * 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
+ * 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%
+ */
+
+package org.chorem.jtimer.system.unix;
+
+import org.bridj.BridJ;
+import org.bridj.Pointer;
+import org.bridj.StructObject;
+import org.bridj.ann.Field;
+import org.bridj.ann.Library;
+import org.bridj.ann.Ptr;
+
+/**
+ * Unix Xss Bridj library.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+@Library("Xss")
+public class Xss {
+ static {
+ BridJ.register();
+ }
+
+ public static class XScreenSaverInfo extends StructObject {
+ public XScreenSaverInfo() {
+ super();
+ }
+
+ public XScreenSaverInfo(Pointer pointer) {
+ super(pointer);
+ }
+
+ /**
+ * screen saver window<br>
+ * C type : Window
+ */
+ @Ptr
+ @Field(0)
+ public long window() {
+ return this.io.getSizeTField(this, 0);
+ }
+
+ /**
+ * screen saver window<br>
+ * C type : Window
+ */
+ @Ptr
+ @Field(0)
+ public XScreenSaverInfo window(long window) {
+ this.io.setSizeTField(this, 0, window);
+ return this;
+ }
+
+ // ScreenSaver{Off,On,Disabled}
+ @Field(1)
+ public int state() {
+ return this.io.getIntField(this, 1);
+ }
+
+ // ScreenSaver{Off,On,Disabled}
+ @Field(1)
+ public XScreenSaverInfo state(int state) {
+ this.io.setIntField(this, 1, state);
+ return this;
+ }
+
+ // ScreenSaver{Blanked,Internal,External}
+ @Field(2)
+ public int kind() {
+ return this.io.getIntField(this, 2);
+ }
+
+ // ScreenSaver{Blanked,Internal,External}
+ @Field(2)
+ public XScreenSaverInfo kind(int kind) {
+ this.io.setIntField(this, 2, kind);
+ return this;
+ }
+
+ // milliseconds
+ @org.bridj.ann.CLong
+ @Field(3)
+ public long til_or_since() {
+ return this.io.getCLongField(this, 3);
+ }
+
+ // milliseconds
+ @org.bridj.ann.CLong
+ @Field(3)
+ public XScreenSaverInfo til_or_since(long til_or_since) {
+ this.io.setCLongField(this, 3, til_or_since);
+ return this;
+ }
+
+ // milliseconds
+ @org.bridj.ann.CLong
+ @Field(4)
+ public long idle() {
+ return this.io.getCLongField(this, 4);
+ }
+
+ // milliseconds
+ @org.bridj.ann.CLong
+ @Field(4)
+ public XScreenSaverInfo idle(long idle) {
+ this.io.setCLongField(this, 4, idle);
+ return this;
+ }
+
+ // events
+ @org.bridj.ann.CLong
+ @Field(5)
+ public long event_mask() {
+ return this.io.getCLongField(this, 5);
+ }
+
+ // events
+ @org.bridj.ann.CLong
+ @Field(5)
+ public XScreenSaverInfo event_mask(long event_mask) {
+ this.io.setCLongField(this, 5, event_mask);
+ return this;
+ }
+ }
+
+ public static native Pointer<XScreenSaverInfo> XScreenSaverAllocInfo();
+
+ public static native int XScreenSaverQueryInfo(X11.Display dpy,
+ X11.Drawable drawable, Pointer<XScreenSaverInfo> saver_info);
+}
Property changes on: branches/ng-jtimer/jtimer-client/src/main/java/org/chorem/jtimer/system/unix/Xss.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: branches/ng-jtimer/jtimer-client/src/main/java/org/chorem/jtimer/system/unix/package-info.java
===================================================================
--- branches/ng-jtimer/jtimer-client/src/main/java/org/chorem/jtimer/system/unix/package-info.java (rev 0)
+++ branches/ng-jtimer/jtimer-client/src/main/java/org/chorem/jtimer/system/unix/package-info.java 2013-07-19 13:36:34 UTC (rev 2905)
@@ -0,0 +1,28 @@
+/*
+ * #%L
+ * jTimer
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * 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
+ * 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%
+ */
+/**
+ * Linux specific system info implementation.
+ */
+package org.chorem.jtimer.system.unix;
Property changes on: branches/ng-jtimer/jtimer-client/src/main/java/org/chorem/jtimer/system/unix/package-info.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: branches/ng-jtimer/jtimer-client/src/main/java/org/chorem/jtimer/system/win32/Kernel32.java
===================================================================
--- branches/ng-jtimer/jtimer-client/src/main/java/org/chorem/jtimer/system/win32/Kernel32.java (rev 0)
+++ branches/ng-jtimer/jtimer-client/src/main/java/org/chorem/jtimer/system/win32/Kernel32.java 2013-07-19 13:36:34 UTC (rev 2905)
@@ -0,0 +1,58 @@
+/*
+ * #%L
+ * jTimer
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2010 - 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
+ * 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%
+ */
+
+package org.chorem.jtimer.system.win32;
+
+import org.bridj.*;
+import org.bridj.ann.*;
+
+/**
+ * Win Kernel32 Bridj library.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+(a)Convention(Convention.Style.StdCall)
+@Library("kernel32")
+public class Kernel32 {
+ static {
+ BridJ.register();
+ }
+
+ /**
+ * Retrieves the number of milliseconds that have elapsed since the system
+ * was started.
+ *
+ * @see <a
+ * href="http://msdn2.microsoft.com/en-us/library/ms724408.aspx">MSDN
+ * GetTickCount function</a>
+ * @return number of milliseconds that have elapsed since the system was
+ * started.
+ */
+ public static native int GetTickCount();
+}
Property changes on: branches/ng-jtimer/jtimer-client/src/main/java/org/chorem/jtimer/system/win32/Kernel32.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: branches/ng-jtimer/jtimer-client/src/main/java/org/chorem/jtimer/system/win32/User32.java
===================================================================
--- branches/ng-jtimer/jtimer-client/src/main/java/org/chorem/jtimer/system/win32/User32.java (rev 0)
+++ branches/ng-jtimer/jtimer-client/src/main/java/org/chorem/jtimer/system/win32/User32.java 2013-07-19 13:36:34 UTC (rev 2905)
@@ -0,0 +1,80 @@
+/*
+ * #%L
+ * jTimer
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * 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
+ * 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%
+ */
+
+package org.chorem.jtimer.system.win32;
+
+import org.bridj.BridJ;
+import org.bridj.Pointer;
+import org.bridj.StructObject;
+import org.bridj.ann.Convention;
+import org.bridj.ann.Field;
+import org.bridj.ann.Library;
+
+/**
+ * Win User32 Bridj library.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+(a)Convention(Convention.Style.StdCall)
+@Library("user32")
+public class User32 {
+ static {
+ BridJ.register();
+ }
+
+ /**
+ * Contains the time of the last input.
+ *
+ * @see <a
+ * href="http://msdn.microsoft.com/en-us/library/ms646272">MSDN
+ * LASTINPUTINFO structure</a>
+ */
+ public static class LASTINPUTINFO extends StructObject {
+ @Field(0)
+ public int cbSize() {
+ return this.io.getIntField(this, 0);
+ }
+
+ // / Tick count of when the last input event was received.
+ @Field(1)
+ public int dwTime() {
+ return this.io.getIntField(this, 1);
+ }
+ }
+
+ /**
+ * Retrieves the time of the last input event.
+ *
+ * @see <a
+ * href="http://msdn.microsoft.com/en-us/library/ms646272">MSDN
+ * GetLastInputInfo function</a>
+ * @return time of the last input event, in milliseconds
+ */
+ public static native boolean GetLastInputInfo(Pointer<LASTINPUTINFO> result);
+}
Property changes on: branches/ng-jtimer/jtimer-client/src/main/java/org/chorem/jtimer/system/win32/User32.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: branches/ng-jtimer/jtimer-client/src/main/java/org/chorem/jtimer/system/win32/Win32SystemInfo.java
===================================================================
--- branches/ng-jtimer/jtimer-client/src/main/java/org/chorem/jtimer/system/win32/Win32SystemInfo.java (rev 0)
+++ branches/ng-jtimer/jtimer-client/src/main/java/org/chorem/jtimer/system/win32/Win32SystemInfo.java 2013-07-19 13:36:34 UTC (rev 2905)
@@ -0,0 +1,76 @@
+/*
+ * #%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%
+ */
+
+package org.chorem.jtimer.system.win32;
+
+import org.bridj.Pointer;
+import org.chorem.jtimer.system.SystemInfo;
+
+/**
+ * Win32 System info.
+ *
+ * From https://github.com/ochafik/nativelibs4java.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class Win32SystemInfo implements SystemInfo {
+
+ /** {@link User32.LASTINPUTINFO}. */
+ protected User32.LASTINPUTINFO lastInputInfo;
+
+ /**
+ * Constructor.
+ *
+ * Package visibility
+ */
+ public Win32SystemInfo() {
+ lastInputInfo = new User32.LASTINPUTINFO();
+ }
+
+ /**
+ * Get the amount of milliseconds that have elapsed since the last input
+ * event (mouse or keyboard)
+ *
+ * @return idle time in milliseconds
+ */
+ public int getIdleTimeMillisWin32() {
+ User32.LASTINPUTINFO lastInputInfo = new User32.LASTINPUTINFO();
+ User32.GetLastInputInfo(Pointer.pointerTo(lastInputInfo));
+ return Kernel32.GetTickCount() - lastInputInfo.dwTime();
+ }
+
+ /*
+ * @see org.chorem.jtimer.ui.system.SystemInfo#getIdleTime()
+ */
+ @Override
+ public long getIdleTime() {
+ long millisTime = getIdleTimeMillisWin32();
+ return millisTime;
+ }
+}
Property changes on: branches/ng-jtimer/jtimer-client/src/main/java/org/chorem/jtimer/system/win32/Win32SystemInfo.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: branches/ng-jtimer/jtimer-client/src/main/java/org/chorem/jtimer/system/win32/package-info.java
===================================================================
--- branches/ng-jtimer/jtimer-client/src/main/java/org/chorem/jtimer/system/win32/package-info.java (rev 0)
+++ branches/ng-jtimer/jtimer-client/src/main/java/org/chorem/jtimer/system/win32/package-info.java 2013-07-19 13:36:34 UTC (rev 2905)
@@ -0,0 +1,28 @@
+/*
+ * #%L
+ * jTimer
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * 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
+ * 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%
+ */
+/**
+ * Windows specific system info implementation.
+ */
+package org.chorem.jtimer.system.win32;
Property changes on: branches/ng-jtimer/jtimer-client/src/main/java/org/chorem/jtimer/system/win32/package-info.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: branches/ng-jtimer/jtimer-server/LICENSE.txt
===================================================================
Added: branches/ng-jtimer/jtimer-server/README.txt
===================================================================
Added: branches/ng-jtimer/jtimer-server/pom.xml
===================================================================
--- branches/ng-jtimer/jtimer-server/pom.xml (rev 0)
+++ branches/ng-jtimer/jtimer-server/pom.xml 2013-07-19 13:36:34 UTC (rev 2905)
@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.chorem</groupId>
+ <artifactId>jtimer</artifactId>
+ <version>2.0.0-SNAPSHOT</version>
+ </parent>
+
+ <groupId>org.chorem.jtimer</groupId>
+ <artifactId>jtimer-server</artifactId>
+ <packaging>jar</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.h2database</groupId>
+ <artifactId>h2</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.google.code.gson</groupId>
+ <artifactId>gson</artifactId>
+ <version>2.2.4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-servlet_3.0_spec</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <resources>
+ <resource>
+ <directory>src/main/webapp</directory>
+ <includes>
+ <include>web/*.html</include>
+ </includes>
+ </resource>
+ </resources>
+
+ <plugins>
+ <plugin>
+ <groupId>ro.isdc.wro4j</groupId>
+ <artifactId>wro4j-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <phase>generate-resources</phase>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ </executions>
+
+ <configuration>
+ <targetGroups>jtimer</targetGroups>
+ <contextFolder>${basedir}/src/main/webapp/web/</contextFolder>
+ <cssDestinationFolder>${basedir}/target/classes/web/css</cssDestinationFolder>
+ <jsDestinationFolder>${basedir}/target/classes/web/js</jsDestinationFolder>
+ <wroManagerFactory>org.nuiton.js.wro.NuitonJsMavenWroManagerFactory</wroManagerFactory>
+ <wroFile>${basedir}/src/main/config/wro.xml</wroFile>
+ <extraConfigFile>${basedir}/src/main/config/wro.properties</extraConfigFile>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
Property changes on: branches/ng-jtimer/jtimer-server/pom.xml
___________________________________________________________________
Added: svn:mime-type
+ text/xml
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: branches/ng-jtimer/jtimer-server/src/main/config/wro.properties
===================================================================
--- branches/ng-jtimer/jtimer-server/src/main/config/wro.properties (rev 0)
+++ branches/ng-jtimer/jtimer-server/src/main/config/wro.properties 2013-07-19 13:36:34 UTC (rev 2905)
@@ -0,0 +1,3 @@
+preProcessors=cssVariables,forceCssDataUri,cssUrlRewriting,cssImport,semicolonAppender
+postProcessors=
+#cssMinJawr,jsMin
Property changes on: branches/ng-jtimer/jtimer-server/src/main/config/wro.properties
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: branches/ng-jtimer/jtimer-server/src/main/config/wro.xml
===================================================================
--- branches/ng-jtimer/jtimer-server/src/main/config/wro.xml (rev 0)
+++ branches/ng-jtimer/jtimer-server/src/main/config/wro.xml 2013-07-19 13:36:34 UTC (rev 2905)
@@ -0,0 +1,9 @@
+<groups xmlns="http://www.isdc.ro/wro">
+ <group name='jtimer'>
+ <group-ref>angular</group-ref>
+ <group-ref>jquery</group-ref>
+ <group-ref>bootstrap</group-ref>
+ <css>/styles/*.css</css>
+ <js>/scripts/*.js</js>
+ </group>
+</groups>
Property changes on: branches/ng-jtimer/jtimer-server/src/main/config/wro.xml
___________________________________________________________________
Added: svn:mime-type
+ text/xml
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: branches/ng-jtimer/jtimer-server/src/main/java/org/chorem/jtimer/ProxyService.java
===================================================================
--- branches/ng-jtimer/jtimer-server/src/main/java/org/chorem/jtimer/ProxyService.java (rev 0)
+++ branches/ng-jtimer/jtimer-server/src/main/java/org/chorem/jtimer/ProxyService.java 2013-07-19 13:36:34 UTC (rev 2905)
@@ -0,0 +1,85 @@
+package org.chorem.jtimer;
+
+import java.io.IOException;
+import java.lang.reflect.Method;
+
+import javax.servlet.ServletException;
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.chorem.jtimer.storage.Storage;
+
+import com.google.gson.Gson;
+
+public class ProxyService extends HttpServlet {
+
+ /** serialVersionUID. */
+ private static final long serialVersionUID = -5180281013629027617L;
+
+ protected Storage storage;
+
+ protected Gson gson;
+
+ public ProxyService() {
+ storage = new Storage();
+ gson = new Gson();
+ }
+
+ @Override
+ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+ callMethod("get", req, resp);
+ }
+
+ @Override
+ protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+ callMethod("get", req, resp);
+ }
+
+ @Override
+ protected void doPut(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+ callMethod("get", req, resp);
+ }
+
+ @Override
+ protected void doDelete(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+ callMethod("get", req, resp);
+ }
+
+ protected void callMethod(String prefix, HttpServletRequest req, HttpServletResponse resp) throws IOException {
+
+ String contextPath = req.getContextPath();
+ String requestUri = req.getRequestURI();
+
+ String query = requestUri;
+ System.out.println("requestUri = " + requestUri);
+ if (query.startsWith("/rest/")) {
+ query = query.substring("/rest/".length());
+ }
+
+ String methodName = prefix + Character.toTitleCase(query.charAt(0)) + query.substring(1);
+ System.out.println("Callling method " + methodName);
+ Method[] methods = Storage.class.getMethods();
+ Method method = null;
+ for (Method m : methods) {
+ if (m.getName().equalsIgnoreCase(methodName)) {
+ method = m;
+ }
+ }
+
+ if (method == null) {
+ resp.sendError(HttpServletResponse.SC_NOT_FOUND);
+ } else {
+ try {
+ Object result = method.invoke(storage);
+ String json = gson.toJson(result);
+ resp.setContentType("application/json");
+ ServletOutputStream out = resp.getOutputStream();
+ out.print(json);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }
+}
Property changes on: branches/ng-jtimer/jtimer-server/src/main/java/org/chorem/jtimer/ProxyService.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: branches/ng-jtimer/jtimer-server/src/main/java/org/chorem/jtimer/entities/TimerProject.java
===================================================================
--- branches/ng-jtimer/jtimer-server/src/main/java/org/chorem/jtimer/entities/TimerProject.java (rev 0)
+++ branches/ng-jtimer/jtimer-server/src/main/java/org/chorem/jtimer/entities/TimerProject.java 2013-07-19 13:36:34 UTC (rev 2905)
@@ -0,0 +1,56 @@
+/*
+ * #%L
+ * jTimer
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2013 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%
+ */
+
+package org.chorem.jtimer.entities;
+
+/**
+ * Represent a project.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class TimerProject extends TimerTask {
+
+ /** serialVersionUID. */
+ private static final long serialVersionUID = -8953488997256237790L;
+
+ /**
+ * Constructor.
+ */
+ public TimerProject() {
+ }
+
+ /**
+ * Constructor with name.
+ *
+ * @param name project name
+ */
+ public TimerProject(String name) {
+ super(name);
+ }
+}
Property changes on: branches/ng-jtimer/jtimer-server/src/main/java/org/chorem/jtimer/entities/TimerProject.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: branches/ng-jtimer/jtimer-server/src/main/java/org/chorem/jtimer/entities/TimerTask.java
===================================================================
--- branches/ng-jtimer/jtimer-server/src/main/java/org/chorem/jtimer/entities/TimerTask.java (rev 0)
+++ branches/ng-jtimer/jtimer-server/src/main/java/org/chorem/jtimer/entities/TimerTask.java 2013-07-19 13:36:34 UTC (rev 2905)
@@ -0,0 +1,288 @@
+/*
+ * #%L
+ * jTimer
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2013 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%
+ */
+
+package org.chorem.jtimer.entities;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.SortedMap;
+import java.util.TreeMap;
+
+/**
+ * Represents a task.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class TimerTask implements Serializable {
+
+ /** serialVersionUID */
+ private static final long serialVersionUID = -7590755569706702695L;
+
+ /** Task number. */
+ protected long number;
+
+ /** Parent task number. */
+ protected long parent;
+
+ /** Task name. */
+ protected String name;
+
+ /** Creation date. */
+ protected Date creationDate;
+
+ /** Closed task. */
+ protected boolean closed;
+
+ /**
+ * Map calendar of day -> time (ms). (ordered on keys)
+ */
+ protected SortedMap<Date, Long> allDaysTimes;
+
+ /**
+ * Map date -> annotation text.
+ */
+ protected SortedMap<Date, String> allDaysAnnotations;
+
+ /**
+ * Sub tasks.
+ */
+ protected List<TimerTask> subTasks;
+
+ /**
+ * Constructor.
+ */
+ public TimerTask() {
+ //allDaysTimes = new DailySortedMap<Long>();
+ // les annoation sont à la seconde pres
+ allDaysAnnotations = new TreeMap<Date, String>();
+ subTasks = new ArrayList<TimerTask>();
+
+ // wrong value to detect bug
+ number = -1;
+ }
+
+ /**
+ * Constructor with name.
+ *
+ * @param name task name
+ */
+ public TimerTask(String name) {
+ this();
+ this.name = name;
+ }
+
+ /**
+ * Get task number.
+ *
+ * @return the number
+ */
+ public long getNumber() {
+ return number;
+ }
+
+ /**
+ * Set task number.
+ *
+ * @param number the number to set
+ */
+ public void setNumber(long number) {
+ this.number = number;
+ }
+
+ public long getParent() {
+ return parent;
+ }
+
+ public void setParent(long parent) {
+ this.parent = parent;
+ }
+
+ /**
+ * Get task name.
+ *
+ * @return the name
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Set task name.
+ *
+ * @param name the name to set
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ * Get task creation date.
+ *
+ * @return task creation date
+ */
+ public Date getCreationDate() {
+ return creationDate;
+ }
+
+ /**
+ * Set task creation date.
+ *
+ * @param creationDate creation date
+ */
+ public void setCreationDate(Date creationDate) {
+ this.creationDate = creationDate;
+ }
+
+ /**
+ * Get closed task state.
+ *
+ * @return <tt>true</tt> if task is closed
+ */
+ public boolean isClosed() {
+ return closed;
+ }
+
+ /**
+ * Set closed.
+ *
+ * @param closed closed
+ */
+ public void setClosed(boolean closed) {
+ this.closed = closed;
+ }
+
+ /**
+ * Get task's subtasks.
+ *
+ * @return the subTasks
+ */
+ public List<TimerTask> getSubTasks() {
+ return subTasks;
+ }
+
+ /**
+ * Add task's subtask.
+ *
+ * Also add parent reference.
+ *
+ * @param t the task to add
+ * @return success flag
+ */
+ public boolean addTask(TimerTask t) {
+ boolean result = subTasks.add(t);
+ return result;
+ }
+
+ /**
+ * Add time.
+ *
+ * @param date date
+ * @param time time in ms
+ */
+ public void setTime(Date date, Long time) {
+ allDaysTimes.put(date, time);
+ }
+
+ /**
+ * Get time at date.
+ *
+ * @param date date
+ * @return time at specified date in ms
+ */
+ public long getTime(Date date) {
+ long result = 0;
+
+ Long t = allDaysTimes.get(date);
+ if (t != null) {
+ result = t.longValue();
+ }
+
+ return result;
+ }
+
+ /**
+ * Return all data. Sorted on date.
+ *
+ * @return total duration of all projects
+ */
+ public SortedMap<Date, Long> getAllDaysAndTimes() {
+ return allDaysTimes;
+ }
+
+ /**
+ * Add annotation.
+ *
+ * @param date date
+ * @param note note text
+ */
+ public void addAnnotation(Date date, String note) {
+ allDaysAnnotations.put(date, note);
+ }
+
+ /**
+ * Return all annotation, sorted on date.
+ *
+ * @return annotations
+ */
+ public SortedMap<Date, String> getAllDaysAnnotations() {
+ return allDaysAnnotations;
+ }
+
+ /*
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString() {
+ return name + subTasks.toString();
+ }
+
+ /*
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ int result = (int)(number % 31);
+ return result;
+ }
+
+ /*
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object o) {
+
+ if (!(o instanceof TimerTask)) {
+ return false;
+ }
+
+ return number == ((TimerTask)o).getNumber();
+ }
+}
\ No newline at end of file
Property changes on: branches/ng-jtimer/jtimer-server/src/main/java/org/chorem/jtimer/entities/TimerTask.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: branches/ng-jtimer/jtimer-server/src/main/java/org/chorem/jtimer/storage/Storage.java
===================================================================
--- branches/ng-jtimer/jtimer-server/src/main/java/org/chorem/jtimer/storage/Storage.java (rev 0)
+++ branches/ng-jtimer/jtimer-server/src/main/java/org/chorem/jtimer/storage/Storage.java 2013-07-19 13:36:34 UTC (rev 2905)
@@ -0,0 +1,453 @@
+package org.chorem.jtimer.storage;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.SortedMap;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.jtimer.entities.TimerProject;
+import org.chorem.jtimer.entities.TimerTask;
+
+/**
+ * Implementation du stockage des taches en base de données basée sur h2.
+ *
+ * Le schema est composé des tables:
+ * <ul>
+ * <li>Task
+ * <li>TaskTime
+ * <li>Version (contenant la version du schema en cas de migration)</li>
+ * </ul>
+ *
+ * @author echatellier
+ */
+public class Storage {
+
+ private static final Log log = LogFactory.getLog(Storage.class);
+
+ protected static final String TABLE_TASK = "task";
+ protected static final String TABLE_TIME = "tasktime";
+ protected static final String TABLE_VERSION = "version";
+
+ protected Connection connection;
+
+ public Storage() {
+
+ try {
+ if (log.isDebugEnabled()) {
+ log.debug("Registering jdbc driver");
+ }
+ Class.forName("org.h2.Driver");
+ } catch (ClassNotFoundException e) {
+ if (log.isErrorEnabled()) {
+ log.fatal("Can't find h2 driver");
+ }
+ }
+
+ try {
+ connection = getConnection();
+ } catch (SQLException ex) {
+ throw new StorageException("Can't open database", ex);
+ }
+
+ if (getProjectsCount() == 0) {
+ addProject(new TimerProject("Test1"));
+ addProject(new TimerProject("Test2"));
+ addProject(new TimerProject("Test3"));
+ addProject(new TimerProject("Test4"));
+ }
+ }
+
+ @Override
+ protected void finalize() throws Throwable {
+ connection.close();
+ }
+
+ protected Connection getConnection() throws SQLException {
+
+ String url = "/tmp/jtimer/jtimer";
+ if (log.isInfoEnabled()) {
+ log.info("Opening connection to database : " + url);
+ }
+ Connection conn = DriverManager.getConnection("jdbc:h2:" + url, "sa",
+ "");
+ conn.setAutoCommit(true);
+
+ // test to create schema if it not already exists
+ boolean schemaExists = schemaExists(conn);
+ if (!schemaExists) {
+ if (log.isInfoEnabled()) {
+ log.info("Creating new database schema");
+ }
+ createSchema(conn);
+
+ // set new version in schema
+ Statement statement = conn.createStatement();
+ statement.executeUpdate("INSERT INTO VERSION VALUES('2.0')");
+ }
+
+ return conn;
+ }
+
+ protected void closeConnection(Connection conn) throws SQLException {
+ if (conn != null) {
+ conn.close();
+ }
+ }
+
+ protected void closeStatement(Statement stmt) {
+ if (stmt != null) {
+ try {
+ stmt.close();
+ } catch (SQLException ex) {
+ throw new StorageException("Can't close statement", ex);
+ }
+ }
+ }
+
+ /**
+ * Test if table "version" exists in database list.
+ *
+ * @param conn sql connection
+ * @return schema exists
+ */
+ protected boolean schemaExists(Connection conn) {
+ boolean found = false;
+ Statement statement = null;
+ try {
+ statement = conn.createStatement();
+ ResultSet rs = statement.executeQuery("SELECT table_name FROM information_schema.tables;");
+ while (rs.next()) {
+ String name = rs.getString(1);
+ if (TABLE_VERSION.equalsIgnoreCase(name)) {
+ found = true;
+ }
+ }
+ } catch (SQLException ex) {
+ throw new StorageException("Can't test schema", ex);
+ } finally {
+ closeStatement(statement);
+ }
+
+ return found;
+ }
+
+ protected void createSchema(Connection conn) {
+ Statement statement = null;
+ try {
+ statement = conn.createStatement();
+ statement.executeUpdate("CREATE TABLE " + TABLE_VERSION +
+ "(version VARCHAR(10))");
+ statement.executeUpdate("CREATE TABLE " + TABLE_TASK +
+ "(id LONG NOT NULL AUTO_INCREMENT PRIMARY KEY," +
+ " name VARCHAR(255) NOT NULL," +
+ " parent LONG DEFAULT 0," +
+ " hidden BOOLEAN," +
+ " note TEXT)");
+ statement.executeUpdate("CREATE TABLE " + TABLE_TIME +
+ "(taskid LONG NOT NULL REFERENCES " + TABLE_TASK + "(id)," +
+ " date DATE," +
+ " duration LONG," +
+ " PRIMARY KEY (taskid, date))");
+ } catch (SQLException ex) {
+ throw new StorageException("Can't create schema", ex);
+ } finally {
+ closeStatement(statement);
+ }
+
+ }
+
+ /**
+ * Find all project. (task with no parent, parent = 0).
+ *
+ * @return all projects
+ */
+ public int getProjectsCount() {
+ int result = 0;
+ Statement statement = null;
+ try {
+ statement = connection.createStatement();
+ ResultSet rs = statement.executeQuery("SELECT count(*) FROM " + TABLE_TASK +
+ " WHERE parent = 0");
+ if (rs.next()) {
+ result = rs.getInt(1);
+ }
+ } catch (SQLException ex) {
+ throw new StorageException("Can't get project count", ex);
+ } finally {
+ closeStatement(statement);
+ }
+ return result;
+ }
+
+ /**
+ * Find all project. (task with no parent, parent = 0).
+ *
+ * @return all projects
+ */
+ public List<TimerProject> getProjects() {
+ List<TimerProject> projects = new ArrayList<TimerProject>();
+ PreparedStatement statement = null;
+ try {
+ statement = connection.prepareStatement("SELECT * FROM " + TABLE_TASK +
+ " WHERE parent = 0 ORDER BY id");
+ ResultSet rs = statement.executeQuery();
+ while (rs.next()) {
+ TimerProject project = new TimerProject();
+ project.setNumber(rs.getInt("id"));
+ project.setName(rs.getString("name"));
+ projects.add(project);
+ }
+ } catch (SQLException ex) {
+ throw new StorageException("Can't get project", ex);
+ } finally {
+ closeStatement(statement);
+ }
+ return projects;
+ }
+
+ /**
+ * Find all project. (task with no parent, parent = 0).
+ *
+ * @return all projects
+ */
+ public TimerProject getProject(int offset) {
+ TimerProject project = null;
+ PreparedStatement statement = null;
+ try {
+ statement = connection.prepareStatement("SELECT * FROM " + TABLE_TASK +
+ " WHERE parent = 0 ORDER BY id LIMIT 1 OFFSET ?");
+ statement.setInt(1, offset);
+ ResultSet rs = statement.executeQuery();
+ if (rs.next()) {
+ project = new TimerProject();
+ project.setNumber(rs.getInt("id"));
+ project.setName(rs.getString("name"));
+ }
+ } catch (SQLException ex) {
+ throw new StorageException("Can't get project", ex);
+ } finally {
+ closeStatement(statement);
+ }
+ return project;
+ }
+
+ /**
+ * Find all project. (task with no parent, parent = 0).
+ *
+ * @return all projects
+ */
+ public int getTasksCount(TimerTask parent) {
+ int result = 0;
+ PreparedStatement statement = null;
+ try {
+ statement = connection.prepareStatement("SELECT count(*) FROM " + TABLE_TASK +
+ " WHERE parent = ?");
+ statement.setLong(1, parent.getNumber());
+ ResultSet rs = statement.executeQuery();
+ if (rs.next()) {
+ result = rs.getInt(1);
+ }
+ } catch (SQLException ex) {
+ throw new StorageException("Can't get task count", ex);
+ } finally {
+ closeStatement(statement);
+ }
+ return result;
+ }
+
+ public TimerTask getTasks(TimerTask parent, int offset) {
+ TimerTask task = null;
+ PreparedStatement statement = null;
+ try {
+ statement = connection.prepareStatement("SELECT * FROM " + TABLE_TASK +
+ " WHERE parent = ? ORDER BY id LIMIT 1 OFFSET ?");
+ statement.setLong(1, parent.getNumber());
+ statement.setLong(2, offset);
+ ResultSet rs = statement.executeQuery();
+ while (rs.next()) {
+ task = new TimerTask();
+ task.setNumber(rs.getInt("id"));
+ task.setName(rs.getString("name"));
+ }
+ } catch (SQLException ex) {
+ throw new StorageException("Can't get task", ex);
+ } finally {
+ closeStatement(statement);
+ }
+ return task;
+ }
+
+ /**
+ * Find sub tasks..
+ *
+ * @param parent parent task
+ * @return all sub tasks
+ */
+ public List<TimerTask> getTasks(TimerTask parent) {
+ List<TimerTask> tasks = new ArrayList<TimerTask>();
+ PreparedStatement statement = null;
+ try {
+ statement = connection.prepareStatement("SELECT * FROM " + TABLE_TASK +
+ " WHERE parent = ? ORDER BY id");
+ statement.setLong(1, parent.getNumber());
+ ResultSet rs = statement.executeQuery();
+ while (rs.next()) {
+ TimerTask task = new TimerTask();
+ task.setNumber(rs.getInt("id"));
+ task.setName(rs.getString("name"));
+ tasks.add(task);
+ }
+ } catch (SQLException ex) {
+ throw new StorageException("Can't get task", ex);
+ } finally {
+ closeStatement(statement);
+ }
+ return tasks;
+ }
+
+ public void addProject(TimerProject project) {
+ PreparedStatement statement = null;
+ try {
+ statement = connection.prepareStatement("INSERT INTO " +
+ TABLE_TASK + "(name, parent, hidden, note)" +
+ " VALUES (?, ?, ?, ?)", Statement.RETURN_GENERATED_KEYS);
+ statement.setString(1, project.getName());
+ statement.setLong(2, 0);
+ statement.setBoolean(3, project.isClosed());
+ statement.setString(4, null /*project.getNote()*/);
+ statement.executeUpdate();
+
+ // get generated id
+ ResultSet rs = statement.getGeneratedKeys();
+ if (rs.next()) {
+ project.setNumber(rs.getInt(1));
+ }
+ } catch (SQLException ex) {
+ throw new StorageException("Can't add project", ex);
+ } finally {
+ closeStatement(statement);
+ }
+ }
+
+ public void addTask(TimerTask task) {
+ PreparedStatement statement = null;
+ try {
+ statement = connection.prepareStatement("INSERT INTO " +
+ TABLE_TASK + "(name, parent, hidden, note)" +
+ " VALUES (?, ?, ?, ?)", Statement.RETURN_GENERATED_KEYS);
+ statement.setString(1, task.getName());
+ statement.setLong(2, task.getParent());
+ statement.setBoolean(3, task.isClosed());
+ statement.setString(4, null /*project.getNote()*/);
+ statement.executeUpdate();
+
+ // get generated id
+ ResultSet rs = statement.getGeneratedKeys();
+ if (rs.next()) {
+ task.setNumber(rs.getInt(1));
+ }
+ } catch (SQLException ex) {
+ throw new StorageException("Can't add project", ex);
+ } finally {
+ closeStatement(statement);
+ }
+ }
+
+ public void modifyProject(TimerProject project) {
+ modifyTask(project);
+ }
+
+ public void modifyTask(TimerTask task) {
+ PreparedStatement statement = null;
+ try {
+ statement = connection.prepareStatement("UPDATE " +
+ TABLE_TASK + " SET name=?, parent=?, hidden=?, note=?" +
+ " WHERE id = ?");
+ statement.setString(1, task.getName());
+ if (task.getParent() > 0) {
+ statement.setLong(2, 0);
+ } else {
+ statement.setLong(2, task.getParent());
+ }
+ statement.setBoolean(3, task.isClosed());
+ statement.setString(4, null /*project.getNote()*/);
+ statement.setLong(5, task.getNumber());
+ statement.executeUpdate();
+ } catch (SQLException ex) {
+ throw new StorageException("Can't modify task", ex);
+ } finally {
+ closeStatement(statement);
+ }
+ }
+
+ protected void saveTaskTimes(TimerTask task) throws SQLException {
+
+ // delete all
+ PreparedStatement statement = null;
+ try {
+ statement = connection.prepareStatement("DELETE " + TABLE_TIME +
+ " WHERE TASKID = ?");
+ statement.setLong(1, task.getNumber());
+ statement.executeUpdate();
+ } finally {
+ closeStatement(statement);
+ }
+
+ // add new
+ try {
+ statement = connection.prepareStatement("INSERT INTO " + TABLE_TIME +
+ "(taskid, date, duration)" +
+ " VALUES(?, ?, ?)");
+ SortedMap<Date, Long> taskTimes = task.getAllDaysAndTimes();
+ for (Map.Entry<Date, Long> taskTime : taskTimes.entrySet()) {
+ statement.setLong(1, task.getNumber());
+ statement.setDate(2, new java.sql.Date(taskTime.getKey().getTime()));
+ statement.setLong(3, taskTime.getValue());
+
+ statement.executeUpdate();
+ }
+ } finally {
+ closeStatement(statement);
+ }
+ }
+
+ public void deleteProject(TimerProject project) {
+ deleteTask(project);
+ }
+
+ public void deleteTask(TimerTask task) {
+ PreparedStatement statement = null;
+ try {
+ statement = connection.prepareStatement("DELETE FROM " +
+ TABLE_TASK + " WHERE id = ?");
+ statement.setLong(1, task.getNumber());
+ statement.executeUpdate();
+ } catch (SQLException ex) {
+ throw new StorageException("Can't delete project", ex);
+ } finally {
+ closeStatement(statement);
+ }
+ }
+
+ public void setAnnotation(TimerTask task, Date date, String annotation) {
+
+ }
+
+ public void setTaskTime(TimerTask task, Date date, Long time) {
+ try {
+ saveTaskTimes(task);
+ } catch (SQLException ex) {
+ throw new StorageException("Can't set task time", ex);
+ }
+ }
+
+}
\ No newline at end of file
Property changes on: branches/ng-jtimer/jtimer-server/src/main/java/org/chorem/jtimer/storage/Storage.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: branches/ng-jtimer/jtimer-server/src/main/java/org/chorem/jtimer/storage/StorageException.java
===================================================================
--- branches/ng-jtimer/jtimer-server/src/main/java/org/chorem/jtimer/storage/StorageException.java (rev 0)
+++ branches/ng-jtimer/jtimer-server/src/main/java/org/chorem/jtimer/storage/StorageException.java 2013-07-19 13:36:34 UTC (rev 2905)
@@ -0,0 +1,15 @@
+package org.chorem.jtimer.storage;
+
+public class StorageException extends RuntimeException {
+
+ /** serialVersionUID. */
+ private static final long serialVersionUID = -6544441950983775434L;
+
+ public StorageException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public StorageException(String message) {
+ super(message);
+ }
+}
\ No newline at end of file
Property changes on: branches/ng-jtimer/jtimer-server/src/main/java/org/chorem/jtimer/storage/StorageException.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: branches/ng-jtimer/jtimer-server/src/main/webapp/web/index.html
===================================================================
--- branches/ng-jtimer/jtimer-server/src/main/webapp/web/index.html (rev 0)
+++ branches/ng-jtimer/jtimer-server/src/main/webapp/web/index.html 2013-07-19 13:36:34 UTC (rev 2905)
@@ -0,0 +1,103 @@
+<!doctype html>
+<html ng-app="JTimerModule">
+ <head>
+ <title>jTimer (browser)</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+
+ <!-- <link type="text/css" rel="stylesheet" href="styles/jtimer.css" />
+ <link type="text/css" rel="stylesheet" href="//twitter.github.io/bootstrap/assets/css/bootstrap.css" />
+ <script type="text/javascript" src="//code.jquery.com/jquery-2.0.3.min.js"></script>
+ <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/angularjs/1.1.5/angular.min.js"></script>
+ <script type="text/javascript" src="scripts/app.js"></script>
+ <script type="text/javascript" src="scripts/controllers.js"></script> -->
+
+ <link type="text/css" rel="stylesheet" href="css/jtimer.css" />
+ <script type="text/javascript" src="js/jtimer.js"></script>
+ <script type="text/javascript" src="//angular-ui.github.io/bootstrap/ui-bootstrap-tpls-0.4.0.js"></script>
+
+ <script type="text/ng-template" id="tree_item_renderer_name.html">
+ <span class="badge" ng-class="{sync:'badge-success'}">T</span> {{project.name}}
+ </script>
+
+ <script type="text/ng-template" id="tree_item_renderer_details.html">
+ {{project.todayTime|time}} - {{project2.totalTime|time}}
+ </script>
+ </head>
+
+ <body ng-controller="JTimerController">
+ <div class="container-fluid">
+ <div class="row-fluid">
+ <div class="span8 names">
+ <ul class="mainTree">
+ <li class="title">
+ <div>Name</div>
+ </li>
+
+ <li class="task" ng-repeat="project in projects| orderBy: 'name'" ng-animate="'maintree'"
+ ng-include="'tree_item_renderer_name.html'"></li>
+ </ul>
+ </div>
+
+ <div class="span2 details">
+ <ul class="time today">
+ <li class="title">
+ <div>Total</div>
+ </li>
+
+ <li class="task" ng-repeat="project in projects| orderBy: 'name'" ng-animate="'maintree'"
+ ng-animate="'filtering'"
+ ng-include="'tree_item_renderer_details.html'"></li>
+ </ul>
+ </div>
+ <div class="span2 details">
+ <ul class="time total">
+ <li class="title">
+ <div>Total</div>
+ </li>
+
+ <li class="task" ng-repeat="project in projects| orderBy: 'name'" ng-animate="'maintree'"
+ ng-animate="'filtering'"
+ ng-include="'tree_item_renderer_details.html'"></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+
+ <div ng-controller="NewProjectCtrl">
+ <button class="btn" ng-click="open()">Nouveau projet</button>
+ <div modal="shouldBeOpen" close="close()" options="opts">
+ <div class="modal-header">
+ <h3>Nouveau projet</h3>
+ </div>
+ <div class="modal-body" ng-form="projectForm">
+ <label>
+ Nouveau projet : <input type="text" ng-model="name" placeholder="Name" required /></label>
+ <label class="checkbox">
+ <input type="checkbox" ng-model="sync" />
+ Synchroniser le projet sur chorem</label>
+ </div>
+ <div class="modal-footer">
+ <button class="btn" ng-click="cancel()">Annuler</button>
+ <button class="btn btn-primary" ng-click="valid()" ng-disabled="!projectForm.$valid">Valider</button>
+ </div>
+ </div>
+ </div>
+
+ <div ng-controller="NewProjectCtrl">
+ <button class="btn" ng-click="open()">Nouveau task</button>
+ <div modal="shouldBeOpen" close="close()" options="opts">
+ <div class="modal-header">
+ <h3>Nouvelle tâche</h3>
+ </div>
+ <div class="modal-body" ng-form="taskForm">
+ <label>
+ Nouvelle tâche : <input type="text" ng-model="name" placeholder="Name"/></label>
+ </div>
+ <div class="modal-footer">
+ <button class="btn" ng-click="cancel()">Annuler</button>
+ <button class="btn btn-primary" ng-click="valid()" ng-disabled="!taskForm.$valid">Valider</button>
+ </div>
+ </div>
+ </div>
+ </body>
+</html>
\ No newline at end of file
Added: branches/ng-jtimer/jtimer-server/src/main/webapp/web/scripts/app.js
===================================================================
--- branches/ng-jtimer/jtimer-server/src/main/webapp/web/scripts/app.js (rev 0)
+++ branches/ng-jtimer/jtimer-server/src/main/webapp/web/scripts/app.js 2013-07-19 13:36:34 UTC (rev 2905)
@@ -0,0 +1,25 @@
+var JTimerModule = angular.module('JTimerModule', ['ui.bootstrap']);
+
+function toHHMMSS(sec_num) {
+ //var sec_num = parseInt(this, 10); // don't forget the second parm
+ var hours = Math.floor(sec_num / 3600);
+ var minutes = Math.floor((sec_num - (hours * 3600)) / 60);
+ var seconds = sec_num - (hours * 3600) - (minutes * 60);
+
+ if (hours < 10) {hours = "0"+hours;}
+ if (minutes < 10) {minutes = "0"+minutes;}
+ if (seconds < 10) {seconds = "0"+seconds;}
+ var time = hours+':'+minutes+':'+seconds;
+ return time;
+}
+
+JTimerModule.filter('time', function() {
+ return function(input) {
+ /*var date = new Date(input);
+ return date.getUTCHours()
+ + ":" + date.getUTCMinutes()
+ + ":" + date.getUTCSeconds()
+ + "." + date.getUTCMilliseconds();*/
+ return toHHMMSS(input);
+ };
+});
Added: branches/ng-jtimer/jtimer-server/src/main/webapp/web/scripts/controllers.js
===================================================================
--- branches/ng-jtimer/jtimer-server/src/main/webapp/web/scripts/controllers.js (rev 0)
+++ branches/ng-jtimer/jtimer-server/src/main/webapp/web/scripts/controllers.js 2013-07-19 13:36:34 UTC (rev 2905)
@@ -0,0 +1,55 @@
+JTimerModule.controller('JTimerController', ['$scope', '$http', '$timeout',
+ function JTimerController($scope, $http, $timeout) {
+ $scope.projects;
+
+ $http.post("http://localhost:8888/rest/projects").
+ success(function(data, status, headers, config) {
+ $scope.projects = data;
+ });
+ }
+]);
+
+JTimerModule.controller('NewProjectCtrl', ['$scope', '$http', '$timeout',
+ function NewProjectCtrl($scope, $http, $timeout) {
+ $scope.open = function () {
+ $scope.shouldBeOpen = true;
+ };
+
+ $scope.cancel = function () {
+ $scope.shouldBeOpen = false;
+ };
+
+ $scope.valid = function () {
+ $scope.cancel();
+ $scope.projects.push({name: $scope.name, sync: $scope.sync});
+ };
+
+ $scope.items = ['item1', 'item2'];
+
+ $scope.opts = {
+ backdropFade: true,
+ dialogFade:true
+ };
+}]);
+
+JTimerModule.controller('NewTaskCtrl', ['$scope', '$http', '$timeout',
+ function NewTaskCtrl($scope, $http, $timeout) {
+ $scope.open = function () {
+ $scope.shouldBeOpen = true;
+ };
+
+ $scope.cancel = function () {
+ $scope.shouldBeOpen = false;
+ };
+
+ $scope.valid = function () {
+ $scope.shouldBeOpen = false;
+ };
+
+ $scope.items = ['item1', 'item2'];
+
+ $scope.opts = {
+ backdropFade: true,
+ dialogFade:true
+ };
+ }]);
Added: branches/ng-jtimer/jtimer-server/src/main/webapp/web/styles/jtimer.css
===================================================================
--- branches/ng-jtimer/jtimer-server/src/main/webapp/web/styles/jtimer.css (rev 0)
+++ branches/ng-jtimer/jtimer-server/src/main/webapp/web/styles/jtimer.css 2013-07-19 13:36:34 UTC (rev 2905)
@@ -0,0 +1,42 @@
+ul.mainTree, ul.time {
+ list-style: none outside none;
+
+}
+
+ul.mainTree .title, ul.time .title {
+ font-weight: bold;
+ border-bottom:1px black dotted;
+}
+
+
+
+
+
+
+
+/* Angular animations */
+.maintree-enter,
+.maintree-leave
+{
+ -webkit-transition: 425ms cubic-bezier(0.250, 0.250, 0.750, 0.750) all;
+ -moz-transition: 425ms cubic-bezier(0.250, 0.250, 0.750, 0.750) all;
+ -ms-transition: 425ms cubic-bezier(0.250, 0.250, 0.750, 0.750) all;
+ -o-transition: 425ms cubic-bezier(0.250, 0.250, 0.750, 0.750) all;
+ transition: 425ms cubic-bezier(0.250, 0.250, 0.750, 0.750) all;
+ position: relative;
+ display: block;
+}
+
+.maintree-enter.maintree-enter-active,
+.maintree-leave {
+ opacity: 1;
+ top: 0;
+ height: 30px;
+}
+
+.maintree-leave.maintree-leave-active,
+.maintree-enter {
+ opacity: 0;
+ top: -50px;
+ height: 0px;
+}
Property changes on: branches/ng-jtimer/jtimer-server/src/main/webapp/web/styles/jtimer.css
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: branches/ng-jtimer/pom.xml
===================================================================
--- branches/ng-jtimer/pom.xml (rev 0)
+++ branches/ng-jtimer/pom.xml 2013-07-19 13:36:34 UTC (rev 2905)
@@ -0,0 +1,124 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.nuiton</groupId>
+ <artifactId>mavenpom4redmine</artifactId>
+ <version>3.4.13</version>
+ </parent>
+
+ <groupId>org.chorem</groupId>
+ <artifactId>jtimer</artifactId>
+ <version>2.0.0-SNAPSHOT</version>
+ <packaging>pom</packaging>
+
+ <name>jTimer</name>
+ <description>jTimer - Time tracking tool.</description>
+ <url>http://maven-site.chorem.org/jtimer</url>
+ <inceptionYear>2007</inceptionYear>
+
+ <modules>
+ <module>jtimer-server</module>
+ <module>jtimer-client</module>
+ </modules>
+
+ <licenses>
+ <license>
+ <name>General Public License (GPL)</name>
+ <url>http://www.gnu.org/licenses/gpl.html</url>
+ <distribution>repo</distribution>
+ </license>
+ </licenses>
+
+ <properties>
+ <platform>chorem.org</platform>
+ <license.licenseName>gpl_v3</license.licenseName>
+ <javaVersion>1.7</javaVersion>
+ </properties>
+
+ <build>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>ro.isdc.wro4j</groupId>
+ <artifactId>wro4j-maven-plugin</artifactId>
+ <version>1.7.0</version>
+ <dependencies>
+ <dependency>
+ <groupId>org.nuiton.js</groupId>
+ <artifactId>nuiton-js-wro</artifactId>
+ <version>1.0.1-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.nuiton.js</groupId>
+ <artifactId>nuiton-js-angular</artifactId>
+ <version>1.1.5-1-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.nuiton.js</groupId>
+ <artifactId>nuiton-js-jquery</artifactId>
+ <version>2.0.2-1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.nuiton.js</groupId>
+ <artifactId>nuiton-js-bootstrap</artifactId>
+ <version>2.3.2-1</version>
+ </dependency>
+ <dependency>
+ <groupId>ro.isdc.wro4j</groupId>
+ <artifactId>wro4j-extensions</artifactId>
+ <version>1.7.0</version>
+ </dependency>
+ <dependency>
+ <groupId>com.google.javascript</groupId>
+ <artifactId>closure-compiler</artifactId>
+ <version>v20130603</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ </build>
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.resteasy</groupId>
+ <artifactId>tjws</artifactId>
+ <version>1.104</version>
+ </dependency>
+ <dependency>
+ <groupId>com.h2database</groupId>
+ <artifactId>h2</artifactId>
+ <version>1.3.172</version>
+ </dependency>
+ <dependency>
+ <groupId>com.nativelibs4java</groupId>
+ <artifactId>bridj</artifactId>
+ <classifier>c-only</classifier>
+ <version>0.6.2</version>
+ <exclusions>
+ <exclusion>
+ <artifactId>dx</artifactId>
+ <groupId>com.google.android.tools</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-servlet_3.0_spec</artifactId>
+ <version>1.0</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.oracle</groupId>
+ <artifactId>javafx</artifactId>
+ <version>2.2.3</version>
+ <scope>system</scope>
+ <systemPath>${java.home}/lib/jfxrt.jar</systemPath>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+</project>
Property changes on: branches/ng-jtimer/pom.xml
___________________________________________________________________
Added: svn:mime-type
+ text/xml
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
1
0
Author: echatellier
Date: 2013-07-12 09:34:24 +0200 (Fri, 12 Jul 2013)
New Revision: 2904
Url: http://chorem.org/projects/jtimer/repository/revisions/2904
Log:
Remove old branch
Removed:
branches/1.4.x-evol-657-bridj/
1
0
11 Jul '13
Author: echatellier
Date: 2013-07-11 23:34:52 +0200 (Thu, 11 Jul 2013)
New Revision: 2903
Url: http://chorem.org/projects/jtimer/repository/revisions/2903
Log:
Prepare 2.0.0 branch for html5 ui
Added:
branches/2.0.0-evol-499-storage/src/main/java/org/chorem/jtimer/system/
branches/2.0.0-evol-499-storage/src/main/java/org/chorem/jtimer/system/SystemInfo.java
branches/2.0.0-evol-499-storage/src/main/java/org/chorem/jtimer/system/SystemInfoFactory.java
branches/2.0.0-evol-499-storage/src/main/java/org/chorem/jtimer/system/UnsupportedSystemInfoException.java
branches/2.0.0-evol-499-storage/src/main/java/org/chorem/jtimer/system/macos/
branches/2.0.0-evol-499-storage/src/main/java/org/chorem/jtimer/system/package-info.java
branches/2.0.0-evol-499-storage/src/main/java/org/chorem/jtimer/system/unix/
branches/2.0.0-evol-499-storage/src/main/java/org/chorem/jtimer/system/win32/
branches/2.0.0-evol-499-storage/src/test/java/org/chorem/jtimer/system/
Removed:
branches/2.0.0-evol-499-storage/src/main/java/org/chorem/jtimer/JTimer.java
branches/2.0.0-evol-499-storage/src/main/java/org/chorem/jtimer/JTimerFactory.java
branches/2.0.0-evol-499-storage/src/main/java/org/chorem/jtimer/ui/
branches/2.0.0-evol-499-storage/src/main/java/org/chorem/jtimer/utils/
branches/2.0.0-evol-499-storage/src/test/java/org/chorem/jtimer/ui/
branches/2.0.0-evol-499-storage/src/test/java/org/chorem/jtimer/utils/
Modified:
branches/2.0.0-evol-499-storage/pom.xml
branches/2.0.0-evol-499-storage/src/main/java/org/chorem/jtimer/JTimerActions.java
branches/2.0.0-evol-499-storage/src/main/java/org/chorem/jtimer/JTimerConfig.java
branches/2.0.0-evol-499-storage/src/main/java/org/chorem/jtimer/data/TimerCore.java
branches/2.0.0-evol-499-storage/src/main/java/org/chorem/jtimer/entities/TimerTask.java
branches/2.0.0-evol-499-storage/src/main/java/org/chorem/jtimer/system/macos/ApplicationServices.java
branches/2.0.0-evol-499-storage/src/main/java/org/chorem/jtimer/system/macos/MacOSSystemInfo.java
branches/2.0.0-evol-499-storage/src/main/java/org/chorem/jtimer/system/macos/package-info.java
branches/2.0.0-evol-499-storage/src/main/java/org/chorem/jtimer/system/unix/UnixSystemInfo.java
branches/2.0.0-evol-499-storage/src/main/java/org/chorem/jtimer/system/unix/X11.java
branches/2.0.0-evol-499-storage/src/main/java/org/chorem/jtimer/system/unix/Xss.java
branches/2.0.0-evol-499-storage/src/main/java/org/chorem/jtimer/system/unix/package-info.java
branches/2.0.0-evol-499-storage/src/main/java/org/chorem/jtimer/system/win32/Kernel32.java
branches/2.0.0-evol-499-storage/src/main/java/org/chorem/jtimer/system/win32/User32.java
branches/2.0.0-evol-499-storage/src/main/java/org/chorem/jtimer/system/win32/Win32SystemInfo.java
branches/2.0.0-evol-499-storage/src/main/java/org/chorem/jtimer/system/win32/package-info.java
branches/2.0.0-evol-499-storage/src/test/java/org/chorem/jtimer/AbstractJTimerTest.java
branches/2.0.0-evol-499-storage/src/test/java/org/chorem/jtimer/JTimerFactoryTest.java
branches/2.0.0-evol-499-storage/src/test/java/org/chorem/jtimer/entities/TimerTaskTest.java
branches/2.0.0-evol-499-storage/src/test/java/org/chorem/jtimer/storage/StorageTest.java
branches/2.0.0-evol-499-storage/src/test/java/org/chorem/jtimer/system/SystemInfoFactoryTest.java
Modified: branches/2.0.0-evol-499-storage/pom.xml
===================================================================
--- branches/2.0.0-evol-499-storage/pom.xml 2013-07-11 20:30:35 UTC (rev 2902)
+++ branches/2.0.0-evol-499-storage/pom.xml 2013-07-11 21:34:52 UTC (rev 2903)
@@ -1,16 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.nuiton</groupId>
<artifactId>mavenpom4redmine</artifactId>
- <version>3.4</version>
+ <version>3.4.12</version>
</parent>
<groupId>org.chorem</groupId>
<artifactId>jtimer</artifactId>
- <version>1.4.2-SNAPSHOT</version>
+ <version>2.0.0-SNAPSHOT</version>
<name>jTimer</name>
<description>
@@ -78,25 +79,17 @@
</distributionManagement>
<properties>
-
- <!-- redmine platform -->
<platform>chorem.org</platform>
+ <license.licenseName>gpl_v3</license.licenseName>
- <!--Main class in JAR -->
+ <javaVersion>1.7</javaVersion>
<maven.jar.main.class>org.chorem.jtimer.JTimer</maven.jar.main.class>
+ <seleniumVersion>2.33.0</seleniumVersion>
- <!-- license to use -->
- <license.licenseName>gpl_v3</license.licenseName>
-
- <!--Multilanguage maven-site -->
- <locales>fr,en</locales>
-
- <!-- files to deploy to redmine -->
<redmine.releaseFiles>
target/${project.artifactId}-${project.version}-bin.zip,
target/${project.artifactId}-${project.version}-src.zip,
</redmine.releaseFiles>
-
</properties>
<build>
@@ -136,8 +129,74 @@
</execution>
</executions>
</plugin>
+ <plugin>
+ <groupId>ro.isdc.wro4j</groupId>
+ <artifactId>wro4j-maven-plugin</artifactId>
+ <version>1.7.0</version>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.nuiton.js</groupId>
+ <artifactId>nuiton-js-wro</artifactId>
+ <version>1.0.1-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.nuiton.js</groupId>
+ <artifactId>nuiton-js-angular</artifactId>
+ <version>1.1.5-1-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.nuiton.js</groupId>
+ <artifactId>nuiton-js-bootstrap</artifactId>
+ <version>2.3.2-1</version>
+ </dependency>
+ </dependencies>
+
+ <executions>
+ <execution>
+ <phase>compile</phase>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ </executions>
+
+ <configuration>
+ <targetGroups>jtimer</targetGroups>
+ <minimize>false</minimize>
+ <destinationFolder>${basedir}/target/classes/html/</destinationFolder>
+ <contextFolder>${basedir}/src/main/resources/html/</contextFolder>
+ <wroFile>${basedir}/src/main/resources/nuiton-js/wro.xml</wroFile>
+ <wroManagerFactory>org.nuiton.js.wro.NuitonJsMavenWroManagerFactory</wroManagerFactory>
+ <extraConfigFile>${basedir}/src/main/resources/nuiton-js/wro.properties</extraConfigFile>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-maven-plugin</artifactId>
+ <version>9.0.4.v20130625</version>
+ <executions>
+ <execution>
+ <id>start-jetty</id>
+ <phase>pre-integration-test</phase>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <configuration>
+ <daemon>true</daemon>
+ </configuration>
+ </execution>
+ <execution>
+ <id>stop-jetty</id>
+ <phase>post-integration-test</phase>
+ <goals>
+ <goal>stop</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
</plugins>
-
+
<pluginManagement>
<plugins>
<plugin>
@@ -154,6 +213,9 @@
</plugin>
<plugin>
<artifactId>maven-site-plugin</artifactId>
+ <configuration>
+ <locales>en</locales>
+ </configuration>
<dependencies>
<dependency>
<groupId>org.nuiton.jrst</groupId>
@@ -166,40 +228,11 @@
</pluginManagement>
</build>
- <reporting>
- <plugins>
- <plugin>
- <artifactId>maven-checkstyle-plugin</artifactId>
- <version>2.9.1</version>
- <configuration>
- <configLocation>${maven.src.dir}/main/config/checkstyle.xml
- </configLocation>
- <excludes>**/Xss.java,**/User32.java,**/ApplicationServices.java</excludes>
- </configuration>
- </plugin>
-
- <plugin>
- <artifactId>maven-changelog-plugin</artifactId>
- <version>2.2</version>
- <configuration>
- <type>range</type>
- <range>365</range>
- </configuration>
- </plugin>
-
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>cobertura-maven-plugin</artifactId>
- <version>2.5.1</version>
- </plugin>
- </plugins>
- </reporting>
-
<dependencies>
<dependency>
<groupId>org.nuiton</groupId>
- <artifactId>nuiton-utils</artifactId>
- <version>2.5.3</version>
+ <artifactId>nuiton-config</artifactId>
+ <version>2.6.12</version>
<scope>compile</scope>
<exclusions>
<exclusion>
@@ -214,35 +247,33 @@
<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>
- <scope>compile</scope>
- <exclusions>
<exclusion>
- <groupId>javax.jnlp</groupId>
- <artifactId>jnlp</artifactId>
+ <artifactId>commons-vfs2</artifactId>
+ <groupId>org.apache.commons</groupId>
</exclusion>
+ <exclusion>
+ <artifactId>guava</artifactId>
+ <groupId>com.google.guava</groupId>
+ </exclusion>
+ <exclusion>
+ <artifactId>commons-collections</artifactId>
+ <groupId>commons-collections</groupId>
+ </exclusion>
+ <exclusion>
+ <artifactId>commons-io</artifactId>
+ <groupId>commons-io</groupId>
+ </exclusion>
</exclusions>
</dependency>
<dependency>
- <groupId>org.swinglabs.swingx</groupId>
- <artifactId>swingx-core</artifactId>
- <version>1.6.4</version>
- <scope>compile</scope>
- </dependency>
- <dependency>
<groupId>com.nativelibs4java</groupId>
<artifactId>bridj</artifactId>
- <version>0.6.1</version>
+ <version>0.6.2</version>
<scope>compile</scope>
<exclusions>
<exclusion>
+ <artifactId>dx</artifactId>
<groupId>com.google.android.tools</groupId>
- <artifactId>dx</artifactId>
</exclusion>
</exclusions>
</dependency>
@@ -252,23 +283,21 @@
<scope>runtime</scope>
</dependency>
<dependency>
- <groupId>org.freemarker</groupId>
- <artifactId>freemarker</artifactId>
- <version>2.3.19</version>
- </dependency>
- <dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
- <version>1.3.168</version>
+ <version>1.3.172</version>
<scope>runtime</scope>
</dependency>
+ <dependency>
+ <groupId>com.oracle</groupId>
+ <artifactId>javafx</artifactId>
+ <version>2.2.25</version>
+ <scope>system</scope>
+ <systemPath>${java.home}/lib/jfxrt.jar</systemPath>
+ </dependency>
<!-- commons-xxx lib -->
<dependency>
- <groupId>commons-collections</groupId>
- <artifactId>commons-collections</artifactId>
- </dependency>
- <dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
@@ -277,23 +306,49 @@
<artifactId>commons-logging</artifactId>
</dependency>
<dependency>
+ <artifactId>commons-io</artifactId>
<groupId>commons-io</groupId>
- <artifactId>commons-io</artifactId>
</dependency>
- <!-- tests dependencies -->
+ <!-- tests -->
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
- <version>6.7</version>
+ <version>6.8.5</version>
<scope>test</scope>
<exclusions>
- <exclusion>
- <artifactId>junit</artifactId>
- <groupId>junit</groupId>
- </exclusion>
+ <exclusion>
+ <artifactId>junit</artifactId>
+ <groupId>junit</groupId>
+ </exclusion>
</exclusions>
</dependency>
+ <dependency>
+ <groupId>org.easytesting</groupId>
+ <artifactId>fest-assert-core</artifactId>
+ <version>2.0M10</version>
+ <scope>test</scope>
+ </dependency>
+
+ <!-- integration-tests -->
+ <dependency>
+ <groupId>org.seleniumhq.selenium</groupId>
+ <artifactId>selenium-java</artifactId>
+ <version>${seleniumVersion}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.seleniumhq.selenium</groupId>
+ <artifactId>selenium-firefox-driver</artifactId>
+ <version>${seleniumVersion}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.seleniumhq.selenium</groupId>
+ <artifactId>selenium-chrome-driver</artifactId>
+ <version>${seleniumVersion}</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<profiles>
@@ -325,7 +380,7 @@
<jar>jtimer.jar</jar>
<errTitle>${project.name}</errTitle>
<jre>
- <minVersion>1.6.0</minVersion>
+ <minVersion>1.7.0</minVersion>
</jre>
</configuration>
</execution>
Deleted: branches/2.0.0-evol-499-storage/src/main/java/org/chorem/jtimer/JTimer.java
===================================================================
--- branches/2.0.0-evol-499-storage/src/main/java/org/chorem/jtimer/JTimer.java 2013-07-11 20:30:35 UTC (rev 2902)
+++ branches/2.0.0-evol-499-storage/src/main/java/org/chorem/jtimer/JTimer.java 2013-07-11 21:34:52 UTC (rev 2903)
@@ -1,1476 +0,0 @@
-/*
- * #%L
- * jTimer
- *
- * $Id$
- * $HeadURL$
- * %%
- * 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
- * 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%
- */
-
-package org.chorem.jtimer;
-
-import java.awt.BorderLayout;
-import java.awt.Dimension;
-import java.awt.Toolkit;
-import java.awt.event.ActionEvent;
-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;
-import java.util.Timer;
-
-import javax.swing.ButtonGroup;
-import javax.swing.InputMap;
-import javax.swing.JButton;
-import javax.swing.JCheckBoxMenuItem;
-import javax.swing.JComponent;
-import javax.swing.JFrame;
-import javax.swing.JMenu;
-import javax.swing.JMenuBar;
-import javax.swing.JMenuItem;
-import javax.swing.JOptionPane;
-import javax.swing.JPanel;
-import javax.swing.JPopupMenu;
-import javax.swing.JRadioButtonMenuItem;
-import javax.swing.JScrollPane;
-import javax.swing.JSeparator;
-import javax.swing.JToolBar;
-import javax.swing.KeyStroke;
-import javax.swing.ListSelectionModel;
-import javax.swing.event.TreeSelectionEvent;
-import javax.swing.event.TreeSelectionListener;
-import javax.swing.tree.TreePath;
-
-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;
-import org.chorem.jtimer.data.TimerCore;
-import org.chorem.jtimer.entities.TimerProject;
-import org.chorem.jtimer.entities.TimerTask;
-import org.chorem.jtimer.ui.HelpFrame;
-import org.chorem.jtimer.ui.StatusBar;
-import org.chorem.jtimer.ui.TimerTaskEditor;
-import org.chorem.jtimer.ui.alert.AlertEditor;
-import org.chorem.jtimer.ui.report.ReportView;
-import org.chorem.jtimer.ui.systray.SystrayManager;
-import org.chorem.jtimer.ui.tasks.IdleDialog;
-import org.chorem.jtimer.ui.tasks.RefreshTreeTask;
-import org.chorem.jtimer.ui.tasks.RunTaskJob;
-import org.chorem.jtimer.ui.treetable.ProjectsAndTasksTable;
-import org.chorem.jtimer.ui.widget.WindowProperty2;
-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;
-import org.jdesktop.application.Task;
-import org.jdesktop.application.TaskMonitor;
-
-/**
- * Main jTimer application window.
- *
- * Respect JSR-296
- *
- * @author chatellier
- * @version $Revision$
- *
- * Last update : $Date$
- * By : $Author$
- */
-public class JTimer extends SingleFrameApplication implements
- TreeSelectionListener, MouseListener {
-
- /** log. */
- private static Log log = LogFactory.getLog(JTimer.class);
-
- /** Timer core controller. */
- protected TimerCore core;
-
- /** Tree structure. */
- protected ProjectsAndTasksTable projectsAndTasksTable;
-
- /** Systray manager. */
- protected SystrayManager systrayManager;
-
- /** I18n resources map. */
- protected ResourceMap resourceMap;
-
- /** Jtimer application config. */
- public static JTimerConfig config;
-
- /** Single project selection property. */
- protected boolean selectedSingleProject;
-
- /** Single task selection property. */
- protected boolean selectedSingleTask;
-
- /** Single task or project selection. */
- protected boolean selectedSingleElement;
-
- /** Single running task selection. */
- protected boolean selectedSingleRunningTask;
-
- /** Single non running task selection. */
- protected boolean selectedSingleStoppedTask;
-
- /** Multiples projects selection. */
- protected boolean selectedMultiplesProjects;
-
- /** Multiples tasks selection. */
- protected boolean selectedMultiplesTasks;
-
- /** Multiples elements selection. */
- protected boolean selectedMultiplesElements;
-
- /**
- * Main. launch UI
- *
- * @param args args
- */
- public static void main(String[] args) {
-
- if (log.isInfoEnabled()) {
- log.info("Starting " + JTimer.class.getSimpleName() + " at "
- + new Date());
- }
-
- // load configuration and run actions
- loadConfiguration(args);
- config.doAction(JTimerConfig.STEP_BEFORE_UI);
-
- launch(JTimer.class, args);
- }
-
- /**
- * Initialize application. Called before UI build.
- *
- * @param args args
- * @see Application#initialize(String[])
- */
- @Override
- protected void initialize(String[] args) {
-
- // super, but does nothing
- super.initialize(args);
-
- // init resources map
- ApplicationContext ctxt = getContext();
- resourceMap = ctxt.getResourceMap();
-
- // fixme awt application name. Can be seen only with gnome-shell
- // tray icon is displayed with name "org-chorem-jtimer-JTimer" instead of
- // only "jTimer" with following fix :
- try {
- Toolkit xToolkit = Toolkit.getDefaultToolkit();
- java.lang.reflect.Field awtAppClassNameField = xToolkit.getClass().getDeclaredField("awtAppClassName");
- awtAppClassNameField.setAccessible(true);
- awtAppClassNameField.set(xToolkit, resourceMap.getString("Application.title"));
- } catch (Exception ex) {
- if (log.isWarnEnabled()) {
- log.warn("Can change awt application name", ex);
- }
- }
-
- // fix start in iconified mode
- ctxt.getSessionStorage().putProperty(JFrame.class, new WindowProperty2());
-
- // init timercore
- core = new TimerCore();
-
- // Systray mgr
- systrayManager = new SystrayManager(this);
- core.getData().addDataEventListener(systrayManager);
-
- IdleDialog.init(this);
- }
-
- /**
- * Load configuration.
- *
- * @param args args to parse command line options
- */
- protected static 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.getUserConfigDirectory(), 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.
- *
- * @see Application#startup()
- */
- @Override
- protected void startup() {
-
- // set Menu Bar
- getMainFrame().setJMenuBar(createMenuBar());
-
- // show main panel components
- show(createMainComponent());
-
- }
-
- /**
- * Create main component.
- *
- * Toolbar on top. Tree middle. Status bar on bottom.
- *
- * @return The component
- */
- protected JComponent createMainComponent() {
-
- // panel = main component
- JPanel panel = new JPanel(new BorderLayout());
-
- // toolbar on top (north)
- panel.add(createToolBar(), BorderLayout.NORTH);
-
- // tree middle (center-top)
- ProjectsAndTasksTable projectTreeTable = createTreeTable();
- JScrollPane scrollPaneProjectTreeTable = new JScrollPane(
- projectTreeTable);
- panel.add(scrollPaneProjectTreeTable, BorderLayout.CENTER);
-
- // status bar bottom
- StatusBar sb = new StatusBar(this, core.getData());
- // status bar ui will be notified from events
- core.getData().addDataEventListener(sb);
- panel.add(sb, BorderLayout.SOUTH);
-
- // taille par defaut au premier lancement de l'application
- // sera ecrasee par la restauration de la session
- panel.setPreferredSize(new Dimension(640, 480));
-
- return panel;
- }
-
- /**
- * Create complex tree table.
- *
- * @return ProjectsAndTaskTable instance
- */
- protected ProjectsAndTasksTable createTreeTable() {
-
- projectsAndTasksTable = new ProjectsAndTasksTable(this, core);
-
- // name used in properties files
- projectsAndTasksTable.setName("projectslist");
- projectsAndTasksTable.addTreeSelectionListener(this);
- projectsAndTasksTable.addMouseListener(this);
- projectsAndTasksTable.setShowClosed(config.isShowClosed());
-
- // since merge option, selection can be multiple
- projectsAndTasksTable
- .setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
-
- // remove F2 KeyStroke from table
- KeyStroke keyToRemove = KeyStroke.getKeyStroke(KeyEvent.VK_F2, 0);
- InputMap imap = projectsAndTasksTable.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
- while (imap != null) {
- imap.remove(keyToRemove);
- imap = imap.getParent();
- }
-
- return projectsAndTasksTable;
- }
-
- /**
- * Create toolbar.
- *
- * @return tool bar builded
- */
- protected JComponent createToolBar() {
- String[] toolbarActionNames = { "startTask", "stopTask", "newProject",
- "newTask", "---", "addAnnotation", "editAlert" };
- JToolBar toolBar = new JToolBar();
- toolBar.setFloatable(false);
- for (String actionName : toolbarActionNames) {
-
- if (actionName.equals("---")) {
- toolBar.add(new JToolBar.Separator());
- } else {
- JButton button = new JButton();
- button.setAction(getAction(actionName));
-
- // hide text
- // button.setVerticalTextPosition(JButton.BOTTOM);
- // button.setHorizontalTextPosition(JButton.CENTER);
- button.setHideActionText(true);
-
- button.setFocusable(false);
- toolBar.add(button);
- }
- }
- return toolBar;
- }
-
- /**
- * Create application menu bar.
- *
- * @return menu bar
- */
- protected JMenuBar createMenuBar() {
-
- JMenuBar menuBar = new JMenuBar();
- String[] fileMenuActionNames = { "quit" };
- menuBar.add(createMenu("fileMenu", fileMenuActionNames));
-
- String[] projectMenuActionNames = { "newProject", "editProject",
- "closeProject", "deleteProject" };
- menuBar.add(createMenu("projectMenu", projectMenuActionNames));
-
- String[] taskMenuActionNames = { "newTask", "editTask", "closeTask",
- "deleteTask", "---", "startTask", "stopTask", "---",
- "addAnnotation", "editAlert", "increment1Task",
- "increment5Task", "increment30Task", "decrement1Task",
- "decrement5Task", "decrement30Task", "setToZero", "mergeTasks" };
- menuBar.add(createMenu("taskMenu", taskMenuActionNames));
-
- String[] reportMenuActionNames = { "makeReport" };
- menuBar.add(createMenu("reportMenu", reportMenuActionNames));
-
- JMenu optionmMenu = createOptionMenu();
- menuBar.add(optionmMenu);
-
- String[] helpMenuActionNames = { "about" };
- menuBar.add(createMenu("helpMenu", helpMenuActionNames));
-
- return menuBar;
- }
-
- /**
- * Create option dynamic menu.
- *
- * @return option menu
- */
- protected JMenu createOptionMenu() {
- JMenu menu = new JMenu();
- menu.setName("optionMenu");
-
- // show closed
- JMenuItem showClosedItem = new JCheckBoxMenuItem();
- showClosedItem.setAction(getAction("isShowClosed"));
- showClosedItem.setSelected(config.isShowClosed());
- showClosedItem.setIcon(null);
- menu.add(showClosedItem);
-
- // close to systray
- JMenuItem closeToSysItem = new JCheckBoxMenuItem();
- closeToSysItem.setAction(getAction("isCloseToSystray"));
- closeToSysItem.setSelected(config.isCloseToSystray());
- closeToSysItem.setIcon(null);
- menu.add(closeToSysItem);
-
- // report first day of week
- JMenu reportFDoW = new JMenu();
- reportFDoW.setName("optionReportFirstDayMenu");
- Calendar calendar = Calendar.getInstance();
- ButtonGroup bg = new ButtonGroup();
- // affiche la liste des jours dans l'ordre de la locale utilisateur
- for (int day = calendar.getFirstDayOfWeek() ; day < calendar.getFirstDayOfWeek() + 7 ; day++) {
- int realDay = (day - 1) % 7 + 1;
- JRadioButtonMenuItem fdowItem = new JRadioButtonMenuItem();
- fdowItem.setAction(getAction("isReportFirstDayOfWeek" + realDay));
- fdowItem.setSelected(realDay == JTimer.config.getReportFirstDayOfWeek());
- fdowItem.setIcon(null);
- reportFDoW.add(fdowItem);
- bg.add(fdowItem);
- }
- menu.add(reportFDoW);
-
- return menu;
- }
-
- /**
- * Create single menu.
- *
- * @param menuName menu name
- * @param actionNames associated actions
- * @return menu
- */
- protected JMenu createMenu(String menuName, String[] actionNames) {
- JMenu menu = new JMenu();
- menu.setName(menuName);
- addActionToMenu(menu, actionNames);
- return menu;
- }
-
- /**
- * Add saf action to an existing menu.
- *
- * Menu have to be a JMenu or JPopupMenu.
- *
- * @param menu parent menu
- * @param actionNames action names
- */
- protected void addActionToMenu(JComponent menu, String[] actionNames) {
- for (String actionName : actionNames) {
- if (actionName.equals("---")) {
- menu.add(new JSeparator());
- } else if (actionName.startsWith("is")) {
- // if action name start by is
- // display it as CheckBox
- JMenuItem menuItem = new JCheckBoxMenuItem();
- // link to an @Action
- menuItem.setAction(getAction(actionName));
- menuItem.setIcon(null);
- menu.add(menuItem);
- } else {
- JMenuItem menuItem = new JMenuItem();
- // link to an @Action
- menuItem.setAction(getAction(actionName));
- menuItem.setIcon(null);
- menu.add(menuItem);
- }
- }
- }
-
- /**
- * Ready. Called when UI is ready and displayed.
- *
- * @see Application#ready()
- */
- @Override
- protected void ready() {
-
- // init core, load list, synchronization, etc...
- boolean init = core.init();
-
- if (init) {
- // schedule tree refresh at midnight
- scheduleTreeRefresh();
-
- // install icon (do it at last action)
- systrayManager.install();
-
- // run action after ui
- config.putObject(this);
- config.doAction(JTimerConfig.STEP_AFTER_UI);
- } else {
- String failTitle = resourceMap.getString("startFail.title");
- String failMessage = resourceMap.getString("startFail.message");
- JOptionPane.showMessageDialog(getMainFrame(), failMessage,
- failTitle, JOptionPane.ERROR_MESSAGE);
- exit();
- }
- }
-
- /**
- * Called on application shutdown.
- *
- * Save context.
- *
- * @see SingleFrameApplication#shutdown()
- */
- @Override
- protected void shutdown() {
- log.debug("Shutdown called");
-
- // save context
- // super, sauve le context des fenetres, etc...
- super.shutdown();
- }
-
- /**
- * Refresh tree at midnight.
- */
- protected void scheduleTreeRefresh() {
-
- // task used to refresh tree
- java.util.TimerTask refreshTreeTask = new RefreshTreeTask(core);
-
- Timer timer = new Timer();
-
- Calendar date = Calendar.getInstance();
- date.setTimeInMillis(System.currentTimeMillis());
- date.set(Calendar.HOUR_OF_DAY, 0);
- date.set(Calendar.MINUTE, 0);
- date.set(Calendar.SECOND, 0);
- date.set(Calendar.MILLISECOND, 0);
- date.add(Calendar.DAY_OF_YEAR, 1); // run only next day
-
- // Schedule to run every day in midnight
- // task,firstTime,period
- timer.schedule(refreshTreeTask, date.getTime(), // at date
- 1000 * 60 * 60 * 24 // every day
- );
- }
-
- /**
- * Display a popup error message.
- *
- * @param errorMessageKey saf error message key
- */
- protected void displayErrorMessage(String errorMessageKey) {
- String title = resourceMap.getString("action.invalidActionTitle");
- String message = resourceMap.getString(errorMessageKey);
-
- // check untranslated string
- if (StringUtils.isEmpty(message)) {
- message = resourceMap.getString("action.missingErrorMessage",
- errorMessageKey);
- }
-
- JOptionPane.showMessageDialog(getMainFrame(), message, title,
- JOptionPane.ERROR_MESSAGE);
- }
-
- /**
- * New project action.
- *
- * Ask user for project name
- */
- @Action
- public void newProject() {
-
- String projectName = JOptionPane.showInputDialog(getMainFrame(),
- resourceMap.getString("input.newProjectMessage"), resourceMap
- .getString("input.newProjectTitle"),
- JOptionPane.QUESTION_MESSAGE);
-
- if (projectName != null) {
-
- // remove unneeded spaces
- projectName = projectName.trim();
-
- TimerProject p = new TimerProject(projectName);
-
- // add creation date
- p.setCreationDate(new Date());
-
- try {
- core.getData().addProject(p);
- } catch (DataViolationException e) {
- displayErrorMessage(e.getExceptionKey());
- }
- }
- }
-
- /**
- * Edit project
- *
- * Enabled when a project is selected
- */
- @Action(enabledProperty = "selectedSingleProject")
- public void editProject() {
- TimerProject project = projectsAndTasksTable.getSelectedProjects().get(
- 0);
-
- String newProjectName = (String) JOptionPane.showInputDialog(getMainFrame(), resourceMap
- .getString("input.editProjectMessage"), resourceMap
- .getString("input.editProjectTitle"),
- JOptionPane.INFORMATION_MESSAGE, null, null, project.getName());
-
- if (newProjectName != null) {
-
- // remove unneeded spaces
- newProjectName = newProjectName.trim();
-
- try {
- core.getData().editProject(project, newProjectName);
- } catch (DataViolationException e) {
- displayErrorMessage(e.getExceptionKey());
- }
- }
- }
-
- /**
- * Create new task action.
- *
- * Enabled when a project or a task is selected
- */
- @Action(enabledProperty = "selectedSingleElement")
- public void newTask() {
-
- // select task to add new task
- TimerTask selectedTask = projectsAndTasksTable.getSelectedElements()
- .get(0);
-
- String taskName = JOptionPane.showInputDialog(getMainFrame(),
- resourceMap.getString("input.newTaskMessage", selectedTask
- .getName()), resourceMap
- .getString("input.newTaskTitle"),
- JOptionPane.QUESTION_MESSAGE);
-
- if (taskName != null) {
-
- // remove unneeded spaces
- taskName = taskName.trim();
-
- TimerTask t = new TimerTask(taskName);
-
- // Fix creation date
- t.setCreationDate(new Date());
-
- try {
- core.getData().addTask(selectedTask, t);
- } catch (DataViolationException e) {
- displayErrorMessage(e.getExceptionKey());
- }
- }
-
- }
-
- /**
- * Edit task.
- *
- * Enabled when a task is selected
- */
- @Action(enabledProperty = "selectedSingleTask")
- public void editTask() {
-
- TimerTask task = projectsAndTasksTable.getSelectedTasks().get(0);
-
- TimerTaskEditor editor = new TimerTaskEditor(this, task, core);
- editor.setLocationByPlatform(true);
- editor.setVisible(true);
- }
-
- /**
- * Start selected task in tree.
- *
- * If it not already been running
- *
- * @return TimerTask scheduled for start
- * @see Task
- */
- @Action(enabledProperty = "selectedSingleStoppedTask")
- public Task<?, ?> startTask() {
-
- // search for selected task in tree
- // can't be null
- TimerTask task = projectsAndTasksTable.getSelectedTasks().get(0);
-
- RunTaskJob jobToRun = new RunTaskJob(this, task, core.getData());
- core.getData().startTask(task);
-
- return jobToRun;
- }
-
- /**
- * Start task pointed by taskPath.
- *
- * @param taskPath task path to start (from root to task)
- */
- public void startTask(String taskPath) {
- TimerTask task = core.getData().getTaskForPath(taskPath);
- if (task != null) {
- RunTaskJob jobToRun = new RunTaskJob(this, task, core.getData());
- getContext().getTaskService().execute(jobToRun);
- core.getData().startTask(task);
- } else {
- if (log.isWarnEnabled()) {
- log.warn("Can't find task '" + taskPath + "'");
- }
- }
- }
-
- /**
- * Called by task job manager when task as been started.
- *
- * @param task started task
- */
- public void startedTask(TimerTask task) {
- setSelectedSingleRunningTask(true);
- setSelectedSingleStoppedTask(false);
- }
-
- /**
- * Return job that manage running task.
- *
- * @param task timer task to get job
- * @return job or null
- */
- protected RunTaskJob getJobForRunningTask(TimerTask task) {
- RunTaskJob job = null;
-
- TaskMonitor tm = getContext().getTaskMonitor();
- for (Task t : tm.getTasks()) {
- TimerTask localtask = ((RunTaskJob) t).getTask();
- if (task.equals(localtask)) {
- job = (RunTaskJob) t;
- }
- }
-
- return job;
- }
-
- /**
- * Stop selected task in tree.
- *
- * Verify if it has been started
- */
- @Action(enabledProperty = "selectedSingleRunningTask")
- public void stopTask() {
-
- // task can't be null
- TimerTask task = projectsAndTasksTable.getSelectedTasks().get(0);
- stopTask(task);
-
- }
-
- /**
- * Stop a task.
- *
- * Delegate method. Called by idle detect ?
- * Called by delete method too.
- *
- * @param task task to stop
- */
- public void stopTask(TimerTask task) {
-
- RunTaskJob rtt = getJobForRunningTask(task);
- // test if task is already running
- if (rtt != null) {
- rtt.wantToStop();
- core.getData().stopTask(task);
-
- // re-enable/disable buttons
- setSelectedSingleRunningTask(false);
- setSelectedSingleStoppedTask(true);
- }
- }
-
- /**
- * Stop all running tasks.
- */
- public void stopAllTasks() {
-
- TaskMonitor tm = getContext().getTaskMonitor();
- for (Task t : tm.getTasks()) {
- // task
- TimerTask ttask = ((RunTaskJob) t).getTask();
- stopTask(ttask);
- }
- }
-
- /**
- * Close project.
- */
- @Action(enabledProperty = "selectedSingleProject")
- public void closeProject() {
- TimerProject project = projectsAndTasksTable.getSelectedProjects().get(0);
-
- core.getData().changeProjectCloseState(project);
- }
-
- /**
- * Close task.
- */
- @Action(enabledProperty = "selectedSingleTask")
- public void closeTask() {
- TimerTask task = projectsAndTasksTable.getSelectedTasks().get(0);
-
- core.getData().changeTaskCloseState(task);
- }
-
- /**
- * Delete project.
- */
- @Action(enabledProperty = "selectedSingleProject")
- public void deleteProject() {
-
- TimerProject project = projectsAndTasksTable.getSelectedProjects().get(
- 0);
-
- if (project != null) {
- int confirm = JOptionPane.showConfirmDialog(getMainFrame(),
- resourceMap.getString("input.deleteProjectMessage", project
- .getName()), resourceMap
- .getString("input.deleteProjectTitle"),
- JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
-
- if (confirm == JOptionPane.YES_OPTION) { // approved
- try {
- core.getData().deleteProject(project);
- } catch (DataViolationException e) {
- displayErrorMessage(e.getExceptionKey());
- }
- }
-
- }
-
- }
-
- /**
- * Delete task.
- */
- @Action(enabledProperty = "selectedSingleTask")
- public void deleteTask() {
-
- TimerTask task = projectsAndTasksTable.getSelectedTasks().get(0);
-
- if (task != null) {
- int confirm = JOptionPane.showConfirmDialog(getMainFrame(),
- resourceMap.getString("input.deleteTaskMessage", task
- .getName()), resourceMap
- .getString("input.deleteTaskTitle"),
- JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
-
- if (confirm == JOptionPane.YES_OPTION) { // approved
- try {
- stopTask(task);
- core.getData().deleteTask(task);
- } catch (DataViolationException e) {
- displayErrorMessage(e.getExceptionKey());
- }
- }
- }
- }
-
- /**
- * Change show closed option.
- *
- * @param event action event
- */
- @Action
- public void isShowClosed(ActionEvent event) {
- JCheckBoxMenuItem source = (JCheckBoxMenuItem) event.getSource();
- boolean showClosed = source.isSelected();
- projectsAndTasksTable.setShowClosed(showClosed);
- config.setShowClosed(showClosed);
- }
-
- /**
- * Change close to systray option.
- *
- * @param event action event
- */
- @Action
- public void isCloseToSystray(ActionEvent event) {
- JCheckBoxMenuItem source = (JCheckBoxMenuItem) event.getSource();
- boolean closeToSystray = source.isSelected();
- config.setCloseToSystray(closeToSystray);
- }
-
- /**
- * Change report first day of week.
- */
- @Action
- public void isReportFirstDayOfWeek1() {
- config.setReportFirstDayOfWeek(1);
- }
-
- /**
- * Change report first day of week.
- */
- @Action
- public void isReportFirstDayOfWeek2() {
- config.setReportFirstDayOfWeek(2);
- }
-
- /**
- * Change report first day of week.
- */
- @Action
- public void isReportFirstDayOfWeek3() {
- config.setReportFirstDayOfWeek(3);
- }
-
- /**
- * Change report first day of week.
- */
- @Action
- public void isReportFirstDayOfWeek4() {
- config.setReportFirstDayOfWeek(4);
- }
-
- /**
- * Change report first day of week.
- */
- @Action
- public void isReportFirstDayOfWeek5() {
- config.setReportFirstDayOfWeek(5);
- }
-
- /**
- * Change report first day of week.
- */
- @Action
- public void isReportFirstDayOfWeek6() {
- config.setReportFirstDayOfWeek(6);
- }
-
- /**
- * Change report first day of week.
- */
- @Action
- public void isReportFirstDayOfWeek7() {
- config.setReportFirstDayOfWeek(7);
- }
-
- /**
- * Increment task time.
- */
- @Action(enabledProperty = "selectedSingleTask")
- public void increment5Task() {
- incrementTaskTime(5 * 60000);
- }
-
- /**
- * Increment task time.
- */
- @Action(enabledProperty = "selectedSingleTask")
- public void increment30Task() {
- incrementTaskTime(30 * 60000);
- }
-
- /**
- * Decrement task time.
- */
- @Action(enabledProperty = "selectedSingleTask")
- public void decrement1Task() {
- incrementTaskTime(-60000);
- }
-
- /**
- * Decrement task time.
- */
- @Action(enabledProperty = "selectedSingleTask")
- public void decrement5Task() {
- incrementTaskTime(-5 * 60000);
- }
-
- /**
- * Decrement task time.
- */
- @Action(enabledProperty = "selectedSingleTask")
- public void decrement30Task() {
- incrementTaskTime(-30 * 60000);
- }
-
- /**
- * Increment task time.
- */
- @Action(enabledProperty = "selectedSingleTask")
- public void increment1Task() {
- incrementTaskTime(60000);
- }
-
- /**
- * Increment task time.
- *
- * To decrement, set negative increment:)
- *
- * @param increment increment in ms
- */
- protected void incrementTaskTime(long increment) {
- TimerTask selectedTask = projectsAndTasksTable.getSelectedTasks()
- .get(0);
-
- // task is not running
- Date now = new Date();
- long todayTime = selectedTask.getTime(now);
-
- long newTodayTime = todayTime + increment;
-
- 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());
- }
- }
-
- /**
- * Reset task time to zero.
- */
- @Action(enabledProperty = "selectedSingleTask")
- public void setToZero() {
- TimerTask task = projectsAndTasksTable.getSelectedTasks().get(0);
- incrementTaskTime(-task.getTime(new Date()));
- }
-
- /**
- * Merge multiples tasks action.
- */
- @Action(enabledProperty = "selectedMultiplesTasks")
- public void mergeTasks() {
- List<TimerTask> tasks = projectsAndTasksTable.getSelectedTasks();
-
- TimerTask destinationTask = tasks.get(0);
- List<TimerTask> otherTasks = tasks.subList(1, tasks.size());
- int confirm = JOptionPane.showConfirmDialog(getMainFrame(),
- resourceMap.getString("input.mergeTaskMessage", tasks.size(),
- destinationTask.getName()), resourceMap
- .getString("input.mergeTaskTitle"),
- JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
- if (confirm == JOptionPane.YES_OPTION) {
-
- try {
- core.getData().mergeTasks(destinationTask, otherTasks);
- } catch (DataViolationException e) {
- displayErrorMessage(e.getExceptionKey());
- }
- }
- }
-
- /**
- * Add annotation action.
- */
- @Action(enabledProperty = "selectedSingleTask")
- public void addAnnotation() {
- // select task to add new annotation
- TimerTask selectedTask = projectsAndTasksTable.getSelectedTasks()
- .get(0);
-
- String annotation = JOptionPane.showInputDialog(getMainFrame(),
- resourceMap.getString("input.addAnnotationMessage",
- selectedTask.getName()), resourceMap
- .getString("input.addAnnotationTitle"),
- JOptionPane.QUESTION_MESSAGE);
-
- if (annotation != null) {
- // remove useless spaces
- annotation = annotation.trim();
-
- try {
- core.getData().addAnnotation(selectedTask, new Date(),
- annotation);
- } catch (DataViolationException e) {
- displayErrorMessage(e.getExceptionKey());
- }
- }
- }
-
- /**
- * Edit alert action.
- */
- @Action(enabledProperty = "selectedSingleTask")
- public void editAlert() {
- // select task to edit alert
- TimerTask selectedTask = projectsAndTasksTable.getSelectedTasks()
- .get(0);
-
- AlertEditor alertEditor = new AlertEditor(this, core.getData(),
- selectedTask);
- show(alertEditor);
- }
-
- /**
- * Create report.
- */
- @Action
- public void makeReport() {
- ReportView view = new ReportView(this, core);
- show(view);
- }
-
- /**
- * Show about frame.
- */
- @Action
- public void about() {
- HelpFrame aboutFrame = new HelpFrame(this);
- show(aboutFrame);
- }
-
- /**
- * Is selected project.
- *
- * @return selected project property
- */
- public boolean isSelectedSingleProject() {
- return selectedSingleProject;
- }
-
- /**
- * Change selected project property.
- *
- * @param selectedSingleProject selected project property
- */
- public void setSelectedSingleProject(boolean selectedSingleProject) {
- boolean oldValue = this.selectedSingleProject;
- this.selectedSingleProject = selectedSingleProject;
- firePropertyChange("selectedSingleProject", oldValue,
- selectedSingleProject);
- }
-
- /**
- * Is selected task.
- *
- * @return selected task property
- */
- public boolean isSelectedSingleTask() {
- return selectedSingleTask;
- }
-
- /**
- * Change selected task property.
- *
- * @param selectedSingleTask selected task property
- */
- public void setSelectedSingleTask(boolean selectedSingleTask) {
- boolean oldValue = this.selectedSingleTask;
- this.selectedSingleTask = selectedSingleTask;
- firePropertyChange("selectedSingleTask", oldValue, selectedSingleTask);
- }
-
- /**
- * Is selected task or project.
- *
- * @return selected task or project property
- */
- public boolean isSelectedSingleElement() {
- return selectedSingleElement;
- }
-
- /**
- * Change selected task or project property.
- *
- * @param selectedSingleElement selected task or project property
- */
- public void setSelectedSingleElement(boolean selectedSingleElement) {
- boolean oldValue = this.selectedSingleElement;
- this.selectedSingleElement = selectedSingleElement;
- firePropertyChange("selectedSingleElement", oldValue,
- selectedSingleElement);
- }
-
- /**
- * Is selected running task.
- *
- * @return the selectedSingleRunningTask
- */
- public boolean isSelectedSingleRunningTask() {
- return selectedSingleRunningTask;
- }
-
- /**
- * Change selected running task property.
- *
- * @param selectedSingleRunningTask selected running task property
- */
- public void setSelectedSingleRunningTask(boolean selectedSingleRunningTask) {
- boolean oldValue = this.selectedSingleRunningTask;
- this.selectedSingleRunningTask = selectedSingleRunningTask;
- firePropertyChange("selectedSingleRunningTask", oldValue,
- selectedSingleRunningTask);
- }
-
- /**
- * Is selected non running task.
- *
- * @return selected non running task
- */
- public boolean isSelectedSingleStoppedTask() {
- return selectedSingleStoppedTask;
- }
-
- /**
- * Change selected non running task property.
- *
- * @param selectedSingleStoppedTask selected non running task
- */
- public void setSelectedSingleStoppedTask(boolean selectedSingleStoppedTask) {
- boolean oldValue = this.selectedSingleStoppedTask;
- this.selectedSingleStoppedTask = selectedSingleStoppedTask;
- firePropertyChange("selectedSingleStoppedTask", oldValue,
- selectedSingleStoppedTask);
- }
-
- /**
- * Is selected multiples projects.
- *
- * @return selected multiples projects
- */
- public boolean isSelectedMultiplesProjects() {
- return selectedMultiplesProjects;
- }
-
- /**
- * Change selected multiples projects property.
- *
- * @param selectedMultiplesProjects selected multiples projects
- */
- public void setSelectedMultiplesProjects(boolean selectedMultiplesProjects) {
- boolean oldValue = this.selectedMultiplesProjects;
- this.selectedMultiplesProjects = selectedMultiplesProjects;
- firePropertyChange("selectedMultiplesProjects", oldValue,
- selectedMultiplesProjects);
- }
-
- /**
- * Is selected multiples tasks.
- *
- * @return selected multiples tasks
- */
- public boolean isSelectedMultiplesTasks() {
- return selectedMultiplesTasks;
- }
-
- /**
- * Change selected multiples tasks property.
- *
- * @param selectedMultiplesTasks selected multiples tasks
- */
- public void setSelectedMultiplesTasks(boolean selectedMultiplesTasks) {
- boolean oldValue = this.selectedMultiplesTasks;
- this.selectedMultiplesTasks = selectedMultiplesTasks;
- firePropertyChange("selectedMultiplesTasks", oldValue,
- selectedMultiplesTasks);
- }
-
- /**
- * Is selected multiples elements.
- *
- * @return selected multiples elements
- */
- public boolean isSelectedMultiplesElements() {
- return selectedMultiplesElements;
- }
-
- /**
- * Change selected multiples elements property.
- *
- * @param selectedMultiplesElements selected multiples elements
- */
- public void setSelectedMultiplesElements(boolean selectedMultiplesElements) {
- boolean oldValue = this.selectedMultiplesElements;
- this.selectedMultiplesElements = selectedMultiplesElements;
- firePropertyChange("selectedMultiplesElements", oldValue,
- selectedMultiplesElements);
- }
-
- /*
- * @see javax.swing.event.TreeSelectionListener#valueChanged(javax.swing.event.TreeSelectionEvent)
- */
- @Override
- public void valueChanged(TreeSelectionEvent e) {
- // get selected elements
- List<TimerTask> elements = projectsAndTasksTable.getSelectedElements();
- List<TimerProject> projects = projectsAndTasksTable
- .getSelectedProjects();
- List<TimerTask> tasks = projectsAndTasksTable.getSelectedTasks();
-
- // notify application that tree selection has changed
- if (tasks.size() == 1 && projects.size() == 0) {
- TimerTask task = tasks.get(0);
- setSelectedSingleTask(true);
-
- // ask for SAF job manager if task is running
- RunTaskJob job = getJobForRunningTask(task);
- if (job == null || job.isStopping()) {
- setSelectedSingleStoppedTask(true);
- setSelectedSingleRunningTask(false);
- } else {
- setSelectedSingleStoppedTask(false);
- setSelectedSingleRunningTask(true);
- }
- setSelectedMultiplesTasks(false);
- setSelectedSingleProject(false);
- setSelectedMultiplesProjects(false);
- } else {
- setSelectedSingleTask(false);
- setSelectedSingleStoppedTask(false);
- setSelectedSingleRunningTask(false);
-
- if (tasks.size() > 1) {
- setSelectedMultiplesTasks(projects.size() == 0);
- } else {
- setSelectedSingleProject(tasks.size() == 0
- && projects.size() == 1);
- setSelectedMultiplesProjects(tasks.size() == 0
- && projects.size() > 1);
- }
- }
- setSelectedSingleElement(elements.size() == 1);
- setSelectedMultiplesElements(elements.size() > 1);
- }
-
- /**
- * Get action for named component.
- *
- * Util method.
- *
- * @param actionName action name
- * @return swing action
- */
- protected javax.swing.Action getAction(String actionName) {
- return getContext().getActionMap().get(actionName);
- }
-
- /**
- * Show window
- */
- @Action
- public void show() {
- // TODO better code ? that use SAF methods ?
- getMainFrame().setVisible(true);
- getMainFrame().toFront();
- }
-
- /**
- * Show window
- */
- @Action
- public void hide() {
- // TODO better code ? that use SAF methods ?
- getMainFrame().setVisible(false);
- }
-
- /**
- * Notified by job on pre idle detect.
- */
- public void preIdleDetect() {
- systrayManager.preIdleDetect();
- }
-
- /**
- * Notified by job on post idle detect.
- */
- public void postIdleDetect() {
- systrayManager.postIdleDetect();
- }
-
- /*
- * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
- */
- public void mouseClicked(MouseEvent e) {
-
- if (log.isDebugEnabled()) {
- log.debug("Mouse clicked (" + e.getClickCount()
- + " clics), source = "
- + e.getSource().getClass().getName());
- }
-
- switch (e.getButton()) {
-
- // clic gauche
- case MouseEvent.BUTTON1:
- // clic sur l'arbre des projets
- if (e.getSource() == projectsAndTasksTable) {
- // demarre la tache lors d'un double clic dessus
- if (e.getClickCount() == 2) {
-
- if (isSelectedSingleStoppedTask()) { // can only launch non running tasks
- Task<?, ?> appTask = startTask();
- if (appTask != null) {
-
- // first, on dlb click stop all running tasks
- stopAllTasks();
-
- getContext().getTaskService().execute(appTask);
- }
- /* TODO EC-20100416 temp disable, called twice, can display
- -1 task running :(
- } else if (isSelectedSingleRunningTask()) {
- TimerTask task = projectsAndTasksTable.getSelectedTasks().get(0);
- stopTask(task); */
- } else {
- if (log.isDebugEnabled()) {
- log.debug("Non selected non running task to launch");
- }
- }
- } else {
- if (log.isDebugEnabled()) {
- log.debug("Single clic on tree, do nothing");
- }
- }
- }
- break;
-
- // gestion du clic droit
- case MouseEvent.BUTTON3:
-
- // force task selection on rigth clic
- TreePath path = projectsAndTasksTable.getPathForLocation(e.getX(),
- e.getY());
- int selectedRow = projectsAndTasksTable.getRowForPath(path);
- projectsAndTasksTable.getSelectionModel().setSelectionInterval(
- selectedRow, selectedRow);
-
- // fix item selection
- JPopupMenu menu = new JPopupMenu();
-
- String[] actionNames = null;
-
- // construct menu in function of selection
- if (isSelectedSingleProject()) {
- actionNames = new String[] { "newTask", "---", "newProject",
- "editProject", "closeProject", "deleteProject" };
- }
-
- if (isSelectedSingleTask()) {
- actionNames = new String[] { "startTask", "stopTask", "---",
- "newTask", "editTask", "closeTask", "deleteTask",
- "---", "addAnnotation", "editAlert", "increment1Task",
- "increment5Task", "increment30Task", "decrement1Task",
- "decrement5Task", "decrement30Task", "setToZero" };
- }
-
- if (isSelectedMultiplesTasks()) {
- actionNames = new String[] { "mergeTasks" };
- }
-
- // case, right clic, but nothing selected
- if (actionNames != null) {
- addActionToMenu(menu, actionNames);
-
- menu.show(e.getComponent(), e.getX(), e.getY());
- }
- }
- }
-
- public void mouseEntered(MouseEvent e) {
- }
-
- public void mouseExited(MouseEvent e) {
- }
-
- public void mousePressed(MouseEvent e) {
- }
-
- public void mouseReleased(MouseEvent e) {
- }
-}
Modified: branches/2.0.0-evol-499-storage/src/main/java/org/chorem/jtimer/JTimerActions.java
===================================================================
--- branches/2.0.0-evol-499-storage/src/main/java/org/chorem/jtimer/JTimerActions.java 2013-07-11 20:30:35 UTC (rev 2902)
+++ branches/2.0.0-evol-499-storage/src/main/java/org/chorem/jtimer/JTimerActions.java 2013-07-11 21:34:52 UTC (rev 2903)
@@ -26,8 +26,8 @@
package org.chorem.jtimer;
import org.chorem.jtimer.JTimerConfig.JTimerAction;
-import org.nuiton.util.ApplicationConfig;
-import org.nuiton.util.ApplicationConfig.Action.Step;
+import org.nuiton.util.config.ApplicationConfig;
+import org.nuiton.util.config.ApplicationConfig.Action.Step;
/**
* JTimer actions class run from command line.
@@ -75,7 +75,6 @@
@Step(JTimerConfig.STEP_AFTER_UI)
public void start(String taskPath) {
- JTimer ui = config.getObject(JTimer.class);
- ui.startTask(taskPath);
+
}
}
Modified: branches/2.0.0-evol-499-storage/src/main/java/org/chorem/jtimer/JTimerConfig.java
===================================================================
--- branches/2.0.0-evol-499-storage/src/main/java/org/chorem/jtimer/JTimerConfig.java 2013-07-11 20:30:35 UTC (rev 2902)
+++ branches/2.0.0-evol-499-storage/src/main/java/org/chorem/jtimer/JTimerConfig.java 2013-07-11 21:34:52 UTC (rev 2903)
@@ -25,8 +25,8 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.nuiton.util.ApplicationConfig;
-import org.nuiton.util.ArgumentsParserException;
+import org.nuiton.util.config.ApplicationConfig;
+import org.nuiton.util.config.ArgumentsParserException;
/**
* JTimer configuration.
Deleted: branches/2.0.0-evol-499-storage/src/main/java/org/chorem/jtimer/JTimerFactory.java
===================================================================
--- branches/2.0.0-evol-499-storage/src/main/java/org/chorem/jtimer/JTimerFactory.java 2013-07-11 20:30:35 UTC (rev 2902)
+++ branches/2.0.0-evol-499-storage/src/main/java/org/chorem/jtimer/JTimerFactory.java 2013-07-11 21:34:52 UTC (rev 2903)
@@ -1,97 +0,0 @@
-/*
- * #%L
- * jTimer
- *
- * $Id$
- * $HeadURL$
- * %%
- * 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
- * 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%
- */
-
-package org.chorem.jtimer;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.chorem.jtimer.io.Saver;
-
-/**
- * JTimer config class.
- *
- * @author chatellier
- * @version $Revision$
- *
- * Last update : $Date$
- * By : $Author$
- */
-public class JTimerFactory {
-
- /** Logger */
- private static Log log = LogFactory.getLog(JTimerFactory.class);
-
- /** Saver */
- protected static Saver saver;
-
- /**
- * Constructeur.
- */
- protected JTimerFactory() {
- // disable instanciation
- }
-
- /**
- * Get saver manager.
- *
- * @return saver manager
- */
- public static Saver getFileSaver() {
-
- if (saver == null) {
-
- Class saverClass = JTimer.config.getIOSaverClass();
-
- // log
- if (log.isInfoEnabled()) {
- 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) saverClass.newInstance();
-
- // init instance
- saver.setSaveDirectory(JTimer.config.getIOSaverDirectory());
-
- // set delay to saver
- saver.setAutoSaveDelay(JTimer.config.getIOSaverAutoSaveDelay() * 1000);
-
- } catch (InstantiationException e) {
- if (log.isErrorEnabled()) {
- log.error("Can't instanciate class : " + saverClass, e);
- }
- } catch (IllegalAccessException e) {
- if (log.isErrorEnabled()) {
- log.error("Can't access class : " + saverClass, e);
- }
- }
- }
-
- return saver;
- }
-}
Modified: branches/2.0.0-evol-499-storage/src/main/java/org/chorem/jtimer/data/TimerCore.java
===================================================================
--- branches/2.0.0-evol-499-storage/src/main/java/org/chorem/jtimer/data/TimerCore.java 2013-07-11 20:30:35 UTC (rev 2902)
+++ branches/2.0.0-evol-499-storage/src/main/java/org/chorem/jtimer/data/TimerCore.java 2013-07-11 21:34:52 UTC (rev 2903)
@@ -25,18 +25,8 @@
package org.chorem.jtimer.data;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-
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.entities.TimerProject;
-import org.chorem.jtimer.io.DataLockingException;
-import org.chorem.jtimer.io.Saver;
import org.chorem.jtimer.storage.Storage;
/**
@@ -68,7 +58,7 @@
data = new TimerDataManager();
// init storage
- storage = new Storage(JTimer.config);
+ //storage = new Storage(JTimer.config);
data.addDataEventListener(storage);
// add commmon vetoable
Modified: branches/2.0.0-evol-499-storage/src/main/java/org/chorem/jtimer/entities/TimerTask.java
===================================================================
--- branches/2.0.0-evol-499-storage/src/main/java/org/chorem/jtimer/entities/TimerTask.java 2013-07-11 20:30:35 UTC (rev 2902)
+++ branches/2.0.0-evol-499-storage/src/main/java/org/chorem/jtimer/entities/TimerTask.java 2013-07-11 21:34:52 UTC (rev 2903)
@@ -32,8 +32,6 @@
import java.util.SortedMap;
import java.util.TreeMap;
-import org.chorem.jtimer.utils.DailySortedMap;
-
/**
* Represents a task.
*
@@ -91,7 +89,7 @@
* Constructor.
*/
public TimerTask() {
- allDaysTimes = new DailySortedMap<Long>();
+ //allDaysTimes = new DailySortedMap<Long>();
// les annoation sont à la seconde pres
allDaysAnnotations = new TreeMap<Date, String>();
subTasks = new ArrayList<TimerTask>();
@@ -363,7 +361,7 @@
: (Date) creationDate.clone();
// make new list instance
- task.allDaysTimes = new DailySortedMap<Long>(allDaysTimes);
+ //task.allDaysTimes = new DailySortedMap<Long>(allDaysTimes);
task.allDaysAnnotations = new TreeMap<Date, String>(allDaysAnnotations);
task.subTasks = new ArrayList<TimerTask>(subTasks);
} catch (CloneNotSupportedException e) {
Copied: branches/2.0.0-evol-499-storage/src/main/java/org/chorem/jtimer/system/SystemInfo.java (from rev 2902, branches/2.0.0-evol-499-storage/src/main/java/org/chorem/jtimer/ui/system/SystemInfo.java)
===================================================================
--- branches/2.0.0-evol-499-storage/src/main/java/org/chorem/jtimer/system/SystemInfo.java (rev 0)
+++ branches/2.0.0-evol-499-storage/src/main/java/org/chorem/jtimer/system/SystemInfo.java 2013-07-11 21:34:52 UTC (rev 2903)
@@ -0,0 +1,45 @@
+/*
+ * #%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%
+ */
+
+package org.chorem.jtimer.system;
+
+/**
+ * System info interface for all systems.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public interface SystemInfo {
+
+ /**
+ * Get system idle time in milliseconds.
+ *
+ * @return system idle time in milliseconds
+ */
+ public long getIdleTime();
+}
Copied: branches/2.0.0-evol-499-storage/src/main/java/org/chorem/jtimer/system/SystemInfoFactory.java (from rev 2902, branches/2.0.0-evol-499-storage/src/main/java/org/chorem/jtimer/ui/system/SystemInfoFactory.java)
===================================================================
--- branches/2.0.0-evol-499-storage/src/main/java/org/chorem/jtimer/system/SystemInfoFactory.java (rev 0)
+++ branches/2.0.0-evol-499-storage/src/main/java/org/chorem/jtimer/system/SystemInfoFactory.java 2013-07-11 21:34:52 UTC (rev 2903)
@@ -0,0 +1,94 @@
+/*
+ * #%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%
+ */
+
+package org.chorem.jtimer.system;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.bridj.Platform;
+import org.chorem.jtimer.system.macos.MacOSSystemInfo;
+import org.chorem.jtimer.system.unix.UnixSystemInfo;
+import org.chorem.jtimer.system.win32.Win32SystemInfo;
+
+/**
+ * Build system info determined from system.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class SystemInfoFactory {
+
+ /** log */
+ private static Log log = LogFactory.getLog(SystemInfoFactory.class);
+
+ /** Single instance */
+ protected static SystemInfo instance;
+
+ /**
+ * SystemInfoFactory Constructor.
+ */
+ protected SystemInfoFactory() {
+
+ }
+
+ /**
+ * Return system info depending on system.
+ *
+ * @return SystemInfo instance
+ * @see SystemInfo
+ * @throws UnsupportedSystemInfoException if system info is not supported
+ * for system
+ */
+ public static SystemInfo getSystemInfo()
+ throws UnsupportedSystemInfoException {
+
+ if (instance == null) {
+ String os = System.getProperty("os.name");
+
+ // log it
+ if (log.isInfoEnabled()) {
+ log.info("Try do build system info for system : " + os);
+ }
+
+ // try windows
+ if (Platform.isWindows()) {
+ instance = new Win32SystemInfo();
+ } else if (Platform.isLinux()) {
+ instance = new UnixSystemInfo();
+ } else if (Platform.isMacOSX()) {
+ instance = new MacOSSystemInfo();
+ } else {
+ // system unknown
+ throw new UnsupportedSystemInfoException(
+ "Can't get system info for " + os);
+ }
+ }
+
+ return instance;
+ }
+}
Copied: branches/2.0.0-evol-499-storage/src/main/java/org/chorem/jtimer/system/UnsupportedSystemInfoException.java (from rev 2902, branches/2.0.0-evol-499-storage/src/main/java/org/chorem/jtimer/ui/system/UnsupportedSystemInfoException.java)
===================================================================
--- branches/2.0.0-evol-499-storage/src/main/java/org/chorem/jtimer/system/UnsupportedSystemInfoException.java (rev 0)
+++ branches/2.0.0-evol-499-storage/src/main/java/org/chorem/jtimer/system/UnsupportedSystemInfoException.java 2013-07-11 21:34:52 UTC (rev 2903)
@@ -0,0 +1,69 @@
+/*
+ * #%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%
+ */
+
+package org.chorem.jtimer.system;
+
+/**
+ * Exception thrown when system info is not available.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class UnsupportedSystemInfoException extends Exception {
+
+ /** serialVersionUID. */
+ private static final long serialVersionUID = 138458861335881500L;
+
+ /**
+ * Constructor.
+ *
+ * @param message message
+ * @param cause cause
+ */
+ public UnsupportedSystemInfoException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param message message
+ */
+ public UnsupportedSystemInfoException(String message) {
+ super(message);
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param cause cause.
+ */
+ public UnsupportedSystemInfoException(Throwable cause) {
+ super(cause);
+ }
+}
Modified: branches/2.0.0-evol-499-storage/src/main/java/org/chorem/jtimer/system/macos/ApplicationServices.java
===================================================================
--- branches/2.0.0-evol-499-storage/src/main/java/org/chorem/jtimer/ui/system/macos/ApplicationServices.java 2013-07-11 20:30:35 UTC (rev 2902)
+++ branches/2.0.0-evol-499-storage/src/main/java/org/chorem/jtimer/system/macos/ApplicationServices.java 2013-07-11 21:34:52 UTC (rev 2903)
@@ -23,7 +23,7 @@
* #L%
*/
-package org.chorem.jtimer.ui.system.macos;
+package org.chorem.jtimer.system.macos;
import org.bridj.BridJ;
import org.bridj.ann.Library;
Modified: branches/2.0.0-evol-499-storage/src/main/java/org/chorem/jtimer/system/macos/MacOSSystemInfo.java
===================================================================
--- branches/2.0.0-evol-499-storage/src/main/java/org/chorem/jtimer/ui/system/macos/MacOSSystemInfo.java 2013-07-11 20:30:35 UTC (rev 2902)
+++ branches/2.0.0-evol-499-storage/src/main/java/org/chorem/jtimer/system/macos/MacOSSystemInfo.java 2013-07-11 21:34:52 UTC (rev 2903)
@@ -23,9 +23,9 @@
* #L%
*/
-package org.chorem.jtimer.ui.system.macos;
+package org.chorem.jtimer.system.macos;
-import org.chorem.jtimer.ui.system.SystemInfo;
+import org.chorem.jtimer.system.SystemInfo;
/**
* MacOSSystemInfo
Modified: branches/2.0.0-evol-499-storage/src/main/java/org/chorem/jtimer/system/macos/package-info.java
===================================================================
--- branches/2.0.0-evol-499-storage/src/main/java/org/chorem/jtimer/ui/system/macos/package-info.java 2013-07-11 20:30:35 UTC (rev 2902)
+++ branches/2.0.0-evol-499-storage/src/main/java/org/chorem/jtimer/system/macos/package-info.java 2013-07-11 21:34:52 UTC (rev 2903)
@@ -25,4 +25,4 @@
/**
* Mac OS specific system info implementation.
*/
-package org.chorem.jtimer.ui.system.macos;
+package org.chorem.jtimer.system.macos;
Copied: branches/2.0.0-evol-499-storage/src/main/java/org/chorem/jtimer/system/package-info.java (from rev 2902, branches/2.0.0-evol-499-storage/src/main/java/org/chorem/jtimer/ui/system/package-info.java)
===================================================================
--- branches/2.0.0-evol-499-storage/src/main/java/org/chorem/jtimer/system/package-info.java (rev 0)
+++ branches/2.0.0-evol-499-storage/src/main/java/org/chorem/jtimer/system/package-info.java 2013-07-11 21:34:52 UTC (rev 2903)
@@ -0,0 +1,28 @@
+/*
+ * #%L
+ * jTimer
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * 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
+ * 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%
+ */
+/**
+ * System interface using Bridj to get system information.
+ */
+package org.chorem.jtimer.system;
Modified: branches/2.0.0-evol-499-storage/src/main/java/org/chorem/jtimer/system/unix/UnixSystemInfo.java
===================================================================
--- branches/2.0.0-evol-499-storage/src/main/java/org/chorem/jtimer/ui/system/unix/UnixSystemInfo.java 2013-07-11 20:30:35 UTC (rev 2902)
+++ branches/2.0.0-evol-499-storage/src/main/java/org/chorem/jtimer/system/unix/UnixSystemInfo.java 2013-07-11 21:34:52 UTC (rev 2903)
@@ -23,12 +23,12 @@
* #L%
*/
-package org.chorem.jtimer.ui.system.unix;
+package org.chorem.jtimer.system.unix;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.bridj.Pointer;
-import org.chorem.jtimer.ui.system.SystemInfo;
+import org.chorem.jtimer.system.SystemInfo;
/**
* Linux system info.
Modified: branches/2.0.0-evol-499-storage/src/main/java/org/chorem/jtimer/system/unix/X11.java
===================================================================
--- branches/2.0.0-evol-499-storage/src/main/java/org/chorem/jtimer/ui/system/unix/X11.java 2013-07-11 20:30:35 UTC (rev 2902)
+++ branches/2.0.0-evol-499-storage/src/main/java/org/chorem/jtimer/system/unix/X11.java 2013-07-11 21:34:52 UTC (rev 2903)
@@ -1,4 +1,4 @@
-package org.chorem.jtimer.ui.system.unix;
+package org.chorem.jtimer.system.unix;
import org.bridj.BridJ;
import org.bridj.Pointer;
Modified: branches/2.0.0-evol-499-storage/src/main/java/org/chorem/jtimer/system/unix/Xss.java
===================================================================
--- branches/2.0.0-evol-499-storage/src/main/java/org/chorem/jtimer/ui/system/unix/Xss.java 2013-07-11 20:30:35 UTC (rev 2902)
+++ branches/2.0.0-evol-499-storage/src/main/java/org/chorem/jtimer/system/unix/Xss.java 2013-07-11 21:34:52 UTC (rev 2903)
@@ -23,7 +23,7 @@
* #L%
*/
-package org.chorem.jtimer.ui.system.unix;
+package org.chorem.jtimer.system.unix;
import org.bridj.BridJ;
import org.bridj.Pointer;
Modified: branches/2.0.0-evol-499-storage/src/main/java/org/chorem/jtimer/system/unix/package-info.java
===================================================================
--- branches/2.0.0-evol-499-storage/src/main/java/org/chorem/jtimer/ui/system/unix/package-info.java 2013-07-11 20:30:35 UTC (rev 2902)
+++ branches/2.0.0-evol-499-storage/src/main/java/org/chorem/jtimer/system/unix/package-info.java 2013-07-11 21:34:52 UTC (rev 2903)
@@ -25,4 +25,4 @@
/**
* Linux specific system info implementation.
*/
-package org.chorem.jtimer.ui.system.unix;
+package org.chorem.jtimer.system.unix;
Modified: branches/2.0.0-evol-499-storage/src/main/java/org/chorem/jtimer/system/win32/Kernel32.java
===================================================================
--- branches/2.0.0-evol-499-storage/src/main/java/org/chorem/jtimer/ui/system/win32/Kernel32.java 2013-07-11 20:30:35 UTC (rev 2902)
+++ branches/2.0.0-evol-499-storage/src/main/java/org/chorem/jtimer/system/win32/Kernel32.java 2013-07-11 21:34:52 UTC (rev 2903)
@@ -23,7 +23,7 @@
* #L%
*/
-package org.chorem.jtimer.ui.system.win32;
+package org.chorem.jtimer.system.win32;
import org.bridj.*;
import org.bridj.ann.*;
Modified: branches/2.0.0-evol-499-storage/src/main/java/org/chorem/jtimer/system/win32/User32.java
===================================================================
--- branches/2.0.0-evol-499-storage/src/main/java/org/chorem/jtimer/ui/system/win32/User32.java 2013-07-11 20:30:35 UTC (rev 2902)
+++ branches/2.0.0-evol-499-storage/src/main/java/org/chorem/jtimer/system/win32/User32.java 2013-07-11 21:34:52 UTC (rev 2903)
@@ -23,7 +23,7 @@
* #L%
*/
-package org.chorem.jtimer.ui.system.win32;
+package org.chorem.jtimer.system.win32;
import org.bridj.BridJ;
import org.bridj.Pointer;
Modified: branches/2.0.0-evol-499-storage/src/main/java/org/chorem/jtimer/system/win32/Win32SystemInfo.java
===================================================================
--- branches/2.0.0-evol-499-storage/src/main/java/org/chorem/jtimer/ui/system/win32/Win32SystemInfo.java 2013-07-11 20:30:35 UTC (rev 2902)
+++ branches/2.0.0-evol-499-storage/src/main/java/org/chorem/jtimer/system/win32/Win32SystemInfo.java 2013-07-11 21:34:52 UTC (rev 2903)
@@ -23,10 +23,10 @@
* #L%
*/
-package org.chorem.jtimer.ui.system.win32;
+package org.chorem.jtimer.system.win32;
import org.bridj.Pointer;
-import org.chorem.jtimer.ui.system.SystemInfo;
+import org.chorem.jtimer.system.SystemInfo;
/**
* Win32 System info.
Modified: branches/2.0.0-evol-499-storage/src/main/java/org/chorem/jtimer/system/win32/package-info.java
===================================================================
--- branches/2.0.0-evol-499-storage/src/main/java/org/chorem/jtimer/ui/system/win32/package-info.java 2013-07-11 20:30:35 UTC (rev 2902)
+++ branches/2.0.0-evol-499-storage/src/main/java/org/chorem/jtimer/system/win32/package-info.java 2013-07-11 21:34:52 UTC (rev 2903)
@@ -25,4 +25,4 @@
/**
* Windows specific system info implementation.
*/
-package org.chorem.jtimer.ui.system.win32;
+package org.chorem.jtimer.system.win32;
Modified: branches/2.0.0-evol-499-storage/src/test/java/org/chorem/jtimer/AbstractJTimerTest.java
===================================================================
--- branches/2.0.0-evol-499-storage/src/test/java/org/chorem/jtimer/AbstractJTimerTest.java 2013-07-11 20:30:35 UTC (rev 2902)
+++ branches/2.0.0-evol-499-storage/src/test/java/org/chorem/jtimer/AbstractJTimerTest.java 2013-07-11 21:34:52 UTC (rev 2903)
@@ -95,9 +95,6 @@
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());
@@ -108,10 +105,6 @@
FileUtils.copyDirectory(new File("src/test/resources/testdata"),
testDataDirectory, HiddenFileFilter.VISIBLE);
- // force null, to force new instance
- JTimerFactory.saver = null;
- testSaver = JTimerFactory.getFileSaver();
-
}
/**
Modified: branches/2.0.0-evol-499-storage/src/test/java/org/chorem/jtimer/JTimerFactoryTest.java
===================================================================
--- branches/2.0.0-evol-499-storage/src/test/java/org/chorem/jtimer/JTimerFactoryTest.java 2013-07-11 20:30:35 UTC (rev 2902)
+++ branches/2.0.0-evol-499-storage/src/test/java/org/chorem/jtimer/JTimerFactoryTest.java 2013-07-11 21:34:52 UTC (rev 2903)
@@ -27,9 +27,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.chorem.jtimer.io.GTimerIncrementalSaver;
-import org.chorem.jtimer.io.Saver;
-import org.testng.Assert;
import org.testng.annotations.Test;
/**
@@ -56,13 +53,13 @@
log.info("Test property loading " + JTimerFactoryTest.class);
}
- Assert.assertEquals(JTimer.config.getIdleTime(), 299);
+ //Assert.assertEquals(JTimer.config.getIdleTime(), 299);
- Assert.assertEquals(JTimer.config.getIOSaverClass(), GTimerIncrementalSaver.class);
+ //Assert.assertEquals(JTimer.config.getIOSaverClass(), GTimerIncrementalSaver.class);
// Temp dir is dynamic
//Assert.assertEquals(AbstractJTimerTest.getTempDirPath() + "/testngdata",
// JTimer.config.getIOSaverDirectory());
- Assert.assertEquals(JTimer.config.getIOSaverAutoSaveDelay(), 199);
+ //Assert.assertEquals(JTimer.config.getIOSaverAutoSaveDelay(), 199);
}
@@ -71,8 +68,8 @@
*/
@Test
public void getFileSaverTest() {
- Saver saver = JTimerFactory.getFileSaver();
+ //Saver saver = JTimerFactory.getFileSaver();
- Assert.assertNotNull(saver);
+ //Assert.assertNotNull(saver);
}
}
Modified: branches/2.0.0-evol-499-storage/src/test/java/org/chorem/jtimer/entities/TimerTaskTest.java
===================================================================
--- branches/2.0.0-evol-499-storage/src/test/java/org/chorem/jtimer/entities/TimerTaskTest.java 2013-07-11 20:30:35 UTC (rev 2902)
+++ branches/2.0.0-evol-499-storage/src/test/java/org/chorem/jtimer/entities/TimerTaskTest.java 2013-07-11 21:34:52 UTC (rev 2903)
@@ -28,7 +28,6 @@
import java.util.Date;
import org.chorem.jtimer.AbstractJTimerTest;
-import org.chorem.jtimer.utils.DailySortedMap;
import org.testng.Assert;
import org.testng.annotations.Test;
@@ -66,8 +65,8 @@
TimerTask clonedTask = task.clone();
- Assert.assertTrue(clonedTask.allDaysTimes instanceof DailySortedMap<?>, "Clone put invalid type for map");
- Assert.assertFalse(clonedTask.allDaysAnnotations instanceof DailySortedMap<?>, "Clone put invalid type for map");
+ //Assert.assertTrue(clonedTask.allDaysTimes instanceof DailySortedMap<?>, "Clone put invalid type for map");
+ //Assert.assertFalse(clonedTask.allDaysAnnotations instanceof DailySortedMap<?>, "Clone put invalid type for map");
}
/**
Modified: branches/2.0.0-evol-499-storage/src/test/java/org/chorem/jtimer/storage/StorageTest.java
===================================================================
--- branches/2.0.0-evol-499-storage/src/test/java/org/chorem/jtimer/storage/StorageTest.java 2013-07-11 20:30:35 UTC (rev 2902)
+++ branches/2.0.0-evol-499-storage/src/test/java/org/chorem/jtimer/storage/StorageTest.java 2013-07-11 21:34:52 UTC (rev 2903)
@@ -3,7 +3,6 @@
import java.io.File;
import org.chorem.jtimer.AbstractJTimerTest;
-import org.chorem.jtimer.JTimer;
import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
@@ -20,9 +19,9 @@
@BeforeMethod
public void setUp() {
String location = System.getProperty("java.io.tmpdir") + File.separator + "jtimer";
- JTimer.config.setStrorageDatabaseLocation(location);
+ //JTimer.config.setStrorageDatabaseLocation(location);
- storage = new Storage(JTimer.config);
+ //storage = new Storage(JTimer.config);
}
@Test
Modified: branches/2.0.0-evol-499-storage/src/test/java/org/chorem/jtimer/system/SystemInfoFactoryTest.java
===================================================================
--- branches/2.0.0-evol-499-storage/src/test/java/org/chorem/jtimer/ui/system/SystemInfoFactoryTest.java 2013-07-11 20:30:35 UTC (rev 2902)
+++ branches/2.0.0-evol-499-storage/src/test/java/org/chorem/jtimer/system/SystemInfoFactoryTest.java 2013-07-11 21:34:52 UTC (rev 2903)
@@ -23,15 +23,14 @@
* #L%
*/
-package org.chorem.jtimer.ui.system;
+package org.chorem.jtimer.system;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.jtimer.AbstractJTimerTest;
-import org.chorem.jtimer.ui.report.ReportGeneratorTest;
-import org.chorem.jtimer.ui.system.SystemInfo;
-import org.chorem.jtimer.ui.system.SystemInfoFactory;
-import org.chorem.jtimer.ui.system.UnsupportedSystemInfoException;
+import org.chorem.jtimer.system.SystemInfo;
+import org.chorem.jtimer.system.SystemInfoFactory;
+import org.chorem.jtimer.system.UnsupportedSystemInfoException;
import org.testng.Assert;
import org.testng.annotations.Test;
@@ -47,7 +46,7 @@
public class SystemInfoFactoryTest extends AbstractJTimerTest {
/** log. */
- private static Log log = LogFactory.getLog(ReportGeneratorTest.class);
+ private static Log log = LogFactory.getLog(SystemInfoFactoryTest.class);
/**
* Test to get system info.
1
0
Author: echatellier
Date: 2013-07-11 22:30:35 +0200 (Thu, 11 Jul 2013)
New Revision: 2902
Url: http://chorem.org/projects/jtimer/repository/revisions/2902
Log:
Remove old branches
Removed:
branches/1.3.x/
branches/1.4.0-ttalgo/
1
0