branch feature/sync updated (8dd4914 -> 3cda6fb)
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 8dd4914 cleaned up synchronizeTaskOnURL method new 0a0946b removed timezone display in TimerTaskUpdaterView (useless) new 10eaac3 added a combobox in manual sync to pick which url to sync on new 3cda6fb fix to display error message when the sync went wrong 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 3cda6fbabd8fa7e768932efdbbbbf19b8569b8ff Author: servantie <servantie.c@gmail.com> Date: Thu Jun 9 17:57:32 2016 +0200 fix to display error message when the sync went wrong commit 10eaac3410a3023d6605211e7f3b39e832e9319d Author: servantie <servantie.c@gmail.com> Date: Thu Jun 9 16:25:23 2016 +0200 added a combobox in manual sync to pick which url to sync on (if one sync fails, pop up shows to say so, but textarea isn't updated on "generate update" button pressing) commit 0a0946bcad76d302cec41adfc4542a989656ca64 Author: servantie <servantie.c@gmail.com> Date: Thu Jun 9 15:15:58 2016 +0200 removed timezone display in TimerTaskUpdaterView (useless) Summary of changes: .../chorem/jtimer/io/TimerTaskSynchronizer.java | 6 +-- .../jtimer/ui/report/TimerTaskUpdaterView.java | 61 +++++++++++++++------- .../resources/TimerTaskUpdaterView.properties | 4 +- .../resources/TimerTaskUpdaterView_fr.properties | 2 +- 4 files changed, 48 insertions(+), 25 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 0a0946bcad76d302cec41adfc4542a989656ca64 Author: servantie <servantie.c@gmail.com> Date: Thu Jun 9 15:15:58 2016 +0200 removed timezone display in TimerTaskUpdaterView (useless) --- .../java/org/chorem/jtimer/io/TimerTaskSynchronizer.java | 6 ++---- .../org/chorem/jtimer/ui/report/TimerTaskUpdaterView.java | 14 ++------------ .../ui/report/resources/TimerTaskUpdaterView.properties | 1 - .../ui/report/resources/TimerTaskUpdaterView_fr.properties | 1 - 4 files changed, 4 insertions(+), 18 deletions(-) diff --git a/src/main/java/org/chorem/jtimer/io/TimerTaskSynchronizer.java b/src/main/java/org/chorem/jtimer/io/TimerTaskSynchronizer.java index b0ea2d0..37c685f 100644 --- a/src/main/java/org/chorem/jtimer/io/TimerTaskSynchronizer.java +++ b/src/main/java/org/chorem/jtimer/io/TimerTaskSynchronizer.java @@ -146,11 +146,11 @@ public class TimerTaskSynchronizer implements DataEventListener { connection.setUseCaches(false); connection.setDoInput(true); connection.setDoOutput(true); - connection.setRequestProperty("Content-Length", "" + Integer.toString(updateJsonString.length())); + connection.setRequestProperty("Content-Length", Integer.toString(updateJsonString.length())); connection.setRequestProperty("Accept-Charset", charset); connection.setRequestProperty("Content-Type", "application/json"); connection.setRequestMethod("POST"); - postDataBytes = updateJsonString.getBytes("UTF-8"); + postDataBytes = updateJsonString.getBytes(charset); connection.getOutputStream().write(postDataBytes); //get the header fields Map<String, List<String>> map = connection.getHeaderFields(); @@ -165,14 +165,12 @@ public class TimerTaskSynchronizer implements DataEventListener { } } catch (MalformedURLException e) { log.error("URL malformed"); - //abort synchronization of this task if the url is wrong } catch (ProtocolException e) { log.error("Protocol error."); } catch (UnsupportedEncodingException e) { log.error("Problem with encoding"); } catch (IOException e) { log.error("Problem with the connection"); - //abort synchronization of this task if connection impossible } return hasUpdated; } diff --git a/src/main/java/org/chorem/jtimer/ui/report/TimerTaskUpdaterView.java b/src/main/java/org/chorem/jtimer/ui/report/TimerTaskUpdaterView.java index 26a48ac..d98fcb9 100644 --- a/src/main/java/org/chorem/jtimer/ui/report/TimerTaskUpdaterView.java +++ b/src/main/java/org/chorem/jtimer/ui/report/TimerTaskUpdaterView.java @@ -102,7 +102,6 @@ public class TimerTaskUpdaterView extends FrameView implements DocumentListener this.task = task; timezone = "+0100"; setComponent(getMainComponent()); - //default the timezone updateJson = new ArrayList<>(); @@ -197,14 +196,6 @@ public class TimerTaskUpdaterView extends FrameView implements DocumentListener GridBagConstraints.WEST, GridBagConstraints.VERTICAL, new Insets(1, 2, 1, 1), 0, 0)); } - //display of the timezone - JLabel timezoneLabel = new JLabel(getResourceMap().getString("timezone")); - JLabel timezoneText = new JLabel(this.timezone); - panelOption.add(timezoneLabel, new GridBagConstraints(1,3,1,2,0,0, - GridBagConstraints.WEST, GridBagConstraints.VERTICAL, new Insets(2,1,1,1),0,0)); - panelOption.add(timezoneText, new GridBagConstraints(2,3,1,2,0,0, - GridBagConstraints.WEST, GridBagConstraints.VERTICAL, new Insets(1,2,1,1),0,0)); - configComponent.add(panelGeneral); configComponent.add(panelOption); @@ -408,7 +399,6 @@ public class TimerTaskUpdaterView extends FrameView implements DocumentListener } } - /** * Sends the update of a task to one url * @param task task to update @@ -428,11 +418,11 @@ public class TimerTaskUpdaterView extends FrameView implements DocumentListener connection.setUseCaches(false); connection.setDoInput(true); connection.setDoOutput(true); - connection.setRequestProperty("Content-Length", "" + Integer.toString(updateJsonString.length())); + connection.setRequestProperty("Content-Length", Integer.toString(updateJsonString.length())); connection.setRequestProperty("Accept-Charset", charset); connection.setRequestProperty("Content-Type", "application/json"); connection.setRequestMethod("POST"); - postDataBytes = updateJsonString.getBytes("UTF-8"); + postDataBytes = updateJsonString.getBytes(charset); connection.getOutputStream().write(postDataBytes); //get the header fields Map<String, List<String>> map = connection.getHeaderFields(); 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 index 09a82f9..ddeae17 100644 --- a/src/main/resources/org/chorem/jtimer/ui/report/resources/TimerTaskUpdaterView.properties +++ b/src/main/resources/org/chorem/jtimer/ui/report/resources/TimerTaskUpdaterView.properties @@ -26,7 +26,6 @@ updateFrom=From : updateTo=To : lastUpdateLabel=Last Sync at: -timezone= Timezone: pickCurrentMonth.Action.text = Select current month 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 index 4a9a20a..908ccad 100644 --- 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 @@ -27,7 +27,6 @@ updateFrom=De : updateTo=\u00C0 : lastUpdateLabel=Derni\u00E8re synchronisation : -timezone= Timezone : pickCurrentMonth.Action.text = Selectionner le mois courant -- 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 10eaac3410a3023d6605211e7f3b39e832e9319d Author: servantie <servantie.c@gmail.com> Date: Thu Jun 9 16:25:23 2016 +0200 added a combobox in manual sync to pick which url to sync on (if one sync fails, pop up shows to say so, but textarea isn't updated on "generate update" button pressing) --- .../jtimer/ui/report/TimerTaskUpdaterView.java | 37 +++++++++++++++++++--- .../resources/TimerTaskUpdaterView.properties | 3 +- .../resources/TimerTaskUpdaterView_fr.properties | 1 + 3 files changed, 36 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/chorem/jtimer/ui/report/TimerTaskUpdaterView.java b/src/main/java/org/chorem/jtimer/ui/report/TimerTaskUpdaterView.java index d98fcb9..0af876d 100644 --- a/src/main/java/org/chorem/jtimer/ui/report/TimerTaskUpdaterView.java +++ b/src/main/java/org/chorem/jtimer/ui/report/TimerTaskUpdaterView.java @@ -73,8 +73,15 @@ public class TimerTaskUpdaterView extends FrameView implements DocumentListener /** update output view*/ protected JTextArea updateArea; + /** task in json format (1/synchronizing url) */ protected List<JsonObject> updateJson; + /** list of URLs to sync to */ + protected List<String> urlSyncList; + + /** ComboBox of URLs */ + protected JComboBox<String> urlComboBox; + /** task to update */ protected TimerTask task; @@ -101,6 +108,8 @@ public class TimerTaskUpdaterView extends FrameView implements DocumentListener this.core = core; this.task = task; timezone = "+0100"; + urlSyncList = task.getSynchronisingURLList(); + setComponent(getMainComponent()); updateJson = new ArrayList<>(); @@ -189,13 +198,26 @@ public class TimerTaskUpdaterView extends FrameView implements DocumentListener //if there has been an update before, display its date LocalDateTime lastSyncTime = task.getLastSync(); if (lastSyncTime != null) { - JLabel lastUpdate = new JLabel(lastSyncTime.toLocalDate().toString()); + JLabel lastUpdate = new JLabel(lastSyncTime.toString()); panelOption.add(lastSyncDate, new GridBagConstraints(1, 2, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.VERTICAL, new Insets(2, 1, 1, 1), 0, 0)); panelOption.add(lastUpdate, new GridBagConstraints(2, 2, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.VERTICAL, new Insets(1, 2, 1, 1), 0, 0)); } + //display the various urls to sync to in a combobox to choose which one will be updated + JLabel urlcomboBoxLabel = new JLabel(getResourceMap().getString("urlComboLabel")); + urlComboBox = new JComboBox<>(); + //add the urls to the combobox + for (String url : urlSyncList) { + urlComboBox.addItem(url); + } + panelOption.add(urlcomboBoxLabel, new GridBagConstraints(1,3,1,1,0,0, + GridBagConstraints.WEST, GridBagConstraints.VERTICAL, new Insets(3,1,1,1), 0, 0)); + panelOption.add(urlComboBox, new GridBagConstraints(2,3,1,1,0,0, + GridBagConstraints.WEST, GridBagConstraints.VERTICAL, new Insets(1,3,1,1), 0, 0)); + + configComponent.add(panelGeneral); configComponent.add(panelOption); @@ -343,11 +365,14 @@ public class TimerTaskUpdaterView extends FrameView implements DocumentListener 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) { - builder.append(gson.toJson(object)); + if (urlSelected.equals(object.get("URL").getAsString())) { + builder.append(gson.toJson(object)); + } } updateArea.setText(builder.toString()); @@ -390,12 +415,16 @@ public class TimerTaskUpdaterView extends FrameView implements DocumentListener } /** - * goes through the Jsons to send and sends them + * 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) { - synchronizeTaskOnURL(task, object); + if (urlSelected.equals(object.get("URL").getAsString())) { + synchronizeTaskOnURL(task, object); + } } } 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 index ddeae17..dca4916 100644 --- a/src/main/resources/org/chorem/jtimer/ui/report/resources/TimerTaskUpdaterView.properties +++ b/src/main/resources/org/chorem/jtimer/ui/report/resources/TimerTaskUpdaterView.properties @@ -25,7 +25,8 @@ updateOptions=Options updateFrom=From : updateTo=To : -lastUpdateLabel=Last Sync at: +lastUpdateLabel=Last Synchronisation at: +urlComboLabel = Synchronisation Url: pickCurrentMonth.Action.text = Select current month 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 index 908ccad..d34c270 100644 --- 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 @@ -27,6 +27,7 @@ updateFrom=De : updateTo=\u00C0 : lastUpdateLabel=Derni\u00E8re synchronisation : +urlComboLabel=Url de synchronisation : pickCurrentMonth.Action.text = Selectionner le mois courant -- 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 3cda6fbabd8fa7e768932efdbbbbf19b8569b8ff Author: servantie <servantie.c@gmail.com> Date: Thu Jun 9 17:57:32 2016 +0200 fix to display error message when the sync went wrong --- .../org/chorem/jtimer/ui/report/TimerTaskUpdaterView.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/chorem/jtimer/ui/report/TimerTaskUpdaterView.java b/src/main/java/org/chorem/jtimer/ui/report/TimerTaskUpdaterView.java index 0af876d..3c9f162 100644 --- a/src/main/java/org/chorem/jtimer/ui/report/TimerTaskUpdaterView.java +++ b/src/main/java/org/chorem/jtimer/ui/report/TimerTaskUpdaterView.java @@ -361,6 +361,9 @@ public class TimerTaskUpdaterView extends FrameView implements DocumentListener */ @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); @@ -464,6 +467,7 @@ public class TimerTaskUpdaterView extends FrameView implements DocumentListener } } } + connection.disconnect(); } catch (MalformedURLException e) { log.error("URL malformed"); //abort synchronization of this task if the url is wrong @@ -481,12 +485,14 @@ public class TimerTaskUpdaterView extends FrameView implements DocumentListener log.error("Update error, wrong URL?"); String message = getResourceMap().getString("action.updateError"); String title = getResourceMap().getString("action.updateErrorTitle"); - JOptionPane.showMessageDialog(this.getMainComponent(), message, title, - JOptionPane.ERROR_MESSAGE); - + infoBox(message, title); } } + public static void infoBox(String infoMessage, String titleBar) + { + JOptionPane.showMessageDialog(null, infoMessage, "Erreur : " + titleBar, JOptionPane.ERROR_MESSAGE); + } @Override public void changedUpdate(DocumentEvent e) { documentChanged(); -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
participants (1)
-
chorem.org scm