Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package org.uberfire.ext.widgets.common.client.tables;
  
  import  com.google.gwt.cell.client.AbstractSafeHtmlCell;
  import  com.google.gwt.safehtml.shared.SafeHtml;
  import  com.google.gwt.safehtml.shared.SafeHtmlBuilder;
  import  com.google.gwt.safehtml.shared.SafeHtmlUtils;
  import  com.google.gwt.text.shared.SafeHtmlRenderer;
An extension to the normal TextCell that renders upto two rows of text; one being the title and the other being narrative.
 
 public class TitledTextCell extends AbstractSafeHtmlCell<TitledTextCell.TitledText> {
 
     protected static final CommonCss css = ..CSS();

    
Constructs a TitledTextCell that uses a TitledTextSafeHtmlRenderer to render its text.
 
     public TitledTextCell() {
         super( TitledTextSafeHtmlRenderer.getInstance() );
     }

    
Constructs a TextCell that uses the provided SafeHtmlRenderer to render its text.

Parameters:
renderer a SafeHtmlRenderer<String> instance
 
     public TitledTextCellfinal SafeHtmlRenderer<TitledTextrenderer ) {
         superrenderer );
     }
 
     @Override
     public void render( Context context,
                         SafeHtml value,
                         SafeHtmlBuilder sb ) {
         if ( value != null ) {
             sb.append( value );
         }
     }

    
Container for the Cell value; consisting of title and description
 
     public static class TitledText
             implements
             Comparable<TitledText> {
 
         private String title;
         private String description;
 
         public TitledTextString title,
                            String description ) {
             this. = title;
             this. = description;
         }
 
         public String getTitle() {
             return ;
         }
 
         public String getDescription() {
             return ;
         }
 
         public int compareToTitledText o ) {
             return .compareToo.title );
         }
 
     }

    
A renderer for TitledText values
 
     public static class TitledTextSafeHtmlRenderer
             implements
             SafeHtmlRenderer<TitledText> {
 
         // Singleton
         private static TitledTextSafeHtmlRenderer instance;
 
         public static TitledTextSafeHtmlRenderer getInstance() {
             if (  == null ) {
                  = new TitledTextSafeHtmlRenderer();
             }
             return ;
         }
 
         private TitledTextSafeHtmlRenderer() {
         }
 
         public SafeHtml renderTitledText object ) {
             boolean bHasDescription = object.description != null && !"".equalsobject.description );
 
             if ( bHasDescription ) {
                 String html = "<div class='" + .titleTextCellContainer() + "'>";
                html = html + "<div>" + object.title + "</div>";
                html = html + "<div class='" + .titleTextCellDescription() + "'>" + object.description + "</div>";
                html = html + "</div>";
                return SafeHtmlUtils.fromTrustedString( html );
            } else {
                String html = "<div class='" + .titleTextCellContainer() + "'>";
                html = html + "<div>" + object.title + "</div>";
                html = html + "</div>";
                return SafeHtmlUtils.fromTrustedString( html );
            }
        }
        public void renderTitledText object,
                            SafeHtmlBuilder builder ) {
            builder.append( renderobject ) );
        }
    }
New to GrepCode? Check out our FAQ X