Icon from GWT tree menu item to the right.
Is it possible to align the icon for a tree menu开发者_JS百科 item to the right instead of left? Like this :
item1 >
item2 >
item3 >
Where the ">" is an image. I am using standard GWT. Tried with both CellTree and normal Tree.
/Andreas
Edit: Just realised this is a Google Web Toolkit question. I know nothing about Google Web Toolkit - but if they let you use normal CSS you can style any list in the way I describe below:
You can't do it with the standard list-style property, but you can definitely do it with background-image:
li {
list-style: none;
background-image: url('arrow.gif');
background-position: right center;
}
You can put any Widgets as treeItem into the Tree. So if you want to put an item inside the tree which has the icon left just create a horizonal panel, put your text and the icon inside and then put the horizontal panel into the tree... (I know this sounds a little bit complex but it is actually really simple and you can do alot of other cool stuf with it)
Tree t = new Tree();
HorizontalPanel hc = new HorizontalPanel();
hc.add(new Label("some text"));
hc.add(new Image("http://tueffel.net/images/icons/icon13.gif"));
TreeItem ti = new TreeItem(hc);
HorizontalPanel hc2 = new HorizontalPanel();
hc2.add(new Label("some text"));
hc2.add(new Image("http://tueffel.net/images/icons/icon13.gif"));
ti.addItem(new TreeItem(hc2));
t.addItem(ti);
RootPanel.get().add(t);
I have a CellTree
with my own TreeModel
which return a NodeInfo
with custom renderer.
something like this:
viewModel = new MyTreeModel( dirs.getRootItems(), filter );
treeDrives = new CellTree( viewModel, null, treeResources );
public class MyTreeModel {
@Override
public <T> NodeInfo<?> getNodeInfo( final T value ) {
return new DefaultNodeInfo<Item>( new ListDataProvider<Item>( dirs ), new DirectoryCell(), selectionModel, null );
}
}
private final class DirectoryCell extends AbstractCell<Item> {
@Override
public void render( com.google.gwt.cell.client.Cell.Context context, Item value, SafeHtmlBuilder sb ) {
// my own html renderer ...
sb.appendHtmlConstant(value.toString);
sb.append"<img src=\"" + value.getImgUrl() + "\" //>");
}
new TreeItem(new HTML("Item Text <img src='path/to/image.png'>"));
精彩评论