Author: scabanovich
Date: 2007-09-17 08:43:03 -0400 (Mon, 17 Sep 2007)
New Revision: 3649
Added:
trunk/vpe/plugins/org.jboss.tools.vpe.ui.palette/src/org/jboss/tools/vpe/ui/palette/model/LargeImageDescriptor.java
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe.ui.palette/src/org/jboss/tools/vpe/ui/palette/model/PaletteItem.java
Log:
JBIDE-571
Added:
trunk/vpe/plugins/org.jboss.tools.vpe.ui.palette/src/org/jboss/tools/vpe/ui/palette/model/LargeImageDescriptor.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe.ui.palette/src/org/jboss/tools/vpe/ui/palette/model/LargeImageDescriptor.java
(rev 0)
+++
trunk/vpe/plugins/org.jboss.tools.vpe.ui.palette/src/org/jboss/tools/vpe/ui/palette/model/LargeImageDescriptor.java 2007-09-17
12:43:03 UTC (rev 3649)
@@ -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;
+ }
+}
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe.ui.palette/src/org/jboss/tools/vpe/ui/palette/model/PaletteItem.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe.ui.palette/src/org/jboss/tools/vpe/ui/palette/model/PaletteItem.java 2007-09-17
12:42:24 UTC (rev 3648)
+++
trunk/vpe/plugins/org.jboss.tools.vpe.ui.palette/src/org/jboss/tools/vpe/ui/palette/model/PaletteItem.java 2007-09-17
12:43:03 UTC (rev 3649)
@@ -37,7 +37,7 @@
setLabel("" + xobject.getModelEntity().getRenderer().getTitle(xobject));
//$NON-NLS-1$
XModelObjectImageDescriptor icon = new XModelObjectImageDescriptor(xobject);
setSmallIcon(icon);
- setLargeIcon(icon);
+ setLargeIcon(new LargeImageDescriptor(xobject));
String description = xobject.getAttributeValue("description"); //$NON-NLS-1$
///XModelObjectLoaderUtil.loadFromXMLAttribute(xobject.getAttributeValue("description"));
this.description = (description != null && description.trim().length() > 0)
? description : null;