summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteffen Pingel2013-07-01 06:32:25 (EDT)
committerSteffen Pingel2013-07-01 06:32:25 (EDT)
commit93e000540e9c140e7a25e095f6fd420dff2deed4 (patch)
tree7acefd5aad6c3ed58c2eaef7ba29da20855ca116
parent801d86f518e5d9d7b1d6297cbfab31b06f8a5da7 (diff)
downloadorg.eclipse.mylyn.tasks-93e000540e9c140e7a25e095f6fd420dff2deed4.zip
org.eclipse.mylyn.tasks-93e000540e9c140e7a25e095f6fd420dff2deed4.tar.gz
org.eclipse.mylyn.tasks-93e000540e9c140e7a25e095f6fd420dff2deed4.tar.bz2
408511: [api] honor IAdatpable when loading connector UI and branding refs/changes/63/14163/1
Change-Id: I0445424b80fe6ff6956f48ea6fb5fb0d77c9985c Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=408511
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/RepositoryConnectorUiExtensionReader.java19
1 files changed, 15 insertions, 4 deletions
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 4659538..392e2b3 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
@@ -15,6 +15,7 @@ import java.io.InputStream;
import java.util.Set;
import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtension;
import org.eclipse.core.runtime.IExtensionPoint;
@@ -84,14 +85,12 @@ public class RepositoryConnectorUiExtensionReader {
SafeRunner.run(new ISafeRunnable() {
@Override
public void run() throws Exception {
- AbstractRepositoryConnectorUi connectorUi = (AbstractRepositoryConnectorUi) Platform.getAdapterManager()
- .loadAdapter(connector, AbstractRepositoryConnectorUi.class.getName());
+ AbstractRepositoryConnectorUi connectorUi = loadAdapter(connector, AbstractRepositoryConnectorUi.class);
if (connectorUi != null) {
TasksUiPlugin.getDefault().addRepositoryConnectorUi(connectorUi);
}
- RepositoryConnectorBranding branding = (RepositoryConnectorBranding) Platform.getAdapterManager()
- .loadAdapter(connector, RepositoryConnectorBranding.class.getName());
+ RepositoryConnectorBranding branding = loadAdapter(connector, RepositoryConnectorBranding.class);
if (branding != null) {
InputStream brandingImageData = branding.getBrandingImageData();
if (brandingImageData != null) {
@@ -106,6 +105,18 @@ public class RepositoryConnectorUiExtensionReader {
}
}
+ @SuppressWarnings("unchecked")
+ public <T> T loadAdapter(final AbstractRepositoryConnector connector, Class<T> klass) {
+ T adapter = null;
+ if (connector instanceof IAdaptable) {
+ adapter = (T) ((IAdaptable) connector).getAdapter(klass);
+ }
+ if (adapter == null) {
+ adapter = (T) Platform.getAdapterManager().loadAdapter(connector, klass.getName());
+ }
+ return adapter;
+ }
+
private ImageDescriptor getImageDescriptor(InputStream in) {
return ImageDescriptor.createFromImageData(new ImageData(in));
}