Search in sources :

Example 1 with CSVExportGroupedStreamSource

use of de.catma.ui.module.analyze.CSVExportGroupedStreamSource in project catma by forTEXT.

the class QueryResultPanel method initActions.

private void initActions(CloseListener resultPanelCloseListener) {
    if (cardStyle) {
        caretRightBt.addClickListener(new ClickListener() {

            public void buttonClick(ClickEvent event) {
                addComponent(treeGridPanel);
                ((HorizontalLayout) caretRightBt.getParent()).replaceComponent(caretRightBt, caretDownBt);
                searchField.setEnabled(true);
            }
        });
        caretDownBt.addClickListener(new ClickListener() {

            public void buttonClick(ClickEvent event) {
                removeComponent(treeGridPanel);
                ((HorizontalLayout) caretDownBt.getParent()).replaceComponent(caretDownBt, caretRightBt);
                searchField.setEnabled(false);
            }
        });
    }
    optionsBt.addClickListener((evt) -> optionsMenu.open(evt.getClientX(), evt.getClientY()));
    miGroupByPhrase = optionsMenu.addItem("Group by Phrase", mi -> initPhraseBasedData());
    miGroupByPhrase.setEnabled(false);
    miGroupByTagPath = optionsMenu.addItem("Group by Tag Path", mi -> initTagBasedData());
    miFlatTable = optionsMenu.addItem("Display Annotations as flat table", mi -> initFlatTagBasedData());
    miPropertiesAsColumns = optionsMenu.addItem("Display Properties as columns", mi -> initPropertiesAsColumnsTagBasedData());
    MenuItem miExport = optionsMenu.addItem("Export");
    MenuItem miCSVFlatExport = miExport.addItem("Export flat as CSV");
    StreamResource csvFlatExportResource = new StreamResource(new CSVExportFlatStreamSource(() -> getFilteredQueryResult(), project, kwicProviderCache, ((BackgroundServiceProvider) UI.getCurrent())), "CATMA-Query-Result_Export-" + LocalDateTime.now().format(DateTimeFormatter.ISO_DATE_TIME) + ".csv");
    csvFlatExportResource.setCacheTime(0);
    csvFlatExportResource.setMIMEType("text/comma-separated-values");
    FileDownloader csvFlatExportFileDownloader = new FileDownloader(csvFlatExportResource);
    csvFlatExportFileDownloader.extend(miCSVFlatExport);
    MenuItem miCSVGroupedByPhraseExport = miExport.addItem("Export grouped as CSV");
    StreamResource csvGroupedByPhraseExportResource = new StreamResource(new CSVExportGroupedStreamSource(() -> getFilteredQueryResult(), project, () -> getDisplaySetting().equals(DisplaySetting.GROUPED_BY_TAG), kwicProviderCache, ((BackgroundServiceProvider) UI.getCurrent())), "CATMA-Query-Result_Export-" + LocalDateTime.now().format(DateTimeFormatter.ISO_DATE_TIME) + ".csv");
    csvGroupedByPhraseExportResource.setCacheTime(0);
    csvGroupedByPhraseExportResource.setMIMEType("text/comma-separated-values");
    FileDownloader csvGroupedByPhraseExportFileDownloader = new FileDownloader(csvGroupedByPhraseExportResource);
    csvGroupedByPhraseExportFileDownloader.extend(miCSVGroupedByPhraseExport);
    MenuItem miFilterPunctuation = optionsMenu.addItem("Filter punctuation", mi -> queryResultGrid.getDataProvider().refreshAll());
    miFilterPunctuation.setCheckable(true);
    miFilterPunctuation.setChecked(true);
    punctuationFilter = new PunctuationFilter(() -> miFilterPunctuation.isChecked());
    if (resultPanelCloseListener != null) {
        removeBt.addClickListener(clickEvent -> resultPanelCloseListener.closeRequest(QueryResultPanel.this));
    } else {
        removeBt.setVisible(false);
    }
    searchField.addValueChangeListener(event -> handleSearchValueInput(event.getValue()));
}
Also used : BackgroundServiceProvider(de.catma.backgroundservice.BackgroundServiceProvider) GroupedQueryResult(de.catma.queryengine.result.GroupedQueryResult) GridSortOrderBuilder(com.vaadin.data.provider.GridSortOrderBuilder) MenuItem(com.vaadin.ui.MenuBar.MenuItem) LoadingCache(com.google.common.cache.LoadingCache) SelectionListener(com.vaadin.event.selection.SelectionListener) TextField(com.vaadin.ui.TextField) Alignment(com.vaadin.ui.Alignment) UI(com.vaadin.ui.UI) FooterRow(com.vaadin.ui.components.grid.FooterRow) QueryResultRowArray(de.catma.queryengine.result.QueryResultRowArray) KwicProvider(de.catma.indexer.KwicProvider) ErrorHandler(de.catma.ui.module.main.ErrorHandler) Map(java.util.Map) TreeDataProvider(com.vaadin.data.provider.TreeDataProvider) TagQueryResultRow(de.catma.queryengine.result.TagQueryResultRow) VaadinIcons(com.vaadin.icons.VaadinIcons) QueryId(de.catma.queryengine.QueryId) IconButton(de.catma.ui.component.IconButton) Set(java.util.Set) TreeGrid(com.vaadin.ui.TreeGrid) AnnotatedTextProvider(de.catma.ui.module.annotate.annotationpanel.AnnotatedTextProvider) Collectors(java.util.stream.Collectors) BinaryOperator(java.util.function.BinaryOperator) List(java.util.List) Type(com.vaadin.ui.Notification.Type) TagDefinition(de.catma.tag.TagDefinition) ExpandEvent(com.vaadin.event.ExpandEvent) StreamResource(com.vaadin.server.StreamResource) ClickListener(com.vaadin.ui.Button.ClickListener) Column(com.vaadin.ui.Grid.Column) VerticalLayout(com.vaadin.ui.VerticalLayout) LocalDateTime(java.time.LocalDateTime) HashMap(java.util.HashMap) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) Registration(com.vaadin.shared.Registration) Notification(com.vaadin.ui.Notification) TreeGridFactory(de.catma.ui.component.TreeGridFactory) ButtonRenderer(com.vaadin.ui.renderers.ButtonRenderer) WeakReference(java.lang.ref.WeakReference) CSVExportGroupedStreamSource(de.catma.ui.module.analyze.CSVExportGroupedStreamSource) InMemoryDataProvider(com.vaadin.data.provider.InMemoryDataProvider) ContentMode(com.vaadin.shared.ui.ContentMode) QueryResult(de.catma.queryengine.result.QueryResult) Iterator(java.util.Iterator) TreeData(com.vaadin.data.TreeData) ClickEvent(com.vaadin.ui.Button.ClickEvent) Project(de.catma.project.Project) Command(com.vaadin.ui.MenuBar.Command) QueryResultRow(de.catma.queryengine.result.QueryResultRow) ContextMenu(com.vaadin.contextmenu.ContextMenu) FooterCell(com.vaadin.ui.components.grid.FooterCell) Button(com.vaadin.ui.Button) HorizontalLayout(com.vaadin.ui.HorizontalLayout) DateTimeFormatter(java.time.format.DateTimeFormatter) FileDownloader(com.vaadin.server.FileDownloader) SerializablePredicate(com.vaadin.server.SerializablePredicate) HierarchicalQuery(com.vaadin.data.provider.HierarchicalQuery) HtmlRenderer(com.vaadin.ui.renderers.HtmlRenderer) CSVExportFlatStreamSource(de.catma.ui.module.analyze.CSVExportFlatStreamSource) Component(com.vaadin.ui.Component) StreamResource(com.vaadin.server.StreamResource) ClickEvent(com.vaadin.ui.Button.ClickEvent) MenuItem(com.vaadin.ui.MenuBar.MenuItem) FileDownloader(com.vaadin.server.FileDownloader) CSVExportFlatStreamSource(de.catma.ui.module.analyze.CSVExportFlatStreamSource) CSVExportGroupedStreamSource(de.catma.ui.module.analyze.CSVExportGroupedStreamSource) ClickListener(com.vaadin.ui.Button.ClickListener)

