@Override public int compare( final DiscussionRecord o1, final DiscussionRecord o2 ) { return o1.getTimestamp().compareTo( o2.getTimestamp() ); } } );
public static Map<String, Object> toMap( final DiscussionAttributes attrs, final String... attributes ) { return new HashMap<String, Object>() {{ for ( final String attribute : attributes ) { checkNotEmpty( "attribute", attribute ); if ( attribute.equals( "*" ) || attribute.equals( DISCUSS ) ) { for ( int i = 0; i < attrs.discussion().size(); i++ ) { final DiscussionRecord record = attrs.discussion().get( i ); put( buildAttrName( TIMESTAMP, i ), record.getTimestamp() ); put( buildAttrName( AUTHOR, i ), record.getAuthor() ); put( buildAttrName( NOTE, i ), record.getNote() ); } } if ( attribute.equals( "*" ) ) { break; } } }}; }
private Widget appendComment( final DiscussionRecord r ) { final SmallLabel hrd = new SmallLabel( MetadataConstants.INSTANCE.smallCommentBy0On1Small( r.getAuthor(), new Date( r.getTimestamp() ) ) ); hrd.addStyleName( "discussion-header" ); commentList.add( hrd ); final String[] parts = r.getNote().split( "\n" ); if ( parts.length > 0 ) { final StringBuilder txtBuilder = new StringBuilder(); for ( int i = 0; i < parts.length; i++ ) { txtBuilder.append( parts[ i ] ); if ( i != parts.length - 1 ) { txtBuilder.append( "<br/>" ); } } final HTML hth = new HTML( txtBuilder.toString() ); hth.setStyleName( "form-field" ); commentList.add( hth ); } else { final Label lbl = new Label( r.getNote() ); lbl.setStyleName( "form-field" ); commentList.add( lbl ); } commentList.add( new HTML( "<br/>" ) ); return hrd; }