Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteffen Pingel2012-10-05 22:56:23 -0400
committerSteffen Pingel2013-09-26 15:45:58 -0400
commitb25ac21444f9250945fa89c2a9bb20cb8c8d67b6 (patch)
tree83ddfbc36c084485080e714b5f22838aa25edbbd /org.eclipse.mylyn.tasks.ui
parentd4245c3b3223e8fbae7927a5acc0cc8401690448 (diff)
downloadorg.eclipse.mylyn.tasks-b25ac21444f9250945fa89c2a9bb20cb8c8d67b6.tar.gz
org.eclipse.mylyn.tasks-b25ac21444f9250945fa89c2a9bb20cb8c8d67b6.tar.xz
org.eclipse.mylyn.tasks-b25ac21444f9250945fa89c2a9bb20cb8c8d67b6.zip
386117: [api] declare repository connector extensions in tasks.core
Change-Id: I9eafa88b5731e9aaf1d46bd0f91e1b3c51f4f129 Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=386117
Diffstat (limited to 'org.eclipse.mylyn.tasks.ui')
-rw-r--r--org.eclipse.mylyn.tasks.ui/schema/repositories.exsd2
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/TasksUiPlugin.java3
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/RepositoryConnectorUiExtensionReader.java15
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TasksUiExtensionReader.java112
4 files changed, 29 insertions, 103 deletions
diff --git a/org.eclipse.mylyn.tasks.ui/schema/repositories.exsd b/org.eclipse.mylyn.tasks.ui/schema/repositories.exsd
index 3b6fd1f41..8acdaf825 100644
--- a/org.eclipse.mylyn.tasks.ui/schema/repositories.exsd
+++ b/org.eclipse.mylyn.tasks.ui/schema/repositories.exsd
@@ -21,7 +21,7 @@
</annotation>
<complexType>
<sequence>
- <element ref="connectorCore"/>
+ <element ref="connectorCore" minOccurs="0" maxOccurs="1"/>
<element ref="connectorUi" minOccurs="0" maxOccurs="1"/>
<element ref="taskListMigrator" minOccurs="0" maxOccurs="1"/>
<element ref="repositoryMigrator" minOccurs="0" maxOccurs="1"/>
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 1993562d5..1855dabdf 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
@@ -85,6 +85,7 @@ import org.eclipse.mylyn.internal.tasks.core.externalization.ExternalizationMana
import org.eclipse.mylyn.internal.tasks.core.externalization.IExternalizationParticipant;
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.TasksCoreExtensionReader;
import org.eclipse.mylyn.internal.tasks.ui.actions.ActivateTaskDialogAction;
import org.eclipse.mylyn.internal.tasks.ui.actions.NewTaskAction;
import org.eclipse.mylyn.internal.tasks.ui.notifications.TaskListNotificationReminder;
@@ -1443,7 +1444,7 @@ public class TasksUiPlugin extends AbstractUIPlugin {
public static synchronized AbstractTaskContextStore getContextStore() {
if (contextStore == null) {
- contextStore = TasksUiExtensionReader.loadTaskContextStore();
+ contextStore = TasksCoreExtensionReader.loadTaskContextStore();
}
return contextStore;
}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/RepositoryConnectorUiExtensionReader.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/RepositoryConnectorUiExtensionReader.java
index 392e2b320..21b21a447 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/RepositoryConnectorUiExtensionReader.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/RepositoryConnectorUiExtensionReader.java
@@ -28,6 +28,7 @@ import org.eclipse.core.runtime.Status;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.mylyn.commons.core.StatusHandler;
import org.eclipse.mylyn.commons.ui.CommonImages;
+import org.eclipse.mylyn.internal.tasks.core.util.ContributorBlackList;
import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
import org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector;
import org.eclipse.mylyn.tasks.core.spi.RepositoryConnectorBranding;
@@ -55,17 +56,13 @@ public class RepositoryConnectorUiExtensionReader {
/**
* Plug-in ids of connector extensions that failed to load.
*/
- private final Set<String> disabledContributors;
+ private final ContributorBlackList blackList;
- public RepositoryConnectorUiExtensionReader(IExtensionRegistry registry, Set<String> disabledContributors) {
+ public RepositoryConnectorUiExtensionReader(IExtensionRegistry registry, ContributorBlackList blackList) {
Assert.isNotNull(registry);
- Assert.isNotNull(disabledContributors);
+ Assert.isNotNull(blackList);
this.registry = registry;
- this.disabledContributors = disabledContributors;
- }
-
- private boolean isDisabled(IConfigurationElement element) {
- return disabledContributors.contains(element.getContributor().getName());
+ this.blackList = blackList;
}
public void registerConnectorUis() {
@@ -139,7 +136,7 @@ public class RepositoryConnectorUiExtensionReader {
for (IExtension repositoryExtension : repositoryExtensions) {
IConfigurationElement[] elements = repositoryExtension.getConfigurationElements();
for (IConfigurationElement element : elements) {
- if (!isDisabled(element)) {
+ if (!blackList.isDisabled(element)) {
if (element.getName().equals(ELMNT_REPOSITORY_UI)) {
registerRepositoryConnectorUi(element);
}
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 ed07f17e1..b362e513e 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
@@ -28,13 +28,14 @@ import org.eclipse.mylyn.internal.tasks.core.TaskRepositoryManager;
import org.eclipse.mylyn.internal.tasks.core.activity.DefaultTaskActivityMonitor;
import org.eclipse.mylyn.internal.tasks.core.context.DefaultTaskContextStore;
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.RepositoryTemplate;
import org.eclipse.mylyn.tasks.core.activity.AbstractTaskActivityMonitor;
import org.eclipse.mylyn.tasks.core.context.AbstractTaskContextStore;
import org.eclipse.mylyn.tasks.core.spi.RepositoryConnectorDescriptor;
@@ -56,32 +57,6 @@ public class TasksUiExtensionReader {
public static final String EXTENSION_REPOSITORY_LINKS_PROVIDERS = "org.eclipse.mylyn.tasks.ui.projectLinkProviders"; //$NON-NLS-1$
- public static final String EXTENSION_TEMPLATES = "org.eclipse.mylyn.tasks.core.templates"; //$NON-NLS-1$
-
- public static final String EXTENSION_TMPL_REPOSITORY = "repository"; //$NON-NLS-1$
-
- public static final String ELMNT_TMPL_LABEL = "label"; //$NON-NLS-1$
-
- public static final String ELMNT_TMPL_URLREPOSITORY = "urlRepository"; //$NON-NLS-1$
-
- public static final String ELMNT_TMPL_REPOSITORYKIND = "repositoryKind"; //$NON-NLS-1$
-
- public static final String ELMNT_TMPL_CHARACTERENCODING = "characterEncoding"; //$NON-NLS-1$
-
- public static final String ELMNT_TMPL_ANONYMOUS = "anonymous"; //$NON-NLS-1$
-
- public static final String ELMNT_TMPL_VERSION = "version"; //$NON-NLS-1$
-
- public static final String ELMNT_TMPL_URLNEWTASK = "urlNewTask"; //$NON-NLS-1$
-
- public static final String ELMNT_TMPL_URLTASK = "urlTask"; //$NON-NLS-1$
-
- public static final String ELMNT_TMPL_URLTASKQUERY = "urlTaskQuery"; //$NON-NLS-1$
-
- public static final String ELMNT_TMPL_NEWACCOUNTURL = "urlNewAccount"; //$NON-NLS-1$
-
- public static final String ELMNT_TMPL_ADDAUTO = "addAutomatically"; //$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$
@@ -129,7 +104,7 @@ public class TasksUiExtensionReader {
/**
* Plug-in ids of connector extensions that failed to load.
*/
- private static Set<String> disabledContributors = new HashSet<String>();
+ private static ContributorBlackList blackList = new ContributorBlackList();
private static Set<RepositoryConnectorDescriptor> descriptors = new HashSet<RepositoryConnectorDescriptor>();
@@ -139,32 +114,28 @@ public class TasksUiExtensionReader {
IExtensionRegistry registry = Platform.getExtensionRegistry();
// NOTE: has to be read first, consider improving
- IExtensionPoint repositoriesExtensionPoint = registry.getExtensionPoint(EXTENSION_REPOSITORIES);
RepositoryConnectorExtensionReader reader = new RepositoryConnectorExtensionReader(taskListExternalizer,
repositoryManager);
- reader.registerConnectors(repositoriesExtensionPoint);
+ // 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());
- disabledContributors.addAll(reader.getDisabledContributors());
+ blackList.merge(reader.getBlackList());
- IExtensionPoint templatesExtensionPoint = registry.getExtensionPoint(EXTENSION_TEMPLATES);
- IExtension[] templateExtensions = templatesExtensionPoint.getExtensions();
- for (IExtension templateExtension : templateExtensions) {
- IConfigurationElement[] elements = templateExtension.getConfigurationElements();
- for (IConfigurationElement element : elements) {
- if (!isDisabled(element)) {
- if (element.getName().equals(EXTENSION_TMPL_REPOSITORY)) {
- readRepositoryTemplate(element);
- }
- }
- }
- }
+ 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 (!isDisabled(element)) {
+ if (!blackList.isDisabled(element)) {
readPresentation(element);
}
}
@@ -176,7 +147,7 @@ public class TasksUiExtensionReader {
for (IExtension editor : editors) {
IConfigurationElement[] elements = editor.getConfigurationElements();
for (IConfigurationElement element : elements) {
- if (!isDisabled(element)) {
+ if (!blackList.isDisabled(element)) {
if (element.getName().equals(ELMNT_TASK_EDITOR_PAGE_FACTORY)) {
readTaskEditorPageFactory(element);
}
@@ -191,8 +162,7 @@ public class TasksUiExtensionReader {
public static void initWorkbenchUiExtensions() {
IExtensionRegistry registry = Platform.getExtensionRegistry();
- RepositoryConnectorUiExtensionReader reader = new RepositoryConnectorUiExtensionReader(registry,
- disabledContributors);
+ RepositoryConnectorUiExtensionReader reader = new RepositoryConnectorUiExtensionReader(registry, blackList);
reader.registerConnectorUis();
IExtensionPoint linkProvidersExtensionPoint = registry.getExtensionPoint(EXTENSION_REPOSITORY_LINKS_PROVIDERS);
@@ -200,7 +170,7 @@ public class TasksUiExtensionReader {
for (IExtension linkProvidersExtension : linkProvidersExtensions) {
IConfigurationElement[] elements = linkProvidersExtension.getConfigurationElements();
for (IConfigurationElement element : elements) {
- if (!isDisabled(element)) {
+ if (!blackList.isDisabled(element)) {
if (element.getName().equals(ELMNT_REPOSITORY_LINK_PROVIDER)) {
readLinkProvider(element);
}
@@ -213,7 +183,7 @@ public class TasksUiExtensionReader {
for (IExtension dulicateDetectorsExtension : dulicateDetectorsExtensions) {
IConfigurationElement[] elements = dulicateDetectorsExtension.getConfigurationElements();
for (IConfigurationElement element : elements) {
- if (!isDisabled(element)) {
+ if (!blackList.isDisabled(element)) {
if (element.getName().equals(ELMNT_DUPLICATE_DETECTOR)) {
readDuplicateDetector(element);
}
@@ -226,7 +196,7 @@ public class TasksUiExtensionReader {
for (IExtension extension : extensions) {
IConfigurationElement[] elements = extension.getConfigurationElements();
for (IConfigurationElement element : elements) {
- if (!isDisabled(element)) {
+ if (!blackList.isDisabled(element)) {
if (element.getName().equals(DYNAMIC_POPUP_ELEMENT)) {
readDynamicPopupContributor(element);
}
@@ -318,44 +288,6 @@ public class TasksUiExtensionReader {
}
}
- private static void readRepositoryTemplate(IConfigurationElement element) {
- boolean anonymous = false;
- boolean addAuto = false;
-
- String label = element.getAttribute(ELMNT_TMPL_LABEL);
- String serverUrl = element.getAttribute(ELMNT_TMPL_URLREPOSITORY);
- String repKind = element.getAttribute(ELMNT_TMPL_REPOSITORYKIND);
- String version = element.getAttribute(ELMNT_TMPL_VERSION);
- String newTaskUrl = element.getAttribute(ELMNT_TMPL_URLNEWTASK);
- String taskPrefix = element.getAttribute(ELMNT_TMPL_URLTASK);
- String taskQueryUrl = element.getAttribute(ELMNT_TMPL_URLTASKQUERY);
- String newAccountUrl = element.getAttribute(ELMNT_TMPL_NEWACCOUNTURL);
- String encoding = element.getAttribute(ELMNT_TMPL_CHARACTERENCODING);
- addAuto = Boolean.parseBoolean(element.getAttribute(ELMNT_TMPL_ADDAUTO));
- anonymous = Boolean.parseBoolean(element.getAttribute(ELMNT_TMPL_ANONYMOUS));
-
- if (serverUrl != null && label != null && repKind != null
- && TasksUi.getRepositoryManager().getRepositoryConnector(repKind) != null) {
- RepositoryTemplate template = new RepositoryTemplate(label, serverUrl, encoding, version, newTaskUrl,
- taskPrefix, taskQueryUrl, newAccountUrl, anonymous, addAuto);
- TasksUiPlugin.getRepositoryTemplateManager().addTemplate(repKind, template);
-
- for (IConfigurationElement configElement : element.getChildren()) {
- String name = configElement.getAttribute("name"); //$NON-NLS-1$
- String value = configElement.getAttribute("value"); //$NON-NLS-1$
- if (name != null && !name.equals("") && value != null) { //$NON-NLS-1$
- template.addAttribute(name, value);
- }
- }
- } else {
- // TODO change error message to include hints about the cause of the error
- StatusHandler.log(new Status(
- IStatus.ERROR,
- TasksUiPlugin.ID_PLUGIN,
- "Could not load repository template extension contributed by " + element.getNamespaceIdentifier() + " with connectorKind " + repKind)); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
-
private static void readDynamicPopupContributor(IConfigurationElement element) {
try {
Object dynamicPopupContributor = element.createExecutableExtension(ATTR_CLASS);
@@ -442,8 +374,4 @@ public class TasksUiExtensionReader {
return new DefaultTaskContextStore();
}
- private static boolean isDisabled(IConfigurationElement element) {
- return disabledContributors.contains(element.getContributor().getName());
- }
-
}

Back to the top