Search in sources :

Example 1 with QueryResultPanel

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;
}
Also used : RefreshQueryResultPanel(de.catma.ui.module.analyze.queryresultpanel.RefreshQueryResultPanel) QueryResultPanel(de.catma.ui.module.analyze.queryresultpanel.QueryResultPanel) ArrayList(java.util.ArrayList) Component(com.vaadin.ui.Component) QueryResultPanelSetting(de.catma.ui.module.analyze.queryresultpanel.QueryResultPanelSetting)

Example 2 with QueryResultPanel

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);
        }
    }
}
Also used : RefreshQueryResultPanel(de.catma.ui.module.analyze.queryresultpanel.RefreshQueryResultPanel) QueryResultPanel(de.catma.ui.module.analyze.queryresultpanel.QueryResultPanel) Component(com.vaadin.ui.Component) Corpus(de.catma.document.corpus.Corpus)

Example 3 with 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();
    }
}
Also used : QueryResultPanel(de.catma.ui.module.analyze.queryresultpanel.QueryResultPanel) ComponentContainer(com.vaadin.ui.ComponentContainer) AbstractOrderedLayout(com.vaadin.ui.AbstractOrderedLayout)

Example 4 with QueryResultPanel

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);
}
Also used : DisplaySetting(de.catma.ui.module.analyze.queryresultpanel.DisplaySetting) LoadingCache(com.google.common.cache.LoadingCache) TextField(com.vaadin.ui.TextField) QueryResultPanelSetting(de.catma.ui.module.analyze.queryresultpanel.QueryResultPanelSetting) QueryResultPanel(de.catma.ui.module.analyze.queryresultpanel.QueryResultPanel) VerticalLayout(com.vaadin.ui.VerticalLayout) VerticalSplitPanel(com.vaadin.ui.VerticalSplitPanel) SelectionEvent(com.vaadin.event.selection.SelectionEvent) Alignment(com.vaadin.ui.Alignment) ComboBox(com.vaadin.ui.ComboBox) SingleSelectionEvent(com.vaadin.event.selection.SingleSelectionEvent) ComponentContainer(com.vaadin.ui.ComponentContainer) QueryResultRowArray(de.catma.queryengine.result.QueryResultRowArray) SingleSelectionListener(com.vaadin.event.selection.SingleSelectionListener) KwicProvider(de.catma.indexer.KwicProvider) VaadinIcons(com.vaadin.icons.VaadinIcons) AbstractOrderedLayout(com.vaadin.ui.AbstractOrderedLayout) IconButton(de.catma.ui.component.IconButton) ListDataProvider(com.vaadin.data.provider.ListDataProvider) ExpansionListener(de.catma.ui.module.analyze.visualization.ExpansionListener) Project(de.catma.project.Project) Collection(java.util.Collection) HorizontalSplitPanel(com.vaadin.ui.HorizontalSplitPanel) Visualization(de.catma.ui.module.analyze.visualization.Visualization) ValueChangeListener(com.vaadin.data.HasValue.ValueChangeListener) Sizeable(com.vaadin.server.Sizeable) MarginInfo(com.vaadin.shared.ui.MarginInfo) List(java.util.List) Button(com.vaadin.ui.Button) HorizontalLayout(com.vaadin.ui.HorizontalLayout) QueryResultRowItem(de.catma.ui.module.analyze.queryresultpanel.QueryResultRowItem) KwicPanel(de.catma.ui.module.analyze.visualization.kwic.KwicPanel) IconButton(de.catma.ui.component.IconButton) MarginInfo(com.vaadin.shared.ui.MarginInfo) QueryResultPanel(de.catma.ui.module.analyze.queryresultpanel.QueryResultPanel) HorizontalSplitPanel(com.vaadin.ui.HorizontalSplitPanel) TextField(com.vaadin.ui.TextField) VerticalLayout(com.vaadin.ui.VerticalLayout) VerticalSplitPanel(com.vaadin.ui.VerticalSplitPanel) HorizontalLayout(com.vaadin.ui.HorizontalLayout)

