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