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