Lior Vernia has uploaded a new change for review.

Change subject: webadmin: Added ShapedButton class
......................................................................

webadmin: Added ShapedButton class

It represents a custom-shaped button whose faces change according to
supplied image files.

Change-Id: I83eafafa7ca480b350d4b1b96aa560fd184acbad
Signed-off-by: Lior Vernia <[email protected]>
---
A 
frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/dialog/ShapedButton.java
1 file changed, 48 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/29/19429/1

diff --git 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/dialog/ShapedButton.java
 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/dialog/ShapedButton.java
new file mode 100644
index 0000000..817c9c4
--- /dev/null
+++ 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/dialog/ShapedButton.java
@@ -0,0 +1,48 @@
+package org.ovirt.engine.ui.common.widget.dialog;
+
+import com.google.gwt.resources.client.ImageResource;
+import com.google.gwt.user.client.ui.AbstractImagePrototype;
+import com.google.gwt.user.client.ui.CustomButton;
+
+/**
+ * A class to be used for buttons of a custom shape, as opposed to the usual, 
rectangular buttons (e.g.
+ * {@link SimpleDialogButton}) where only the text or image on the button's 
face may be customised. The shape
+ * customisation is achieved by passing proper images for each of the button's 
states (i.e. normal, pressed, hovered
+ * upon or disabled).
+ */
+public class ShapedButton extends CustomButton {
+
+    /**
+     * @param normal
+     *            an image that defines how the button normally looks, when 
it's neither pressed nor hovered upon.
+     * @param click
+     *            an image that defines how the button looks when it's pressed.
+     * @param hover
+     *            an image that defines how the button looks when it's hovered 
upon.
+     * @param disabled
+     *            an image that defines how the button looks when it's 
disabled.
+     */
+    public ShapedButton(ImageResource normal, ImageResource click, 
ImageResource hover, ImageResource disabled) {
+        
getUpFace().setHTML(AbstractImagePrototype.create(normal).getSafeHtml());
+        
getDownFace().setHTML(AbstractImagePrototype.create(click).getSafeHtml());
+        
getUpHoveringFace().setHTML(AbstractImagePrototype.create(hover).getSafeHtml());
+        
getUpDisabledFace().setHTML(AbstractImagePrototype.create(disabled).getSafeHtml());
+    }
+
+    @Override
+    protected void onClick() {
+        setDown(false);
+        super.onClick();
+    }
+
+    @Override
+    protected void onClickCancel() {
+        setDown(false);
+    }
+
+    @Override
+    protected void onClickStart() {
+        setDown(true);
+    }
+
+}


-- 
To view, visit http://gerrit.ovirt.org/19429
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I83eafafa7ca480b350d4b1b96aa560fd184acbad
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Lior Vernia <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to