use of de.catma.ui.module.analyze.queryresultpanel.QueryResultPanel in project catma by forTEXT.
the class AnalyzeView method getQueryResultPanelSettings.
private List<QueryResultPanelSetting> getQueryResultPanelSettings() {
List<QueryResultPanelSetting> settings = new ArrayList<QueryResultPanelSetting>();
for (Iterator<Component> iter = resultsPanel.iterator(); iter.hasNext(); ) {
Component component = iter.next();
if (component instanceof QueryResultPanel) {
QueryResultPanel queryResultPanel = (QueryResultPanel) component;
settings.add(queryResultPanel.getQueryResultPanelSetting());
}
}
return settings;
}
use of de.catma.ui.module.analyze.queryresultpanel.QueryResultPanel in project catma by forTEXT.
the class AnalyzeView method corpusChanged.
private void corpusChanged() {
Corpus corpus = analyzeResourcePanel.getCorpus();
if (!corpus.isEmpty()) {
// TODO: provide a facility where the user can select between different IndexInfoSets -> AnalyzeResourcePanel
indexInfoSet = corpus.getSourceDocuments().get(0).getSourceContentHandler().getSourceDocumentInfo().getIndexInfoSet();
btQueryBuilder.setEnabled(true);
btExecuteSearch.setEnabled(true);
} else {
btQueryBuilder.setEnabled(false);
btExecuteSearch.setEnabled(false);
}
currentCorpus = corpus;
if (!analyzeCaption.isSetManually()) {
analyzeCaption.setCaption(currentCorpus);
if (tabCaptionChangeListener != null) {
tabCaptionChangeListener.tabCaptionChange(this);
}
}
for (int i = 0; i < resultsPanel.getComponentCount(); i++) {
Component component = resultsPanel.getComponent(i);
if (component instanceof QueryResultPanel) {
QueryResultPanel queryResultPanel = (QueryResultPanel) component;
handleMarkAsStale(queryResultPanel);
}
}
}
use of de.catma.ui.module.analyze.queryresultpanel.QueryResultPanel in project catma by forTEXT.
the class VizMaxPanel method setQueryResultPanel.
private void setQueryResultPanel(QuerySelection querySelection) {
if (querySelection != null) {
if (currentQueryResultPanel != null) {
((ComponentContainer) currentQueryResultPanel.getParent()).removeComponent(currentQueryResultPanel);
}
if (querySelection.getPanel() == null) {
QueryResultPanel queryResultPanel = new QueryResultPanel(project, querySelection.getSetting().getQueryResult(), querySelection.getSetting().getQueryId(), kwicProviderCache, querySelection.getSetting().getDisplaySetting(), item -> handleItemSelection(item));
queryResultPanel.addOptionsMenuItem("Select all", mi -> handleRowsSelection(queryResultPanel.getFilteredQueryResult()));
queryResultPanel.setSizeFull();
querySelection.setPanel(queryResultPanel);
}
AbstractOrderedLayout boxContainer = (AbstractOrderedLayout) queryResultBox.getParent();
if (boxContainer != null) {
boxContainer.removeComponent(queryResultBox);
}
querySelection.getPanel().addToButtonBarLeft(queryResultBox);
boxContainer = (AbstractOrderedLayout) queryResultBox.getParent();
boxContainer.setExpandRatio(queryResultBox, 1f);
topLeftPanel.addComponent(querySelection.getPanel());
topLeftPanel.setExpandRatio(querySelection.getPanel(), 1f);
currentQueryResultPanel = querySelection.getPanel();
}
}
use of de.catma.ui.module.analyze.queryresultpanel.QueryResultPanel in project catma by forTEXT.
the class VizMaxPanel method initComponents.
private void initComponents(String name) {
setSizeFull();
setMargin(false);
HorizontalLayout titlePanel = new HorizontalLayout();
titlePanel.setMargin(false);
titlePanel.setWidth("100%");
nameLabel = new TextField(null, name);
nameLabel.addStyleName("viz-max-panel-name");
titlePanel.addComponent(nameLabel);
titlePanel.setComponentAlignment(nameLabel, Alignment.TOP_CENTER);
titlePanel.setExpandRatio(nameLabel, 1.f);
btMinViz = new IconButton(VaadinIcons.COMPRESS_SQUARE);
titlePanel.addComponent(btMinViz);
titlePanel.setComponentAlignment(btMinViz, Alignment.TOP_CENTER);
addComponent(titlePanel);
mainContentSplitPanel = new HorizontalSplitPanel();
mainContentSplitPanel.setSplitPosition(40, Sizeable.Unit.PERCENTAGE);
addComponent(mainContentSplitPanel);
setExpandRatio(mainContentSplitPanel, 1f);
// left column
VerticalSplitPanel resultSelectionSplitPanel = new VerticalSplitPanel();
mainContentSplitPanel.addComponent(resultSelectionSplitPanel);
// top left
topLeftPanel = new VerticalLayout();
topLeftPanel.setSizeFull();
topLeftPanel.setMargin(new MarginInfo(false, false, false, false));
resultSelectionSplitPanel.addComponent(topLeftPanel);
queryResultBox = new ComboBox<QuerySelection>();
queryResultBox.setWidth("100%");
queryResultBox.setEmptySelectionCaption("Select a resultset");
queryResultBox.setEmptySelectionAllowed(false);
queryResultBox.setItemCaptionGenerator(querySelection -> querySelection.getSetting().getQueryId().toString());
// bottom left
selectedResultsPanel = new QueryResultPanel(project, kwicProviderCache, DisplaySetting.GROUPED_BY_PHRASE, item -> handleItemRemoval(item));
selectedResultsPanel.addToButtonBarLeft(queryResultBox);
selectedResultsPanel.setSizeFull();
selectedResultsPanel.setMargin(new MarginInfo(false, false, false, false));
resultSelectionSplitPanel.addComponent(selectedResultsPanel);
// right column
mainContentSplitPanel.addComponent(visualization);
}
use of de.catma.ui.module.analyze.queryresultpanel.QueryResultPanel in project catma by forTEXT.
the class AnalyzeView method executeSearch.
private void executeSearch(String searchInput, Consumer<QueryResultPanel> addToLayoutFunction) {
QueryOptions queryOptions = new QueryOptions(new QueryId(searchInput), currentCorpus.getDocumentIds(), currentCorpus.getCollectionIds(), indexInfoSet.getUnseparableCharacterSequences(), indexInfoSet.getUserDefinedSeparatingCharacters(), indexInfoSet.getLocale(), project);
QueryJob job = new QueryJob(searchInput, queryOptions);
showProgress(true);
((BackgroundServiceProvider) UI.getCurrent()).submit("Searching...", job, new ExecutionListener<QueryResult>() {
public void done(QueryResult result) {
try {
QueryResultPanel queryResultPanel = new QueryResultPanel(project, result, new QueryId(searchInput.toString()), kwicProviderCache, closingPanel -> handleRemoveQueryResultPanel(closingPanel));
addToLayoutFunction.accept(queryResultPanel);
addQueryResultPanelSetting(queryResultPanel.getQueryResultPanelSetting());
} finally {
showProgress(false);
}
}
public void error(Throwable t) {
showProgress(false);
if (t instanceof QueryException) {
QueryJob.QueryException qe = (QueryJob.QueryException) t;
String input = qe.getInput();
int idx = ((RecognitionException) qe.getCause()).charPositionInLine;
if ((idx >= 0) && (input.length() > idx)) {
char character = input.charAt(idx);
String message = MessageFormat.format("<html><p>There is something wrong with your query <b>{0}</b> approximately at positon {1} character <b>{2}</b>.</p> <p>If you are unsure about how to construct a query try the Query Builder!</p></html>", input, idx + 1, character);
HTMLNotification.show("Info", message, Type.TRAY_NOTIFICATION);
} else {
String message = MessageFormat.format("<html><p>There is something wrong with your query <b>{0}</b>.</p> <p>If you are unsure about how to construct a query try the Query Builder!</p></html>", input);
HTMLNotification.show("Info", message, Type.TRAY_NOTIFICATION);
}
} else {
((ErrorHandler) UI.getCurrent()).showAndLogError("Error during search!", t);
}
}
});
}
Aggregations