complexListConfiguration.setExportConfiguration(initExportConfiguration());
complexListConfiguration.setColumnDescriptors(initListColumnDescriptors());
complexListConfiguration.setCustomColumnEnabled(true, Pony.class);
complexListConfiguration.setShowPreferences(true);
final ComplexListView complexListView = new DefaultComplexListView();
complexListView.setFloatableToolBar(scrolPanel);
complexListActivity = new ComplexListActivity<Pony>(complexListConfiguration, complexListView, getRootEventBus());
complexListActivity.registerSearchCriteria(new Criterion("name"), nameSearchField);
complexListActivity.registerSearchCriteria(new Criterion("age"), ageSearchField);
complexListActivity.setCommandFactory(new ComplexListCommandFactory<Pony>() {
@Override
public Command<Result<List<Pony>>> newFindCommand(final ComplexListActivity<Pony> complexListActivity, final Query query) {
return new FindPonysCommand(query) {
@Override
protected void doAfterSuccess(final Result<List<Pony>> result) {
for (final Pony pony : result.getData()) {
if (!raceSearchFormFieldRenderer.hasItem(pony.getRace())) raceSearchFormFieldRenderer.addItem(pony.getRace());
}
complexListActivity.setData(result);
}
};
}
@Override
public Command<String> newExportCommand(final ComplexListActivity<Pony> complexListActivity, final ExportContext<Pony> exportContext) {
return new ExportCommand<Pony>(exportContext);
}
});
complexListActivity.start(scrolPanel);
// complexListActivity.getForm().addFormField(nameSearchField);
// complexListActivity.getForm().addFormField(ageSearchField);
final PButton addPonyButton = new PButton("Create new pony");
addPonyButton.addClickHandler(new PClickHandler() {
@Override
public void onClick(final PClickEvent clickEvent) {
showCreatePonyPopup();
}
});
addPonyButton.addStyleName(PonySDKTheme.BUTTON_GREEN);
complexListView.getToolbarLayout().add(addPonyButton);
// Load initial datas
complexListActivity.refresh();
// Build create pony form