Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteffen Pingel2011-08-22 20:49:47 -0400
committerSteffen Pingel2011-08-22 20:49:47 -0400
commit88eb0b5a82b31512654a83aa7bd336341c74358a (patch)
tree07995ad18394bc8c1efe93f5447f4b7f450bf529 /org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal
parent322adb87a8732b447c0c271762fe3b861c19c269 (diff)
downloadorg.eclipse.mylyn.tasks-88eb0b5a82b31512654a83aa7bd336341c74358a.tar.gz
org.eclipse.mylyn.tasks-88eb0b5a82b31512654a83aa7bd336341c74358a.tar.xz
org.eclipse.mylyn.tasks-88eb0b5a82b31512654a83aa7bd336341c74358a.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.java49
2 files changed, 30 insertions, 21 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 8185bdc5f..3ff03b8c7 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,8 +67,6 @@ 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 7a97a926b..5e7573fd0 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
@@ -27,7 +27,6 @@ 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;
@@ -41,6 +40,7 @@ import org.eclipse.mylyn.tasks.core.ITask;
import org.eclipse.mylyn.tasks.core.ITaskActivationListener;
import org.eclipse.mylyn.tasks.core.ITaskActivityListener;
import org.eclipse.mylyn.tasks.core.ITaskActivityManager;
+import org.eclipse.osgi.util.NLS;
/**
* Manages task elapsed time, scheduling, due dates, and the date ranges
@@ -96,6 +96,9 @@ public class TaskActivityManager implements ITaskActivityManager {
}
};
+ private static final String ID_EXTENSION_TASK_ACTIVATION_LISTENERS = ITasksCoreConstants.ID_PLUGIN
+ + ".taskActivationListeners"; //$NON-NLS-1$
+
public TaskActivityManager(TaskRepositoryManager repositoryManager, TaskList taskList) {
this.taskList = taskList;
this.repositoryManager = repositoryManager;
@@ -103,35 +106,43 @@ public class TaskActivityManager implements ITaskActivityManager {
clear();
}
+ /**
+ * Reads task activation listeners from an extension point.
+ * <p>
+ * Note: The method is not synchronizes since task activation and de-activation are expected to occur sequentially.
+ */
private void initTaskListeners() {
if (!listenersInitialized) {
- try {
- IExtensionRegistry registry = Platform.getExtensionRegistry();
-
- IExtensionPoint listenerExtensionPoint = registry.getExtensionPoint(ITasksCoreConstants.TASK_ACTIVATION_LISTENER_EP_ID);
- IExtension[] listenerExtensions = listenerExtensionPoint.getExtensions();
+ listenersInitialized = true;
- 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$
+ IExtensionRegistry registry = Platform.getExtensionRegistry();
+ IExtensionPoint listenerExtensionPoint = registry.getExtensionPoint(TaskActivityManager.ID_EXTENSION_TASK_ACTIVATION_LISTENERS);
+ IExtension[] listenerExtensions = listenerExtensionPoint.getExtensions();
+ for (IExtension extension : listenerExtensions) {
+ IConfigurationElement[] elements = extension.getConfigurationElements();
+ for (IConfigurationElement element : elements) {
+ if ("listener".equals(element.getName())) { //$NON-NLS-1$
+ try {
+ Object object = element.createExecutableExtension("class"); //$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$
+ StatusHandler.log(new Status(
+ IStatus.ERROR,
+ ITasksCoreConstants.ID_PLUGIN,
+ NLS.bind(
+ "Unexpected error registering listener contributed by {0}: ''{1}'' does not extend expected class", //$NON-NLS-1$
+ element.getContributor().getName(), object.getClass()
+ .getCanonicalName())));
}
+ } catch (Throwable e) {
+ StatusHandler.log(new Status(IStatus.ERROR, ITasksCoreConstants.ID_PLUGIN, NLS.bind(
+ "Unexpected error registering listener contributed by {0}", //$NON-NLS-1$
+ element.getContributor().getName()), e));
}
}
}
- } 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;
}
}

Back to the top