Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSam Davis2015-08-25 18:49:26 -0400
committerSam Davis2015-08-26 12:53:08 -0400
commitd7d046ca38d3dfbeef93e4f7a0939d0ea436f5c2 (patch)
tree12c8688b6f8cb9ebe51fffee2dd3a657a2a6043b
parent5528c60382bc995bcf112133696b4bdaf215f991 (diff)
downloadorg.eclipse.mylyn.tasks-d7d046ca38d3dfbeef93e4f7a0939d0ea436f5c2.tar.gz
org.eclipse.mylyn.tasks-d7d046ca38d3dfbeef93e4f7a0939d0ea436f5c2.tar.xz
org.eclipse.mylyn.tasks-d7d046ca38d3dfbeef93e4f7a0939d0ea436f5c2.zip
475540: enable plugins to display messages using the task list message
service Change-Id: I524a266b0ea4770a07511b543bcd4f5643337890 Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=475540
-rw-r--r--org.eclipse.mylyn.tasks.tests/META-INF/MANIFEST.MF4
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/ui/TaskListServiceMessageControlTest.java82
-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/notifications/TaskListServiceMessageControl.java7
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListView.java1
5 files changed, 91 insertions, 4 deletions
diff --git a/org.eclipse.mylyn.tasks.tests/META-INF/MANIFEST.MF b/org.eclipse.mylyn.tasks.tests/META-INF/MANIFEST.MF
index b523111a2..5bc10a930 100644
--- a/org.eclipse.mylyn.tasks.tests/META-INF/MANIFEST.MF
+++ b/org.eclipse.mylyn.tasks.tests/META-INF/MANIFEST.MF
@@ -32,7 +32,9 @@ Require-Bundle: org.junit;bundle-version="4.8.2",
org.eclipse.mylyn.tests.util,
org.eclipse.mylyn.commons.repositories.core,
org.eclipse.core.runtime.compatibility.auth;resolution:=optional,
- com.google.guava;bundle-version="15.0.0"
+ com.google.guava;bundle-version="15.0.0",
+ org.eclipse.mylyn.commons.notifications.feed,
+ org.eclipse.mylyn.commons.notifications.core
Export-Package: org.eclipse.mylyn.tasks.tests;x-internal:=true,
org.eclipse.mylyn.tasks.tests.bugs;x-internal:=true,
org.eclipse.mylyn.tasks.tests.connector;x-friends:="org.eclipse.mylyn.tasks.ui.tests",
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/ui/TaskListServiceMessageControlTest.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/ui/TaskListServiceMessageControlTest.java
index b8edda030..95501b24e 100644
--- a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/ui/TaskListServiceMessageControlTest.java
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/ui/TaskListServiceMessageControlTest.java
@@ -13,13 +13,41 @@ package org.eclipse.mylyn.tasks.tests.ui;
import junit.framework.TestCase;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.mylyn.commons.notifications.feed.ServiceMessageEvent;
+import org.eclipse.mylyn.commons.notifications.feed.ServiceMessageEvent.Kind;
+import org.eclipse.mylyn.commons.workbench.WorkbenchUtil;
+import org.eclipse.mylyn.internal.commons.notifications.feed.ServiceMessage;
+import org.eclipse.mylyn.internal.tasks.ui.ITasksUiPreferenceConstants;
+import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
import org.eclipse.mylyn.internal.tasks.ui.notifications.TaskListServiceMessageControl;
+import org.eclipse.swt.widgets.Composite;
+
+import com.google.common.collect.ImmutableList;
/**
* @author Steffen Pingel
*/
public class TaskListServiceMessageControlTest extends TestCase {
+ private final class TestTaskListServiceMessageControl extends TaskListServiceMessageControl {
+ private TestTaskListServiceMessageControl(Composite parent) {
+ super(parent);
+ }
+
+ @Override
+ protected void closeMessage() {
+ super.closeMessage();
+ }
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ TasksUiPlugin.getDefault()
+ .getPreferenceStore()
+ .setValue(ITasksUiPreferenceConstants.LAST_SERVICE_MESSAGE_ID, "");
+ }
+
public void testGetAction() {
assertEquals("abc", TaskListServiceMessageControl.getAction("ABC"));
assertEquals("abc", TaskListServiceMessageControl.getAction("abc"));
@@ -28,4 +56,58 @@ public class TaskListServiceMessageControlTest extends TestCase {
assertEquals(null, TaskListServiceMessageControl.getAction("http://eclipse.org?foo=bar&action=defg"));
}
+ public void testCloseMessageWithNoId() {
+ TestTaskListServiceMessageControl control = new TestTaskListServiceMessageControl(WorkbenchUtil.getShell());
+ control.setMessage(new ServiceMessage("123"));
+ control.closeMessage();
+ assertEquals("", getLastMessageId());
+ }
+
+ public void testCloseMessageWithId() {
+ TestTaskListServiceMessageControl control = new TestTaskListServiceMessageControl(WorkbenchUtil.getShell());
+ ServiceMessage message = new ServiceMessage("123");
+ message.setId("300");
+ control.setMessage(message);
+ control.closeMessage();
+ assertEquals("300", getLastMessageId());
+ }
+
+ public void testHandleEvent() throws Exception {
+ TestTaskListServiceMessageControl control = new TestTaskListServiceMessageControl(WorkbenchUtil.getShell());
+ handleMessage(control, "123");
+ control.closeMessage();
+ assertEquals("123", getLastMessageId());
+
+ handleMessage(control, "100");
+ control.closeMessage();
+ assertEquals("123", getLastMessageId());
+
+ handleMessage(control, "200");
+ control.closeMessage();
+ assertEquals("200", getLastMessageId());
+
+ handleMessage(control, "org.eclipse.mylyn.reset.1");
+ control.closeMessage();
+ assertEquals("", getLastMessageId());
+
+ handleMessage(control, "hello");
+ control.closeMessage();
+ assertEquals("hello", getLastMessageId());
+ }
+
+ private String getLastMessageId() {
+ return TasksUiPlugin.getDefault()
+ .getPreferenceStore()
+ .getString(ITasksUiPreferenceConstants.LAST_SERVICE_MESSAGE_ID);
+ }
+
+ private void handleMessage(TestTaskListServiceMessageControl control, String id) {
+ ServiceMessage message = new ServiceMessage("123");
+ message.setTitle("Title");
+ message.setDescription("Description");
+ message.setImage(Dialog.DLG_IMG_HELP);
+ message.setId(id);
+ control.handleEvent(new ServiceMessageEvent(TasksUiPlugin.getDefault().getServiceMessageManager(),
+ Kind.MESSAGE_UPDATE, ImmutableList.of(message)));
+ }
}
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 4c0c1cd58..49d65c8b9 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
@@ -434,7 +434,6 @@ public class TasksUiPlugin extends AbstractUIPlugin {
return false;
}
};
- message.setId("hide.nonmatching.subtasks"); //$NON-NLS-1$
message.setImage(Dialog.DLG_IMG_MESSAGE_INFO);
message.setTitle(Messages.TasksUiPlugin_Hide_Irrelevant_Subtasks);
message.setDescription(NLS.bind(Messages.TasksUiPlugin_Hide_Irrelevant_Subtasks_Message,
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/notifications/TaskListServiceMessageControl.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/notifications/TaskListServiceMessageControl.java
index c2cfea33c..54721b945 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/notifications/TaskListServiceMessageControl.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/notifications/TaskListServiceMessageControl.java
@@ -51,6 +51,7 @@ import org.eclipse.ui.handlers.IHandlerService;
* @author Steffen Pingel
* @author Torkild U. Resheim
*/
+@SuppressWarnings("restriction")
public class TaskListServiceMessageControl extends NotificationControl implements IServiceMessageListener {
private ServiceMessage currentMessage;
@@ -67,7 +68,7 @@ public class TaskListServiceMessageControl extends NotificationControl implement
@Override
protected void closeMessage() {
- if (currentMessage != null) {
+ if (currentMessage != null && currentMessage.getId() != null && !currentMessage.getId().equals("0")) { //$NON-NLS-1$
TasksUiPlugin.getDefault()
.getPreferenceStore()
.setValue(ITasksUiPreferenceConstants.LAST_SERVICE_MESSAGE_ID, currentMessage.getId());
@@ -81,6 +82,10 @@ public class TaskListServiceMessageControl extends NotificationControl implement
IPreferenceStore preferenceStore = TasksUiPlugin.getDefault().getPreferenceStore();
preferenceStore.setValue(ITasksUiPreferenceConstants.LAST_SERVICE_MESSAGE_CHECKTIME, new Date().getTime());
String lastMessageId = preferenceStore.getString(ITasksUiPreferenceConstants.LAST_SERVICE_MESSAGE_ID);
+ if (lastMessageId != null && lastMessageId.startsWith("org.eclipse.mylyn.reset.")) { //$NON-NLS-1$
+ lastMessageId = ""; //$NON-NLS-1$
+ preferenceStore.setValue(ITasksUiPreferenceConstants.LAST_SERVICE_MESSAGE_ID, lastMessageId);
+ }
for (final ServiceMessage message : event.getMessages()) {
if (!message.isValid() || message.getId().equals("-1")) { //$NON-NLS-1$
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListView.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListView.java
index 516bce197..bb9d70f2c 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListView.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListView.java
@@ -852,7 +852,6 @@ public class TaskListView extends AbstractTaskListView implements IPropertyChang
message.setDescription(Messages.TaskListView_Welcome_Message);
message.setTitle(Messages.TaskListView_Welcome_Message_Title);
message.setImage(Dialog.DLG_IMG_MESSAGE_INFO);
- message.setId("0"); //$NON-NLS-1$
serviceMessageControl.setMessage(message);
}

Back to the top