branch feature/sync updated (eacb097 -> a774a64)
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 eacb097 set up ids for times in the json output to be dates (one task at one date has only one value for duration in jtimer), minor properties change new b8b27e2 displayed the checkbox to include annotations with the update, includes it in the update if checked. new 624a2ef be able to pick previous month and current month for update with a button new a774a64 saving synchronisation time when update successful The 3 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 a774a643e041d50bb215c237dbd6833d0193af6d Author: servantie <servantie.c@gmail.com> Date: Fri May 20 09:48:12 2016 +0200 saving synchronisation time when update successful commit 624a2ef867f9b3c657c8a579a782db654b810fd1 Author: servantie <servantie.c@gmail.com> Date: Thu May 19 16:06:24 2016 +0200 be able to pick previous month and current month for update with a button commit b8b27e24911ae96423235a64c43f943c70906681 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. Summary of changes: .../chorem/jtimer/entities/TimerTaskHelper.java | 19 +++-- .../jtimer/ui/report/TimerTaskUpdaterView.java | 90 +++++++++++++++++----- .../resources/TimerTaskUpdaterView.properties | 9 ++- .../resources/TimerTaskUpdaterView_fr.properties | 7 +- 4 files changed, 99 insertions(+), 26 deletions(-) -- 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 b8b27e24911ae96423235a64c43f943c70906681 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 43f34b2..8e6beff 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>.
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 624a2ef867f9b3c657c8a579a782db654b810fd1 Author: servantie <servantie.c@gmail.com> Date: Thu May 19 16:06:24 2016 +0200 be able to pick previous month and current month for update with a button --- .../chorem/jtimer/entities/TimerTaskHelper.java | 9 +++- .../jtimer/ui/report/TimerTaskUpdaterView.java | 48 ++++++++++++++++++++++ .../resources/TimerTaskUpdaterView.properties | 6 +++ .../resources/TimerTaskUpdaterView_fr.properties | 6 +++ 4 files changed, 68 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/chorem/jtimer/entities/TimerTaskHelper.java b/src/main/java/org/chorem/jtimer/entities/TimerTaskHelper.java index 8e6beff..94bb7f8 100644 --- a/src/main/java/org/chorem/jtimer/entities/TimerTaskHelper.java +++ b/src/main/java/org/chorem/jtimer/entities/TimerTaskHelper.java @@ -356,7 +356,14 @@ public class TimerTaskHelper { * @return result the string in JSON */ public static String taskToJSONFormat(TimerTask task, Date startDate, Date endDate, boolean withAnnotations) { - String resultingJSON = "{\"URL\":\"" + task.getSynchronisingURL()+ "\",\"periods\":" + getTimesAndCommentsJSON(task, startDate, endDate, withAnnotations) +"}"; + + LocalDate startPeriodDate = startDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDate(); + LocalDate endPeriodDate = endDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDate(); + + + String resultingJSON = "{\"URL\":\"" + task.getSynchronisingURL()+ "\",\"startDate\":\"" + + startPeriodDate.toString() + "\",\"endDate\":\"" + endPeriodDate.toString() + "\",\"periods\":" + + getTimesAndCommentsJSON(task, startDate, endDate, withAnnotations) +"}"; return resultingJSON; } 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 f5be8bf..0c264a5 100644 --- a/src/main/java/org/chorem/jtimer/ui/report/TimerTaskUpdaterView.java +++ b/src/main/java/org/chorem/jtimer/ui/report/TimerTaskUpdaterView.java @@ -43,7 +43,9 @@ import java.io.OutputStream; import java.io.UnsupportedEncodingException; import java.net.*; import java.text.DateFormat; +import java.time.LocalDate; import java.time.LocalDateTime; +import java.time.ZoneId; import java.util.*; import java.util.List; @@ -155,6 +157,18 @@ public class TimerTaskUpdaterView extends FrameView implements DocumentListener JPanel typePanel = new JPanel(new GridLayout(0, 2)); panelGeneral.add(typePanel, new GridBagConstraints(0, 2, 3, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); + //button to have the whole month selected in the datepicker + JButton currentMonthButton = new JButton(); + currentMonthButton.setBorder(BorderFactory.createEmptyBorder()); + currentMonthButton.setAction(getContext().getActionMap(this).get("pickCurrentMonth")); + panelGeneral.add(currentMonthButton, new GridBagConstraints(1, 2, 1, 1, 0, 0, + GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(1, 1, 1, 1), 0, 0)); + JButton previousMonthButton = new JButton(); + previousMonthButton.setBorder(BorderFactory.createEmptyBorder()); + previousMonthButton.setAction(getContext().getActionMap(this).get("pickPreviousMonth")); + panelGeneral.add(previousMonthButton, new GridBagConstraints(1, 3, 1, 1, 0, 0, + GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(1, 1, 1, 1), 0, 0)); + // miscellaneous JXTaskPane panelOption = new JXTaskPane(getResourceMap().getString("updateOptions")); @@ -223,6 +237,40 @@ public class TimerTaskUpdaterView extends FrameView implements DocumentListener } /** + * Have current month selected in date pickers + */ + @org.jdesktop.application.Action + public void pickCurrentMonth() { + Calendar calendar = Calendar.getInstance(); + datePickerTo.setDate(calendar.getTime()); + //set it to the first day of the month + calendar.set(calendar.DAY_OF_MONTH, 1); + datePickerFrom.setDate(calendar.getTime()); + + } + + /** + * Have previous month selected in date pickers + */ + @org.jdesktop.application.Action + public void pickPreviousMonth() { + //get number of days in the previous month + //there has to be a better way to do this.. + LocalDate currentDate = LocalDate.now(); + currentDate.minusMonths(1); + int numberOfDays = currentDate.minusMonths(1).lengthOfMonth(); + + Calendar calendar = Calendar.getInstance(); + //previous month, first day + calendar.add(calendar.MONTH, -1); + calendar.set(calendar.DAY_OF_MONTH, 1); + datePickerFrom.setDate(calendar.getTime()); + Calendar calendarEnd = (Calendar) calendar.clone(); + calendarEnd.set(calendar.DAY_OF_MONTH, numberOfDays); + datePickerTo.setDate(calendarEnd.getTime()); + + } + /** * Fill picker date with predefined week selection (from current) * and apply a delay (-1 = previous week). * 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 e2d2022..8268439 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 @@ -25,6 +25,12 @@ updateOptions=Options updateFrom=From : updateTo=To : +pickCurrentMonth.Action.text = Select current month +pickCurrentMonth.Action.shortDescription = Select current month + +pickPreviousMonth.Action.text = Select previous month +pickPreviousMonth.Action.shortDescription = Select previous month + currentWeek.Action.icon = date_current.png currentWeek.Action.shortDescription = Current week 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 8cda7ee..3f3eacc 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 @@ -26,6 +26,12 @@ updateOptions=Options updateFrom=De : updateTo=\u00C0 : +pickCurrentMonth.Action.text = Selectionner le mois courant +pickCurrentMonth.Action.shortDescription = Selectionner le mois courant + +pickPreviousMonth.Action.text = Selectionner le mois pr\u00E9c\u00E9dent +pickPreviousMonth.Action.shortDescription = Selectionner le mois pr\u00E9c\u00E9dent + currentWeek.Action.icon = date_current.png currentWeek.Action.shortDescription = Semaine courante -- 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 a774a643e041d50bb215c237dbd6833d0193af6d Author: servantie <servantie.c@gmail.com> Date: Fri May 20 09:48:12 2016 +0200 saving synchronisation time when update successful --- .../java/org/chorem/jtimer/ui/report/TimerTaskUpdaterView.java | 7 +------ 1 file changed, 1 insertion(+), 6 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 0c264a5..4b72b27 100644 --- a/src/main/java/org/chorem/jtimer/ui/report/TimerTaskUpdaterView.java +++ b/src/main/java/org/chorem/jtimer/ui/report/TimerTaskUpdaterView.java @@ -38,14 +38,12 @@ import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; import java.awt.*; import java.io.IOException; -import java.io.InputStream; import java.io.OutputStream; import java.io.UnsupportedEncodingException; import java.net.*; import java.text.DateFormat; import java.time.LocalDate; import java.time.LocalDateTime; -import java.time.ZoneId; import java.util.*; import java.util.List; @@ -90,11 +88,8 @@ public class TimerTaskUpdaterView extends FrameView implements DocumentListener public TimerTaskUpdaterView(Application application, TimerCore core, TimerTask task) { super(application); - // modify frame name - // otherwise, get parent frame dimension getFrame().setName("updateFrame"); - //getFrame().setTitle("Update"); getFrame().setTitle(getResourceMap().getString("updateTitle")); this.core = core; @@ -452,7 +447,7 @@ public class TimerTaskUpdaterView extends FrameView implements DocumentListener } //if all has gone well, update SyncTime (todo:save information) if (hasUpdated) { - task.setLastSync(LocalDateTime.now()); + core.getData().editTaskLastSync(task, LocalDateTime.now()); } } -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
participants (1)
-
chorem.org scm