Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package org.drools.guvnor.client.widgets.tables;
  
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<TitledText> {
 
     protected static final TitledTextCellCss css = ..titledTextCellCss();

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

    
Constructs a TextCell that uses the provided com.google.gwt.text.shared.SafeHtmlRenderer to render its text.

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

    
Container for the Cell value; consisting of title and description
 
     public static class TitledText
         implements
         Comparable<TitledText> {
         private String title;
         private String description;
 
         public TitledText(String title,
                           String description) {
             this. = title;
             this. = description;
         }
 
         public String getTitle() {
             return ;
         }
 
         public String getDescription() {
             return ;
         }
 
         public int compareTo(TitledText 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 render(TitledText object) {
             boolean bHasDescription = object.description != null && !"".equalsobject.description );
 
             if ( bHasDescription ) {
                String html = "<div class='" + .container() + "'>";
                html = html + "<div>" + object.title + "</div>";
                html = html + "<div class='" + .description() + "'>" + object.description + "</div>";
                html = html + "</div>";
                return SafeHtmlUtils.fromTrustedStringhtml );
            } else {
                String html = "<div class='" + .container() + "'>";
                html = html + "<div>" + object.title + "</div>";
                html = html + "</div>";
                return SafeHtmlUtils.fromTrustedStringhtml );
            }
        }
        public void render(TitledText object,
                           SafeHtmlBuilder builder) {
            builder.appendrenderobject ) );
        }
    }
New to GrepCode? Check out our FAQ X