@Override
public IsPWidget render(final FormField formField) {
selected = new PListBox(true, true);
unselected = new PListBox(true, true);
final PHorizontalPanel panel = new PHorizontalPanel();
formFieldComponent = new FormFieldComponent<PHorizontalPanel>(panel);
panel.setVerticalAlignment(PVerticalAlignment.ALIGN_MIDDLE);
selected.addChangeHandler(this);
unselected.addChangeHandler(this);
panel.setSpacing(5);
for (final String item : items) {
unselected.addItem(item);
}
panel.setTitle("caption");
final PWidget unselectedWidget = unselected.asWidget();
panel.add(unselectedWidget);
switchButton = new PButton("<>");
formFieldComponent.setCaption(caption);
switchButton.addClickHandler(new PClickHandler() {
@Override
public void onClick(final PClickEvent clickEvent) {
selectValues.clear();
for (int i = 1; i < unselected.getItemCount(); i++) {
if (unselected.isItemSelected(i)) {
selectValues.add(unselected.getItem(i));
}
}
for (int i = 1; i < selected.getItemCount(); i++) {
if (!selected.isItemSelected(i)) {
selectValues.add(selected.getItem(i));
}
}
refresh();
}
});
final PWidget button = switchButton.asWidget();
panel.add(button);
final PWidget selectedWidget = selected.asWidget();
panel.add(selectedWidget);
panel.setCellVerticalAlignment(selectedWidget, PVerticalAlignment.ALIGN_TOP);
panel.setCellHeight(selectedWidget, "100%");
panel.setCellHeight(unselectedWidget, "100%");
panel.setCellVerticalAlignment(button, PVerticalAlignment.ALIGN_TOP);
panel.setCellVerticalAlignment(unselectedWidget, PVerticalAlignment.ALIGN_TOP);
if (debugID != null) {
onEnsureDebugID();
}
return formFieldComponent.asWidget();
}