diff options
author | Steffen Pingel | 2013-06-27 15:25:00 +0000 |
---|---|---|
committer | Steffen Pingel | 2013-06-28 12:49:17 +0000 |
commit | 41bfa30a421f1051ef38c4946eb31ecd253b2226 (patch) | |
tree | dc3109bc38013136e7e95d4dfc6b497a27f713f0 /org.eclipse.mylyn.tasks.core | |
parent | 7d54bbdcace41210385cab6463fae1f096231866 (diff) | |
download | org.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')
4 files changed, 131 insertions, 16 deletions
diff --git a/org.eclipse.mylyn.tasks.core/schema/repositoryConnectorContributor.exsd b/org.eclipse.mylyn.tasks.core/schema/repositoryConnectorContributor.exsd index 1009f3f5e..6c8388663 100644 --- a/org.eclipse.mylyn.tasks.core/schema/repositoryConnectorContributor.exsd +++ b/org.eclipse.mylyn.tasks.core/schema/repositoryConnectorContributor.exsd @@ -17,9 +17,9 @@ </appInfo> </annotation> <complexType> - <choice> + <sequence> <element ref="contributor"/> - </choice> + </sequence> <attribute name="point" type="string" use="required"> <annotation> <documentation> @@ -49,13 +49,13 @@ <element name="contributor"> <complexType> - <attribute name="class" type="string"> + <attribute name="class" type="string" use="required"> <annotation> <documentation> The class that contributes connector descriptors. </documentation> <appInfo> - <meta.attribute kind="java" basedOn="org.eclipse.mylyn.tasks.core.RepositoryConnectorDescriptor:"/> + <meta.attribute kind="java" basedOn="org.eclipse.mylyn.tasks.core.spi.RepositoryConnectorContributor:"/> </appInfo> </annotation> </attribute> @@ -76,27 +76,28 @@ <meta.section type="examples"/> </appInfo> <documentation> - [Enter extension point usage example here.] + <extension + point="org.eclipse.mylyn.tasks.core.repositoryConnectorContributor"> + <contributor + class="MyRepositoryConnectorContributor"> + </contributor> + </extension> </documentation> </annotation> - <annotation> - <appInfo> - <meta.section type="apiinfo"/> - </appInfo> - <documentation> - [Enter API information here.] - </documentation> - </annotation> + <annotation> <appInfo> - <meta.section type="implementation"/> + <meta.section type="copyright"/> </appInfo> <documentation> - [Enter information about supplied implementation of this extension point.] + 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 </documentation> </annotation> - </schema> 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> + * <extension + * point="org.eclipse.core.runtime.adapters"> + * <factory + * adaptableType="org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector" + * class="MyRepositoryConnectorAdapter"> + * <adapter + * type="org.eclipse.mylyn.tasks.core.spi.RepositoryConnectorBranding"> + * </adapter> + * </factory> + * </extension> + * </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 { + * + * @Override + * public Object getAdapter(Object adaptableObject, Class adapterType) { + * if (adaptableObject instanceof MyRepositoryConnector) { + * if (adapterType == RepositoryConnectorBranding.class) { + * return new RepositoryConnectorBranding() { + * @Override + * public InputStream getOverlayImageData() throws IOException { + * return getResource(this, "repository-overlay.gif"); + * } + * + * @Override + * public InputStream getBrandingImageData() throws IOException { + * return CommonTestUtil.getResource(this, "repository.gif"); + * } + * }; + * } + * } + * 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 { |