Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteffen Pingel2013-06-27 11:25:00 -0400
committerSteffen Pingel2013-06-28 08:49:17 -0400
commit41bfa30a421f1051ef38c4946eb31ecd253b2226 (patch)
treedc3109bc38013136e7e95d4dfc6b497a27f713f0 /org.eclipse.mylyn.tasks.core/src/org/eclipse
parent7d54bbdcace41210385cab6463fae1f096231866 (diff)
downloadorg.eclipse.mylyn.tasks-41bfa30a421f1051ef38c4946eb31ecd253b2226.tar.gz
org.eclipse.mylyn.tasks-41bfa30a421f1051ef38c4946eb31ecd253b2226.tar.xz
org.eclipse.mylyn.tasks-41bfa30a421f1051ef38c4946eb31ecd253b2226.zip
408511: [api] add support for contributing UI and branding at runtime
Change-Id: I33c608dad60ee5d979e2ddd5c5cde4c386519610 Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=408511
Diffstat (limited to 'org.eclipse.mylyn.tasks.core/src/org/eclipse')
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/util/RepositoryConnectorExtensionReader.java7
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/spi/RepositoryConnectorBranding.java106
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/spi/RepositoryConnectorDescriptor.java1
3 files changed, 114 insertions, 0 deletions
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/util/RepositoryConnectorExtensionReader.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/util/RepositoryConnectorExtensionReader.java
index 2137fbf98..3523a502a 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/util/RepositoryConnectorExtensionReader.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/util/RepositoryConnectorExtensionReader.java
@@ -208,6 +208,8 @@ public class RepositoryConnectorExtensionReader {
private final List<ConnectorFactory> factories = new ArrayList<ConnectorFactory>();
+ private final List<RepositoryConnectorDescriptor> descriptors = new ArrayList<RepositoryConnectorDescriptor>();
+
private MultiStatus result;
public RepositoryConnectorExtensionReader(TaskListExternalizer taskListExternalizer,
@@ -267,6 +269,7 @@ public class RepositoryConnectorExtensionReader {
factories.add(new ConnectorFactory(descriptor, element.getContributor().getName()));
}
}
+ RepositoryConnectorExtensionReader.this.descriptors.addAll(descriptors);
}
@Override
@@ -380,6 +383,10 @@ public class RepositoryConnectorExtensionReader {
list.add(descriptor);
}
+ public List<RepositoryConnectorDescriptor> getDescriptors() {
+ return new ArrayList<RepositoryConnectorDescriptor>(descriptors);
+ }
+
public Set<String> getDisabledContributors() {
return new HashSet<String>(disabledContributors);
}
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/spi/RepositoryConnectorBranding.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/spi/RepositoryConnectorBranding.java
new file mode 100644
index 000000000..64f659a8a
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/spi/RepositoryConnectorBranding.java
@@ -0,0 +1,106 @@
+/*******************************************************************************
+ * Copyright (c) 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Tasktop Technologies - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.mylyn.tasks.core.spi;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.eclipse.core.runtime.IAdapterFactory;
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector;
+
+/**
+ * Specifies branding for a connector that is registered as runtime using {@link RepositoryConnectorContributor}. The
+ * branding extension is obtained by adapting an {@link AbstractRepositoryConnector} instance to
+ * {@link RepositoryConnectorBranding}.
+ * <p>
+ * To contribute branding clients need to register an {@link IAdapterFactory} for the type
+ * {@link AbstractRepositoryConnector}.
+ * </p>
+ * Example <code>plugin.xml</code>:
+ * <p>
+ *
+ * <pre>
+ * &lt;extension
+ * point="org.eclipse.core.runtime.adapters"&gt;
+ * &lt;factory
+ * adaptableType="org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector"
+ * class="MyRepositoryConnectorAdapter"&gt;
+ * &lt;adapter
+ * type="org.eclipse.mylyn.tasks.core.spi.RepositoryConnectorBranding"&gt;
+ * &lt;/adapter&gt;
+ * &lt;/factory&gt;
+ * &lt;/extension&gt;
+ * </pre>
+ *
+ * </p>
+ * <p>
+ * <code>MyRepositoryConnector</code> needs to return an instance of {@link RepositoryConnectorBranding} for the
+ * appropriate connector instance:
+ *
+ * <pre>
+ * public class MyRepositoryConnectorAdapter implements IAdapterFactory {
+ *
+ * &#064;Override
+ * public Object getAdapter(Object adaptableObject, Class adapterType) {
+ * if (adaptableObject instanceof MyRepositoryConnector) {
+ * if (adapterType == RepositoryConnectorBranding.class) {
+ * return new RepositoryConnectorBranding() {
+ * &#064;Override
+ * public InputStream getOverlayImageData() throws IOException {
+ * return getResource(this, &quot;repository-overlay.gif&quot;);
+ * }
+ *
+ * &#064;Override
+ * public InputStream getBrandingImageData() throws IOException {
+ * return CommonTestUtil.getResource(this, &quot;repository.gif&quot;);
+ * }
+ * };
+ * }
+ * }
+ * return null;
+ * }
+ * }
+ * </pre>
+ *
+ * </p>
+ *
+ * @since 3.10
+ * @see RepositoryConnectorContributor
+ * @see RepositoryConnectorDescriptor
+ */
+public abstract class RepositoryConnectorBranding {
+
+ /**
+ * Returns an input stream with the image data for a 16x16 branding icon. This is typically shown in the UI when
+ * selecting connectors. Supported file formats are GIF and PNG.
+ *
+ * @return input stream for image data
+ * @throws IOException
+ * thrown if opening of the stream fails
+ */
+ @NonNull
+ public abstract InputStream getBrandingImageData() throws IOException;
+
+ /**
+ * Returns an input stream with the image data for a 7x8 overlay branding icon. This is typically a very small
+ * version of the branding icon that is used for overlays over repository icons. Supported file formats are GIF and
+ * PNG.
+ *
+ * @return input stream for image data
+ * @throws IOException
+ * thrown if opening of the stream fails
+ */
+ @NonNull
+ public abstract InputStream getOverlayImageData() throws IOException;
+
+}
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/spi/RepositoryConnectorDescriptor.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/spi/RepositoryConnectorDescriptor.java
index a0151d122..c1c532662 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/spi/RepositoryConnectorDescriptor.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/spi/RepositoryConnectorDescriptor.java
@@ -21,6 +21,7 @@ import org.eclipse.mylyn.tasks.core.AbstractTaskListMigrator;
* A descriptor for an {@link AbstractRepositoryConnector} instance.
*
* @since 3.10
+ * @see RepositoryConnectorBranding
*/
public abstract class RepositoryConnectorDescriptor {

Back to the top