branch feature/sync updated (2f92619 -> 2d14fce)
This is an automated email from the git hooks/post-receive script. New change to branch feature/sync in repository jtimer. See https://gitlab.nuiton.org/chorem/jtimer.git from 2f92619 logs and corrected an actioncommand, removed useless null checks new af8bae3 revert of the syncAtStartUp new b708354 turned the jcombobox into a jtable for url edition new 2d14fce date format in jtable display + width of cells 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 2d14fcefe71c28ec733b4a2ce396c7afa54890b9 Author: servantie <servantie.c@gmail.com> Date: Wed Jul 20 10:13:26 2016 +0200 date format in jtable display + width of cells commit b7083543390046a16354a2038ef2df26498fd00c Author: servantie <servantie.c@gmail.com> Date: Tue Jul 19 17:09:52 2016 +0200 turned the jcombobox into a jtable for url edition commit af8bae33a37f2fb97a7283038b120a2b8884a410 Author: servantie <servantie.c@gmail.com> Date: Fri Jul 15 15:22:20 2016 +0200 revert of the syncAtStartUp Summary of changes: .../org/chorem/jtimer/data/DataEventListener.java | 16 +- .../java/org/chorem/jtimer/data/TimerCore.java | 30 -- .../org/chorem/jtimer/data/TimerDataManager.java | 20 - .../java/org/chorem/jtimer/entities/SyncInfo.java | 18 - .../java/org/chorem/jtimer/entities/TimerTask.java | 33 +- .../chorem/jtimer/io/GTimerIncrementalSaver.java | 10 - .../chorem/jtimer/io/TimerTaskSynchronizer.java | 29 -- .../jtimer/ui/report/TimerTaskSyncInfoEditor.java | 475 +++++++++++---------- .../resources/TimerTaskSyncInfoEditor.properties | 12 +- .../TimerTaskSyncInfoEditor_fr.properties | 15 +- 10 files changed, 269 insertions(+), 389 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 feature/sync in repository jtimer. See https://gitlab.nuiton.org/chorem/jtimer.git commit af8bae33a37f2fb97a7283038b120a2b8884a410 Author: servantie <servantie.c@gmail.com> Date: Fri Jul 15 15:22:20 2016 +0200 revert of the syncAtStartUp --- .../org/chorem/jtimer/data/DataEventListener.java | 16 +++++----- .../java/org/chorem/jtimer/data/TimerCore.java | 30 ------------------- .../org/chorem/jtimer/data/TimerDataManager.java | 34 +++++++++------------- .../java/org/chorem/jtimer/entities/SyncInfo.java | 18 ------------ .../java/org/chorem/jtimer/entities/TimerTask.java | 31 -------------------- .../chorem/jtimer/io/GTimerIncrementalSaver.java | 10 ------- .../chorem/jtimer/io/TimerTaskSynchronizer.java | 29 ------------------ .../jtimer/ui/report/TimerTaskSyncInfoEditor.java | 1 - 8 files changed, 22 insertions(+), 147 deletions(-) diff --git a/src/main/java/org/chorem/jtimer/data/DataEventListener.java b/src/main/java/org/chorem/jtimer/data/DataEventListener.java index 0c42b9f..a14f25f 100644 --- a/src/main/java/org/chorem/jtimer/data/DataEventListener.java +++ b/src/main/java/org/chorem/jtimer/data/DataEventListener.java @@ -206,13 +206,13 @@ public interface DataEventListener extends EventListener { */ default void syncInfoDeleted(TimerTask task, SyncInfo syncInfo) { } - /** - * Task synchronized - * @param task TimerTask - * @param syncInfo SyncInfo - */ - default void taskSynchronized(TimerTask task, SyncInfo syncInfo) { - - } +// /** +// * Task synchronized +// * @param task TimerTask +// * @param syncInfo SyncInfo +// */ +// default void taskSynchronized(TimerTask task, SyncInfo syncInfo) { +// +// } } diff --git a/src/main/java/org/chorem/jtimer/data/TimerCore.java b/src/main/java/org/chorem/jtimer/data/TimerCore.java index 02297c1..c6be19f 100644 --- a/src/main/java/org/chorem/jtimer/data/TimerCore.java +++ b/src/main/java/org/chorem/jtimer/data/TimerCore.java @@ -28,15 +28,12 @@ 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.SyncInfo; import org.chorem.jtimer.entities.TimerProject; -import org.chorem.jtimer.entities.TimerTask; import org.chorem.jtimer.io.DataLockingException; import org.chorem.jtimer.io.Saver; import org.chorem.jtimer.io.TimerTaskSynchronizer; @@ -191,33 +188,6 @@ public class TimerCore { Collections.sort(projectsList); data.addAllProjects(projectsList); - - - // add the tasks that haven't been synced before to the synchronizer - if (log.isDebugEnabled()) { - log.debug("Adding tasks that were not synchronized at last jTimer exit"); - } - for (TimerTask project : data.getProjectsList()) { - project.getSubTasks().forEach(this::addTaskToSync); - } - } - - - /** - * Add tasks that haven't been synchronized at - * the last exit to the synchronizer tasks - */ - - protected void addTaskToSync(TimerTask task) { - if (log.isDebugEnabled()) { - log.debug("Adding task " + task.getName() + " to the synchronizer"); - } - for (SyncInfo sync : task.getSynchronizingInfoList()) { - if (sync.getIsToSyncAtStartUp()) { - synchronizer.addTask(task); - } - } - task.getSubTasks().forEach(this::addTaskToSync); } /** diff --git a/src/main/java/org/chorem/jtimer/data/TimerDataManager.java b/src/main/java/org/chorem/jtimer/data/TimerDataManager.java index fe9125b..f459fff 100644 --- a/src/main/java/org/chorem/jtimer/data/TimerDataManager.java +++ b/src/main/java/org/chorem/jtimer/data/TimerDataManager.java @@ -645,10 +645,6 @@ public class TimerDataManager { public void syncInfoChanged(TimerTask task, SyncInfo info) { task.addSyncInfo(info); - //the syncInfo is added to the syncs at startup only if it is active - if (info.getIsActiveSync()) { - task.setSyncAtStartUp(true, info.getSyncURL()); - } for (DataEventListener dataEventListener : dataEventListeners) { dataEventListener.syncInfoChanged(task, info); @@ -674,20 +670,18 @@ public class TimerDataManager { log.debug("SyncInfo deleted: " + info.getSyncURL()); } } - - /** - * When a task is synced - * @param task - * @param syncInfo - */ - public void taskSynchronized(TimerTask task, SyncInfo syncInfo) { - task.setSyncAtStartUp(false, syncInfo.getSyncURL()); - - for (DataEventListener dataEventListener: dataEventListeners) { - dataEventListener.taskSynchronized(task, syncInfo); - } - if (log.isDebugEnabled()) { - log.debug("Task " + task.getName() + " synced at " + syncInfo.getSyncURL()); - } - } +// +// /** +// * When a task is synced +// * @param task +// * @param syncInfo +// */ +// public void taskSynchronized(TimerTask task, SyncInfo syncInfo) { +// for (DataEventListener dataEventListener: dataEventListeners) { +// dataEventListener.taskSynchronized(task, syncInfo); +// } +// if (log.isDebugEnabled()) { +// log.debug("Task " + task.getName() + " synced at " + syncInfo.getSyncURL()); +// } +// } } diff --git a/src/main/java/org/chorem/jtimer/entities/SyncInfo.java b/src/main/java/org/chorem/jtimer/entities/SyncInfo.java index ac04854..904c5b4 100644 --- a/src/main/java/org/chorem/jtimer/entities/SyncInfo.java +++ b/src/main/java/org/chorem/jtimer/entities/SyncInfo.java @@ -22,9 +22,6 @@ public class SyncInfo { /** true if annotations included */ protected boolean isWithAnnotations; - /** true if the synchronization needs to be done at next start */ - protected boolean isToSyncAtStartUp; - /** * constructor with all parameters * @param syncURL the url to sync to @@ -37,7 +34,6 @@ public class SyncInfo { this.lastSync = lastSync; this.isActiveSync = isActiveSync; this.isWithAnnotations = isWithAnnotations; - this.isToSyncAtStartUp = true; } /** @@ -50,7 +46,6 @@ public class SyncInfo { this.isActiveSync = true; this.isWithAnnotations = false; this.lastSync = new Date(0); - this.isToSyncAtStartUp = true; } /** @@ -115,19 +110,6 @@ public class SyncInfo { } /** - * Gets the isToSyncAtStartUp - * @return a boolean - */ - public boolean getIsToSyncAtStartUp() {return isToSyncAtStartUp; } - - /** - * Sets the isToSyncAtStartUp - * @param isToSyncAtStartUp a boolean - */ - public void setIsToSyncAtStartUp(boolean isToSyncAtStartUp) { this.isToSyncAtStartUp = isToSyncAtStartUp; } - - - /** * Overrides the toString() method to return the url (for combobox) */ @Override diff --git a/src/main/java/org/chorem/jtimer/entities/TimerTask.java b/src/main/java/org/chorem/jtimer/entities/TimerTask.java index a8015e5..8213f47 100644 --- a/src/main/java/org/chorem/jtimer/entities/TimerTask.java +++ b/src/main/java/org/chorem/jtimer/entities/TimerTask.java @@ -374,37 +374,6 @@ public class TimerTask implements Cloneable, } /** - * Sets the sync at startup - * @param syncAtStart boolean - * @param url the url of the syncInfo - */ - public void setSyncAtStartUp(boolean syncAtStart, String url) { - if(!synchronisingInfoList.isEmpty()) { - for (SyncInfo sync : synchronisingInfoList) { - if (sync.syncURL.equals(url)) { - sync.setIsToSyncAtStartUp(syncAtStart); - } - } - } - } - - /** - * Get the sync at startup - * @return boolean - */ - public boolean getIsSyncAtStartUp(String url) { - boolean syncsAtStart = false; - if(!synchronisingInfoList.isEmpty()) { - for (SyncInfo sync : synchronisingInfoList) { - if (sync.syncURL.equals(url)) { - syncsAtStart = sync.getIsToSyncAtStartUp(); - } - } - } - return syncsAtStart; - } - - /** * Add task's subtask. * * Also add parent reference. diff --git a/src/main/java/org/chorem/jtimer/io/GTimerIncrementalSaver.java b/src/main/java/org/chorem/jtimer/io/GTimerIncrementalSaver.java index a204740..4b4abf9 100644 --- a/src/main/java/org/chorem/jtimer/io/GTimerIncrementalSaver.java +++ b/src/main/java/org/chorem/jtimer/io/GTimerIncrementalSaver.java @@ -1506,16 +1506,6 @@ public class GTimerIncrementalSaver extends AbstractSaver implements Saver, } /** - * When a task is synced - * @param task - * @param info - */ - @Override - public void taskSynchronized(TimerTask task, SyncInfo info) { - saveSynchronizationInfo(task); - } - - /** * When a syncInfo is modified * @param task TimerTask * @param info diff --git a/src/main/java/org/chorem/jtimer/io/TimerTaskSynchronizer.java b/src/main/java/org/chorem/jtimer/io/TimerTaskSynchronizer.java index 9157890..d7350ac 100644 --- a/src/main/java/org/chorem/jtimer/io/TimerTaskSynchronizer.java +++ b/src/main/java/org/chorem/jtimer/io/TimerTaskSynchronizer.java @@ -141,8 +141,6 @@ public class TimerTaskSynchronizer implements DataEventListener { } Calendar cal = Calendar.getInstance(); task.setLastSync(cal.getTime(), syncURL); - //it doesn't have to be synced at startup sync it succeeded - task.setSyncAtStartUp(false, syncURL); } } } @@ -213,10 +211,6 @@ public class TimerTaskSynchronizer implements DataEventListener { tasksToSync.add(task); } } - //set the syncAtStartup to true for all syncInfo - for (SyncInfo info : task.getSynchronizingInfoList()) { - info.setIsToSyncAtStartUp(true); - } } /** @@ -245,10 +239,6 @@ public class TimerTaskSynchronizer implements DataEventListener { } } - //set the syncAtStartup to true for all syncInfo - for (SyncInfo info : task.getSynchronizingInfoList()) { - info.setIsToSyncAtStartUp(true); - } } /** @@ -263,10 +253,6 @@ public class TimerTaskSynchronizer implements DataEventListener { tasksToSync.add(task); } } - //set the syncAtStartup to true for all syncInfo - for (SyncInfo info : task.getSynchronizingInfoList()) { - info.setIsToSyncAtStartUp(true); - } } /** @@ -281,10 +267,6 @@ public class TimerTaskSynchronizer implements DataEventListener { tasksToSync.add(task); } } - //set the syncAtStartup to true for all syncInfo - for (SyncInfo info : task.getSynchronizingInfoList()) { - info.setIsToSyncAtStartUp(true); - } } /** @@ -300,16 +282,5 @@ public class TimerTaskSynchronizer implements DataEventListener { tasksToSync.add(task); } } - task.setSyncAtStartUp(true, info.getSyncURL()); - } - - /** - * When the synchronization happens, set the syncAtStartUp to false - * @param task the task that was synchronized - * @param info SyncInfo - */ - @Override - public void taskSynchronized(TimerTask task, SyncInfo info) { - task.setSyncAtStartUp(false, info.getSyncURL()); } } diff --git a/src/main/java/org/chorem/jtimer/ui/report/TimerTaskSyncInfoEditor.java b/src/main/java/org/chorem/jtimer/ui/report/TimerTaskSyncInfoEditor.java index da1a341..45128ef 100644 --- a/src/main/java/org/chorem/jtimer/ui/report/TimerTaskSyncInfoEditor.java +++ b/src/main/java/org/chorem/jtimer/ui/report/TimerTaskSyncInfoEditor.java @@ -400,7 +400,6 @@ public class TimerTaskSyncInfoEditor extends FrameView implements ActionListener infoBox(getResourceMap().getString("testSyncSuccessMessage"), getResourceMap().getString("testSyncSuccessTitle")); Calendar cal = Calendar.getInstance(); infoToUse.setLastSync(cal.getTime()); - core.getData().taskSynchronized(task, infoToUse); //update the last synctime displayed lastUpdate.setVisible(true); lastSyncDateLabel.setVisible(true); -- 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 feature/sync in repository jtimer. See https://gitlab.nuiton.org/chorem/jtimer.git commit b7083543390046a16354a2038ef2df26498fd00c Author: servantie <servantie.c@gmail.com> Date: Tue Jul 19 17:09:52 2016 +0200 turned the jcombobox into a jtable for url edition --- .../org/chorem/jtimer/data/TimerDataManager.java | 14 - .../java/org/chorem/jtimer/entities/TimerTask.java | 2 +- .../jtimer/ui/report/TimerTaskSyncInfoEditor.java | 440 ++++++++++----------- .../resources/TimerTaskSyncInfoEditor.properties | 12 +- .../TimerTaskSyncInfoEditor_fr.properties | 15 +- 5 files changed, 226 insertions(+), 257 deletions(-) diff --git a/src/main/java/org/chorem/jtimer/data/TimerDataManager.java b/src/main/java/org/chorem/jtimer/data/TimerDataManager.java index f459fff..6d03164 100644 --- a/src/main/java/org/chorem/jtimer/data/TimerDataManager.java +++ b/src/main/java/org/chorem/jtimer/data/TimerDataManager.java @@ -670,18 +670,4 @@ public class TimerDataManager { log.debug("SyncInfo deleted: " + info.getSyncURL()); } } -// -// /** -// * When a task is synced -// * @param task -// * @param syncInfo -// */ -// public void taskSynchronized(TimerTask task, SyncInfo syncInfo) { -// for (DataEventListener dataEventListener: dataEventListeners) { -// dataEventListener.taskSynchronized(task, syncInfo); -// } -// if (log.isDebugEnabled()) { -// log.debug("Task " + task.getName() + " synced at " + syncInfo.getSyncURL()); -// } -// } } diff --git a/src/main/java/org/chorem/jtimer/entities/TimerTask.java b/src/main/java/org/chorem/jtimer/entities/TimerTask.java index 8213f47..35996a7 100644 --- a/src/main/java/org/chorem/jtimer/entities/TimerTask.java +++ b/src/main/java/org/chorem/jtimer/entities/TimerTask.java @@ -318,7 +318,7 @@ public class TimerTask implements Cloneable, */ public void addSyncInfo(SyncInfo info) { - if (!getSynchronizingInfoList().contains(info)) { + if (!getSynchronizingInfoList().contains(info) && !info.getSyncURL().isEmpty()) { synchronisingInfoList.add(info); } } diff --git a/src/main/java/org/chorem/jtimer/ui/report/TimerTaskSyncInfoEditor.java b/src/main/java/org/chorem/jtimer/ui/report/TimerTaskSyncInfoEditor.java index 45128ef..6e67b42 100644 --- a/src/main/java/org/chorem/jtimer/ui/report/TimerTaskSyncInfoEditor.java +++ b/src/main/java/org/chorem/jtimer/ui/report/TimerTaskSyncInfoEditor.java @@ -24,25 +24,21 @@ package org.chorem.jtimer.ui.report; import com.google.gson.JsonObject; import java.awt.BorderLayout; +import java.awt.Component; 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.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; -import javax.swing.Box; -import javax.swing.BoxLayout; -import javax.swing.DefaultComboBoxModel; +import java.util.List; 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.JTable; +import javax.swing.table.AbstractTableModel; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.jtimer.data.TimerCore; @@ -50,7 +46,6 @@ 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; @@ -59,7 +54,7 @@ import org.jdesktop.application.FrameView; * * Created by servantie on 13/05/16. */ -public class TimerTaskSyncInfoEditor extends FrameView implements ActionListener, ItemListener { +public class TimerTaskSyncInfoEditor extends FrameView implements ActionListener { /** Class logger */ protected static Log log = LogFactory.getLog(TimerTaskSyncInfoEditor.class); @@ -67,11 +62,8 @@ public class TimerTaskSyncInfoEditor extends FrameView implements ActionListener /** Timer core. */ protected TimerCore core; - /** Include annotations on updates */ - protected JCheckBox checkIncludesAnnotations; - - /** Activate a sync URL */ - protected JCheckBox checkIsActiveSync; + /** button to add a URL */ + protected JButton addButton; /** button to delete a URL */ protected JButton deleteButton; @@ -79,14 +71,8 @@ public class TimerTaskSyncInfoEditor extends FrameView implements ActionListener /** button to test a url */ protected JButton testSyncUrlButton; - /** ComboBox of URLs */ - protected JComboBox<SyncInfo> urlComboBox; - - /** LastSync */ - protected JLabel lastUpdate; - - /** lastSync Label */ - protected JLabel lastSyncDateLabel; + /** JTable of URLs */ + protected JTable urlJTable; /** task to update */ protected TimerTask task; @@ -116,8 +102,6 @@ public class TimerTaskSyncInfoEditor extends FrameView implements ActionListener df = new SimpleDateFormat("dd/MM/yy HH:mm:ss"); setComponent(getMainComponent()); - - } /** @@ -133,67 +117,22 @@ public class TimerTaskSyncInfoEditor extends FrameView implements ActionListener 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()); - Date lastSyncTime = syncInfo.getLastSync(); - //if there has been an update before, display its date - if ((lastSyncTime != null) && lastSyncTime.after(new Date(0))) { - lastUpdate.setText(df.format(lastSyncTime)); - //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()).getIsActiveSync()); - } - } - 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 + + urlJTable = new JTable(new SyncInfoTableModel()); + + + //add the headers and the table + urlPanel.add(urlJTable.getTableHeader(), BorderLayout.NORTH); + urlPanel.add(urlJTable, BorderLayout.CENTER); + + //panel to hold the buttons + JPanel buttonPane = new JPanel(); + buttonPane.setAlignmentX(Component.CENTER_ALIGNMENT); + + addButton = new JButton(getResourceMap().getString("addButton")); + addButton.addActionListener(this); + addButton.setActionCommand("addURL"); + deleteButton = new JButton(getResourceMap().getString("deleteButton")); deleteButton.addActionListener(this); deleteButton.setActionCommand("deleteURL"); @@ -202,19 +141,16 @@ public class TimerTaskSyncInfoEditor extends FrameView implements ActionListener testSyncUrlButton.addActionListener(this); testSyncUrlButton.setActionCommand("testURL"); - - deleteBox.add(deleteButton); - deleteBox.add(testSyncUrlButton); - - // button to close + buttonPane.add(addButton); + buttonPane.add(testSyncUrlButton); + buttonPane.add(deleteButton); + // 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(buttonPane, BorderLayout.CENTER); configComponent.add(closeButton, BorderLayout.SOUTH); // color fix on linux ? @@ -233,42 +169,6 @@ public class TimerTaskSyncInfoEditor extends FrameView implements ActionListener getApplication().hide(this); } - - /** - * Add annotation checkbox checked. - */ - @Action - public boolean isIncludingAnnotations() { - boolean ischeckedIncludeAnnotations = checkIncludesAnnotations.isSelected(); - if (urlComboBox.getSelectedItem() instanceof SyncInfo) { - SyncInfo syncInfo = (SyncInfo) urlComboBox.getSelectedItem(); - task.getSynchronizingInfo(syncInfo.getSyncURL()).setIsWithAnnotations(ischeckedIncludeAnnotations); - core.getData().syncInfoChanged(task,syncInfo); - - } - 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(); - if (urlComboBox.getSelectedItem() instanceof SyncInfo) { - SyncInfo syncInfo = (SyncInfo) urlComboBox.getSelectedItem(); - task.getSynchronizingInfo(syncInfo.getSyncURL()).setIsActiveSync(isActiveSyncURL); - core.getData().syncInfoChanged(task,syncInfo); - } - if (log.isDebugEnabled()) { - log.debug("Activity of url changed "); - } - return isActiveSyncURL; - } - /** * Method to display an error message * @param errorMessage the message to display @@ -288,127 +188,209 @@ public class TimerTaskSyncInfoEditor extends FrameView implements ActionListener 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 + * Class to deal with the SyncInfos in a table */ - public void itemAdded(String urlToAdd){ - if ((urlToAdd != null) && (!urlToAdd.isEmpty()) && ((!task.getSynchronizingURLList().contains(urlToAdd)))) { - SyncInfo infoToAdd = new SyncInfo(urlToAdd); - core.getData().syncInfoChanged(task, infoToAdd); - urlComboBox.addItem(infoToAdd); - if (log.isDebugEnabled()) { - log.debug("New SyncInfo with URL : " + urlToAdd); - } + protected class SyncInfoTableModel extends AbstractTableModel { + + /** the syncInfo list */ + protected List<SyncInfo> syncInfoList; + + /** headers of the columns */ + protected String[] columnHeaders= {getResourceMap().getString("syncURLHeader"), getResourceMap().getString("isActiveHeader"), + getResourceMap().getString("isWithAnnotationsHeader"), getResourceMap().getString("lastSyncHeader")}; + + + public SyncInfoTableModel() { syncInfoList = task.getSynchronizingInfoList(); } + + + /** + * Gets the column headers + * @param col the column + * @return a string for the header + */ + @Override + public String getColumnName(int col) { + return columnHeaders[col]; } - } - /** - * deals with item selection in the combobox - * @param itemEvent - */ - @Override - public void itemStateChanged(ItemEvent itemEvent) { - if (itemEvent.getStateChange()== ItemEvent.SELECTED) { - if (urlComboBox.getSelectedItem() != null) { - SyncInfo syncInfo; - String urlToDisplay; - if (urlComboBox.getSelectedItem() instanceof String) { - urlToDisplay = (String)urlComboBox.getSelectedItem(); - //trim the whitespaces - urlToDisplay = urlToDisplay.trim(); - syncInfo = new SyncInfo(urlToDisplay); - urlComboBox.setSelectedItem(syncInfo); + @Override + public int getRowCount() { + return syncInfoList.size(); + } - } - else { - syncInfo = (SyncInfo) urlComboBox.getSelectedItem(); - urlToDisplay = syncInfo.getSyncURL(); - } - if (!urlToDisplay.isEmpty()) { - if (log.isDebugEnabled()) { - log.debug("Selected an object : " + urlToDisplay); - } - if (checkIsActiveSync != null) { - checkIsActiveSync.setSelected(syncInfo.getIsActiveSync()); - } - if (checkIncludesAnnotations != null) { - checkIncludesAnnotations.setSelected(syncInfo.getIsWithAnnotations()); - } - //display last Sync Time - if (lastUpdate != null && syncInfo.getLastSync() != null) { - if (syncInfo.getLastSync().after(new Date(0))) { - lastUpdate.setText(df.format(syncInfo.getLastSync())); - lastUpdate.setVisible(true); - lastSyncDateLabel.setVisible(true); - } - else { - lastUpdate.setVisible(false); - lastSyncDateLabel.setVisible(false); - } - } - } + /** + * returns the column number (url, activity, annotations and last sync, so 4) + */ + @Override + public int getColumnCount() { + return 4; + } + + /** + * Returns the value at rowIndex, columnIndex + * column 0 is url String, column 1 is activity boolean, + * column 2 is annotations boolean, column 3 is lastSync Date + * @param rowIndex + * @param columnIndex + * @return an Object + */ + @Override + public Object getValueAt(int rowIndex, int columnIndex) { + Object value = ""; + SyncInfo syncInfo = syncInfoList.get(rowIndex); + switch (columnIndex) { + case 0: + value = syncInfo.getSyncURL(); + break; + case 1: + value = syncInfo.getIsActiveSync(); + break; + case 2: + value = syncInfo.getIsWithAnnotations(); + break; + case 3: + value = syncInfo.getLastSync(); + break; } + return value; } - } - @Override - public void actionPerformed(ActionEvent actionEvent) { + /** + * When the data is changed + * @param value an object -a string- + * @param rowIndex the row selected + * @param columnIndex the column modified + */ + @Override + public void setValueAt(Object value, int rowIndex, int columnIndex) { + SyncInfo syncInfo = syncInfoList.get(rowIndex); + //if the url changes + if (columnIndex == 0) { + syncInfo.setSyncURL((String) value); + } + //if the checkbox of activity changes + else if (columnIndex == 1) { + syncInfo.setIsActiveSync((Boolean) value); + } + //if the checkbox of annotation changes + else if (columnIndex == 2) { + syncInfo.setIsWithAnnotations((Boolean) value); + } + else if (columnIndex == 3) { + syncInfo.setLastSync(new Date()); + } + core.getData().syncInfoChanged(task, syncInfo); - String actionCommand = actionEvent.getActionCommand(); - SyncInfo infoToUse; - String urlToUse; - if (urlComboBox.getSelectedItem() instanceof String) { - urlToUse = (String) urlComboBox.getSelectedItem(); - infoToUse = new SyncInfo(urlToUse); } - else{ - infoToUse = (SyncInfo) urlComboBox.getSelectedItem(); - urlToUse = infoToUse.getSyncURL(); + + /** To mark the url and checkbox cells as editable but not the date + * + * @param rowIndex + * @param columnIndex + * @return + */ + @Override + public boolean isCellEditable(int rowIndex, int columnIndex) { + //the sync date is not editable + if (columnIndex >= 3) { + return false; + } + else { + return true; + } } - if ("deleteURL".equals(actionCommand)) { - //if the delete button has been clicked, delete the task (if it exists) - if ((task.getSynchronizingInfoList().contains(infoToUse))) { - task.removeSyncInfo(infoToUse); - urlComboBox.removeItem(infoToUse); - core.getData().deleteSyncInfo(task, infoToUse); - } else { - errorBox(getResourceMap().getString("deleteErrorMessage"), getResourceMap().getString("deleteErrorTitle")); + + /** Returns the class of objects in the columns + * + * @param columnIndex + * @return the class + */ + + @Override + public Class<?> getColumnClass(int columnIndex) { + if (columnIndex == 0) { + return String.class; } + else if(columnIndex == 1 || columnIndex == 2) { + return Boolean.class; + } + else if (columnIndex == 3) { + return Date.class; + } + return Object.class; } - else if ("comboBoxEdited".equals(actionCommand)) { - if (!task.getSynchronizingInfoList().contains(infoToUse)) { - if (log.isDebugEnabled()) { - log.debug("New URL added"); - } - itemAdded(urlToUse); + + /** + * Adds a syncInfo + * @param sync + */ + public void add(SyncInfo sync) { + if (!syncInfoList.contains(sync)) { + syncInfoList.add(sync); + fireTableRowsInserted(syncInfoList.indexOf(sync), syncInfoList.indexOf(sync)); } - else if (log.isDebugEnabled()) { - log.debug("No addition"); + } + + /** + * removes a syncInfo + * @param sync + */ + public void remove(SyncInfo sync) { + if (syncInfoList.contains(sync)) { + fireTableRowsDeleted(syncInfoList.indexOf(sync), syncInfoList.indexOf(sync)); + syncInfoList.remove(sync); } + } + } + @Override + public void actionPerformed(ActionEvent actionEvent) { + + String actionCommand = actionEvent.getActionCommand(); + SyncInfo infoToUse; + SyncInfoTableModel model = (SyncInfoTableModel) urlJTable.getModel(); + + if ("addURL".equals(actionCommand)) { + model.add(new SyncInfo("")); } - else if ("testURL".equals(actionCommand)) { - //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 (task.getSynchronizingInfoList().contains(infoToUse)) { - JsonObject testObject = TimerTaskHelper.taskURLToJSONObject(task, urlToUse, isIncludingAnnotations(), timezone); - int responseCode = TimerTaskSynchronizer.synchronizeTaskOnURL(testObject); - if (responseCode > 199 && responseCode < 300) { - infoBox(getResourceMap().getString("testSyncSuccessMessage"), getResourceMap().getString("testSyncSuccessTitle")); - Calendar cal = Calendar.getInstance(); - infoToUse.setLastSync(cal.getTime()); - //update the last synctime displayed - lastUpdate.setVisible(true); - lastSyncDateLabel.setVisible(true); - lastUpdate.setText(df.format(infoToUse.getLastSync())); + else if (!task.getSynchronizingInfoList().isEmpty()) { + //first check that a row is selected + if (urlJTable.getSelectedRow() != -1) { + infoToUse = task.getSynchronizingInfo((String) urlJTable.getModel().getValueAt(urlJTable.getSelectedRow(), 0)); + if ("deleteURL".equals(actionCommand)) { + if (!((SyncInfoTableModel) urlJTable.getModel()).syncInfoList.isEmpty()) { + //if the delete button has been clicked, delete the task (if it exists) + if ((task.getSynchronizingInfoList().contains(infoToUse))) { + task.removeSyncInfo(infoToUse); + model.remove(infoToUse); + core.getData().deleteSyncInfo(task, infoToUse); + } else { + errorBox(getResourceMap().getString("deleteErrorMessage"), getResourceMap().getString("deleteErrorTitle")); + } } else { - errorBox(getResourceMap().getString("testSyncFailureMessage"), getResourceMap().getString("testSyncFailureTitle")); + errorBox(getResourceMap().getString("deleteErrorMessage"), getResourceMap().getString("deleteErrorTitle")); } } + else if ("testURL".equals(actionCommand)) { + //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 (task.getSynchronizingInfoList().contains(infoToUse)) { + JsonObject testObject = TimerTaskHelper.taskURLToJSONObject(task, infoToUse.getSyncURL(), false, timezone); + int responseCode = TimerTaskSynchronizer.synchronizeTaskOnURL(testObject); + if (responseCode > 199 && responseCode < 300) { + infoBox(getResourceMap().getString("testSyncSuccessMessage"), getResourceMap().getString("testSyncSuccessTitle")); + Calendar cal = Calendar.getInstance(); + infoToUse.setLastSync(cal.getTime()); + } + else { + errorBox(getResourceMap().getString("testSyncFailureMessage"), getResourceMap().getString("testSyncFailureTitle")); + } + } + } + } } else { if (log.isDebugEnabled()) { 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 index 990a73e..dc0e956 100644 --- a/src/main/resources/org/chorem/jtimer/ui/report/resources/TimerTaskSyncInfoEditor.properties +++ b/src/main/resources/org/chorem/jtimer/ui/report/resources/TimerTaskSyncInfoEditor.properties @@ -20,11 +20,6 @@ # #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 @@ -37,10 +32,15 @@ deleteButton = Delete URL deleteErrorMessage = No URL to delete deleteErrorTitle = Deletion error +addButton = Add URL + 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 +syncURLHeader = URL +isActiveHeader = is Active +isWithAnnotationsHeader = With annotations +lastSyncHeader = Last 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 index d3e733c..cd69cce 100644 --- 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 @@ -21,13 +21,7 @@ ### # 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 @@ -37,10 +31,17 @@ deleteButton = Supprimer l'URL deleteErrorMessage = Aucune URL \u00E0 supprimer deleteErrorTitle = Erreur de suppression +addButton = Ajouter une URL + 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 +isActiveSync.Action.text = Synchronisation Active + +syncURLHeader = URL +isActiveHeader = Active +isWithAnnotationsHeader = Avec annotations +lastSyncHeader = Derni\u00E8re synchronisation \ No newline at end of file -- 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 feature/sync in repository jtimer. See https://gitlab.nuiton.org/chorem/jtimer.git commit 2d14fcefe71c28ec733b4a2ce396c7afa54890b9 Author: servantie <servantie.c@gmail.com> Date: Wed Jul 20 10:13:26 2016 +0200 date format in jtable display + width of cells --- .../jtimer/ui/report/TimerTaskSyncInfoEditor.java | 38 +++++++++++++++++++++- .../resources/TimerTaskSyncInfoEditor.properties | 2 +- .../TimerTaskSyncInfoEditor_fr.properties | 2 +- 3 files changed, 39 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/chorem/jtimer/ui/report/TimerTaskSyncInfoEditor.java b/src/main/java/org/chorem/jtimer/ui/report/TimerTaskSyncInfoEditor.java index 6e67b42..96cb74c 100644 --- a/src/main/java/org/chorem/jtimer/ui/report/TimerTaskSyncInfoEditor.java +++ b/src/main/java/org/chorem/jtimer/ui/report/TimerTaskSyncInfoEditor.java @@ -29,16 +29,20 @@ import java.awt.Dimension; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.text.DateFormat; +import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.List; +import java.util.Locale; import javax.swing.JButton; import javax.swing.JComponent; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JTable; import javax.swing.table.AbstractTableModel; +import javax.swing.table.DefaultTableCellRenderer; +import javax.swing.table.TableColumnModel; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.jtimer.data.TimerCore; @@ -99,7 +103,6 @@ public class TimerTaskSyncInfoEditor extends FrameView implements ActionListener this.core = core; this.task = task; timezone = "+01:00"; - df = new SimpleDateFormat("dd/MM/yy HH:mm:ss"); setComponent(getMainComponent()); } @@ -119,6 +122,15 @@ public class TimerTaskSyncInfoEditor extends FrameView implements ActionListener urlJTable = new JTable(new SyncInfoTableModel()); + //try to have coherent width of columns + TableColumnModel tableColModel = urlJTable.getColumnModel(); + tableColModel.getColumn(0).setPreferredWidth(200); + tableColModel.getColumn(1).setPreferredWidth(40); + tableColModel.getColumn(2).setPreferredWidth(60); + tableColModel.getColumn(3).setPreferredWidth(200); + //render the date properly + tableColModel.getColumn(3).setCellRenderer(new DateRenderer()); + //add the headers and the table @@ -345,6 +357,27 @@ public class TimerTaskSyncInfoEditor extends FrameView implements ActionListener } } + /** + * Class to render dates with a readable format + * (dd/MM/yy HH:mm:ss) + */ + protected class DateRenderer extends DefaultTableCellRenderer { + + private Date dateValue; + private SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yy HH:mm:ss"); + private String valueToString = ""; + + @Override + public void setValue(Object value) { + if ((value != null)) { + dateValue = (Date) value; + valueToString = dateFormat.format(dateValue); + value = valueToString; + super.setValue(value); + } + } + } + @Override public void actionPerformed(ActionEvent actionEvent) { @@ -388,6 +421,9 @@ public class TimerTaskSyncInfoEditor extends FrameView implements ActionListener else { errorBox(getResourceMap().getString("testSyncFailureMessage"), getResourceMap().getString("testSyncFailureTitle")); } + if (log.isDebugEnabled()) { + log.debug("Response code : " + responseCode); + } } } } 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 index dc0e956..f311f08 100644 --- a/src/main/resources/org/chorem/jtimer/ui/report/resources/TimerTaskSyncInfoEditor.properties +++ b/src/main/resources/org/chorem/jtimer/ui/report/resources/TimerTaskSyncInfoEditor.properties @@ -42,5 +42,5 @@ testSyncFailureTitle = Synchronization test failure syncURLHeader = URL isActiveHeader = is Active -isWithAnnotationsHeader = With annotations +isWithAnnotationsHeader = Annotations lastSyncHeader = Last 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 index cd69cce..3c5ee10 100644 --- 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 @@ -43,5 +43,5 @@ isActiveSync.Action.text = Synchronisation Active syncURLHeader = URL isActiveHeader = Active -isWithAnnotationsHeader = Avec annotations +isWithAnnotationsHeader = Annotations lastSyncHeader = Derni\u00E8re synchronisation \ No newline at end of file -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
participants (1)
-
chorem.org scm