use of org.corpus_tools.annis.gui.CorpusSet in project ANNIS by korpling.
the class CorpusListPanel method attach.
@Override
public void attach() {
super.attach();
// Get the initial corpus list, this must become before the binder is set,
// to make sure any selected value is also an item.
CorporaApi api = new CorporaApi(Helper.getClient(ui));
try {
List<String> corpora = api.listCorpora();
availableCorpora = new ListDataProvider<>(corpora);
availableCorpora.setFilter(filter);
tblCorpora.setDataProvider(availableCorpora);
if (ui.getInstanceConfig() != null && ui.getInstanceConfig().getCorpusSets() != null) {
TreeSet<String> corpusSetNames = new TreeSet<>(ui.getInstanceConfig().getCorpusSets().stream().map(CorpusSet::getName).collect(Collectors.toList()));
cbSelection.setItems(corpusSetNames);
if (ui.getInstanceConfig().getDefaultCorpusSet() != null && !ui.getInstanceConfig().getDefaultCorpusSet().isEmpty()) {
cbSelection.setSelectedItem(ui.getInstanceConfig().getDefaultCorpusSet());
}
}
if (corpora.isEmpty() && Helper.getUser(ui.getSecurityContext()).isPresent()) {
Notification.show("No corpora found. Please login " + "(use button at upper right corner) to see more corpora.", Notification.Type.HUMANIZED_MESSAGE);
}
} catch (ApiException e) {
ExceptionDialog.show(e, "Coould not get corpus list", getUI());
}
Binder<QueryUIState> binder = new Binder<>();
MultiSelect<String> corpusSelection = tblCorpora.asMultiSelect();
binder.forField(corpusSelection).bind(QueryUIState::getSelectedCorpora, QueryUIState::setSelectedCorpora);
binder.setBean(ui.getQueryState());
binder.addValueChangeListener(event -> {
Set<String> selectedCorpora = new HashSet<>(ui.getQueryState().getSelectedCorpora());
autoGenQueries.setSelectedCorpusInBackground(selectedCorpora);
ui.getQueryController().corpusSelectionChangedInBackground();
// trigger a resort
tblCorpora.clearSortOrder();
tblCorpora.setSortOrder(new GridSortOrderBuilder<String>().thenDesc(selectedColumn).thenAsc(nameColumn).build());
tblCorpora.scrollTo(0);
});
IDGenerator.assignIDForFields(CorpusListPanel.this, tblCorpora, txtFilter);
}
Aggregations