|
@@ -1,8 +1,7 @@ |
1 |
1 |
|
package com.temp.client.foundation.widget; |
2 |
2 |
|
|
3 |
|
- |
import com.google.gwt.event.dom.client.ClickHandler; |
4 |
|
- |
import com.google.gwt.user.client.ui.Image; |
5 |
|
- |
import com.google.gwt.user.client.ui.PushButton; |
|
3 |
+ |
import com.google.gwt.event.dom.client.*; |
|
4 |
+ |
import com.google.gwt.user.client.ui.*; |
6 |
5 |
|
|
7 |
6 |
|
public class NamedImageButton extends CompositeButton<NamedImageButton> { |
8 |
7 |
|
public static final String UP = "Up"; |
|
@@ -12,65 +11,64 @@ |
12 |
11 |
|
public NamedImageButton() { |
13 |
12 |
|
} |
14 |
13 |
|
|
15 |
|
- |
public NamedImageButton(String name) { |
|
14 |
+ |
public NamedImageButton( String name ) { |
16 |
15 |
|
this(); |
17 |
|
- |
setName(name); |
|
16 |
+ |
setName( name ); |
18 |
17 |
|
} |
19 |
18 |
|
|
20 |
|
- |
public NamedImageButton(String name, ClickHandler handler) { |
21 |
|
- |
this(name); |
22 |
|
- |
add(handler); |
|
19 |
+ |
public NamedImageButton( String name, ClickHandler handler ) { |
|
20 |
+ |
this( name ); |
|
21 |
+ |
add( handler ); |
23 |
22 |
|
} |
24 |
23 |
|
|
25 |
24 |
|
@Override |
26 |
|
- |
public void setName(String name) { |
27 |
|
- |
super.setName(name); |
28 |
|
- |
setImage(UP, proxyTo.getUpFace()); |
29 |
|
- |
setImage(HOVER, proxyTo.getUpHoveringFace()); |
30 |
|
- |
setImage(PRESSED, proxyTo.getDownFace(), proxyTo.getDownHoveringFace(), proxyTo.getUpDisabledFace(), proxyTo.getDownDisabledFace()); |
|
25 |
+ |
public void setName( String name ) { |
|
26 |
+ |
super.setName( name ); |
|
27 |
+ |
setImage( UP, proxyTo.getUpFace() ); |
|
28 |
+ |
setImage( HOVER, proxyTo.getUpHoveringFace() ); |
|
29 |
+ |
setImage( PRESSED, proxyTo.getDownFace(), proxyTo.getDownHoveringFace(), proxyTo.getUpDisabledFace(), proxyTo.getDownDisabledFace() ); |
31 |
30 |
|
} |
32 |
31 |
|
|
33 |
|
- |
public NamedImageButton add(ClickHandler handler) { |
34 |
|
- |
if (handler != null) { |
35 |
|
- |
proxyTo.addClickHandler(handler); |
|
32 |
+ |
public NamedImageButton add( ClickHandler handler ) { |
|
33 |
+ |
if ( handler != null ) { |
|
34 |
+ |
proxyTo.addClickHandler( handler ); |
36 |
35 |
|
} |
37 |
36 |
|
return this; |
38 |
37 |
|
} |
39 |
38 |
|
|
40 |
|
- |
public NamedImageButton style(String className) { |
41 |
|
- |
addStyleName(className); |
|
39 |
+ |
public NamedImageButton style( String className ) { |
|
40 |
+ |
addStyleName( className ); |
42 |
41 |
|
return this; |
43 |
42 |
|
} |
44 |
43 |
|
|
45 |
|
- |
private void setImage(String imageFaceName, PushButton.Face... faces) { |
46 |
|
- |
String url = getImageUrl(getName(), imageFaceName); |
47 |
|
- |
for (PushButton.Face face : faces) { |
48 |
|
- |
face.setImage(new Image(url)); |
|
44 |
+ |
private void setImage( String imageFaceName, PushButton.Face... faces ) { |
|
45 |
+ |
String url = getImageUrl( getName(), imageFaceName ); |
|
46 |
+ |
for ( PushButton.Face face : faces ) { |
|
47 |
+ |
face.setImage( new Image( url ) ); |
49 |
48 |
|
} |
50 |
49 |
|
} |
51 |
50 |
|
|
52 |
|
- |
private static String getImageUrl(String name, String imageFaceName) { |
|
51 |
+ |
private static String getImageUrl( String name, String imageFaceName ) { |
53 |
52 |
|
return "images/buttons/" + name + "/" + imageFaceName + ".png"; |
54 |
53 |
|
} |
55 |
54 |
|
|
56 |
|
- |
public static String createSafeHtmlElement(String name, String safeHtmlAltToolTip) { |
57 |
|
- |
return createSafeHtmlElementWithIdAndStyle(null, name, UP, safeHtmlAltToolTip, null); |
|
55 |
+ |
public static String createSafeHtmlElement( String name, String safeHtmlAltToolTip ) { |
|
56 |
+ |
return createSafeHtmlElementWithIdAndStyle( null, name, UP, safeHtmlAltToolTip, null ); |
58 |
57 |
|
} |
59 |
58 |
|
|
60 |
|
- |
public static String createSafeHtmlElementWithId(String id, String name, String safeHtmlAltToolTip) { |
61 |
|
- |
return createSafeHtmlElementWithIdAndStyle(id, name, UP, safeHtmlAltToolTip, null); |
|
59 |
+ |
public static String createSafeHtmlElementWithId( String id, String name, String safeHtmlAltToolTip ) { |
|
60 |
+ |
return createSafeHtmlElementWithIdAndStyle( id, name, UP, safeHtmlAltToolTip, null ); |
62 |
61 |
|
} |
63 |
62 |
|
|
64 |
|
- |
public static String createSafeHtmlElement(String name, String safeHtmlAltToolTip, String styleName) { |
65 |
|
- |
return createSafeHtmlElementWithIdAndStyle(null, name, UP, safeHtmlAltToolTip, styleName); |
|
63 |
+ |
public static String createSafeHtmlElement( String name, String safeHtmlAltToolTip, String styleName ) { |
|
64 |
+ |
return createSafeHtmlElementWithIdAndStyle( null, name, UP, safeHtmlAltToolTip, styleName ); |
66 |
65 |
|
} |
67 |
66 |
|
|
68 |
|
- |
public static String createSafeHtmlElementWithId(String id, String name, String safeHtmlAltToolTip, String styleName) { |
69 |
|
- |
return createSafeHtmlElementWithIdAndStyle(id, name, UP, safeHtmlAltToolTip, styleName); |
|
67 |
+ |
public static String createSafeHtmlElementWithId( String id, String name, String safeHtmlAltToolTip, String styleName ) { |
|
68 |
+ |
return createSafeHtmlElementWithIdAndStyle( id, name, UP, safeHtmlAltToolTip, styleName ); |
70 |
69 |
|
} |
71 |
70 |
|
|
72 |
|
- |
private static String createSafeHtmlElementWithIdAndStyle(String id, String name, String imageFaceName, String safeHtmlAltToolTip, String styleName) { |
73 |
|
- |
return createSafeHtmlElementWithImageUrl(id, safeHtmlAltToolTip, styleName, getImageUrl(name, imageFaceName)); |
|
71 |
+ |
private static String createSafeHtmlElementWithIdAndStyle( String id, String name, String imageFaceName, String safeHtmlAltToolTip, String styleName ) { |
|
72 |
+ |
return createSafeHtmlElementWithImageUrl( id, safeHtmlAltToolTip, styleName, getImageUrl( name, imageFaceName ) ); |
74 |
73 |
|
} |
75 |
|
- |
|
76 |
74 |
|
} |