litesoft
@ HEAD
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 |
// This Source Code is in the Public Domain per: http://unlicense.org package org.litesoft.GWT.client.widgets.datatables; import org.litesoft.commonfoundation.base.*; import org.litesoft.commonfoundation.html.*; import org.litesoft.commonfoundation.typeutils.*; import com.google.gwt.user.client.ui.*; public abstract class AbstractAccordionDetailView<RowType> extends Composite { private String mPrefix = HTMLPanel.createUniqueId(); private HTMLPanel mImpl; protected void initHTML( String pHtml ) { initWidget( mImpl = new HTMLPanel( pHtml ) ); } abstract public void populate( RowType pRowType ); protected String id( String pID ) { return mPrefix + pID; } protected void setText( String pID, Object pValue ) { String zText = Objects.toStringOrNull( pValue ); if ( pValue != null ) { mImpl.getElementById( id( pID ) ).setInnerText( zText ); } else { /* * matg: sets to " " which is guaranteed to reserve space which * ensures consistent row height calculation */ setHtml( pID, null ); } } protected void setHtml( String pID, Object pValue ) { mImpl.getElementById( id( pID ) ).setInnerHTML( (pValue != null) ? pValue.toString() : HtmlEntity.NBSP ); } protected String table( String... pTRs ) { StringBuilder sb = new StringBuilder().append( "<table width='100%' cellpadding='0' cellspacing='0'>" ); for ( String zTR : pTRs ) { sb.append( zTR ); } return sb.append( "</table>" ).toString(); } protected String tr( String... pTDs ) { StringBuilder sb = new StringBuilder().append( "<tr>" ); for ( String zTD : pTDs ) { sb.append( zTD ); } return sb.append( "</tr>" ).toString(); } protected String tdWithID( String pID ) { return td( pID, 1, "" ); } protected String td( String pText ) { return td( 1, pText ); } protected String td( int pColspan, String pText ) { return td( null, pColspan, pText ); } protected String td( String pID, int pColspan, String pText ) { StringBuilder sb = new StringBuilder().append( "<td style='white-space:nowrap;'" ); if ( pColspan > 1 ) { sb.append( " colspan='" ).append( pColspan ).append( "'" ); } if ( pID != null ) { sb.append( " id='" ).append( id( pID ) ).append( "'" ); } return sb.append( ">" ).append( pText ).append( "</td>" ).toString(); } protected String wrap( String pText, int pMaxCharsPerLength ) { pText = ConstrainTo.notNull( pText ).trim(); StringBuilder sb = new StringBuilder(); String zPart = getUptoBreakAt( pText, pMaxCharsPerLength ); sb.append( zPart ).append( "<br>" ); pText = pText.substring( zPart.length() ).trim(); zPart = getUptoBreakAt( pText, pMaxCharsPerLength ); sb.append( zPart ).append( "<br>" ); pText = pText.substring( zPart.length() ).trim(); zPart = getUptoBreakAt( pText, pMaxCharsPerLength ); if ( zPart.length() == 0 ) { sb.append( HtmlEntity.NBSP ); } else { if ( pText.length() > zPart.length() ) { zPart = zPart.substring( 0, zPart.length() - 3 ) + "..."; } sb.append( zPart ); } return sb.toString(); } private String getUptoBreakAt( String pText, int pMaxCharsPerLength ) { int zBrkAt = pMaxCharsPerLength; if ( pText.length() <= zBrkAt ) { return pText; } while ( (zBrkAt > 0) && (' ' != pText.charAt( zBrkAt )) ) { zBrkAt--; } return pText.substring( 0, (zBrkAt != 0) ? zBrkAt : pMaxCharsPerLength ); } } |
Commits for litesoft/trunk/Java/GWT/Client/src/org/litesoft/GWT/client/widgets/datatables/AbstractAccordionDetailView.java
Revision | Author | Commited | Message |
---|---|---|---|
950 Diff | GeorgeS | Thu 19 Jun, 2014 17:57:04 +0000 | New Lines |
948 Diff | GeorgeS | Sat 07 Jun, 2014 23:42:39 +0000 | Jusefuls Formatter Updated to New Code Format |
947 Diff | GeorgeS | Fri 06 Jun, 2014 23:36:56 +0000 | Correct Spelling of package! |
942 Diff | GeorgeS | Mon 02 Jun, 2014 23:41:46 +0000 | Extracting commonfoundation |
939 Diff | GeorgeS | Mon 02 Jun, 2014 21:30:31 +0000 | Extracting commonfoundation |
822 Diff | GeorgeS | Sun 19 Aug, 2012 01:03:51 +0000 | |
802 Diff | GeorgeS | Wed 15 Aug, 2012 04:04:47 +0000 | |
720 Diff | GeorgeS | Sun 10 Jun, 2012 16:20:42 +0000 | |
712 Diff | GeorgeS | Sat 09 Jun, 2012 22:46:04 +0000 | Move PAV stuff into LiteSoft |
151 | GeorgeS | Thu 17 Mar, 2011 04:16:22 +0000 |