branch feature/sync updated (90cb72f -> 09f14bd)
This is an automated email from the git hooks/post-receive script. New change to branch feature/sync in repository jtimer. See https://gitlab.nuiton.org/chorem/jtimer.git from 90cb72f removed the changes in the task editor (url no longer changed here) new 9d74422 removed an unused field (lastSync) in TimerTask, clarified some documentations new 2a0e547 minor cleanup in methods new 7aee74f added a test for taskToJSONFormat new 5506ddb added a test on parseSyncInfo in GTimerIncrementalSaver new 9db7005 added a checkbox for activity of url (not listening on it yet) new f3431bc added some logging (more to come) and added properties new bf43b49 corrected text on the checkbox isActiveSync new e2106d5 added logs, made method synchronizeTaskOnURL static and returning an int new 7d1d920 checking the isActive checkbox de/activates the sync on the url chosen new 2d9e642 when a url is deleted in the combobox, it's saved in the file new 09f14bd deletion of url saved to sync file properly + corrected parsing of syncInfo The 11 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Detailed log of new commits: commit 09f14bd1e012dafcd3c99df853e531a317d2236c Author: servantie <servantie.c@gmail.com> Date: Wed Jun 22 17:52:52 2016 +0200 deletion of url saved to sync file properly + corrected parsing of syncInfo (catching a DateTimeParseException, and taking a 00:00:00 instead of 00:00:00.000 format) commit 2d9e6420fbd15150d3719ba8763de25cb5dbd5dc Author: servantie <servantie.c@gmail.com> Date: Wed Jun 22 16:28:55 2016 +0200 when a url is deleted in the combobox, it's saved in the file commit 7d1d920fc335ee30254b0baab612a7a760359b4e Author: servantie <servantie.c@gmail.com> Date: Wed Jun 22 14:33:15 2016 +0200 checking the isActive checkbox de/activates the sync on the url chosen commit e2106d5e24314ab00b9b93a1de2ac16f5e5a4520 Author: servantie <servantie.c@gmail.com> Date: Wed Jun 22 16:38:43 2016 +0200 added logs, made method synchronizeTaskOnURL static and returning an int (http response) commit bf43b497525a2219527caeaf7521043d2393a194 Author: servantie <servantie.c@gmail.com> Date: Tue Jun 21 17:47:53 2016 +0200 corrected text on the checkbox isActiveSync commit f3431bc78f4c0a54271cddef2da6928f09438883 Author: servantie <servantie.c@gmail.com> Date: Tue Jun 21 17:27:12 2016 +0200 added some logging (more to come) and added properties commit 9db700554d9de889b5ee8946812616b95a5b6cb8 Author: servantie <servantie.c@gmail.com> Date: Tue Jun 21 14:49:18 2016 +0200 added a checkbox for activity of url (not listening on it yet) commit 5506ddb530ad82501b3f3975b4c7d027737766d4 Author: servantie <servantie.c@gmail.com> Date: Tue Jun 21 11:20:58 2016 +0200 added a test on parseSyncInfo in GTimerIncrementalSaver commit 7aee74f456fbabd342f9171a373f83427f0cef3c Author: servantie <servantie.c@gmail.com> Date: Tue Jun 21 10:27:46 2016 +0200 added a test for taskToJSONFormat commit 2a0e547cd4b5b4bfb4f55179b3c15ca694379e63 Author: servantie <servantie.c@gmail.com> Date: Mon Jun 20 16:45:26 2016 +0200 minor cleanup in methods commit 9d744223f01aad0e06d3dad98bedbd550fbfccb2 Author: servantie <servantie.c@gmail.com> Date: Mon Jun 20 11:44:32 2016 +0200 removed an unused field (lastSync) in TimerTask, clarified some documentations Summary of changes: .../org/chorem/jtimer/data/DataEventListener.java | 6 + .../org/chorem/jtimer/data/TimerDataManager.java | 14 ++ .../java/org/chorem/jtimer/entities/SyncInfo.java | 10 +- .../java/org/chorem/jtimer/entities/TimerTask.java | 35 +-- .../chorem/jtimer/entities/TimerTaskHelper.java | 10 +- .../chorem/jtimer/io/GTimerIncrementalSaver.java | 22 +- .../chorem/jtimer/io/TimerTaskSynchronizer.java | 43 ++-- .../jtimer/ui/report/TimerTaskUpdaterView.java | 240 +++++++++++++-------- .../resources/TimerTaskUpdaterView.properties | 16 +- .../resources/TimerTaskUpdaterView_fr.properties | 9 +- .../jtimer/entities/TimerTaskHelperTest.java | 47 ++++ .../jtimer/io/GTimerIncrementalSaverTest.java | 35 ++- src/test/resources/testdata/41.task | 8 + src/test/resources/testdata/41.task.sync | 3 + 14 files changed, 344 insertions(+), 154 deletions(-) create mode 100644 src/test/resources/testdata/41.task create mode 100644 src/test/resources/testdata/41.task.sync -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/sync in repository jtimer. See https://gitlab.nuiton.org/chorem/jtimer.git commit 9d744223f01aad0e06d3dad98bedbd550fbfccb2 Author: servantie <servantie.c@gmail.com> Date: Mon Jun 20 11:44:32 2016 +0200 removed an unused field (lastSync) in TimerTask, clarified some documentations --- src/main/java/org/chorem/jtimer/entities/TimerTask.java | 11 ++++------- src/main/java/org/chorem/jtimer/entities/TimerTaskHelper.java | 3 ++- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/chorem/jtimer/entities/TimerTask.java b/src/main/java/org/chorem/jtimer/entities/TimerTask.java index 3ee66e9..1cb4755 100644 --- a/src/main/java/org/chorem/jtimer/entities/TimerTask.java +++ b/src/main/java/org/chorem/jtimer/entities/TimerTask.java @@ -90,11 +90,6 @@ public class TimerTask implements Cloneable, protected List<TimerAlert> alerts; /** - * Last synchronisation date - */ - protected LocalDateTime lastSync; - - /** * Synchronisation Info */ protected List<SyncInfo> synchronisingInfoList; @@ -304,7 +299,7 @@ public class TimerTask implements Cloneable, } /** - * Adds a new synchronization info if the url isn't already present + * Adds a new synchronization info if the url isn't already present in the list * @param url a string * @param time a LocalDateTime * @param isActive a boolean for activity (true to sync auto) @@ -334,7 +329,7 @@ public class TimerTask implements Cloneable, } /** - * Returns all the synchronization info + * Returns all the synchronization info as a List * @return a list of TimerTask.SyncInfo */ public List<SyncInfo> getSynchronizingInfoList() { @@ -344,7 +339,9 @@ public class TimerTask implements Cloneable, /** * Returns the sync info matching a url + * (if the url is not in the list, returns a SyncInfo with an "error" string as url) * @param urlString + * @return a SyncInfo matching the url */ public SyncInfo getSynchronizingInfo(String urlString) { for (SyncInfo sync : synchronisingInfoList) { diff --git a/src/main/java/org/chorem/jtimer/entities/TimerTaskHelper.java b/src/main/java/org/chorem/jtimer/entities/TimerTaskHelper.java index 5f77e03..75759ef 100644 --- a/src/main/java/org/chorem/jtimer/entities/TimerTaskHelper.java +++ b/src/main/java/org/chorem/jtimer/entities/TimerTaskHelper.java @@ -328,8 +328,9 @@ public class TimerTaskHelper { } /** - * Returns a String in JSON format (cf schema (simplified) + * Returns a list of JSONObject (1/SyncURL) (follows the schema) * with all times and annotations of a task (without subtasks) + * with annotations if enabled * @param task the task to make a JSON from * @param withAnnotations true if annotations included * @param timezone represents the timezone -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/sync in repository jtimer. See https://gitlab.nuiton.org/chorem/jtimer.git commit 2a0e547cd4b5b4bfb4f55179b3c15ca694379e63 Author: servantie <servantie.c@gmail.com> Date: Mon Jun 20 16:45:26 2016 +0200 minor cleanup in methods --- .../java/org/chorem/jtimer/entities/SyncInfo.java | 2 +- .../java/org/chorem/jtimer/entities/TimerTask.java | 14 ++++++------ .../chorem/jtimer/entities/TimerTaskHelper.java | 7 +++--- .../chorem/jtimer/io/GTimerIncrementalSaver.java | 2 +- .../chorem/jtimer/io/TimerTaskSynchronizer.java | 2 +- .../jtimer/ui/report/TimerTaskUpdaterView.java | 25 +++++++++------------- 6 files changed, 25 insertions(+), 27 deletions(-) diff --git a/src/main/java/org/chorem/jtimer/entities/SyncInfo.java b/src/main/java/org/chorem/jtimer/entities/SyncInfo.java index d5d9e00..cf81350 100644 --- a/src/main/java/org/chorem/jtimer/entities/SyncInfo.java +++ b/src/main/java/org/chorem/jtimer/entities/SyncInfo.java @@ -54,7 +54,7 @@ public class SyncInfo { * Sets the isActiveSync boolean * @param isActive boolean */ - public void setActiveSync(boolean isActive) { + public void isActiveSync(boolean isActive) { isActiveSync = isActive; } diff --git a/src/main/java/org/chorem/jtimer/entities/TimerTask.java b/src/main/java/org/chorem/jtimer/entities/TimerTask.java index 1cb4755..be6b5c7 100644 --- a/src/main/java/org/chorem/jtimer/entities/TimerTask.java +++ b/src/main/java/org/chorem/jtimer/entities/TimerTask.java @@ -270,13 +270,13 @@ public class TimerTask implements Cloneable, * @return the URL List */ public List<String> getSynchronizingURLList() { - List<String> resutList = new ArrayList<>(); + List<String> resultList = new ArrayList<>(); if (!synchronisingInfoList.isEmpty()) { for (SyncInfo sync : synchronisingInfoList) { - resutList.add(sync.getSyncURL()); + resultList.add(sync.getSyncURL()); } } - return resutList; + return resultList; } /** @@ -305,8 +305,10 @@ public class TimerTask implements Cloneable, * @param isActive a boolean for activity (true to sync auto) */ public void addSyncInfo(String url, LocalDateTime time, boolean isActive) { - if (!getSynchronizingURLList().contains(url)) { - synchronisingInfoList.add(new SyncInfo(url, time, isActive)); + if (!url.isEmpty()) { + if (!getSynchronizingURLList().contains(url)) { + synchronisingInfoList.add(new SyncInfo(url, time, isActive)); + } } } @@ -360,7 +362,7 @@ public class TimerTask implements Cloneable, * @param syncInfo the SyncInfo */ public void setIsActive(boolean isActive, SyncInfo syncInfo) { - syncInfo.setActiveSync(isActive); + syncInfo.isActiveSync(isActive); } /** diff --git a/src/main/java/org/chorem/jtimer/entities/TimerTaskHelper.java b/src/main/java/org/chorem/jtimer/entities/TimerTaskHelper.java index 75759ef..09128d2 100644 --- a/src/main/java/org/chorem/jtimer/entities/TimerTaskHelper.java +++ b/src/main/java/org/chorem/jtimer/entities/TimerTaskHelper.java @@ -359,6 +359,7 @@ public class TimerTaskHelper { public static List<JsonObject> taskToJSONFormat(TimerTask task, Date startDate, Date endDate, boolean withAnnotations, String timezone) { ArrayList<JsonObject> jsonObjectList = new ArrayList<>(); + String timestamp = "T00:00:00"; for (String url : task.getSynchronizingURLList()) { boolean isActive = task.getSynchronizingInfo(url).getActiveSync(); @@ -378,7 +379,7 @@ public class TimerTaskHelper { //as jtimer has time entries only for a day, the id of the times will be the date in yyyy-mm-dd format JsonObject periodElement = new JsonObject(); periodElement.addProperty("id", dateString); - periodElement.addProperty("startDate", dateString + "T00:00:00" + timezone); + periodElement.addProperty("startDate", dateString + timestamp + timezone); periodElement.addProperty("duration", entry.getValue()/1000); if (withAnnotations && !(getAnnotation(task, entry.getKey()).isEmpty())) { StringBuilder builder = new StringBuilder(); @@ -394,8 +395,8 @@ public class TimerTaskHelper { } } responseJSON.addProperty("URL", url); - responseJSON.addProperty("startDate", startPeriodDate.toString() + "T00:00:00" + timezone); - responseJSON.addProperty("endDate", endPeriodDate.toString() + "T00:00:00" + timezone); + responseJSON.addProperty("startDate", startPeriodDate.toString() + timestamp + timezone); + responseJSON.addProperty("endDate", endPeriodDate.toString() + timestamp + timezone); responseJSON.add("periods", periodArray); jsonObjectList.add(responseJSON); diff --git a/src/main/java/org/chorem/jtimer/io/GTimerIncrementalSaver.java b/src/main/java/org/chorem/jtimer/io/GTimerIncrementalSaver.java index b427531..79be028 100644 --- a/src/main/java/org/chorem/jtimer/io/GTimerIncrementalSaver.java +++ b/src/main/java/org/chorem/jtimer/io/GTimerIncrementalSaver.java @@ -622,7 +622,7 @@ public class GTimerIncrementalSaver extends AbstractSaver implements Saver, String line = parseIn.readLine(); while ((line = parseIn.readLine()) != null) { line = line.trim(); - if ((!line.isEmpty())) { + if (!line.isEmpty()) { String[] urlArray = line.split(" "); //if there is no lastSyncTime if (urlArray.length == 2) { diff --git a/src/main/java/org/chorem/jtimer/io/TimerTaskSynchronizer.java b/src/main/java/org/chorem/jtimer/io/TimerTaskSynchronizer.java index 51bcde0..ea3660c 100644 --- a/src/main/java/org/chorem/jtimer/io/TimerTaskSynchronizer.java +++ b/src/main/java/org/chorem/jtimer/io/TimerTaskSynchronizer.java @@ -122,7 +122,7 @@ public class TimerTaskSynchronizer implements DataEventListener { else { log.debug("Sync failed on " + object.get("URL").getAsString()); //deactivate autosync if the sync failed - task.getSynchronizingInfo(object.get("URL").getAsString()).setActiveSync(false); + task.getSynchronizingInfo(object.get("URL").getAsString()).isActiveSync(false); log.info("Adress deactivated"); } diff --git a/src/main/java/org/chorem/jtimer/ui/report/TimerTaskUpdaterView.java b/src/main/java/org/chorem/jtimer/ui/report/TimerTaskUpdaterView.java index 7220cb6..bc20e94 100644 --- a/src/main/java/org/chorem/jtimer/ui/report/TimerTaskUpdaterView.java +++ b/src/main/java/org/chorem/jtimer/ui/report/TimerTaskUpdaterView.java @@ -82,7 +82,7 @@ public class TimerTaskUpdaterView extends FrameView implements DocumentListener, /** ComboBox of URLs */ protected JComboBox<String> urlComboBox; - /** LastSync */ + /** LastSync */ protected JLabel lastUpdate; /** task to update */ @@ -204,6 +204,8 @@ public class TimerTaskUpdaterView extends FrameView implements DocumentListener, for (String url : task.getSynchronizingURLList()) { urlComboBox.addItem(url); } + + urlComboBox.setActionCommand("comboBox"); panelOption.add(urlcomboBoxLabel, new GridBagConstraints(1,3,1,1,0,0, GridBagConstraints.WEST, GridBagConstraints.VERTICAL, new Insets(3,1,1,1), 0, 0)); panelOption.add(urlComboBox, new GridBagConstraints(2,3,1,1,0,0, @@ -386,14 +388,13 @@ public class TimerTaskUpdaterView extends FrameView implements DocumentListener, builder.append(gson.toJson(object)); } } - updateArea.setText(builder.toString()); -// if (task.getSynchronizingInfo(urlSelected).getLastSync().isAfter(LocalDateTime.MIN)) { -// lastUpdate.setText(task.getSynchronizingInfo(urlSelected).getLastSync().toString()); -// } -// else { -// lastUpdate.setText(""); -// } - + if (!task.getSynchronizingInfo(urlSelected).getActiveSync()) { + //todo : get in properties + updateArea.setText("Url inactive"); + } + else { + updateArea.setText(builder.toString()); + } } else { updateArea.setText("No data"); @@ -442,12 +443,6 @@ public class TimerTaskUpdaterView extends FrameView implements DocumentListener, if (urlSelected.equals(object.get("URL").getAsString())) { synchronizeTaskOnURL(task, object); } -// } -// if (task.getSynchronizingInfo(urlSelected).getLastSync().isAfter(LocalDateTime.MIN)) { -// lastUpdate.setText(task.getSynchronizingInfo(urlSelected).getLastSync().toString()); -// } -// else { -// lastUpdate.setText(""); } } -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/sync in repository jtimer. See https://gitlab.nuiton.org/chorem/jtimer.git commit 7aee74f456fbabd342f9171a373f83427f0cef3c Author: servantie <servantie.c@gmail.com> Date: Tue Jun 21 10:27:46 2016 +0200 added a test for taskToJSONFormat --- .../java/org/chorem/jtimer/entities/TimerTask.java | 10 +++++ .../jtimer/ui/report/TimerTaskUpdaterView.java | 2 +- .../jtimer/entities/TimerTaskHelperTest.java | 47 ++++++++++++++++++++++ .../jtimer/io/GTimerIncrementalSaverTest.java | 2 +- src/test/resources/testdata/41.task | 8 ++++ src/test/resources/testdata/41.task.sync | 3 ++ 6 files changed, 70 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/chorem/jtimer/entities/TimerTask.java b/src/main/java/org/chorem/jtimer/entities/TimerTask.java index be6b5c7..f782e55 100644 --- a/src/main/java/org/chorem/jtimer/entities/TimerTask.java +++ b/src/main/java/org/chorem/jtimer/entities/TimerTask.java @@ -313,6 +313,16 @@ public class TimerTask implements Cloneable, } /** + * Adds a new synchronization info with just url provided + * (default isActive = true and time is minimum) + * @param url a String + */ + public void addSyncInfo(String url) { + addSyncInfo(url, LocalDateTime.MIN, true); + } + + + /** * Removes a synchronisation info attached to a url if it exists * @param url : the url of the info to remove * diff --git a/src/main/java/org/chorem/jtimer/ui/report/TimerTaskUpdaterView.java b/src/main/java/org/chorem/jtimer/ui/report/TimerTaskUpdaterView.java index bc20e94..3929948 100644 --- a/src/main/java/org/chorem/jtimer/ui/report/TimerTaskUpdaterView.java +++ b/src/main/java/org/chorem/jtimer/ui/report/TimerTaskUpdaterView.java @@ -562,7 +562,7 @@ public class TimerTaskUpdaterView extends FrameView implements DocumentListener, String urlToAdd = (String) urlComboBox.getSelectedItem(); if ((!urlToAdd.isEmpty()) && (!task.getSynchronizingURLList().contains(urlToAdd))) { urlComboBox.addItem(urlToAdd); - task.addSyncInfo(urlToAdd, LocalDateTime.MIN, true); + task.addSyncInfo(urlToAdd); core.getData().changeSyncInfo(task, urlToAdd); } if (lastUpdate != null) { diff --git a/src/test/java/org/chorem/jtimer/entities/TimerTaskHelperTest.java b/src/test/java/org/chorem/jtimer/entities/TimerTaskHelperTest.java index 88eb68f..abd36ea 100644 --- a/src/test/java/org/chorem/jtimer/entities/TimerTaskHelperTest.java +++ b/src/test/java/org/chorem/jtimer/entities/TimerTaskHelperTest.java @@ -21,10 +21,15 @@ */ package org.chorem.jtimer.entities; +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; import org.chorem.jtimer.AbstractJTimerTest; import org.testng.Assert; import org.testng.annotations.Test; +import java.util.ArrayList; +import java.util.Date; import java.util.List; /** @@ -49,4 +54,46 @@ public class TimerTaskHelperTest extends AbstractJTimerTest { Assert.assertEquals(components.get(1), task1); Assert.assertEquals(components.get(2), task2); } + + /** + * Test json production + */ + @Test + public void taskToJSONFormatTest() { + TimerTask task = new TimerTask(); + task.setName("JsonBuilder Test"); + task.addSyncInfo("http://localhost:3000"); + //date : 2016-05-10 + task.setTime(new Date(1462831200000L), 452000L); + //date : 2016-05-12 + task.setTime(new Date(1463004000000L), 4533000L); + + //create json object list to get + List<JsonObject> listOfObjects = new ArrayList<>(); + + JsonObject objectToHave = new JsonObject(); + JsonArray periodArray = new JsonArray(); + JsonObject periodElement1 = new JsonObject(); + periodElement1.addProperty("id", "2016-05-10"); + periodElement1.addProperty("startDate", "2016-05-10T00:00:00+01:00"); + periodElement1.addProperty("duration", 452); + periodArray.add(periodElement1); + JsonObject periodElement2 = new JsonObject(); + periodElement2.addProperty("id", "2016-05-12"); + periodElement2.addProperty("startDate", "2016-05-12T00:00:00+01:00"); + periodElement2.addProperty("duration", 4533); + periodArray.add(periodElement2); + + objectToHave.addProperty("URL", "http://localhost:3000"); + objectToHave.addProperty("startDate", "2016-05-10T00:00:00+01:00"); + objectToHave.addProperty("endDate", "2016-05-20T00:00:00+01:00"); + objectToHave.add("periods", periodArray); + listOfObjects.add(objectToHave); + + + //make a list of json objects from the task + List<JsonObject> taskJsonList = TimerTaskHelper.taskToJSONFormat(task, new Date(1462831200000L), new Date(1463695200000L), false, "+01:00"); + //compare it + Assert.assertEquals(taskJsonList, listOfObjects); + } } diff --git a/src/test/java/org/chorem/jtimer/io/GTimerIncrementalSaverTest.java b/src/test/java/org/chorem/jtimer/io/GTimerIncrementalSaverTest.java index 3a153a6..774776a 100644 --- a/src/test/java/org/chorem/jtimer/io/GTimerIncrementalSaverTest.java +++ b/src/test/java/org/chorem/jtimer/io/GTimerIncrementalSaverTest.java @@ -88,7 +88,7 @@ public class GTimerIncrementalSaverTest extends AbstractJTimerTest { Assert.assertNotNull(projects); Assert.assertEquals(getProjectsCount(projects), 6); - Assert.assertEquals(getTasksCount(projects), 40); + Assert.assertEquals(getTasksCount(projects), 41); Assert.assertEquals(getAnnotationsCount(projects), 9); Assert.assertEquals(getAlertsCount(projects), 6); diff --git a/src/test/resources/testdata/41.task b/src/test/resources/testdata/41.task new file mode 100644 index 0000000..a64c2cc --- /dev/null +++ b/src/test/resources/testdata/41.task @@ -0,0 +1,8 @@ +Format: 1.2 +Name: JsonBuilder Test +Created: 1243600123 +Options: 0 +Project: 1 +Data: +20090131 452 +20090205 4533 diff --git a/src/test/resources/testdata/41.task.sync b/src/test/resources/testdata/41.task.sync new file mode 100644 index 0000000..01cb6d9 --- /dev/null +++ b/src/test/resources/testdata/41.task.sync @@ -0,0 +1,3 @@ +Format: 1.2 +SyncInfo: +http://localhost:3000 true -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/sync in repository jtimer. See https://gitlab.nuiton.org/chorem/jtimer.git commit 5506ddb530ad82501b3f3975b4c7d027737766d4 Author: servantie <servantie.c@gmail.com> Date: Tue Jun 21 11:20:58 2016 +0200 added a test on parseSyncInfo in GTimerIncrementalSaver --- .../jtimer/io/GTimerIncrementalSaverTest.java | 33 +++++++++++++++------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/src/test/java/org/chorem/jtimer/io/GTimerIncrementalSaverTest.java b/src/test/java/org/chorem/jtimer/io/GTimerIncrementalSaverTest.java index 774776a..ac99865 100644 --- a/src/test/java/org/chorem/jtimer/io/GTimerIncrementalSaverTest.java +++ b/src/test/java/org/chorem/jtimer/io/GTimerIncrementalSaverTest.java @@ -24,19 +24,11 @@ package org.chorem.jtimer.io; import java.io.File; import java.io.IOException; -import java.util.Calendar; -import java.util.Collection; -import java.util.Date; -import java.util.HashMap; -import java.util.Map; -import java.util.SortedMap; -import java.util.TreeMap; +import java.util.*; import org.chorem.jtimer.AbstractJTimerTest; -import org.chorem.jtimer.entities.TimerAlert; -import org.chorem.jtimer.entities.TimerProject; +import org.chorem.jtimer.entities.*; import org.chorem.jtimer.entities.TimerTask; -import org.chorem.jtimer.entities.TimerTaskHelper; import org.testng.Assert; import org.testng.annotations.Test; @@ -342,4 +334,25 @@ public class GTimerIncrementalSaverTest extends AbstractJTimerTest { } }*/ } + + /** + * Test that synchronization Info is properly parsed + */ + @Test + public void parseSyncInfoTest() throws IOException{ + + GTimerIncrementalSaver gsaver = (GTimerIncrementalSaver) testSaver; + + TimerTask task = new TimerTask(); + task.setNumber(41); + + gsaver.parseSyncInfo(task); + + SyncInfo syncInfo = new SyncInfo("http://localhost:3000"); + + Assert.assertNotNull(task.getSynchronizingInfoList()); + Assert.assertEquals(task.getSynchronizingInfoList().get(0).getSyncURL(), syncInfo.getSyncURL()); + Assert.assertEquals(task.getSynchronizingInfoList().get(0).getActiveSync(), syncInfo.getActiveSync()); + + } } -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/sync in repository jtimer. See https://gitlab.nuiton.org/chorem/jtimer.git commit 9db700554d9de889b5ee8946812616b95a5b6cb8 Author: servantie <servantie.c@gmail.com> Date: Tue Jun 21 14:49:18 2016 +0200 added a checkbox for activity of url (not listening on it yet) --- .../jtimer/ui/report/TimerTaskUpdaterView.java | 26 ++++++++++++++-------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/chorem/jtimer/ui/report/TimerTaskUpdaterView.java b/src/main/java/org/chorem/jtimer/ui/report/TimerTaskUpdaterView.java index 3929948..202baa2 100644 --- a/src/main/java/org/chorem/jtimer/ui/report/TimerTaskUpdaterView.java +++ b/src/main/java/org/chorem/jtimer/ui/report/TimerTaskUpdaterView.java @@ -70,6 +70,9 @@ public class TimerTaskUpdaterView extends FrameView implements DocumentListener, /** Include annotations on updates */ protected JCheckBox checkIncludesAnnotations; + /** Activate a sync URL */ + protected JCheckBox checkIsActiveSync; + /** Date pickers, from... to */ protected JXDatePicker datePickerFrom, datePickerTo; @@ -206,16 +209,19 @@ public class TimerTaskUpdaterView extends FrameView implements DocumentListener, } urlComboBox.setActionCommand("comboBox"); - panelOption.add(urlcomboBoxLabel, new GridBagConstraints(1,3,1,1,0,0, - GridBagConstraints.WEST, GridBagConstraints.VERTICAL, new Insets(3,1,1,1), 0, 0)); - panelOption.add(urlComboBox, new GridBagConstraints(2,3,1,1,0,0, - GridBagConstraints.WEST, GridBagConstraints.VERTICAL, new Insets(1,3,1,1), 0, 0)); + panelOption.add(urlcomboBoxLabel, new GridBagConstraints(1, 2, 1, 1, 0, 0, + GridBagConstraints.WEST, GridBagConstraints.VERTICAL, new Insets(2,1,1,1), 0, 0)); + panelOption.add(urlComboBox, new GridBagConstraints(2, 2, 1, 1, 0, 0, + GridBagConstraints.WEST, GridBagConstraints.VERTICAL, new Insets(1, 2, 1, 1), 0, 0)); JLabel lastSyncDateLabel = new JLabel(getResourceMap().getString("lastUpdateLabel")); - panelOption.add(lastSyncDateLabel, new GridBagConstraints(1, 2, 1, 1, 0, 0, - GridBagConstraints.WEST, GridBagConstraints.VERTICAL, new Insets(2, 1, 1, 1), 0, 0)); + panelOption.add(lastSyncDateLabel, new GridBagConstraints(1, 3, 1, 1, 0, 0, + GridBagConstraints.WEST, GridBagConstraints.VERTICAL, new Insets(3, 1, 1, 1), 0, 0)); //display last Sync time lastUpdate = new JLabel(""); + //todo : properties + checkIsActiveSync = new JCheckBox("active"); + checkIsActiveSync.setAction(getContext().getActionMap(this).get("isActiveSync")); if (urlComboBox.getSelectedItem() != null) { if (task.getSynchronizingURLList().contains(urlComboBox.getSelectedItem())){ SyncInfo syncInfo = task.getSynchronizingInfo((String) urlComboBox.getSelectedItem()); @@ -224,11 +230,13 @@ public class TimerTaskUpdaterView extends FrameView implements DocumentListener, if ((lastSyncTime != null) && lastSyncTime.isAfter(LocalDateTime.MIN)) { lastUpdate.setText(lastSyncTime.toString()); } + checkIsActiveSync.setSelected(task.getSynchronizingInfo((String) urlComboBox.getSelectedItem()).getActiveSync()); } } - panelOption.add(lastUpdate, new GridBagConstraints(2, 2, 1, 1, 0, 0, - GridBagConstraints.WEST, GridBagConstraints.VERTICAL, new Insets(1, 2, 1, 1), 0, 0)); - + panelOption.add(lastUpdate, new GridBagConstraints(2, 3, 1, 1, 0, 0, + GridBagConstraints.WEST, GridBagConstraints.VERTICAL, new Insets(1, 3, 1, 1), 0, 0)); + panelOption.add(checkIsActiveSync, new GridBagConstraints(1, 4, 1, 1, 0, 0, + GridBagConstraints.WEST, GridBagConstraints.VERTICAL, new Insets(4, 1, 1, 1), 0, 0)); configComponent.add(panelGeneral); configComponent.add(panelOption); -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/sync in repository jtimer. See https://gitlab.nuiton.org/chorem/jtimer.git commit f3431bc78f4c0a54271cddef2da6928f09438883 Author: servantie <servantie.c@gmail.com> Date: Tue Jun 21 17:27:12 2016 +0200 added some logging (more to come) and added properties --- .../java/org/chorem/jtimer/entities/SyncInfo.java | 6 +++++ .../jtimer/ui/report/TimerTaskUpdaterView.java | 30 +++++++++++++++++----- .../resources/TimerTaskUpdaterView.properties | 8 +++--- .../resources/TimerTaskUpdaterView_fr.properties | 2 ++ 4 files changed, 36 insertions(+), 10 deletions(-) diff --git a/src/main/java/org/chorem/jtimer/entities/SyncInfo.java b/src/main/java/org/chorem/jtimer/entities/SyncInfo.java index cf81350..f1fee01 100644 --- a/src/main/java/org/chorem/jtimer/entities/SyncInfo.java +++ b/src/main/java/org/chorem/jtimer/entities/SyncInfo.java @@ -9,8 +9,14 @@ import java.time.LocalDateTime; * Created by servantie on 13/06/16. */ public class SyncInfo { + + /** the url to synchronize on */ String syncURL; + + /** the last time the synchronization happened successfully */ LocalDateTime lastSync; + + /** true if the synchronization is active */ boolean isActiveSync; /** diff --git a/src/main/java/org/chorem/jtimer/ui/report/TimerTaskUpdaterView.java b/src/main/java/org/chorem/jtimer/ui/report/TimerTaskUpdaterView.java index 202baa2..7bc1787 100644 --- a/src/main/java/org/chorem/jtimer/ui/report/TimerTaskUpdaterView.java +++ b/src/main/java/org/chorem/jtimer/ui/report/TimerTaskUpdaterView.java @@ -214,13 +214,14 @@ public class TimerTaskUpdaterView extends FrameView implements DocumentListener, panelOption.add(urlComboBox, new GridBagConstraints(2, 2, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.VERTICAL, new Insets(1, 2, 1, 1), 0, 0)); + //display last Sync time JLabel lastSyncDateLabel = new JLabel(getResourceMap().getString("lastUpdateLabel")); panelOption.add(lastSyncDateLabel, new GridBagConstraints(1, 3, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.VERTICAL, new Insets(3, 1, 1, 1), 0, 0)); - //display last Sync time - lastUpdate = new JLabel(""); - //todo : properties - checkIsActiveSync = new JCheckBox("active"); + + lastUpdate = new JLabel(); + //checkbox for active sync + checkIsActiveSync = new JCheckBox(getResourceMap().getString("isActiveSync")); checkIsActiveSync.setAction(getContext().getActionMap(this).get("isActiveSync")); if (urlComboBox.getSelectedItem() != null) { if (task.getSynchronizingURLList().contains(urlComboBox.getSelectedItem())){ @@ -233,6 +234,7 @@ public class TimerTaskUpdaterView extends FrameView implements DocumentListener, checkIsActiveSync.setSelected(task.getSynchronizingInfo((String) urlComboBox.getSelectedItem()).getActiveSync()); } } + panelOption.add(lastUpdate, new GridBagConstraints(2, 3, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.VERTICAL, new Insets(1, 3, 1, 1), 0, 0)); panelOption.add(checkIsActiveSync, new GridBagConstraints(1, 4, 1, 1, 0, 0, @@ -397,8 +399,7 @@ public class TimerTaskUpdaterView extends FrameView implements DocumentListener, } } if (!task.getSynchronizingInfo(urlSelected).getActiveSync()) { - //todo : get in properties - updateArea.setText("Url inactive"); + updateArea.setText(getResourceMap().getString("isNotActiveURL")); } else { updateArea.setText(builder.toString()); @@ -410,7 +411,7 @@ public class TimerTaskUpdaterView extends FrameView implements DocumentListener, } /** - * Show annotation checkbox checked. + * Add annotation checkbox checked. */ @Action public boolean isIncludingAnnotations() { @@ -418,6 +419,14 @@ public class TimerTaskUpdaterView extends FrameView implements DocumentListener, return ischeckedIncludeAnnotations; } + /** + * Active sync checkbox checked + */ + @Action + public boolean isActiveSync() { + boolean isActiveSyncURL = checkIsActiveSync.isSelected(); + return isActiveSyncURL; + } /** @@ -479,9 +488,16 @@ public class TimerTaskUpdaterView extends FrameView implements DocumentListener, connection.setRequestProperty("Accept-Charset", charset); connection.setRequestProperty("Content-Type", "application/json"); connection.setRequestMethod("POST"); + //logging connection + log.info("Sending json to : " + syncURL); + postDataBytes = updateJsonString.getBytes(charset); connection.getOutputStream().write(postDataBytes); int code = connection.getResponseCode(); + + //logging code return + log.info("Code return : " + code); + if ((code == 200) || (code == 2001) || (code == 202)) { hasUpdated = true; } diff --git a/src/main/resources/org/chorem/jtimer/ui/report/resources/TimerTaskUpdaterView.properties b/src/main/resources/org/chorem/jtimer/ui/report/resources/TimerTaskUpdaterView.properties index 963ee35..1e8718e 100644 --- a/src/main/resources/org/chorem/jtimer/ui/report/resources/TimerTaskUpdaterView.properties +++ b/src/main/resources/org/chorem/jtimer/ui/report/resources/TimerTaskUpdaterView.properties @@ -19,14 +19,16 @@ # <http://www.gnu.org/licenses/gpl-3.0.html>. # #L% ### -updateTitle=${Application.title} - Synchronisation +updateTitle=${Application.title} - Synchronization updateGeneral=General updateOptions=Options updateFrom=From : updateTo=To : -lastUpdateLabel=Last Synchronisation at: -urlComboLabel = Synchronisation Url: +lastUpdateLabel=Last Synchronization at: +urlComboLabel = Synchronization Url: +isActiveSync = Active sync +isNotActiveURL = Inactive Synchronization pickCurrentMonth.Action.text = Select current month diff --git a/src/main/resources/org/chorem/jtimer/ui/report/resources/TimerTaskUpdaterView_fr.properties b/src/main/resources/org/chorem/jtimer/ui/report/resources/TimerTaskUpdaterView_fr.properties index aa37b4b..0febdcb 100644 --- a/src/main/resources/org/chorem/jtimer/ui/report/resources/TimerTaskUpdaterView_fr.properties +++ b/src/main/resources/org/chorem/jtimer/ui/report/resources/TimerTaskUpdaterView_fr.properties @@ -28,6 +28,8 @@ updateTo=\u00C0 : lastUpdateLabel=Derni\u00E8re synchronisation : urlComboLabel=Url de synchronisation : +isActiveSync= Synchronisation active +isNotActiveURL = Synchronisation vers cette URL d\u00E9sactiv\u00E9e pickCurrentMonth.Action.text = Selectionner le mois courant -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/sync in repository jtimer. See https://gitlab.nuiton.org/chorem/jtimer.git commit bf43b497525a2219527caeaf7521043d2393a194 Author: servantie <servantie.c@gmail.com> Date: Tue Jun 21 17:47:53 2016 +0200 corrected text on the checkbox isActiveSync --- src/main/java/org/chorem/jtimer/ui/report/TimerTaskUpdaterView.java | 4 +++- .../chorem/jtimer/ui/report/resources/TimerTaskUpdaterView.properties | 4 ++-- .../jtimer/ui/report/resources/TimerTaskUpdaterView_fr.properties | 4 ++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/chorem/jtimer/ui/report/TimerTaskUpdaterView.java b/src/main/java/org/chorem/jtimer/ui/report/TimerTaskUpdaterView.java index 7bc1787..e0be355 100644 --- a/src/main/java/org/chorem/jtimer/ui/report/TimerTaskUpdaterView.java +++ b/src/main/java/org/chorem/jtimer/ui/report/TimerTaskUpdaterView.java @@ -221,7 +221,7 @@ public class TimerTaskUpdaterView extends FrameView implements DocumentListener, lastUpdate = new JLabel(); //checkbox for active sync - checkIsActiveSync = new JCheckBox(getResourceMap().getString("isActiveSync")); + checkIsActiveSync = new JCheckBox(); checkIsActiveSync.setAction(getContext().getActionMap(this).get("isActiveSync")); if (urlComboBox.getSelectedItem() != null) { if (task.getSynchronizingURLList().contains(urlComboBox.getSelectedItem())){ @@ -230,6 +230,8 @@ public class TimerTaskUpdaterView extends FrameView implements DocumentListener, //if there has been an update before, display its date if ((lastSyncTime != null) && lastSyncTime.isAfter(LocalDateTime.MIN)) { lastUpdate.setText(lastSyncTime.toString()); + //logging change of lastSync + log.info(lastSyncTime.toString()); } checkIsActiveSync.setSelected(task.getSynchronizingInfo((String) urlComboBox.getSelectedItem()).getActiveSync()); } diff --git a/src/main/resources/org/chorem/jtimer/ui/report/resources/TimerTaskUpdaterView.properties b/src/main/resources/org/chorem/jtimer/ui/report/resources/TimerTaskUpdaterView.properties index 1e8718e..938b3ca 100644 --- a/src/main/resources/org/chorem/jtimer/ui/report/resources/TimerTaskUpdaterView.properties +++ b/src/main/resources/org/chorem/jtimer/ui/report/resources/TimerTaskUpdaterView.properties @@ -27,7 +27,6 @@ updateTo=To : lastUpdateLabel=Last Synchronization at: urlComboLabel = Synchronization Url: -isActiveSync = Active sync isNotActiveURL = Inactive Synchronization @@ -65,4 +64,5 @@ action.update404 = Not found action.update500 = Server error action.updateErrorTitle = Synchronization error action.updateEncodingError = Encoding error -action.updateURLError = URL error \ No newline at end of file +action.updateURLError = URL error +isActiveSync.Action.text = Active synchronization \ No newline at end of file diff --git a/src/main/resources/org/chorem/jtimer/ui/report/resources/TimerTaskUpdaterView_fr.properties b/src/main/resources/org/chorem/jtimer/ui/report/resources/TimerTaskUpdaterView_fr.properties index 0febdcb..722dc83 100644 --- a/src/main/resources/org/chorem/jtimer/ui/report/resources/TimerTaskUpdaterView_fr.properties +++ b/src/main/resources/org/chorem/jtimer/ui/report/resources/TimerTaskUpdaterView_fr.properties @@ -28,7 +28,6 @@ updateTo=\u00C0 : lastUpdateLabel=Derni\u00E8re synchronisation : urlComboLabel=Url de synchronisation : -isActiveSync= Synchronisation active isNotActiveURL = Synchronisation vers cette URL d\u00E9sactiv\u00E9e @@ -65,4 +64,5 @@ action.update400 = Mauvaise requ\u00EAte action.update404 = Mauvaise URL action.update500 = Erreur du serveur action.updateEncodingError = Erreur d'encodage -action.updateURLError = Erreur d'URL \ No newline at end of file +action.updateURLError = Erreur d'URL +isActiveSync.Action.text = Synchronisation Active \ No newline at end of file -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/sync in repository jtimer. See https://gitlab.nuiton.org/chorem/jtimer.git commit e2106d5e24314ab00b9b93a1de2ac16f5e5a4520 Author: servantie <servantie.c@gmail.com> Date: Wed Jun 22 16:38:43 2016 +0200 added logs, made method synchronizeTaskOnURL static and returning an int (http response) --- .../java/org/chorem/jtimer/entities/SyncInfo.java | 4 +- .../java/org/chorem/jtimer/entities/TimerTask.java | 2 +- .../chorem/jtimer/io/TimerTaskSynchronizer.java | 43 +++--- .../jtimer/ui/report/TimerTaskUpdaterView.java | 160 +++++++++++---------- .../resources/TimerTaskUpdaterView.properties | 1 + .../resources/TimerTaskUpdaterView_fr.properties | 1 + 6 files changed, 110 insertions(+), 101 deletions(-) diff --git a/src/main/java/org/chorem/jtimer/entities/SyncInfo.java b/src/main/java/org/chorem/jtimer/entities/SyncInfo.java index f1fee01..1eb90c4 100644 --- a/src/main/java/org/chorem/jtimer/entities/SyncInfo.java +++ b/src/main/java/org/chorem/jtimer/entities/SyncInfo.java @@ -57,10 +57,10 @@ public class SyncInfo { } /** - * Sets the isActiveSync boolean + * Sets the setIsActiveSync boolean * @param isActive boolean */ - public void isActiveSync(boolean isActive) { + public void setIsActiveSync(boolean isActive) { isActiveSync = isActive; } diff --git a/src/main/java/org/chorem/jtimer/entities/TimerTask.java b/src/main/java/org/chorem/jtimer/entities/TimerTask.java index f782e55..070f3d0 100644 --- a/src/main/java/org/chorem/jtimer/entities/TimerTask.java +++ b/src/main/java/org/chorem/jtimer/entities/TimerTask.java @@ -372,7 +372,7 @@ public class TimerTask implements Cloneable, * @param syncInfo the SyncInfo */ public void setIsActive(boolean isActive, SyncInfo syncInfo) { - syncInfo.isActiveSync(isActive); + syncInfo.setIsActiveSync(isActive); } /** diff --git a/src/main/java/org/chorem/jtimer/io/TimerTaskSynchronizer.java b/src/main/java/org/chorem/jtimer/io/TimerTaskSynchronizer.java index ea3660c..5063ce9 100644 --- a/src/main/java/org/chorem/jtimer/io/TimerTaskSynchronizer.java +++ b/src/main/java/org/chorem/jtimer/io/TimerTaskSynchronizer.java @@ -112,18 +112,23 @@ public class TimerTaskSynchronizer implements DataEventListener { List<JsonObject> jsonObjectList = TimerTaskHelper.taskToJSONFormat(task, false, timezone); for (JsonObject object : jsonObjectList) { - boolean successfulSync = synchronizeTaskOnURL(object); + int SyncResult = synchronizeTaskOnURL(object); + boolean successfulSync = false; + String syncURL = object.get("URL").getAsString(); + if (SyncResult > 199 && SyncResult < 300) { + successfulSync = true; + } + else if (SyncResult == 0) { + log.debug("Error in connection " + syncURL); + } //sync successful -> change the last sync time if (successfulSync) { - log.debug("Sync successful on " + object.get("URL").getAsString()); - task.setLastSync(LocalDateTime.now(), object.get("URL").getAsString()); + log.debug("Sync successful on " + syncURL); + task.setLastSync(LocalDateTime.now(), syncURL); } //-> do not change last sync time else { - log.debug("Sync failed on " + object.get("URL").getAsString()); - //deactivate autosync if the sync failed - task.getSynchronizingInfo(object.get("URL").getAsString()).isActiveSync(false); - log.info("Adress deactivated"); + log.debug("Sync failed on " + syncURL); } } @@ -132,16 +137,16 @@ public class TimerTaskSynchronizer implements DataEventListener { /** * Sends one synchronization (one JSON object) * @param object the object to sync - * @return a boolean indicating failure or success + * @return an int (http response code or 0 in case of a problem) */ - public boolean synchronizeTaskOnURL(JsonObject object) { + public static int synchronizeTaskOnURL(JsonObject object) { String updateJsonString = object.toString(); String syncURL = object.get("URL").getAsString(); String charset = "UTF-8"; HttpURLConnection connection; URL url; byte[] postDataBytes; - boolean hasUpdated = false; + int upDateValue = 0; try { url = new URL(syncURL); connection = (HttpURLConnection) url.openConnection(); @@ -154,23 +159,19 @@ public class TimerTaskSynchronizer implements DataEventListener { connection.setRequestMethod("POST"); postDataBytes = updateJsonString.getBytes(charset); connection.getOutputStream().write(postDataBytes); - int code = connection.getResponseCode(); - if ((code == 200) || (code == 201) || (code == 202)){ - hasUpdated = true; - } - else { - log.info("Error"); - } + upDateValue = connection.getResponseCode(); } catch (MalformedURLException e) { - log.error("URL malformed"); + log.error("URL malformed : " + syncURL); } catch (ProtocolException e) { log.error("Protocol error."); } catch (UnsupportedEncodingException e) { - log.error("Problem with encoding"); + log.error("Problem with encoding " + syncURL); } catch (IOException e) { - log.error("Problem with the connection"); + log.error("Problem with the connection " + syncURL); + }catch (IllegalArgumentException e) { + log.error("Port value not valid " + syncURL); } - return hasUpdated; + return upDateValue; } @Override diff --git a/src/main/java/org/chorem/jtimer/ui/report/TimerTaskUpdaterView.java b/src/main/java/org/chorem/jtimer/ui/report/TimerTaskUpdaterView.java index e0be355..3844abb 100644 --- a/src/main/java/org/chorem/jtimer/ui/report/TimerTaskUpdaterView.java +++ b/src/main/java/org/chorem/jtimer/ui/report/TimerTaskUpdaterView.java @@ -31,6 +31,7 @@ import org.chorem.jtimer.JTimer; import org.chorem.jtimer.data.TimerCore; import org.chorem.jtimer.entities.SyncInfo; import org.chorem.jtimer.entities.TimerTask; +import org.chorem.jtimer.io.TimerTaskSynchronizer; import org.jdesktop.application.*; import org.jdesktop.application.Action; import org.jdesktop.swingx.JXDatePicker; @@ -43,9 +44,8 @@ import javax.swing.event.DocumentListener; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; -import java.io.IOException; -import java.io.UnsupportedEncodingException; -import java.net.*; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; import java.text.DateFormat; import java.time.LocalDate; import java.time.LocalDateTime; @@ -59,7 +59,7 @@ import static org.chorem.jtimer.entities.TimerTaskHelper.taskToJSONFormat; * * Created by servantie on 13/05/16. */ -public class TimerTaskUpdaterView extends FrameView implements DocumentListener, ActionListener { +public class TimerTaskUpdaterView extends FrameView implements DocumentListener, ActionListener, ItemListener { /** Class logger */ protected static Log log = LogFactory.getLog(TimerTaskUpdaterView.class); @@ -113,10 +113,10 @@ public class TimerTaskUpdaterView extends FrameView implements DocumentListener, this.core = core; this.task = task; timezone = "+01:00"; + updateJson = new ArrayList<>(); setComponent(getMainComponent()); - updateJson = new ArrayList<>(); } @@ -170,6 +170,7 @@ public class TimerTaskUpdaterView extends FrameView implements DocumentListener, panelGeneral.add(previousWeekButton, new GridBagConstraints(2, 1, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(1, 1, 1, 1), 0, 0)); + // Option for period grouping JPanel typePanel = new JPanel(new GridLayout(0, 2)); panelGeneral.add(typePanel, new GridBagConstraints(0, 2, 3, 1, 0, 0, @@ -191,17 +192,19 @@ public class TimerTaskUpdaterView extends FrameView implements DocumentListener, JXTaskPane panelOption = new JXTaskPane(getResourceMap().getString("updateOptions")); panelOption.setLayout(new GridBagLayout()); + //checkbox to include annotations checkIncludesAnnotations = new JCheckBox(); checkIncludesAnnotations.setAction(getContext().getActionMap(this).get("isIncludingAnnotations")); - panelOption.add(checkIncludesAnnotations, new GridBagConstraints(1, 1, 1, 1, 0, 0, - GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(1, 1, 1, 1), 0, 0)); + panelOption.add(checkIncludesAnnotations, new GridBagConstraints(2, 4, 1, 1, 0, 0, + GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(4, 1, 1, 1), 0, 0)); //url combobox JLabel urlcomboBoxLabel = new JLabel(getResourceMap().getString("urlComboLabel")); urlComboBox = new JComboBox<>(); //make it editable to add new urls urlComboBox.setEditable(true); + urlComboBox.addItemListener(this); urlComboBox.addActionListener(this); //add the urls to the combobox for (String url : task.getSynchronizingURLList()) { @@ -209,10 +212,10 @@ public class TimerTaskUpdaterView extends FrameView implements DocumentListener, } urlComboBox.setActionCommand("comboBox"); - panelOption.add(urlcomboBoxLabel, new GridBagConstraints(1, 2, 1, 1, 0, 0, - GridBagConstraints.WEST, GridBagConstraints.VERTICAL, new Insets(2,1,1,1), 0, 0)); - panelOption.add(urlComboBox, new GridBagConstraints(2, 2, 1, 1, 0, 0, - GridBagConstraints.WEST, GridBagConstraints.VERTICAL, new Insets(1, 2, 1, 1), 0, 0)); + panelOption.add(urlcomboBoxLabel, new GridBagConstraints(1, 1, 1, 1, 0, 0, + GridBagConstraints.WEST, GridBagConstraints.VERTICAL, new Insets(1,1,1,1), 0, 0)); + panelOption.add(urlComboBox, new GridBagConstraints(2, 1, 1, 1, 0, 0, + GridBagConstraints.WEST, GridBagConstraints.VERTICAL, new Insets(1, 1, 1, 1), 0, 0)); //display last Sync time JLabel lastSyncDateLabel = new JLabel(getResourceMap().getString("lastUpdateLabel")); @@ -222,6 +225,7 @@ public class TimerTaskUpdaterView extends FrameView implements DocumentListener, lastUpdate = new JLabel(); //checkbox for active sync checkIsActiveSync = new JCheckBox(); + checkIsActiveSync.addActionListener(this); checkIsActiveSync.setAction(getContext().getActionMap(this).get("isActiveSync")); if (urlComboBox.getSelectedItem() != null) { if (task.getSynchronizingURLList().contains(urlComboBox.getSelectedItem())){ @@ -231,7 +235,10 @@ public class TimerTaskUpdaterView extends FrameView implements DocumentListener, if ((lastSyncTime != null) && lastSyncTime.isAfter(LocalDateTime.MIN)) { lastUpdate.setText(lastSyncTime.toString()); //logging change of lastSync - log.info(lastSyncTime.toString()); + log.info("Last Sync time loaded : " + lastSyncTime.toString()); + } + else { + log.info("No Last Sync time loaded"); } checkIsActiveSync.setSelected(task.getSynchronizingInfo((String) urlComboBox.getSelectedItem()).getActiveSync()); } @@ -422,11 +429,13 @@ public class TimerTaskUpdaterView extends FrameView implements DocumentListener, } /** - * Active sync checkbox checked + * Active sync checkbox checked, activates sync */ @Action public boolean isActiveSync() { boolean isActiveSyncURL = checkIsActiveSync.isSelected(); + task.getSynchronizingInfo((String) urlComboBox.getSelectedItem()).setIsActiveSync(isActiveSyncURL); + log.info("Activity of url changed "); return isActiveSyncURL; } @@ -471,75 +480,37 @@ public class TimerTaskUpdaterView extends FrameView implements DocumentListener, * @param object json of task info */ public void synchronizeTaskOnURL(TimerTask task, JsonObject object) { - String updateJsonString = object.toString(); + int syncAnswer = TimerTaskSynchronizer.synchronizeTaskOnURL(object); String syncURL = object.get("URL").getAsString(); - String charset = "UTF-8"; - HttpURLConnection connection; - URL url; - byte[] postDataBytes; + String message =""; + String title = ""; boolean hasUpdated = false; - String message = ""; - String title = getResourceMap().getString("action.updateErrorTitle"); - try { - url = new URL(syncURL); - connection = (HttpURLConnection) url.openConnection(); - connection.setUseCaches(false); - connection.setDoInput(true); - connection.setDoOutput(true); - connection.setRequestProperty("Content-Length", Integer.toString(updateJsonString.length())); - connection.setRequestProperty("Accept-Charset", charset); - connection.setRequestProperty("Content-Type", "application/json"); - connection.setRequestMethod("POST"); - //logging connection - log.info("Sending json to : " + syncURL); - - postDataBytes = updateJsonString.getBytes(charset); - connection.getOutputStream().write(postDataBytes); - int code = connection.getResponseCode(); - - //logging code return - log.info("Code return : " + code); - - if ((code == 200) || (code == 2001) || (code == 202)) { + if ((syncAnswer == 200) || (syncAnswer == 201) || (syncAnswer == 202)) { hasUpdated = true; + log.info("Update accepted for URL : " + syncURL); } - else if (code == 400) { - log.debug("Bad Request"); + else if (syncAnswer == 400) { + log.debug("Bad Request for URL : " + syncURL); message = getResourceMap().getString("action.update400"); } - else if (code == 404) { - log.debug("Not Found"); + else if (syncAnswer == 404) { + log.debug("URL Not Found : " + syncURL); message = getResourceMap().getString("action.update404"); } - else if (code == 500) { - log.debug("Server Error"); + else if (syncAnswer == 500) { + log.debug("Server Error on URL : " + syncURL); message = getResourceMap().getString("action.update500"); } else { log.debug("Error"); message = getResourceMap().getString("action.updateError"); } - connection.disconnect(); - - } catch (MalformedURLException e) { - log.debug("URL malformed"); - message = getResourceMap().getString("action.updateURLError"); - } catch (ProtocolException e) { - log.debug("Protocol error."); - message = getResourceMap().getString("action.updateProtocolError"); - } catch (UnsupportedEncodingException e) { - log.debug("Problem with encoding"); - message = getResourceMap().getString("action.updateEncodingError"); - } catch (IOException e) { - log.debug("Problem with the connection"); - message = getResourceMap().getString("action.updateError"); - } finally { if (hasUpdated) { - task.setLastSync(LocalDateTime.now(),syncURL); + task.setLastSync(LocalDateTime.now(), syncURL); + core.getData().changeSyncInfo(task, syncURL); } else if (!message.isEmpty()){ errorBox(message, title); } - } //advise that it's done, to grey-out the send sync button boolean oldValue = canUpdate; canUpdate = false; @@ -587,23 +558,58 @@ public class TimerTaskUpdaterView extends FrameView implements DocumentListener, public void itemAdded(){ String urlToAdd = (String) urlComboBox.getSelectedItem(); if ((!urlToAdd.isEmpty()) && (!task.getSynchronizingURLList().contains(urlToAdd))) { - urlComboBox.addItem(urlToAdd); - task.addSyncInfo(urlToAdd); - core.getData().changeSyncInfo(task, urlToAdd); + urlComboBox.addItem(urlToAdd); + task.addSyncInfo(urlToAdd); + core.getData().changeSyncInfo(task, urlToAdd); + log.info("New SyncInfo with URL : " + urlToAdd); } - if (lastUpdate != null) { - if (task.getSynchronizingInfo(urlToAdd).getLastSync().isAfter(LocalDateTime.MIN)) { - lastUpdate.setText(task.getSynchronizingInfo(urlToAdd).getLastSync().toString()); - core.getData().changeSyncInfo(task, urlToAdd); - } - else { - lastUpdate.setText(""); - } + } + + @Override + public void itemStateChanged(ItemEvent itemEvent) { + if (itemEvent.getStateChange()== ItemEvent.SELECTED) { + if (urlComboBox.getSelectedItem() != null) { + String urlToDisplay = urlComboBox.getSelectedItem().toString(); + if (!urlToDisplay.isEmpty()) { + log.info("Selected an object : " + urlComboBox.getSelectedItem().toString()); + //display last Sync Time + if (lastUpdate != null && task.getSynchronizingInfo(urlToDisplay).getLastSync() != null) { + if (task.getSynchronizingInfo(urlToDisplay).getLastSync().isAfter(LocalDateTime.MIN)) { + lastUpdate.setText(task.getSynchronizingInfo(urlToDisplay).getLastSync().toString()); + } + else { + lastUpdate.setText(""); + } + } + } + } } } + + @Override public void actionPerformed(ActionEvent actionEvent) { - itemAdded(); + String actionCommand = actionEvent.getActionCommand(); + if (actionCommand.equals("comboBox")) { + String urlToAdd = (String) urlComboBox.getSelectedItem(); + if (!task.getSynchronizingURLList().contains(urlToAdd)) { + log.info("New URL detected !"); + itemAdded(); + } + } + else if (actionCommand.equals("comboBoxChanged")) { + log.info("There has been a change in the comboBox"); + + } + else if (actionCommand.equals("comboBoxEdited")) { + log.info("The comboBox was edited"); + } + else if (actionCommand.equals(getResourceMap().getString("isActiveSync.Action.text"))) { + log.info("Checkbox ticked, unticked"); + } + else { + log.info("Action performed, not a new URL. Action: " + actionEvent.getActionCommand()); + } } -} +} \ No newline at end of file diff --git a/src/main/resources/org/chorem/jtimer/ui/report/resources/TimerTaskUpdaterView.properties b/src/main/resources/org/chorem/jtimer/ui/report/resources/TimerTaskUpdaterView.properties index 938b3ca..2b669a8 100644 --- a/src/main/resources/org/chorem/jtimer/ui/report/resources/TimerTaskUpdaterView.properties +++ b/src/main/resources/org/chorem/jtimer/ui/report/resources/TimerTaskUpdaterView.properties @@ -65,4 +65,5 @@ action.update500 = Server error action.updateErrorTitle = Synchronization error action.updateEncodingError = Encoding error action.updateURLError = URL error + isActiveSync.Action.text = Active synchronization \ No newline at end of file diff --git a/src/main/resources/org/chorem/jtimer/ui/report/resources/TimerTaskUpdaterView_fr.properties b/src/main/resources/org/chorem/jtimer/ui/report/resources/TimerTaskUpdaterView_fr.properties index 722dc83..db5d2a1 100644 --- a/src/main/resources/org/chorem/jtimer/ui/report/resources/TimerTaskUpdaterView_fr.properties +++ b/src/main/resources/org/chorem/jtimer/ui/report/resources/TimerTaskUpdaterView_fr.properties @@ -65,4 +65,5 @@ action.update404 = Mauvaise URL action.update500 = Erreur du serveur action.updateEncodingError = Erreur d'encodage action.updateURLError = Erreur d'URL + isActiveSync.Action.text = Synchronisation Active \ No newline at end of file -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/sync in repository jtimer. See https://gitlab.nuiton.org/chorem/jtimer.git commit 7d1d920fc335ee30254b0baab612a7a760359b4e Author: servantie <servantie.c@gmail.com> Date: Wed Jun 22 14:33:15 2016 +0200 checking the isActive checkbox de/activates the sync on the url chosen -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/sync in repository jtimer. See https://gitlab.nuiton.org/chorem/jtimer.git commit 2d9e6420fbd15150d3719ba8763de25cb5dbd5dc Author: servantie <servantie.c@gmail.com> Date: Wed Jun 22 16:28:55 2016 +0200 when a url is deleted in the combobox, it's saved in the file --- .../org/chorem/jtimer/data/DataEventListener.java | 6 +++++ .../org/chorem/jtimer/data/TimerDataManager.java | 12 +++++++++ .../chorem/jtimer/io/GTimerIncrementalSaver.java | 9 +++++++ .../jtimer/ui/report/TimerTaskUpdaterView.java | 30 ++++++++++++++++++++++ 4 files changed, 57 insertions(+) diff --git a/src/main/java/org/chorem/jtimer/data/DataEventListener.java b/src/main/java/org/chorem/jtimer/data/DataEventListener.java index cead109..f51ec8e 100644 --- a/src/main/java/org/chorem/jtimer/data/DataEventListener.java +++ b/src/main/java/org/chorem/jtimer/data/DataEventListener.java @@ -162,5 +162,11 @@ public interface DataEventListener extends EventListener { */ void changeSyncInfo(TimerTask task, String syncURL); + /** + * SyncInfo deleted + */ + default void deleteSyncInfo(TimerTask task, String syncURL) { + + } } diff --git a/src/main/java/org/chorem/jtimer/data/TimerDataManager.java b/src/main/java/org/chorem/jtimer/data/TimerDataManager.java index 09c6c83..8d4e6db 100644 --- a/src/main/java/org/chorem/jtimer/data/TimerDataManager.java +++ b/src/main/java/org/chorem/jtimer/data/TimerDataManager.java @@ -651,4 +651,16 @@ public class TimerDataManager { dataEventListener.changeSyncInfo(task, url); } } + + /** + * When a syncInfo is deleted + */ + public void deleteSyncInfo(TimerTask task, String url) { + if (task.getSynchronizingURLList().contains(url)) { + task.removeSyncInfo(url); + } + for (DataEventListener dataEventListener : dataEventListeners) { + dataEventListener.deleteSyncInfo(task, url); + } + } } diff --git a/src/main/java/org/chorem/jtimer/io/GTimerIncrementalSaver.java b/src/main/java/org/chorem/jtimer/io/GTimerIncrementalSaver.java index 79be028..e5947b1 100644 --- a/src/main/java/org/chorem/jtimer/io/GTimerIncrementalSaver.java +++ b/src/main/java/org/chorem/jtimer/io/GTimerIncrementalSaver.java @@ -1704,4 +1704,13 @@ public class GTimerIncrementalSaver extends AbstractSaver implements Saver, } + /** when a syncInfo is deleted make a save + * + * @param task + * @param url + */ + public void deleteSyncInfo(TimerTask task, String url) { + saveSynchronisationInfo(task); + } + } diff --git a/src/main/java/org/chorem/jtimer/ui/report/TimerTaskUpdaterView.java b/src/main/java/org/chorem/jtimer/ui/report/TimerTaskUpdaterView.java index 3844abb..522a60e 100644 --- a/src/main/java/org/chorem/jtimer/ui/report/TimerTaskUpdaterView.java +++ b/src/main/java/org/chorem/jtimer/ui/report/TimerTaskUpdaterView.java @@ -73,6 +73,9 @@ public class TimerTaskUpdaterView extends FrameView implements DocumentListener, /** Activate a sync URL */ protected JCheckBox checkIsActiveSync; + /** button to delete a URL */ + protected JButton deleteButton; + /** Date pickers, from... to */ protected JXDatePicker datePickerFrom, datePickerTo; @@ -244,6 +247,19 @@ public class TimerTaskUpdaterView extends FrameView implements DocumentListener, } } + //option to delete url + //todo : properties ! + deleteButton = new JButton("Delete"); + deleteButton.addActionListener(this); + deleteButton.setActionCommand("deleteURL"); + + panelOption.add(deleteButton, new GridBagConstraints(1, 5, 1, 1, 0, 0, + GridBagConstraints.WEST, GridBagConstraints.VERTICAL, new Insets(2, 1, 1, 1), 0, 0)); + + + + + panelOption.add(lastUpdate, new GridBagConstraints(2, 3, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.VERTICAL, new Insets(1, 3, 1, 1), 0, 0)); panelOption.add(checkIsActiveSync, new GridBagConstraints(1, 4, 1, 1, 0, 0, @@ -608,6 +624,20 @@ public class TimerTaskUpdaterView extends FrameView implements DocumentListener, else if (actionCommand.equals(getResourceMap().getString("isActiveSync.Action.text"))) { log.info("Checkbox ticked, unticked"); } + else if (actionCommand.equals("deleteURL")) { + String urlToUse = (String) urlComboBox.getSelectedItem(); + //if the delete button has been clicked, delete the task (if it exists) + if ((urlToUse != null) && !urlToUse.isEmpty() && (task.getSynchronizingURLList().contains(urlToUse))) { + task.removeSyncInfo(urlToUse); + urlComboBox.removeItem(urlToUse); + log.info("SyncInfo deleted " + urlToUse); + core.getData().deleteSyncInfo(task, urlToUse); + } + else { + //todo : properties! + errorBox("No task to delete", "Error"); + } + } else { log.info("Action performed, not a new URL. Action: " + actionEvent.getActionCommand()); } -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/sync in repository jtimer. See https://gitlab.nuiton.org/chorem/jtimer.git commit 09f14bd1e012dafcd3c99df853e531a317d2236c Author: servantie <servantie.c@gmail.com> Date: Wed Jun 22 17:52:52 2016 +0200 deletion of url saved to sync file properly + corrected parsing of syncInfo (catching a DateTimeParseException, and taking a 00:00:00 instead of 00:00:00.000 format) --- .../org/chorem/jtimer/data/TimerDataManager.java | 2 ++ .../chorem/jtimer/io/GTimerIncrementalSaver.java | 11 +++++++++-- .../jtimer/ui/report/TimerTaskUpdaterView.java | 21 +++++++-------------- .../resources/TimerTaskUpdaterView.properties | 5 +++++ .../resources/TimerTaskUpdaterView_fr.properties | 4 ++++ 5 files changed, 27 insertions(+), 16 deletions(-) diff --git a/src/main/java/org/chorem/jtimer/data/TimerDataManager.java b/src/main/java/org/chorem/jtimer/data/TimerDataManager.java index 8d4e6db..2c390c1 100644 --- a/src/main/java/org/chorem/jtimer/data/TimerDataManager.java +++ b/src/main/java/org/chorem/jtimer/data/TimerDataManager.java @@ -650,6 +650,7 @@ public class TimerDataManager { for (DataEventListener dataEventListener : dataEventListeners) { dataEventListener.changeSyncInfo(task, url); } + log.info("SyncInfo changed: " + url); } /** @@ -662,5 +663,6 @@ public class TimerDataManager { for (DataEventListener dataEventListener : dataEventListeners) { dataEventListener.deleteSyncInfo(task, url); } + log.info("SyncInfo deleted: " + url); } } diff --git a/src/main/java/org/chorem/jtimer/io/GTimerIncrementalSaver.java b/src/main/java/org/chorem/jtimer/io/GTimerIncrementalSaver.java index e5947b1..537604f 100644 --- a/src/main/java/org/chorem/jtimer/io/GTimerIncrementalSaver.java +++ b/src/main/java/org/chorem/jtimer/io/GTimerIncrementalSaver.java @@ -43,6 +43,7 @@ import java.text.DateFormat; import java.text.SimpleDateFormat; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; +import java.time.format.DateTimeParseException; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -635,8 +636,13 @@ public class GTimerIncrementalSaver extends AbstractSaver implements Saver, } //else if there is lastSyncTime else if (urlArray.length == 3) { - DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSS"); - LocalDateTime date = LocalDateTime.parse(urlArray[2], formatter); + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss"); + LocalDateTime date = null; + try { + date = LocalDateTime.parse(urlArray[2], formatter); + } catch (DateTimeParseException e) { + log.error("Error parsing SyncTime for " + urlArray[0]); + } if ("true".equals(urlArray[1])) { task.addSyncInfo(urlArray[0], date, true); } else { @@ -1592,6 +1598,7 @@ public class GTimerIncrementalSaver extends AbstractSaver implements Saver, for (TimerTask task : runningTasks) { saveTask(task); + saveSynchronisationInfo(task); } } } diff --git a/src/main/java/org/chorem/jtimer/ui/report/TimerTaskUpdaterView.java b/src/main/java/org/chorem/jtimer/ui/report/TimerTaskUpdaterView.java index 522a60e..e912b4d 100644 --- a/src/main/java/org/chorem/jtimer/ui/report/TimerTaskUpdaterView.java +++ b/src/main/java/org/chorem/jtimer/ui/report/TimerTaskUpdaterView.java @@ -248,8 +248,7 @@ public class TimerTaskUpdaterView extends FrameView implements DocumentListener, } //option to delete url - //todo : properties ! - deleteButton = new JButton("Delete"); + deleteButton = new JButton(getResourceMap().getString("deleteButton")); deleteButton.addActionListener(this); deleteButton.setActionCommand("deleteURL"); @@ -411,7 +410,7 @@ public class TimerTaskUpdaterView extends FrameView implements DocumentListener, updateArea.setText(""); updateJson = new ArrayList<>(); //get the various objects for updates (on several urls) - updateJson = taskToJSONFormat(task, datePickerFrom.getDate(), + updateJson = taskToJSONFormat(task, datePickerFrom.getDate(), datePickerTo.getDate(), isIncludingAnnotations(), timezone); if (!updateJson.isEmpty()) { String urlSelected = (String) urlComboBox.getSelectedItem(); @@ -423,15 +422,11 @@ public class TimerTaskUpdaterView extends FrameView implements DocumentListener, builder.append(gson.toJson(object)); } } - if (!task.getSynchronizingInfo(urlSelected).getActiveSync()) { - updateArea.setText(getResourceMap().getString("isNotActiveURL")); - } - else { + if (task.getSynchronizingInfo(urlSelected).getActiveSync()) { updateArea.setText(builder.toString()); } - } - else { - updateArea.setText("No data"); + } else { + updateArea.setText(getResourceMap().getString("isNotActiveURL")); } } @@ -573,7 +568,7 @@ public class TimerTaskUpdaterView extends FrameView implements DocumentListener, */ public void itemAdded(){ String urlToAdd = (String) urlComboBox.getSelectedItem(); - if ((!urlToAdd.isEmpty()) && (!task.getSynchronizingURLList().contains(urlToAdd))) { + if ((urlToAdd != null) && (!urlToAdd.isEmpty()) && (!task.getSynchronizingURLList().contains(urlToAdd))) { urlComboBox.addItem(urlToAdd); task.addSyncInfo(urlToAdd); core.getData().changeSyncInfo(task, urlToAdd); @@ -630,12 +625,10 @@ public class TimerTaskUpdaterView extends FrameView implements DocumentListener, if ((urlToUse != null) && !urlToUse.isEmpty() && (task.getSynchronizingURLList().contains(urlToUse))) { task.removeSyncInfo(urlToUse); urlComboBox.removeItem(urlToUse); - log.info("SyncInfo deleted " + urlToUse); core.getData().deleteSyncInfo(task, urlToUse); } else { - //todo : properties! - errorBox("No task to delete", "Error"); + errorBox(getResourceMap().getString("deleteErrorMessage"), getResourceMap().getString("deleteErrorTitle")); } } else { diff --git a/src/main/resources/org/chorem/jtimer/ui/report/resources/TimerTaskUpdaterView.properties b/src/main/resources/org/chorem/jtimer/ui/report/resources/TimerTaskUpdaterView.properties index 2b669a8..6de32f8 100644 --- a/src/main/resources/org/chorem/jtimer/ui/report/resources/TimerTaskUpdaterView.properties +++ b/src/main/resources/org/chorem/jtimer/ui/report/resources/TimerTaskUpdaterView.properties @@ -66,4 +66,9 @@ action.updateErrorTitle = Synchronization error action.updateEncodingError = Encoding error action.updateURLError = URL error +deleteButton = Delete URL + +deleteErrorMessage = No URL to delete +deleteErrorTitle = Deletion error + isActiveSync.Action.text = Active synchronization \ No newline at end of file diff --git a/src/main/resources/org/chorem/jtimer/ui/report/resources/TimerTaskUpdaterView_fr.properties b/src/main/resources/org/chorem/jtimer/ui/report/resources/TimerTaskUpdaterView_fr.properties index db5d2a1..768678c 100644 --- a/src/main/resources/org/chorem/jtimer/ui/report/resources/TimerTaskUpdaterView_fr.properties +++ b/src/main/resources/org/chorem/jtimer/ui/report/resources/TimerTaskUpdaterView_fr.properties @@ -66,4 +66,8 @@ action.update500 = Erreur du serveur action.updateEncodingError = Erreur d'encodage action.updateURLError = Erreur d'URL +deleteButton = Supprimer l'URL +deleteErrorMessage = Aucune URL \u00E0 supprimer +deleteErrorTitle = Erreur de suppression + isActiveSync.Action.text = Synchronisation Active \ No newline at end of file -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
participants (1)
-
chorem.org scm