Aggregations

LoadingCache (com.google.common.cache.LoadingCache)1 ContextMenu (com.vaadin.contextmenu.ContextMenu)1 TreeData (com.vaadin.data.TreeData)1 GridSortOrderBuilder (com.vaadin.data.provider.GridSortOrderBuilder)1 HierarchicalQuery (com.vaadin.data.provider.HierarchicalQuery)1 InMemoryDataProvider (com.vaadin.data.provider.InMemoryDataProvider)1 TreeDataProvider (com.vaadin.data.provider.TreeDataProvider)1 ExpandEvent (com.vaadin.event.ExpandEvent)1 SelectionListener (com.vaadin.event.selection.SelectionListener)1 VaadinIcons (com.vaadin.icons.VaadinIcons)1 FileDownloader (com.vaadin.server.FileDownloader)1 SerializablePredicate (com.vaadin.server.SerializablePredicate)1 StreamResource (com.vaadin.server.StreamResource)1 Registration (com.vaadin.shared.Registration)1 ContentMode (com.vaadin.shared.ui.ContentMode)1 Alignment (com.vaadin.ui.Alignment)1 Button (com.vaadin.ui.Button)1 ClickEvent (com.vaadin.ui.Button.ClickEvent)1 ClickListener (com.vaadin.ui.Button.ClickListener)1 Component (com.vaadin.ui.Component)1