Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteffen Pingel2014-03-25 14:29:45 +0000
committerSteffen Pingel2014-03-26 09:22:34 +0000
commitc88adbabaed4aba155426669690fa4a8297ab8d9 (patch)
treeb8df4ea56e5a9125ffad0b4c42962fa0c21bec76
parent604234eb263e3bf3981a715500d36e5d7be293be (diff)
downloadorg.eclipse.mylyn.tasks-c88adbabaed4aba155426669690fa4a8297ab8d9.tar.gz
org.eclipse.mylyn.tasks-c88adbabaed4aba155426669690fa4a8297ab8d9.tar.xz
org.eclipse.mylyn.tasks-c88adbabaed4aba155426669690fa4a8297ab8d9.zip
316253: move connector extension loading into core
Change-Id: Iba3b445736d552825e095a3e35ace3a304af4e86 Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=316253
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/util/RepositoryConnectorLoader.java63
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/TasksUiPlugin.java72
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TasksUiExtensionReader.java96
-rw-r--r--org.eclipse.mylyn.tests.util/src/org/eclipse/mylyn/tests/util/TasksUiTestUtil.java3
4 files changed, 94 insertions, 140 deletions
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/util/RepositoryConnectorLoader.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/util/RepositoryConnectorLoader.java
new file mode 100644
index 000000000..e51bc41e1
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/util/RepositoryConnectorLoader.java
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * Copyright (c) 2014 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
+ *******************************************************************************/
+
+package org.eclipse.mylyn.internal.tasks.core.util;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.mylyn.internal.tasks.core.RepositoryTemplateManager;
+import org.eclipse.mylyn.internal.tasks.core.TaskRepositoryManager;
+import org.eclipse.mylyn.internal.tasks.core.externalization.TaskListExternalizer;
+import org.eclipse.mylyn.tasks.core.spi.RepositoryConnectorDescriptor;
+
+public class RepositoryConnectorLoader {
+
+ private static final String EXTENSION_REPOSITORIES = "org.eclipse.mylyn.tasks.ui.repositories"; //$NON-NLS-1$
+
+ /**
+ * Plug-in ids of connector extensions that failed to load.
+ */
+ private final ContributorBlackList blackList = new ContributorBlackList();
+
+ private final Set<RepositoryConnectorDescriptor> descriptors = new HashSet<RepositoryConnectorDescriptor>();
+
+ public ContributorBlackList getBlackList() {
+ return blackList;
+ }
+
+ public void registerConnectors(TaskRepositoryManager repositoryManager, TaskListExternalizer taskListExternalizer) {
+ IExtensionRegistry registry = Platform.getExtensionRegistry();
+
+ // NOTE: has to be read first, consider improving
+ RepositoryConnectorExtensionReader reader = new RepositoryConnectorExtensionReader(taskListExternalizer,
+ repositoryManager);
+ // load core extension point
+ reader.loadConnectorsFromRepositoriesExtension();
+ // load legacy ui extension point
+ reader.loadConnectors(registry.getExtensionPoint(EXTENSION_REPOSITORIES));
+ // load connectors contributed at runtime
+ reader.loadConnectorsFromContributors();
+ reader.registerConnectors();
+ descriptors.addAll(reader.getDescriptors());
+ blackList.merge(reader.getBlackList());
+ }
+
+ public void registerTemplates(TaskRepositoryManager repositoryManager,
+ RepositoryTemplateManager repositoryTemplateManager) {
+ RepositoryTemplateExtensionReader templateExtensionReader = new RepositoryTemplateExtensionReader(
+ repositoryManager, repositoryTemplateManager);
+ templateExtensionReader.loadExtensions(blackList);
+ }
+
+}
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 dcf5828a4..dc9a76fae 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
@@ -86,6 +86,7 @@ import org.eclipse.mylyn.internal.tasks.core.externalization.IExternalizationPar
import org.eclipse.mylyn.internal.tasks.core.externalization.TaskActivationExternalizationParticipant;
import org.eclipse.mylyn.internal.tasks.core.externalization.TaskListExternalizationParticipant;
import org.eclipse.mylyn.internal.tasks.core.externalization.TaskListExternalizer;
+import org.eclipse.mylyn.internal.tasks.core.util.RepositoryConnectorLoader;
import org.eclipse.mylyn.internal.tasks.core.util.TaskRepositoryKeyringMigrator;
import org.eclipse.mylyn.internal.tasks.core.util.TaskRepositorySecureStoreMigrator;
import org.eclipse.mylyn.internal.tasks.core.util.TasksCoreExtensionReader;
@@ -281,68 +282,6 @@ public class TasksUiPlugin extends AbstractUIPlugin {
}
};
-// private static ITaskListNotificationProvider INCOMING_NOTIFICATION_PROVIDER = new ITaskListNotificationProvider() {
-//
-// @SuppressWarnings( { "deprecation", "restriction" })
-// public Set<AbstractNotification> getNotifications() {
-// Set<AbstractNotification> notifications = new HashSet<AbstractNotification>();
-// // Incoming Changes
-// for (TaskRepository repository : getRepositoryManager().getAllRepositories()) {
-// AbstractRepositoryConnector connector = getRepositoryManager().getRepositoryConnector(
-// repository.getConnectorKind());
-// if (connector instanceof AbstractLegacyRepositoryConnector) {
-// AbstractRepositoryConnectorUi connectorUi = getConnectorUi(repository.getConnectorKind());
-// if (connectorUi != null && !connectorUi.hasCustomNotifications()) {
-// for (ITask itask : TasksUiPlugin.getTaskList().getTasks(repository.getRepositoryUrl())) {
-// if (itask instanceof AbstractTask) {
-// AbstractTask task = (AbstractTask) itask;
-// if ((task.getLastReadTimeStamp() == null || task.getSynchronizationState() == SynchronizationState.INCOMING)
-// && task.isNotified() == false) {
-// TaskListNotification notification = LegacyChangeManager.getIncommingNotification(
-// connector, task);
-// notifications.add(notification);
-// task.setNotified(true);
-// }
-// }
-// }
-// }
-// }
-// }
-// // New query hits
-// for (RepositoryQuery query : TasksUiPlugin.getTaskList().getQueries()) {
-// TaskRepository repository = getRepositoryManager().getRepository(query.getRepositoryUrl());
-// if (repository != null) {
-// AbstractRepositoryConnector connector = getRepositoryManager().getRepositoryConnector(
-// repository.getConnectorKind());
-// if (connector instanceof AbstractLegacyRepositoryConnector) {
-// AbstractRepositoryConnectorUi connectorUi = getConnectorUi(repository.getConnectorKind());
-// if (!connectorUi.hasCustomNotifications()) {
-// for (ITask hit : query.getChildren()) {
-// if (((AbstractTask) hit).isNotified() == false) {
-// notifications.add(new TaskListNotificationQueryIncoming(hit));
-// ((AbstractTask) hit).setNotified(true);
-// }
-// }
-// }
-// }
-// }
-// }
-// return notifications;
-// }
-// };
-
-// private final IPropertyChangeListener PREFERENCE_LISTENER = new IPropertyChangeListener() {
-//
-// public void propertyChange(PropertyChangeEvent event) {
-// // TODO: do we ever get here?
-//// if (event.getProperty().equals(ContextPreferenceContstants.PREF_DATA_DIR)) {
-//// if (event.getOldValue() instanceof String) {
-//// reloadDataDirectory();
-//// }
-//// }
-// }
-// };
-
private final org.eclipse.jface.util.IPropertyChangeListener PROPERTY_LISTENER = new org.eclipse.jface.util.IPropertyChangeListener() {
public void propertyChange(org.eclipse.jface.util.PropertyChangeEvent event) {
@@ -392,6 +331,8 @@ public class TasksUiPlugin extends AbstractUIPlugin {
private SynchronizationManger synchronizationManger;
+ private RepositoryConnectorLoader connectorLoader;
+
private class TasksUiInitializationJob extends UIJob {
public TasksUiInitializationJob() {
@@ -408,7 +349,7 @@ public class TasksUiPlugin extends AbstractUIPlugin {
try {
// Needs to run after workbench is loaded because it
// relies on images.
- TasksUiExtensionReader.initWorkbenchUiExtensions();
+ TasksUiExtensionReader.initWorkbenchUiExtensions(connectorLoader.getBlackList());
if (externalizationManager.getLoadStatus() != null) {
// XXX: recovery from task list load failure (Rendered in task list)
@@ -634,7 +575,10 @@ public class TasksUiPlugin extends AbstractUIPlugin {
// NOTE: initializing extensions in start(..) has caused race
// conditions previously
- TasksUiExtensionReader.initStartupExtensions(taskListExternalizer, repositoryManager);
+ connectorLoader = new RepositoryConnectorLoader();
+ connectorLoader.registerConnectors(repositoryManager, taskListExternalizer);
+ connectorLoader.registerTemplates(repositoryManager, repositoryTemplateManager);
+ TasksUiExtensionReader.initStartupExtensions(connectorLoader.getBlackList());
// instantiate taskDataManager
TaskDataStore taskDataStore = new TaskDataStore(repositoryManager);
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TasksUiExtensionReader.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TasksUiExtensionReader.java
index 2112be840..eb6c74e43 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TasksUiExtensionReader.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TasksUiExtensionReader.java
@@ -11,9 +11,6 @@
package org.eclipse.mylyn.internal.tasks.ui.util;
-import java.util.HashSet;
-import java.util.Set;
-
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtension;
import org.eclipse.core.runtime.IExtensionPoint;
@@ -23,19 +20,13 @@ import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.mylyn.commons.core.StatusHandler;
-import org.eclipse.mylyn.internal.tasks.core.TaskRepositoryManager;
-import org.eclipse.mylyn.internal.tasks.core.externalization.TaskListExternalizer;
import org.eclipse.mylyn.internal.tasks.core.util.ContributorBlackList;
-import org.eclipse.mylyn.internal.tasks.core.util.RepositoryConnectorExtensionReader;
-import org.eclipse.mylyn.internal.tasks.core.util.RepositoryTemplateExtensionReader;
import org.eclipse.mylyn.internal.tasks.ui.IDynamicSubMenuContributor;
import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
import org.eclipse.mylyn.internal.tasks.ui.views.AbstractTaskListPresentation;
import org.eclipse.mylyn.internal.tasks.ui.views.TaskListView;
import org.eclipse.mylyn.tasks.core.AbstractDuplicateDetector;
-import org.eclipse.mylyn.tasks.core.spi.RepositoryConnectorDescriptor;
import org.eclipse.mylyn.tasks.ui.AbstractTaskRepositoryLinkProvider;
-import org.eclipse.mylyn.tasks.ui.TasksUi;
import org.eclipse.mylyn.tasks.ui.editors.AbstractTaskEditorPageFactory;
import org.eclipse.ui.plugin.AbstractUIPlugin;
@@ -47,24 +38,12 @@ import org.eclipse.ui.plugin.AbstractUIPlugin;
*/
public class TasksUiExtensionReader {
- public static final String EXTENSION_REPOSITORIES = "org.eclipse.mylyn.tasks.ui.repositories"; //$NON-NLS-1$
-
public static final String EXTENSION_REPOSITORY_LINKS_PROVIDERS = "org.eclipse.mylyn.tasks.ui.projectLinkProviders"; //$NON-NLS-1$
public static final String ELMNT_REPOSITORY_LINK_PROVIDER = "linkProvider"; //$NON-NLS-1$
- public static final String ELMNT_REPOSITORY_UI = "connectorUi"; //$NON-NLS-1$
-
- public static final String ELMNT_TYPE = "type"; //$NON-NLS-1$
-
- public static final String ELMNT_QUERY_PAGE = "queryPage"; //$NON-NLS-1$
-
- public static final String ELMNT_SETTINGS_PAGE = "settingsPage"; //$NON-NLS-1$
-
public static final String EXTENSION_TASK_CONTRIBUTOR = "org.eclipse.mylyn.tasks.ui.actions"; //$NON-NLS-1$
- public static final String ATTR_ACTION_CONTRIBUTOR_CLASS = "taskHandlerClass"; //$NON-NLS-1$
-
public static final String DYNAMIC_POPUP_ELEMENT = "dynamicPopupMenu"; //$NON-NLS-1$
public static final String ATTR_CLASS = "class"; //$NON-NLS-1$
@@ -85,75 +64,42 @@ public class TasksUiExtensionReader {
private static final String EXTENSION_PRESENTATIONS = "org.eclipse.mylyn.tasks.ui.presentations"; //$NON-NLS-1$
- public static final String ELMNT_PRESENTATION = "presentation"; //$NON-NLS-1$
-
public static final String ATTR_ICON = "icon"; //$NON-NLS-1$
public static final String ATTR_PRIMARY = "primary"; //$NON-NLS-1$
public static final String ATTR_ID = "id"; //$NON-NLS-1$
- private static boolean coreExtensionsRead = false;
-
- /**
- * Plug-in ids of connector extensions that failed to load.
- */
- private static ContributorBlackList blackList = new ContributorBlackList();
-
- private static Set<RepositoryConnectorDescriptor> descriptors = new HashSet<RepositoryConnectorDescriptor>();
-
- public static void initStartupExtensions(TaskListExternalizer taskListExternalizer,
- TaskRepositoryManager repositoryManager) {
- if (!coreExtensionsRead) {
- IExtensionRegistry registry = Platform.getExtensionRegistry();
-
- // NOTE: has to be read first, consider improving
- RepositoryConnectorExtensionReader reader = new RepositoryConnectorExtensionReader(taskListExternalizer,
- repositoryManager);
- // load core extension point
- reader.loadConnectorsFromRepositoriesExtension();
- // load legacy ui extension point
- reader.loadConnectors(registry.getExtensionPoint(EXTENSION_REPOSITORIES));
- // load connectors contributed at runtime
- reader.loadConnectorsFromContributors();
- reader.registerConnectors();
- descriptors.addAll(reader.getDescriptors());
- blackList.merge(reader.getBlackList());
-
- RepositoryTemplateExtensionReader templateExtensionReader = new RepositoryTemplateExtensionReader(
- TasksUi.getRepositoryManager(), TasksUiPlugin.getRepositoryTemplateManager());
- templateExtensionReader.loadExtensions(blackList);
-
- IExtensionPoint presentationsExtensionPoint = registry.getExtensionPoint(EXTENSION_PRESENTATIONS);
- IExtension[] presentations = presentationsExtensionPoint.getExtensions();
- for (IExtension presentation : presentations) {
- IConfigurationElement[] elements = presentation.getConfigurationElements();
- for (IConfigurationElement element : elements) {
- if (!blackList.isDisabled(element)) {
- readPresentation(element);
- }
+ public static void initStartupExtensions(ContributorBlackList blackList) {
+ IExtensionRegistry registry = Platform.getExtensionRegistry();
+
+ IExtensionPoint presentationsExtensionPoint = registry.getExtensionPoint(EXTENSION_PRESENTATIONS);
+ IExtension[] presentations = presentationsExtensionPoint.getExtensions();
+ for (IExtension presentation : presentations) {
+ IConfigurationElement[] elements = presentation.getConfigurationElements();
+ for (IConfigurationElement element : elements) {
+ if (!blackList.isDisabled(element)) {
+ readPresentation(element);
}
}
+ }
- // NOTE: causes ..mylyn.context.ui to load
- IExtensionPoint editorsExtensionPoint = registry.getExtensionPoint(EXTENSION_EDITORS);
- IExtension[] editors = editorsExtensionPoint.getExtensions();
- for (IExtension editor : editors) {
- IConfigurationElement[] elements = editor.getConfigurationElements();
- for (IConfigurationElement element : elements) {
- if (!blackList.isDisabled(element)) {
- if (element.getName().equals(ELMNT_TASK_EDITOR_PAGE_FACTORY)) {
- readTaskEditorPageFactory(element);
- }
+ // NOTE: causes ..mylyn.context.ui to load
+ IExtensionPoint editorsExtensionPoint = registry.getExtensionPoint(EXTENSION_EDITORS);
+ IExtension[] editors = editorsExtensionPoint.getExtensions();
+ for (IExtension editor : editors) {
+ IConfigurationElement[] elements = editor.getConfigurationElements();
+ for (IConfigurationElement element : elements) {
+ if (!blackList.isDisabled(element)) {
+ if (element.getName().equals(ELMNT_TASK_EDITOR_PAGE_FACTORY)) {
+ readTaskEditorPageFactory(element);
}
}
}
-
- coreExtensionsRead = true;
}
}
- public static void initWorkbenchUiExtensions() {
+ public static void initWorkbenchUiExtensions(ContributorBlackList blackList) {
IExtensionRegistry registry = Platform.getExtensionRegistry();
RepositoryConnectorUiExtensionReader reader = new RepositoryConnectorUiExtensionReader(registry, blackList);
diff --git a/org.eclipse.mylyn.tests.util/src/org/eclipse/mylyn/tests/util/TasksUiTestUtil.java b/org.eclipse.mylyn.tests.util/src/org/eclipse/mylyn/tests/util/TasksUiTestUtil.java
index 286c037cd..dabee32d4 100644
--- a/org.eclipse.mylyn.tests.util/src/org/eclipse/mylyn/tests/util/TasksUiTestUtil.java
+++ b/org.eclipse.mylyn.tests.util/src/org/eclipse/mylyn/tests/util/TasksUiTestUtil.java
@@ -11,6 +11,7 @@
package org.eclipse.mylyn.tests.util;
+import org.eclipse.mylyn.internal.tasks.core.util.ContributorBlackList;
import org.eclipse.mylyn.internal.tasks.ui.util.TasksUiExtensionReader;
/**
@@ -22,7 +23,7 @@ public class TasksUiTestUtil {
* Ensures that connector UI extensions are registered (see bug 400370).
*/
public static void ensureTasksUiInitialization() {
- TasksUiExtensionReader.initWorkbenchUiExtensions();
+ TasksUiExtensionReader.initWorkbenchUiExtensions(new ContributorBlackList());
}
}

Back to the top