Subversion Repository Public Repository

litesoft

Diff Revisions 947 vs 948 for /trunk/Java/GWT/Client/src/org/litesoft/GWT/client/widgets/datatables/TableCellRenderer.java

Diff revisions: vs.
  @@ -16,53 +16,43 @@
16 16 * <p/>
17 17 * see #setFormatter(StringFormatter)
18 18 */
19 - public class TableCellRenderer<T> implements CellRenderer<T, Object>
20 - {
21 - public enum EscapeCtrl
22 - {
19 + public class TableCellRenderer<T> implements CellRenderer<T, Object> {
20 + public enum EscapeCtrl {
23 21 NoWrap( HTMLize.INSTANCE_NO_WRAP ), //
24 22 NoEscape( HTMLize.INSTANCE_NO_ESCAPE ), //
25 23 Regular( HTMLize.INSTANCE );
26 24
27 25 private HTMLize mHTMLizer;
28 26
29 - EscapeCtrl( HTMLize pHTMLizer )
30 - {
27 + EscapeCtrl( HTMLize pHTMLizer ) {
31 28 mHTMLizer = pHTMLizer;
32 29 }
33 30
34 - public String process( String pText )
35 - {
31 + public String process( String pText ) {
36 32 return mHTMLizer.process( pText );
37 33 }
38 34 }
39 35
40 - public static class Builder
41 - {
36 + public static class Builder {
42 37 private String mElementStyleName;
43 38 private StringFormatter mFormatter;
44 39 private EscapeCtrl mEscapeCtrl = EscapeCtrl.NoWrap;
45 40
46 - public String getElementBaseStyleName()
47 - {
41 + public String getElementBaseStyleName() {
48 42 return (mElementStyleName != null) ? mElementStyleName : "";
49 43 }
50 44
51 - public Builder setElementBaseStyleName( String pStyleName )
52 - {
45 + public Builder setElementBaseStyleName( String pStyleName ) {
53 46 mElementStyleName = pStyleName;
54 47 return this;
55 48 }
56 49
57 - public StringFormatter getFormatter()
58 - {
50 + public StringFormatter getFormatter() {
59 51 return (mFormatter != null) ? mFormatter : StringFormatterDefault.INSTANCE;
60 52 }
61 53
62 - public Builder setFormatter( StringFormatter pFormatter )
63 - {
64 - if ( pFormatter == null )
65 - {
54 + public Builder setFormatter( StringFormatter pFormatter ) {
55 + if ( pFormatter == null ) {
66 56 throw new NullPointerException();
67 57 }
68 58
  @@ -70,8 +60,7 @@
70 60 return this;
71 61 }
72 62
73 - public EscapeCtrl getEscapeCtrl()
74 - {
63 + public EscapeCtrl getEscapeCtrl() {
75 64 return (mEscapeCtrl != null) ? mEscapeCtrl : EscapeCtrl.NoWrap;
76 65 }
77 66
  @@ -86,8 +75,7 @@
86 75 * <p/>
87 76 * see #escapeMarkup(String)
88 77 */
89 - public Builder setEscapeCtrl( EscapeCtrl pEscapeCtrl )
90 - {
78 + public Builder setEscapeCtrl( EscapeCtrl pEscapeCtrl ) {
91 79 mEscapeCtrl = pEscapeCtrl;
92 80 return this;
93 81 }
  @@ -100,10 +88,8 @@
100 88 private StringFormatter mFormatter;
101 89 private EscapeCtrl mEscapeCtrl;
102 90
103 - public TableCellRenderer( Builder pBuilder )
104 - {
105 - if ( pBuilder == null )
106 - {
91 + public TableCellRenderer( Builder pBuilder ) {
92 + if ( pBuilder == null ) {
107 93 pBuilder = NO_WRAP;
108 94 }
109 95 mElementStyleName = pBuilder.getElementBaseStyleName();
  @@ -111,22 +97,19 @@
111 97 mEscapeCtrl = pBuilder.getEscapeCtrl();
112 98 }
113 99
114 - public TableCellRenderer()
115 - {
100 + public TableCellRenderer() {
116 101 this( null );
117 102 }
118 103
119 104 @Override
120 - public void renderRowValue( T pRowValue, ColumnDefinition<T, Object> pColumnDef, AbstractCellView<T> pView )
121 - {
105 + public void renderRowValue( T pRowValue, ColumnDefinition<T, Object> pColumnDef, AbstractCellView<T> pView ) {
122 106 Object cellValue = pColumnDef.getCellValue( pRowValue );
123 107 prepareElement( pRowValue, pColumnDef, pView, cellValue );
124 108 renderContent( pRowValue, pColumnDef, pView, cellValue );
125 109 }
126 110
127 111 @SuppressWarnings({"UnusedDeclaration"})
128 - public void prepareElement( T rowValue, ColumnDefinition<T, Object> pColumnDef, AbstractCellView<T> pView, Object pCellValue )
129 - {
112 + public void prepareElement( T rowValue, ColumnDefinition<T, Object> pColumnDef, AbstractCellView<T> pView, Object pCellValue ) {
130 113 // set cell class name(s)
131 114 StringBuilder styleName = new StringBuilder();
132 115 buildStyleName( styleName, pCellValue );
  @@ -145,21 +128,17 @@
145 128 }
146 129
147 130 @SuppressWarnings({"UnusedDeclaration"})
148 - protected StringBuilder buildStyleName( StringBuilder result, Object pCellValue )
149 - {
131 + protected StringBuilder buildStyleName( StringBuilder result, Object pCellValue ) {
150 132 result.append( mElementStyleName );
151 133 return result;
152 134 }
153 135
154 - protected StringBuilder appendDependantStyle( StringBuilder styleIn, String dependentStyleName )
155 - {
136 + protected StringBuilder appendDependantStyle( StringBuilder styleIn, String dependentStyleName ) {
156 137 return appendDependantStyle( styleIn, dependentStyleName, true );
157 138 }
158 139
159 - protected StringBuilder appendDependantStyle( StringBuilder styleIn, String dependentStyleName, boolean add )
160 - {
161 - if ( add )
162 - {
140 + protected StringBuilder appendDependantStyle( StringBuilder styleIn, String dependentStyleName, boolean add ) {
141 + if ( add ) {
163 142 styleIn.append( ' ' );
164 143 styleIn.append( mElementStyleName );
165 144 styleIn.append( '-' );
  @@ -168,23 +147,18 @@
168 147 return styleIn;
169 148 }
170 149
171 - public void renderContent( T pRowValue, ColumnDefinition<T, Object> pColumnDef, AbstractCellView<T> pView, Object pCellValue )
172 - {
173 - if ( pCellValue instanceof Widget )
174 - {
150 + public void renderContent( T pRowValue, ColumnDefinition<T, Object> pColumnDef, AbstractCellView<T> pView, Object pCellValue ) {
151 + if ( pCellValue instanceof Widget ) {
175 152 Widget widget = (Widget) pCellValue;
176 153 Element element = widget.getElement();
177 154 HorizontalAlignmentConstant align = pColumnDef.getColumnProperty( HorizontalAlignmentProperty.TYPE ).getValue();
178 155 pView.setHorizontalAlignment( align );
179 - if ( element.getTagName().equalsIgnoreCase( "table" ) )
180 - {
156 + if ( element.getTagName().equalsIgnoreCase( "table" ) ) {
181 157 DOM.setElementAttribute( element, "cellpadding", "0" );
182 158 DOM.setElementAttribute( element, "cellspacing", "0" );
183 159 }
184 160 pView.setWidget( widget );
185 - }
186 - else
187 - {
161 + } else {
188 162 String valueString = getValueString( pCellValue );
189 163 String safeValueString = mEscapeCtrl.process( valueString );
190 164 String nonEmptyValueString = ("".equals( safeValueString )) ? HTMLConstants.NBSP : safeValueString;
  @@ -198,8 +172,7 @@
198 172 *
199 173 * @return an HTML snippet representing <code>modelElement</code>
200 174 */
201 - protected String getValueString( Object modelElement )
202 - {
175 + protected String getValueString( Object modelElement ) {
203 176 return mFormatter.getString( modelElement );
204 177 }
205 178
  @@ -214,8 +187,7 @@
214 187 *
215 188 * @return an HTML snippet describing the entire content of the cell
216 189 */
217 - protected String getCellString( T pRowValue, String pValueString, Object pCellValue )
218 - {
190 + protected String getCellString( T pRowValue, String pValueString, Object pCellValue ) {
219 191 return pValueString;
220 192 }
221 193 }