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 8dba28cb1330e9c4b54f840a60935fe57b116e35 Author: servantie <servantie.c@gmail.com> Date: Thu Jun 30 15:49:29 2016 +0200 New display of SyncInfo edition, with URL test button --- src/main/java/org/chorem/jtimer/JTimer.java | 4 +- .../org/chorem/jtimer/data/DataEventListener.java | 5 +- .../java/org/chorem/jtimer/data/TimerCore.java | 2 - .../org/chorem/jtimer/data/TimerDataManager.java | 21 +- .../java/org/chorem/jtimer/entities/SyncInfo.java | 35 +- .../java/org/chorem/jtimer/entities/TimerTask.java | 39 +- .../chorem/jtimer/entities/TimerTaskHelper.java | 86 ++- .../chorem/jtimer/io/GTimerIncrementalSaver.java | 74 ++- .../chorem/jtimer/io/TimerTaskSynchronizer.java | 16 +- src/main/java/org/chorem/jtimer/ui/StatusBar.java | 2 +- .../jtimer/ui/report/TimerTaskSyncInfoEditor.java | 385 ++++++++++++ .../jtimer/ui/report/TimerTaskUpdaterView.java | 671 --------------------- .../chorem/jtimer/ui/systray/SystrayManager.java | 7 +- .../jtimer/ui/treetable/ProjectsAndTasksModel.java | 2 - .../ProjectsAndTasksRunningCellRenderer.java | 1 - .../org/chorem/jtimer/resources/JTimer.properties | 4 +- .../chorem/jtimer/resources/JTimer_fr.properties | 4 +- .../resources/TimerTaskSyncInfoEditor.properties | 46 ++ .../TimerTaskSyncInfoEditor_fr.properties | 46 ++ .../resources/TimerTaskUpdaterView.properties | 74 --- .../resources/TimerTaskUpdaterView_fr.properties | 73 --- .../org/chorem/jtimer/entities/TimerTaskTest.java | 12 +- src/test/resources/testdata/41.task.sync | 2 +- 23 files changed, 671 insertions(+), 940 deletions(-) diff --git a/src/main/java/org/chorem/jtimer/JTimer.java b/src/main/java/org/chorem/jtimer/JTimer.java index 4a0a733..eeae51d 100644 --- a/src/main/java/org/chorem/jtimer/JTimer.java +++ b/src/main/java/org/chorem/jtimer/JTimer.java @@ -74,7 +74,7 @@ import org.chorem.jtimer.ui.StatusBar; import org.chorem.jtimer.ui.TimerTaskEditor; import org.chorem.jtimer.ui.alert.AlertEditor; import org.chorem.jtimer.ui.report.ReportView; -import org.chorem.jtimer.ui.report.TimerTaskUpdaterView; +import org.chorem.jtimer.ui.report.TimerTaskSyncInfoEditor; import org.chorem.jtimer.ui.systray.SystrayManager; import org.chorem.jtimer.ui.tasks.IdleDialog; import org.chorem.jtimer.ui.tasks.RefreshTreeTask; @@ -669,7 +669,7 @@ public class JTimer extends SingleFrameApplication implements public void updateTask() { TimerTask task = projectsAndTasksTable.getSelectedTasks().get(0); - TimerTaskUpdaterView updater = new TimerTaskUpdaterView(this, core, task); + TimerTaskSyncInfoEditor updater = new TimerTaskSyncInfoEditor(this, core, task); show(updater); } diff --git a/src/main/java/org/chorem/jtimer/data/DataEventListener.java b/src/main/java/org/chorem/jtimer/data/DataEventListener.java index 04b0e0a..ea7d9e9 100644 --- a/src/main/java/org/chorem/jtimer/data/DataEventListener.java +++ b/src/main/java/org/chorem/jtimer/data/DataEventListener.java @@ -27,6 +27,7 @@ import java.util.Date; import java.util.EventListener; import java.util.List; +import org.chorem.jtimer.entities.SyncInfo; import org.chorem.jtimer.entities.TimerProject; import org.chorem.jtimer.entities.TimerTask; @@ -194,14 +195,14 @@ public interface DataEventListener extends EventListener { * @param task * @param syncURL String */ - default void changeSyncInfo(TimerTask task, String syncURL) { + default void changeSyncInfo(TimerTask task, SyncInfo syncURL) { } /** * SyncInfo deleted */ - default void deleteSyncInfo(TimerTask task, String syncURL) { + default void deleteSyncInfo(TimerTask task, SyncInfo syncURL) { } } diff --git a/src/main/java/org/chorem/jtimer/data/TimerCore.java b/src/main/java/org/chorem/jtimer/data/TimerCore.java index b6eba6d..d29448b 100644 --- a/src/main/java/org/chorem/jtimer/data/TimerCore.java +++ b/src/main/java/org/chorem/jtimer/data/TimerCore.java @@ -198,8 +198,6 @@ public class TimerCore { if (log.isInfoEnabled()) { log.info("Exiting application"); } - //try one last sync - synchronizer.lastSync(); // unlock fs directory try { saver.unlock(); diff --git a/src/main/java/org/chorem/jtimer/data/TimerDataManager.java b/src/main/java/org/chorem/jtimer/data/TimerDataManager.java index df9d8c0..d51edec 100644 --- a/src/main/java/org/chorem/jtimer/data/TimerDataManager.java +++ b/src/main/java/org/chorem/jtimer/data/TimerDataManager.java @@ -37,6 +37,7 @@ import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.jtimer.JTimer; +import org.chorem.jtimer.entities.SyncInfo; import org.chorem.jtimer.entities.TimerProject; import org.chorem.jtimer.entities.TimerTask; @@ -638,31 +639,31 @@ public class TimerDataManager { } /** - * Edit Synchronisation Information + * Edit Synchronization Information */ - public void changeSyncInfo(TimerTask task, String url) { - task.addSyncInfo(url, LocalDateTime.MIN, true); + public void changeSyncInfo(TimerTask task, SyncInfo info) { + task.addSyncInfo(info); for (DataEventListener dataEventListener : dataEventListeners) { - dataEventListener.changeSyncInfo(task, url); + dataEventListener.changeSyncInfo(task, info); } if (log.isDebugEnabled()) { - log.debug("SyncInfo changed: " + url); + log.debug("SyncInfo changed: " + info.getSyncURL()); } } /** * When a syncInfo is deleted */ - public void deleteSyncInfo(TimerTask task, String url) { - if (task.getSynchronizingURLList().contains(url)) { - task.removeSyncInfo(url); + public void deleteSyncInfo(TimerTask task, SyncInfo info) { + if (task.getSynchronizingInfoList().contains(info)) { + task.removeSyncInfo(info); } for (DataEventListener dataEventListener : dataEventListeners) { - dataEventListener.deleteSyncInfo(task, url); + dataEventListener.deleteSyncInfo(task, info); } if (log.isDebugEnabled()) { - log.debug("SyncInfo deleted: " + url); + log.debug("SyncInfo deleted: " + info.getSyncURL()); } } } diff --git a/src/main/java/org/chorem/jtimer/entities/SyncInfo.java b/src/main/java/org/chorem/jtimer/entities/SyncInfo.java index 1eb90c4..7963eac 100644 --- a/src/main/java/org/chorem/jtimer/entities/SyncInfo.java +++ b/src/main/java/org/chorem/jtimer/entities/SyncInfo.java @@ -19,25 +19,33 @@ public class SyncInfo { /** true if the synchronization is active */ boolean isActiveSync; + /** true if annotations included */ + boolean isWithAnnotations; + /** * constructor with all parameters * @param syncURL the url to sync to * @param lastSync the last time it was synced successfully * @param isActiveSync if true, will sync auto + * @param isWithAnnotations if true, will add annotations */ - public SyncInfo(String syncURL, LocalDateTime lastSync, boolean isActiveSync) { + public SyncInfo(String syncURL, LocalDateTime lastSync, boolean isActiveSync, boolean isWithAnnotations) { this.syncURL = syncURL; this.lastSync = lastSync; this.isActiveSync = isActiveSync; + this.isWithAnnotations = isWithAnnotations; } /** - * Constructor with just the url, at creation the sync is considered active by default + * Constructor with just the url, at creation the sync is considered active by default, + * and annotations are not sent by default * @param syncURL the url to sync to */ public SyncInfo(String syncURL) { this.syncURL = syncURL; this.isActiveSync = true; + this.isWithAnnotations = false; + this.lastSync = LocalDateTime.MIN; } /** @@ -50,7 +58,7 @@ public class SyncInfo { /** * Returns a boolean if sync should send to this url - * @return boolean + * @return aboolean */ public boolean getActiveSync() { return isActiveSync; @@ -65,6 +73,19 @@ public class SyncInfo { } /** + * Returns a boolean for the inclusion of annotations + * in the sync + * @return a boolean + */ + public boolean getIsWithAnnotations(){ return isWithAnnotations;} + + /** + * Sets the isWithAnnotations boolean + * @param hasAnnotations boolean + */ + public void setIsWithAnnotations(boolean hasAnnotations){ isWithAnnotations = hasAnnotations;} + + /** * Set the syncURL * @param syncURL String */ @@ -87,5 +108,13 @@ public class SyncInfo { public void setLastSync(LocalDateTime syncTime) { lastSync = syncTime; } + + /** + * Overrides the toString() method to return the url (for combobox) + */ + @Override + public String toString() { + return syncURL; + } } diff --git a/src/main/java/org/chorem/jtimer/entities/TimerTask.java b/src/main/java/org/chorem/jtimer/entities/TimerTask.java index 3bc22d5..b691fea 100644 --- a/src/main/java/org/chorem/jtimer/entities/TimerTask.java +++ b/src/main/java/org/chorem/jtimer/entities/TimerTask.java @@ -90,7 +90,7 @@ public class TimerTask implements Cloneable, protected List<TimerAlert> alerts; /** - * Synchronisation Info + * Synchronization Info */ protected List<SyncInfo> synchronisingInfoList; @@ -260,7 +260,7 @@ public class TimerTask implements Cloneable, } } if (!urlinList) { - synchronisingInfoList.add(new SyncInfo(syncURL, syncDate, true)); + synchronisingInfoList.add(new SyncInfo(syncURL)); } } @@ -300,37 +300,44 @@ public class TimerTask implements Cloneable, * @param url a string * @param time a LocalDateTime * @param isActive a boolean for activity (true to sync auto) + * @param isWithAnnotations a boolean for annotations (false default) */ - public void addSyncInfo(String url, LocalDateTime time, boolean isActive) { + public void addSyncInfo(String url, LocalDateTime time, boolean isActive, boolean isWithAnnotations) { if (!url.isEmpty() && !getSynchronizingURLList().contains(url)) { - synchronisingInfoList.add(new SyncInfo(url, time, isActive)); + synchronisingInfoList.add(new SyncInfo(url, time, isActive, isWithAnnotations)); } } /** * Adds a new synchronization info with just url provided - * (default isActive = true and time is minimum) + * (default isActive = true and isWithAnnotations false) * @param url a String */ public void addSyncInfo(String url) { - addSyncInfo(url, LocalDateTime.MIN, true); + addSyncInfo(url, LocalDateTime.MIN, true, false); + } + + /** + * Adds a SyncInfo to the task + * @param info a SyncInfo + */ + + public void addSyncInfo(SyncInfo info) { + if (!getSynchronizingInfoList().contains(info)) { + synchronisingInfoList.add(info); + } } /** - * Removes a synchronisation info attached to a url if it exists - * @param url : the url of the info to remove + * Removes a synchronization info attached to a url if it exists + * @param info : the sync info to remove * */ - public void removeSyncInfo(String url) { + public void removeSyncInfo(SyncInfo info) { List<SyncInfo> copySyncList = new ArrayList<>(synchronisingInfoList); - if (getSynchronizingURLList().contains(url)) { - int a = getSynchronizingURLList().size(); - for (int i = 0; i<a ; ++i) { - if (synchronisingInfoList.get(i).getSyncURL().equals(url)) { - copySyncList.remove(synchronisingInfoList.get(i)); - } - } + if (getSynchronizingURLList().contains(info.getSyncURL())) { + copySyncList.remove(info); } synchronisingInfoList = copySyncList; } diff --git a/src/main/java/org/chorem/jtimer/entities/TimerTaskHelper.java b/src/main/java/org/chorem/jtimer/entities/TimerTaskHelper.java index c55d8d8..e893536 100644 --- a/src/main/java/org/chorem/jtimer/entities/TimerTaskHelper.java +++ b/src/main/java/org/chorem/jtimer/entities/TimerTaskHelper.java @@ -368,48 +368,68 @@ public class TimerTaskHelper { */ public static List<JsonObject> taskToJSONFormat(TimerTask task, Date startDate, Date endDate, boolean withAnnotations, String timezone) { ArrayList<JsonObject> jsonObjectList = new ArrayList<>(); - String timestamp = "T00:00:00" + timezone; - //start and end period dates are the same for all the objects - LocalDate startPeriodDate = startDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDate(); - String startPeriodString = startPeriodDate.toString() + timestamp; - LocalDate endPeriodDate = endDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDate(); - String endPeriodString = endPeriodDate.toString() + timestamp; SortedMap<Date, Long> dates = task.getAllDaysAndTimes().subMap(startDate, endDate); //only create jsons if there are times to send if (dates.size() != 0) { //iterate over active urls only for (String url : task.getActiveSynchronizingURLList()) { - JsonObject responseJSON = new JsonObject(); - JsonArray periodArray = new JsonArray(); - for (SortedMap.Entry<Date, Long> entry : dates.entrySet()) { - //adding id, startDate and duration - //converting Date to LocalDate (to ease the .toString()) - LocalDate date = entry.getKey().toInstant().atZone(ZoneId.systemDefault()).toLocalDate(); - String dateString = date.toString(); - //as jtimer has time entries only for a day, the id of the times will be the date in yyyy-mm-dd format - JsonObject periodElement = new JsonObject(); - periodElement.addProperty("id", dateString); - periodElement.addProperty("startDate", dateString + timestamp); - periodElement.addProperty("duration", entry.getValue()/1000); - if (withAnnotations && !(getAnnotation(task, entry.getKey()).isEmpty())) { - StringBuilder annotationBuilder = new StringBuilder(); - for (String s : getAnnotation(task, entry.getKey())) { - annotationBuilder.append(s); - annotationBuilder.append(","); - } - periodElement.addProperty("info", annotationBuilder.toString()); - } - periodArray.add(periodElement); - } - responseJSON.addProperty("URL", url); - responseJSON.addProperty("startDate", startPeriodString); - responseJSON.addProperty("endDate", endPeriodString); - responseJSON.add("periods", periodArray); - + JsonObject responseJSON = taskURLToJSONObject(task, url, startDate, endDate, withAnnotations, timezone); jsonObjectList.add(responseJSON); } } return jsonObjectList; } + + /** + * Makes only one object for a task associated to a URL + */ + public static JsonObject taskURLToJSONObject(TimerTask task, String url, Date startDate, Date endDate, boolean withAnnotations, String timezone) { + JsonObject resultingObject = new JsonObject(); + JsonArray periodArray = new JsonArray(); + String timestamp = "T00:00:00" + timezone; + SortedMap<Date, Long> dates = task.getAllDaysAndTimes().subMap(startDate, endDate); + LocalDate startPeriodDate = startDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDate(); + String startPeriodString = startPeriodDate.toString() + timestamp; + LocalDate endPeriodDate = endDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDate(); + String endPeriodString = endPeriodDate.toString() + timestamp; + for (SortedMap.Entry<Date, Long> entry : dates.entrySet()) { + //adding id, startDate and duration + //converting Date to LocalDate (to ease the .toString()) + LocalDate date = entry.getKey().toInstant().atZone(ZoneId.systemDefault()).toLocalDate(); + String dateString = date.toString(); + //as jtimer has time entries only for a day, the id of the times will be the date in yyyy-mm-dd format + JsonObject periodElement = new JsonObject(); + periodElement.addProperty("id", dateString); + periodElement.addProperty("startDate", dateString + timestamp); + periodElement.addProperty("duration", entry.getValue()/1000); + if (withAnnotations && !(getAnnotation(task, entry.getKey()).isEmpty())) { + StringBuilder annotationBuilder = new StringBuilder(); + for (String s : getAnnotation(task, entry.getKey())) { + annotationBuilder.append(s); + annotationBuilder.append(","); + } + periodElement.addProperty("info", annotationBuilder.toString()); + } + periodArray.add(periodElement); + } + resultingObject.addProperty("URL", url); + resultingObject.addProperty("startDate", startPeriodString); + resultingObject.addProperty("endDate", endPeriodString); + resultingObject.add("periods", periodArray); + + return resultingObject; + } + + /** + * Makes a single object with all the times + */ + public static JsonObject taskURLToJSONObject(TimerTask task, String url, boolean withAnnotations, String timezone) { + Date startDate = task.getAllDaysAndTimes().firstKey(); + Date endDate = new Date(); + //get the current day too by making endDate a day later + endDate.setTime(endDate.getTime() + 86400 * 1000L); + JsonObject resultingObject = taskURLToJSONObject(task, url, startDate, endDate, withAnnotations, timezone); + return resultingObject; + } } diff --git a/src/main/java/org/chorem/jtimer/io/GTimerIncrementalSaver.java b/src/main/java/org/chorem/jtimer/io/GTimerIncrementalSaver.java index ef651cf..22ef2c6 100644 --- a/src/main/java/org/chorem/jtimer/io/GTimerIncrementalSaver.java +++ b/src/main/java/org/chorem/jtimer/io/GTimerIncrementalSaver.java @@ -600,7 +600,7 @@ public class GTimerIncrementalSaver extends AbstractSaver implements Saver, if (syncTaskFile.exists()) { if (log.isDebugEnabled()) { - log.debug("Synchronisation information found for task " + task.getName()); + log.debug("Synchronization information found for task " + task.getName()); } try (BufferedReader parseIn = new BufferedReader(new FileReader(syncTaskFile))) { @@ -612,29 +612,50 @@ public class GTimerIncrementalSaver extends AbstractSaver implements Saver, if (!line.isEmpty()) { String[] urlArray = line.split(" "); //if there is no lastSyncTime - if (urlArray.length == 2) { + if (urlArray.length == 3) { if ("true".equals(urlArray[1])) { - task.addSyncInfo(urlArray[0], LocalDateTime.MIN, true); + if ("true".equals(urlArray[2])) { + task.addSyncInfo(urlArray[0], LocalDateTime.MIN, true, true); + } + else { + task.addSyncInfo(urlArray[0], LocalDateTime.MIN, true, false); + } } else { - task.addSyncInfo(urlArray[0], LocalDateTime.MIN, false); + if ("true".equals(urlArray[2])) { + task.addSyncInfo(urlArray[0], LocalDateTime.MIN, false, true); + } + else { + task.addSyncInfo(urlArray[0], LocalDateTime.MIN, false, false); + } } } //else if there is lastSyncTime - else if (urlArray.length == 3) { + else if (urlArray.length == 4) { DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSS"); LocalDateTime date = null; try { - date = LocalDateTime.parse(urlArray[2], formatter); + date = LocalDateTime.parse(urlArray[3], formatter); } catch (DateTimeParseException e) { if (log.isErrorEnabled()) { log.error("Error parsing SyncTime for " + urlArray[0]); } } if ("true".equals(urlArray[1])) { - task.addSyncInfo(urlArray[0], date, true); - } else { - task.addSyncInfo(urlArray[0], date, false); + if ("true".equals(urlArray[2])) { + task.addSyncInfo(urlArray[0], date, true, true); + } + else { + task.addSyncInfo(urlArray[0], date, true, false); + } + } + else { + if ("true".equals(urlArray[2])) { + task.addSyncInfo(urlArray[0], date, false, true); + } + else { + task.addSyncInfo(urlArray[0], date, false, false); + } } } } @@ -650,7 +671,7 @@ public class GTimerIncrementalSaver extends AbstractSaver implements Saver, } else { if (log.isDebugEnabled()) { - log.debug("Synchronisation information not found for task " + task.getName()); + log.debug("Synchronization information not found for task " + task.getName()); } } } @@ -1140,22 +1161,22 @@ public class GTimerIncrementalSaver extends AbstractSaver implements Saver, } /** - * Save synchronisation info for a task. + * Save synchronization info for a task. * * @param task task to save annotation */ - protected void saveSynchronisationInfo(TimerTask task) { + protected void saveSynchronizationInfo(TimerTask task) { int taskNumber = task.getNumber(); - File synchronisationTaskFile = new File(dataSaveDirectory + File.separator + File synchronizationTaskFile = new File(dataSaveDirectory + File.separator + taskNumber + "." + GTIMER_TASK_EXTENSION + "." + GTIMER_SYNC_EXTENSION); if ((task.getSynchronizingURLList() != null) || (!task.getSynchronizingURLList().isEmpty())) { File backupfile = null; - try (Writer out = new OutputStreamWriter(new FileOutputStream(synchronisationTaskFile), "ISO-8859-1")) { + try (Writer out = new OutputStreamWriter(new FileOutputStream(synchronizationTaskFile), "ISO-8859-1")) { // first make backup - backupfile = makeBackupFile(synchronisationTaskFile); + backupfile = makeBackupFile(synchronizationTaskFile); out.write("Format: " + GTIMER_FILE_VERSION + "\n"); //start Sync Save @@ -1171,6 +1192,13 @@ public class GTimerIncrementalSaver extends AbstractSaver implements Saver, else { out.write("false "); } + //write isWithAnnotations + if(sync.getIsWithAnnotations()) { + out.write("true "); + } + else { + out.write("false "); + } //write lastsync (HH:MM:SS) if (sync.getLastSync() != null && sync.getLastSync().isAfter(LocalDateTime.MIN)) { //remove the milliseconds @@ -1184,7 +1212,7 @@ public class GTimerIncrementalSaver extends AbstractSaver implements Saver, deleteBackupFile(backupfile); } catch (IOException e) { if (log.isErrorEnabled()) { - log.debug("Can't save task synchronisation information", e); + log.debug("Can't save task synchronization information", e); } // can be null if backup throws the exception @@ -1193,7 +1221,7 @@ public class GTimerIncrementalSaver extends AbstractSaver implements Saver, } } } else { - synchronisationTaskFile.delete(); + synchronizationTaskFile.delete(); } } @@ -1313,8 +1341,8 @@ public class GTimerIncrementalSaver extends AbstractSaver implements Saver, } @Override - public void changeSyncInfo(TimerTask task, String syncURL) { - saveSynchronisationInfo(task); + public void changeSyncInfo(TimerTask task, SyncInfo syncURL) { + saveSynchronizationInfo(task); } @Override @@ -1366,7 +1394,7 @@ public class GTimerIncrementalSaver extends AbstractSaver implements Saver, if (syncFileToDelete.exists()) { syncFileToDelete.delete(); if (log.isDebugEnabled()) { - log.debug("Synchronisation file deleted for " + taskOrProject.getName() + "(" + syncFileToDelete.getPath() +")"); + log.debug("Synchronization file deleted for " + taskOrProject.getName() + "(" + syncFileToDelete.getPath() +")"); } } } @@ -1414,7 +1442,7 @@ public class GTimerIncrementalSaver extends AbstractSaver implements Saver, // Potentiellement aussi lors d'un move. saveTaskAnnotation(task); saveAlerts(task); - saveSynchronisationInfo(task); + saveSynchronizationInfo(task); // fix a bug with the gtimer subtask // save format du to composed task name @@ -1548,8 +1576,8 @@ public class GTimerIncrementalSaver extends AbstractSaver implements Saver, * @param url */ @Override - public void deleteSyncInfo(TimerTask task, String url) { - saveSynchronisationInfo(task); + public void deleteSyncInfo(TimerTask task, SyncInfo url) { + saveSynchronizationInfo(task); } } diff --git a/src/main/java/org/chorem/jtimer/io/TimerTaskSynchronizer.java b/src/main/java/org/chorem/jtimer/io/TimerTaskSynchronizer.java index 97b77e5..ca42cd5 100644 --- a/src/main/java/org/chorem/jtimer/io/TimerTaskSynchronizer.java +++ b/src/main/java/org/chorem/jtimer/io/TimerTaskSynchronizer.java @@ -10,6 +10,7 @@ import java.util.Timer; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.jtimer.data.DataEventListener; +import org.chorem.jtimer.entities.SyncInfo; import org.chorem.jtimer.entities.TimerProject; import org.chorem.jtimer.entities.TimerTask; import org.chorem.jtimer.entities.TimerTaskHelper; @@ -78,19 +79,6 @@ public class TimerTaskSynchronizer implements DataEventListener { } /** - * Synchronizes at exit the tasks left in the sync - */ - public void lastSync() { - log.info("Synchronizing at exit"); - for (TimerTask task : tasksToSync) { - if (log.isDebugEnabled()) { - log.debug(task.getName()); - } - synchronizeSingleTask(task); - } - } - - /** * Inner Task class to make the automatic sync */ protected class UpdateTask extends java.util.TimerTask { @@ -336,7 +324,7 @@ public class TimerTaskSynchronizer implements DataEventListener { * @param syncURL the url to sync on (a String) */ @Override - public void changeSyncInfo(TimerTask task, String syncURL) { + public void changeSyncInfo(TimerTask task, SyncInfo syncURL) { if (!tasksToSync.contains(task)) { //add it only if the URL is not empty if ((task.getSynchronizingURLList() != null) && !(task.getSynchronizingURLList().isEmpty())) { diff --git a/src/main/java/org/chorem/jtimer/ui/StatusBar.java b/src/main/java/org/chorem/jtimer/ui/StatusBar.java index 11b7fde..7802885 100644 --- a/src/main/java/org/chorem/jtimer/ui/StatusBar.java +++ b/src/main/java/org/chorem/jtimer/ui/StatusBar.java @@ -34,6 +34,7 @@ import javax.swing.SwingConstants; import org.apache.commons.lang3.time.DurationFormatUtils; import org.chorem.jtimer.data.DataEventListener; import org.chorem.jtimer.data.TimerDataManager; +import org.chorem.jtimer.entities.SyncInfo; import org.chorem.jtimer.entities.TimerProject; import org.chorem.jtimer.entities.TimerTask; import org.chorem.jtimer.entities.TimerTaskHelper; @@ -136,7 +137,6 @@ public class StatusBar extends JPanel implements DataEventListener { // and call modifyTask modifyTask(null); } - /* * @see org.chorem.jtimer.data.event.DataEventListener#deleteProject(org.chorem.jtimer.entities.TimerProject) */ diff --git a/src/main/java/org/chorem/jtimer/ui/report/TimerTaskSyncInfoEditor.java b/src/main/java/org/chorem/jtimer/ui/report/TimerTaskSyncInfoEditor.java new file mode 100644 index 0000000..ab0c4da --- /dev/null +++ b/src/main/java/org/chorem/jtimer/ui/report/TimerTaskSyncInfoEditor.java @@ -0,0 +1,385 @@ + +/* + * #%L + * jTimer + * %% + * Copyright (C) 2008 - 2016 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 + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.jtimer.ui.report; + +import com.google.gson.Gson; +import com.google.gson.JsonObject; +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.List; +import javax.swing.Box; +import javax.swing.BoxLayout; +import javax.swing.DefaultComboBoxModel; +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JComboBox; +import javax.swing.JComponent; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.jtimer.data.TimerCore; +import org.chorem.jtimer.entities.SyncInfo; +import org.chorem.jtimer.entities.TimerTask; +import org.chorem.jtimer.entities.TimerTaskHelper; +import org.chorem.jtimer.io.TimerTaskSynchronizer; +import org.jdesktop.application.Action; +import org.jdesktop.application.Application; +import org.jdesktop.application.FrameView; + +/** + * UI to modify Synchronization Info of a task + * + * Created by servantie on 13/05/16. + */ +public class TimerTaskSyncInfoEditor extends FrameView implements ActionListener, ItemListener { + + /** Class logger */ + protected static Log log = LogFactory.getLog(TimerTaskSyncInfoEditor.class); + + /** Timer core. */ + protected TimerCore core; + + /** Include annotations on updates */ + protected JCheckBox checkIncludesAnnotations; + + /** Activate a sync URL */ + protected JCheckBox checkIsActiveSync; + + /** button to delete a URL */ + protected JButton deleteButton; + + /** button to test a url */ + protected JButton testSyncUrlButton; + + /** task in json format (1/synchronizing url) */ + protected List<JsonObject> updateJson; + + /** ComboBox of URLs */ + protected JComboBox<SyncInfo> urlComboBox; + + /** LastSync */ + protected JLabel lastUpdate; + /** lastSync Label */ + protected JLabel lastSyncDateLabel; + + /** task to update */ + protected TimerTask task; + + /** timezone */ + protected String timezone; + + /** + * UpdaterView constructor. + * @param application parent reference + * @param core core reference + * @param task the task to update + */ + public TimerTaskSyncInfoEditor(Application application, TimerCore core, TimerTask task) { + + super(application); + // modify frame name + getFrame().setName("syncFrame"); + getFrame().setTitle(getResourceMap().getString("syncTitle")); + + this.core = core; + this.task = task; + timezone = "+01:00"; + updateJson = new ArrayList<>(); + + setComponent(getMainComponent()); + + + } + + /** + * Get main view component. + * + * @return main component + */ + protected JComponent getMainComponent() { + + JPanel configComponent = new JPanel(); + configComponent.setLayout(new BorderLayout(5, 5)); + + JPanel urlPanel = new JPanel(); + urlPanel.setLayout(new BorderLayout(5,5)); + + //url combobox + JLabel urlcomboBoxLabel = new JLabel(getResourceMap().getString("urlComboLabel")); + urlComboBox = new JComboBox<>(new DefaultComboBoxModel<>()); + //make it editable to add new urls + urlComboBox.setEditable(true); + urlComboBox.addItemListener(this); + urlComboBox.addActionListener(this); + //add the urls to the combobox + for (SyncInfo info : task.getSynchronizingInfoList()) { + urlComboBox.addItem(info); + } + urlComboBox.setActionCommand("comboBox"); + + urlPanel.add(urlcomboBoxLabel, BorderLayout.NORTH); + urlPanel.add(urlComboBox, BorderLayout.SOUTH); + + //a box containing the url sync time label and the checkboxes + Box labelBox = new Box(BoxLayout.PAGE_AXIS); + + + //checkbox to include annotations + checkIncludesAnnotations = new JCheckBox(); + checkIncludesAnnotations.setAction(getContext().getActionMap(this).get("isIncludingAnnotations")); + //checkbox for active sync + checkIsActiveSync = new JCheckBox(); + checkIsActiveSync.addActionListener(this); + checkIsActiveSync.setAction(getContext().getActionMap(this).get("isActiveSync")); + //display last Sync time + lastSyncDateLabel = new JLabel(getResourceMap().getString("lastUpdateLabel")); + lastUpdate = new JLabel(); + if (urlComboBox.getSelectedItem() != null) { + SyncInfo selectedInfo = (SyncInfo) urlComboBox.getSelectedItem(); + if (task.getSynchronizingInfoList().contains(selectedInfo)){ + SyncInfo syncInfo = task.getSynchronizingInfo(selectedInfo.getSyncURL()); + LocalDateTime lastSyncTime = syncInfo.getLastSync(); + //if there has been an update before, display its date + if ((lastSyncTime != null) && lastSyncTime.isAfter(LocalDateTime.MIN)) { + lastUpdate.setText(lastSyncTime.toString()); + //logging change of lastSync + if (log.isDebugEnabled()) { + log.debug("Last Sync time loaded : " + lastSyncTime.toString()); + } + lastSyncDateLabel.setVisible(true); + } + else { + if (log.isDebugEnabled()) { + log.debug("No Last Sync time loaded"); + } + lastSyncDateLabel.setVisible(false); + } + checkIsActiveSync.setSelected(task.getSynchronizingInfo(selectedInfo.getSyncURL()).getActiveSync()); + } + } + labelBox.add(checkIsActiveSync); + labelBox.add(checkIncludesAnnotations); + labelBox.add(lastSyncDateLabel); + labelBox.add(lastUpdate); + + //box to hold the delete button and the test sync button + Box deleteBox = new Box(BoxLayout.PAGE_AXIS); + //option to delete url + deleteButton = new JButton(getResourceMap().getString("deleteButton")); + deleteButton.addActionListener(this); + deleteButton.setActionCommand("deleteURL"); + + testSyncUrlButton = new JButton(getResourceMap().getString("testSyncButton")); + testSyncUrlButton.addActionListener(this); + testSyncUrlButton.setActionCommand("testURL"); + + + deleteBox.add(deleteButton); + deleteBox.add(testSyncUrlButton); + + // button to close + JButton closeButton = new JButton(); + closeButton.setAction(getContext().getActionMap(this).get("closeView")); + + //adding components to the main one + + configComponent.add(urlPanel, BorderLayout.NORTH); + configComponent.add(labelBox, BorderLayout.WEST); + configComponent.add(deleteBox, BorderLayout.EAST); + configComponent.add(closeButton, BorderLayout.SOUTH); + + // color fix on linux ? + configComponent.setBackground(urlPanel.getBackground()); + // set minimum size to prevent "packed size" (too big) + configComponent.setMinimumSize(new Dimension(100, 100)); + + return configComponent; + } + + /** + * Close action. + */ + @org.jdesktop.application.Action + public void closeView() { + getApplication().hide(this); + } + + + /** + * Add annotation checkbox checked. + */ + @Action + public boolean isIncludingAnnotations() { + boolean ischeckedIncludeAnnotations = checkIncludesAnnotations.isSelected(); + task.getSynchronizingInfo(((SyncInfo) urlComboBox.getSelectedItem()).getSyncURL()).setIsWithAnnotations(ischeckedIncludeAnnotations); + if (log.isDebugEnabled()) { + log.debug("Inclusion of annotations in sync changed"); + } + return ischeckedIncludeAnnotations; + } + + /** + * Active sync checkbox checked, activates sync + */ + @Action + public boolean isActiveSync() { + boolean isActiveSyncURL = checkIsActiveSync.isSelected(); + task.getSynchronizingInfo(((SyncInfo) urlComboBox.getSelectedItem()).getSyncURL()).setIsActiveSync(isActiveSyncURL); + if (log.isDebugEnabled()) { + log.debug("Activity of url changed "); + } + return isActiveSyncURL; + } + + /** + * Method to display an error message + * @param errorMessage the message to display + * @param titleBar the title of the frame + */ + public static void errorBox(String errorMessage, String titleBar) + { + JOptionPane.showMessageDialog(null, errorMessage, titleBar, JOptionPane.ERROR_MESSAGE); + } + + /** + * Method to display an info message + * @param infoMessage the message to display + * @param titleBar the title of the frame + */ + public static void infoBox(String infoMessage, String titleBar) { + JOptionPane.showMessageDialog(null, infoMessage, titleBar, JOptionPane.INFORMATION_MESSAGE); + } + + + /** + * when an item is added to the list, + * add it to the url displayed, and to the syncInfo of the task + */ + public void itemAdded(String urlToAdd){ + if ((urlToAdd != null) && ((!task.getSynchronizingURLList().contains(urlToAdd)))) { + SyncInfo infoToAdd = new SyncInfo(urlToAdd); + urlComboBox.addItem(infoToAdd); + task.addSyncInfo(urlToAdd); + core.getData().changeSyncInfo(task, infoToAdd); + if (log.isDebugEnabled()) { + log.debug("New SyncInfo with URL : " + urlToAdd); + } + } + + } + + @Override + public void itemStateChanged(ItemEvent itemEvent) { + if (itemEvent.getStateChange()== ItemEvent.SELECTED) { + if (urlComboBox.getSelectedItem() != null) { + SyncInfo syncInfo; + if (urlComboBox.getSelectedItem() instanceof String) { + syncInfo = new SyncInfo((String)urlComboBox.getSelectedItem()); + } + else { + syncInfo = (SyncInfo) urlComboBox.getSelectedItem(); + } + String urlToDisplay = syncInfo.getSyncURL(); + if (!urlToDisplay.isEmpty()) { + if (log.isDebugEnabled()) { + log.debug("Selected an object : " + urlToDisplay); + } + if (checkIsActiveSync != null) { + checkIsActiveSync.setSelected(syncInfo.getActiveSync()); + } + if (checkIncludesAnnotations != null) { + checkIncludesAnnotations.setSelected(syncInfo.getIsWithAnnotations()); + } + //display last Sync Time + if (lastUpdate != null && syncInfo.getLastSync() != null) { + if (syncInfo.getLastSync().isAfter(LocalDateTime.MIN)) { + lastUpdate.setText(syncInfo.getLastSync().toString()); + lastSyncDateLabel.setVisible(true); + } + else { + lastUpdate.setText(""); + + lastSyncDateLabel.setVisible(false); + } + } + } + } + } + } + + @Override + public void actionPerformed(ActionEvent actionEvent) { + String actionCommand = actionEvent.getActionCommand(); + if ("comboBox".equals(actionCommand)) { + if (urlComboBox.getSelectedItem() instanceof String) { + String urlToAdd = (String) urlComboBox.getSelectedItem(); + if (!task.getSynchronizingInfoList().contains(urlToAdd)) { + if (log.isDebugEnabled()) { + log.debug("New URL added"); + } + itemAdded(urlToAdd); + } + } + } + else if ("deleteURL".equals(actionCommand)) { + SyncInfo infoToUse = (SyncInfo) urlComboBox.getSelectedItem(); + //if the delete button has been clicked, delete the task (if it exists) + if ((infoToUse != null) && (task.getSynchronizingInfoList().contains(infoToUse))) { + task.removeSyncInfo(infoToUse); + urlComboBox.removeItem(infoToUse); + core.getData().deleteSyncInfo(task, infoToUse); + } + else { + errorBox(getResourceMap().getString("deleteErrorMessage"), getResourceMap().getString("deleteErrorTitle")); + } + } + else if ("testURL".equals(actionCommand)) { + SyncInfo infoToTest = (SyncInfo) urlComboBox.getSelectedItem(); + //if the test button has been clicked, test the sync on the URL and returns a message to the user + //tests only if the info exists + if ((infoToTest != null) && task.getSynchronizingInfoList().contains(infoToTest)) { + JsonObject testObject = TimerTaskHelper.taskURLToJSONObject(task, infoToTest.getSyncURL(), isIncludingAnnotations(), timezone); + int responseCode = TimerTaskSynchronizer.synchronizeTaskOnURL(testObject); + if (responseCode > 199 && responseCode < 300) { + infoBox(getResourceMap().getString("testSyncSuccessMessage"), getResourceMap().getString("testSyncSuccessTitle")); + } + else { + errorBox(getResourceMap().getString("testSyncFailureMessage"), getResourceMap().getString("testSyncFailureTitle")); + } + } + } + else { + if (log.isDebugEnabled()) { + log.debug("Action performed. Action: " + actionEvent.getActionCommand()); + } + } + } +} \ No newline at end of file diff --git a/src/main/java/org/chorem/jtimer/ui/report/TimerTaskUpdaterView.java b/src/main/java/org/chorem/jtimer/ui/report/TimerTaskUpdaterView.java deleted file mode 100644 index 929c530..0000000 --- a/src/main/java/org/chorem/jtimer/ui/report/TimerTaskUpdaterView.java +++ /dev/null @@ -1,671 +0,0 @@ - -/* - * #%L - * jTimer - * %% - * Copyright (C) 2008 - 2016 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 - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ -package org.chorem.jtimer.ui.report; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonObject; - -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.SyncInfo; -import org.chorem.jtimer.entities.TimerTask; -import org.chorem.jtimer.io.TimerTaskSynchronizer; -import org.jdesktop.application.Action; -import org.jdesktop.application.Application; -import org.jdesktop.application.FrameView; -import org.jdesktop.swingx.JXDatePicker; -import org.jdesktop.swingx.JXTaskPane; -import org.jdesktop.swingx.JXTaskPaneContainer; - -import javax.swing.BorderFactory; -import javax.swing.JButton; -import javax.swing.JCheckBox; -import javax.swing.JComboBox; -import javax.swing.JComponent; -import javax.swing.JLabel; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JScrollPane; -import javax.swing.JSplitPane; -import javax.swing.JTextArea; -import javax.swing.event.DocumentEvent; -import javax.swing.event.DocumentListener; - -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Font; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.GridLayout; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; - -import java.text.DateFormat; -import java.time.LocalDate; -import java.time.LocalDateTime; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.Date; -import java.util.List; - -import static org.chorem.jtimer.entities.TimerTaskHelper.taskToJSONFormat; - -/** - * Updates UI - * - * Created by servantie on 13/05/16. - */ -public class TimerTaskUpdaterView extends FrameView implements DocumentListener, ActionListener, ItemListener { - - /** Class logger */ - protected static Log log = LogFactory.getLog(TimerTaskUpdaterView.class); - - /** Timer core. */ - protected TimerCore core; - - /** Include annotations on updates */ - protected JCheckBox checkIncludesAnnotations; - - /** Activate a sync URL */ - protected JCheckBox checkIsActiveSync; - - /** button to delete a URL */ - protected JButton deleteButton; - - /** Date pickers, from... to */ - protected JXDatePicker datePickerFrom, datePickerTo; - - /** update output view*/ - protected JTextArea updateArea; - - /** task in json format (1/synchronizing url) */ - protected List<JsonObject> updateJson; - - /** ComboBox of URLs */ - protected JComboBox<String> urlComboBox; - - /** LastSync */ - protected JLabel lastUpdate; - - /** task to update */ - protected TimerTask task; - - /** can update */ - protected boolean canUpdate; - - /** timezone */ - protected String timezone; - - /** - * UpdaterView constructor. - * @param application parent reference - * @param core core reference - * @param task the task to update - */ - public TimerTaskUpdaterView(Application application, TimerCore core, TimerTask task) { - - super(application); - // modify frame name - getFrame().setName("updateFrame"); - getFrame().setTitle(getResourceMap().getString("updateTitle")); - - this.core = core; - this.task = task; - timezone = "+01:00"; - updateJson = new ArrayList<>(); - - setComponent(getMainComponent()); - - - } - - /** - * Get main view component. - * - * TODO use less complicated UI (no gbl) - * @return main component - */ - protected JComponent getMainComponent() { - - JPanel configComponent = new JXTaskPaneContainer(); - - // panel for options - JXTaskPane panelGeneral = new JXTaskPane(getResourceMap().getString("updateGeneral")); - panelGeneral.setLayout(new GridBagLayout()); - panelGeneral.setSpecial(true); - - // first date picker - JLabel labelFrom = new JLabel(getResourceMap().getString("updateFrom")); - panelGeneral.add(labelFrom, new GridBagConstraints(0, 0, 1, 1, 0, 0, - GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(1, 1, 1, 1), 0, 0)); - datePickerFrom = new JXDatePicker(); - datePickerFrom.getMonthView().setDayForeground(Calendar.SUNDAY, Color.RED); - datePickerFrom.setFormats(DateFormat.getDateInstance(DateFormat.FULL)); - panelGeneral.add(datePickerFrom, new GridBagConstraints(1, 0, 1, 1, 1, 0, - GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(1, 1, 1, 1), 0, 0)); - - // second date picker - JLabel labelTo = new JLabel(getResourceMap().getString("updateTo")); - panelGeneral.add(labelTo, new GridBagConstraints(0, 1, 1, 1, 0, 0, - GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(1, 1, 1, 1), 0, 0)); - datePickerTo = new JXDatePicker(); - datePickerTo.getMonthView().setDayForeground(Calendar.SUNDAY, Color.RED); - datePickerTo.setFormats(DateFormat.getDateInstance(DateFormat.FULL)); - panelGeneral.add(datePickerTo, new GridBagConstraints(1, 1, 1, 1, 0, 0, - GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(1, 1, 1, 1), 0, 0)); - - // set current week by default - currentWeek(); - - // action button to show current or previous week - JButton currentWeekButton = new JButton(); - currentWeekButton.setBorder(BorderFactory.createEmptyBorder()); - currentWeekButton.setAction(getContext().getActionMap(this).get("currentWeek")); - panelGeneral.add(currentWeekButton, new GridBagConstraints(2, 0, 1, 1, 0, 0, - GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(1, 1, 1, 1), 0, 0)); - JButton previousWeekButton = new JButton(); - previousWeekButton.setBorder(BorderFactory.createEmptyBorder()); - previousWeekButton.setAction(getContext().getActionMap(this).get("previousWeek")); - panelGeneral.add(previousWeekButton, new GridBagConstraints(2, 1, 1, 1, 0, 0, - GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(1, 1, 1, 1), 0, 0)); - - - // Option for period grouping - 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")); - panelOption.setLayout(new GridBagLayout()); - - - //checkbox to include annotations - checkIncludesAnnotations = new JCheckBox(); - checkIncludesAnnotations.setAction(getContext().getActionMap(this).get("isIncludingAnnotations")); - panelOption.add(checkIncludesAnnotations, new GridBagConstraints(2, 4, 1, 1, 0, 0, - GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(4, 1, 1, 1), 0, 0)); - - //url combobox - JLabel urlcomboBoxLabel = new JLabel(getResourceMap().getString("urlComboLabel")); - urlComboBox = new JComboBox<>(); - //make it editable to add new urls - urlComboBox.setEditable(true); - urlComboBox.addItemListener(this); - urlComboBox.addActionListener(this); - //add the urls to the combobox - for (String url : task.getSynchronizingURLList()) { - urlComboBox.addItem(url); - } - - urlComboBox.setActionCommand("comboBox"); - panelOption.add(urlcomboBoxLabel, new GridBagConstraints(1, 1, 1, 1, 0, 0, - GridBagConstraints.WEST, GridBagConstraints.VERTICAL, new Insets(1,1,1,1), 0, 0)); - panelOption.add(urlComboBox, new GridBagConstraints(2, 1, 1, 1, 0, 0, - GridBagConstraints.WEST, GridBagConstraints.VERTICAL, new Insets(1, 1, 1, 1), 0, 0)); - - //display last Sync time - JLabel lastSyncDateLabel = new JLabel(getResourceMap().getString("lastUpdateLabel")); - panelOption.add(lastSyncDateLabel, new GridBagConstraints(1, 3, 1, 1, 0, 0, - GridBagConstraints.WEST, GridBagConstraints.VERTICAL, new Insets(3, 1, 1, 1), 0, 0)); - - lastUpdate = new JLabel(); - //checkbox for active sync - checkIsActiveSync = new JCheckBox(); - checkIsActiveSync.addActionListener(this); - checkIsActiveSync.setAction(getContext().getActionMap(this).get("isActiveSync")); - if (urlComboBox.getSelectedItem() != null) { - String selectedURL = (String) urlComboBox.getSelectedItem(); - if (task.getSynchronizingURLList().contains(selectedURL)){ - SyncInfo syncInfo = task.getSynchronizingInfo(selectedURL); - LocalDateTime lastSyncTime = syncInfo.getLastSync(); - //if there has been an update before, display its date - if ((lastSyncTime != null) && lastSyncTime.isAfter(LocalDateTime.MIN)) { - lastUpdate.setText(lastSyncTime.toString()); - //logging change of lastSync - if (log.isDebugEnabled()) { - log.debug("Last Sync time loaded : " + lastSyncTime.toString()); - } - } - else { - if (log.isDebugEnabled()) { - log.debug("No Last Sync time loaded"); - } - } - checkIsActiveSync.setSelected(task.getSynchronizingInfo((String) urlComboBox.getSelectedItem()).getActiveSync()); - } - } - - //option to delete url - deleteButton = new JButton(getResourceMap().getString("deleteButton")); - deleteButton.addActionListener(this); - deleteButton.setActionCommand("deleteURL"); - - panelOption.add(deleteButton, new GridBagConstraints(1, 5, 1, 1, 0, 0, - GridBagConstraints.WEST, GridBagConstraints.VERTICAL, new Insets(2, 1, 1, 1), 0, 0)); - panelOption.add(lastUpdate, new GridBagConstraints(2, 3, 1, 1, 0, 0, - GridBagConstraints.WEST, GridBagConstraints.VERTICAL, new Insets(1, 3, 1, 1), 0, 0)); - panelOption.add(checkIsActiveSync, new GridBagConstraints(1, 4, 1, 1, 0, 0, - GridBagConstraints.WEST, GridBagConstraints.VERTICAL, new Insets(4, 1, 1, 1), 0, 0)); - - configComponent.add(panelGeneral); - configComponent.add(panelOption); - - // panel for update output text - JPanel panelUpdate = new JPanel(new GridBagLayout()); - - updateArea = new JTextArea(); - updateArea.setFont(new Font("Courier", Font.PLAIN, 12)); - updateArea.getDocument().addDocumentListener(this); - JScrollPane jspupdate = new JScrollPane(updateArea); - panelUpdate.add(jspupdate, new GridBagConstraints(0, 0, 3, 1, 1, 1, - GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(1, 1, 1, 1), 0, 0)); - - // buttons - JButton generateButton = new JButton(); - generateButton.setAction(getContext().getActionMap(this).get("generateUpdate")); - panelUpdate.add(generateButton, new GridBagConstraints(0, 1, 1, 1, 1, 0, - GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(1, 1, 1, 1), 0, 0)); - - JButton sendUpdateButton = new JButton(); - sendUpdateButton.setAction(getContext().getActionMap(this).get("sendUpdate")); - panelUpdate.add(sendUpdateButton, new GridBagConstraints(1, 1, 1, 1, 1, 0, - GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(1, 1, 1, 1), 0, 0)); - - JButton closeButton = new JButton(); - closeButton.setAction(getContext().getActionMap(this).get("closeView")); - panelUpdate.add(closeButton, new GridBagConstraints(2, 1, 1, 1, 1, 0, - GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(1, 1, 1, 1), 0, 0)); - - // color fix on linux ? - configComponent.setBackground(panelUpdate.getBackground()); - // set minimum size to prevent "packed size" (too big) - configComponent.setMinimumSize(new Dimension(200, 0)); - - JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, configComponent, panelUpdate); - splitPane.setOneTouchExpandable(true); - return splitPane; - } - - /** - * Select current week in date pickers. - */ - @org.jdesktop.application.Action - public void currentWeek() { - fillPickerDates(0); - } - - /** - * Display previous week in date pickers. - */ - @org.jdesktop.application.Action - public void previousWeek() { - fillPickerDates(-1); - } - - /** - * 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). - * - * @param delay delay to add to current week - */ - protected void fillPickerDates(int delay) { - // init dates - Calendar calendarBegin = Calendar.getInstance(); - int firstDayOfWeek = JTimer.config.getReportFirstDayOfWeek(); - if (firstDayOfWeek <= 0 || firstDayOfWeek > 7) { - 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(); - calendarEnd.add(Calendar.WEEK_OF_YEAR, 1); - calendarEnd.add(Calendar.DAY_OF_YEAR, -1); // take the day before - - // apply delai - calendarBegin.add(Calendar.WEEK_OF_YEAR, delay); - calendarEnd.add(Calendar.WEEK_OF_YEAR, delay); - - datePickerFrom.setDate(calendarBegin.getTime()); - datePickerTo.setDate(calendarEnd.getTime()); - } - - /** - * Close action. - */ - @org.jdesktop.application.Action - public void closeView() { - getApplication().hide(this); - } - - /** - * Make update. - * - * Set content in {@link #updateArea} text area. - */ - @org.jdesktop.application.Action - public void generateUpdate() { - //reinitialiser les trucs - updateArea.setText(""); - updateJson = new ArrayList<>(); - //get the various objects for updates (on several urls) - updateJson = taskToJSONFormat(task, datePickerFrom.getDate(), - datePickerTo.getDate(), isIncludingAnnotations(), timezone); - if (!updateJson.isEmpty()) { - String urlSelected = (String) urlComboBox.getSelectedItem(); - //to make it human readable - Gson gson = new GsonBuilder().setPrettyPrinting().create(); - StringBuilder builder = new StringBuilder(); - for (JsonObject object : updateJson) { - if (urlSelected.equals(object.get("URL").getAsString())) { - builder.append(gson.toJson(object)); - } - } - if (task.getSynchronizingInfo(urlSelected).getActiveSync()) { - updateArea.setText(builder.toString()); - } - } else { - updateArea.setText(getResourceMap().getString("isNotActiveURL")); - } - } - - /** - * Add annotation checkbox checked. - */ - @Action - public boolean isIncludingAnnotations() { - boolean ischeckedIncludeAnnotations = checkIncludesAnnotations.isSelected(); - return ischeckedIncludeAnnotations; - } - - /** - * Active sync checkbox checked, activates sync - */ - @Action - public boolean isActiveSync() { - boolean isActiveSyncURL = checkIsActiveSync.isSelected(); - task.getSynchronizingInfo((String) urlComboBox.getSelectedItem()).setIsActiveSync(isActiveSyncURL); - if (log.isDebugEnabled()) { - log.debug("Activity of url changed "); - } - return isActiveSyncURL; - } - - /** - * Can update ? - * - * @return true if can update - */ - public boolean isUpdatingEnabled() { - return canUpdate; - } - - /** - * Change can update property. - * - * @param enabled can update - */ - public void setUpdatingEnabled(boolean enabled) { - boolean oldValue = canUpdate; - canUpdate = enabled; - firePropertyChange("updatingEnabled", oldValue, canUpdate); - } - - /** - * sends the sync of the task associated with the current url selected - * in the combobox (urlComboBox) - */ - @Action(enabledProperty = "updatingEnabled") - public void sendUpdate() { - String urlSelected = (String) urlComboBox.getSelectedItem(); - for (JsonObject object : updateJson) { - if (urlSelected.equals(object.get("URL").getAsString())) { - synchronizeTaskOnURL(task, object); - } - } - } - - /** - * Sends the update of a task to one url - * @param task task to update - * @param object json of task info - */ - public void synchronizeTaskOnURL(TimerTask task, JsonObject object) { - int syncAnswer = TimerTaskSynchronizer.synchronizeTaskOnURL(object); - String syncURL = object.get("URL").getAsString(); - String message =""; - String title = ""; - boolean hasUpdated = false; - if ((syncAnswer == 200) || (syncAnswer == 201) || (syncAnswer == 202)) { - hasUpdated = true; - if (log.isDebugEnabled()) { - log.debug("Update accepted for URL : " + syncURL); - } - } - else if (syncAnswer == 400) { - if (log.isDebugEnabled()) { - log.debug("Bad Request for URL : " + syncURL); - } - message = getResourceMap().getString("action.update400"); - } - else if (syncAnswer == 404) { - if (log.isDebugEnabled()) { - log.debug("URL Not Found : " + syncURL); - } - message = getResourceMap().getString("action.update404"); - } - else if (syncAnswer == 500) { - if (log.isDebugEnabled()) { - log.debug("Server Error on URL : " + syncURL); - } - message = getResourceMap().getString("action.update500"); - } - else { - if (log.isDebugEnabled()) { - log.debug("Error"); - } - message = getResourceMap().getString("action.updateError"); - } - if (hasUpdated) { - task.setLastSync(LocalDateTime.now(), syncURL); - core.getData().changeSyncInfo(task, syncURL); - } else if (!message.isEmpty()){ - errorBox(message, title); - } - //advise that it's done, to grey-out the send sync button - boolean oldValue = canUpdate; - canUpdate = false; - firePropertyChange("updatingEnabled", oldValue, canUpdate); - } - - /** - * Method to display an error message (in case the sync goes wrong) - * @param errorMessage the message to display - * @param titleBar the title of the frame - */ - public static void errorBox(String errorMessage, String titleBar) - { - JOptionPane.showMessageDialog(null, errorMessage, titleBar, JOptionPane.ERROR_MESSAGE); - } - - @Override - public void changedUpdate(DocumentEvent e) { - documentChanged(); - } - - @Override - public void insertUpdate(DocumentEvent e) { - documentChanged(); - } - - @Override - public void removeUpdate(DocumentEvent e) { - documentChanged(); - } - - /** - * Document content changed. - * - * Update can send update property. - */ - protected void documentChanged() { - setUpdatingEnabled(updateArea.getText().trim().length() > 0); - } - - /** - * when an item is added to the list, - * add it to the url displayed, and to the syncInfo of the task - */ - public void itemAdded(){ - String urlToAdd = (String) urlComboBox.getSelectedItem(); - if ((urlToAdd != null) && (!urlToAdd.isEmpty()) && (!task.getSynchronizingURLList().contains(urlToAdd))) { - urlComboBox.addItem(urlToAdd); - task.addSyncInfo(urlToAdd); - core.getData().changeSyncInfo(task, urlToAdd); - if (log.isDebugEnabled()) { - log.debug("New SyncInfo with URL : " + urlToAdd); - } - } - - } - - @Override - public void itemStateChanged(ItemEvent itemEvent) { - if (itemEvent.getStateChange()== ItemEvent.SELECTED) { - if (urlComboBox.getSelectedItem() != null) { - String urlToDisplay = urlComboBox.getSelectedItem().toString(); - if (!urlToDisplay.isEmpty()) { - if (log.isDebugEnabled()) { - log.debug("Selected an object : " + urlComboBox.getSelectedItem().toString()); - } - if (checkIsActiveSync != null) { - checkIsActiveSync.setSelected(task.getSynchronizingInfo(urlToDisplay).getActiveSync()); - } - //display last Sync Time - if (lastUpdate != null && task.getSynchronizingInfo(urlToDisplay).getLastSync() != null) { - if (task.getSynchronizingInfo(urlToDisplay).getLastSync().isAfter(LocalDateTime.MIN)) { - lastUpdate.setText(task.getSynchronizingInfo(urlToDisplay).getLastSync().toString()); - } - else { - lastUpdate.setText(""); - } - } - } - } - } - } - - @Override - public void actionPerformed(ActionEvent actionEvent) { - String actionCommand = actionEvent.getActionCommand(); - if ("comboBox".equals(actionCommand)) { - String urlToAdd = (String) urlComboBox.getSelectedItem(); - if (!task.getSynchronizingURLList().contains(urlToAdd)) { - if (log.isDebugEnabled()) { - log.debug("New URL added"); - } - itemAdded(); - } - } - else if ("deleteURL".equals(actionCommand)) { - String urlToUse = (String) urlComboBox.getSelectedItem(); - //if the delete button has been clicked, delete the task (if it exists) - if ((urlToUse != null) && !urlToUse.isEmpty() && (task.getSynchronizingURLList().contains(urlToUse))) { - task.removeSyncInfo(urlToUse); - urlComboBox.removeItem(urlToUse); - core.getData().deleteSyncInfo(task, urlToUse); - } - else { - errorBox(getResourceMap().getString("deleteErrorMessage"), getResourceMap().getString("deleteErrorTitle")); - } - } - else { - if (log.isDebugEnabled()) { - log.debug("Action performed, not a new URL. Action: " + actionEvent.getActionCommand()); - } - } - } -} \ No newline at end of file diff --git a/src/main/java/org/chorem/jtimer/ui/systray/SystrayManager.java b/src/main/java/org/chorem/jtimer/ui/systray/SystrayManager.java index 700b0b8..322ffca 100644 --- a/src/main/java/org/chorem/jtimer/ui/systray/SystrayManager.java +++ b/src/main/java/org/chorem/jtimer/ui/systray/SystrayManager.java @@ -33,10 +33,8 @@ import java.awt.event.MouseListener; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.awt.event.WindowListener; - import javax.swing.JMenuItem; import javax.swing.JPopupMenu; - import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.jtimer.JTimer; @@ -194,6 +192,11 @@ public class SystrayManager extends WindowAdapter implements ActionListener, Dat } } + + + /* + * @see org.chorem.jtimer.ui.systray.SystrayManager#startTask(org.chorem.jtimer.entities.TimerTask) + */ @Override public void startTask(TimerTask task) { startStopTask(task, true); diff --git a/src/main/java/org/chorem/jtimer/ui/treetable/ProjectsAndTasksModel.java b/src/main/java/org/chorem/jtimer/ui/treetable/ProjectsAndTasksModel.java index d365546..230db7e 100644 --- a/src/main/java/org/chorem/jtimer/ui/treetable/ProjectsAndTasksModel.java +++ b/src/main/java/org/chorem/jtimer/ui/treetable/ProjectsAndTasksModel.java @@ -29,11 +29,9 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.stream.Collectors; - import javax.swing.SwingUtilities; import javax.swing.table.TableColumn; import javax.swing.tree.TreePath; - import org.apache.commons.lang3.time.DurationFormatUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; diff --git a/src/main/java/org/chorem/jtimer/ui/treetable/ProjectsAndTasksRunningCellRenderer.java b/src/main/java/org/chorem/jtimer/ui/treetable/ProjectsAndTasksRunningCellRenderer.java index e8e41dd..905fa9d 100644 --- a/src/main/java/org/chorem/jtimer/ui/treetable/ProjectsAndTasksRunningCellRenderer.java +++ b/src/main/java/org/chorem/jtimer/ui/treetable/ProjectsAndTasksRunningCellRenderer.java @@ -156,7 +156,6 @@ public class ProjectsAndTasksRunningCellRenderer extends ProjectsAndTasksCellRen } } - @Override public void startTask(TimerTask task) { diff --git a/src/main/resources/org/chorem/jtimer/resources/JTimer.properties b/src/main/resources/org/chorem/jtimer/resources/JTimer.properties index 5233547..4120155 100644 --- a/src/main/resources/org/chorem/jtimer/resources/JTimer.properties +++ b/src/main/resources/org/chorem/jtimer/resources/JTimer.properties @@ -62,9 +62,9 @@ editTask.Action.text = &Edit Task editTask.Action.accelerator = F2 editTask.Action.shortDescription = Edit task -updateTask.Action.text = &Synchronise Task +updateTask.Action.text = &Edit Synchronization Info updateTask.Action.accelerator = F5 -updateTask.Action.shortDescription = Synchronise task +updateTask.Action.shortDescription = Edit Synchronization Info closeTask.Action.text = &Open/Close Task closeTask.Action.accelerator = control O diff --git a/src/main/resources/org/chorem/jtimer/resources/JTimer_fr.properties b/src/main/resources/org/chorem/jtimer/resources/JTimer_fr.properties index c7ab52b..b070bbf 100644 --- a/src/main/resources/org/chorem/jtimer/resources/JTimer_fr.properties +++ b/src/main/resources/org/chorem/jtimer/resources/JTimer_fr.properties @@ -42,8 +42,8 @@ editTask.Action.text = \u00C9dition de la t\u00E2ch&e editTask.Action.shortDescription = \u00C9dition de la t\u00E2che -updateTask.Action.text = &Synchroniser la t\u00E2che -updateTask.Action.shortDescription = Synchroniser +updateTask.Action.text = &\u00C9dition de la synchronisation +updateTask.Action.shortDescription = Edition de la synchronisation closeTask.Action.text = &Ouvrir/Fermer la t\u00E2che closeTask.Action.shortDescription = Ouvrir ou fermer la t\u00E2che diff --git a/src/main/resources/org/chorem/jtimer/ui/report/resources/TimerTaskSyncInfoEditor.properties b/src/main/resources/org/chorem/jtimer/ui/report/resources/TimerTaskSyncInfoEditor.properties new file mode 100644 index 0000000..990a73e --- /dev/null +++ b/src/main/resources/org/chorem/jtimer/ui/report/resources/TimerTaskSyncInfoEditor.properties @@ -0,0 +1,46 @@ +### +# #%L +# jTimer +# %% +# Copyright (C) 2007 - 2016 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 +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public +# License along with this program. If not, see +# <http://www.gnu.org/licenses/gpl-3.0.html>. +# #L% +### +syncTitle=${Application.title} - Edition of Synchronization Info +syncGeneral=General +syncOptions=Options + +lastUpdateLabel=Last Synchronization at: +urlComboLabel = Synchronization Url: + +updateAnnotations.Action.text = Include annotations +updateAnnotations.Action.shortDescription = Include annotations + +closeView.Action.text = &Close +closeView.Action.icon = dialog-close.png +closeView.Action.shortDescription = Close + +deleteButton = Delete URL +deleteErrorMessage = No URL to delete +deleteErrorTitle = Deletion error + +testSyncButton = Test URL +testSyncSuccessMessage = Synchronization test successful ! +testSyncSuccessTitle = Successful test +testSyncFailureMessage = Test failed to synchronize, check the URL ? +testSyncFailureTitle = Synchronization test failure + +isActiveSync.Action.text = Active synchronization \ No newline at end of file diff --git a/src/main/resources/org/chorem/jtimer/ui/report/resources/TimerTaskSyncInfoEditor_fr.properties b/src/main/resources/org/chorem/jtimer/ui/report/resources/TimerTaskSyncInfoEditor_fr.properties new file mode 100644 index 0000000..d3e733c --- /dev/null +++ b/src/main/resources/org/chorem/jtimer/ui/report/resources/TimerTaskSyncInfoEditor_fr.properties @@ -0,0 +1,46 @@ +### +# #%L +# jTimer +# %% +# Copyright (C) 2007 - 2016 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 +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public +# License along with this program. If not, see +# <http://www.gnu.org/licenses/gpl-3.0.html>. +# #L% +### +# update i18n +syncTitle=${Application.title} - Edition de la Synchronisation +syncGeneral=G\u00E9n\u00E9ral +syncOptions=Options + +lastUpdateLabel=Derni\u00E8re synchronisation : +urlComboLabel=Url de synchronisation : + +isIncludingAnnotations.Action.text = Inclure les annotations + +closeView.Action.text = &Fermer +closeView.Action.icon = dialog-close.png +closeView.Action.shortDescription = Fermer + +deleteButton = Supprimer l'URL +deleteErrorMessage = Aucune URL \u00E0 supprimer +deleteErrorTitle = Erreur de suppression + +testSyncButton = Tester l'URL +testSyncSuccessMessage = Test r\u00E9ussi, URL de synchronisation valide ! +testSyncSuccessTitle = Test r\u00E9ussi +testSyncFailureMessage = Test \u00E9chou\u00E9, v\u00E9rifier l'URL ? +testSyncFailureTitle = Echec du test de synchronisation + +isActiveSync.Action.text = Synchronisation Active \ No newline at end of file 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 deleted file mode 100644 index 6de32f8..0000000 --- a/src/main/resources/org/chorem/jtimer/ui/report/resources/TimerTaskUpdaterView.properties +++ /dev/null @@ -1,74 +0,0 @@ -### -# #%L -# jTimer -# %% -# Copyright (C) 2007 - 2016 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 -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public -# License along with this program. If not, see -# <http://www.gnu.org/licenses/gpl-3.0.html>. -# #L% -### -updateTitle=${Application.title} - Synchronization -updateGeneral=General -updateOptions=Options -updateFrom=From : -updateTo=To : - -lastUpdateLabel=Last Synchronization at: -urlComboLabel = Synchronization Url: -isNotActiveURL = Inactive Synchronization - - -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 - -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 -generateUpdate.Action.shortDescription = Generate synchronisation -updateSyncTime = No recent synchronization - -sendUpdate.Action.text = &Send -sendUpdate.Action.icon = mail-forward.png -sendUpdate.Action.shortDescription = Send synchronization - -closeView.Action.text = &Close -closeView.Action.icon = dialog-close.png -closeView.Action.shortDescription = Close - -action.updateError = Synchronization failed -action.update400 = Bad Request -action.update404 = Not found -action.update500 = Server error -action.updateErrorTitle = Synchronization error -action.updateEncodingError = Encoding error -action.updateURLError = URL error - -deleteButton = Delete URL - -deleteErrorMessage = No URL to delete -deleteErrorTitle = Deletion error - -isActiveSync.Action.text = Active synchronization \ No newline at end of file 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 deleted file mode 100644 index 768678c..0000000 --- a/src/main/resources/org/chorem/jtimer/ui/report/resources/TimerTaskUpdaterView_fr.properties +++ /dev/null @@ -1,73 +0,0 @@ -### -# #%L -# jTimer -# %% -# Copyright (C) 2007 - 2016 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 -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public -# License along with this program. If not, see -# <http://www.gnu.org/licenses/gpl-3.0.html>. -# #L% -### -# update i18n -updateTitle=${Application.title} - Synchronisation -updateGeneral=G\u00E9n\u00E9ral -updateOptions=Options -updateFrom=De : -updateTo=\u00C0 : - -lastUpdateLabel=Derni\u00E8re synchronisation : -urlComboLabel=Url de synchronisation : -isNotActiveURL = Synchronisation vers cette URL d\u00E9sactiv\u00E9e - - -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 - -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 -generateUpdate.Action.shortDescription = G\u00E9n\u00E9rer les donn\u00E9es de synchronisation -updateSyncTime = Pas de synchronisation r\u00E9cente - -sendUpdate.Action.text = &Envoyer -sendUpdate.Action.icon = mail-forward.png -sendUpdate.Action.shortDescription = Envoyer les donn\u00E9es - -closeView.Action.text = &Fermer -closeView.Action.icon = dialog-close.png -closeView.Action.shortDescription = Fermer - -action.updateError = Probl\u00E8me avec la connexion -action.updateErrorTitle = Erreur de synchronisation -action.update400 = Mauvaise requ\u00EAte -action.update404 = Mauvaise URL -action.update500 = Erreur du serveur -action.updateEncodingError = Erreur d'encodage -action.updateURLError = Erreur d'URL - -deleteButton = Supprimer l'URL -deleteErrorMessage = Aucune URL \u00E0 supprimer -deleteErrorTitle = Erreur de suppression - -isActiveSync.Action.text = Synchronisation Active \ No newline at end of file diff --git a/src/test/java/org/chorem/jtimer/entities/TimerTaskTest.java b/src/test/java/org/chorem/jtimer/entities/TimerTaskTest.java index 6db7cb0..0126c0a 100644 --- a/src/test/java/org/chorem/jtimer/entities/TimerTaskTest.java +++ b/src/test/java/org/chorem/jtimer/entities/TimerTaskTest.java @@ -144,18 +144,18 @@ public class TimerTaskTest extends AbstractJTimerTest { public void removeSyncInfoTest() { TimerTask task = new TimerTask(); - String url1 = "localhost/test"; - String url2 = "localhost/other"; + SyncInfo info1 = new SyncInfo("localhost/test"); + SyncInfo info2 = new SyncInfo("localhost/other"); - task.addSyncInfo(url1); - task.addSyncInfo(url2); + task.addSyncInfo(info1); + task.addSyncInfo(info2); Assert.assertTrue(task.getSynchronizingInfoList().size() == 2); - task.removeSyncInfo(url1); + task.removeSyncInfo(info1); Assert.assertTrue(task.getSynchronizingInfoList().size() == 1); - Assert.assertTrue(task.getSynchronizingURLList().contains(url2)); + Assert.assertTrue(task.getSynchronizingInfoList().contains(info2)); } } diff --git a/src/test/resources/testdata/41.task.sync b/src/test/resources/testdata/41.task.sync index 01cb6d9..f4d9859 100644 --- a/src/test/resources/testdata/41.task.sync +++ b/src/test/resources/testdata/41.task.sync @@ -1,3 +1,3 @@ Format: 1.2 SyncInfo: -http://localhost:3000 true +http://localhost:3000 true false -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.