summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteffen Kriese2010-08-24 07:41:57 (EDT)
committerSteffen Kriese2010-08-24 07:41:57 (EDT)
commit8f20dfc900781723178a8986fb5ff37c8975c0ed (patch)
treecf60efea4d5daf13d7f92ebe0624329676be9060
parente202a245c170cee8317a209800e2e88db4daf500 (diff)
downloadorg.eclipse.riena-8f20dfc900781723178a8986fb5ff37c8975c0ed.zip
org.eclipse.riena-8f20dfc900781723178a8986fb5ff37c8975c0ed.tar.gz
org.eclipse.riena-8f20dfc900781723178a8986fb5ff37c8975c0ed.tar.bz2
Extended the GCFAcade to single source the StatusMeterRidget
-rw-r--r--org.eclipse.riena.ui.swt.rcp/src/org/eclipse/riena/ui/swt/facades/GCFacadeRCP.java12
-rw-r--r--org.eclipse.riena.ui.swt/src/org/eclipse/riena/ui/swt/StatusMeter.java8
-rw-r--r--org.eclipse.riena.ui.swt/src/org/eclipse/riena/ui/swt/StatusMeterWidget.java3
-rw-r--r--org.eclipse.riena.ui.swt/src/org/eclipse/riena/ui/swt/facades/GCFacade.java28
4 files changed, 48 insertions, 3 deletions
diff --git a/org.eclipse.riena.ui.swt.rcp/src/org/eclipse/riena/ui/swt/facades/GCFacadeRCP.java b/org.eclipse.riena.ui.swt.rcp/src/org/eclipse/riena/ui/swt/facades/GCFacadeRCP.java
index 18f780e..c811a4b 100644
--- a/org.eclipse.riena.ui.swt.rcp/src/org/eclipse/riena/ui/swt/facades/GCFacadeRCP.java
+++ b/org.eclipse.riena.ui.swt.rcp/src/org/eclipse/riena/ui/swt/facades/GCFacadeRCP.java
@@ -12,6 +12,8 @@
package org.eclipse.riena.ui.swt.facades;
import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Display;
/**
* Implements {@link GCFacade} for RCP.
@@ -49,4 +51,14 @@ public class GCFacadeRCP extends GCFacade {
gc.setLineDash(dashes);
}
+ @Override
+ public GC createGCFromImage(final Image img) {
+ return new GC(img);
+ }
+
+ @Override
+ public Image createImage(final Display display, final int width, final int height) {
+ return new Image(display, width, height);
+ }
+
}
diff --git a/org.eclipse.riena.ui.swt/src/org/eclipse/riena/ui/swt/StatusMeter.java b/org.eclipse.riena.ui.swt/src/org/eclipse/riena/ui/swt/StatusMeter.java
index e56b17c..cc1d700 100644
--- a/org.eclipse.riena.ui.swt/src/org/eclipse/riena/ui/swt/StatusMeter.java
+++ b/org.eclipse.riena.ui.swt/src/org/eclipse/riena/ui/swt/StatusMeter.java
@@ -16,6 +16,7 @@ import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.ImageData;
import org.eclipse.swt.widgets.Display;
+import org.eclipse.riena.ui.swt.facades.GCFacade;
import org.eclipse.riena.ui.swt.lnf.LnfKeyConstants;
import org.eclipse.riena.ui.swt.lnf.LnfManager;
import org.eclipse.riena.ui.swt.lnf.rienadefault.RienaDefaultLnf;
@@ -175,9 +176,12 @@ public class StatusMeter {
// TODO sma@2010-08-17 Is this the Riena way?
final Display display = Display.getCurrent();
+ final Image image = GCFacade.getDefault().createImage(display, width, height);
- final Image image = new Image(display, width, height);
- final GC gc = new GC(image);
+ //final Image image = new Image(display, width, height);
+ //final GC gc = new GC(image);
+
+ final GC gc = GCFacade.getDefault().createGCFromImage(image);
final int start = margin + indent + BORDER_WIDTH;
final int end = width - (margin * 2) - BORDER_WIDTH - 1;
diff --git a/org.eclipse.riena.ui.swt/src/org/eclipse/riena/ui/swt/StatusMeterWidget.java b/org.eclipse.riena.ui.swt/src/org/eclipse/riena/ui/swt/StatusMeterWidget.java
index a41b294..9f32245 100644
--- a/org.eclipse.riena.ui.swt/src/org/eclipse/riena/ui/swt/StatusMeterWidget.java
+++ b/org.eclipse.riena.ui.swt/src/org/eclipse/riena/ui/swt/StatusMeterWidget.java
@@ -12,6 +12,7 @@ import org.eclipse.swt.events.PaintEvent;
import org.eclipse.swt.events.PaintListener;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.riena.ui.swt.StatusMeter.StatusMeterBuilder;
@@ -22,7 +23,7 @@ import org.eclipse.riena.ui.swt.StatusMeter.StatusMeterBuilder;
* @see StatusMeter
* @since 2.1
*/
-public final class StatusMeterWidget extends Composite {
+public final class StatusMeterWidget extends Canvas {
private int value = 0;
private int maximum = 100;
private int minimum = 0;
diff --git a/org.eclipse.riena.ui.swt/src/org/eclipse/riena/ui/swt/facades/GCFacade.java b/org.eclipse.riena.ui.swt/src/org/eclipse/riena/ui/swt/facades/GCFacade.java
index 96db31e..1f49d53 100644
--- a/org.eclipse.riena.ui.swt/src/org/eclipse/riena/ui/swt/facades/GCFacade.java
+++ b/org.eclipse.riena.ui.swt/src/org/eclipse/riena/ui/swt/facades/GCFacade.java
@@ -11,6 +11,8 @@
package org.eclipse.riena.ui.swt.facades;
import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Display;
/**
* Facade for the {@link GC} class.
@@ -29,6 +31,32 @@ public abstract class GCFacade {
}
/**
+ * Creates an graphics context from a given image.
+ * <p>
+ *
+ * The RAP implementation creates a graphics context by leveraging
+ * Display.getCurrent().
+ *
+ * @param img
+ * @return
+ */
+ public abstract GC createGCFromImage(Image img);
+
+ /**
+ * Creates an image width a given width and heigt.
+ * <p>
+ *
+ * The RAP implementation doesn't work properly and is only used to get rid
+ * of the compile errors.
+ *
+ * @param display
+ * @param width
+ * @param height
+ * @return
+ */
+ public abstract Image createImage(Display display, int width, int height);
+
+ /**
* @deprecated - RAP's GC now supports this directly TODO [ev] remove
*/
@Deprecated