Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManuel Doninger2011-08-22 20:23:30 -0400
committerSteffen Pingel2011-08-22 20:23:30 -0400
commit322adb87a8732b447c0c271762fe3b861c19c269 (patch)
tree1d6419ef6053e54a1c022ce5dfada1bf2692dc31 /org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal
parentcc66518916118a0146170ef002e25612710e62d0 (diff)
downloadorg.eclipse.mylyn.tasks-322adb87a8732b447c0c271762fe3b861c19c269.tar.gz
org.eclipse.mylyn.tasks-322adb87a8732b447c0c271762fe3b861c19c269.tar.xz
org.eclipse.mylyn.tasks-322adb87a8732b447c0c271762fe3b861c19c269.zip
ASSIGNED - bug 349924: [patch][api] provide extension point for task
activation listeners https://bugs.eclipse.org/bugs/show_bug.cgi?id=349924
Diffstat (limited to 'org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal')
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/ITasksCoreConstants.java2
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/TaskActivityManager.java45
2 files changed, 47 insertions, 0 deletions
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/ITasksCoreConstants.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/ITasksCoreConstants.java
index 3ff03b8c7..8185bdc5f 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/ITasksCoreConstants.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/ITasksCoreConstants.java
@@ -67,6 +67,8 @@ public interface ITasksCoreConstants {
public static final String PROPERTY_USE_SECURE_STORAGE = "org.eclipse.mylyn.tasklist.repositories.configuration.securestorage"; //$NON-NLS-1$
+ public static final String TASK_ACTIVATION_LISTENER_EP_ID = ID_PLUGIN + ".taskActivationListeners"; //$NON-NLS-1$
+
/**
* Jobs that have the same instances of this rule set are mutually exclusive.
*/
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/TaskActivityManager.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/TaskActivityManager.java
index a03c249dc..7a97a926b 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/TaskActivityManager.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/TaskActivityManager.java
@@ -7,6 +7,7 @@
*
* Contributors:
* Tasktop Technologies - initial API and implementation
+ * Manuel Doninger - fixes for bug 349924
*******************************************************************************/
package org.eclipse.mylyn.internal.tasks.core;
@@ -26,7 +27,13 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArraySet;
import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IExtensionRegistry;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.mylyn.commons.core.StatusHandler;
import org.eclipse.mylyn.internal.tasks.core.TaskContainerDelta.Kind;
@@ -73,6 +80,8 @@ public class TaskActivityManager implements ITaskActivityManager {
private int startDay = Calendar.MONDAY;
+ private boolean listenersInitialized = false;
+
private final ITaskListChangeListener TASKLIST_CHANGE_LISTENER = new ITaskListChangeListener() {
public void containersChanged(Set<TaskContainerDelta> containers) {
@@ -94,6 +103,38 @@ public class TaskActivityManager implements ITaskActivityManager {
clear();
}
+ private void initTaskListeners() {
+ if (!listenersInitialized) {
+ try {
+ IExtensionRegistry registry = Platform.getExtensionRegistry();
+
+ IExtensionPoint listenerExtensionPoint = registry.getExtensionPoint(ITasksCoreConstants.TASK_ACTIVATION_LISTENER_EP_ID);
+ IExtension[] listenerExtensions = listenerExtensionPoint.getExtensions();
+
+ for (IExtension extension : listenerExtensions) {
+ IConfigurationElement[] configurationElements = extension.getConfigurationElements();
+ for (IConfigurationElement config : configurationElements) {
+ if ("listener".equals(config.getName())) { //$NON-NLS-1$
+ Object object;
+ object = config.createExecutableExtension("listenerClass");//$NON-NLS-1$
+ if (object instanceof ITaskActivationListener) {
+ addActivationListener((ITaskActivationListener) object);
+ } else {
+ StatusHandler.log(new Status(IStatus.ERROR, ITasksCoreConstants.ID_PLUGIN,
+ "Registering of task activation listener failed: \"" + object + "\"")); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+ }
+ }
+ } catch (CoreException e) {
+ StatusHandler.log(new Status(IStatus.ERROR, ITasksCoreConstants.ID_PLUGIN,
+ "Registering of task activation listener failed: \"" + e.getMessage() + "\"")); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ listenersInitialized = true;
+ }
+ }
+
/**
* Get the user specified first day of the week (Calendar.SUNDAY | Calendar.MONDAY)
*
@@ -407,6 +448,8 @@ public class TaskActivityManager implements ITaskActivityManager {
taskList.addTaskIfAbsent(task);
+ initTaskListeners();
+
// notify that a task is about to be activated
for (ITaskActivationListener listener : new ArrayList<ITaskActivationListener>(activationListeners)) {
try {
@@ -443,6 +486,8 @@ public class TaskActivityManager implements ITaskActivityManager {
if (task.isActive() && task == activeTask) {
// notify that a task is about to be deactivated
+ initTaskListeners();
+
for (ITaskActivationListener listener : new ArrayList<ITaskActivationListener>(activationListeners)) {
try {
listener.preTaskDeactivated(task);

Back to the top