final ListBox multiBox = new ListBox();
multiBox.setVisibleItemCount(5);
layout.add(multiBox);
// init
final Preferences prefs = GWT.create(Preferences.class);
String prefEditor = prefs.get(Preferences.DEFAULT_TOOL);
for(ToolSet ts : toolsets)
{
multiBox.addItem(ts.getToolSetName());
if(ts.getToolSetName().equals(prefEditor))
multiBox.setItemSelected(multiBox.getItemCount()-1, true);
}
multiBox.addClickHandler(
new ClickHandler()
{
public void onClick(ClickEvent clickEvent)
{
String title = multiBox.getItemText(multiBox.getSelectedIndex());
for(ToolSet ts: toolsets)
{
if(ts.getToolSetName().equals(title))
{
prefs.set(Preferences.DEFAULT_TOOL, ts.getToolSetName());
}
}
}
}
);