Author: svasilyev
Date: 2007-10-16 10:37:58 -0400 (Tue, 16 Oct 2007)
New Revision: 4236
Added:
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe.ui.palette/src/org/jboss/tools/vpe/ui/palette/model/LargeImageDescriptor.java
Log:
Sync before merge with HEAD
Added:
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe.ui.palette/src/org/jboss/tools/vpe/ui/palette/model/LargeImageDescriptor.java
===================================================================
---
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe.ui.palette/src/org/jboss/tools/vpe/ui/palette/model/LargeImageDescriptor.java
(rev 0)
+++
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe.ui.palette/src/org/jboss/tools/vpe/ui/palette/model/LargeImageDescriptor.java 2007-10-16
14:37:58 UTC (rev 4236)
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.vpe.ui.palette.model;
+
+import java.util.Hashtable;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.graphics.Device;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.ImageData;
+import org.jboss.tools.common.model.XModelObject;
+import org.jboss.tools.common.model.icons.impl.LargeReferencedIcons;
+
+/**
+ * @author Viacheslav Kabanovich
+ */
+public class LargeImageDescriptor extends ImageDescriptor {
+ private static Hashtable<String,Image> imageCache = new
Hashtable<String,Image>();
+ LargeReferencedIcons xicon = new LargeReferencedIcons();
+ XModelObject object;
+
+ public LargeImageDescriptor(XModelObject object) {
+ this.object = object;
+ }
+
+ public ImageData getImageData() {
+ return createImage().getImageData();
+ }
+
+ public Image createImage(boolean returnMissingImageOnError, Device device) {
+ int code = xicon.getHash(object);
+ if (code == 0) return null;
+ String key = "" + code;
+ Image img = (Image)imageCache.get(key);
+ if (img != null) return img;
+ img = xicon.getImage(object);
+ if (img != null) imageCache.put(key, img);
+ return img;
+ }
+}