Jtimer-commits
Threads by month
- ----- 2026 -----
- August
- July
- 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
July 26, 2013
Author: echatellier
Date: 2013-07-26 23:09:49 +0200 (Fri, 26 Jul 2013)
New Revision: 2917
Url: http://chorem.org/projects/jtimer/repository/revisions/2917
Log:
Start chromium and add systray menu
Added:
branches/ng-jtimer/jtimer-server/src/main/go/systray.go
branches/ng-jtimer/jtimer-server/src/main/go/ui.go
Modified:
branches/ng-jtimer/jtimer-server/src/main/go/jtimer.go
branches/ng-jtimer/jtimer-server/src/main/go/readme.txt
Modified: branches/ng-jtimer/jtimer-server/src/main/go/jtimer.go
===================================================================
--- branches/ng-jtimer/jtimer-server/src/main/go/jtimer.go 2013-07-26 20:04:45 UTC (rev 2916)
+++ branches/ng-jtimer/jtimer-server/src/main/go/jtimer.go 2013-07-26 21:09:49 UTC (rev 2917)
@@ -27,13 +27,14 @@
import (
"fmt"
+ "log"
+ "time"
+ "os"
"net/http"
- "time"
"github.com/BurntSushi/xgb"
"github.com/BurntSushi/xgb/xproto"
"github.com/BurntSushi/xgb/screensaver"
"code.google.com/p/go.net/websocket"
- "log"
)
func RunIdleReporting() {
@@ -74,5 +75,9 @@
func main() {
go StartWebsocketServer()
- RunIdleReporting()
+ go RunIdleReporting()
+ cmd := RunClient()
+ cmd.Start()
+ InstallSystray(&os.Args)
+ cmd.Process.Kill()
}
Modified: branches/ng-jtimer/jtimer-server/src/main/go/readme.txt
===================================================================
--- branches/ng-jtimer/jtimer-server/src/main/go/readme.txt 2013-07-26 20:04:45 UTC (rev 2916)
+++ branches/ng-jtimer/jtimer-server/src/main/go/readme.txt 2013-07-26 21:09:49 UTC (rev 2917)
@@ -5,12 +5,13 @@
--------------------
go get github.com/BurntSushi/xgb/screensaver
go get code.google.com/p/go.net/websocket
+go get github.com/mattn/go-gtk/gtk
Lancement
---------
-go run *.go
+go run [^j]*.go jtimer.go
Compilation
-----------
-go build -o jtimer *.go
+go build -o jtimer [^j]*.go jtimer.go
Added: branches/ng-jtimer/jtimer-server/src/main/go/systray.go
===================================================================
--- branches/ng-jtimer/jtimer-server/src/main/go/systray.go (rev 0)
+++ branches/ng-jtimer/jtimer-server/src/main/go/systray.go 2013-07-26 21:09:49 UTC (rev 2917)
@@ -0,0 +1,48 @@
+package main
+
+import (
+ "github.com/mattn/go-gtk/gtk"
+ "github.com/mattn/go-gtk/glib"
+)
+
+func InstallSystray(args *[]string) {
+ gtk.Init(args)
+
+ glib.SetApplicationName("go-gtk-statusicon-example")
+
+ // Popup menu
+ popupMenu := gtk.NewMenu()
+
+ // Hide menu item
+ miHide := gtk.NewMenuItemWithLabel("Cacher")
+ miHide.Connect("activate", func() {
+
+ })
+ popupMenu.Append(miHide)
+
+ // Stop all task
+ popupMenu.Append(gtk.NewSeparatorMenuItem())
+ miStop := gtk.NewMenuItemWithLabel("Arrêter toutes les tâches")
+ miStop.Connect("activate", func() {
+
+ })
+ popupMenu.Append(miStop)
+
+ // Quit
+ miQuit := gtk.NewMenuItemWithLabel("Quitter")
+ miQuit.Connect("activate", func() {
+ gtk.MainQuit()
+ })
+ popupMenu.Append(miQuit)
+
+ // install systray with popup menu
+ popupMenu.ShowAll()
+ si := gtk.NewStatusIconFromFile("jtimer-40-green.png")
+ si.SetTitle("jTimer")
+ si.SetTooltipMarkup("jTimer 2.0")
+ si.Connect("popup-menu", func(cbx *glib.CallbackContext) {
+ popupMenu.Popup(nil, nil, gtk.StatusIconPositionMenu, si, uint(cbx.Args(0)), uint32(cbx.Args(1)))
+ })
+
+ gtk.Main()
+}
\ No newline at end of file
Added: branches/ng-jtimer/jtimer-server/src/main/go/ui.go
===================================================================
--- branches/ng-jtimer/jtimer-server/src/main/go/ui.go (rev 0)
+++ branches/ng-jtimer/jtimer-server/src/main/go/ui.go 2013-07-26 21:09:49 UTC (rev 2917)
@@ -0,0 +1,11 @@
+package main
+
+import (
+ "os/exec"
+)
+
+func RunClient() *exec.Cmd {
+ binary, _ := exec.LookPath("chromium")
+ return exec.Command(binary, "--app=http://localhost:8080",
+ "--user-data-dir=/tmp/jtimer")
+}
1
0
r2916 - in branches/ng-jtimer/jtimer-server/src/main: go webapp/js
by echatellier@users.chorem.org July 26, 2013
by echatellier@users.chorem.org July 26, 2013
July 26, 2013
Author: echatellier
Date: 2013-07-26 22:04:45 +0200 (Fri, 26 Jul 2013)
New Revision: 2916
Url: http://chorem.org/projects/jtimer/repository/revisions/2916
Log:
Add go websocket server and js client
Added:
branches/ng-jtimer/jtimer-server/src/main/go/conn.go
branches/ng-jtimer/jtimer-server/src/main/go/hub.go
branches/ng-jtimer/jtimer-server/src/main/go/readme.txt
Modified:
branches/ng-jtimer/jtimer-server/src/main/go/jtimer.go
branches/ng-jtimer/jtimer-server/src/main/webapp/js/controllers.js
Added: branches/ng-jtimer/jtimer-server/src/main/go/conn.go
===================================================================
--- branches/ng-jtimer/jtimer-server/src/main/go/conn.go (rev 0)
+++ branches/ng-jtimer/jtimer-server/src/main/go/conn.go 2013-07-26 20:04:45 UTC (rev 2916)
@@ -0,0 +1,43 @@
+package main
+
+import (
+ "code.google.com/p/go.net/websocket"
+)
+
+type connection struct {
+ // The websocket connection.
+ ws *websocket.Conn
+
+ // Buffered channel of outbound messages.
+ send chan string
+}
+
+func (c *connection) reader() {
+ for {
+ var message string
+ err := websocket.Message.Receive(c.ws, &message)
+ if err != nil {
+ break
+ }
+ h.broadcast <- message
+ }
+ c.ws.Close()
+}
+
+func (c *connection) writer() {
+ for message := range c.send {
+ err := websocket.Message.Send(c.ws, message)
+ if err != nil {
+ break
+ }
+ }
+ c.ws.Close()
+}
+
+func wsHandler(ws *websocket.Conn) {
+ c := &connection{send: make(chan string, 256), ws: ws}
+ h.register <- c
+ defer func() { h.unregister <- c }()
+ go c.writer()
+ c.reader()
+}
\ No newline at end of file
Added: branches/ng-jtimer/jtimer-server/src/main/go/hub.go
===================================================================
--- branches/ng-jtimer/jtimer-server/src/main/go/hub.go (rev 0)
+++ branches/ng-jtimer/jtimer-server/src/main/go/hub.go 2013-07-26 20:04:45 UTC (rev 2916)
@@ -0,0 +1,44 @@
+package main
+
+type hub struct {
+ // Registered connections.
+ connections map[*connection]bool
+
+ // Inbound messages from the connections.
+ broadcast chan string
+
+ // Register requests from the connections.
+ register chan *connection
+
+ // Unregister requests from connections.
+ unregister chan *connection
+}
+
+var h = hub{
+ broadcast: make(chan string),
+ register: make(chan *connection),
+ unregister: make(chan *connection),
+ connections: make(map[*connection]bool),
+}
+
+func (h *hub) run() {
+ for {
+ select {
+ case c := <-h.register:
+ h.connections[c] = true
+ case c := <-h.unregister:
+ delete(h.connections, c)
+ close(c.send)
+ case m := <-h.broadcast:
+ for c := range h.connections {
+ select {
+ case c.send <- m:
+ default:
+ delete(h.connections, c)
+ close(c.send)
+ go c.ws.Close()
+ }
+ }
+ }
+ }
+}
Modified: branches/ng-jtimer/jtimer-server/src/main/go/jtimer.go
===================================================================
--- branches/ng-jtimer/jtimer-server/src/main/go/jtimer.go 2013-07-26 17:24:01 UTC (rev 2915)
+++ branches/ng-jtimer/jtimer-server/src/main/go/jtimer.go 2013-07-26 20:04:45 UTC (rev 2916)
@@ -1,35 +1,42 @@
+/*
+ * 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>.
+ */
+
package main
+/**
+ * Start a web socket server on port 12345.
+ * Notify idleness on ws://localhost:12345/jtimer
+ *
+ * jTimer ui can connect to ws://localhost:12345/jtimer to receive idle activity
+ */
+
import (
"fmt"
"net/http"
"time"
- //"log"
- //"strconv"
"github.com/BurntSushi/xgb"
"github.com/BurntSushi/xgb/xproto"
"github.com/BurntSushi/xgb/screensaver"
"code.google.com/p/go.net/websocket"
+ "log"
)
-
-// echo back the websocket.
-func EchoServer(ws *websocket.Conn) {
- var message string
- websocket.Message.Receive(ws, &message)
- fmt.Println("[Received] ", message)
-}
-
-func WebSocketServer() {
- http.Handle("/echo", websocket.Handler(EchoServer));
- err := http.ListenAndServe(":12345", nil);
- if err != nil {
- //panic("ListenAndServe: ", err.String())
- fmt.Println("[Debug] ");
- }
-}
-
-func RunTimer() {
+func RunIdleReporting() {
X, err := xgb.NewConn()
if err != nil {
fmt.Println(err)
@@ -42,8 +49,8 @@
screensaver.Init(X)
// connect to webscocket server
- origin := "http://localhost:12345/"
- url := "ws://localhost:12345/echo"
+ origin := "http://localhost:8080/"
+ url := "ws://localhost:12345/jtimer"
for {
time.Sleep(1 * time.Second)
@@ -53,14 +60,19 @@
ws, _ := websocket.Dial(url, "", origin)
msSinceUserInputString := fmt.Sprintf("{idle:%d}", reply.MsSinceUserInput)
- /*if _, err := ws.Write([]byte(msSinceUserInputString)); err != nil {
- log.Fatal(err)
- }*/
websocket.Message.Send(ws, msSinceUserInputString)
}
}
+func StartWebsocketServer() {
+ go h.run()
+ http.Handle("/jtimer", websocket.Handler(wsHandler))
+ if err := http.ListenAndServe(":12345", nil); err != nil {
+ log.Fatal("ListenAndServe:", err)
+ }
+}
+
func main() {
- go WebSocketServer()
- RunTimer()
+ go StartWebsocketServer()
+ RunIdleReporting()
}
Added: branches/ng-jtimer/jtimer-server/src/main/go/readme.txt
===================================================================
--- branches/ng-jtimer/jtimer-server/src/main/go/readme.txt (rev 0)
+++ branches/ng-jtimer/jtimer-server/src/main/go/readme.txt 2013-07-26 20:04:45 UTC (rev 2916)
@@ -0,0 +1,16 @@
+Compilation do client go
+========================
+
+Packages necessaires
+--------------------
+go get github.com/BurntSushi/xgb/screensaver
+go get code.google.com/p/go.net/websocket
+
+Lancement
+---------
+go run *.go
+
+
+Compilation
+-----------
+go build -o jtimer *.go
Modified: branches/ng-jtimer/jtimer-server/src/main/webapp/js/controllers.js
===================================================================
--- branches/ng-jtimer/jtimer-server/src/main/webapp/js/controllers.js 2013-07-26 17:24:01 UTC (rev 2915)
+++ branches/ng-jtimer/jtimer-server/src/main/webapp/js/controllers.js 2013-07-26 20:04:45 UTC (rev 2916)
@@ -321,4 +321,12 @@
// force the first tree creation
$scope.createTree();
+
+ var conn = conn = new WebSocket("ws://localhost:12345/jtimer");
+ conn.onclose = function(evt) {
+ console.log("Connection closed.");
+ };
+ conn.onmessage = function(evt) {
+ console.log("Message", evt.data);
+ };
}
1
0
r2915 - in branches/ng-jtimer/jtimer-server/src/main/webapp: . js partials
by bpoussin@users.chorem.org July 26, 2013
by bpoussin@users.chorem.org July 26, 2013
July 26, 2013
Author: bpoussin
Date: 2013-07-26 19:24:01 +0200 (Fri, 26 Jul 2013)
New Revision: 2915
Url: http://chorem.org/projects/jtimer/repository/revisions/2915
Log:
fix bug refresh in add/remove task
Modified:
branches/ng-jtimer/jtimer-server/src/main/webapp/js/app.js
branches/ng-jtimer/jtimer-server/src/main/webapp/js/controllers.js
branches/ng-jtimer/jtimer-server/src/main/webapp/js/entities.js
branches/ng-jtimer/jtimer-server/src/main/webapp/partials/tasks.html
branches/ng-jtimer/jtimer-server/src/main/webapp/webtimer.appcache
Modified: branches/ng-jtimer/jtimer-server/src/main/webapp/js/app.js
===================================================================
--- branches/ng-jtimer/jtimer-server/src/main/webapp/js/app.js 2013-07-26 17:23:14 UTC (rev 2914)
+++ branches/ng-jtimer/jtimer-server/src/main/webapp/js/app.js 2013-07-26 17:24:01 UTC (rev 2915)
@@ -134,6 +134,11 @@
update(tree);
}
});
+ isNewElement && childScope.$watch("$node.children.length", function (newValue, oldValue, scope) {
+ if (newValue !== oldValue) {
+ update(tree);
+ }
+ });
if (!isNewElement) {
animate.move(cacheEntry.element, null, lastElement);
Modified: branches/ng-jtimer/jtimer-server/src/main/webapp/js/controllers.js
===================================================================
--- branches/ng-jtimer/jtimer-server/src/main/webapp/js/controllers.js 2013-07-26 17:23:14 UTC (rev 2914)
+++ branches/ng-jtimer/jtimer-server/src/main/webapp/js/controllers.js 2013-07-26 17:24:01 UTC (rev 2915)
@@ -115,10 +115,14 @@
* Ajoute une tache root
*/
$scope.addTask = function() {
- $scope.data.tasks.push(new Task($scope.name));
+ var newTask = new Task($scope.name);
+ $scope.data.tasks.push(newTask);
$scope.name = "";
save();
- $scope.createTree();
+ if (tree) {
+ tree.addChild($scope.createTreeNode(newTask));
+ }
+// $scope.createTree();
};
/**
@@ -127,28 +131,33 @@
*/
$scope.addSubTask = function(node) {
var task = node.task;
- $scope.data.tasks.push(new Task("New task", task.taskId));
+ var newTask = new Task("New task", task.taskId);
+ $scope.data.tasks.push(newTask);
node.$$open = true;
save();
- $scope.createTree();
+ node.addChild($scope.createTreeNode(newTask));
+// $scope.createTree();
};
/**
* Supprime une tache (et ces sous taches recursivement)
* @param {type} task
*/
- $scope.removeTask = function(task) {
+ $scope.removeTask = function(node) {
// methode pour faire la suppression recursivement
var removeRecurse = function(tasks) {
- angular.forEach(tasks, function() {
+ angular.forEach(tasks, function(task) {
task.remove();
var children = $scope.getChildren(task);
removeRecurse(children);
});
};
- removeRecurse([task]);
+ // mark all task as removed
+ removeRecurse([node.task]);
+ // remove node in tree
+ node.remove();
save();
- $scope.createTree();
+// $scope.createTree();
};
/**
Modified: branches/ng-jtimer/jtimer-server/src/main/webapp/js/entities.js
===================================================================
--- branches/ng-jtimer/jtimer-server/src/main/webapp/js/entities.js 2013-07-26 17:23:14 UTC (rev 2914)
+++ branches/ng-jtimer/jtimer-server/src/main/webapp/js/entities.js 2013-07-26 17:24:01 UTC (rev 2915)
@@ -150,11 +150,32 @@
this.localTimes = localTimes || [];
children = angular.forEach(children, function(child) {
child.parent = this;
- });
+ }, this);
this.children = children || [];
};
/**
+ * Ce retire de l'arbre
+ * @returns {undefined}
+ */
+TreeNode.prototype.remove = function() {
+ if (this.parent) {
+ var brothers = this.parent.children;
+ var match = brothers.indexOf(this);
+
+ if (match > -1 ) {
+ brothers.splice(match, 1);
+ delete this.parent;
+ }
+ }
+};
+
+TreeNode.prototype.addChild = function(node) {
+ node.parent = this;
+ this.children.push(node);
+};
+
+/**
* Copie toutes les donnees d'etat d'une noeud
* @param {TreeNode} node
* @returns {undefined}
Modified: branches/ng-jtimer/jtimer-server/src/main/webapp/partials/tasks.html
===================================================================
--- branches/ng-jtimer/jtimer-server/src/main/webapp/partials/tasks.html 2013-07-26 17:23:14 UTC (rev 2914)
+++ branches/ng-jtimer/jtimer-server/src/main/webapp/partials/tasks.html 2013-07-26 17:24:01 UTC (rev 2915)
@@ -20,7 +20,7 @@
<i ng-class="{'icon-play' : ($node.task != currentTask), 'icon-stop' : ($node.task == currentTask)}"></i>
</a>
<a class="btn btn-mini" href="" ng-click="addSubTask($node)"><i class="icon-plus"></i></a>
- <a class="btn btn-mini" href="" ng-click="removeTask($node.task)"><i class="icon-minus"></i></a>
+ <a class="btn btn-mini" href="" ng-click="removeTask($node)"><i class="icon-minus"></i></a>
</span>
</div>
@@ -67,7 +67,7 @@
</div>
<div id="footer">
<span class="left">{{currentDate()}}</span>
- <span class="center"><a href="#">WebTimer</a><i class="icon-html5"></i></span>
+ <span class="center"><i class="icon-html5"></i> <a href="#">WebTimer</a></span>
<span class="right">{{tree.getTime().today |time}} | {{tree.getTime().global | time}}</a>
</div>
Modified: branches/ng-jtimer/jtimer-server/src/main/webapp/webtimer.appcache
===================================================================
--- branches/ng-jtimer/jtimer-server/src/main/webapp/webtimer.appcache 2013-07-26 17:23:14 UTC (rev 2914)
+++ branches/ng-jtimer/jtimer-server/src/main/webapp/webtimer.appcache 2013-07-26 17:24:01 UTC (rev 2915)
@@ -1,5 +1,5 @@
CACHE MANIFEST
-# version 11
+# version 12
CACHE:
index.html
1
0
July 26, 2013
Author: bpoussin
Date: 2013-07-26 19:23:14 +0200 (Fri, 26 Jul 2013)
New Revision: 2914
Url: http://chorem.org/projects/jtimer/repository/revisions/2914
Log:
disable web app during devel
Modified:
branches/ng-jtimer/jtimer-server/src/main/webapp/index.html
Modified: branches/ng-jtimer/jtimer-server/src/main/webapp/index.html
===================================================================
--- branches/ng-jtimer/jtimer-server/src/main/webapp/index.html 2013-07-26 16:11:03 UTC (rev 2913)
+++ branches/ng-jtimer/jtimer-server/src/main/webapp/index.html 2013-07-26 17:23:14 UTC (rev 2914)
@@ -1,5 +1,5 @@
<!DOCTYPE html>
-<html lang="en" ng-app="webtimer" manifest="webtimer.appcache">
+<html lang="en" ng-app="webtimer" zmanifest="webtimer.appcache">
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
1
0
r2913 - in branches/ng-jtimer: . jtimer-server jtimer-server/src/main/config
by bpoussin@users.chorem.org July 26, 2013
by bpoussin@users.chorem.org July 26, 2013
July 26, 2013
Author: bpoussin
Date: 2013-07-26 18:11:03 +0200 (Fri, 26 Jul 2013)
New Revision: 2913
Url: http://chorem.org/projects/jtimer/repository/revisions/2913
Log:
change wro generation during devel time
Modified:
branches/ng-jtimer/jtimer-server/pom.xml
branches/ng-jtimer/jtimer-server/src/main/config/wro.xml
branches/ng-jtimer/pom.xml
Modified: branches/ng-jtimer/jtimer-server/pom.xml
===================================================================
--- branches/ng-jtimer/jtimer-server/pom.xml 2013-07-26 16:06:59 UTC (rev 2912)
+++ branches/ng-jtimer/jtimer-server/pom.xml 2013-07-26 16:11:03 UTC (rev 2913)
@@ -53,6 +53,7 @@
<plugin>
<groupId>ro.isdc.wro4j</groupId>
<artifactId>wro4j-maven-plugin</artifactId>
+
<executions>
<execution>
<phase>generate-resources</phase>
@@ -65,8 +66,13 @@
<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>
+<!-- hack during devel, otherwize tomcat don't find generated file (perhaps it's not the good place ?)
+ <cssDestinationFolder>${basedir}/target/${projectId}-${project.version}/css</cssDestinationFolder>
+ <jsDestinationFolder>${basedir}/target/${projectId}-${project.version}/js</jsDestinationFolder>
+ -->
+ <cssDestinationFolder>${basedir}/src/main/webapp/css</cssDestinationFolder>
+ <jsDestinationFolder>${basedir}/src/main/webapp/js</jsDestinationFolder>
+ <!-- end devel hack-->
<wroManagerFactory>org.nuiton.js.wro.NuitonJsMavenWroManagerFactory</wroManagerFactory>
<wroFile>${basedir}/src/main/config/wro.xml</wroFile>
<extraConfigFile>${basedir}/src/main/config/wro.properties</extraConfigFile>
Modified: branches/ng-jtimer/jtimer-server/src/main/config/wro.xml
===================================================================
--- branches/ng-jtimer/jtimer-server/src/main/config/wro.xml 2013-07-26 16:06:59 UTC (rev 2912)
+++ branches/ng-jtimer/jtimer-server/src/main/config/wro.xml 2013-07-26 16:11:03 UTC (rev 2913)
@@ -3,7 +3,11 @@
<group-ref>angular</group-ref>
<group-ref>jquery</group-ref>
<group-ref>bootstrap</group-ref>
- <css>/styles/*.css</css>
- <js>/scripts/*.js</js>
+ <group-ref>font-awesome</group-ref>
+ <group-ref>moment</group-ref>
+ <!-- direct import in html file during development
+ <css>/webtimer/css/*.css</css>
+ <js>/webtimer/js/*.js</js>
+ -->
</group>
</groups>
Modified: branches/ng-jtimer/pom.xml
===================================================================
--- branches/ng-jtimer/pom.xml 2013-07-26 16:06:59 UTC (rev 2912)
+++ branches/ng-jtimer/pom.xml 2013-07-26 16:11:03 UTC (rev 2913)
@@ -66,6 +66,16 @@
<version>2.3.2-1</version>
</dependency>
<dependency>
+ <groupId>org.nuiton.js</groupId>
+ <artifactId>nuiton-js-moment</artifactId>
+ <version>2.0.0-1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.nuiton.js</groupId>
+ <artifactId>nuiton-js-font-awesome</artifactId>
+ <version>3.2.1-1-SNAPSHOT</version>
+ </dependency>
+ <dependency>
<groupId>ro.isdc.wro4j</groupId>
<artifactId>wro4j-extensions</artifactId>
<version>1.7.0</version>
1
0
r2912 - in branches/ng-jtimer/jtimer-server/src/main/webapp: . css js partials
by bpoussin@users.chorem.org July 26, 2013
by bpoussin@users.chorem.org July 26, 2013
July 26, 2013
Author: bpoussin
Date: 2013-07-26 18:06:59 +0200 (Fri, 26 Jul 2013)
New Revision: 2912
Url: http://chorem.org/projects/jtimer/repository/revisions/2912
Log:
first version of web ui (webtimer)
- remove old web directory
Added:
branches/ng-jtimer/jtimer-server/src/main/webapp/css/
branches/ng-jtimer/jtimer-server/src/main/webapp/css/app.css
branches/ng-jtimer/jtimer-server/src/main/webapp/index.html
branches/ng-jtimer/jtimer-server/src/main/webapp/js/
branches/ng-jtimer/jtimer-server/src/main/webapp/js/app.js
branches/ng-jtimer/jtimer-server/src/main/webapp/js/controllers.js
branches/ng-jtimer/jtimer-server/src/main/webapp/js/entities.js
branches/ng-jtimer/jtimer-server/src/main/webapp/js/filters.js
branches/ng-jtimer/jtimer-server/src/main/webapp/partials/
branches/ng-jtimer/jtimer-server/src/main/webapp/partials/about.html
branches/ng-jtimer/jtimer-server/src/main/webapp/partials/contact.html
branches/ng-jtimer/jtimer-server/src/main/webapp/partials/tasks.html
branches/ng-jtimer/jtimer-server/src/main/webapp/webtimer.appcache
Removed:
branches/ng-jtimer/jtimer-server/src/main/webapp/web/
Added: branches/ng-jtimer/jtimer-server/src/main/webapp/css/app.css
===================================================================
--- branches/ng-jtimer/jtimer-server/src/main/webapp/css/app.css (rev 0)
+++ branches/ng-jtimer/jtimer-server/src/main/webapp/css/app.css 2013-07-26 16:06:59 UTC (rev 2912)
@@ -0,0 +1,243 @@
+
+body{
+ margin:0;
+ padding: 60px 0 20px 0;
+}
+div#header {
+ position:absolute;
+ top:0;
+ left:0;
+ width:100%;
+ height: 35px;
+ z-index: 1000;
+
+ background:black;
+ color:graytext;
+}
+div#footer{
+ position:absolute;
+ bottom:0;
+ left:0;
+ width:100%;
+ height:20px;
+ z-index: 1000;
+
+ background:black;
+ color:graytext;
+}
+#footer>.left, #header>.left {
+ text-align: left;
+ position: absolute;
+ left: 0px;
+ top: 0px;
+ z-index: 10;
+}
+#footer>.center, #header>.center {
+ width: 100%;
+ height: 100%;
+ text-align: center;
+ display: block;
+ z-index: 5;
+}
+#footer>.right, #header>.right {
+ text-align: right;
+ position: absolute;
+ right: 0px;
+ top: 0px;
+ z-index: 10;
+}
+
+.menu-show {
+ display: block;
+ left: -170px
+}
+
+@media screen{
+ body div#header{
+ position:fixed;
+ }
+ body div#subheader{
+ position:fixed;
+ }
+ body div#footer{
+ position:fixed;
+ }
+}
+* html body{
+ overflow:hidden;
+}
+* html div#content{
+ height:100%;
+ overflow:auto;
+}
+
+.table {
+ display: table;
+}
+
+.table .tbody {
+ display: table-row-group;
+}
+
+.table .tr {
+ display: table-row;
+}
+
+.table .th {
+ display: table-cell;
+ font-weight: bold;
+ text-align: center;
+}
+
+.table .td {
+ display: table-cell;
+ position: relative;
+ overflow: hidden;
+ white-space: nowrap;
+ text-wrap: none;
+}
+
+.spacer.level1 {padding-left: 10px;}
+.spacer.level2 {padding-left: 20px;}
+.spacer.level3 {padding-left: 30px;}
+.spacer.level4 {padding-left: 40px;}
+.spacer.level5 {padding-left: 50px;}
+.spacer.level6 {padding-left: 60px;}
+.spacer.level7 {padding-left: 70px;}
+.spacer.level8 {padding-left: 80px;}
+.spacer.level9 {padding-left: 90px;}
+
+.th.name {
+
+}
+
+.th.today, .td.today, .th.global, .td.global {
+ width: 4em;
+ border-right: 1px #0088cc solid;
+}
+
+.td.today, .td.global {
+ text-align: right;
+}
+
+.th.tags {
+
+}
+
+
+
+/*
+body {
+ position: relative;
+ padding-top: 60px;
+}
+*/
+
+ul.tasks {
+ display : block;
+ width : 100%;
+ list-style: none;
+}
+
+li.task {
+ display : block;
+ width : 100%;
+ height: 32px;
+}
+
+li.task.title {
+ font-weight: bold;
+ font-size: medium;
+}
+
+li.task div {
+ width : 25%;
+ height: 32px;
+ float: left;
+}
+
+.names li.task div {
+ width : 100%;
+}
+
+.details li.task div {
+ width : 30%;
+}
+
+.names ul.tasks {
+ margin: 0 0 0 15px;
+}
+
+.details ul.tasks {
+ margin: 0 0 0 0;
+}
+
+form {
+ display : inline-block;
+ margin : 0px;
+}
+
+.filtering-enter {
+ -webkit-transition : all linear 0.2s;
+ -moz-transition : all linear 0.2s;
+ -o-transition : all linear 0.2s;
+ transition : all linear 0.2s;
+
+ /* The animation preparation code */
+ opacity : 0;
+ height : 0;
+}
+
+.filtering-enter.filtering-enter-active {
+ /* The animation code itself */
+ opacity : 1;
+ height : 42px;
+}
+
+.filtering-leave {
+ -webkit-transition : all linear 0.2s;
+ -moz-transition : all linear 0.2s;
+ -o-transition : all linear 0.2s;
+ transition : all linear 0.2s;
+
+ /* The animation preparation code */
+ opacity : 1;
+ height : 42px;
+}
+
+.filtering-leave.filtering-leave-active {
+ /* The animation code itself */
+ opacity : 0;
+ height : 0;
+}
+
+.btn-group.action {
+ display: none;
+ position: absolute;
+ right: 0;
+}
+
+div:hover > .btn-group.action {
+ display: inline;
+}
+
+.current-row {
+ background-color: #3a87ad;
+ color: white;
+}
+
+.selected-row {
+ background-color: #5ca9cf;
+}
+
+.tr:hover {
+ background-color: #7ecbef;
+}
+
+.online {
+ color: greenyellow;
+}
+
+.offline {
+ color: red;
+}
\ No newline at end of file
Added: branches/ng-jtimer/jtimer-server/src/main/webapp/index.html
===================================================================
--- branches/ng-jtimer/jtimer-server/src/main/webapp/index.html (rev 0)
+++ branches/ng-jtimer/jtimer-server/src/main/webapp/index.html 2013-07-26 16:06:59 UTC (rev 2912)
@@ -0,0 +1,21 @@
+<!DOCTYPE html>
+<html lang="en" ng-app="webtimer" manifest="webtimer.appcache">
+ <head>
+ <title></title>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+
+ <link rel="stylesheet" href="css/jtimer.css">
+ <script src="js/jtimer.js"></script>
+
+ <link rel="stylesheet" href="css/app.css">
+ <script src="js/app.js"></script>
+ <script src="js/controllers.js"></script>
+ <script src="js/filters.js"></script>
+ <script src="js/entities.js"></script>
+ </head>
+ <body>
+
+ <div id='content' ng-view></div>
+
+ </body>
+</html>
Property changes on: branches/ng-jtimer/jtimer-server/src/main/webapp/index.html
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: branches/ng-jtimer/jtimer-server/src/main/webapp/js/app.js
===================================================================
--- branches/ng-jtimer/jtimer-server/src/main/webapp/js/app.js (rev 0)
+++ branches/ng-jtimer/jtimer-server/src/main/webapp/js/app.js 2013-07-26 16:06:59 UTC (rev 2912)
@@ -0,0 +1,224 @@
+/**
+ * Cette directive permet de parcourir un Arbre, pour chaque noeud de l'arbre
+ * un l'element DOM est duplique.
+ * Il est possible
+ * - de filtrer les noeuds lors de la definition de l'arbre (wtTreeRepeat)
+ * (ex: wt-tree-repeat="tree | filter:query | orderBy:'task.name'")
+ * - d'afficher le noeud root ou non (wtDisplayRoot)
+ * - de forcer l'ouverture de tout les noeuds (wtForceOpen)
+ *
+ * Lors du parcours pour chaque noeud un nouveau scope est cree permettant
+ * d'utilise les variables:
+ * - $node le noeud courant de l'arbre
+ * - $index l'index de parcours de ce noeud (0 pour le root)
+ * - $level la profondeur de ce noeud (0 pour le root)
+ * - $state l'etat de ce noeud ('empty', 'open', 'close')
+ * - $path le chemin pour arriver a ce noeud (tous ces noeuds parents)
+ * - $pathIndex le chemin pour arriver a ce noeud par index dans le tableau children du pere
+ * - $toggleState une fonction qui permet de changer l'etat d'un noeud ('open' <-> 'close')
+
+ *
+ * @param {ngAnimator} $animator permet l'ajout, suppression des noeuds dans le DOM
+ * @param {ngFilter} $filter permet de filtrer les elements de l'arbre a afficher (filtre, tri, ...)
+ * @param {ngParse} $parse permet de parser des expressions qui doivent etre evaluer regulierement sur une scope
+ */
+var wtTreeRepeatDirective = ['$animator', '$filter', '$parse', function($animator, $filter, $parse) {
+ return {
+ transclude: 'element',
+ priority: 1000,
+ terminal: true,
+ compile: function(element, attr, linker) {
+ return function($scope, $element, $attr){
+ var animate = $animator($scope, $attr); // use to add/remove element
+
+ // sert a surveiller les changements sur la donnee ou les filtres
+ // qui engendrerait un besoin de rafraichissement.
+ // (ce tableau contient les fonctions permettant leur desenregistrement)
+ var watchers = [];
+ // element genere HTML et scope du dernier arbre represente
+ var cache = new Cache(animate);
+ // indique si l'element root doit etre affiche ou non (faux par defaut)
+ var displayRoot = $parse($attr.wtDisplayRoot || 'false');
+ // indique si l'arbre doit etre ouvert de facon forcee ou non (faux par defaut)
+ var forceOpen = $parse($attr.wtForceOpen || 'false');
+ // l'expression permettant de recuperer l'arbre et les filtres
+ var expression = $attr.wtTreeRepeat;
+
+ // les differents filtres a applique aux noeuds enfants
+ var filters = [];
+ var filterStrings = expression.split('|');
+ // l'expression pour la recuperation de arbre
+ var tree = filterStrings.shift();
+ // add tree as watcher
+ watchers.push(tree);
+ // add forceOpen as watcher
+ watchers.push($attr.wtForceOpen||'false');
+
+ // Recuperation des filtres et preparation pour etre pret
+ // a l'utilisation
+ angular.forEach(filterStrings, function(filterString) {
+ var argStrings = filterString.split(":");
+ var filterName = argStrings.shift().trim();
+ var argGetters = argStrings.map(function(e) {
+ // add all args as watcher
+ watchers.push(e);
+ var result = $parse(e);
+ return result;
+ });
+ var filter = function(children) {
+ var f = $filter(filterName);
+ var args = argGetters.map(function(a) {
+ return a($scope);
+ });
+ var result = f.apply(null, [children].concat(args));
+ return result;
+ };
+ filters.push(filter);
+ });
+
+ // met a jour l'affichage de l'arbre
+ var update = function(tree) {
+ // les objets HTML et scope utilise durant cette mise a jour
+ // qui pourront etre reutilise durant la mis a jour suivante
+ var newCache = new Cache(animate);
+
+ // l'index de parcours du noeud, on met dans un tableau
+ // pour avoir une reference lors du passage en argument
+ // et non pas une valeur lors des appels recursifs
+ var index = [0];
+ // le niveau du noeud
+ var level = 0;
+ var path = [];
+ var pathIndex = [];
+ // le dernier element HTML ajoute (il faut mettre le suivant apres celui-ci)
+ var lastElement = $element;
+
+ /**
+ * Genere un noeud et appel la fonction pour chaque noeud
+ * fils a affiche
+ */
+ var generate = function(node, index, level, path, pathIndex) {
+ var state = 'open'; // init to open, if root is not display
+
+ // on affiche le root que si demande
+ if (index[0] !== 0 || displayRoot($scope)) {
+ // try to find already created element
+ var cacheEntry = cache.get(node) || {node: node, scope:$scope.$new()};
+ node.copyState(cacheEntry.node); // copy les etats, les noeuds ouvert doivent rester ouvert
+ var isNewElement = !cacheEntry.element;
+
+ // new item which we don't know about
+ var childScope = cacheEntry.scope;
+
+ if (node.children.length === 0) {
+ state = 'empty';
+ } else {
+ if (node.$$open || forceOpen($scope)) {
+ state = 'open';
+ } else {
+ state = 'close';
+ }
+ }
+
+ childScope.$node = node;
+ childScope.$index = index[0];
+ childScope.$level = level;
+ childScope.$state = state;
+ childScope.$path = path;
+ childScope.$pathIndex = pathIndex;
+ childScope.$toggleState = function() {
+ node.$$open = !node.$$open;
+ };
+ isNewElement && childScope.$watch("$node.$$open", function (newValue, oldValue, scope) {
+ if (newValue !== oldValue) {
+ update(tree);
+ }
+ });
+
+ if (!isNewElement) {
+ animate.move(cacheEntry.element, null, lastElement);
+ lastElement = cacheEntry.element;
+ newCache.put(node, cacheEntry.element, cacheEntry.scope);
+ } else {
+ linker(childScope, function(clone) {
+ animate.enter(clone, null, lastElement);
+ lastElement = clone;
+ newCache.put(node, clone, childScope);
+ });
+ }
+ }
+ index[0]++;
+
+ if (state == 'open') {
+ var children = node.children;
+ filters.forEach(function(e) {
+ children = e(children);
+ });
+ for (var i = 0, length = children.length; i < length; i++) {
+ var child = children[i];
+ generate(child, index, level+1, path.concat([child]), pathIndex.concat([i]));
+ }
+ }
+ };
+
+ generate(tree, index, level, path, pathIndex);
+
+ // on nettoie les anciens noeud non reutilise
+ cache.clear();
+ // on met les nouveaux noeuds dans le cache pour la prochaine maj
+ cache = newCache;
+ };
+
+ // expression permettant de recupere facilement l'arbre
+ var treeGetter = $parse(tree);
+
+ // on enregistre chaque watcher sur le scope
+ angular.forEach(watchers, function (watcher) {
+ $scope.$watch(watcher, function(newValue, oldValue, scope){
+ if (newValue !== oldValue) {
+ var tree = treeGetter($scope);
+ update(tree);
+ }
+ });
+ });
+
+ // on force un premier appel pour que l'arbre s'affiche
+ update(treeGetter($scope));
+ };
+ }
+ };
+}];
+
+
+angular.module('webtimer', ['webtimerFilters'])
+ .config(['$routeProvider', function($routeProvider) {
+ $routeProvider.
+ when('/tasks', {templateUrl: 'partials/tasks.html', controller: TasksCtrl}).
+ when('/about', {templateUrl: 'partials/about.html'}).
+ when('/contact', {templateUrl: 'partials/contact.html'}).
+ otherwise({redirectTo: '/tasks'});
+ }])
+
+ .factory("$localStorage", function() {
+ // Encapsule l'acces au localStorage pour
+ // - ajouter un prefix au variable sauvee pour les differencier des autres ("WebTimer-")
+ var webtimerPrefix = "WebTimer-";
+ return {
+ set: function(key, value) {
+ key = webtimerPrefix + key;
+ // add version, to check version during read (get)
+ var item = value.toJson();
+ window.localStorage.setItem(key, item);
+ },
+ get: function(key) {
+ key = webtimerPrefix + key;
+ var item = window.localStorage.getItem(key);
+ var result = new WebTimerData();
+ result.fromJson(item);
+
+ return result;
+ }
+ };
+ })
+
+ .directive('wtTreeRepeat', wtTreeRepeatDirective);
Added: branches/ng-jtimer/jtimer-server/src/main/webapp/js/controllers.js
===================================================================
--- branches/ng-jtimer/jtimer-server/src/main/webapp/js/controllers.js (rev 0)
+++ branches/ng-jtimer/jtimer-server/src/main/webapp/js/controllers.js 2013-07-26 16:06:59 UTC (rev 2912)
@@ -0,0 +1,315 @@
+function TasksCtrl($scope, $timeout, $localStorage, $window, $document) {
+
+ /**
+ * {Boolean} vrai si on est online
+ */
+ $scope.online = $window.navigator.onLine;
+
+ // {WebTimerData} toutes les donnees
+ $scope.data = $localStorage.get("data");
+ // {TreeNode} l'arbre regenere automatiquement lorsque les donnees changent
+ $scope.tree;
+ // {Array of Function} les listeners qui surveille l'ajout de nouveau temps, et qui les ajoutes dans l'arbre
+ $scope.treeWatcher = [];
+ // {String} le nom de la nouvelle tache a creer
+ $scope.name = "";
+ // {Task} la derniere tache selectionnee
+ $scope.selectedTask = null;
+ // {Task} la tache en cours de timing
+ $scope.currentTask = null;
+ // {Date in millis} le temps pour la tache en cours de timing
+ $scope.currentTaskDate = null;
+ // {String} le filtre d'affichage des noeuds (permet la recherche d'un noeud)
+ $scope.query = "";
+ // {boolean} boolean qui permet de force le depliage complet de l'arbre s'il est vrai
+ $scope.forceExpanded = false;
+
+ // {boolean} boolean qui indique si la colonne NAME doit etre affichee
+ $scope.showName = true;
+ // {boolean} boolean qui indique si la colonne TODAY doit etre affichee
+ $scope.showToday = true;
+ // {boolean} boolean qui indique si la colonne TOTAL doit etre affichee
+ $scope.showGlobal = true;
+ // {boolean} boolean qui indique si la colonne TAGS doit etre affichee
+ $scope.showTags = true;
+
+ /**
+ * Met a jour la tache selectionne, si la tache selectionnee est la courante
+ * alors on met la selection a null
+ * @param {Task} task
+ */
+ $scope.setSelectedTask = function(task) {
+ if ($scope.selectedTask === task) {
+ $scope.selectedTask = null;
+ } else {
+ $scope.selectedTask = task;
+ }
+ };
+
+ /**
+ * Permet de faire des actions sur la tache selectionne en fonction
+ * des touches pressees
+ * @param {type} e
+ * @returns {undefined}
+ */
+ $document[0].onkeydown = function(e){
+ console.log(e);
+ // i = 73; d = 68; F2 = 113
+ if ($scope.selectedTask) {
+ var taskTime = $scope.getTodayTaskTime($scope.selectedTask);
+ if (e.keyCode === 113) {
+ // edit task, time, note
+ } else if (e.keyCode === 73 && e.ctrlKey && e.shiftKey) {
+ // increment by 30min
+ taskTime.addTime(30*60*1000);
+ } else if (e.keyCode === 68 && e.ctrlKey && e.shiftKey) {
+ // decrement by 30min
+ taskTime.addTime(-30*60*1000);
+ } else if (e.keyCode === 73 && e.ctrlKey) {
+ // increment by 5min
+ taskTime.addTime(5*60*1000);
+ } else if (e.keyCode === 68 && e.ctrlKey) {
+ // decrement by 5min
+ taskTime.addTime(-5*60*1000);
+ }
+ }
+ };
+
+ $window.addEventListener("offline", function(e) {
+ $scope.online = false;
+ }, false);
+ $window.addEventListener("online", function(e) {
+ $scope.online = true;
+ }, false);
+
+
+
+ /**
+ * Force la sauvegarde des datas
+ * @returns {undefined}
+ */
+ var save = function() {
+ $localStorage.set("data", $scope.data);
+ };
+
+ /**
+ * Timer qui mais les temps a jour toutes les secondes si une tache est
+ * active
+ * @returns {undefined}
+ */
+ var refresh = function() {
+ $timeout(function() {
+ if ($scope.currentTask) {
+ var now = Date.now();
+ var taskTime = $scope.getTodayTaskTime($scope.currentTask);
+ taskTime.addTime(now - $scope.currentTaskDate);
+ $scope.currentTaskDate = now;
+ save();
+ }
+ refresh();
+ }, 1000);
+ };
+ refresh();
+
+ /**
+ * Ajoute une tache root
+ */
+ $scope.addTask = function() {
+ $scope.data.tasks.push(new Task($scope.name));
+ $scope.name = "";
+ save();
+ $scope.createTree();
+ };
+
+ /**
+ * Ajoute une sous tache a la tache du noeud passe en parametre
+ * @param {type} node
+ */
+ $scope.addSubTask = function(node) {
+ var task = node.task;
+ $scope.data.tasks.push(new Task("New task", task.taskId));
+ node.$$open = true;
+ save();
+ $scope.createTree();
+ };
+
+ /**
+ * Supprime une tache (et ces sous taches recursivement)
+ * @param {type} task
+ */
+ $scope.removeTask = function(task) {
+ // methode pour faire la suppression recursivement
+ var removeRecurse = function(tasks) {
+ angular.forEach(tasks, function() {
+ task.remove();
+ var children = $scope.getChildren(task);
+ removeRecurse(children);
+ });
+ };
+ removeRecurse([task]);
+ save();
+ $scope.createTree();
+ };
+
+ /**
+ * met a jour la variable $scope.tree par recreation de l'arbre
+ * Tous les listeners de l'ancien arbre sont enleves
+ */
+ $scope.createTree = function() {
+ // on supprime tous les watchers de l'arbre courant
+ angular.forEach($scope.treeWatcher, function(deregisterFuntion) {
+ // la methode stocker dans treeWatcher permet de desenregistrer le watcher
+ deregisterFuntion();
+ });
+ $scope.treeWatcher = [];
+
+ var nodes = [];
+ angular.forEach($scope.getRootTask(), function(t) {
+ var node = $scope.createTreeNode(t);
+ nodes.push(node);
+ });
+
+ var result = new TreeNode(new Task("root"), null, null, nodes);
+ $scope.tree = result;
+ };
+
+ /**
+ * Retourne la liste des enfants non supprime d'un noeud. Les sous taches
+ * retourne peuvent etre modifiee via encapsulationFuntion si elle existe
+ * @param {Task} task la tache dont on recherche les enfants
+ * @param {Funciton} encapsulationFuntion une methode appelee pour chaque enfant,
+ * qui peut retourner un autre objet que l'enfant
+ * @returns {Array of Task or other if encapsulationFuntion used}
+ */
+ $scope.getChildren = function (task, encapsulationFuntion) {
+ var result = [];
+ angular.forEach($scope.data.tasks, function (t) {
+ if (!t.isRemoved() && task.isParentOf(t)) {
+ var node = t;
+ if (encapsulationFuntion) {
+ node = encapsulationFuntion(node);
+ }
+ result.push(node);
+ }
+ });
+
+ return result;
+ };
+
+ /**
+ * Encapsule une tache dans un TreeNode. On ajoute un watcher sur les temps
+ * pour cette tache qui pousse les nouvelles donnes dans le noeud lorsqu'ils
+ * sont modifies
+ *
+ * @param {Task} task
+ * @returns {TreeNode}
+ */
+ $scope.createTreeNode = function(task) {
+ var globalTime = $scope.data.globalTimes[task.taskId] || new GlobalTime();
+ var localTimes = $scope.data.times[task.taskId] || [];
+ var children = $scope.getChildren(task, $scope.createTreeNode);
+ var node = new TreeNode(task, globalTime, localTimes, children);
+
+ var watcher = $scope.$watch("data.times['"+task.taskId+"']", function(localtimes) {
+ node.setTaskTimes(localtimes);
+ }, true);
+ $scope.treeWatcher.push(watcher);
+
+ return node;
+ };
+
+ /**
+ * Retourne la liste des taches root actif (non supprime)
+ * @returns {result}
+ */
+ $scope.getRootTask = function () {
+ var result = [];
+ angular.forEach($scope.data.tasks, function (t) {
+ if (t.isRoot() && !t.isRemoved()) {
+ result.push(t);
+ }
+ });
+ return result;
+ };
+
+ /**
+ * Retourne l'objet TaskTime d'aujourd'hui pour la tache demandee
+ * Si cet objet n'existait pas, il est cree et ajouter a la liste
+ * des objets temps existant
+ * @param {type} task
+ * @returns {nodes}
+ */
+ $scope.getTodayTaskTime = function(task) {
+ var times = $scope.data.times[task.taskId];
+ if (!times) {
+ times = [];
+ $scope.data.times[task.taskId]= times;
+ }
+
+ var result;
+ angular.forEach(times, function (t) {
+ if (!result && t.isToday()) {
+ result = t;
+ }
+ });
+
+ if (!result) {
+ result = new TaskTime(task);
+ times.push(result);
+ }
+
+ return result;
+ };
+
+ /**
+ * Lance l'edition du nom d'une tache
+ * @param {TreeNode} node
+ * @param {String} type le type d'action
+ */
+ $scope.editTask = function(node, type) {
+ node.edit = type;
+ save();
+ };
+
+ /**
+ * Sauve la modification de la tache
+ * @param {TreeNode} node
+ */
+ $scope.saveTask = function(node) {
+ node.edit = null;
+ save();
+ };
+
+ /**
+ * Active/desactive le comptage de temps pour une tache
+ * @param {type} task
+ * @param {type} element
+ */
+ $scope.timeTask = function(task, element) {
+ var now = Date.now();
+ if ($scope.currentTask) {
+ var taskTime = $scope.getTodayTaskTime($scope.currentTask);
+ taskTime.addTime(now - $scope.currentTaskDate);
+ }
+
+ if ($scope.currentTask !== task) {
+ $scope.currentTask = task;
+ $scope.currentTaskDate = now;
+ } else {
+ $scope.currentTask = null;
+ $scope.currentTaskDate = null;
+ }
+ save();
+ };
+
+ /**
+ * Retourne la date et heure courant
+ * @returns {String}
+ */
+ $scope.currentDate = function() {
+ return moment().format("HH:mm DD/MM/YYYY");
+ };
+
+ // force the first tree creation
+ $scope.createTree();
+}
Added: branches/ng-jtimer/jtimer-server/src/main/webapp/js/entities.js
===================================================================
--- branches/ng-jtimer/jtimer-server/src/main/webapp/js/entities.js (rev 0)
+++ branches/ng-jtimer/jtimer-server/src/main/webapp/js/entities.js 2013-07-26 16:06:59 UTC (rev 2912)
@@ -0,0 +1,347 @@
+/**
+ * Genere un UUID
+ * @returns {String}
+ */
+function generateUUID(){
+ var d = Date.now();
+ var uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
+ var r = (d + Math.random()*16)%16 | 0;
+ d = Math.floor(d/16);
+ return (c==='x' ? r : (r&0x7|0x8)).toString(16);
+ });
+ return uuid;
+};
+
+/**
+ * Retourne la date d'aujourd'hui sous la forme "2013-O7-25"
+ * @returns {String}
+ */
+function today() {
+ var result = moment().format("YYYY-MM-DD");
+ return result;
+}
+
+/**
+ * permet de gerer les elements HTML et scope creer pour chaque
+ * noeud et les reutilisers plutot que de les recreer a chaque mise a jour
+ *
+ * @param {ngAnimator} animate l'objet permettant de supprimer un noeud dans le DOM
+ * @returns {Cache}
+ */
+var Cache = function(animate) {
+ this.animate = animate;
+};
+Cache.prototype.put = function(node, element, scope) {
+ var id = node.task.taskId;
+ this[id] = {node: node, element: element, scope: scope};
+};
+Cache.prototype.get = function(nodeOrId) {
+ var id = nodeOrId;
+ if (!angular.isString(nodeOrId)) {
+ id = nodeOrId.task.taskId;
+ }
+ var result = this[id];
+ delete this[id];
+ return result;
+};
+
+Cache.prototype.clear = function() {
+ for (var key in this) {
+ if (this.hasOwnProperty(key) && key !== "animate") {
+ var entry = this[key];
+ this.animate.leave(entry.element);
+ entry.scope.$destroy();
+ }
+ }
+};
+
+
+/**
+ * Toutes les donnees qui sont a stocker entre 2 sessions
+ * @returns {WebTimerData}
+ */
+var WebTimerData = function() {
+ // la version des donnees
+ this.dataVersion = 1;
+
+ this.tasks = []; // Array of Task
+ this.globalTimes = {}; // key: taskId, value: GlobalTime
+ this.times = {}; // key: taskId, value: Array of TaskTime
+ this.notes = {}; // key: taskId, value: Array of TaskNote
+};
+
+/**
+ * Migre les donnees d'une version a une autre
+ * @param {Number} oldVersion
+ * @param {Number} newVersion
+ * @param {JSON} data
+ * @returns {JSON}
+ */
+WebTimerData.prototype.migrate = function(oldVersion, newVersion, data) {
+ return data;
+};
+
+/**
+ * Converti l'objet WebTimerData en Json en ajoutant
+ * @returns {JSON}
+ */
+WebTimerData.prototype.toJson = function() {
+ var result = angular.toJson(this);
+ return result;
+};
+
+/**
+ * Charge des donnees au format JSON les convertit dans le bon type d'objet,
+ * fait la migration des data si necessaire
+ * @param {JSON or JsonString} json
+ * @returns {WebTimerData} retourne lui meme
+ */
+WebTimerData.prototype.fromJson = function(json) {
+ if (angular.isString(json)) {
+ json = angular.fromJson(json);
+ }
+ if (json) {
+ if (json.dataVersion !== this.dataVersion) {
+ json = this.migrate(json.dataVersion, this.dataVersion, json);
+ }
+ if (json) {
+ angular.forEach(json.tasks, function (t) {
+ t = jQuery.extend(new Task(), t);
+ this.tasks.push(t);
+ }, this);
+
+ angular.forEach(json.globalTimes, function (t, k) {
+ t = jQuery.extend(new GlobalTime(), t);
+ this.globalTimes[k] = t;
+ }, this);
+
+ angular.forEach(json.times, function (times, k) {
+ this.times[k] = [];
+ angular.forEach(times, function (t) {
+ t = jQuery.extend(new TaskTime(), t);
+ this.times[k].push(t);
+ }, this);
+ }, this);
+
+ angular.forEach(json.notes, function (notes, k) {
+ this.notes[k] = [];
+ angular.forEach(notes, function (n, k) {
+ n = jQuery.extend(new TaskNote(), n);
+ this.notes[k].push(n);
+ }, this);
+ }, this);
+ }
+ }
+ return this;
+};
+
+/**
+ * Un noeud de l'arbre.
+ *
+ * @param {Task} task la tache a encapsuler
+ * @param {GlobalTime} globalTime les temps totaux provenant du serveur
+ * @param {Array of TaskTime} localTimes les temps crees localement
+ * @param {Array of TreeNode} children les enfants de ce noeud
+ * @returns {TreeNode}
+ */
+var TreeNode = function (task, globalTime, localTimes, children) {
+ this.task = task || new Task("root");
+ this.globalTime = globalTime || new GlobalTime();
+ this.localTimes = localTimes || [];
+ children = angular.forEach(children, function(child) {
+ child.parent = this;
+ });
+ this.children = children || [];
+};
+
+/**
+ * Copie toutes les donnees d'etat d'une noeud
+ * @param {TreeNode} node
+ * @returns {undefined}
+ */
+TreeNode.prototype.copyState = function(node) {
+ this.$$open = node.$$open;
+};
+
+/**
+ * Met a jour les temps locaux
+ *
+ * @param {Array of TaskTime} taskTimes
+ * @returns {undefined}
+ */
+TreeNode.prototype.setTaskTimes = function(taskTimes) {
+ this.localTimes = taskTimes;
+};
+
+/**
+ * Retourne le temps consolide pour ce noeud (temps glocal + locaux + enfant)
+ * @returns {GlobalTime}
+ */
+TreeNode.prototype.getTime = function() {
+ var result = new GlobalTime();
+ result.addGlobalTime(this.globalTime);
+ result.addTaskTimes(this.localTimes);
+ angular.forEach(this.children, function(node) {
+ var nodeTime = node.getTime();
+ result.addGlobalTime(nodeTime);
+ });
+ return result;
+};
+
+/**
+ * Objet permettant de stocke le temps total et le temps de la journee actuelle
+ *
+ * @param {Task} task
+ * @returns {GlobalTime}
+ */
+var GlobalTime = function (task) {
+ this.taskId = task && task.taskId;
+ this.today = 0;
+ this.global = 0;
+};
+
+/**
+ * Fait une copie de l'objet
+ * @returns {GlobalTime}
+ */
+GlobalTime.prototype.clone = function() {
+ var result = new GlobalTime();
+ result.add(this);
+ return result;
+};
+
+/**
+ * Ajoute les temps d'un GlobalTime
+ * @param {GlobalTime} globalTime
+ * @returns {GlobalTime} this
+ */
+GlobalTime.prototype.addGlobalTime = function(globalTime) {
+ this.global += globalTime.global;
+ this.today += globalTime.today;
+ return this;
+};
+
+/**
+ * Ajoute les temps d'un tableau de TaskTime au temps global et a today si
+ * la TaskTime est pour today
+ * @param {Array of TaskTime} taskTimes
+ * @returns {GlobalTime} this
+ */
+GlobalTime.prototype.addTaskTimes = function(taskTimes) {
+ angular.forEach(taskTimes, function(taskTime) {
+ this.global += taskTime.time;
+ if (taskTime.isToday()) {
+ this.today += taskTime.time;
+ }
+ }, this);
+ return this;
+};
+
+/**
+ * Represente une tache
+ * @param {type} name le nom de la tache
+ * @param {type} parentTaskId l'identifiant de la tache parente
+ * @returns {Task}
+ */
+var Task = function (name, parentTaskId) {
+ this.taskId = generateUUID();
+ this.creationDate = Date.now();
+ this.modificationDate = this.creationDate;
+ this.removed = 0;
+ this.parentTaskId = parentTaskId;
+ this.name = name;
+ this.description = "";
+ this.tags = [];
+ this.syncOptions = {};
+};
+
+/**
+ * Marque la tache comme supprimee
+ * @returns {undefined}
+ */
+Task.prototype.remove = function() {
+ this.removed = Date.now();
+};
+
+/**
+ * return vrai si la tache est supprimee
+ * @returns {boolean}
+ */
+Task.prototype.isRemoved = function() {
+ return !!this.removed;
+};
+
+/**
+ * Retourne vrai si la tache est parent de la sous tache passee en parametre
+ * @param {Task} subtask
+ * @returns {Boolean}
+ */
+Task.prototype.isParentOf = function(subtask) {
+ var result = subtask.parentTaskId === this.taskId;
+ return result;
+};
+
+/**
+ * Indique si la tache est une tache root (pas de parent)
+ * @returns {unresolved}
+ */
+Task.prototype.isRoot = function() {
+ var result = !this.parentTaskId;
+ return result;
+};
+
+/**
+ * Permet de conserve une temps cree localement
+ * @param {Task} task
+ * @returns {TaskTime}
+ */
+var TaskTime = function (task) {
+ this.taskId = task && task.taskId;
+ this.timeId = generateUUID();
+ this.date = today();
+ this.time = 0;
+};
+
+/**
+ * Retourne vrai si ce temps est pour aujourd'hui
+ * @returns {Boolean}
+ */
+TaskTime.prototype.isToday = function() {
+ var result = this.date === today();
+ return result;
+};
+
+/**
+ * ajoute du temps
+ * @param {Number} t
+ * @returns {TaskTime} this
+ */
+TaskTime.prototype.addTime = function(t) {
+ this.time += t;
+ if (this.time < 0) {
+ this.time = 0;
+ }
+ return this;
+};
+
+/**
+ * Represente une note pour une tache
+ * @param {Task} task
+ * @returns {TaskNote}
+ */
+var TaskNote = function (task) {
+ this.taskId = task && task.taskId;
+ this.noteId = generateUUID();
+ this.date = today();
+ this.text = "";
+};
+
+/**
+ * Retourne vrai si cette note est pour aujourd'hui
+ * @returns {Boolean}
+ */
+TaskNote.prototype.isToday = function() {
+ var result = this.date === today();
+ return result;
+};
+
Added: branches/ng-jtimer/jtimer-server/src/main/webapp/js/filters.js
===================================================================
--- branches/ng-jtimer/jtimer-server/src/main/webapp/js/filters.js (rev 0)
+++ branches/ng-jtimer/jtimer-server/src/main/webapp/js/filters.js 2013-07-26 16:06:59 UTC (rev 2912)
@@ -0,0 +1,8 @@
+var wtFilter = function(input) {
+ var date = moment(input).utc();
+ return date.diff(moment(0), 'hours') + ":" +date.format("mm:ss");
+};
+
+angular.module('webtimerFilters', []).filter('time', function() {
+ return wtFilter;
+});
Added: branches/ng-jtimer/jtimer-server/src/main/webapp/partials/about.html
===================================================================
--- branches/ng-jtimer/jtimer-server/src/main/webapp/partials/about.html (rev 0)
+++ branches/ng-jtimer/jtimer-server/src/main/webapp/partials/about.html 2013-07-26 16:06:59 UTC (rev 2912)
@@ -0,0 +1 @@
+WebTimer 1.0
Property changes on: branches/ng-jtimer/jtimer-server/src/main/webapp/partials/about.html
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: branches/ng-jtimer/jtimer-server/src/main/webapp/partials/contact.html
===================================================================
--- branches/ng-jtimer/jtimer-server/src/main/webapp/partials/contact.html (rev 0)
+++ branches/ng-jtimer/jtimer-server/src/main/webapp/partials/contact.html 2013-07-26 16:06:59 UTC (rev 2912)
@@ -0,0 +1 @@
+jtimer-users(a)listes.chorem.org
Property changes on: branches/ng-jtimer/jtimer-server/src/main/webapp/partials/contact.html
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: branches/ng-jtimer/jtimer-server/src/main/webapp/partials/tasks.html
===================================================================
--- branches/ng-jtimer/jtimer-server/src/main/webapp/partials/tasks.html (rev 0)
+++ branches/ng-jtimer/jtimer-server/src/main/webapp/partials/tasks.html 2013-07-26 16:06:59 UTC (rev 2912)
@@ -0,0 +1,88 @@
+<script type="text/ng-template" id="tree_item_renderer_details.html">
+ <div class="tr" ng-class="{'current-row' : ($node.task === currentTask), 'selected-row' : ($node.task === selectedTask)}"
+ ng-click="setSelectedTask($node.task)"
+ ng-dblclick="timeTask($node.task)"
+ ng-keydown="keyPressed($event)">
+ <div class="td" ng-show="showName">
+ <span class="spacer level{{$level}}"></span>
+ <i class="icon-ban-circle" ng-show="$state=='empty'"></i>
+ <i class="icon-plus-sign" ng-click="$toggleState()" ng-show="$state=='close'"></i>
+ <i class="icon-minus-sign" ng-click="$toggleState()" ng-show="$state=='open'"></i>
+
+ <form ng-submit="saveTask($node)" ng-show="$node.edit == 'name'">
+ <input ng-model="$node.task.name">
+ </form>
+
+ <span ng-click="editTask($node, 'name')" ng-show="$node.edit != 'name'">{{$node.task.name}} </span>
+
+ <span class="btn-group action">
+ <a class="btn btn-mini" href="" ng-click="timeTask($node.task)">
+ <i ng-class="{'icon-play' : ($node.task != currentTask), 'icon-stop' : ($node.task == currentTask)}"></i>
+ </a>
+ <a class="btn btn-mini" href="" ng-click="addSubTask($node)"><i class="icon-plus"></i></a>
+ <a class="btn btn-mini" href="" ng-click="removeTask($node.task)"><i class="icon-minus"></i></a>
+ </span>
+ </div>
+
+ <div class="td today" ng-show="showToday">
+ {{$node.getTime().today | time}}
+ </div>
+
+ <div class="td global" ng-show="showGlobal">{{$node.getTime().global | time}}</div>
+
+ <div class="td tags" ng-show="showTags" ng-click="editTask($node, 'tags')">
+ <form ng-submit="saveTask($node)" ng-show="$node.edit == 'tags'">
+ <input ng-model="$node.task.tags" ng-list>
+ </form>
+
+ <span class="label label-info" ng-repeat="tag in $node.task.tags" style="margin-right: 10px;" ng-show="$node.edit != 'tags'">
+ {{tag}}
+ </span>
+
+ <span ng-show="$node.task.tags.length == 0 && $node.edit != 'tags'">No tag</span>
+ </div>
+ </div>
+</script>
+
+<div id="header">
+ <span class='left'>
+ <input class='search-query input-small' ng-model="query" placeholder="Search">
+ <form ng-submit="addTask()">
+ <input class='search-query input-small' ng-model="name" placeholder="New Task">
+ </form>
+ </span>
+ <span class="right">
+ <a class="icon-plus-sign" ng-click="showMenu = !showMenu">
+ <b class="caret"></b>
+ </a>
+ <ul class="dropdown-menu" ng-class="{'menu-show': showMenu}">
+ <li>Keep Tree opened <input type='checkbox' ng-model="forceExpanded"></li>
+ <li>Name <input type='checkbox' ng-model='showName'/></li>
+ <li>Today <input type='checkbox' ng-model='showToday'/></li>
+ <li>Total <input type='checkbox' ng-model='showGlobal'/></li>
+ <li>Tags <input type='checkbox' ng-model='showTags'/></li>
+ </ul>
+ <i class="icon-cloud" ng-class="{online: online, offline: !online}"></i>
+ </span>
+</div>
+<div id="footer">
+ <span class="left">{{currentDate()}}</span>
+ <span class="center"><a href="#">WebTimer</a><i class="icon-html5"></i></span>
+ <span class="right">{{tree.getTime().today |time}} | {{tree.getTime().global | time}}</a>
+</div>
+
+<div>
+ <div class='table'>
+ <div class='tr'>
+ <div class='th name' ng-show="showName">Name</div>
+ <div class='th today' ng-show="showToday">Today</div>
+ <div class='th global' ng-show="showGlobal">Total</div>
+ <div class='th tags' ng-show="showTags">Tags</div>
+ </div>
+ <div class="tbody"
+ wt-tree-repeat="tree | filter:query | orderBy:'task.name'"
+ wt-force-open="query || forceExpanded"
+ ng-include="'tree_item_renderer_details.html'"></div>
+
+ </div>
+</div>
Property changes on: branches/ng-jtimer/jtimer-server/src/main/webapp/partials/tasks.html
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: branches/ng-jtimer/jtimer-server/src/main/webapp/webtimer.appcache
===================================================================
--- branches/ng-jtimer/jtimer-server/src/main/webapp/webtimer.appcache (rev 0)
+++ branches/ng-jtimer/jtimer-server/src/main/webapp/webtimer.appcache 2013-07-26 16:06:59 UTC (rev 2912)
@@ -0,0 +1,18 @@
+CACHE MANIFEST
+# version 11
+
+CACHE:
+index.html
+partials/about.html
+partials/contact.html
+partials/tasks.html
+css/app.css
+css/jtimer.css
+js/app.js
+js/controllers.js
+js/entities.js
+js/filters.js
+js/jtimer.js
+
+NETWORK:
+http://localhost:33678/*
1
0
July 24, 2013
Author: echatellier
Date: 2013-07-24 23:08:10 +0200 (Wed, 24 Jul 2013)
New Revision: 2911
Url: http://chorem.org/projects/jtimer/repository/revisions/2911
Log:
Send idle time into sockets
Modified:
branches/ng-jtimer/jtimer-server/src/main/go/jtimer.go
Modified: branches/ng-jtimer/jtimer-server/src/main/go/jtimer.go
===================================================================
--- branches/ng-jtimer/jtimer-server/src/main/go/jtimer.go 2013-07-23 21:15:26 UTC (rev 2910)
+++ branches/ng-jtimer/jtimer-server/src/main/go/jtimer.go 2013-07-24 21:08:10 UTC (rev 2911)
@@ -4,6 +4,8 @@
"fmt"
"net/http"
"time"
+ //"log"
+ //"strconv"
"github.com/BurntSushi/xgb"
"github.com/BurntSushi/xgb/xproto"
"github.com/BurntSushi/xgb/screensaver"
@@ -13,13 +15,19 @@
// echo back the websocket.
func EchoServer(ws *websocket.Conn) {
- fmt.Println("Allo ?");
- //var message string
- //websocket.Message.Receive(ws, &message)
- //fmt.Println("[Debug] ", message);
- websocket.Message.Send(ws, "Hello")
+ var message string
+ websocket.Message.Receive(ws, &message)
+ fmt.Println("[Received] ", message)
}
+func WebSocketServer() {
+ http.Handle("/echo", websocket.Handler(EchoServer));
+ err := http.ListenAndServe(":12345", nil);
+ if err != nil {
+ //panic("ListenAndServe: ", err.String())
+ fmt.Println("[Debug] ");
+ }
+}
func RunTimer() {
X, err := xgb.NewConn()
@@ -33,23 +41,26 @@
draw := xproto.Drawable(screen.Root)
screensaver.Init(X)
+ // connect to webscocket server
+ origin := "http://localhost:12345/"
+ url := "ws://localhost:12345/echo"
+
for {
time.Sleep(1 * time.Second)
cookie := screensaver.QueryInfo(X, draw)
reply, _ := cookie.Reply()
fmt.Println("Idle since", reply.MsSinceUserInput);
-
+ ws, _ := websocket.Dial(url, "", origin)
+ msSinceUserInputString := fmt.Sprintf("{idle:%d}", reply.MsSinceUserInput)
+ /*if _, err := ws.Write([]byte(msSinceUserInputString)); err != nil {
+ log.Fatal(err)
+ }*/
+ websocket.Message.Send(ws, msSinceUserInputString)
}
}
func main() {
- go RunTimer()
- http.Handle("/echo", websocket.Handler(EchoServer));
- err := http.ListenAndServe(":12345", nil);
- if err != nil {
- //panic("ListenAndServe: ", err.String())
- fmt.Println("[Debug] ");
- }
+ go WebSocketServer()
+ RunTimer()
}
-
1
0
r2910 - in branches/ng-jtimer/jtimer-server/src/main: . go
by echatellier@users.chorem.org July 23, 2013
by echatellier@users.chorem.org July 23, 2013
July 23, 2013
Author: echatellier
Date: 2013-07-23 23:15:26 +0200 (Tue, 23 Jul 2013)
New Revision: 2910
Url: http://chorem.org/projects/jtimer/repository/revisions/2910
Log:
Add go client (idle detect and websocket server)
Added:
branches/ng-jtimer/jtimer-server/src/main/go/
branches/ng-jtimer/jtimer-server/src/main/go/jtimer.go
Added: branches/ng-jtimer/jtimer-server/src/main/go/jtimer.go
===================================================================
--- branches/ng-jtimer/jtimer-server/src/main/go/jtimer.go (rev 0)
+++ branches/ng-jtimer/jtimer-server/src/main/go/jtimer.go 2013-07-23 21:15:26 UTC (rev 2910)
@@ -0,0 +1,55 @@
+package main
+
+import (
+ "fmt"
+ "net/http"
+ "time"
+ "github.com/BurntSushi/xgb"
+ "github.com/BurntSushi/xgb/xproto"
+ "github.com/BurntSushi/xgb/screensaver"
+ "code.google.com/p/go.net/websocket"
+)
+
+
+// echo back the websocket.
+func EchoServer(ws *websocket.Conn) {
+ fmt.Println("Allo ?");
+ //var message string
+ //websocket.Message.Receive(ws, &message)
+ //fmt.Println("[Debug] ", message);
+ websocket.Message.Send(ws, "Hello")
+}
+
+
+func RunTimer() {
+ X, err := xgb.NewConn()
+ if err != nil {
+ fmt.Println(err)
+ return
+ }
+
+ screen := xproto.Setup(X).DefaultScreen(X)
+ //wid, err := xproto.NewWindowId(X)
+ draw := xproto.Drawable(screen.Root)
+ screensaver.Init(X)
+
+ for {
+ time.Sleep(1 * time.Second)
+ cookie := screensaver.QueryInfo(X, draw)
+ reply, _ := cookie.Reply()
+ fmt.Println("Idle since", reply.MsSinceUserInput);
+
+
+ }
+}
+
+func main() {
+ go RunTimer()
+ http.Handle("/echo", websocket.Handler(EchoServer));
+ err := http.ListenAndServe(":12345", nil);
+ if err != nil {
+ //panic("ListenAndServe: ", err.String())
+ fmt.Println("[Debug] ");
+ }
+}
+
1
0
r2909 - in branches/ng-jtimer/jtimer-server: . src/main/java/org/chorem/jtimer/web src/main/webapp/WEB-INF
by echatellier@users.chorem.org July 23, 2013
by echatellier@users.chorem.org July 23, 2013
July 23, 2013
Author: echatellier
Date: 2013-07-23 21:44:03 +0200 (Tue, 23 Jul 2013)
New Revision: 2909
Url: http://chorem.org/projects/jtimer/repository/revisions/2909
Log:
Switch to restlet
Added:
branches/ng-jtimer/jtimer-server/src/main/java/org/chorem/jtimer/web/ProjectsResource.java
branches/ng-jtimer/jtimer-server/src/main/java/org/chorem/jtimer/web/RestApplication.java
Removed:
branches/ng-jtimer/jtimer-server/src/main/java/org/chorem/jtimer/web/RestController.java
Modified:
branches/ng-jtimer/jtimer-server/pom.xml
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/pom.xml 2013-07-19 14:43:56 UTC (rev 2908)
+++ branches/ng-jtimer/jtimer-server/pom.xml 2013-07-23 19:44:03 UTC (rev 2909)
@@ -27,10 +27,20 @@
<version>2.2.4</version>
</dependency>
<dependency>
- <groupId>org.debux.webmotion</groupId>
- <artifactId>webmotion</artifactId>
- <version>2.4-SNAPSHOT</version>
+ <groupId>org.restlet.jee</groupId>
+ <artifactId>org.restlet</artifactId>
+ <version>2.1.2</version>
</dependency>
+ <dependency>
+ <groupId>org.restlet.jee</groupId>
+ <artifactId>org.restlet.ext.servlet</artifactId>
+ <version>2.1.2</version>
+ </dependency>
+ <dependency>
+ <groupId>org.restlet.jee</groupId>
+ <artifactId>org.restlet.ext.jackson</artifactId>
+ <version>2.1.2</version>
+ </dependency>
</dependencies>
<build>
@@ -64,4 +74,12 @@
</plugin>
</plugins>
</build>
+
+ <repositories>
+ <repository>
+ <id>maven-restlet</id>
+ <name>Public online Restlet repository</name>
+ <url>http://maven.restlet.org</url>
+ </repository>
+ </repositories>
</project>
Copied: branches/ng-jtimer/jtimer-server/src/main/java/org/chorem/jtimer/web/ProjectsResource.java (from rev 2907, 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/ProjectsResource.java (rev 0)
+++ branches/ng-jtimer/jtimer-server/src/main/java/org/chorem/jtimer/web/ProjectsResource.java 2013-07-23 19:44:03 UTC (rev 2909)
@@ -0,0 +1,32 @@
+package org.chorem.jtimer.web;
+
+import org.chorem.jtimer.entities.TimerProject;
+import org.chorem.jtimer.storage.Storage;
+import org.restlet.ext.jackson.JacksonRepresentation;
+import org.restlet.representation.Representation;
+import org.restlet.resource.Get;
+import org.restlet.resource.ServerResource;
+
+public class ProjectsResource extends ServerResource {
+
+ protected Storage storage;
+
+ public ProjectsResource() {
+ storage = new Storage();
+
+ if (storage.getProjectsCount() == 0) {
+ storage.addProject(new TimerProject("jTimer"));
+ storage.addProject(new TimerProject("Chorem"));
+ storage.addProject(new TimerProject("Wikitty"));
+ storage.addProject(new TimerProject("Nuiton-js"));
+ storage.addProject(new TimerProject("Angular"));
+ storage.addProject(new TimerProject("Isis-Fish"));
+ }
+ }
+
+ @Get("json")
+ public Representation getProjects() {
+ Representation jsonRep = new JacksonRepresentation<>(storage.getProjects());
+ return jsonRep;
+ }
+}
Added: branches/ng-jtimer/jtimer-server/src/main/java/org/chorem/jtimer/web/RestApplication.java
===================================================================
--- branches/ng-jtimer/jtimer-server/src/main/java/org/chorem/jtimer/web/RestApplication.java (rev 0)
+++ branches/ng-jtimer/jtimer-server/src/main/java/org/chorem/jtimer/web/RestApplication.java 2013-07-23 19:44:03 UTC (rev 2909)
@@ -0,0 +1,24 @@
+package org.chorem.jtimer.web;
+
+import org.restlet.Application;
+import org.restlet.Restlet;
+import org.restlet.routing.Router;
+
+public class RestApplication extends Application {
+
+ /**
+ * Creates a root Restlet that will receive all incoming calls.
+ */
+ @Override
+ public synchronized Restlet createInboundRoot() {
+ // Create a router Restlet that routes each call to a
+ // new instance of HelloWorldResource.
+ Router router = new Router(getContext());
+
+ // Defines only one route
+ router.attach("/projects", ProjectsResource.class);
+
+ return router;
+ }
+
+}
\ No newline at end of file
Property changes on: branches/ng-jtimer/jtimer-server/src/main/java/org/chorem/jtimer/web/RestApplication.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Deleted: 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 2013-07-19 14:43:56 UTC (rev 2908)
+++ branches/ng-jtimer/jtimer-server/src/main/java/org/chorem/jtimer/web/RestController.java 2013-07-23 19:44:03 UTC (rev 2909)
@@ -1,27 +0,0 @@
-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);
- }
-}
Modified: branches/ng-jtimer/jtimer-server/src/main/webapp/WEB-INF/web.xml
===================================================================
--- branches/ng-jtimer/jtimer-server/src/main/webapp/WEB-INF/web.xml 2013-07-19 14:43:56 UTC (rev 2908)
+++ branches/ng-jtimer/jtimer-server/src/main/webapp/WEB-INF/web.xml 2013-07-23 19:44:03 UTC (rev 2909)
@@ -1,4 +1,19 @@
-<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
+<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">
+
+ <context-param>
+ <param-name>org.restlet.application</param-name>
+ <param-value>org.chorem.jtimer.web.RestApplication</param-value>
+ </context-param>
+
+ <servlet>
+ <servlet-name>RestletServlet</servlet-name>
+ <servlet-class>org.restlet.ext.servlet.ServerServlet</servlet-class>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>RestletServlet</servlet-name>
+ <url-pattern>/rest/*</url-pattern>
+ </servlet-mapping>
+</web-app>
1
0
July 19, 2013
Author: echatellier
Date: 2013-07-19 16:43:56 +0200 (Fri, 19 Jul 2013)
New Revision: 2908
Url: http://chorem.org/projects/jtimer/repository/revisions/2908
Log:
svn:ignore
Modified:
branches/ng-jtimer/jtimer-server/
Property changes on: branches/ng-jtimer/jtimer-server
___________________________________________________________________
Added: svn:ignore
+ .settings
.classpath
.project
1
0
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 July 19, 2013
by echatellier@users.chorem.org July 19, 2013
July 19, 2013
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 July 19, 2013
by echatellier@users.chorem.org July 19, 2013
July 19, 2013
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
July 19, 2013
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
July 11, 2013
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