Author: echatellier Date: 2012-03-15 11:41:39 +0100 (Thu, 15 Mar 2012) New Revision: 2825 Url: http://chorem.org/repositories/revision/jtimer/2825 Log: #281: Ability to save report options #486: Add close to systray option #488: Remember show closed option Added: trunk/src/main/resources/org/chorem/jtimer/ui/report/resources/applications-system.png trunk/src/main/resources/org/chorem/jtimer/ui/report/resources/mail-forward.png Modified: trunk/src/main/java/org/chorem/jtimer/JTimer.java trunk/src/main/java/org/chorem/jtimer/JTimerConfig.java trunk/src/main/java/org/chorem/jtimer/ui/report/ReportView.java trunk/src/main/java/org/chorem/jtimer/ui/treetable/ProjectsAndTasksTable.java trunk/src/main/resources/org/chorem/jtimer/resources/JTimer.properties trunk/src/main/resources/org/chorem/jtimer/resources/JTimer_fr.properties trunk/src/main/resources/org/chorem/jtimer/ui/report/resources/ReportView.properties Modified: trunk/src/main/java/org/chorem/jtimer/JTimer.java =================================================================== --- trunk/src/main/java/org/chorem/jtimer/JTimer.java 2012-03-15 09:56:38 UTC (rev 2824) +++ trunk/src/main/java/org/chorem/jtimer/JTimer.java 2012-03-15 10:41:39 UTC (rev 2825) @@ -38,16 +38,19 @@ import java.util.List; import java.util.Timer; +import javax.swing.ButtonGroup; import javax.swing.InputMap; import javax.swing.JButton; import javax.swing.JCheckBoxMenuItem; import javax.swing.JComponent; +import javax.swing.JFrame; import javax.swing.JMenu; import javax.swing.JMenuBar; import javax.swing.JMenuItem; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JPopupMenu; +import javax.swing.JRadioButtonMenuItem; import javax.swing.JScrollPane; import javax.swing.JSeparator; import javax.swing.JToolBar; @@ -75,6 +78,7 @@ import org.chorem.jtimer.ui.tasks.RefreshTreeTask; import org.chorem.jtimer.ui.tasks.RunTaskJob; import org.chorem.jtimer.ui.treetable.ProjectsAndTasksTable; +import org.chorem.jtimer.ui.widget.WindowProperty2; import org.chorem.jtimer.ui.ws.SwingConnectionInformationHandler; import org.chorem.jtimer.ws.ConnectionDataHandler; import org.chorem.jtimer.ws.ProjectManagement; @@ -175,6 +179,9 @@ ApplicationContext ctxt = getContext(); resourceMap = ctxt.getResourceMap(); + // fix start in iconified mode + ctxt.getSessionStorage().putProperty(JFrame.class, new WindowProperty2()); + // init timercore core = new TimerCore(); @@ -289,6 +296,7 @@ projectsAndTasksTable.setName("projectslist"); projectsAndTasksTable.addTreeSelectionListener(this); projectsAndTasksTable.addMouseListener(this); + projectsAndTasksTable.setShowClosed(config.isShowClosed()); // since merge option, selection can be multiple projectsAndTasksTable @@ -360,8 +368,8 @@ String[] reportMenuActionNames = { "makeReport" }; menuBar.add(createMenu("reportMenu", reportMenuActionNames)); - String[] optionMenuActionNames = { "isShowClosed" }; - menuBar.add(createMenu("optionMenu", optionMenuActionNames)); + JMenu optionmMenu = createOptionMenu(); + menuBar.add(optionmMenu); String[] helpMenuActionNames = { "about" }; menuBar.add(createMenu("helpMenu", helpMenuActionNames)); @@ -370,6 +378,49 @@ } /** + * Create option dynamic menu. + * + * @return option menu + */ + protected JMenu createOptionMenu() { + JMenu menu = new JMenu(); + menu.setName("optionMenu"); + + // show closed + JMenuItem showClosedItem = new JCheckBoxMenuItem(); + showClosedItem.setAction(getAction("isShowClosed")); + showClosedItem.setSelected(config.isShowClosed()); + showClosedItem.setIcon(null); + menu.add(showClosedItem); + + // close to systray + JMenuItem closeToSysItem = new JCheckBoxMenuItem(); + closeToSysItem.setAction(getAction("isCloseToSystray")); + closeToSysItem.setSelected(config.isCloseToSystray()); + closeToSysItem.setIcon(null); + menu.add(closeToSysItem); + + // report first day of week + JMenu reportFDoW = new JMenu(); + reportFDoW.setName("optionReportFirstDayMenu"); + Calendar calendar = Calendar.getInstance(); + ButtonGroup bg = new ButtonGroup(); + // affiche la liste des jours dans l'ordre de la locale utilisateur + for (int day = calendar.getFirstDayOfWeek() ; day < calendar.getFirstDayOfWeek() + 7 ; day++) { + int realDay = (day - 1) % 7 + 1; + JRadioButtonMenuItem fdowItem = new JRadioButtonMenuItem(); + fdowItem.setAction(getAction("isReportFirstDayOfWeek" + realDay)); + fdowItem.setSelected(realDay == JTimer.config.getReportFirstDayOfWeek()); + fdowItem.setIcon(null); + reportFDoW.add(fdowItem); + bg.add(fdowItem); + } + menu.add(reportFDoW); + + return menu; + } + + /** * Create single menu. * * @param menuName menu name @@ -786,17 +837,87 @@ } /** - * Increment task time. + * Change show closed option. * * @param event action event */ @Action public void isShowClosed(ActionEvent event) { JCheckBoxMenuItem source = (JCheckBoxMenuItem) event.getSource(); - projectsAndTasksTable.setShowClosed(source.isSelected()); + boolean showClosed = source.isSelected(); + projectsAndTasksTable.setShowClosed(showClosed); + config.setShowClosed(showClosed); } /** + * Change close to systray option. + * + * @param event action event + */ + @Action + public void isCloseToSystray(ActionEvent event) { + JCheckBoxMenuItem source = (JCheckBoxMenuItem) event.getSource(); + boolean closeToSystray = source.isSelected(); + config.setCloseToSystray(closeToSystray); + } + + /** + * Change report first day of week. + */ + @Action + public void isReportFirstDayOfWeek1() { + config.setReportFirstDayOfWeek(1); + } + + /** + * Change report first day of week. + */ + @Action + public void isReportFirstDayOfWeek2() { + config.setReportFirstDayOfWeek(2); + } + + /** + * Change report first day of week. + */ + @Action + public void isReportFirstDayOfWeek3() { + config.setReportFirstDayOfWeek(3); + } + + /** + * Change report first day of week. + */ + @Action + public void isReportFirstDayOfWeek4() { + config.setReportFirstDayOfWeek(4); + } + + /** + * Change report first day of week. + */ + @Action + public void isReportFirstDayOfWeek5() { + config.setReportFirstDayOfWeek(5); + } + + /** + * Change report first day of week. + */ + @Action + public void isReportFirstDayOfWeek6() { + config.setReportFirstDayOfWeek(6); + } + + /** + * Change report first day of week. + */ + @Action + public void isReportFirstDayOfWeek7() { + config.setReportFirstDayOfWeek(7); + } + + /** * Increment task time. */ @Action(enabledProperty = "selectedSingleTask") Modified: trunk/src/main/java/org/chorem/jtimer/JTimerConfig.java =================================================================== --- trunk/src/main/java/org/chorem/jtimer/JTimerConfig.java 2012-03-15 09:56:38 UTC (rev 2824) +++ trunk/src/main/java/org/chorem/jtimer/JTimerConfig.java 2012-03-15 10:41:39 UTC (rev 2825) @@ -109,6 +109,44 @@ } /** + * Show closed project on main ui tree. + * + * @return show closed project + */ + public boolean isShowClosed() { + return appConfig.getOptionAsBoolean(JTimerOption.UI_SHOW_CLOSED.key); + } + + /** + * Set show closed option. + * + * @param showClosed show closed + */ + public void setShowClosed(boolean showClosed) { + appConfig.setOption(JTimerOption.UI_SHOW_CLOSED.key, String.valueOf(showClosed)); + appConfig.saveForUser(); + } + + /** + * Get close to systray option. + * + * @return close to systray + */ + public boolean isCloseToSystray() { + return appConfig.getOptionAsBoolean(JTimerOption.UI_CLOSE_TO_SYSTRAY.key); + } + + /** + * Set close to systray option + * + * @param closeToSystray close to systray + */ + public void setCloseToSystray(boolean closeToSystray) { + appConfig.setOption(JTimerOption.UI_CLOSE_TO_SYSTRAY.key, String.valueOf(closeToSystray)); + appConfig.saveForUser(); + } + + /** * Return first day of week. * Default to {@code -1} (no preference). * @@ -118,6 +156,16 @@ return appConfig.getOptionAsInt(JTimerOption.UI_REPORT_FIRSTDAYOFWEEK.key); } + /** + * Report first day of week. + * + * @param firstDayOfWeek first day of week + */ + public void setReportFirstDayOfWeek(int firstDayOfWeek) { + appConfig.setOption(JTimerOption.UI_REPORT_FIRSTDAYOFWEEK.key, String.valueOf(firstDayOfWeek)); + appConfig.saveForUser(); + } + public enum JTimerOption { CONFIG_FILENAME(ApplicationConfig.CONFIG_FILE_NAME, "jtimer.properties"), SERVICE_CLASS("jtimer.service.class", null), @@ -127,7 +175,9 @@ 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_REPORT_FIRSTDAYOFWEEK("jtimer.ui.report.firstdayofweek", "-1"); + UI_SHOW_CLOSED("jtimer.ui.showclosed", "false"), + UI_CLOSE_TO_SYSTRAY("jtimer.ui.closetosystray", "true"), + UI_REPORT_FIRSTDAYOFWEEK("jtimer.ui.report.firstdayofweek", "0"); 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-15 09:56:38 UTC (rev 2824) +++ trunk/src/main/java/org/chorem/jtimer/ui/report/ReportView.java 2012-03-15 10:41:39 UTC (rev 2825) @@ -54,6 +54,7 @@ import javax.swing.JPanel; import javax.swing.JRadioButton; import javax.swing.JScrollPane; +import javax.swing.JSplitPane; import javax.swing.JTextArea; import javax.swing.JTree; import javax.swing.event.DocumentEvent; @@ -162,7 +163,7 @@ */ protected JComponent getMainComponent() { - JPanel mainComponent = new JPanel(new GridBagLayout()); + JPanel configComponent = new JPanel(new GridBagLayout()); // panel for options JPanel panelOption = new JPanel(new GridBagLayout()); @@ -275,8 +276,16 @@ JScrollPane jspTable = new JScrollPane(projectsTree); panelProjects.add(jspTable, BorderLayout.CENTER); + configComponent.add(panelOption, new GridBagConstraints(0, 0, 1, 1, 0, 0, + GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, + new Insets(1, 1, 1, 1), 0, 0)); + + configComponent.add(panelProjects, new GridBagConstraints(0, 1, 1, 1, 1, + 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, + new Insets(1, 1, 1, 1), 0, 0)); + // panel for report text - JPanel panelReports = new JPanel(new BorderLayout()); + JPanel panelReports = new JPanel(new GridBagLayout()); panelReports.setBorder(BorderFactory.createTitledBorder(getResourceMap() .getString("reportContent"))); @@ -284,42 +293,34 @@ reportArea.setFont(new Font("Courier", Font.PLAIN, 12)); reportArea.getDocument().addDocumentListener(this); JScrollPane jspReport = new JScrollPane(reportArea); - panelReports.add(jspReport, BorderLayout.CENTER); - - mainComponent.add(panelOption, new GridBagConstraints(0, 0, 3, 1, 2, 0, - GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, + panelReports.add(jspReport, new GridBagConstraints(0, 0, 3, 1, 1, 1, + GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(1, 1, 1, 1), 0, 0)); - mainComponent.add(panelProjects, new GridBagConstraints(0, 1, 3, 1, 2, - 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, - new Insets(1, 1, 1, 1), 0, 0)); - // buttons JButton generateButton = new JButton(); generateButton.setAction(getContext().getActionMap(this).get( "generateReport")); - mainComponent.add(generateButton, new GridBagConstraints(0, 2, 1, 1, 1, + panelReports.add(generateButton, new GridBagConstraints(0, 1, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(1, 1, 1, 1), 0, 0)); JButton sendMailButton = new JButton(); sendMailButton.setAction(getContext().getActionMap(this) .get("sendMail")); - mainComponent.add(sendMailButton, new GridBagConstraints(1, 2, 1, 1, 1, + panelReports.add(sendMailButton, new GridBagConstraints(1, 1, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(1, 1, 1, 1), 0, 0)); JButton closeButton = new JButton(); closeButton.setAction(getContext().getActionMap(this).get("closeView")); - mainComponent.add(closeButton, new GridBagConstraints(2, 2, 1, 1, 1, 0, + panelReports.add(closeButton, new GridBagConstraints(2, 1, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(1, 1, 1, 1), 0, 0)); - - mainComponent.add(panelReports, new GridBagConstraints(3, 0, 1, 3, 8, - 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, - new Insets(1, 1, 1, 1), 250, 0)); - - return mainComponent; + + JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, configComponent, panelReports); + splitPane.setOneTouchExpandable(true); + return splitPane; } /** @@ -348,7 +349,7 @@ // init dates Calendar calendarBegin = Calendar.getInstance(); int firstDayOfWeek = JTimer.config.getReportFirstDayOfWeek(); - if (firstDayOfWeek < 0 || firstDayOfWeek > 6) { + if (firstDayOfWeek <= 0 || firstDayOfWeek > 7) { firstDayOfWeek = calendarBegin.getFirstDayOfWeek(); } calendarBegin.set(Calendar.DAY_OF_WEEK, firstDayOfWeek); Modified: trunk/src/main/java/org/chorem/jtimer/ui/treetable/ProjectsAndTasksTable.java =================================================================== --- trunk/src/main/java/org/chorem/jtimer/ui/treetable/ProjectsAndTasksTable.java 2012-03-15 09:56:38 UTC (rev 2824) +++ trunk/src/main/java/org/chorem/jtimer/ui/treetable/ProjectsAndTasksTable.java 2012-03-15 10:41:39 UTC (rev 2825) @@ -86,8 +86,7 @@ columnIdentifiers.add(resourceMap.getString("totalTimeColumnName")); // set model - treeTableModel = new ProjectsAndTasksModel(this, core, - columnIdentifiers); + treeTableModel = new ProjectsAndTasksModel(this, core, columnIdentifiers); // set renderer treeCellRenderer = new ProjectsAndTasksCellRenderer(core); Modified: trunk/src/main/resources/org/chorem/jtimer/resources/JTimer.properties =================================================================== --- trunk/src/main/resources/org/chorem/jtimer/resources/JTimer.properties 2012-03-15 09:56:38 UTC (rev 2824) +++ trunk/src/main/resources/org/chorem/jtimer/resources/JTimer.properties 2012-03-15 10:41:39 UTC (rev 2825) @@ -119,6 +119,17 @@ isShowClosed.Action.text = Show closed isShowClosed.Action.shortDescription = Show closed task and project +isCloseToSystray.Action.text = Close to systray +isCloseToSystray.Action.shortDescription = Reduce application to system tray instead of closing + +isReportFirstDayOfWeek1.Action.text = Sunday +isReportFirstDayOfWeek2.Action.text = Monday +isReportFirstDayOfWeek3.Action.text = Tuesday +isReportFirstDayOfWeek4.Action.text = Wednesday +isReportFirstDayOfWeek5.Action.text = Thursday +isReportFirstDayOfWeek6.Action.text = Friday +isReportFirstDayOfWeek7.Action.text = Saturday + about.Action.text = About... about.Action.shortDescription = About ${Application.title} @@ -136,6 +147,7 @@ taskMenu.text = Task reportMenu.text = Report optionMenu.text = Options +optionReportFirstDayMenu.text = Report - First day of week helpMenu.text = Help # Input @@ -156,11 +168,11 @@ input.addAnnotationTitle=Add annotation input.addAnnotationMessage=Annotation for task "%s" : -#�Error +# Error action.invalidActionTitle=Can't do action action.missingErrorMessage=Error message is missing (%s) -#�listeners errors +# listeners errors vetoable.common.duplicated.project.name=A project already exists with that name at this level ! vetoable.common.duplicated.task.name=A task already exists with that name at this level ! vetoable.common.merge.invalid.types=Can't merge project and task ! @@ -169,6 +181,6 @@ vetoable.saver.invalid.task.characters=Task name contains invalid characters ! vetoable.ws.chorem.cant.modify.synchronized.project=Can't do this action on a synchronized project ! -#�Start fail i18n +# Start fail i18n startFail.title=Error startFail.message=${Application.title} fail to init.\nCheck that ${Application.title} is not already launched. Modified: trunk/src/main/resources/org/chorem/jtimer/resources/JTimer_fr.properties =================================================================== --- trunk/src/main/resources/org/chorem/jtimer/resources/JTimer_fr.properties 2012-03-15 09:56:38 UTC (rev 2824) +++ trunk/src/main/resources/org/chorem/jtimer/resources/JTimer_fr.properties 2012-03-15 10:41:39 UTC (rev 2825) @@ -90,7 +90,7 @@ decrement30Task.Action.shortDescription = Retire 30 minutes au temps de la t\u00E2che setToZero.Action.text = Remettre \u00E0 Zero -setToZero.Action.shortDecription = Remet le temps de la t\u00E2che \u00E0 zero +setToZero.Action.shortDecription = Remet le temps de la t\u00E2che \u00E0 z\u00E9ro mergeTasks.Action.text = Fusionner mergeTasks.Action.shortDecription = Fusionner les t\u00E2ches @@ -98,9 +98,20 @@ makeReport.Action.text = Rapport... makeReport.Action.shortDescription = Cr\u00E9er un rapport -isShowClosed.Action.text = Afficher les cach\u00E9es -isShowClosed.Action.shortDescription = Affiche les projets et t\u00E2ches ferm\u00E9es +isShowClosed.Action.text = Afficher les cach\u00E9s +isShowClosed.Action.shortDescription = Affiche les projets et t\u00E2ches ferm\u00E9s +isCloseToSystray.Action.text = Fermer vers le systray +isCloseToSystray.Action.shortDescription = R\u00E9duit l'application dans le systray au lieu de la fermer + +isReportFirstDayOfWeek1.Action.text = Dimanche +isReportFirstDayOfWeek2.Action.text = Lundi +isReportFirstDayOfWeek3.Action.text = Mardi +isReportFirstDayOfWeek4.Action.text = Mercredi +isReportFirstDayOfWeek5.Action.text = Jeudi +isReportFirstDayOfWeek6.Action.text = Vendredi +isReportFirstDayOfWeek7.Action.text = Samedi + about.Action.text = \u00C0 propos... about.Action.shortDescription = About ${Application.title} @@ -115,6 +126,7 @@ taskMenu.text = T\u00E2che reportMenu.text = Rapport optionMenu.text = Options +optionReportFirstDayMenu.text = Rapport - Premier jour de la semaine helpMenu.text = Aide # Input @@ -135,11 +147,11 @@ input.addAnnotationTitle=Ajouter une annotation input.addAnnotationMessage=Annotation pour la t\u00E2che "%s" : -#�Error +# Error action.invalidActionTitle=Impossible d'effectuer cette action action.missingErrorMessage=Message d'erreur manquant (%s) -#�listeners errors +# listeners errors vetoable.common.duplicated.project.name=Un projet avec ce nom existe d\u00E9j\u00E0 \u00E0 ce niveau ! vetoable.common.duplicated.task.name=Une t\u00E2che avec ce nom existe d\u00E9j\u00E0 \u00E0 ce niveau ! vetoable.common.merge.invalid.types=Impossible de fusionner un projet et une t\u00E2che ! @@ -148,6 +160,6 @@ vetoable.saver.invalid.characters=Le nom contient des caract\u00E8res invalide ! vetoable.ws.chorem.cant.modify.synchronized.project=Impossible d'effectuer cette action sur un projet synchronis\u00E9 ! -#�Start fail i18n +# Start fail i18n startFail.title=Erreur startFail.message=${Application.title} n'a pas r\u00E9ussi \u00E0 s'initiliser.\nV\u00E9rifiez que ${Application.title} n'est pas d\u00E9j\u00E0 lanc\u00E9. \ No newline at end of file Modified: trunk/src/main/resources/org/chorem/jtimer/ui/report/resources/ReportView.properties =================================================================== --- trunk/src/main/resources/org/chorem/jtimer/ui/report/resources/ReportView.properties 2012-03-15 09:56:38 UTC (rev 2824) +++ trunk/src/main/resources/org/chorem/jtimer/ui/report/resources/ReportView.properties 2012-03-15 10:41:39 UTC (rev 2825) @@ -47,9 +47,11 @@ showHiddenProjects.Action.shortDescription = Show hidden projects generateReport.Action.text = Generate +generateReport.Action.icon = applications-system.png generateReport.Action.shortDescription = Generate report sendMail.Action.text = Send by mail +sendMail.Action.icon = mail-forward.png sendMail.Action.shortDescription = Send report by mail closeView.Action.text = Close Added: trunk/src/main/resources/org/chorem/jtimer/ui/report/resources/applications-system.png =================================================================== (Binary files differ) Property changes on: trunk/src/main/resources/org/chorem/jtimer/ui/report/resources/applications-system.png ___________________________________________________________________ Added: svn:mime-type + image/png Added: trunk/src/main/resources/org/chorem/jtimer/ui/report/resources/mail-forward.png =================================================================== (Binary files differ) Property changes on: trunk/src/main/resources/org/chorem/jtimer/ui/report/resources/mail-forward.png ___________________________________________________________________ Added: svn:mime-type + image/png
participants (1)
-
echatellier@users.chorem.org