litesoft
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
|
package org.litesoft.GWT.client.widgets.datatables;
import com.google.gwt.user.client.ui.*;
import org.litesoft.GWT.client.*;
import org.litesoft.core.util.*;
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 = UtilsGwt.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() : " " );
}
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 = UtilsCommon.deNull( 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( " " );
}
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 );
}
}
|
Revision |
Author |
Commited |
Message |
2
|
GeorgeS
|
Sun 07 Feb, 2010 12:50:58 +0000 |
|