diff options
author | David Yee | 2016-09-24 18:56:14 +0000 |
---|---|---|
committer | Gerrit Code Review @ Eclipse.org | 2016-10-12 21:03:10 +0000 |
commit | 0cb159ddc3ba5e84f9a7ab70ab37c1c069691074 (patch) | |
tree | 5f9047499bab8a4cc333b95a3b51f98d0ca25c9a | |
parent | 34d3d72f38d6fffd3c97830e4fdc536b156d37d1 (diff) | |
download | org.eclipse.mylyn.tasks-0cb159ddc3ba5e84f9a7ab70ab37c1c069691074.tar.gz org.eclipse.mylyn.tasks-0cb159ddc3ba5e84f9a7ab70ab37c1c069691074.tar.xz org.eclipse.mylyn.tasks-0cb159ddc3ba5e84f9a7ab70ab37c1c069691074.zip |
502035: Complete relevant task scheduler integration
Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=502035
Change-Id: I3a902b7c1436312b2d378555d8ca28ef154e5df4
Signed-off-by: David Yee <dveyee@hotmail.com>
-rw-r--r-- | org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/TasksUiPlugin.java | 68 |
1 files changed, 47 insertions, 21 deletions
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/TasksUiPlugin.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/TasksUiPlugin.java index 510347025..7d010ffa3 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/TasksUiPlugin.java +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/TasksUiPlugin.java @@ -163,7 +163,9 @@ public class TasksUiPlugin extends AbstractUIPlugin { private static TaskRepositoryManager repositoryManager; - private static TaskListSynchronizationScheduler synchronizationScheduler; + private static TaskListSynchronizationScheduler taskScheduler; + + private static TaskListSynchronizationScheduler relevantTaskScheduler; private static TaskDataManager taskDataManager; @@ -292,7 +294,16 @@ public class TasksUiPlugin extends AbstractUIPlugin { if (event.getProperty().equals(ITasksUiPreferenceConstants.REPOSITORY_SYNCH_SCHEDULE_ENABLED) || event.getProperty().equals(ITasksUiPreferenceConstants.REPOSITORY_SYNCH_SCHEDULE_MILISECONDS)) { - updateSynchronizationScheduler(false); + updateSynchronizationScheduler(taskScheduler, false, + ITasksUiPreferenceConstants.REPOSITORY_SYNCH_SCHEDULE_ENABLED, + ITasksUiPreferenceConstants.REPOSITORY_SYNCH_SCHEDULE_MILISECONDS); + } + + if (event.getProperty().equals(ITasksUiPreferenceConstants.REPOSITORY_SYNCH_SCHEDULE_ENABLED) + || event.getProperty().equals(ITasksUiPreferenceConstants.RELEVANT_TASKS_SCHEDULE_MILISECONDS)) { + updateSynchronizationScheduler(relevantTaskScheduler, false, + ITasksUiPreferenceConstants.REPOSITORY_SYNCH_SCHEDULE_ENABLED, + ITasksUiPreferenceConstants.RELEVANT_TASKS_SCHEDULE_MILISECONDS); } if (event.getProperty().equals(ITasksUiPreferenceConstants.SERVICE_MESSAGES_ENABLED)) { @@ -481,25 +492,35 @@ public class TasksUiPlugin extends AbstractUIPlugin { } } - private void updateSynchronizationScheduler(boolean initial) { - if (synchronizationScheduler == null) { + /** + * Updates the scheduler with the latest user-set preferences. + * + * @param scheduler + * The scheduler to schedule refreshes. + * @param initial + * <b>true</b> for the initial invocation; <b>false</b> for later invocations. When <b>true</b>, the + * scheduler interval is set to a fixed startup delay (typically 20 seconds). + * @param enabledKey + * The string key in the preferences which is used to retrieve the latest user-set value (on/off). + * @param intervalKey + * The string key in the preferences which is used to retrieve the latest schedule interval time. + */ + private void updateSynchronizationScheduler(TaskListSynchronizationScheduler scheduler, boolean initial, + String enabledKey, String intervalKey) { + if (scheduler == null) { return; } - boolean enabled = TasksUiPlugin.getDefault() - .getPreferenceStore() - .getBoolean(ITasksUiPreferenceConstants.REPOSITORY_SYNCH_SCHEDULE_ENABLED); + boolean enabled = TasksUiPlugin.getDefault().getPreferenceStore().getBoolean(enabledKey); if (enabled) { - long interval = TasksUiPlugin.getDefault() - .getPreferenceStore() - .getLong(ITasksUiPreferenceConstants.REPOSITORY_SYNCH_SCHEDULE_MILISECONDS); + long interval = TasksUiPlugin.getDefault().getPreferenceStore().getLong(intervalKey); if (initial) { - synchronizationScheduler.setInterval(DELAY_QUERY_REFRESH_ON_STARTUP, interval); + scheduler.setInterval(DELAY_QUERY_REFRESH_ON_STARTUP, interval); } else { - synchronizationScheduler.setInterval(interval); + scheduler.setInterval(interval); } } else { - synchronizationScheduler.setInterval(0); + scheduler.setInterval(0); } } @@ -1193,11 +1214,6 @@ public class TasksUiPlugin extends AbstractUIPlugin { return repositoryConnectorUiMap.get(kind); } - @Deprecated - public static TaskListSynchronizationScheduler getSynchronizationScheduler() { - return synchronizationScheduler; - } - /** * @since 3.0 */ @@ -1452,9 +1468,19 @@ public class TasksUiPlugin extends AbstractUIPlugin { SynchronizationJob refreshJob = taskJobFactory.createSynchronizeRepositoriesJob(null); refreshJob.setFullSynchronization(true); - synchronizationScheduler = new TaskListSynchronizationScheduler(refreshJob); - MonitorUiPlugin.getDefault().getActivityContextManager().addListener(synchronizationScheduler); - updateSynchronizationScheduler(true); + taskScheduler = new TaskListSynchronizationScheduler(refreshJob); + MonitorUiPlugin.getDefault().getActivityContextManager().addListener(taskScheduler); + updateSynchronizationScheduler(taskScheduler, true, + ITasksUiPreferenceConstants.REPOSITORY_SYNCH_SCHEDULE_ENABLED, + ITasksUiPreferenceConstants.REPOSITORY_SYNCH_SCHEDULE_MILISECONDS); + + Job relevantJob = new SynchronizeRelevantTasksJob(taskActivityManager, repositoryManager, taskJobFactory); + relevantTaskScheduler = new TaskListSynchronizationScheduler(relevantJob); + MonitorUiPlugin.getDefault().getActivityContextManager().addListener(relevantTaskScheduler); + updateSynchronizationScheduler(relevantTaskScheduler, true, + ITasksUiPreferenceConstants.REPOSITORY_SYNCH_SCHEDULE_ENABLED, + ITasksUiPreferenceConstants.RELEVANT_TASKS_SCHEDULE_MILISECONDS); + } catch (Throwable t) { StatusHandler.log(new Status(IStatus.ERROR, TasksUiPlugin.ID_PLUGIN, "Could not initialize task list backup and synchronization", t)); //$NON-NLS-1$ |