Wednesday, April 11, 2012

Add navigation buttons to an AbstractCell

I've created an AbstractCell<String> to create the header that says "welcome to your mobile..." and I would like to add two buttons in this AbstractCell: the fist to return to the previous page, and the second to return to the welcome page.
I've used to create the header element a class that extends AbstractCell<String> using this code:



public class HeaderCell extends AbstractCell<String> {

interface Templates extends SafeHtmlTemplates {

String style = "HeaderPanel";

@SafeHtmlTemplates.Template("<div class=\""+style+"\">{0}</div>")
SafeHtml cell(SafeHtml value);
}

private Templates templates = GWT.create(Templates.class);

interface templateWithButton extends SafeHtmlTemplates {

}
@Override
public void render(com.google.gwt.cell.client.Cell.Context context,
String value, SafeHtmlBuilder sb) {
SafeHtml safeValue = SafeHtmlUtils.fromString(value);

SafeHtml rendered = templates.cell(safeValue);

sb.append(rendered);
}

}


Is there any way to add to add these two buttons?
Please notice the header cell wich is colored in black.
PS: To set the header element looking like the image below, I use this CSS:



.HeaderPanel {
-moz-box-shadow: inset -1px -1px 15px 1px #ffffff;
-webkit-box-shadow: inset -1px -1px 15px 1px #ffffff;
box-shadow: inset -1px -1px 15px 1px #ffffff;
background: -webkit-gradient(linear, left top, left bottom, color-stop(0.05, #242524
), color-stop(1, #242524) );
background: -moz-linear-gradient(center top, #242524 5%, #242524 100%);
background-color: #242524;
-moz-border-radius: 7px;
-webkit-border-radius: 7px;
border-radius: 7px;
border: 1px solid #dcdcdc;
color: #ffffff;
font-family: arial;
font-size: 17px;
font-weight: bold;
padding: 8px 36px;
text-decoration: none;
text-shadow: 1px 1px 29px #ffffff;
text-align: center;
}


http://hpics.li/5e81f65





1 comment:

  1. What about using CompositeCell with ActionCells for your buttons?

    http://google-web-toolkit.googlecode.com/svn/javadoc/latest/com/google/gwt/cell/client/CompositeCell.html



    new CompositeCell(Arrays.>asList(
    new IdentityColumn(new ActionCell("<", new Delegate() { ... })),
    new Column(new HeaderCell()) { ... },
    new IdentityColumn(new ActionCell(">", new Delegate() { ... }))
    ));

    ReplyDelete