summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomasz Zarna2013-05-17 15:25:10 (EDT)
committer Gerrit Code Review @ Eclipse.org2013-06-28 17:11:30 (EDT)
commit84fa058b13eccfb52980f8a6d62ea98fffd750b9 (patch)
tree3bb4f0211bc00bc9f936cde592e7777f34ea7d57
parent2326dfdb70afc00b17644d9925dbbd7b7c59c950 (diff)
downloadorg.eclipse.mylyn.commons-84fa058b13eccfb52980f8a6d62ea98fffd750b9.zip
org.eclipse.mylyn.commons-84fa058b13eccfb52980f8a6d62ea98fffd750b9.tar.gz
org.eclipse.mylyn.commons-84fa058b13eccfb52980f8a6d62ea98fffd750b9.tar.bz2
use Mylyn ExtensionPointReader in RepositoryCategoryContentProviderrefs/changes/47/12947/3
-rw-r--r--org.eclipse.mylyn.commons.repositories.ui/src/org/eclipse/mylyn/internal/commons/repositories/ui/RepositoryCategoryContentProvider.java49
1 files changed, 22 insertions, 27 deletions
diff --git a/org.eclipse.mylyn.commons.repositories.ui/src/org/eclipse/mylyn/internal/commons/repositories/ui/RepositoryCategoryContentProvider.java b/org.eclipse.mylyn.commons.repositories.ui/src/org/eclipse/mylyn/internal/commons/repositories/ui/RepositoryCategoryContentProvider.java
index 9d5b8d4..c64f4c6 100644
--- a/org.eclipse.mylyn.commons.repositories.ui/src/org/eclipse/mylyn/internal/commons/repositories/ui/RepositoryCategoryContentProvider.java
+++ b/org.eclipse.mylyn.commons.repositories.ui/src/org/eclipse/mylyn/internal/commons/repositories/ui/RepositoryCategoryContentProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 Tasktop Technologies and others.
+ * 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
@@ -12,15 +12,13 @@
package org.eclipse.mylyn.internal.commons.repositories.ui;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
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.Platform;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.mylyn.commons.core.ExtensionPointReader;
import org.eclipse.mylyn.commons.repositories.core.RepositoryCategory;
public class RepositoryCategoryContentProvider implements ITreeContentProvider {
@@ -28,17 +26,15 @@ public class RepositoryCategoryContentProvider implements ITreeContentProvider {
private static final Map<String, RepositoryCategory> repositoryCategories = new HashMap<String, RepositoryCategory>();
public RepositoryCategoryContentProvider() {
- ExtensionPointReader.initExtensions();
+ InternalExtensionPointReader.initExtensions();
}
public void dispose() {
// ignore
-
}
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
// ignore
-
}
public Object[] getElements(Object inputElement) {
@@ -60,8 +56,8 @@ public class RepositoryCategoryContentProvider implements ITreeContentProvider {
return false;
}
- static class ExtensionPointReader {
- public static final String EXTENSION_CUSTOM_CATEGORY = "org.eclipse.mylyn.commons.repositories.ui.categories"; //$NON-NLS-1$
+ private static class InternalExtensionPointReader {
+ public static final String EXTENSION_CUSTOM_CATEGORY = "categories"; //$NON-NLS-1$
public static final String EXTENSION_TMPL_REPOSITORY_CATEGORY = "category"; //$NON-NLS-1$
@@ -71,35 +67,34 @@ public class RepositoryCategoryContentProvider implements ITreeContentProvider {
private static final String ELEMENT_REPOSITORY_CATEGORY_RANK = "rank"; //$NON-NLS-1$
- public static void initExtensions() {
- IExtensionRegistry registry = Platform.getExtensionRegistry();
-
- IExtensionPoint templatesExtensionPoint = registry.getExtensionPoint(EXTENSION_CUSTOM_CATEGORY);
- IExtension[] templateExtensions = templatesExtensionPoint.getExtensions();
- for (IExtension templateExtension : templateExtensions) {
- IConfigurationElement[] elements = templateExtension.getConfigurationElements();
- for (IConfigurationElement element : elements) {
- if (element.getName().equals(EXTENSION_TMPL_REPOSITORY_CATEGORY)) {
- readRepositoryCategory(element);
- }
- }
+ private static void initExtensions() {
+ ExtensionPointReader<RepositoryCategory> reader = new ExtensionPointReader<RepositoryCategory>(
+ RepositoriesUiPlugin.ID_PLUGIN, EXTENSION_CUSTOM_CATEGORY, EXTENSION_TMPL_REPOSITORY_CATEGORY,
+ RepositoryCategory.class) {
+ @Override
+ protected RepositoryCategory readElement(IConfigurationElement element,
+ org.eclipse.core.runtime.MultiStatus result) {
+ return readRepositoryCategory(element);
+ };
+ };
+ reader.read();
+ List<RepositoryCategory> categories = reader.getItems();
+ for (RepositoryCategory cat : categories) {
+ repositoryCategories.put(cat.getId(), cat);
}
-
}
- private static void readRepositoryCategory(IConfigurationElement element) {
+ private static RepositoryCategory readRepositoryCategory(IConfigurationElement element) {
String id = element.getAttribute(ELEMENT_REPOSITORY_CATEGORY_ID);
String label = element.getAttribute(ELEMENT_REPOSITORY_CATEGORY_LABEL);
String rank = element.getAttribute(ELEMENT_REPOSITORY_CATEGORY_RANK);
int rankInt;
try {
rankInt = Integer.parseInt(rank);
-
} catch (NumberFormatException e) {
rankInt = 0;
}
- RepositoryCategory cat = new RepositoryCategory(id, label, rankInt);
- repositoryCategories.put(cat.getId(), cat);
+ return new RepositoryCategory(id, label, rankInt);
}
}
}