r2816 - in trunk/src/main/java/org/chorem/jtimer: . ui/report
Author: echatellier Date: 2012-03-09 16:31:15 +0100 (Fri, 09 Mar 2012) New Revision: 2816 Url: http://chorem.org/repositories/revision/jtimer/2816 Log: #281 : Ability to save report options Modified: trunk/src/main/java/org/chorem/jtimer/JTimerConfig.java trunk/src/main/java/org/chorem/jtimer/ui/report/ReportView.java Modified: trunk/src/main/java/org/chorem/jtimer/JTimerConfig.java =================================================================== --- trunk/src/main/java/org/chorem/jtimer/JTimerConfig.java 2012-03-09 15:03:30 UTC (rev 2815) +++ trunk/src/main/java/org/chorem/jtimer/JTimerConfig.java 2012-03-09 15:31:15 UTC (rev 2816) @@ -85,7 +85,7 @@ public Class getIOSaverClass() { return appConfig.getOptionAsClass(JTimerOption.IO_SAVER_CLASS.key); } - + public String getIOSaverDirectory() { return appConfig.getOption(JTimerOption.IO_SAVER_DIRECTORY.key); } @@ -108,6 +108,16 @@ return appConfig.getOptionAsLong(JTimerOption.UI_IDLE_TIME.key); } + /** + * Return first day of week. + * Default to {@code -1} (no preference). + * + * @return first day of week in report + */ + public int getReportFirstDayOfWeek() { + return appConfig.getOptionAsInt(JTimerOption.UI_REPORT_FIRSTDAYOFWEEK.key); + } + public enum JTimerOption { CONFIG_FILENAME(ApplicationConfig.CONFIG_FILE_NAME, "jtimer.properties"), SERVICE_CLASS("jtimer.service.class", null), @@ -116,7 +126,8 @@ IO_SAVER_CLASS("jtimer.io.saver.class", "org.chorem.jtimer.io.GTimerIncrementalSaver"), IO_SAVER_DIRECTORY("jtimer.io.saver.directory", "${user.home}/.gtimer"), IO_SAVER_AUTOSAVEDELAY("jtimer.io.saver.autosavedelay", "300"), - UI_IDLE_TIME("jtimer.ui.idletime", "300"); + UI_IDLE_TIME("jtimer.ui.idletime", "300"), + UI_REPORT_FIRSTDAYOFWEEK("jtimer.ui.report.firstdayofweek", "-1"); protected String key; Modified: trunk/src/main/java/org/chorem/jtimer/ui/report/ReportView.java =================================================================== --- trunk/src/main/java/org/chorem/jtimer/ui/report/ReportView.java 2012-03-09 15:03:30 UTC (rev 2815) +++ trunk/src/main/java/org/chorem/jtimer/ui/report/ReportView.java 2012-03-09 15:31:15 UTC (rev 2816) @@ -5,7 +5,7 @@ * $Id$ * $HeadURL$ * %% - * Copyright (C) 2008 - 2011 CodeLutin, Chatellier Eric + * Copyright (C) 2008 - 2012 CodeLutin, Chatellier Eric * %% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as @@ -40,6 +40,7 @@ import java.util.ArrayList; import java.util.Calendar; import java.util.Collection; +import java.util.Date; import java.util.HashSet; import java.util.List; import java.util.Set; @@ -60,6 +61,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.chorem.jtimer.JTimer; import org.chorem.jtimer.data.TimerCore; import org.chorem.jtimer.entities.TimerProject; import org.chorem.jtimer.entities.TimerTask; @@ -159,7 +161,7 @@ * Get main view component. * * TODO use less complicated UI (no gbl) - * @return + * @return main component */ protected JComponent getMainComponent() { @@ -167,13 +169,21 @@ // init dates Calendar calendarBegin = Calendar.getInstance(); - calendarBegin.set(Calendar.DAY_OF_WEEK, calendarBegin - .getFirstDayOfWeek()); + int firstDayOfWeek = JTimer.config.getReportFirstDayOfWeek(); + if (firstDayOfWeek < 0 || firstDayOfWeek > 6) { + firstDayOfWeek = calendarBegin.getFirstDayOfWeek(); + } + calendarBegin.set(Calendar.DAY_OF_WEEK, firstDayOfWeek); calendarBegin.set(Calendar.HOUR, 0); calendarBegin.set(Calendar.MINUTE, 0); calendarBegin.set(Calendar.SECOND, 0); calendarBegin.set(Calendar.MILLISECOND, 0); + // calendar must be in current week by default + if (calendarBegin.getTime().after(new Date())) { + calendarBegin.add(Calendar.WEEK_OF_YEAR, -1); + } + // get end of week // take calendarBegin and add a week time Calendar calendarEnd = (Calendar) calendarBegin.clone();
participants (1)
-
echatellier@users.chorem.org