This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository jtimer. See https://gitlab.nuiton.org/chorem/jtimer.git commit e20e86ea452df06dd861d68d0025a96b25cf5957 Author: Eric Chatellier <chatellier@codelutin.com> Date: Wed Aug 3 11:08:04 2016 +0200 fixes #1359 Revert modification to allow running multiple task at the same time This reverts commit 6cca679c8c66737047f6aea3d77a8892d11afdd2. --- src/main/java/org/chorem/jtimer/JTimer.java | 80 +++++++++++++--------- .../chorem/jtimer/ui/systray/SystrayManager.java | 5 +- .../org/chorem/jtimer/resources/JTimer.properties | 8 +-- .../chorem/jtimer/resources/JTimer_fr.properties | 6 +- .../ui/systray/resources/SystrayManager.properties | 8 +-- .../systray/resources/SystrayManager_fr.properties | 6 +- 6 files changed, 61 insertions(+), 52 deletions(-) diff --git a/src/main/java/org/chorem/jtimer/JTimer.java b/src/main/java/org/chorem/jtimer/JTimer.java index 509aafd..5b4393b 100644 --- a/src/main/java/org/chorem/jtimer/JTimer.java +++ b/src/main/java/org/chorem/jtimer/JTimer.java @@ -130,8 +130,8 @@ public class JTimer extends SingleFrameApplication implements /** Single task or project selection. */ protected boolean selectedSingleElement; - /** At least one task running. */ - protected boolean singleRunningTask; + /** Single running task selection. */ + protected boolean selectedSingleRunningTask; /** Single non running task selection. */ protected boolean selectedSingleStoppedTask; @@ -331,7 +331,7 @@ public class JTimer extends SingleFrameApplication implements * @return tool bar builded */ protected JComponent createToolBar() { - String[] toolbarActionNames = {"startTask", "stopAllTasks", "newProject", + String[] toolbarActionNames = {"startTask", "stopTask", "newProject", "newTask", "---", "addAnnotation", "editAlert"}; JToolBar toolBar = new JToolBar(); toolBar.setFloatable(false); @@ -691,9 +691,6 @@ public class JTimer extends SingleFrameApplication implements @Action(enabledProperty = "selectedSingleStoppedTask") public Task<?, ?> startTask() { - // stop all other - stopAllTasks(); - // search for selected task in tree // can't be null TimerTask task = projectsAndTasksTable.getSelectedTasks().get(0); @@ -710,10 +707,6 @@ public class JTimer extends SingleFrameApplication implements * @param taskPath task path to start (from root to task) */ public void startTask(String taskPath) { - - // stop all other - stopAllTasks(); - TimerTask task = core.getData().getTaskForPath(taskPath); if (task != null) { RunTaskJob jobToRun = new RunTaskJob(this, task, core.getData()); @@ -732,7 +725,7 @@ public class JTimer extends SingleFrameApplication implements * @param task started task */ public void startedTask(TimerTask task) { - setSingleRunningTask(true); + setSelectedSingleRunningTask(true); setSelectedSingleStoppedTask(false); } @@ -757,19 +750,16 @@ public class JTimer extends SingleFrameApplication implements } /** - * Stop all running task in tree. - * + * Stop selected task in tree. + * * Verify if it has been started */ - @Action(enabledProperty = "singleRunningTask") - public void stopAllTasks() { + @Action(enabledProperty = "selectedSingleRunningTask") + public void stopTask() { - TaskMonitor tm = getContext().getTaskMonitor(); - for (Task<?, ?> t : tm.getTasks()) { - // task - TimerTask ttask = ((RunTaskJob) t).getTask(); - stopTask(ttask); - } + // task can't be null + TimerTask task = projectsAndTasksTable.getSelectedTasks().get(0); + stopTask(task); } @@ -782,6 +772,7 @@ public class JTimer extends SingleFrameApplication implements * @param task task to stop */ public void stopTask(TimerTask task) { + RunTaskJob rtt = getJobForRunningTask(task); // test if task is already running if (rtt != null) { @@ -789,12 +780,25 @@ public class JTimer extends SingleFrameApplication implements core.getData().stopTask(task); // re-enable/disable buttons - setSingleRunningTask(false); + setSelectedSingleRunningTask(false); setSelectedSingleStoppedTask(true); } } /** + * Stop all running tasks. + */ + public void stopAllTasks() { + + TaskMonitor tm = getContext().getTaskMonitor(); + for (Task<?, ?> t : tm.getTasks()) { + // task + TimerTask ttask = ((RunTaskJob) t).getTask(); + stopTask(ttask); + } + } + + /** * Close project. */ @Action(enabledProperty = "selectedSingleProject") @@ -1195,23 +1199,24 @@ public class JTimer extends SingleFrameApplication implements } /** - * Is running task. - * - * @return the singleRunningTask + * Is selected running task. + * + * @return the selectedSingleRunningTask */ - public boolean isSingleRunningTask() { - return singleRunningTask; + public boolean isSelectedSingleRunningTask() { + return selectedSingleRunningTask; } /** * Change selected running task property. - * - * @param singleRunningTask running task property + * + * @param selectedSingleRunningTask selected running task property */ - public void setSingleRunningTask(boolean singleRunningTask) { - boolean oldValue = this.singleRunningTask; - this.singleRunningTask = singleRunningTask; - firePropertyChange("singleRunningTask", oldValue, singleRunningTask); + public void setSelectedSingleRunningTask(boolean selectedSingleRunningTask) { + boolean oldValue = this.selectedSingleRunningTask; + this.selectedSingleRunningTask = selectedSingleRunningTask; + firePropertyChange("selectedSingleRunningTask", oldValue, + selectedSingleRunningTask); } /** @@ -1356,8 +1361,10 @@ public class JTimer extends SingleFrameApplication implements RunTaskJob job = getJobForRunningTask(task); if (job == null || job.isStopping()) { setSelectedSingleStoppedTask(true); + setSelectedSingleRunningTask(false); } else { setSelectedSingleStoppedTask(false); + setSelectedSingleRunningTask(true); } setSelectedMultiplesTasks(false); setSelectedSingleProject(false); @@ -1366,6 +1373,7 @@ public class JTimer extends SingleFrameApplication implements } else { setSelectedSingleTask(false); setSelectedSingleStoppedTask(false); + setSelectedSingleRunningTask(false); if (tasks.size() > 1) { setSelectedMultiplesTasks(projects.size() == 0); @@ -1449,6 +1457,10 @@ public class JTimer extends SingleFrameApplication implements if (isSelectedSingleStoppedTask()) { // can only launch non running tasks Task<?, ?> appTask = startTask(); if (appTask != null) { + + // first, on dlb click stop all running tasks + stopAllTasks(); + getContext().getTaskService().execute(appTask); } } else if (isSelectedSingleTask()) { @@ -1492,7 +1504,7 @@ public class JTimer extends SingleFrameApplication implements } if (isSelectedSingleTask()) { - actionNames = new String[]{"startTask", "---", + actionNames = new String[]{"startTask", "stopTask", "---", "newTask", "editTask", "closeTask", "deleteTask", "---", "addAnnotation", "editAlert", "increment1Task", "increment5Task", "increment30Task", "decrement1Task", 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 6a80d4f..5ee6dee 100644 --- a/src/main/java/org/chorem/jtimer/ui/systray/SystrayManager.java +++ b/src/main/java/org/chorem/jtimer/ui/systray/SystrayManager.java @@ -82,9 +82,6 @@ public class SystrayManager extends WindowAdapter implements ActionListener, Dat /** Reference how many tasks are running. */ protected int nbTasksRunning = 0; - /** Current running task. */ - protected TimerTask currentTask; - /** Non running popup menu instance. */ protected JPopupMenu popup; @@ -229,7 +226,7 @@ public class SystrayManager extends WindowAdapter implements ActionListener, Dat } else { trayIcon.setImage(runningImage); if (nbTasksRunning == 1) { - message = resourceMap.getString("tooltipRunningTaskText", task.getName()); + message = resourceMap.getString("tooltipRunningTaskText", nbTasksRunning); } else { message = resourceMap.getString("tooltipRunningTasksText", nbTasksRunning); } diff --git a/src/main/resources/org/chorem/jtimer/resources/JTimer.properties b/src/main/resources/org/chorem/jtimer/resources/JTimer.properties index 53bf3d7..c442616 100644 --- a/src/main/resources/org/chorem/jtimer/resources/JTimer.properties +++ b/src/main/resources/org/chorem/jtimer/resources/JTimer.properties @@ -80,10 +80,10 @@ startTask.Action.icon = go-next.png startTask.Action.accelerator = alt S startTask.Action.shortDescription = Start selected task -stopAllTasks.Action.text = Stop &running task -stopAllTasks.Action.icon = process-stop.png -stopAllTasks.Action.accelerator = alt shift S -stopAllTasks.Action.shortDescription = Stop running task +stopTask.Action.text = St&op +stopTask.Action.icon = process-stop.png +stopTask.Action.accelerator = alt shift S +stopTask.Action.shortDescription = Stop selected task addAnnotation.Action.text = Add &annotation addAnnotation.Action.icon = notes.png 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 c34b822..a7975bf 100644 --- a/src/main/resources/org/chorem/jtimer/resources/JTimer_fr.properties +++ b/src/main/resources/org/chorem/jtimer/resources/JTimer_fr.properties @@ -55,9 +55,9 @@ startTask.Action.text = &D\u00E9marrer startTask.Action.icon = go-next.png startTask.Action.shortDescription = D\u00E9marre la t\u00E2che s\u00E9lectionn\u00E9e -stopAllTasks.Action.text = Arr\u00EAter la t\u00E2che en &cours -stopAllTasks.Action.icon = process-stop.png -stopAllTasks.Action.shortDescription = Arr\u00EAte la t\u00E2che en cours +stopTask.Action.text = Arr\u00EAter +stopTask.Action.icon = process-stop.png +stopTask.Action.shortDescription = Arr\u00EAte la t\u00E2che s\u00E9lectionn\u00E9e addAnnotation.Action.text = Ajouter une &annotation addAnnotation.Action.shortDescription = Ajouter une annotation diff --git a/src/main/resources/org/chorem/jtimer/ui/systray/resources/SystrayManager.properties b/src/main/resources/org/chorem/jtimer/ui/systray/resources/SystrayManager.properties index ff79130..1c53616 100644 --- a/src/main/resources/org/chorem/jtimer/ui/systray/resources/SystrayManager.properties +++ b/src/main/resources/org/chorem/jtimer/ui/systray/resources/SystrayManager.properties @@ -2,7 +2,7 @@ # #%L # jTimer # %% -# Copyright (C) 2007 - 2011 CodeLutin, Chatellier Eric +# 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 @@ -19,16 +19,16 @@ # <http://www.gnu.org/licenses/gpl-3.0.html>. # #L% ### -#�tray icon +# tray icon idleImage = jtimer-40-orange.png runningImage = jtimer-40-green.png idleDetectImage = jtimer-40-grey.png # tray i18n tooltipIdleText = ${Application.title} -tooltipRunningTaskText = ${Application.title} - %s +tooltipRunningTaskText = ${Application.title} - %d task running tooltipRunningTasksText = ${Application.title} - %d tasks running showMenuText = Show hideMenuText = Hide -stopMenuText = Stop running task +stopMenuText = Stop all tasks quitMenuText = Quit diff --git a/src/main/resources/org/chorem/jtimer/ui/systray/resources/SystrayManager_fr.properties b/src/main/resources/org/chorem/jtimer/ui/systray/resources/SystrayManager_fr.properties index fe6d1d1..1e2e650 100644 --- a/src/main/resources/org/chorem/jtimer/ui/systray/resources/SystrayManager_fr.properties +++ b/src/main/resources/org/chorem/jtimer/ui/systray/resources/SystrayManager_fr.properties @@ -2,7 +2,7 @@ # #%L # jTimer # %% -# Copyright (C) 2007 - 2011 CodeLutin, Chatellier Eric +# 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 @@ -21,9 +21,9 @@ ### # tray i18n tooltipIdleText = ${Application.title} -tooltipRunningTaskText = ${Application.title} - %s +tooltipRunningTaskText = ${Application.title} - %d t\u00E2che en cours tooltipRunningTasksText = ${Application.title} - %d t\u00E2ches en cours showMenuText = Montrer hideMenuText = Cacher -stopMenuText = Arr\u00EAter la t\u00E2che en cours +stopMenuText = Arr\u00EAter toutes les t\u00E2ches quitMenuText = Quitter -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.