private Constants constants = GWT.create( Constants.class );
private static Images images = GWT.create( Images.class );
public FactTypeBrowser(SuggestionCompletionEngine sce,
final ClickEvent ev) {
Tree tree = new Tree();
final VerticalPanel panel = new VerticalPanel();
HorizontalPanel hp = new HorizontalPanel();
hp.add( new SmallLabel( constants.FactTypes() ) );
hp.add( new ClickableLabel( constants.hide(),
new ClickHandler() {
public void onClick(com.google.gwt.event.dom.client.ClickEvent event) {
panel.setVisible( false );
}
} ) );
panel.add( hp );
panel.add( tree );
if ( sce.getFactTypes() != null ) {
for ( String type : sce.getFactTypes() ) {
TreeItem it = new TreeItem();
it.setHTML( "<img src='" + new Image( images.classImage() ).getUrl() + "'/><small>"
+ type + "</small>" );
it.setUserObject( type + "( )" );
tree.addItem( it );
String[] fields = (String[]) sce.getModelFields( type );
if ( fields != null ) {
for ( String field : fields ) {
TreeItem fi = new TreeItem();
fi.setHTML( "<img src='" + new Image( images.field() ).getUrl() + "'/><small>"
+ field + "</small>" );
fi.setUserObject( field );
it.addItem( fi );
}
}
}
}
tree.setStyleName( "category-explorer-Tree" ); //NON-NLS
tree.addSelectionHandler( new SelectionHandler<TreeItem>() {
public void onSelection(SelectionEvent<TreeItem> event) {
Object o = event.getSelectedItem().getUserObject();
if ( o instanceof String ) {
ev.selected( (String) o );