|
@@ -1,14 +1,9 @@ |
1 |
1 |
|
// This Source Code is in the Public Domain per: http://unlicense.org |
2 |
2 |
|
package org.litesoft.GWT.server; |
3 |
3 |
|
|
4 |
|
- |
import java.io.*; |
5 |
|
- |
|
6 |
|
- |
import org.litesoft.commonfoundation.typeutils.*; |
7 |
|
- |
|
8 |
|
- |
import java.util.*; |
9 |
|
- |
|
10 |
4 |
|
import org.litesoft.GWT.client.widgets.datatables.*; |
11 |
5 |
|
import org.litesoft.commonfoundation.base.*; |
|
6 |
+ |
import org.litesoft.commonfoundation.typeutils.*; |
12 |
7 |
|
import org.litesoft.commonfoundation.typeutils.Objects; |
13 |
8 |
|
import org.litesoft.orsup.base.*; |
14 |
9 |
|
import org.litesoft.orsup.otherattributeaccessors.*; |
|
@@ -17,56 +12,50 @@ |
17 |
12 |
|
import com.google.gwt.gen2.table.client.property.*; |
18 |
13 |
|
import com.google.gwt.user.client.ui.*; |
19 |
14 |
|
|
20 |
|
- |
public class ReportTableDefinition<RowType extends PersistentObject> extends DefaultTableDefinition<RowType> |
21 |
|
- |
{ |
|
15 |
+ |
import java.io.*; |
|
16 |
+ |
import java.util.*; |
|
17 |
+ |
|
|
18 |
+ |
public class ReportTableDefinition<RowType extends PersistentObject> extends DefaultTableDefinition<RowType> { |
22 |
19 |
|
protected Finder mFinder = DataStoreLocator.get().getUnfilteredFinder(); |
23 |
20 |
|
protected MetaDataForPO<RowType> mPOMD; |
24 |
21 |
|
|
25 |
|
- |
public ReportTableDefinition( MetaDataForPO<RowType> pPOMD ) |
26 |
|
- |
{ |
|
22 |
+ |
public ReportTableDefinition( MetaDataForPO<RowType> pPOMD ) { |
27 |
23 |
|
Objects.assertNotNull( "PO MetaData", mPOMD = pPOMD ); |
28 |
24 |
|
} |
29 |
25 |
|
|
30 |
26 |
|
@SuppressWarnings({"UnusedDeclaration"}) |
31 |
27 |
|
public void addHeaders( Writer pWriter ) |
32 |
|
- |
throws IOException |
33 |
|
- |
{ |
|
28 |
+ |
throws IOException { |
34 |
29 |
|
} |
35 |
30 |
|
|
36 |
31 |
|
@SuppressWarnings({"UnusedDeclaration"}) |
37 |
32 |
|
public void addInitialBodyRows( Writer pWriter ) |
38 |
|
- |
throws IOException |
39 |
|
- |
{ |
|
33 |
+ |
throws IOException { |
40 |
34 |
|
} |
41 |
35 |
|
|
42 |
36 |
|
@SuppressWarnings({"UnusedDeclaration"}) |
43 |
37 |
|
public void addFinalBodyRows( Writer pWriter ) |
44 |
|
- |
throws IOException |
45 |
|
- |
{ |
|
38 |
+ |
throws IOException { |
46 |
39 |
|
} |
47 |
40 |
|
|
48 |
41 |
|
@SuppressWarnings({"UnusedDeclaration"}) |
49 |
42 |
|
public void addFooters( Writer pWriter ) |
50 |
|
- |
throws IOException |
51 |
|
- |
{ |
|
43 |
+ |
throws IOException { |
52 |
44 |
|
} |
53 |
45 |
|
|
54 |
46 |
|
@SuppressWarnings({"UnusedDeclaration"}) |
55 |
47 |
|
public void addStandardHeaders( Writer pWriter, String... pTitleLines ) |
56 |
|
- |
throws IOException |
57 |
|
- |
{ |
|
48 |
+ |
throws IOException { |
58 |
49 |
|
List<TableColumnDefinition> zDefinitions = getVisibleTableColumnDefinitions(); |
59 |
|
- |
if ( Lists.isNullOrEmpty( zDefinitions ) ) |
60 |
|
- |
{ |
|
50 |
+ |
if ( Lists.isNullOrEmpty( zDefinitions ) ) { |
61 |
51 |
|
return; |
62 |
52 |
|
} |
63 |
|
- |
if ( Objects.isNotNullOrEmpty( pTitleLines ) ) |
64 |
|
- |
{ |
|
53 |
+ |
if ( Objects.isNotNullOrEmpty( pTitleLines ) ) { |
65 |
54 |
|
pWriter.append( " <tr>\n" ); |
66 |
|
- |
pWriter.append( " <th align=\"center\" colspan=\"" ).append( String.valueOf( zDefinitions.size() ) ).append( "\" class=\"table_head\">" ); |
|
55 |
+ |
pWriter.append( " <th align=\"center\" colspan=\"" ).append( String.valueOf( zDefinitions.size() ) ) |
|
56 |
+ |
.append( "\" class=\"table_head\">" ); |
67 |
57 |
|
pWriter.append( pTitleLines[0] ); |
68 |
|
- |
for ( int i = 1; i < pTitleLines.length; i++ ) |
69 |
|
- |
{ |
|
58 |
+ |
for ( int i = 1; i < pTitleLines.length; i++ ) { |
70 |
59 |
|
pWriter.append( "<br>" ).append( pTitleLines[i] ); |
71 |
60 |
|
} |
72 |
61 |
|
pWriter.append( "</th>\n" ); |
|
@@ -74,8 +63,7 @@ |
74 |
63 |
|
} |
75 |
64 |
|
|
76 |
65 |
|
pWriter.append( " <tr>\n" ); |
77 |
|
- |
for ( TableColumnDefinition zDefinition : zDefinitions ) |
78 |
|
- |
{ |
|
66 |
+ |
for ( TableColumnDefinition zDefinition : zDefinitions ) { |
79 |
67 |
|
pWriter.append( " <th" ); |
80 |
68 |
|
pWriter.append( " align=\"" ); |
81 |
69 |
|
pWriter.append( zDefinition.getHorizontalAlignment().getTextAlignString() ); |
|
@@ -95,22 +83,18 @@ |
95 |
83 |
|
} |
96 |
84 |
|
|
97 |
85 |
|
@SuppressWarnings({"unchecked"}) |
98 |
|
- |
public String getPadding( String pStyleAttributeName, TableColumnDefinition zDefinition, ColumnProperty.Type<PaddingProperty> pType ) |
99 |
|
- |
{ |
|
86 |
+ |
public String getPadding( String pStyleAttributeName, TableColumnDefinition zDefinition, ColumnProperty.Type<PaddingProperty> pType ) { |
100 |
87 |
|
PaddingProperty zProperty = (PaddingProperty) zDefinition.getColumnProperty( pType ); |
101 |
88 |
|
int zValue = zProperty.getValue(); |
102 |
89 |
|
return pStyleAttributeName + ":" + zValue + "px;"; |
103 |
90 |
|
} |
104 |
91 |
|
|
105 |
92 |
|
@SuppressWarnings({"unchecked"}) |
106 |
|
- |
public String getHeader( TableColumnDefinition zDefinition ) |
107 |
|
- |
{ |
|
93 |
+ |
public String getHeader( TableColumnDefinition zDefinition ) { |
108 |
94 |
|
HeaderProperty zProperty = (HeaderProperty) zDefinition.getColumnProperty( HeaderProperty.TYPE ); |
109 |
|
- |
if ( (zProperty != null) && (zProperty.getHeaderCount() == 1) ) |
110 |
|
- |
{ |
|
95 |
+ |
if ( (zProperty != null) && (zProperty.getHeaderCount() == 1) ) { |
111 |
96 |
|
Object zHeader = zProperty.getHeader( 0 ); |
112 |
|
- |
if ( zHeader instanceof String ) |
113 |
|
- |
{ |
|
97 |
+ |
if ( zHeader instanceof String ) { |
114 |
98 |
|
return zHeader.toString(); |
115 |
99 |
|
} |
116 |
100 |
|
} |
|
@@ -118,49 +102,40 @@ |
118 |
102 |
|
} |
119 |
103 |
|
|
120 |
104 |
|
@SuppressWarnings({"UnusedDeclaration"}) |
121 |
|
- |
public ReportColumnDefinition<RowType> addColumn( String pDottedAttributeName ) |
122 |
|
- |
{ |
|
105 |
+ |
public ReportColumnDefinition<RowType> addColumn( String pDottedAttributeName ) { |
123 |
106 |
|
return addColumn( pDottedAttributeName, null, null ); |
124 |
107 |
|
} |
125 |
108 |
|
|
126 |
109 |
|
@SuppressWarnings({"UnusedDeclaration"}) |
127 |
|
- |
public ReportColumnDefinition<RowType> addColumn( String pDottedAttributeName, String pHeaderText ) |
128 |
|
- |
{ |
|
110 |
+ |
public ReportColumnDefinition<RowType> addColumn( String pDottedAttributeName, String pHeaderText ) { |
129 |
111 |
|
return addColumn( pDottedAttributeName, pHeaderText, null ); |
130 |
112 |
|
} |
131 |
113 |
|
|
132 |
114 |
|
@SuppressWarnings({"UnusedDeclaration"}) |
133 |
|
- |
public ReportColumnDefinition<RowType> addColumn( String pDottedAttributeName, TableCellRenderer.Builder pCellRendererBuilder ) |
134 |
|
- |
{ |
|
115 |
+ |
public ReportColumnDefinition<RowType> addColumn( String pDottedAttributeName, TableCellRenderer.Builder pCellRendererBuilder ) { |
135 |
116 |
|
return addColumn( pDottedAttributeName, null, new ReportCellRenderer<RowType>( pCellRendererBuilder ) ); |
136 |
117 |
|
} |
137 |
118 |
|
|
138 |
119 |
|
@SuppressWarnings({"UnusedDeclaration"}) |
139 |
|
- |
public ReportColumnDefinition<RowType> addColumn( String pDottedAttributeName, ReportCellRenderer<RowType> pCellRenderer ) |
140 |
|
- |
{ |
|
120 |
+ |
public ReportColumnDefinition<RowType> addColumn( String pDottedAttributeName, ReportCellRenderer<RowType> pCellRenderer ) { |
141 |
121 |
|
return addColumn( pDottedAttributeName, null, pCellRenderer ); |
142 |
122 |
|
} |
143 |
123 |
|
|
144 |
|
- |
public ReportColumnDefinition<RowType> addColumn( String pDottedAttributeName, String pHeaderText, ReportCellRenderer<RowType> pCellRenderer ) |
145 |
|
- |
{ |
146 |
|
- |
AttributeAccessorSCDpath.Node[] zPathNodes = new AttributeAccessorSCDpath( mFinder, mPOMD ) |
147 |
|
- |
{ |
|
124 |
+ |
public ReportColumnDefinition<RowType> addColumn( String pDottedAttributeName, String pHeaderText, ReportCellRenderer<RowType> pCellRenderer ) { |
|
125 |
+ |
AttributeAccessorSCDpath.Node[] zPathNodes = new AttributeAccessorSCDpath( mFinder, mPOMD ) { |
148 |
126 |
|
@Override |
149 |
|
- |
protected boolean isAcceptableLeaf( AttributeAccessorSCD pSCD ) |
150 |
|
- |
{ |
|
127 |
+ |
protected boolean isAcceptableLeaf( AttributeAccessorSCD pSCD ) { |
151 |
128 |
|
return (pSCD instanceof AbstractAttributeAccessorSCDlocal) || (null != getAcceptableRelationship( pSCD )); |
152 |
129 |
|
} |
153 |
130 |
|
}.createPath( pDottedAttributeName ); |
154 |
|
- |
if ( Objects.isNullOrEmpty( zPathNodes ) ) |
155 |
|
- |
{ |
|
131 |
+ |
if ( Objects.isNullOrEmpty( zPathNodes ) ) { |
156 |
132 |
|
throw new IllegalStateException( "Path '" + pDottedAttributeName + "' unacceptable for " + mPOMD.getIdentifierName() ); |
157 |
133 |
|
} |
158 |
134 |
|
|
159 |
135 |
|
HasHorizontalAlignment.HorizontalAlignmentConstant zHorizontalAlignment = null; |
160 |
136 |
|
|
161 |
137 |
|
AttributeAccessorSCD zLastAA = zPathNodes[zPathNodes.length - 1].getAttributeAccessor(); |
162 |
|
- |
switch ( zLastAA.getAMD().getType() ) |
163 |
|
- |
{ |
|
138 |
+ |
switch ( zLastAA.getAMD().getType() ) { |
164 |
139 |
|
case Integer: |
165 |
140 |
|
case Long: |
166 |
141 |
|
case SimpleMoney: |
|
@@ -174,25 +149,21 @@ |
174 |
149 |
|
} |
175 |
150 |
|
|
176 |
151 |
|
String[] zAttributeNamePath = new String[zPathNodes.length]; |
177 |
|
- |
for ( int i = 0; i < zPathNodes.length; i++ ) |
178 |
|
- |
{ |
|
152 |
+ |
for ( int i = 0; i < zPathNodes.length; i++ ) { |
179 |
153 |
|
zAttributeNamePath[i] = zPathNodes[i].getAttributeAccessor().getName(); |
180 |
154 |
|
} |
181 |
155 |
|
return addColumn( new ReportColumnDefinition<RowType>( pCellRenderer, zHorizontalAlignment, zAttributeNamePath, pHeaderText ) ); |
182 |
156 |
|
} |
183 |
157 |
|
|
184 |
|
- |
public ReportColumnDefinition<RowType> addColumn( ReportColumnDefinition<RowType> pColumnDef ) |
185 |
|
- |
{ |
186 |
|
- |
if ( pColumnDef != null ) |
187 |
|
- |
{ |
|
158 |
+ |
public ReportColumnDefinition<RowType> addColumn( ReportColumnDefinition<RowType> pColumnDef ) { |
|
159 |
+ |
if ( pColumnDef != null ) { |
188 |
160 |
|
addColumnDefinition( pColumnDef ); |
189 |
161 |
|
pColumnDef.setVerticalAlignment( HasVerticalAlignment.ALIGN_TOP ); |
190 |
162 |
|
} |
191 |
163 |
|
return pColumnDef; |
192 |
164 |
|
} |
193 |
165 |
|
|
194 |
|
- |
protected List<TableColumnDefinition> getVisibleTableColumnDefinitions() |
195 |
|
- |
{ |
|
166 |
+ |
protected List<TableColumnDefinition> getVisibleTableColumnDefinitions() { |
196 |
167 |
|
return Cast.it( getVisibleColumnDefinitions() ); |
197 |
168 |
|
} |
198 |
169 |
|
} |