diff options
Diffstat (limited to 'org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/spi/RepositoryConnectorBranding.java')
-rw-r--r-- | org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/spi/RepositoryConnectorBranding.java | 106 |
1 files changed, 106 insertions, 0 deletions
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; + +} |