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 34fb3544605bc89d2c8dbc6b3403f64cc5920733 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 846077b..19643d3 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>.