Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUwe Stieber2013-10-09 09:16:52 -0400
committerUwe Stieber2013-10-09 09:16:52 -0400
commitaa48a9885c6d33cc155c09e1415e9d1fa4a2b406 (patch)
tree6de090f1720fbe1c6bba2eed4dea1c4986731f41 /target_explorer/plugins/org.eclipse.tcf.te.runtime.notifications/src
parent1b23929809aa60bcd0fb59accffaa33356e85649 (diff)
downloadorg.eclipse.tcf-aa48a9885c6d33cc155c09e1415e9d1fa4a2b406.tar.gz
org.eclipse.tcf-aa48a9885c6d33cc155c09e1415e9d1fa4a2b406.tar.xz
org.eclipse.tcf-aa48a9885c6d33cc155c09e1415e9d1fa4a2b406.zip
Target Explorer: Added notification popup implementation based on mylyn commons.
Diffstat (limited to 'target_explorer/plugins/org.eclipse.tcf.te.runtime.notifications/src')
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.runtime.notifications/src/org/eclipse/tcf/te/runtime/notifications/AbstractNotification.java93
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.runtime.notifications/src/org/eclipse/tcf/te/runtime/notifications/NotificationSink.java22
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.runtime.notifications/src/org/eclipse/tcf/te/runtime/notifications/NotificationSinkEvent.java32
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.runtime.notifications/src/org/eclipse/tcf/te/runtime/notifications/interfaces/INotificationService.java39
4 files changed, 186 insertions, 0 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime.notifications/src/org/eclipse/tcf/te/runtime/notifications/AbstractNotification.java b/target_explorer/plugins/org.eclipse.tcf.te.runtime.notifications/src/org/eclipse/tcf/te/runtime/notifications/AbstractNotification.java
new file mode 100644
index 000000000..d6a1a7e72
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.runtime.notifications/src/org/eclipse/tcf/te/runtime/notifications/AbstractNotification.java
@@ -0,0 +1,93 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2013 Tasktop Technologies and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Tasktop Technologies - initial API and implementation
+ * Wind River Systems - Extracted from o.e.mylyn.commons and adapted for Target Explorer
+ *******************************************************************************/
+
+package org.eclipse.tcf.te.runtime.notifications;
+
+import java.util.Date;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.IAdaptable;
+
+/**
+ * A notification. Each notification has an associated <code>eventId</code> that identifies the type of the
+ * notification.
+ *
+ * @author Rob Elves
+ * @author Mik Kersten
+ * @author Steffen Pingel
+ */
+public abstract class AbstractNotification implements Comparable<AbstractNotification>, IAdaptable {
+
+ private final String eventId;
+
+ /**
+ * Constructor
+ *
+ * @param eventId The event id. Must not be <code>null</code>.
+ */
+ public AbstractNotification(String eventId) {
+ Assert.isNotNull(eventId);
+ this.eventId = eventId;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Comparable#compareTo(java.lang.Object)
+ */
+ @Override
+ public int compareTo(AbstractNotification o) {
+ if (o == null) {
+ return 1;
+ }
+ return compare(getDate(), o.getDate());
+ }
+
+ /**
+ * Compares <code>o1</code> and <code>o2</code>.
+ *
+ * @return a negative integer, 0, or a positive, if o1 is less than o2, o1 equals o2 or o1 is more than o2; null is
+ * considered less than any value
+ */
+ private static <T> int compare(Comparable<T> o1, T o2) {
+ if (o1 == null) {
+ return (o2 != null) ? 1 : 0;
+ } else if (o2 == null) {
+ return -1;
+ }
+ return o1.compareTo(o2);
+ }
+
+ /**
+ * Returns the event id.
+ *
+ * @return The event id.
+ */
+ public final String getEventId() {
+ return eventId;
+ }
+
+ public abstract Date getDate();
+
+ public abstract String getDescription();
+
+ public abstract String getLabel();
+
+ /**
+ * Returns a token that identifies correlated notifications, e.g. all notifications resulting from a refresh
+ * operation. Returns <code>null</code> by default.
+ *
+ * @return any object; null, if no token is specified
+ */
+ public Object getToken() {
+ return null;
+ }
+
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime.notifications/src/org/eclipse/tcf/te/runtime/notifications/NotificationSink.java b/target_explorer/plugins/org.eclipse.tcf.te.runtime.notifications/src/org/eclipse/tcf/te/runtime/notifications/NotificationSink.java
new file mode 100644
index 000000000..3c37ab97d
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.runtime.notifications/src/org/eclipse/tcf/te/runtime/notifications/NotificationSink.java
@@ -0,0 +1,22 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2013 Tasktop Technologies and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Tasktop Technologies - initial API and implementation
+ * Wind River Systems - Extracted from o.e.mylyn.commons and adapted for Target Explorer
+ *******************************************************************************/
+
+package org.eclipse.tcf.te.runtime.notifications;
+
+/**
+ * @author Steffen Pingel
+ */
+public abstract class NotificationSink {
+
+ public abstract void notify(NotificationSinkEvent event);
+
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime.notifications/src/org/eclipse/tcf/te/runtime/notifications/NotificationSinkEvent.java b/target_explorer/plugins/org.eclipse.tcf.te.runtime.notifications/src/org/eclipse/tcf/te/runtime/notifications/NotificationSinkEvent.java
new file mode 100644
index 000000000..06084e14f
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.runtime.notifications/src/org/eclipse/tcf/te/runtime/notifications/NotificationSinkEvent.java
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2013 Tasktop Technologies and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Tasktop Technologies - initial API and implementation
+ * Wind River Systems - Extracted from o.e.mylyn.commons and adapted for Target Explorer
+ *******************************************************************************/
+
+package org.eclipse.tcf.te.runtime.notifications;
+
+import java.util.List;
+
+/**
+ * @author Steffen Pingel
+ */
+public class NotificationSinkEvent {
+
+ private final List<AbstractNotification> notifications;
+
+ public NotificationSinkEvent(List<AbstractNotification> notifications) {
+ this.notifications = notifications;
+ }
+
+ public List<AbstractNotification> getNotifications() {
+ return notifications;
+ }
+
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime.notifications/src/org/eclipse/tcf/te/runtime/notifications/interfaces/INotificationService.java b/target_explorer/plugins/org.eclipse.tcf.te.runtime.notifications/src/org/eclipse/tcf/te/runtime/notifications/interfaces/INotificationService.java
new file mode 100644
index 000000000..a8760cb86
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.runtime.notifications/src/org/eclipse/tcf/te/runtime/notifications/interfaces/INotificationService.java
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2013 Tasktop Technologies and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Tasktop Technologies - initial API and implementation
+ * Wind River Systems - Extracted from o.e.mylyn.commons and adapted for Target Explorer
+ *******************************************************************************/
+
+package org.eclipse.tcf.te.runtime.notifications.interfaces;
+
+import org.eclipse.tcf.te.runtime.notifications.AbstractNotification;
+import org.eclipse.tcf.te.runtime.services.interfaces.IService;
+
+/**
+ * @author Steffen Pingel
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ */
+public interface INotificationService extends IService {
+
+ /**
+ * Single notification.
+ *
+ * @param notification The notification. Must not be <code>null</code>.
+ */
+ public void notify(AbstractNotification notification);
+
+ /**
+ * Multi notification.
+ *
+ * @param notifications The notifications. Must not be <code>null</code>.
+ */
+ public void notify(AbstractNotification[] notifications);
+
+}

Back to the top