Author: scabanovich
Date: 2008-05-30 11:50:36 -0400 (Fri, 30 May 2008)
New Revision: 8486
Added:
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/print/
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/print/PrintIconHelper.java
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/figures/ExceptionFigure.java
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/figures/PageFigure.java
Log:
JBIDE-1189
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/figures/ExceptionFigure.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/figures/ExceptionFigure.java 2008-05-30
15:45:23 UTC (rev 8485)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/figures/ExceptionFigure.java 2008-05-30
15:50:36 UTC (rev 8486)
@@ -25,6 +25,7 @@
import org.jboss.tools.seam.ui.pages.editor.ecore.pages.PgException;
import org.jboss.tools.seam.ui.pages.editor.edit.ExceptionEditPart;
import org.jboss.tools.seam.ui.pages.editor.figures.xpl.FixedConnectionAnchor;
+import org.jboss.tools.seam.ui.pages.editor.print.PrintIconHelper;
public class ExceptionFigure extends NodeFigure implements HandleBounds {
private static final Dimension SIZE = new Dimension(56, 100);
@@ -44,10 +45,9 @@
}
public void setIcon(Image i) {
- //icon = PrintIconHelper.getPrintImage(i);
+ icon = PrintIconHelper.getPrintImage(i);
}
-
public void init(int number) {
FixedConnectionAnchor c;
if (number == 0)
@@ -86,6 +86,10 @@
public ExceptionFigure(PgException group) {
this.exc = group;
+ if (group != null) {
+ setIcon(group.getImage());
+ }
+
setOpaque(false);
setLayoutManager(new XYLayout());
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/figures/PageFigure.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/figures/PageFigure.java 2008-05-30
15:45:23 UTC (rev 8485)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/figures/PageFigure.java 2008-05-30
15:50:36 UTC (rev 8486)
@@ -22,6 +22,7 @@
import org.jboss.tools.seam.ui.pages.editor.ecore.pages.Page;
import org.jboss.tools.seam.ui.pages.editor.edit.PageEditPart;
import org.jboss.tools.seam.ui.pages.editor.figures.xpl.FixedConnectionAnchor;
+import org.jboss.tools.seam.ui.pages.editor.print.PrintIconHelper;
public class PageFigure extends NodeFigure implements HandleBounds,
FigureListener {
@@ -70,7 +71,7 @@
}
public void setIcon(Image i) {
- //icon = PrintIconHelper.getPrintImage(i);
+ icon = PrintIconHelper.getPrintImage(i);
}
public void addNotify() {
Added:
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/print/PrintIconHelper.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/print/PrintIconHelper.java
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/print/PrintIconHelper.java 2008-05-30
15:50:36 UTC (rev 8486)
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and 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
+ *
+ * Contributors:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.seam.ui.pages.editor.print;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.draw2d.ColorConstants;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.ImageData;
+
+public class PrintIconHelper {
+ private static Map<Image,Image> iconCashe = new HashMap<Image,Image>();
+
+ public static Image getPrintImage(Image image, Color bgColor) {
+ Image newImage = (Image)iconCashe.get(image);
+ if (newImage == null) {
+ ImageData imageData = image.getImageData();
+ ImageData imgData = (ImageData)imageData.clone();
+ ImageData mask = imgData.getTransparencyMask();
+ int bgPixelValue = imgData.palette.getPixel(bgColor.getRGB());
+
+ for (int x = 0; x < mask.width; x++) {
+ for (int y = 0; y < mask.height; y++) {
+ int pixelValue = mask.getPixel(x, y);
+ if (pixelValue == 0) {
+ imgData.setPixel(x, y, bgPixelValue);
+ }
+ }
+ }
+ imgData.maskData = null;
+
+ newImage = new Image(null, imgData);
+ iconCashe.put(image, newImage);
+ }
+
+ return newImage;
+ }
+
+ public static Image getPrintImage(Image image) {
+ return getPrintImage(image, ColorConstants.white);
+ }
+}