|
@@ -1,8 +1,6 @@ |
1 |
1 |
|
// This Source Code is in the Public Domain per: http://unlicense.org |
2 |
2 |
|
package org.litesoft.GWT.client.widgets.datatables; |
3 |
3 |
|
|
4 |
|
- |
import java.util.*; |
5 |
|
- |
|
6 |
4 |
|
import org.litesoft.GWT.client.widgets.nonpublic.*; |
7 |
5 |
|
import org.litesoft.commonfoundation.html.*; |
8 |
6 |
|
|
|
@@ -13,15 +11,15 @@ |
13 |
11 |
|
import com.google.gwt.user.client.ui.HasVerticalAlignment.*; |
14 |
12 |
|
import com.google.gwt.user.client.ui.*; |
15 |
13 |
|
|
16 |
|
- |
class MockTable |
17 |
|
- |
{ |
|
14 |
+ |
import java.util.*; |
|
15 |
+ |
|
|
16 |
+ |
class MockTable { |
18 |
17 |
|
/** |
19 |
18 |
|
* This element is inserted as a child of the table's outer wrapper behind |
20 |
19 |
|
* the actual table elements. It reserves space for the header and at least |
21 |
20 |
|
* 1 row. |
22 |
21 |
|
*/ |
23 |
|
- |
public static <RowType> MockTable.CreateResult createFrom( PagingScrollTable<RowType> pTable, TableDefinitionPlus<RowType> pTableDefinition ) |
24 |
|
- |
{ |
|
22 |
+ |
public static <RowType> MockTable.CreateResult createFrom( PagingScrollTable<RowType> pTable, TableDefinitionPlus<RowType> pTableDefinition ) { |
25 |
23 |
|
// create a mock table so that we can measure its dimensions |
26 |
24 |
|
DivElement outer = Document.get().createDivElement(); |
27 |
25 |
|
DivElement headerWrapper = Document.get().createDivElement(); |
|
@@ -32,18 +30,14 @@ |
32 |
30 |
|
TableRowElement gridRow = Document.get().createTRElement(); // item 0 is the "ghost row" |
33 |
31 |
|
|
34 |
32 |
|
RowType rowValue = pTableDefinition.getPrototypeRowValue(); |
35 |
|
- |
if ( rowValue != null ) |
36 |
|
- |
{ |
|
33 |
+ |
if ( rowValue != null ) { |
37 |
34 |
|
renderPrototypeRow( pTableDefinition, rowValue, gridRow ); |
38 |
|
- |
} |
39 |
|
- |
else |
40 |
|
- |
{ |
|
35 |
+ |
} else { |
41 |
36 |
|
// render stub row |
42 |
37 |
|
int maxPaddingTop = 0; |
43 |
38 |
|
int maxPaddingBottom = 0; |
44 |
39 |
|
List<ColumnDefinition<RowType, ?>> colDefs = pTableDefinition.getVisibleColumnDefinitions(); |
45 |
|
- |
for ( ColumnDefinition<RowType, ?> colDef : colDefs ) |
46 |
|
- |
{ |
|
40 |
+ |
for ( ColumnDefinition<RowType, ?> colDef : colDefs ) { |
47 |
41 |
|
int paddingTop = colDef.getColumnProperty( PaddingProperty.TOP ).getValue(); |
48 |
42 |
|
int paddingBottom = colDef.getColumnProperty( PaddingProperty.BOTTOM ).getValue(); |
49 |
43 |
|
maxPaddingTop = Math.max( paddingTop, maxPaddingTop ); |
|
@@ -68,17 +62,14 @@ |
68 |
62 |
|
* Render full row w/ prototype values |
69 |
63 |
|
*/ |
70 |
64 |
|
@SuppressWarnings({"unchecked"}) |
71 |
|
- |
public static <RowType> void renderPrototypeRow( TableDefinition<RowType> pTableDefinition, RowType pValue, Element pTr ) |
72 |
|
- |
{ |
73 |
|
- |
for ( Node child; (child = pTr.getFirstChild()) != null; ) |
74 |
|
- |
{ |
|
65 |
+ |
public static <RowType> void renderPrototypeRow( TableDefinition<RowType> pTableDefinition, RowType pValue, Element pTr ) { |
|
66 |
+ |
for ( Node child; (child = pTr.getFirstChild()) != null; ) { |
75 |
67 |
|
pTr.removeChild( child ); |
76 |
68 |
|
} |
77 |
69 |
|
|
78 |
70 |
|
List<ColumnDefinition<RowType, ?>> colDefs = pTableDefinition.getVisibleColumnDefinitions(); |
79 |
71 |
|
PrototypeTableCellView<RowType> view = new PrototypeTableCellView<RowType>(); |
80 |
|
- |
for ( ColumnDefinition<RowType, ?> colDef : colDefs ) |
81 |
|
- |
{ |
|
72 |
+ |
for ( ColumnDefinition<RowType, ?> colDef : colDefs ) { |
82 |
73 |
|
TableCellElement td = Document.get().createTDElement(); |
83 |
74 |
|
view.setTd( td ); |
84 |
75 |
|
CellRenderer cellRenderer = colDef.getCellRenderer(); |
|
@@ -87,70 +78,58 @@ |
87 |
78 |
|
} |
88 |
79 |
|
} |
89 |
80 |
|
|
90 |
|
- |
private static class PrototypeTableCellView<RowType> extends AbstractCellView<RowType> |
91 |
|
- |
{ |
|
81 |
+ |
private static class PrototypeTableCellView<RowType> extends AbstractCellView<RowType> { |
92 |
82 |
|
private TableCellElement mTd; |
93 |
83 |
|
|
94 |
|
- |
public PrototypeTableCellView() |
95 |
|
- |
{ |
|
84 |
+ |
public PrototypeTableCellView() { |
96 |
85 |
|
super( null ); |
97 |
86 |
|
} |
98 |
87 |
|
|
99 |
|
- |
public void setTd( TableCellElement pTd ) |
100 |
|
- |
{ |
|
88 |
+ |
public void setTd( TableCellElement pTd ) { |
101 |
89 |
|
mTd = pTd; |
102 |
90 |
|
} |
103 |
91 |
|
|
104 |
92 |
|
@Override |
105 |
|
- |
public void setHTML( String pHtml ) |
106 |
|
- |
{ |
|
93 |
+ |
public void setHTML( String pHtml ) { |
107 |
94 |
|
mTd.setInnerHTML( pHtml ); |
108 |
95 |
|
} |
109 |
96 |
|
|
110 |
97 |
|
@Override |
111 |
|
- |
public void setHorizontalAlignment( HorizontalAlignmentConstant pAlign ) |
112 |
|
- |
{ |
|
98 |
+ |
public void setHorizontalAlignment( HorizontalAlignmentConstant pAlign ) { |
113 |
99 |
|
mTd.setAlign( pAlign.getTextAlignString() ); |
114 |
100 |
|
} |
115 |
101 |
|
|
116 |
102 |
|
@Override |
117 |
|
- |
public void setStyleAttribute( String pAttr, String pValue ) |
118 |
|
- |
{ |
|
103 |
+ |
public void setStyleAttribute( String pAttr, String pValue ) { |
119 |
104 |
|
mTd.getStyle().setProperty( pAttr, pValue ); |
120 |
105 |
|
} |
121 |
106 |
|
|
122 |
107 |
|
@Override |
123 |
|
- |
public void setStyleName( String pStylename ) |
124 |
|
- |
{ |
|
108 |
+ |
public void setStyleName( String pStylename ) { |
125 |
109 |
|
mTd.setPropertyString( "className", pStylename ); |
126 |
110 |
|
} |
127 |
111 |
|
|
128 |
112 |
|
@Override |
129 |
|
- |
public void setText( String pText ) |
130 |
|
- |
{ |
|
113 |
+ |
public void setText( String pText ) { |
131 |
114 |
|
mTd.setInnerText( pText ); |
132 |
115 |
|
} |
133 |
116 |
|
|
134 |
117 |
|
@Override |
135 |
|
- |
public void setVerticalAlignment( VerticalAlignmentConstant pAlign ) |
136 |
|
- |
{ |
|
118 |
+ |
public void setVerticalAlignment( VerticalAlignmentConstant pAlign ) { |
137 |
119 |
|
mTd.setVAlign( pAlign.getVerticalAlignString() ); |
138 |
120 |
|
} |
139 |
121 |
|
|
140 |
122 |
|
@Override |
141 |
|
- |
public void setWidget( Widget pWidget ) |
142 |
|
- |
{ |
|
123 |
+ |
public void setWidget( Widget pWidget ) { |
143 |
124 |
|
mTd.appendChild( pWidget.getElement() ); |
144 |
125 |
|
} |
145 |
126 |
|
} |
146 |
127 |
|
|
147 |
|
- |
public static class CreateResult |
148 |
|
- |
{ |
|
128 |
+ |
public static class CreateResult { |
149 |
129 |
|
public final Element mTable; |
150 |
130 |
|
public final TableRowElement mPrototypeRow; |
151 |
131 |
|
|
152 |
|
- |
public CreateResult( Element pTable, TableRowElement pPrototypeRow ) |
153 |
|
- |
{ |
|
132 |
+ |
public CreateResult( Element pTable, TableRowElement pPrototypeRow ) { |
154 |
133 |
|
mTable = pTable; |
155 |
134 |
|
mPrototypeRow = pPrototypeRow; |
156 |
135 |
|
} |