Example 5 with QueryResultPanel

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);
            }
        }
    });
}
Also used : ThemeResource(com.vaadin.server.ThemeResource) Panel(com.vaadin.ui.Panel) BackgroundServiceProvider(de.catma.backgroundservice.BackgroundServiceProvider) HTMLNotification(de.catma.ui.component.HTMLNotification) LoadingCache(com.google.common.cache.LoadingCache) WordCloudDisplaySettingHandler(de.catma.ui.module.analyze.visualization.vega.WordCloudDisplaySettingHandler) Alignment(com.vaadin.ui.Alignment) UI(com.vaadin.ui.UI) IndexedProject(de.catma.indexer.IndexedProject) KwicProvider(de.catma.indexer.KwicProvider) RecognitionException(org.antlr.runtime.RecognitionException) ErrorHandler(de.catma.ui.module.main.ErrorHandler) Locale(java.util.Locale) SliderPanel(org.vaadin.sliderpanel.SliderPanel) VaadinIcons(com.vaadin.icons.VaadinIcons) QueryId(de.catma.queryengine.QueryId) ProgressBar(com.vaadin.ui.ProgressBar) IconButton(de.catma.ui.component.IconButton) ExecutionListener(de.catma.backgroundservice.ExecutionListener) QueryOptions(de.catma.queryengine.QueryOptions) IndexInfoSet(de.catma.document.source.IndexInfoSet) ClosableTab(de.catma.ui.component.tabbedview.ClosableTab) QueryBuilder(de.catma.ui.module.analyze.querybuilder.QueryBuilder) MarginInfo(com.vaadin.shared.ui.MarginInfo) List(java.util.List) Type(com.vaadin.ui.Notification.Type) Corpus(de.catma.document.corpus.Corpus) RefreshQueryResultPanel(de.catma.ui.module.analyze.queryresultpanel.RefreshQueryResultPanel) Optional(java.util.Optional) SliderPanelBuilder(org.vaadin.sliderpanel.SliderPanelBuilder) QueryJob(de.catma.queryengine.QueryJob) SliderMode(org.vaadin.sliderpanel.client.SliderMode) KwicPanel(de.catma.ui.module.analyze.visualization.kwic.KwicPanel) FormatStyle(java.time.format.FormatStyle) QueryResultPanelSetting(de.catma.ui.module.analyze.queryresultpanel.QueryResultPanelSetting) DoubleTreePanel(de.catma.ui.module.analyze.visualization.doubletree.DoubleTreePanel) QueryResultPanel(de.catma.ui.module.analyze.queryresultpanel.QueryResultPanel) VerticalLayout(com.vaadin.ui.VerticalLayout) LocalDateTime(java.time.LocalDateTime) ComboBox(com.vaadin.ui.ComboBox) WizardContext(de.catma.ui.dialog.wizard.WizardContext) DistributionDisplaySettingHandler(de.catma.ui.module.analyze.visualization.vega.DistributionDisplaySettingHandler) MessageFormat(java.text.MessageFormat) ArrayList(java.util.ArrayList) EventBus(com.google.common.eventbus.EventBus) MaterialTheme(com.github.appreciated.material.MaterialTheme) Notification(com.vaadin.ui.Notification) VegaPanel(de.catma.ui.module.analyze.visualization.vega.VegaPanel) Label(com.vaadin.ui.Label) ClassResource(com.vaadin.server.ClassResource) SaveCancelListener(de.catma.ui.dialog.SaveCancelListener) QueryException(de.catma.queryengine.QueryJob.QueryException) AnalyzeResourcePanel(de.catma.ui.module.analyze.resourcepanel.AnalyzeResourcePanel) ListDataProvider(com.vaadin.data.provider.ListDataProvider) QueryResult(de.catma.queryengine.result.QueryResult) Iterator(java.util.Iterator) Consumer(java.util.function.Consumer) Button(com.vaadin.ui.Button) HorizontalLayout(com.vaadin.ui.HorizontalLayout) TabCaptionChangeListener(de.catma.ui.component.tabbedview.TabCaptionChangeListener) DateTimeFormatter(java.time.format.DateTimeFormatter) QueryTree(de.catma.queryengine.querybuilder.QueryTree) Collections(java.util.Collections) Component(com.vaadin.ui.Component) QueryResult(de.catma.queryengine.result.QueryResult) QueryException(de.catma.queryengine.QueryJob.QueryException) QueryJob(de.catma.queryengine.QueryJob) RefreshQueryResultPanel(de.catma.ui.module.analyze.queryresultpanel.RefreshQueryResultPanel) QueryResultPanel(de.catma.ui.module.analyze.queryresultpanel.QueryResultPanel) QueryId(de.catma.queryengine.QueryId) BackgroundServiceProvider(de.catma.backgroundservice.BackgroundServiceProvider) QueryOptions(de.catma.queryengine.QueryOptions)

Aggregations

QueryResultPanel (de.catma.ui.module.analyze.queryresultpanel.QueryResultPanel)5 Component (com.vaadin.ui.Component)3 QueryResultPanelSetting (de.catma.ui.module.analyze.queryresultpanel.QueryResultPanelSetting)3 LoadingCache (com.google.common.cache.LoadingCache)2 ListDataProvider (com.vaadin.data.provider.ListDataProvider)2 VaadinIcons (com.vaadin.icons.VaadinIcons)2 MarginInfo (com.vaadin.shared.ui.MarginInfo)2 AbstractOrderedLayout (com.vaadin.ui.AbstractOrderedLayout)2 Alignment (com.vaadin.ui.Alignment)2 Button (com.vaadin.ui.Button)2 ComboBox (com.vaadin.ui.ComboBox)2 ComponentContainer (com.vaadin.ui.ComponentContainer)2 HorizontalLayout (com.vaadin.ui.HorizontalLayout)2 VerticalLayout (com.vaadin.ui.VerticalLayout)2 Corpus (de.catma.document.corpus.Corpus)2 KwicProvider (de.catma.indexer.KwicProvider)2 IconButton (de.catma.ui.component.IconButton)2 RefreshQueryResultPanel (de.catma.ui.module.analyze.queryresultpanel.RefreshQueryResultPanel)2 KwicPanel (de.catma.ui.module.analyze.visualization.kwic.KwicPanel)2 List (java.util.List)2