diff options
Diffstat (limited to 'plugins/facet/org.eclipse.papyrus.emf.facet.util.swt/src/org')
10 files changed, 341 insertions, 341 deletions
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.swt/src/org/eclipse/papyrus/emf/facet/util/swt/colorprovider/IColorProvider.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.swt/src/org/eclipse/papyrus/emf/facet/util/swt/colorprovider/IColorProvider.java index 1c2ea00d098..df619f9d8b1 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.util.swt/src/org/eclipse/papyrus/emf/facet/util/swt/colorprovider/IColorProvider.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.swt/src/org/eclipse/papyrus/emf/facet/util/swt/colorprovider/IColorProvider.java @@ -1,22 +1,22 @@ -/*******************************************************************************
- * Copyright (c) 2013 Mia-Software.
- *
- * 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:
- * Grégoire Dupé (Mia-Software) - Bug 424122 - [Table] Images, fonts and colors are not shared between the instances of table
- ******************************************************************************/
-
-package org.eclipse.papyrus.emf.facet.util.swt.colorprovider;
-
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.RGB;
-
-public interface IColorProvider {
-
- Color getColor(RGB path);
-
-}
+/******************************************************************************* + * Copyright (c) 2013 Mia-Software. + * + * 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: + * Grégoire Dupé (Mia-Software) - Bug 424122 - [Table] Images, fonts and colors are not shared between the instances of table + ******************************************************************************/ + +package org.eclipse.papyrus.emf.facet.util.swt.colorprovider; + +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.RGB; + +public interface IColorProvider { + + Color getColor(RGB path); + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.swt/src/org/eclipse/papyrus/emf/facet/util/swt/colorprovider/IColorProviderFactory.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.swt/src/org/eclipse/papyrus/emf/facet/util/swt/colorprovider/IColorProviderFactory.java index 8c91805caf1..42a1b7377f7 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.util.swt/src/org/eclipse/papyrus/emf/facet/util/swt/colorprovider/IColorProviderFactory.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.swt/src/org/eclipse/papyrus/emf/facet/util/swt/colorprovider/IColorProviderFactory.java @@ -1,22 +1,22 @@ -/*******************************************************************************
- * Copyright (c) 2013 Mia-Software.
- *
- * 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:
- * Grégoire Dupé (Mia-Software) - Bug 424122 - [Table] Images, fonts and colors are not shared between the instances of table
- ******************************************************************************/
-package org.eclipse.papyrus.emf.facet.util.swt.colorprovider;
-
-import org.eclipse.papyrus.emf.facet.util.swt.internal.colorprovider.ColorProviderFactory;
-import org.eclipse.swt.graphics.Device;
-
-public interface IColorProviderFactory {
-
- IColorProviderFactory DEFAULT = new ColorProviderFactory();
-
- IColorProvider getOrCreateIColorProvider(Device device);
-}
+/******************************************************************************* + * Copyright (c) 2013 Mia-Software. + * + * 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: + * Grégoire Dupé (Mia-Software) - Bug 424122 - [Table] Images, fonts and colors are not shared between the instances of table + ******************************************************************************/ +package org.eclipse.papyrus.emf.facet.util.swt.colorprovider; + +import org.eclipse.papyrus.emf.facet.util.swt.internal.colorprovider.ColorProviderFactory; +import org.eclipse.swt.graphics.Device; + +public interface IColorProviderFactory { + + IColorProviderFactory DEFAULT = new ColorProviderFactory(); + + IColorProvider getOrCreateIColorProvider(Device device); +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.swt/src/org/eclipse/papyrus/emf/facet/util/swt/fontprovider/IFontProvider.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.swt/src/org/eclipse/papyrus/emf/facet/util/swt/fontprovider/IFontProvider.java index 13334268988..1d13cd71201 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.util.swt/src/org/eclipse/papyrus/emf/facet/util/swt/fontprovider/IFontProvider.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.swt/src/org/eclipse/papyrus/emf/facet/util/swt/fontprovider/IFontProvider.java @@ -1,22 +1,22 @@ -/*******************************************************************************
- * Copyright (c) 2013 Mia-Software.
- *
- * 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:
- * Grégoire Dupé (Mia-Software) - Bug 424122 - [Table] Images, fonts and colors are not shared between the instances of table
- ******************************************************************************/
-
-package org.eclipse.papyrus.emf.facet.util.swt.fontprovider;
-
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.FontData;
-
-public interface IFontProvider {
-
- Font getFont(FontData fontData);
-
-}
+/******************************************************************************* + * Copyright (c) 2013 Mia-Software. + * + * 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: + * Grégoire Dupé (Mia-Software) - Bug 424122 - [Table] Images, fonts and colors are not shared between the instances of table + ******************************************************************************/ + +package org.eclipse.papyrus.emf.facet.util.swt.fontprovider; + +import org.eclipse.swt.graphics.Font; +import org.eclipse.swt.graphics.FontData; + +public interface IFontProvider { + + Font getFont(FontData fontData); + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.swt/src/org/eclipse/papyrus/emf/facet/util/swt/fontprovider/IFontProviderFactory.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.swt/src/org/eclipse/papyrus/emf/facet/util/swt/fontprovider/IFontProviderFactory.java index 5c2c24b244b..e7a8c70a2b1 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.util.swt/src/org/eclipse/papyrus/emf/facet/util/swt/fontprovider/IFontProviderFactory.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.swt/src/org/eclipse/papyrus/emf/facet/util/swt/fontprovider/IFontProviderFactory.java @@ -1,22 +1,22 @@ -/*******************************************************************************
- * Copyright (c) 2013 Mia-Software.
- *
- * 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:
- * Grégoire Dupé (Mia-Software) - Bug 424122 - [Table] Images, fonts and colors are not shared between the instances of table
- ******************************************************************************/
-package org.eclipse.papyrus.emf.facet.util.swt.fontprovider;
-
-import org.eclipse.papyrus.emf.facet.util.swt.internal.fontprovider.FontProviderFactory;
-import org.eclipse.swt.graphics.Device;
-
-public interface IFontProviderFactory {
-
- IFontProviderFactory DEFAULT = new FontProviderFactory();
-
- IFontProvider getOrCreateIFontProvider(Device device);
-}
+/******************************************************************************* + * Copyright (c) 2013 Mia-Software. + * + * 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: + * Grégoire Dupé (Mia-Software) - Bug 424122 - [Table] Images, fonts and colors are not shared between the instances of table + ******************************************************************************/ +package org.eclipse.papyrus.emf.facet.util.swt.fontprovider; + +import org.eclipse.papyrus.emf.facet.util.swt.internal.fontprovider.FontProviderFactory; +import org.eclipse.swt.graphics.Device; + +public interface IFontProviderFactory { + + IFontProviderFactory DEFAULT = new FontProviderFactory(); + + IFontProvider getOrCreateIFontProvider(Device device); +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.swt/src/org/eclipse/papyrus/emf/facet/util/swt/imageprovider/IImageProvider.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.swt/src/org/eclipse/papyrus/emf/facet/util/swt/imageprovider/IImageProvider.java index d5b011b8ab4..04473d002f7 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.util.swt/src/org/eclipse/papyrus/emf/facet/util/swt/imageprovider/IImageProvider.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.swt/src/org/eclipse/papyrus/emf/facet/util/swt/imageprovider/IImageProvider.java @@ -1,27 +1,27 @@ -/*******************************************************************************
- * Copyright (c) 2013 Mia-Software.
- *
- * 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:
- * Gregoire Dupe (Mia-Software) - Bug 406569 - Image provider factory
- * Gregoire Dupe (Mia-Software) - Bug 424122 - [Table] Images, fonts and colors are not shared between the instances of table
- ******************************************************************************/
-
-package org.eclipse.papyrus.emf.facet.util.swt.imageprovider;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.swt.graphics.Image;
-
-public interface IImageProvider {
-
- Image getImage(String path);
-
- ImageDescriptor createImageDescriptor(String resourcePath);
-
- Image getImage(ImageDescriptor imgDescriptor);
-
-}
+/******************************************************************************* + * Copyright (c) 2013 Mia-Software. + * + * 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: + * Gregoire Dupe (Mia-Software) - Bug 406569 - Image provider factory + * Gregoire Dupe (Mia-Software) - Bug 424122 - [Table] Images, fonts and colors are not shared between the instances of table + ******************************************************************************/ + +package org.eclipse.papyrus.emf.facet.util.swt.imageprovider; + +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.swt.graphics.Image; + +public interface IImageProvider { + + Image getImage(String path); + + ImageDescriptor createImageDescriptor(String resourcePath); + + Image getImage(ImageDescriptor imgDescriptor); + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.swt/src/org/eclipse/papyrus/emf/facet/util/swt/imageprovider/IImageProviderFactory.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.swt/src/org/eclipse/papyrus/emf/facet/util/swt/imageprovider/IImageProviderFactory.java index 0ae8154c2de..629488a5637 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.util.swt/src/org/eclipse/papyrus/emf/facet/util/swt/imageprovider/IImageProviderFactory.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.swt/src/org/eclipse/papyrus/emf/facet/util/swt/imageprovider/IImageProviderFactory.java @@ -1,22 +1,22 @@ -/*******************************************************************************
- * Copyright (c) 2013 Mia-Software.
- *
- * 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:
- * Gregoire Dupe (Mia-Software) - Bug 406569 - Image provider factory
- ******************************************************************************/
-package org.eclipse.papyrus.emf.facet.util.swt.imageprovider;
-
-import org.eclipse.core.runtime.Plugin;
-import org.eclipse.papyrus.emf.facet.util.swt.internal.imageprovider.ImageProviderFactory;
-
-public interface IImageProviderFactory {
-
- IImageProviderFactory DEFAULT = new ImageProviderFactory();
-
- IImageProvider createIImageProvider(Plugin plugin);
-}
+/******************************************************************************* + * Copyright (c) 2013 Mia-Software. + * + * 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: + * Gregoire Dupe (Mia-Software) - Bug 406569 - Image provider factory + ******************************************************************************/ +package org.eclipse.papyrus.emf.facet.util.swt.imageprovider; + +import org.eclipse.core.runtime.Plugin; +import org.eclipse.papyrus.emf.facet.util.swt.internal.imageprovider.ImageProviderFactory; + +public interface IImageProviderFactory { + + IImageProviderFactory DEFAULT = new ImageProviderFactory(); + + IImageProvider createIImageProvider(Plugin plugin); +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.swt/src/org/eclipse/papyrus/emf/facet/util/swt/internal/Activator.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.swt/src/org/eclipse/papyrus/emf/facet/util/swt/internal/Activator.java index bab27c5b0e8..1d721abf6b8 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.util.swt/src/org/eclipse/papyrus/emf/facet/util/swt/internal/Activator.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.swt/src/org/eclipse/papyrus/emf/facet/util/swt/internal/Activator.java @@ -1,45 +1,45 @@ -/*******************************************************************************
- * Copyright (c) 2012 CEA LIST.
- * 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:
- * Nicolas Bros (Mia-Software) - Bug 372865 - FacetSet selection dialog
- *******************************************************************************/
-package org.eclipse.papyrus.emf.facet.util.swt.internal;
-
-import org.eclipse.core.runtime.Plugin;
-import org.osgi.framework.BundleContext;
-
-/** The activator class controls the plug-in life cycle */
-public class Activator extends Plugin {
-
- // The plug-in ID
- public static final String PLUGIN_ID = "org.eclipse.papyrus.emf.facet.util.swt"; //$NON-NLS-1$
-
- // The shared instance
- private static Activator plugin;
-
- @Override
- public void start(final BundleContext context) throws Exception {
- super.start(context);
- Activator.plugin = this;
- }
-
- @Override
- public void stop(final BundleContext context) throws Exception {
- Activator.plugin = null;
- super.stop(context);
- }
-
- /**
- * Returns the shared instance
- *
- * @return the shared instance
- */
- public static Activator getDefault() {
- return Activator.plugin;
- }
-}
+/******************************************************************************* + * Copyright (c) 2012 CEA LIST. + * 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: + * Nicolas Bros (Mia-Software) - Bug 372865 - FacetSet selection dialog + *******************************************************************************/ +package org.eclipse.papyrus.emf.facet.util.swt.internal; + +import org.eclipse.core.runtime.Plugin; +import org.osgi.framework.BundleContext; + +/** The activator class controls the plug-in life cycle */ +public class Activator extends Plugin { + + // The plug-in ID + public static final String PLUGIN_ID = "org.eclipse.papyrus.emf.facet.util.swt"; //$NON-NLS-1$ + + // The shared instance + private static Activator plugin; + + @Override + public void start(final BundleContext context) throws Exception { + super.start(context); + Activator.plugin = this; + } + + @Override + public void stop(final BundleContext context) throws Exception { + Activator.plugin = null; + super.stop(context); + } + + /** + * Returns the shared instance + * + * @return the shared instance + */ + public static Activator getDefault() { + return Activator.plugin; + } +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.swt/src/org/eclipse/papyrus/emf/facet/util/swt/internal/exported/SWTTestUtils.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.swt/src/org/eclipse/papyrus/emf/facet/util/swt/internal/exported/SWTTestUtils.java index 2490cc3a631..415f92cc95f 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.util.swt/src/org/eclipse/papyrus/emf/facet/util/swt/internal/exported/SWTTestUtils.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.swt/src/org/eclipse/papyrus/emf/facet/util/swt/internal/exported/SWTTestUtils.java @@ -1,38 +1,38 @@ -/*******************************************************************************
- * Copyright (c) 2012 CEA LIST.
- * 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:
- * Nicolas Bros (Mia-Software) - Bug 372865 - FacetSet selection dialog
- *******************************************************************************/
-package org.eclipse.papyrus.emf.facet.util.swt.internal.exported;
-
-import org.eclipse.swt.widgets.TreeItem;
-
-public final class SWTTestUtils {
- private SWTTestUtils() {
- // utility class
- }
-
- /**
- * Find a tree item with the given text among the list of tree items.
- *
- * @param text
- * the text of the tree item to find
- * @param items
- * the list of tree items to search
- * @return the tree item or <code>null</code> if not found
- */
- public static TreeItem findTreeItem(final String text, final TreeItem[] items) {
- TreeItem result = null;
- for (TreeItem item : items) {
- if (text.equals(item.getText())) {
- result = item;
- }
- }
- return result;
- }
-}
+/******************************************************************************* + * Copyright (c) 2012 CEA LIST. + * 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: + * Nicolas Bros (Mia-Software) - Bug 372865 - FacetSet selection dialog + *******************************************************************************/ +package org.eclipse.papyrus.emf.facet.util.swt.internal.exported; + +import org.eclipse.swt.widgets.TreeItem; + +public final class SWTTestUtils { + private SWTTestUtils() { + // utility class + } + + /** + * Find a tree item with the given text among the list of tree items. + * + * @param text + * the text of the tree item to find + * @param items + * the list of tree items to search + * @return the tree item or <code>null</code> if not found + */ + public static TreeItem findTreeItem(final String text, final TreeItem[] items) { + TreeItem result = null; + for (TreeItem item : items) { + if (text.equals(item.getText())) { + result = item; + } + } + return result; + } +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.swt/src/org/eclipse/papyrus/emf/facet/util/swt/internal/imageprovider/ImageProvider.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.swt/src/org/eclipse/papyrus/emf/facet/util/swt/internal/imageprovider/ImageProvider.java index 435792d2974..94e92bf7537 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.util.swt/src/org/eclipse/papyrus/emf/facet/util/swt/internal/imageprovider/ImageProvider.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.swt/src/org/eclipse/papyrus/emf/facet/util/swt/internal/imageprovider/ImageProvider.java @@ -1,86 +1,86 @@ -/*******************************************************************************
- * Copyright (c) 2013 Mia-Software.
- *
- * 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:
- * Gregoire Dupe (Mia-Software) - Bug 406569 - Image provider factory
- * Gregoire Dupe (Mia-Software) - Bug 423611 - ImageProvider doesn't use singleton instance
- * Gregoire Dupe (Mia-Software) - Bug 424122 - [Table] Images, fonts and colors are not shared between the instances of table
- ******************************************************************************/
-
-package org.eclipse.papyrus.emf.facet.util.swt.internal.imageprovider;
-
-import java.net.URL;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.core.runtime.Plugin;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.papyrus.emf.facet.util.core.DebugUtils;
-import org.eclipse.papyrus.emf.facet.util.core.Logger;
-import org.eclipse.papyrus.emf.facet.util.swt.imageprovider.IImageProvider;
-import org.eclipse.papyrus.emf.facet.util.swt.internal.Activator;
-import org.eclipse.swt.graphics.Image;
-import org.osgi.framework.Bundle;
-
-public final class ImageProvider implements IImageProvider {
-
- private static final boolean DEBUG = DebugUtils.getDebugStatus(Activator.getDefault());
- private final Map<Object, Image> map = new HashMap<Object, Image>();
- private final Plugin activator;
-
- ImageProvider(final Plugin activator) {
- this.activator = activator;
- }
-
- public ImageDescriptor createImageDescriptor(final String resourcePath) {
- ImageDescriptor result;
- final URL url = this.activator.getBundle().getResource(resourcePath);
- if (url == null) {
- Logger.logError(NLS.bind("Resource not found: {0}", //$NON-NLS-1$
- resourcePath), this.activator);
- result = ImageDescriptor.getMissingImageDescriptor();
- } else {
- result = ImageDescriptor.createFromURL(url);
- }
- return result;
- }
-
- public Image getImage(final String path) {
- Image result = this.map.get(path);
- if (result == null) {
- result = createImageDescriptor(path).createImage();
- this.map.put(path, result);
- if (DEBUG) {
- final Bundle bundle = this.activator.getBundle();
- final String bundleId = bundle.getSymbolicName();
- final String message = String.format("New image loaded: %s:%s", //$NON-NLS-1$
- bundleId, path);
- DebugUtils.debug(message);
- }
- }
- return result;
- }
-
- public Image getImage(final ImageDescriptor imgDescriptor) {
- Image result = this.map.get(imgDescriptor);
- if (result == null) {
- result = imgDescriptor.createImage();
- this.map.put(imgDescriptor, result);
- if (DEBUG) {
- final Bundle bundle = this.activator.getBundle();
- final String bundleId = bundle.getSymbolicName();
- final String message = String.format("New image loaded from an image descriptor (bundle=%s)", //$NON-NLS-1$
- bundleId);
- DebugUtils.debug(message);
- }
- }
- return result;
- }
-
-}
+/******************************************************************************* + * Copyright (c) 2013 Mia-Software. + * + * 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: + * Gregoire Dupe (Mia-Software) - Bug 406569 - Image provider factory + * Gregoire Dupe (Mia-Software) - Bug 423611 - ImageProvider doesn't use singleton instance + * Gregoire Dupe (Mia-Software) - Bug 424122 - [Table] Images, fonts and colors are not shared between the instances of table + ******************************************************************************/ + +package org.eclipse.papyrus.emf.facet.util.swt.internal.imageprovider; + +import java.net.URL; +import java.util.HashMap; +import java.util.Map; + +import org.eclipse.core.runtime.Plugin; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.osgi.util.NLS; +import org.eclipse.papyrus.emf.facet.util.core.DebugUtils; +import org.eclipse.papyrus.emf.facet.util.core.Logger; +import org.eclipse.papyrus.emf.facet.util.swt.imageprovider.IImageProvider; +import org.eclipse.papyrus.emf.facet.util.swt.internal.Activator; +import org.eclipse.swt.graphics.Image; +import org.osgi.framework.Bundle; + +public final class ImageProvider implements IImageProvider { + + private static final boolean DEBUG = DebugUtils.getDebugStatus(Activator.getDefault()); + private final Map<Object, Image> map = new HashMap<Object, Image>(); + private final Plugin activator; + + ImageProvider(final Plugin activator) { + this.activator = activator; + } + + public ImageDescriptor createImageDescriptor(final String resourcePath) { + ImageDescriptor result; + final URL url = this.activator.getBundle().getResource(resourcePath); + if (url == null) { + Logger.logError(NLS.bind("Resource not found: {0}", //$NON-NLS-1$ + resourcePath), this.activator); + result = ImageDescriptor.getMissingImageDescriptor(); + } else { + result = ImageDescriptor.createFromURL(url); + } + return result; + } + + public Image getImage(final String path) { + Image result = this.map.get(path); + if (result == null) { + result = createImageDescriptor(path).createImage(); + this.map.put(path, result); + if (DEBUG) { + final Bundle bundle = this.activator.getBundle(); + final String bundleId = bundle.getSymbolicName(); + final String message = String.format("New image loaded: %s:%s", //$NON-NLS-1$ + bundleId, path); + DebugUtils.debug(message); + } + } + return result; + } + + public Image getImage(final ImageDescriptor imgDescriptor) { + Image result = this.map.get(imgDescriptor); + if (result == null) { + result = imgDescriptor.createImage(); + this.map.put(imgDescriptor, result); + if (DEBUG) { + final Bundle bundle = this.activator.getBundle(); + final String bundleId = bundle.getSymbolicName(); + final String message = String.format("New image loaded from an image descriptor (bundle=%s)", //$NON-NLS-1$ + bundleId); + DebugUtils.debug(message); + } + } + return result; + } + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.swt/src/org/eclipse/papyrus/emf/facet/util/swt/internal/imageprovider/ImageProviderFactory.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.swt/src/org/eclipse/papyrus/emf/facet/util/swt/internal/imageprovider/ImageProviderFactory.java index 530d9916caa..fa23f2bf20f 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.util.swt/src/org/eclipse/papyrus/emf/facet/util/swt/internal/imageprovider/ImageProviderFactory.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.swt/src/org/eclipse/papyrus/emf/facet/util/swt/internal/imageprovider/ImageProviderFactory.java @@ -1,35 +1,35 @@ -/*******************************************************************************
- * Copyright (c) 2013 Mia-Software.
- *
- * 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:
- * Gregoire Dupe (Mia-Software) - Bug 406569 - Image provider factory
- * Gregoire Dupe (Mia-Software) - Bug 423611 - ImageProvider doesn't use singleton instance
- ******************************************************************************/
-package org.eclipse.papyrus.emf.facet.util.swt.internal.imageprovider;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.core.runtime.Plugin;
-import org.eclipse.papyrus.emf.facet.util.swt.imageprovider.IImageProvider;
-import org.eclipse.papyrus.emf.facet.util.swt.imageprovider.IImageProviderFactory;
-
-public class ImageProviderFactory implements IImageProviderFactory {
-
- private final Map<Plugin, IImageProvider> map = new HashMap<Plugin, IImageProvider>();
-
- public IImageProvider createIImageProvider(final Plugin plugin) {
- IImageProvider result = this.map.get(plugin);
- if (result == null) {
- result = new ImageProvider(plugin);
- this.map.put(plugin, result);
- }
- return result;
- }
-
-}
+/******************************************************************************* + * Copyright (c) 2013 Mia-Software. + * + * 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: + * Gregoire Dupe (Mia-Software) - Bug 406569 - Image provider factory + * Gregoire Dupe (Mia-Software) - Bug 423611 - ImageProvider doesn't use singleton instance + ******************************************************************************/ +package org.eclipse.papyrus.emf.facet.util.swt.internal.imageprovider; + +import java.util.HashMap; +import java.util.Map; + +import org.eclipse.core.runtime.Plugin; +import org.eclipse.papyrus.emf.facet.util.swt.imageprovider.IImageProvider; +import org.eclipse.papyrus.emf.facet.util.swt.imageprovider.IImageProviderFactory; + +public class ImageProviderFactory implements IImageProviderFactory { + + private final Map<Plugin, IImageProvider> map = new HashMap<Plugin, IImageProvider>(); + + public IImageProvider createIImageProvider(final Plugin plugin) { + IImageProvider result = this.map.get(plugin); + if (result == null) { + result = new ImageProvider(plugin); + this.map.put(plugin, result); + } + return result; + } + +} |