branch develop updated (537de1f -> 2830943)
This is an automated email from the git hooks/post-receive script. New change to branch develop in repository jtimer. See https://gitlab.nuiton.org/chorem/jtimer.git from 537de1f fixes #1347: Enable "Enter" key support on main popups new d72f1f6 Update jna new 66a5144 fixes #1348: After creating a task, set the focus on this new task new 2830943 fixes #1319: Migrate gtimer directory to new jtimer directories structure 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 2830943485813611e3fa0f189ec7cccd93d07a4f Author: Eric Chatellier <chatellier@codelutin.com> Date: Wed Mar 23 10:55:42 2016 +0100 fixes #1319: Migrate gtimer directory to new jtimer directories structure commit 66a5144997928c9f0dd88e782f78d8cb3d761b34 Author: Eric Chatellier <chatellier@codelutin.com> Date: Tue Mar 22 17:45:53 2016 +0100 fixes #1348: After creating a task, set the focus on this new task commit d72f1f660f55ea674c01da10243b9ea58c7d2a11 Author: Eric Chatellier <chatellier@codelutin.com> Date: Tue Mar 22 17:44:52 2016 +0100 Update jna Summary of changes: pom.xml | 12 +--- src/main/java/org/chorem/jtimer/JTimer.java | 30 +++++++--- src/main/java/org/chorem/jtimer/JTimerConfig.java | 60 ++++++++++++++++++-- src/main/java/org/chorem/jtimer/JTimerFactory.java | 5 +- .../java/org/chorem/jtimer/data/TimerCore.java | 53 +++++++++++++++++- .../chorem/jtimer/io/GTimerIncrementalSaver.java | 65 ++++++++-------------- src/main/java/org/chorem/jtimer/io/Saver.java | 7 --- .../java/org/chorem/jtimer/ui/NewTaskView.java | 3 +- .../jtimer/ui/treetable/ProjectsAndTasksTable.java | 41 +++++++++++--- src/main/resources/log4j2.xml | 2 +- src/site/rst/configuration.rst | 4 +- src/site/rst/index.rst.vm | 2 +- .../java/org/chorem/jtimer/AbstractJTimerTest.java | 15 ++--- .../jtimer/io/GTimerIncrementalSaverTest.java | 8 +-- src/test/resources/jtimertest.properties | 5 +- 15 files changed, 206 insertions(+), 106 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 develop in repository jtimer. See https://gitlab.nuiton.org/chorem/jtimer.git commit d72f1f660f55ea674c01da10243b9ea58c7d2a11 Author: Eric Chatellier <chatellier@codelutin.com> Date: Tue Mar 22 17:44:52 2016 +0100 Update jna --- pom.xml | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/pom.xml b/pom.xml index 0418836..52151f6 100644 --- a/pom.xml +++ b/pom.xml @@ -164,7 +164,7 @@ <dependency> <groupId>org.nuiton.jrst</groupId> <artifactId>doxia-module-jrst</artifactId> - <version>${jrstPluginVersion}</version> + <version>2.2</version> </dependency> </dependencies> </plugin> @@ -172,6 +172,7 @@ <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>webstart-maven-plugin</artifactId> + <version>1.0-beta-7</version> <configuration> <codebase>http://jtimer.chorem.org/v/${siteDeployClassifier}/jnlp</codebase> <libPath>lib</libPath> @@ -209,13 +210,6 @@ <enabled>false</enabled> </pack200> </configuration> - <dependencies> - <dependency> - <groupId>org.codehaus.mojo</groupId> - <artifactId>keytool-api-1.7</artifactId> - <version>1.5</version> - </dependency> - </dependencies> </plugin> </plugins> </pluginManagement> @@ -297,7 +291,7 @@ <dependency> <groupId>net.java.dev.jna</groupId> <artifactId>jna</artifactId> - <version>4.2.1</version> + <version>4.2.2</version> <scope>compile</scope> </dependency> <dependency> -- 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 develop in repository jtimer. See https://gitlab.nuiton.org/chorem/jtimer.git commit 66a5144997928c9f0dd88e782f78d8cb3d761b34 Author: Eric Chatellier <chatellier@codelutin.com> Date: Tue Mar 22 17:45:53 2016 +0100 fixes #1348: After creating a task, set the focus on this new task --- src/main/java/org/chorem/jtimer/JTimer.java | 17 ++++++--- .../java/org/chorem/jtimer/ui/NewTaskView.java | 3 +- .../jtimer/ui/treetable/ProjectsAndTasksTable.java | 41 +++++++++++++++++----- 3 files changed, 46 insertions(+), 15 deletions(-) diff --git a/src/main/java/org/chorem/jtimer/JTimer.java b/src/main/java/org/chorem/jtimer/JTimer.java index c318f94..9eef46e 100644 --- a/src/main/java/org/chorem/jtimer/JTimer.java +++ b/src/main/java/org/chorem/jtimer/JTimer.java @@ -280,8 +280,7 @@ public class JTimer extends SingleFrameApplication implements // tree middle (center-top) ProjectsAndTasksTable projectTreeTable = createTreeTable(); - JScrollPane scrollPaneProjectTreeTable = new JScrollPane( - projectTreeTable); + JScrollPane scrollPaneProjectTreeTable = new JScrollPane(projectTreeTable); panel.add(scrollPaneProjectTreeTable, BorderLayout.CENTER); // status bar bottom @@ -313,8 +312,7 @@ public class JTimer extends SingleFrameApplication implements projectsAndTasksTable.setShowClosed(config.isShowClosed()); // since merge option, selection can be multiple - projectsAndTasksTable - .setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); + projectsAndTasksTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); // remove F2 KeyStroke from table KeyStroke keyToRemove = KeyStroke.getKeyStroke(KeyEvent.VK_F2, 0); @@ -323,7 +321,7 @@ public class JTimer extends SingleFrameApplication implements imap.remove(keyToRemove); imap = imap.getParent(); } - + // default lines are non visible projectsAndTasksTable.putClientProperty("JTree.lineStyle", "Angled"); @@ -645,6 +643,15 @@ public class JTimer extends SingleFrameApplication implements } /** + * Auto select task after creation. + * + * @param task task to select + */ + public void selectTask(TimerTask task) { + projectsAndTasksTable.setSelectedTask(task); + } + + /** * Edit task. * * Enabled when a task is selected diff --git a/src/main/java/org/chorem/jtimer/ui/NewTaskView.java b/src/main/java/org/chorem/jtimer/ui/NewTaskView.java index 29c9aba..9b6f9c8 100644 --- a/src/main/java/org/chorem/jtimer/ui/NewTaskView.java +++ b/src/main/java/org/chorem/jtimer/ui/NewTaskView.java @@ -24,12 +24,10 @@ package org.chorem.jtimer.ui; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.Insets; -import java.awt.event.ActionEvent; import java.util.Date; import java.util.Map; import java.util.Set; -import javax.swing.AbstractAction; import javax.swing.ActionMap; import javax.swing.DefaultComboBoxModel; import javax.swing.ImageIcon; @@ -156,6 +154,7 @@ public class NewTaskView extends DialogView { try { core.getData().addTask(selectedTask, t, taskTemplate); + parent.selectTask(t); } catch (DataViolationException e) { parent.displayErrorMessage(e.getExceptionKey()); } diff --git a/src/main/java/org/chorem/jtimer/ui/treetable/ProjectsAndTasksTable.java b/src/main/java/org/chorem/jtimer/ui/treetable/ProjectsAndTasksTable.java index fac743b..b087b51 100644 --- a/src/main/java/org/chorem/jtimer/ui/treetable/ProjectsAndTasksTable.java +++ b/src/main/java/org/chorem/jtimer/ui/treetable/ProjectsAndTasksTable.java @@ -2,7 +2,7 @@ * #%L * jTimer * %% - * Copyright (C) 2007 - 2012 CodeLutin, Chatellier Eric, Chemit Tony + * Copyright (C) 2007 - 2016 CodeLutin, Chatellier Eric, Chemit Tony * %% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as @@ -26,6 +26,8 @@ import java.awt.Color; import java.awt.event.ActionEvent; import java.awt.event.KeyEvent; import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; import java.util.List; import javax.swing.AbstractAction; @@ -78,12 +80,10 @@ public class ProjectsAndTasksTable extends JXTreeTable { // start with init i18n of table column name ApplicationContext ctxt = application.getContext(); ResourceManager mgr = ctxt.getResourceManager(); - ResourceMap resourceMap = mgr - .getResourceMap(ProjectsAndTasksTable.class); + ResourceMap resourceMap = mgr.getResourceMap(ProjectsAndTasksTable.class); // init list List<String> columnIdentifiers = new ArrayList<>(); - columnIdentifiers.add(resourceMap - .getString("projectsAndTaskColumnName")); + columnIdentifiers.add(resourceMap.getString("projectsAndTaskColumnName")); columnIdentifiers.add(resourceMap.getString("todayTimeColumnName")); columnIdentifiers.add(resourceMap.getString("totalTimeColumnName")); @@ -107,7 +107,7 @@ public class ProjectsAndTasksTable extends JXTreeTable { setDragEnabled(true); setTransferHandler(new TimerTaskTransferHandler(application, core.getData())); - { // add action to collapse (left arrow) selected node + { // add action to collapse (left arrow) selected node Action action = new AbstractAction("collapseSelectedNode") { private static final long serialVersionUID = 1L; @@ -125,7 +125,7 @@ public class ProjectsAndTasksTable extends JXTreeTable { action.getValue(Action.NAME)); getActionMap().put(action.getValue(Action.NAME), action); } - { // add action to expand (right arrow) selected node + { // add action to expand (right arrow) selected node Action action = new AbstractAction("expandSelectedNode") { private static final long serialVersionUID = 1L; @@ -137,7 +137,7 @@ public class ProjectsAndTasksTable extends JXTreeTable { } } }; - + getInputMap(WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put( KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, 0), action.getValue(Action.NAME)); @@ -252,4 +252,29 @@ public class ProjectsAndTasksTable extends JXTreeTable { return results; } + + /** + * Set selected task in tree. + * + * @param task task + */ + public void setSelectedTask(TimerTask task) { + // compute task tree path + List<TimerTask> components = new ArrayList<>(); + TimerTask current = task; + while (current != null) { + components.add(current); + current = current.getParent(); + } + + // add model root + components.add((TimerTask)treeTableModel.getRoot()); + + // select tree path in reverse order (from root to leaf) + Collections.reverse(components); + System.out.println("path " + components); + TreePath path = new TreePath(components.toArray()); + int row = getRowForPath(path); + getSelectionModel().setSelectionInterval(row, row); + } } -- 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 develop in repository jtimer. See https://gitlab.nuiton.org/chorem/jtimer.git commit 2830943485813611e3fa0f189ec7cccd93d07a4f Author: Eric Chatellier <chatellier@codelutin.com> Date: Wed Mar 23 10:55:42 2016 +0100 fixes #1319: Migrate gtimer directory to new jtimer directories structure --- src/main/java/org/chorem/jtimer/JTimer.java | 13 ++++- src/main/java/org/chorem/jtimer/JTimerConfig.java | 60 ++++++++++++++++++-- src/main/java/org/chorem/jtimer/JTimerFactory.java | 5 +- .../java/org/chorem/jtimer/data/TimerCore.java | 53 +++++++++++++++++- .../chorem/jtimer/io/GTimerIncrementalSaver.java | 65 ++++++++-------------- src/main/java/org/chorem/jtimer/io/Saver.java | 7 --- src/main/resources/log4j2.xml | 2 +- src/site/rst/configuration.rst | 4 +- src/site/rst/index.rst.vm | 2 +- .../java/org/chorem/jtimer/AbstractJTimerTest.java | 15 ++--- .../jtimer/io/GTimerIncrementalSaverTest.java | 8 +-- src/test/resources/jtimertest.properties | 5 +- 12 files changed, 157 insertions(+), 82 deletions(-) diff --git a/src/main/java/org/chorem/jtimer/JTimer.java b/src/main/java/org/chorem/jtimer/JTimer.java index 9eef46e..6d89e2f 100644 --- a/src/main/java/org/chorem/jtimer/JTimer.java +++ b/src/main/java/org/chorem/jtimer/JTimer.java @@ -224,6 +224,16 @@ public class JTimer extends SingleFrameApplication implements config = new JTimerConfig(); + migrateConfiguration(); + + // parse after file migration + config.parse(args); + } + + /** + * Migrate configuration between version 1.3 and 1.4. + */ + protected static void migrateConfiguration() { // add file migration for configuration file created before version 1.4 File homeDir = new File(System.getProperty("user.home"), ".jtimer"); File oldFile = new File(homeDir, "JTimer.properties"); @@ -240,9 +250,6 @@ public class JTimer extends SingleFrameApplication implements } } } - - // parse after file migration - config.parse(args); } /** diff --git a/src/main/java/org/chorem/jtimer/JTimerConfig.java b/src/main/java/org/chorem/jtimer/JTimerConfig.java index beb4fa5..76138db 100644 --- a/src/main/java/org/chorem/jtimer/JTimerConfig.java +++ b/src/main/java/org/chorem/jtimer/JTimerConfig.java @@ -22,6 +22,7 @@ package org.chorem.jtimer; +import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; @@ -108,12 +109,53 @@ public class JTimerConfig { } } + /** + * Get IO class implementation. + * + * @return IO save class + */ public Class<?> getIOSaverClass() { return appConfig.getOptionAsClass(JTimerOption.IO_SAVER_CLASS.key); } - public String getIOSaverDirectory() { - return appConfig.getOption(JTimerOption.IO_SAVER_DIRECTORY.key); + /** + * Get jtimer data directory. + * + * @since 1.5 + * @return jtimer 1.5 data directory + */ + public File getDataDirectory() { + return appConfig.getOptionAsFile(JTimerOption.DATA_DIRECTORY.key); + } + + /** + * Get jtimer backup directory. + * + * @since 1.5 + * @return jtimer 1.5 backup directory + */ + public File getBackupDirectory() { + return appConfig.getOptionAsFile(JTimerOption.BACKUP_DIRECTORY.key); + } + + /** + * Get gtimer data directory. + * + * @since 1.5 + * @return jtimer < 1.5 data directory + */ + public File getGtimerDataDirectory() { + return appConfig.getOptionAsFile(JTimerOption.GTIMER_DATA_DIRECTORY.key); + } + + /** + * Get gtimer backup directory. + * + * @since 1.5 + * @return jtimer < 1.5 backup directory + */ + public File getGtimerBackupDirectory() { + return appConfig.getOptionAsFile(JTimerOption.GTIMER_BACKUP_DIRECTORY.key); } /** @@ -161,7 +203,7 @@ public class JTimerConfig { public Map<String, Object> getTaskTemplates() { Map<String, Object> result = new TreeMap<>(); - String tplDirectory = appConfig.getOption(JTimerOption.UI_TEMPLATE_DIRECTORY.key); + String tplDirectory = appConfig.getOption(JTimerOption.TEMPLATE_DIRECTORY.key); Path tplDir = FileSystems.getDefault().getPath(tplDirectory); if (Files.exists(tplDir)) { @@ -225,10 +267,18 @@ public class JTimerConfig { protected enum JTimerOption { CONFIG_FILENAME(ApplicationConfig.CONFIG_FILE_NAME, "jtimer.properties"), + + HOME_DIRECTORY("jtimer.home.directory", "${user.home}/.jtimer"), + DATA_DIRECTORY("jtimer.data.directory", "${jtimer.home.directory}/data"), + BACKUP_DIRECTORY("jtimer.backup.directory", "${jtimer.home.directory}/backups"), + TEMPLATE_DIRECTORY("jtimer.templates.directory", "${jtimer.home.directory}/templates"), + IO_SAVER_CLASS("jtimer.io.saver.class", "org.chorem.jtimer.io.GTimerIncrementalSaver"), - IO_SAVER_DIRECTORY("jtimer.io.saver.directory", "${user.home}/.gtimer"), + // for migration purpose (keep old keys and values for migration) + GTIMER_DATA_DIRECTORY("jtimer.io.saver.directory", "${user.home}/.gtimer"), + GTIMER_BACKUP_DIRECTORY("jtimer.io.backup.directory", "${jtimer.io.saver.directory}/backups"), IO_SAVER_AUTOSAVEDELAY("jtimer.io.saver.autosavedelay", "300"), - UI_TEMPLATE_DIRECTORY("jtimer.ui.template.directory", "${jtimer.io.saver.directory}/templates"), + UI_IDLE_TIME("jtimer.ui.idletime", "300"), UI_SHOW_CLOSED("jtimer.ui.showclosed", "false"), UI_CLOSE_TO_SYSTRAY("jtimer.ui.closetosystray", "true"), diff --git a/src/main/java/org/chorem/jtimer/JTimerFactory.java b/src/main/java/org/chorem/jtimer/JTimerFactory.java index d723519..021a3eb 100644 --- a/src/main/java/org/chorem/jtimer/JTimerFactory.java +++ b/src/main/java/org/chorem/jtimer/JTimerFactory.java @@ -64,7 +64,7 @@ public class JTimerFactory { // log if (log.isInfoEnabled()) { log.info("Using saver class : " + saverClass); - log.info(" with saver home directory : " + JTimer.config.getIOSaverDirectory()); + log.info(" with saver home directory : " + JTimer.config.getDataDirectory()); log.info(" with auto save delay : " + JTimer.config.getIOSaverAutoSaveDelay()); } @@ -72,9 +72,6 @@ public class JTimerFactory { // get instance saver = (Saver) saverClass.newInstance(); - // init instance - saver.setSaveDirectory(JTimer.config.getIOSaverDirectory()); - // set delay to saver saver.setAutoSaveDelay(JTimer.config.getIOSaverAutoSaveDelay() * 1000); diff --git a/src/main/java/org/chorem/jtimer/data/TimerCore.java b/src/main/java/org/chorem/jtimer/data/TimerCore.java index 4d7e50c..2234d9b 100644 --- a/src/main/java/org/chorem/jtimer/data/TimerCore.java +++ b/src/main/java/org/chorem/jtimer/data/TimerCore.java @@ -22,13 +22,18 @@ package org.chorem.jtimer.data; +import java.io.File; +import java.io.FileFilter; +import java.io.IOException; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.List; +import org.apache.commons.io.FileUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.chorem.jtimer.JTimer; import org.chorem.jtimer.JTimerFactory; import org.chorem.jtimer.entities.TimerProject; import org.chorem.jtimer.io.DataLockingException; @@ -59,13 +64,22 @@ public class TimerCore { */ public TimerCore() { + // migrate if necessary + try { + migrateDirectoryStructure(); + } catch (IOException ex) { + if (log.isErrorEnabled()) { + log.error("Can't migrate directories", ex); + } + } + // init data data = new TimerDataManager(); // add commmon vetoable CommonVetoable commonVetoable = new CommonVetoable(data); data.addVetoableDataEventListener(commonVetoable); - + // init saver implementation saver = JTimerFactory.getFileSaver(); if (saver != null) { @@ -76,6 +90,43 @@ public class TimerCore { } /** + * Migrate file structure for jtimer 1.5 directories changes. + * + * @throws IOException + */ + protected void migrateDirectoryStructure() throws IOException { + File newDataDirectory = JTimer.config.getDataDirectory(); + File newBackupDirectory = JTimer.config.getBackupDirectory(); + File oldBackupDirectory = JTimer.config.getGtimerBackupDirectory(); + File oldDataDirectory = JTimer.config.getGtimerDataDirectory(); + + // migrate data + if (!newDataDirectory.isDirectory() && oldDataDirectory.isDirectory()) { + newDataDirectory.mkdirs(); + + if (log.isInfoEnabled()) { + log.info("Migrate data directory from " + oldDataDirectory + " to " + newDataDirectory); + } + + // exclude internal backup directory from recursion + FileUtils.copyDirectory(oldDataDirectory, newDataDirectory, (FileFilter)pathName -> { + return !pathName.equals(oldBackupDirectory); + }); + } + + // migrate backup + if (!newBackupDirectory.isDirectory() && oldBackupDirectory.isDirectory()) { + newBackupDirectory.mkdirs(); + + if (log.isInfoEnabled()) { + log.info("Migrate backup directory from " + oldBackupDirectory + " to " + newBackupDirectory); + } + + FileUtils.copyDirectory(oldBackupDirectory, newBackupDirectory); + } + } + + /** * Init Load and launch synchronization. * * @return true if init has gone successfully diff --git a/src/main/java/org/chorem/jtimer/io/GTimerIncrementalSaver.java b/src/main/java/org/chorem/jtimer/io/GTimerIncrementalSaver.java index 85bcaaf..d786d73 100644 --- a/src/main/java/org/chorem/jtimer/io/GTimerIncrementalSaver.java +++ b/src/main/java/org/chorem/jtimer/io/GTimerIncrementalSaver.java @@ -37,7 +37,6 @@ import java.nio.channels.FileChannel; import java.nio.channels.FileLock; import java.nio.file.DirectoryIteratorException; import java.nio.file.DirectoryStream; -import java.nio.file.FileSystems; import java.nio.file.Files; import java.nio.file.Path; import java.text.DateFormat; @@ -64,6 +63,7 @@ import java.util.zip.ZipOutputStream; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.chorem.jtimer.JTimer; import org.chorem.jtimer.data.DataEventListener; import org.chorem.jtimer.data.DataViolationException; import org.chorem.jtimer.entities.TimerAlert; @@ -121,14 +121,10 @@ public class GTimerIncrementalSaver extends AbstractSaver implements Saver, /** Lock filename. */ protected static final String LOCK_FILE_NAME = ".lock"; - /** Backup directory name. */ - protected static final String BACKUP_DIRECTORY = "backups"; - /** - * Save directory. Init with $user.home/.gtimer + * Save directory. Init with $user.home/.jtimer/data */ - protected String saveDirectory = System.getProperty("user.home") - + File.separator + ".gtimer"; + protected File dataSaveDirectory; /** Resource used by lock. */ protected FileLock lock; @@ -155,6 +151,8 @@ public class GTimerIncrementalSaver extends AbstractSaver implements Saver, */ public GTimerIncrementalSaver() { + dataSaveDirectory = JTimer.config.getDataDirectory(); + // make implementation synchronized runningTasks = Collections.synchronizedCollection(new ArrayList<>()); @@ -162,19 +160,6 @@ public class GTimerIncrementalSaver extends AbstractSaver implements Saver, } /* - * @see org.chorem.jtimer.io.Saver#setSaveDirectory(java.lang.String) - */ - @Override - public void setSaveDirectory(String directory) { - - if (directory == null) { - throw new IllegalArgumentException("Directory is null"); - } - - saveDirectory = directory; - } - - /* * @see org.chorem.jtimer.io.Saver#setAutoSaveDelay(long) */ @Override @@ -191,9 +176,8 @@ public class GTimerIncrementalSaver extends AbstractSaver implements Saver, */ protected void checkSaveDirectory() { // creer le dossier s'il n'existe pas (pour le lock) - File gTimerFileDir = new File(saveDirectory); - if (!gTimerFileDir.exists()) { - gTimerFileDir.mkdirs(); + if (!dataSaveDirectory.exists()) { + dataSaveDirectory.mkdirs(); } } @@ -208,7 +192,7 @@ public class GTimerIncrementalSaver extends AbstractSaver implements Saver, checkSaveDirectory(); // try to get lock - raf = new RandomAccessFile(saveDirectory + File.separator + raf = new RandomAccessFile(dataSaveDirectory + File.separator + LOCK_FILE_NAME, "rw"); channel = raf.getChannel(); @@ -299,13 +283,11 @@ public class GTimerIncrementalSaver extends AbstractSaver implements Saver, // pour pouvoir fair l'association // donc deux boucles - File gTimerFileDir = new File(saveDirectory); - // loop 1 , reading projects // project file "0.project" Pattern pPatronNommage = Pattern.compile("^(\\d+)\\." + GTIMER_PROJECT_EXTENSION + "$"); - for (File f : gTimerFileDir.listFiles()) { + for (File f : dataSaveDirectory.listFiles()) { if (f.isFile() && f.canRead()) { Matcher m = pPatronNommage.matcher(f.getName()); if (m.find()) { @@ -358,7 +340,7 @@ public class GTimerIncrementalSaver extends AbstractSaver implements Saver, }); // now process each file - for (File f : gTimerFileDir.listFiles()) { + for (File f : dataSaveDirectory.listFiles()) { if (f.isFile() && f.canRead()) { Matcher m = pPatronNommage.matcher(f.getName()); if (m.find()) { @@ -580,7 +562,7 @@ public class GTimerIncrementalSaver extends AbstractSaver implements Saver, protected void parseAnnotations(TimerTask task) throws IOException { int taskNumber = task.getNumber(); - File annotationsTaskFile = new File(saveDirectory + File.separator + File annotationsTaskFile = new File(dataSaveDirectory + File.separator + taskNumber + "." + GTIMER_ANNOTATION_EXTENSION); if (annotationsTaskFile.exists()) { @@ -628,7 +610,7 @@ public class GTimerIncrementalSaver extends AbstractSaver implements Saver, protected void parseAlerts(TimerTask task) throws IOException { int taskNumber = task.getNumber(); - File alertTaskFile = new File(saveDirectory + File.separator + File alertTaskFile = new File(dataSaveDirectory + File.separator + taskNumber + "." + GTIMER_ALERT_EXTENSION); if (alertTaskFile.exists()) { @@ -774,7 +756,7 @@ public class GTimerIncrementalSaver extends AbstractSaver implements Saver, String nowString = dateFormat.format(new Date()); // backup directory - String backupDir = saveDirectory + File.separator + BACKUP_DIRECTORY; + String backupDir = JTimer.config.getBackupDirectory().getAbsolutePath(); // build file name String zipFileName = backupDir + File.separator + "backup-" + nowString @@ -798,8 +780,7 @@ public class GTimerIncrementalSaver extends AbstractSaver implements Saver, byte[] buffer = new byte[1024]; // add in this archive only gtimer files - File gtimerdir = new File(saveDirectory); - File[] filesInIt = gtimerdir.listFiles(); + File[] filesInIt = dataSaveDirectory.listFiles(); for (File fileInIt : filesInIt) { String filename = fileInIt.getName(); @@ -842,7 +823,7 @@ public class GTimerIncrementalSaver extends AbstractSaver implements Saver, Pattern pattern = Pattern.compile("backup-(\\d{14})\\.zip"); // collect each file in backup dir - Path backupDir = FileSystems.getDefault().getPath(saveDirectory, BACKUP_DIRECTORY); + Path backupDir = JTimer.config.getBackupDirectory().toPath(); try (DirectoryStream<Path> stream = Files.newDirectoryStream(backupDir, "backup-*.zip")) { for (Path file : stream) { String name = file.getFileName().toString(); @@ -895,7 +876,7 @@ public class GTimerIncrementalSaver extends AbstractSaver implements Saver, } // build full file name - String filename = saveDirectory + File.separator + project.getNumber() + String filename = dataSaveDirectory + File.separator + project.getNumber() + "." + GTIMER_PROJECT_EXTENSION; if (log.isDebugEnabled()) { @@ -992,7 +973,7 @@ public class GTimerIncrementalSaver extends AbstractSaver implements Saver, } // build full file name - String filename = saveDirectory + File.separator + task.getNumber() + String filename = dataSaveDirectory + File.separator + task.getNumber() + "." + GTIMER_TASK_EXTENSION; if (log.isDebugEnabled()) { @@ -1060,7 +1041,7 @@ public class GTimerIncrementalSaver extends AbstractSaver implements Saver, int taskNumber = task.getNumber(); - File annotationTaskFile = new File(saveDirectory + File.separator + File annotationTaskFile = new File(dataSaveDirectory + File.separator + taskNumber + "." + GTIMER_ANNOTATION_EXTENSION); if (task.getAllDaysAnnotations() != null @@ -1108,7 +1089,7 @@ public class GTimerIncrementalSaver extends AbstractSaver implements Saver, int taskNumber = task.getNumber(); - File alertTaskFile = new File(saveDirectory + File.separator + File alertTaskFile = new File(dataSaveDirectory + File.separator + taskNumber + "." + GTIMER_ALERT_EXTENSION); if (task.getAlerts() != null && !task.getAlerts().isEmpty()) { @@ -1217,7 +1198,7 @@ public class GTimerIncrementalSaver extends AbstractSaver implements Saver, // en esperant que sera pas infini :) do { ++foundProjectNumber; - aGtimerFile = new File(saveDirectory + File.separator + aGtimerFile = new File(dataSaveDirectory + File.separator + foundProjectNumber + extension); } while (aGtimerFile.exists()); @@ -1261,7 +1242,7 @@ public class GTimerIncrementalSaver extends AbstractSaver implements Saver, // first, delete task annotation file if (extension.equals(GTIMER_TASK_EXTENSION)) { - File annfileToDelete = new File(saveDirectory + File.separator + File annfileToDelete = new File(dataSaveDirectory + File.separator + fileNumber + "." + GTIMER_ANNOTATION_EXTENSION); if (annfileToDelete.exists()) { annfileToDelete.delete(); @@ -1272,7 +1253,7 @@ public class GTimerIncrementalSaver extends AbstractSaver implements Saver, } } - File alertFileToDelete = new File(saveDirectory + File.separator + File alertFileToDelete = new File(dataSaveDirectory + File.separator + fileNumber + "." + GTIMER_ALERT_EXTENSION); if (alertFileToDelete.exists()) { alertFileToDelete.delete(); @@ -1290,7 +1271,7 @@ public class GTimerIncrementalSaver extends AbstractSaver implements Saver, } // then manage current task file - File fileToDelete = new File(saveDirectory + File.separator + File fileToDelete = new File(dataSaveDirectory + File.separator + fileNumber + "." + extension); if (fileToDelete.exists()) { fileToDelete.delete(); diff --git a/src/main/java/org/chorem/jtimer/io/Saver.java b/src/main/java/org/chorem/jtimer/io/Saver.java index 7ff9a36..7c54c59 100644 --- a/src/main/java/org/chorem/jtimer/io/Saver.java +++ b/src/main/java/org/chorem/jtimer/io/Saver.java @@ -40,13 +40,6 @@ import org.chorem.jtimer.entities.TimerProject; public interface Saver extends DataEventListener, VetoableDataEventListener { /** - * Set file directory. - * - * @param directory directory - */ - void setSaveDirectory(String directory); - - /** * Set auto save delay (in milliseconds). * * @param autoSaveDelay delay in milliseconds diff --git a/src/main/resources/log4j2.xml b/src/main/resources/log4j2.xml index 60f69cc..39ee61a 100644 --- a/src/main/resources/log4j2.xml +++ b/src/main/resources/log4j2.xml @@ -29,7 +29,7 @@ </Appenders> <Loggers> - <!-- <Logger name="org.chorem.jtimer" level="debug"/> --> + <Logger name="org.chorem.jtimer" level="info"/> <Root level="warn"> <AppenderRef ref="Console" /> diff --git a/src/site/rst/configuration.rst b/src/site/rst/configuration.rst index 54ea84c..e1c40ed 100644 --- a/src/site/rst/configuration.rst +++ b/src/site/rst/configuration.rst @@ -43,9 +43,9 @@ Default idle time is ``300`` seconds (5 minutes). It is possible to modify this Task template ------------- jTimer can create a task using subtask template. You can specify template, as yaml format, by creating -a file into ``${userHome}/.gtimer/template`` directory (one file per template). +a file into ``${userHome}/.jtimer/templates`` directory (one file per template). -For example, in file ``templatename1.txt``:: +For example, in file ``templatename1.yml``:: dev: E1: diff --git a/src/site/rst/index.rst.vm b/src/site/rst/index.rst.vm index 4a6b6f3..5bc0000 100644 --- a/src/site/rst/index.rst.vm +++ b/src/site/rst/index.rst.vm @@ -37,7 +37,7 @@ Features * Add notes on tasks * Alerts setup * Internationalization (i18n) - * `gTimer`_ file format compliant + * `gTimer`_ file format migration Download -------- diff --git a/src/test/java/org/chorem/jtimer/AbstractJTimerTest.java b/src/test/java/org/chorem/jtimer/AbstractJTimerTest.java index 067ea8e..4cfc75c 100644 --- a/src/test/java/org/chorem/jtimer/AbstractJTimerTest.java +++ b/src/test/java/org/chorem/jtimer/AbstractJTimerTest.java @@ -83,16 +83,17 @@ public abstract class AbstractJTimerTest { */ protected void initDataDirectory() throws IOException { + JTimer.config = new JTimerConfig(); + URL testConfigFile = AbstractJTimerTest.class.getResource("/jtimertest.properties"); - Properties props = new Properties(); + Properties props = new Properties(JTimer.config.appConfig.getOptions()); props.load(testConfigFile.openStream()); - testDataDirectory = new File(getTempDirPath(), String.valueOf(System - .currentTimeMillis())); - props.put("jtimer.io.saver.directory", testDataDirectory - .getAbsolutePath()); + // overload system wide options + testDataDirectory = new File(getTempDirPath(), String.valueOf(System.currentTimeMillis())); + props.put("jtimer.home.directory", testDataDirectory.getAbsolutePath()); + props.put("jtimer.io.saver.directory", testDataDirectory.getParent() + File.separator + ".gtimer"); - JTimer.config = new JTimerConfig(); JTimer.config.appConfig.setOptions(props); // not call parse in test if (log.isDebugEnabled()) { @@ -103,7 +104,7 @@ public abstract class AbstractJTimerTest { // HiddenFileFilter.VISIBLE is used to not // copy .svn folders FileUtils.copyDirectory(new File("src/test/resources/testdata"), - testDataDirectory, HiddenFileFilter.VISIBLE); + new File(testDataDirectory, "data"), HiddenFileFilter.VISIBLE); // force null, to force new instance JTimerFactory.saver = null; diff --git a/src/test/java/org/chorem/jtimer/io/GTimerIncrementalSaverTest.java b/src/test/java/org/chorem/jtimer/io/GTimerIncrementalSaverTest.java index 26c0675..3a153a6 100644 --- a/src/test/java/org/chorem/jtimer/io/GTimerIncrementalSaverTest.java +++ b/src/test/java/org/chorem/jtimer/io/GTimerIncrementalSaverTest.java @@ -59,10 +59,6 @@ public class GTimerIncrementalSaverTest extends AbstractJTimerTest { Assert.assertTrue(testSaver instanceof GTimerIncrementalSaver); - // Tmp dir is dynamic - //Assert.assertEquals(AbstractJTimerTest.getTempDirPath() + "/testngdata", - // ((GTimerIncrementalSaver) testSaver).saveDirectory); - } /** @@ -118,7 +114,7 @@ public class GTimerIncrementalSaverTest extends AbstractJTimerTest { GTimerIncrementalSaver gsaver = (GTimerIncrementalSaver) testSaver; - String projectFilePath = gsaver.saveDirectory + "/1.project"; + String projectFilePath = gsaver.dataSaveDirectory + "/1.project"; TimerProject project = gsaver.getProjectFromFile(new File( projectFilePath)); @@ -160,7 +156,7 @@ public class GTimerIncrementalSaverTest extends AbstractJTimerTest { GTimerIncrementalSaver gsaver = (GTimerIncrementalSaver) testSaver; - String taskFilePath = gsaver.saveDirectory + "/1.task"; + String taskFilePath = gsaver.dataSaveDirectory + "/1.task"; // parent projects map TimerProject parentProject = new TimerProject(); diff --git a/src/test/resources/jtimertest.properties b/src/test/resources/jtimertest.properties index 20f5ba3..aa0ca1e 100644 --- a/src/test/resources/jtimertest.properties +++ b/src/test/resources/jtimertest.properties @@ -25,10 +25,9 @@ jtimer.ui.idletime=299 # jtimer io saver directory jtimer.io.saver.class=org.chorem.jtimer.io.GTimerIncrementalSaver -# Saver directory -jtimer.io.saver.directory=${user.home}/testngdata + # Save delay jtimer.io.saver.autosavedelay=199 # sandbox in test -jtimer.ui.template.directory=src/test/resources/templates +jtimer.templates.directory=src/test/resources/templates -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
participants (1)
-
chorem.org scm