Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQi Wang2016-09-24 12:21:26 -0400
committerJaxsun McCarthy Huggan2016-10-07 14:42:41 -0400
commita2991dc2f487b9fa565014caf365569fa6fedd9b (patch)
treea54f082d3a3817e0415a740a600638951b2fe03e
parent2abd17c2ef00212b7ebd680d0c866ced9195d167 (diff)
downloadorg.eclipse.mylyn.tasks-a2991dc2f487b9fa565014caf365569fa6fedd9b.tar.gz
org.eclipse.mylyn.tasks-a2991dc2f487b9fa565014caf365569fa6fedd9b.tar.xz
org.eclipse.mylyn.tasks-a2991dc2f487b9fa565014caf365569fa6fedd9b.zip
502035: add tasks preferences UI for synchronizing relevant tasks
Change-Id: I1405d090cd91db0c38be1e361ca86748f4e7f0db Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=502035 Signed-off-by: Qi Wang <qwang12@ubishops.ca>
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/ITasksUiPreferenceConstants.java2
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/TasksUiPlugin.java1
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/preferences/Messages.java6
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/preferences/TasksUiPreferencePage.java127
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/preferences/messages.properties4
5 files changed, 94 insertions, 46 deletions
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/ITasksUiPreferenceConstants.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/ITasksUiPreferenceConstants.java
index 1f2fae768..8ae089cff 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/ITasksUiPreferenceConstants.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/ITasksUiPreferenceConstants.java
@@ -86,6 +86,8 @@ public interface ITasksUiPreferenceConstants {
public static final String REPOSITORY_SYNCH_SCHEDULE_MILISECONDS = "org.eclipse.mylyn.tasks.ui.repositories.synch.schedule.miliseconds"; //$NON-NLS-1$
+ public static final String RELEVANT_TASKS_SCHEDULE_MILISECONDS = "org.eclipse.mylyn.tasks.ui.relevant.tasks.synch.schedule.miliseconds"; //$NON-NLS-1$
+
public static final String TEMPLATES_DELETED = "org.eclipse.mylyn.tasks.ui.templates.deleted"; //$NON-NLS-1$
public static final String TEMPLATES_DELETED_DELIM = "|"; //$NON-NLS-1$
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 942f4919b..510347025 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
@@ -996,6 +996,7 @@ public class TasksUiPlugin extends AbstractUIPlugin {
store.setDefault(ITasksUiPreferenceConstants.REPOSITORY_SYNCH_SCHEDULE_ENABLED, true);
store.setDefault(ITasksUiPreferenceConstants.REPOSITORY_SYNCH_SCHEDULE_MILISECONDS, "" + (20 * 60 * 1000)); //$NON-NLS-1$
+ store.setDefault(ITasksUiPreferenceConstants.RELEVANT_TASKS_SCHEDULE_MILISECONDS, "" + (5 * 60 * 1000)); //$NON-NLS-1$
store.setDefault(ITasksUiPreferenceConstants.BACKUP_MAXFILES, 20);
store.setDefault(ITasksUiPreferenceConstants.BACKUP_LAST, 0f);
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/preferences/Messages.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/preferences/Messages.java
index e41578c7c..7864200b3 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/preferences/Messages.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/preferences/Messages.java
@@ -83,11 +83,15 @@ public class Messages extends NLS {
public static String TasksUiPreferencePage_Stop_time_accumulation_after;
+ public static String TasksUiPreferencePage_Synchronize_Fully;
+
+ public static String TasksUiPreferencePage_Synchronize_Relevant_Tasks;
+
public static String TasksUiPreferencePage_Synchronize_schedule_time_must_be_GT_0;
public static String TasksUiPreferencePage_Synchronize_schedule_time_must_be_valid_integer;
- public static String TasksUiPreferencePage_Synchronize_with_repositories_every;
+ public static String TasksUiPreferencePage_Synchronize_Task_List;
public static String TasksUiPreferencePage_Synchronization;
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/preferences/TasksUiPreferencePage.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/preferences/TasksUiPreferencePage.java
index bb806358e..a013bc281 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/preferences/TasksUiPreferencePage.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/preferences/TasksUiPreferencePage.java
@@ -19,6 +19,7 @@ import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.layout.GridDataFactory;
+import org.eclipse.jface.layout.GridLayoutFactory;
import org.eclipse.jface.preference.PreferencePage;
import org.eclipse.mylyn.commons.core.CommonMessages;
import org.eclipse.mylyn.commons.core.StatusHandler;
@@ -91,7 +92,9 @@ public class TasksUiPreferencePage extends PreferencePage implements IWorkbenchP
private Button useWebBrowser;
- private Text synchScheduleTime = null;
+ private Text fullSyncScheduleTime = null;
+
+ private Text relevantTasksSyncScheduleTime = null;
private Button enableBackgroundSynch;
@@ -221,11 +224,14 @@ public class TasksUiPreferencePage extends PreferencePage implements IWorkbenchP
getPreferenceStore().setValue(ITasksUiPreferenceConstants.EDITOR_TASKS_RICH, useRichEditor.getSelection());
getPreferenceStore().setValue(ITasksUiPreferenceConstants.EDITOR_CURRENT_LINE_HIGHLIGHT,
editorHighlightsCurrentLine.getSelection());
+
getPreferenceStore().setValue(ITasksUiPreferenceConstants.REPOSITORY_SYNCH_SCHEDULE_ENABLED,
enableBackgroundSynch.getSelection());
- long miliseconds = 60000 * Long.parseLong(synchScheduleTime.getText());
- getPreferenceStore().setValue(ITasksUiPreferenceConstants.REPOSITORY_SYNCH_SCHEDULE_MILISECONDS,
- "" + miliseconds); //$NON-NLS-1$
+
+ String miliseconds = toMillisecondsString(fullSyncScheduleTime.getText());
+ getPreferenceStore().setValue(ITasksUiPreferenceConstants.REPOSITORY_SYNCH_SCHEDULE_MILISECONDS, miliseconds);
+ miliseconds = toMillisecondsString(relevantTasksSyncScheduleTime.getText());
+ getPreferenceStore().setValue(ITasksUiPreferenceConstants.RELEVANT_TASKS_SCHEDULE_MILISECONDS, miliseconds);
getPreferenceStore().setValue(ITasksUiPreferenceConstants.TASK_LIST_TOOL_TIPS_ENABLED,
taskListTooltipEnabledButton.getSelection());
@@ -276,6 +282,10 @@ public class TasksUiPreferencePage extends PreferencePage implements IWorkbenchP
return true;
}
+ private String toMillisecondsString(String minutesString) {
+ return Long.toString(60 * 1000 * Long.parseLong(minutesString));
+ }
+
private int getWeekStartValue() {
return weekStartCombo.getSelectionIndex() + 1;
}
@@ -295,9 +305,15 @@ public class TasksUiPreferencePage extends PreferencePage implements IWorkbenchP
editorHighlightsCurrentLine.setSelection(
getPreferenceStore().getBoolean(ITasksUiPreferenceConstants.EDITOR_CURRENT_LINE_HIGHLIGHT));
- enableBackgroundSynch.setSelection(
- getPreferenceStore().getBoolean(ITasksUiPreferenceConstants.REPOSITORY_SYNCH_SCHEDULE_ENABLED));
- synchScheduleTime.setText(getMinutesString());
+ String repositorySyncMinutes = toMinutesString(
+ getPreferenceStore().getLong(ITasksUiPreferenceConstants.REPOSITORY_SYNCH_SCHEDULE_MILISECONDS));
+ String relevantSyncMinutes = toMinutesString(
+ getPreferenceStore().getLong(ITasksUiPreferenceConstants.RELEVANT_TASKS_SCHEDULE_MILISECONDS));
+ boolean shouldSyncAutomatically = getPreferenceStore()
+ .getBoolean(ITasksUiPreferenceConstants.REPOSITORY_SYNCH_SCHEDULE_ENABLED);
+ enableBackgroundSynch.setSelection(shouldSyncAutomatically);
+ fullSyncScheduleTime.setText(repositorySyncMinutes);
+ relevantTasksSyncScheduleTime.setText(relevantSyncMinutes);
taskListTooltipEnabledButton
.setSelection(getPreferenceStore().getBoolean(ITasksUiPreferenceConstants.TASK_LIST_TOOL_TIPS_ENABLED));
@@ -344,10 +360,10 @@ public class TasksUiPreferencePage extends PreferencePage implements IWorkbenchP
enableBackgroundSynch.setSelection(
getPreferenceStore().getDefaultBoolean(ITasksUiPreferenceConstants.REPOSITORY_SYNCH_SCHEDULE_ENABLED));
- long miliseconds = getPreferenceStore()
- .getDefaultLong(ITasksUiPreferenceConstants.REPOSITORY_SYNCH_SCHEDULE_MILISECONDS);
- long minutes = miliseconds / 60000;
- synchScheduleTime.setText("" + minutes); //$NON-NLS-1$
+ fullSyncScheduleTime.setText(toMinutesString(getPreferenceStore()
+ .getDefaultLong(ITasksUiPreferenceConstants.REPOSITORY_SYNCH_SCHEDULE_MILISECONDS)));
+ relevantTasksSyncScheduleTime.setText(toMinutesString(
+ getPreferenceStore().getDefaultLong(ITasksUiPreferenceConstants.RELEVANT_TASKS_SCHEDULE_MILISECONDS)));
weekStartCombo.select(getPreferenceStore().getDefaultInt(ITasksUiPreferenceConstants.WEEK_START_DAY) - 1);
String defaultScheduleFor = getPreferenceStore()
@@ -372,17 +388,16 @@ public class TasksUiPreferencePage extends PreferencePage implements IWorkbenchP
private void createTaskRefreshScheduleGroup(Composite parent) {
Group group = new Group(parent, SWT.SHADOW_ETCHED_IN);
group.setText(Messages.TasksUiPreferencePage_Synchronization);
- GridLayout gridLayout = new GridLayout(1, false);
- group.setLayout(gridLayout);
+
+ group.setLayout(new GridLayout(1, false));
group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- Composite enableSynch = new Composite(group, SWT.NULL);
- gridLayout = new GridLayout(4, false);
- gridLayout.marginWidth = 0;
- gridLayout.marginHeight = 0;
- enableSynch.setLayout(gridLayout);
- enableBackgroundSynch = new Button(enableSynch, SWT.CHECK);
- enableBackgroundSynch.setText(Messages.TasksUiPreferencePage_Synchronize_with_repositories_every);
+ Composite backgroundSync = new Composite(group, SWT.NULL);
+ GridLayoutFactory.swtDefaults().numColumns(3).equalWidth(false).margins(0, 0).applyTo(backgroundSync);
+
+ //Enabled background synchronization
+ enableBackgroundSynch = new Button(backgroundSync, SWT.CHECK);
+ enableBackgroundSynch.setText(Messages.TasksUiPreferencePage_Synchronize_Task_List);
enableBackgroundSynch.setSelection(
getPreferenceStore().getBoolean(ITasksUiPreferenceConstants.REPOSITORY_SYNCH_SCHEDULE_ENABLED));
enableBackgroundSynch.addSelectionListener(new SelectionListener() {
@@ -393,19 +408,21 @@ public class TasksUiPreferencePage extends PreferencePage implements IWorkbenchP
public void widgetDefaultSelected(SelectionEvent e) {
}
});
- synchScheduleTime = new Text(enableSynch, SWT.BORDER | SWT.RIGHT);
- GridData gridData = new GridData();
- gridData.widthHint = 25;
- synchScheduleTime.setLayoutData(gridData);
- synchScheduleTime.setText(getMinutesString());
- synchScheduleTime.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- updateRefreshGroupEnablements();
- }
- });
- Label label = new Label(enableSynch, SWT.NONE);
- label.setText(Messages.TasksUiPreferencePage_minutes);
+ GridDataFactory.defaultsFor(enableBackgroundSynch).span(3, 1).applyTo(enableBackgroundSynch);
+
+ //Synchronize Task List Fully
+ new Label(backgroundSync, SWT.NONE).setText(Messages.TasksUiPreferencePage_Synchronize_Fully);
+ fullSyncScheduleTime = createSynchronizationScheduleTextBox(backgroundSync,
+ ITasksUiPreferenceConstants.REPOSITORY_SYNCH_SCHEDULE_MILISECONDS);
+ new Label(backgroundSync, SWT.NONE).setText(Messages.TasksUiPreferencePage_minutes);
+
+ //Synchronize Relevant Tasks
+ new Label(backgroundSync, SWT.NONE).setText(Messages.TasksUiPreferencePage_Synchronize_Relevant_Tasks);
+ relevantTasksSyncScheduleTime = createSynchronizationScheduleTextBox(backgroundSync,
+ ITasksUiPreferenceConstants.RELEVANT_TASKS_SCHEDULE_MILISECONDS);
+ new Label(backgroundSync, SWT.NONE).setText(Messages.TasksUiPreferencePage_minutes);
+ //notification
notificationEnabledButton = new Button(group, SWT.CHECK);
notificationEnabledButton
.setText(Messages.TasksUiPreferencePage_Display_notifications_for_overdue_tasks_and_incoming_changes);
@@ -414,6 +431,21 @@ public class TasksUiPreferencePage extends PreferencePage implements IWorkbenchP
}
+ private Text createSynchronizationScheduleTextBox(Composite backgroundSync, String preferenceKey) {
+ Text text = new Text(backgroundSync, SWT.BORDER | SWT.RIGHT);
+ GridData gridDataRepo = new GridData();
+ gridDataRepo.widthHint = 25;
+ text.setLayoutData(gridDataRepo);
+ long querySyncMilliseconds = getPreferenceStore().getLong(preferenceKey);
+ text.setText(toMinutesString(querySyncMilliseconds));
+ text.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ updateRefreshGroupEnablements();
+ }
+ });
+ return text;
+ }
+
private void createTaskEditorGroup(Composite parent) {
Group container = new Group(parent, SWT.SHADOW_ETCHED_IN);
container.setLayout(new GridLayout(2, false));
@@ -608,13 +640,9 @@ public class TasksUiPreferencePage extends PreferencePage implements IWorkbenchP
String errorMessage = null;
if (enableBackgroundSynch.getSelection()) {
- try {
- long number = Long.parseLong(synchScheduleTime.getText());
- if (number <= 0) {
- errorMessage = Messages.TasksUiPreferencePage_Synchronize_schedule_time_must_be_GT_0;
- }
- } catch (NumberFormatException e) {
- errorMessage = Messages.TasksUiPreferencePage_Synchronize_schedule_time_must_be_valid_integer;
+ errorMessage = validateSynchronizeSchedule(fullSyncScheduleTime);
+ if (errorMessage == null) {
+ errorMessage = validateSynchronizeSchedule(relevantTasksSyncScheduleTime);
}
}
@@ -633,15 +661,26 @@ public class TasksUiPreferencePage extends PreferencePage implements IWorkbenchP
timeoutLabel2.setEnabled(false);
}
- synchScheduleTime.setEnabled(enableBackgroundSynch.getSelection());
+ fullSyncScheduleTime.setEnabled(enableBackgroundSynch.getSelection());
+ relevantTasksSyncScheduleTime.setEnabled(enableBackgroundSynch.getSelection());
+ }
+ private String validateSynchronizeSchedule(Text synchronizeText) {
+ String errorMessage = null;
+ try {
+ long number = Long.parseLong(synchronizeText.getText());
+ if (number <= 0) {
+ errorMessage = Messages.TasksUiPreferencePage_Synchronize_schedule_time_must_be_GT_0;
+ }
+ } catch (NumberFormatException e) {
+ errorMessage = Messages.TasksUiPreferencePage_Synchronize_schedule_time_must_be_valid_integer;
+ }
+ return errorMessage;
}
- private String getMinutesString() {
- long miliseconds = getPreferenceStore()
- .getLong(ITasksUiPreferenceConstants.REPOSITORY_SYNCH_SCHEDULE_MILISECONDS);
+ private String toMinutesString(long miliseconds) {
long minutes = miliseconds / 60000;
- return "" + minutes; //$NON-NLS-1$
+ return Long.toString(minutes);
}
private boolean checkForExistingTasklist(String dir) {
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/preferences/messages.properties b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/preferences/messages.properties
index bdcb83592..4180dfebe 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/preferences/messages.properties
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/preferences/messages.properties
@@ -37,9 +37,11 @@ TasksUiPreferencePage_Show_active_task_trim_Button_Label=Show active task on win
TasksUiPreferencePage_Show_tooltip_on_hover_Label=Show task overview popups on hover
TasksUiPreferencePage_Specify_the_folder_for_tasks=Specify the folder for tasks
TasksUiPreferencePage_Stop_time_accumulation_after=Stop time accumulation after
+TasksUiPreferencePage_Synchronize_Fully=Synchronize the Task List fully every
+TasksUiPreferencePage_Synchronize_Relevant_Tasks=Synchronize relevant Tasks every
TasksUiPreferencePage_Synchronize_schedule_time_must_be_GT_0=Synchronize schedule time must be > 0
TasksUiPreferencePage_Synchronize_schedule_time_must_be_valid_integer=Synchronize schedule time must be valid integer
-TasksUiPreferencePage_Synchronize_with_repositories_every=Synchronize with repositories every
+TasksUiPreferencePage_Synchronize_Task_List=Synchronize Task List in the Background
TasksUiPreferencePage_Synchronization=Synchronization
TasksUiPreferencePage_Task_Data=Task Data
TasksUiPreferencePage_Task_Data_Directory_Error=Task Data Directory Error

Back to the top