Subversion Repository Public Repository

litesoft

Diff Revisions 631 vs 632 for /trunk/GWT_Sandbox/FormEngine/src/com/temp/client/foundation/widget/CompositeButton.java

Diff revisions: vs.
  @@ -1,12 +1,12 @@
1 1 package com.temp.client.foundation.widget;
2 2
3 - import com.temp.shared.utils.Assert;
4 - import com.temp.shared.utils.StringUtils;
3 + import com.google.gwt.event.dom.client.*;
4 + import com.temp.shared.utils.*;
5 5
6 6 import com.google.gwt.dom.client.Style.Cursor;
7 7 import com.google.gwt.user.client.ui.PushButton;
8 8
9 - public abstract class CompositeButton extends PushButton implements HasIdOverride {
9 + public abstract class CompositeButton<C extends CompositeButton> extends PushButton implements HasIdOverride {
10 10 protected final PushButton proxyTo;
11 11 private String name;
12 12 private String idOverride;
  @@ -15,6 +15,11 @@
15 15 this.proxyTo = this;
16 16 }
17 17
18 + public CompositeButton(String initialText) {
19 + super( initialText );
20 + this.proxyTo = this;
21 + }
22 +
18 23 @Override
19 24 public String getName() {
20 25 return name;
  @@ -35,7 +40,23 @@
35 40 this.idOverride = StringUtils.noEmpty(idOverride);
36 41 }
37 42
38 - protected static String createSafeHtmlElementWithImageUrl(String id, String name, String safeHtmlAltToolTip, String styleName, String imageUrl) {
43 + public C name(String name) {
44 + setName(name);
45 + return inheritanceLeaf();
46 + }
47 +
48 + public C add(ClickHandler handler) {
49 + if (handler != null) {
50 + proxyTo.addClickHandler(handler);
51 + }
52 + return inheritanceLeaf();
53 + }
54 +
55 + protected final C inheritanceLeaf() {
56 + return ObjectUtils.cast( this );
57 + }
58 +
59 + protected static String createSafeHtmlElementWithImageUrl( String id, String safeHtmlAltToolTip, String styleName, String imageUrl ) {
39 60 StringBuilder sb = new StringBuilder().append("<img");
40 61 addAttribute(sb, "id", id);
41 62 addAttribute(sb, "src", imageUrl);