07/75: displayed the checkbox to include annotations with the update, includes it in the update if checked.
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 5249bb573725847edd58afb1fe57984be0e090db Author: servantie <servantie.c@gmail.com> Date: Thu May 19 10:57:29 2016 +0200 displayed the checkbox to include annotations with the update, includes it in the update if checked. --- .../chorem/jtimer/entities/TimerTaskHelper.java | 12 +++---- .../jtimer/ui/report/TimerTaskUpdaterView.java | 39 ++++++++++++++-------- .../resources/TimerTaskUpdaterView.properties | 3 +- .../resources/TimerTaskUpdaterView_fr.properties | 3 +- 4 files changed, 34 insertions(+), 23 deletions(-) diff --git a/src/main/java/org/chorem/jtimer/entities/TimerTaskHelper.java b/src/main/java/org/chorem/jtimer/entities/TimerTaskHelper.java index dd8d6c9..846077b 100644 --- a/src/main/java/org/chorem/jtimer/entities/TimerTaskHelper.java +++ b/src/main/java/org/chorem/jtimer/entities/TimerTaskHelper.java @@ -338,10 +338,10 @@ public class TimerTaskHelper { * @param task the task to make a JSON from * @return result the string in JSON */ - public static String taskToJSONFormat(TimerTask task) { + public static String taskToJSONFormat(TimerTask task, boolean withAnnotations) { Date startDate = task.getCreationDate(); Date endDate = new Date(); - String resultingJSON = taskToJSONFormat(task, startDate, endDate); + String resultingJSON = taskToJSONFormat(task, startDate, endDate, withAnnotations); return resultingJSON; } @@ -355,8 +355,8 @@ public class TimerTaskHelper { * @param endDate the end date * @return result the string in JSON */ - public static String taskToJSONFormat(TimerTask task, Date startDate, Date endDate) { - String resultingJSON = "{\"URL\":\"" + task.getSynchronisingURL()+ "\",\"periods\":" + getTimesAndCommentsJSON(task, startDate, endDate) +"}"; + public static String taskToJSONFormat(TimerTask task, Date startDate, Date endDate, boolean withAnnotations) { + String resultingJSON = "{\"URL\":\"" + task.getSynchronisingURL()+ "\",\"periods\":" + getTimesAndCommentsJSON(task, startDate, endDate, withAnnotations) +"}"; return resultingJSON; } @@ -369,7 +369,7 @@ public class TimerTaskHelper { * @param endDate : end of period * @return a string in json format */ - public static String getTimesAndCommentsJSON(TimerTask task, Date startDate, Date endDate) { + public static String getTimesAndCommentsJSON(TimerTask task, Date startDate, Date endDate, boolean withAnnotations) { String result = ""; SortedMap<Date, Long> dates = task.getAllDaysAndTimes().subMap(startDate, endDate); if (dates.size() != 0) { @@ -384,7 +384,7 @@ public class TimerTaskHelper { result = result + "{\"id\":\""+ dateString + "\",\"startDate\":\"" + dateString + "T00:00:00" + "\",\"duration\":" + Long.toString(entry.getValue()) + ",\"info\":\""; //adding comments (if there are any) - if (getAnnotation(task, entry.getKey()).size() != 0) { + if (getAnnotation(task, entry.getKey()).size() != 0 && withAnnotations ) { for (String s : getAnnotation(task, entry.getKey())) { result = result + s + ","; } 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 045fcfd..f5be8bf 100644 --- a/src/main/java/org/chorem/jtimer/ui/report/TimerTaskUpdaterView.java +++ b/src/main/java/org/chorem/jtimer/ui/report/TimerTaskUpdaterView.java @@ -43,6 +43,7 @@ import java.io.OutputStream; import java.io.UnsupportedEncodingException; import java.net.*; import java.text.DateFormat; +import java.time.LocalDateTime; import java.util.*; import java.util.List; @@ -157,10 +158,14 @@ public class TimerTaskUpdaterView extends FrameView implements DocumentListener // miscellaneous JXTaskPane panelOption = new JXTaskPane(getResourceMap().getString("updateOptions")); + panelOption.setLayout(new GridBagLayout()); checkIncludesAnnotations = new JCheckBox(); - checkIncludesAnnotations.setAction(getContext().getActionMap(this).get("updateAnnotations")); - panelOption.add(checkIncludesAnnotations); + 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)); + + configComponent.add(panelGeneral); configComponent.add(panelOption); @@ -311,7 +316,7 @@ public class TimerTaskUpdaterView extends FrameView implements DocumentListener updateJson = ""; // make String of information updateJson = taskToJSONFormat(task, datePickerFrom.getDate(), - datePickerTo.getDate()); + datePickerTo.getDate(), isIncludingAnnotations()); if (updateJson != null && !updateJson.isEmpty()) { updateArea.setText(prettifyJSON(updateJson)); @@ -320,6 +325,16 @@ public class TimerTaskUpdaterView extends FrameView implements DocumentListener } } + /** + * Show annotation checkbox checked. + */ + @Action + public boolean isIncludingAnnotations() { + boolean ischeckedIncludeAnnotations = checkIncludesAnnotations.isSelected(); + return ischeckedIncludeAnnotations; + } + + /** * Can update ? @@ -376,25 +391,21 @@ public class TimerTaskUpdaterView extends FrameView implements DocumentListener } catch (IOException e) { e.printStackTrace(); } - - try { - InputStream response = connection.getInputStream(); //get the header fields Map<String, List<String>> map = connection.getHeaderFields(); + boolean hasUpdated = false; + //check for positive answer from server for (Map.Entry<String, List<String>> entry : map.entrySet()) { for (String s : entry.getValue()) { if (s.equals("HTTP/1.1 200 OK")) { - log.info("Synchronised!"); - //todo : make it update the lastSync Data - + hasUpdated = true; } } } - - - } catch (IOException e) { - e.printStackTrace(); - } + //if all has gone well, update SyncTime (todo:save information) + if (hasUpdated) { + task.setLastSync(LocalDateTime.now()); + } } @Override 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 e3a30c1..e2d2022 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 @@ -24,7 +24,6 @@ updateGeneral=General updateOptions=Options updateFrom=From : updateTo=To : -updateAnnotations = Include annotations currentWeek.Action.icon = date_current.png currentWeek.Action.shortDescription = Current week @@ -32,6 +31,8 @@ currentWeek.Action.shortDescription = Current week previousWeek.Action.icon = date_previous.png previousWeek.Action.shortDescription = Previous week +updateAnnotations.Action.text = Include annotations +updateAnnotations.Action.shortDescription = Include annotations generateUpdate.Action.text = &Generate generateUpdate.Action.icon = applications-system.png 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 169d5bd..8cda7ee 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 @@ -25,8 +25,6 @@ updateGeneral=G\u00E9n\u00E9ral updateOptions=Options updateFrom=De : updateTo=\u00C0 : -updateAnnotations = Inclure les annotations - currentWeek.Action.icon = date_current.png currentWeek.Action.shortDescription = Semaine courante @@ -34,6 +32,7 @@ currentWeek.Action.shortDescription = Semaine courante previousWeek.Action.icon = date_previous.png previousWeek.Action.shortDescription = Semaine pr\u00E9c\u00E9dente +isIncludingAnnotations.Action.text = Inclure les annotations generateUpdate.Action.text = &G\u00E9n\u00E9rer generateUpdate.Action.icon = applications-system.png -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
participants (1)
-
chorem.org scm