|
@@ -1,15 +1,10 @@ |
1 |
1 |
|
package com.temp.client.foundation.widget.input.support; |
2 |
2 |
|
|
3 |
|
- |
import com.google.gwt.user.client.ui.Composite; |
4 |
|
- |
import com.google.gwt.user.client.ui.HTML; |
5 |
|
- |
import com.google.gwt.user.client.ui.HasName; |
6 |
|
- |
import com.google.gwt.user.client.ui.Widget; |
7 |
|
- |
import com.temp.shared.utils.HtmlUtils; |
8 |
|
- |
import com.temp.shared.utils.ObjectUtils; |
9 |
|
- |
import com.temp.shared.utils.StringUtils; |
|
3 |
+ |
import com.google.gwt.user.client.ui.*; |
|
4 |
+ |
import com.temp.shared.utils.*; |
10 |
5 |
|
|
11 |
6 |
|
public abstract class TextLabel extends Composite implements HasName { |
12 |
|
- |
protected final HTML htmlWidget = new HTML(HtmlUtils.NBSP); |
|
7 |
+ |
protected final HTML htmlWidget = new HTML( HtmlUtils.NBSP ); |
13 |
8 |
|
private String text = null; |
14 |
9 |
|
private String name; |
15 |
10 |
|
|
|
@@ -17,13 +12,13 @@ |
17 |
12 |
|
return text; |
18 |
13 |
|
} |
19 |
14 |
|
|
20 |
|
- |
public final void setText(String text) { |
21 |
|
- |
commonSetText(StringUtils.noEmpty(text)); |
|
15 |
+ |
public final void setText( String text ) { |
|
16 |
+ |
commonSetText( StringUtils.noEmpty( text ) ); |
22 |
17 |
|
} |
23 |
18 |
|
|
24 |
19 |
|
@Override |
25 |
|
- |
public void setName(String name) { |
26 |
|
- |
this.name = StringUtils.noEmpty(name); |
|
20 |
+ |
public void setName( String name ) { |
|
21 |
+ |
this.name = StringUtils.noEmpty( name ); |
27 |
22 |
|
} |
28 |
23 |
|
|
29 |
24 |
|
@Override |
|
@@ -33,47 +28,48 @@ |
33 |
28 |
|
|
34 |
29 |
|
@Override |
35 |
30 |
|
public String toString() { |
36 |
|
- |
return ObjectUtils.getSimpleClassName(this) + ": '" + getText() + "'"; |
|
31 |
+ |
return ObjectUtils.getSimpleClassName( this ) + ": '" + getText() + "'"; |
37 |
32 |
|
} |
38 |
33 |
|
|
39 |
|
- |
public final void setTextNoTrim(String text) { |
40 |
|
- |
text = StringUtils.deNull(text); |
41 |
|
- |
commonSetText("".equals(text) ? null : text); |
|
34 |
+ |
public final void setTextNoTrim( String text ) { |
|
35 |
+ |
text = StringUtils.deNull( text ); |
|
36 |
+ |
commonSetText( "".equals( text ) ? null : text ); |
42 |
37 |
|
} |
43 |
38 |
|
|
44 |
|
- |
public final TextLabel text(String text) { |
45 |
|
- |
setText(text); |
|
39 |
+ |
public final TextLabel text( String text ) { |
|
40 |
+ |
setText( text ); |
46 |
41 |
|
return this; |
47 |
42 |
|
} |
48 |
43 |
|
|
49 |
|
- |
public final TextLabel textNoTrim(String text) { |
50 |
|
- |
setTextNoTrim(text); |
|
44 |
+ |
public final TextLabel textNoTrim( String text ) { |
|
45 |
+ |
setTextNoTrim( text ); |
51 |
46 |
|
return this; |
52 |
47 |
|
} |
53 |
48 |
|
|
54 |
|
- |
public final TextLabel style(String className) { |
55 |
|
- |
className = StringUtils.noEmpty(className); |
56 |
|
- |
if (className != null) { |
57 |
|
- |
addStyleName(className); |
|
49 |
+ |
public final TextLabel style( String className ) { |
|
50 |
+ |
className = StringUtils.noEmpty( className ); |
|
51 |
+ |
if ( className != null ) { |
|
52 |
+ |
addStyleName( className ); |
58 |
53 |
|
} |
59 |
54 |
|
return this; |
60 |
55 |
|
} |
61 |
56 |
|
|
62 |
|
- |
protected final void commonSetText(String text) { |
|
57 |
+ |
protected final void commonSetText( String text ) { |
63 |
58 |
|
this.text = text; |
64 |
|
- |
String html = StringUtils.deNull((text == null) ? HtmlUtils.NBSP : StringUtils.noEmpty(normalizeHTML(text)), HtmlUtils.NBSP); |
65 |
|
- |
htmlWidget.setHTML(html); |
|
59 |
+ |
String html = StringUtils.deNull( (text == null) ? HtmlUtils.NBSP : StringUtils.noEmpty( normalizeHTML( text ) ), HtmlUtils.NBSP ); |
|
60 |
+ |
htmlWidget.setHTML( html ); |
66 |
61 |
|
} |
67 |
62 |
|
|
68 |
63 |
|
@Override |
69 |
|
- |
protected void initWidget(Widget widget) { |
70 |
|
- |
super.initWidget(widget); |
71 |
|
- |
setStyleName(ObjectUtils.getSimpleClassName(this)); |
|
64 |
+ |
protected void initWidget( Widget widget ) { |
|
65 |
+ |
super.initWidget( widget ); |
|
66 |
+ |
setStyleName( ObjectUtils.getSimpleClassName( this ) ); |
72 |
67 |
|
} |
73 |
68 |
|
|
74 |
69 |
|
/** |
75 |
70 |
|
* @param text will NOT be null or have any leading/trailing whitespace |
|
71 |
+ |
* |
76 |
72 |
|
* @return Html Safe Text |
77 |
73 |
|
*/ |
78 |
|
- |
protected abstract String normalizeHTML(String text); |
|
74 |
+ |
protected abstract String normalizeHTML( String text ); |
79 |
75 |
|
} |