diff options
author | Eike Stepper | 2009-08-13 05:52:27 +0000 |
---|---|---|
committer | Eike Stepper | 2009-08-13 05:52:27 +0000 |
commit | 7c56a97fc3869b2a18ebe9d057f814e383c146bf (patch) | |
tree | 0657b07be419edd80904027b15ddd59eb3b70162 /plugins/org.gastro.rcp.table | |
parent | 013f6fa157e9e1590a49fa7fba9f895133eaa8ff (diff) | |
download | cdo-7c56a97fc3869b2a18ebe9d057f814e383c146bf.tar.gz cdo-7c56a97fc3869b2a18ebe9d057f814e383c146bf.tar.xz cdo-7c56a97fc3869b2a18ebe9d057f814e383c146bf.zip |
[284834] [Releng] Migrate Net4j and CDO builds to Athena/Hudson
https://bugs.eclipse.org/bugs/show_bug.cgi?id=284834
Diffstat (limited to 'plugins/org.gastro.rcp.table')
-rw-r--r-- | plugins/org.gastro.rcp.table/src/com/swtdesigner/ResourceManager.java | 60 | ||||
-rw-r--r-- | plugins/org.gastro.rcp.table/src/com/swtdesigner/SWTResourceManager.java | 32 |
2 files changed, 68 insertions, 24 deletions
diff --git a/plugins/org.gastro.rcp.table/src/com/swtdesigner/ResourceManager.java b/plugins/org.gastro.rcp.table/src/com/swtdesigner/ResourceManager.java index 64be40314e..beee171e50 100644 --- a/plugins/org.gastro.rcp.table/src/com/swtdesigner/ResourceManager.java +++ b/plugins/org.gastro.rcp.table/src/com/swtdesigner/ResourceManager.java @@ -27,7 +27,7 @@ import java.util.Map; * <p> * Copyright (c) 2003 - 2007, Instantiations, Inc. <br> * All Rights Reserved - * + * * @author scheglov_ke * @author Dan Rubel */ @@ -43,7 +43,7 @@ public class ResourceManager extends SWTResourceManager /** * Returns an {@link ImageDescriptor} stored in the file at the specified path relative to the specified class. - * + * * @param clazz * the {@link Class} relative to which to find the image descriptor. * @param path @@ -57,7 +57,7 @@ public class ResourceManager extends SWTResourceManager /** * Returns an {@link ImageDescriptor} stored in the file at the specified path. - * + * * @param path * the path to the image file. * @return the {@link ImageDescriptor} stored in the file at the specified path. @@ -76,7 +76,7 @@ public class ResourceManager extends SWTResourceManager /** * Returns an {@link Image} based on the specified {@link ImageDescriptor}. - * + * * @param descriptor * the {@link ImageDescriptor} for the {@link Image}. * @return the {@link Image} based on the specified {@link ImageDescriptor}. @@ -87,12 +87,14 @@ public class ResourceManager extends SWTResourceManager { return null; } + Image image = (Image)m_descriptorImageMap.get(descriptor); if (image == null) { image = descriptor.createImage(); m_descriptorImageMap.put(descriptor, image); } + return image; } @@ -103,7 +105,7 @@ public class ResourceManager extends SWTResourceManager /** * Returns an {@link Image} composed of a base image decorated by another image. - * + * * @param baseImage * the base {@link Image} that should be decorated. * @param decorator @@ -117,7 +119,7 @@ public class ResourceManager extends SWTResourceManager /** * Returns an {@link Image} composed of a base image decorated by another image. - * + * * @param baseImage * the base {@link Image} that should be decorated. * @param decorator @@ -132,19 +134,21 @@ public class ResourceManager extends SWTResourceManager { throw new IllegalArgumentException("Wrong decorate corner"); } + Map cornerDecoratedImageMap = m_decoratedImageMap[corner]; if (cornerDecoratedImageMap == null) { cornerDecoratedImageMap = new HashMap(); m_decoratedImageMap[corner] = cornerDecoratedImageMap; } + Map decoratedMap = (Map)cornerDecoratedImageMap.get(baseImage); if (decoratedMap == null) { decoratedMap = new HashMap(); cornerDecoratedImageMap.put(baseImage, decoratedMap); } - // + Image result = (Image)decoratedMap.get(decorator); if (result == null) { @@ -179,10 +183,11 @@ public class ResourceManager extends SWTResourceManager return baseImageSize; } }; - // + result = compositImageDesc.createImage(); decoratedMap.put(decorator, result); } + return result; } @@ -192,14 +197,17 @@ public class ResourceManager extends SWTResourceManager public static void disposeImages() { SWTResourceManager.disposeImages(); - // dispose ImageDescriptor images + // dispose ImageDescriptor images + { for (Iterator I = m_descriptorImageMap.values().iterator(); I.hasNext();) { ((Image)I.next()).dispose(); } + m_descriptorImageMap.clear(); } + // dispose decorated images for (int i = 0; i < m_decoratedImageMap.length; i++) { @@ -214,17 +222,21 @@ public class ResourceManager extends SWTResourceManager Image image = (Image)J.next(); image.dispose(); } + decoratedMap.clear(); } + cornerDecoratedImageMap.clear(); } } + // dispose plugin images { for (Iterator I = m_URLImageMap.values().iterator(); I.hasNext();) { ((Image)I.next()).dispose(); } + m_URLImageMap.clear(); } } @@ -254,7 +266,7 @@ public class ResourceManager extends SWTResourceManager /** * Returns an {@link Image} based on a plugin and file path. - * + * * @param plugin * the plugin {@link Object} containing the image * @param name @@ -276,12 +288,13 @@ public class ResourceManager extends SWTResourceManager { // Ignore any exceptions } + return null; } /** * Returns an {@link Image} based on a {@link Bundle} and resource entry path. - * + * * @param symbolicName * the symbolic name of the {@link Bundle}. * @param path @@ -302,6 +315,7 @@ public class ResourceManager extends SWTResourceManager { // Ignore any exceptions } + return null; } @@ -318,8 +332,10 @@ public class ResourceManager extends SWTResourceManager { return (Image)m_URLImageMap.get(url); } + InputStream stream = url.openStream(); Image image; + try { image = getImage(stream); @@ -329,6 +345,7 @@ public class ResourceManager extends SWTResourceManager { stream.close(); } + return image; } catch (Throwable e) @@ -340,12 +357,13 @@ public class ResourceManager extends SWTResourceManager { // Ignore any exceptions } + return null; } /** * Returns an {@link ImageDescriptor} based on a plugin and file path. - * + * * @param plugin * the plugin {@link Object} containing the image. * @param name @@ -371,12 +389,13 @@ public class ResourceManager extends SWTResourceManager { // Ignore any exceptions } + return null; } /** * Returns an {@link ImageDescriptor} based on a {@link Bundle} and resource entry path. - * + * * @param symbolicName * the symbolic name of the {@link Bundle}. * @param path @@ -397,6 +416,7 @@ public class ResourceManager extends SWTResourceManager { // Ignore any exceptions } + return null; } @@ -413,18 +433,20 @@ public class ResourceManager extends SWTResourceManager return bundle.getEntry(path); } } + // try design time provider if (m_designTimePluginResourceProvider != null) { return m_designTimePluginResourceProvider.getEntry(symbolicName, path); } + // no such resource return null; } /** * Returns an {@link URL} based on a plugin and file path. - * + * * @param plugin * the plugin {@link Object} containing the file path. * @param name @@ -443,11 +465,11 @@ public class ResourceManager extends SWTResourceManager { Method getBundleMethod = BundleContextClass.getMethod("getBundle", new Class[0]); //$NON-NLS-1$ Object bundle = getBundleMethod.invoke(plugin, new Object[0]); - // + Class PathClass = Class.forName("org.eclipse.core.runtime.Path"); //$NON-NLS-1$ Constructor pathConstructor = PathClass.getConstructor(new Class[] { String.class }); Object path = pathConstructor.newInstance(new Object[] { name }); - // + Class IPathClass = Class.forName("org.eclipse.core.runtime.IPath"); //$NON-NLS-1$ Class PlatformClass = Class.forName("org.eclipse.core.runtime.Platform"); //$NON-NLS-1$ Method findMethod = PlatformClass.getMethod("find", new Class[] { BundleClass, IPathClass }); //$NON-NLS-1$ @@ -458,21 +480,23 @@ public class ResourceManager extends SWTResourceManager { // Ignore any exceptions } + // else work with 'plugin' as with usual Eclipse plugin + { Class PluginClass = Class.forName("org.eclipse.core.runtime.Plugin"); //$NON-NLS-1$ if (PluginClass.isAssignableFrom(plugin.getClass())) { - // Class PathClass = Class.forName("org.eclipse.core.runtime.Path"); //$NON-NLS-1$ Constructor pathConstructor = PathClass.getConstructor(new Class[] { String.class }); Object path = pathConstructor.newInstance(new Object[] { name }); - // + Class IPathClass = Class.forName("org.eclipse.core.runtime.IPath"); //$NON-NLS-1$ Method findMethod = PluginClass.getMethod("find", new Class[] { IPathClass }); //$NON-NLS-1$ return (URL)findMethod.invoke(plugin, new Object[] { path }); } } + return null; } diff --git a/plugins/org.gastro.rcp.table/src/com/swtdesigner/SWTResourceManager.java b/plugins/org.gastro.rcp.table/src/com/swtdesigner/SWTResourceManager.java index 682220565f..23f9c3f575 100644 --- a/plugins/org.gastro.rcp.table/src/com/swtdesigner/SWTResourceManager.java +++ b/plugins/org.gastro.rcp.table/src/com/swtdesigner/SWTResourceManager.java @@ -88,6 +88,7 @@ public class SWTResourceManager color = new Color(display, rgb); m_colorMap.put(rgb, color); } + return color; } @@ -100,6 +101,7 @@ public class SWTResourceManager { ((Color)I.next()).dispose(); } + m_colorMap.clear(); } @@ -130,6 +132,7 @@ public class SWTResourceManager { return new Image(display, data, data.getTransparencyMask()); } + return new Image(display, data); } finally @@ -161,6 +164,7 @@ public class SWTResourceManager m_imageMap.put(path, image); } } + return image; } @@ -190,6 +194,7 @@ public class SWTResourceManager m_imageMap.put(key, image); } } + return image; } @@ -201,12 +206,12 @@ public class SWTResourceManager private static Image getMissingImage() { Image image = new Image(Display.getCurrent(), MISSING_IMAGE_SIZE, MISSING_IMAGE_SIZE); - // + GC gc = new GC(image); gc.setBackground(getColor(SWT.COLOR_RED)); gc.fillRectangle(0, 0, MISSING_IMAGE_SIZE, MISSING_IMAGE_SIZE); gc.dispose(); - // + return image; } @@ -271,27 +276,29 @@ public class SWTResourceManager { throw new IllegalArgumentException("Wrong decorate corner"); } + Map cornerDecoratedImageMap = m_decoratedImageMap[corner]; if (cornerDecoratedImageMap == null) { cornerDecoratedImageMap = new HashMap(); m_decoratedImageMap[corner] = cornerDecoratedImageMap; } + Map decoratedMap = (Map)cornerDecoratedImageMap.get(baseImage); if (decoratedMap == null) { decoratedMap = new HashMap(); cornerDecoratedImageMap.put(baseImage, decoratedMap); } - // + Image result = (Image)decoratedMap.get(decorator); if (result == null) { Rectangle bib = baseImage.getBounds(); Rectangle dib = decorator.getBounds(); - // + result = new Image(Display.getCurrent(), bib.width, bib.height); - // + GC gc = new GC(result); gc.drawImage(baseImage, 0, 0); if (corner == TOP_LEFT) @@ -310,10 +317,12 @@ public class SWTResourceManager { gc.drawImage(decorator, bib.width - dib.width, bib.height - dib.height); } + gc.dispose(); - // + decoratedMap.put(decorator, result); } + return result; } @@ -323,13 +332,16 @@ public class SWTResourceManager public static void disposeImages() { // dispose loaded images + { for (Iterator I = m_imageMap.values().iterator(); I.hasNext();) { ((Image)I.next()).dispose(); } + m_imageMap.clear(); } + // dispose decorated images for (int i = 0; i < m_decoratedImageMap.length; i++) { @@ -344,8 +356,10 @@ public class SWTResourceManager Image image = (Image)J.next(); image.dispose(); } + decoratedMap.clear(); } + cornerDecoratedImageMap.clear(); } } @@ -417,6 +431,7 @@ public class SWTResourceManager { logFontClass.getField("lfStrikeOut").set(logFont, new Byte((byte)1)); //$NON-NLS-1$ } + if (underline) { logFontClass.getField("lfUnderline").set(logFont, new Byte((byte)1)); //$NON-NLS-1$ @@ -428,9 +443,11 @@ public class SWTResourceManager System.err.println("Unable to set underline or strikeout" + " (probably on a non-Windows platform). " + e); //$NON-NLS-1$ //$NON-NLS-2$ } } + font = new Font(Display.getCurrent(), fontData); m_fontMap.put(fontName, font); } + return font; } @@ -451,6 +468,7 @@ public class SWTResourceManager font = new Font(Display.getCurrent(), data.getName(), data.getHeight(), SWT.BOLD); m_fontToBoldFontMap.put(baseFont, font); } + return font; } @@ -464,12 +482,14 @@ public class SWTResourceManager { ((Font)iter.next()).dispose(); } + m_fontMap.clear(); // clear bold fonts for (Iterator iter = m_fontToBoldFontMap.values().iterator(); iter.hasNext();) { ((Font)iter.next()).dispose(); } + m_fontToBoldFontMap.clear(); } |