Search in sources :

Example 1 with CSVExportFlatStreamSource

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

the class KwicPanel method initActions.

private void initActions(EventBus eventBus) {
    ContextMenu moreOptionsMenu = kwicGridComponent.getActionGridBar().getBtnMoreOptionsContextMenu();
    moreOptionsMenu.addItem("Annotate selected rows", mi -> handleAnnotateSelectedRequest(eventBus));
    ActionGridBar actionBar = kwicGridComponent.getActionGridBar();
    actionBar.addButtonAfterSearchField(btnClearSelectedRows);
    btnClearSelectedRows.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            handleRemoveRowRequest();
        }
    });
    miRemoveAnnotations = moreOptionsMenu.addItem("Remove selected Annotations", mi -> handleRemoveAnnotationsRequest(eventBus));
    miRemoveAnnotations.setEnabled(false);
    MenuItem miExport = moreOptionsMenu.addItem("Export");
    MenuItem miCSVFlatExport = miExport.addItem("Export as CSV");
    StreamResource csvFlatExportResource = new StreamResource(new CSVExportFlatStreamSource(() -> getFilteredQueryResult(), project, kwicItemHandler.getKwicProviderCache(), ((BackgroundServiceProvider) UI.getCurrent())), "CATMA-KWIC_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);
    kwicGridComponent.setSearchFilterProvider(new SearchFilterProvider<QueryResultRow>() {

        @Override
        public SerializablePredicate<QueryResultRow> createSearchFilter(String searchInput) {
            return (row) -> kwicItemHandler.containsSearchInput(row, searchInput);
        }
    });
    btExpandCompress.addClickListener(clickEvent -> handleMaxMinRequest());
    defaultDoubleClickRegistration = kwicGrid.addItemClickListener(clickEvent -> handleKwicItemClick(clickEvent, eventBus));
}
Also used : BackgroundServiceProvider(de.catma.backgroundservice.BackgroundServiceProvider) DisplaySetting(de.catma.ui.module.analyze.queryresultpanel.DisplaySetting) MenuItem(com.vaadin.ui.MenuBar.MenuItem) LoadingCache(com.google.common.cache.LoadingCache) ZonedDateTime(java.time.ZonedDateTime) UI(com.vaadin.ui.UI) QueryResultRowArray(de.catma.queryengine.result.QueryResultRowArray) SearchFilterProvider(de.catma.ui.component.actiongrid.SearchFilterProvider) KwicProvider(de.catma.indexer.KwicProvider) ErrorHandler(de.catma.ui.module.main.ErrorHandler) Map(java.util.Map) TagQueryResultRow(de.catma.queryengine.result.TagQueryResultRow) VaadinIcons(com.vaadin.icons.VaadinIcons) Version(de.catma.tag.Version) AnnotationWizard(de.catma.ui.module.analyze.visualization.kwic.annotation.AnnotationWizard) IconButton(de.catma.ui.component.IconButton) ExpansionListener(de.catma.ui.module.analyze.visualization.ExpansionListener) Set(java.util.Set) TagInstance(de.catma.tag.TagInstance) Collectors(java.util.stream.Collectors) MarginInfo(com.vaadin.shared.ui.MarginInfo) ItemClick(com.vaadin.ui.Grid.ItemClick) ItemClickListener(com.vaadin.ui.components.grid.ItemClickListener) TagReference(de.catma.document.annotation.TagReference) CacheLoader(com.google.common.cache.CacheLoader) List(java.util.List) Type(com.vaadin.ui.Notification.Type) TagDefinition(de.catma.tag.TagDefinition) CacheBuilder(com.google.common.cache.CacheBuilder) SelectionMode(com.vaadin.ui.Grid.SelectionMode) RBACPermission(de.catma.rbac.RBACPermission) StreamResource(com.vaadin.server.StreamResource) Range(de.catma.document.Range) ClickListener(com.vaadin.ui.Button.ClickListener) Column(com.vaadin.ui.Grid.Column) VerticalLayout(com.vaadin.ui.VerticalLayout) AnnotationCollectionManager(de.catma.document.annotation.AnnotationCollectionManager) LocalDateTime(java.time.LocalDateTime) Query(com.vaadin.data.provider.Query) WizardContext(de.catma.ui.dialog.wizard.WizardContext) ActionGridComponent(de.catma.ui.component.actiongrid.ActionGridComponent) ActionGridBar(de.catma.ui.component.actiongrid.ActionGridBar) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) EventBus(com.google.common.eventbus.EventBus) Registration(com.vaadin.shared.Registration) Notification(com.vaadin.ui.Notification) Label(com.vaadin.ui.Label) IDGenerator(de.catma.util.IDGenerator) SaveCancelListener(de.catma.ui.dialog.SaveCancelListener) CSVExportGroupedStreamSource(de.catma.ui.module.analyze.CSVExportGroupedStreamSource) ListDataProvider(com.vaadin.data.provider.ListDataProvider) ContentMode(com.vaadin.shared.ui.ContentMode) Property(de.catma.tag.Property) ClickEvent(com.vaadin.ui.Button.ClickEvent) AnnotationCollectionReference(de.catma.document.annotation.AnnotationCollectionReference) Project(de.catma.project.Project) QueryResultRow(de.catma.queryengine.result.QueryResultRow) SourceDocument(de.catma.document.source.SourceDocument) Visualization(de.catma.ui.module.analyze.visualization.Visualization) ContextMenu(com.vaadin.contextmenu.ContextMenu) QueryResultRowInAnnotateEvent(de.catma.ui.events.QueryResultRowInAnnotateEvent) DateTimeFormatter(java.time.format.DateTimeFormatter) FileDownloader(com.vaadin.server.FileDownloader) SerializablePredicate(com.vaadin.server.SerializablePredicate) HtmlRenderer(com.vaadin.ui.renderers.HtmlRenderer) CSVExportFlatStreamSource(de.catma.ui.module.analyze.CSVExportFlatStreamSource) AnnotationWizardContextKey(de.catma.ui.module.analyze.visualization.kwic.annotation.AnnotationWizardContextKey) Grid(com.vaadin.ui.Grid) TagQueryResultRow(de.catma.queryengine.result.TagQueryResultRow) QueryResultRow(de.catma.queryengine.result.QueryResultRow) ClickEvent(com.vaadin.ui.Button.ClickEvent) ActionGridBar(de.catma.ui.component.actiongrid.ActionGridBar) ContextMenu(com.vaadin.contextmenu.ContextMenu) MenuItem(com.vaadin.ui.MenuBar.MenuItem) SerializablePredicate(com.vaadin.server.SerializablePredicate) CSVExportFlatStreamSource(de.catma.ui.module.analyze.CSVExportFlatStreamSource) StreamResource(com.vaadin.server.StreamResource) FileDownloader(com.vaadin.server.FileDownloader) ItemClickListener(com.vaadin.ui.components.grid.ItemClickListener) ClickListener(com.vaadin.ui.Button.ClickListener)

Example 2 with CSVExportFlatStreamSource

use of de.catma.ui.module.analyze.CSVExportFlatStreamSource 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)2 ContextMenu (com.vaadin.contextmenu.ContextMenu)2 VaadinIcons (com.vaadin.icons.VaadinIcons)2 FileDownloader (com.vaadin.server.FileDownloader)2 SerializablePredicate (com.vaadin.server.SerializablePredicate)2 StreamResource (com.vaadin.server.StreamResource)2 Registration (com.vaadin.shared.Registration)2 ContentMode (com.vaadin.shared.ui.ContentMode)2 ClickEvent (com.vaadin.ui.Button.ClickEvent)2 ClickListener (com.vaadin.ui.Button.ClickListener)2 Column (com.vaadin.ui.Grid.Column)2 MenuItem (com.vaadin.ui.MenuBar.MenuItem)2 Notification (com.vaadin.ui.Notification)2 Type (com.vaadin.ui.Notification.Type)2 UI (com.vaadin.ui.UI)2 VerticalLayout (com.vaadin.ui.VerticalLayout)2 HtmlRenderer (com.vaadin.ui.renderers.HtmlRenderer)2 BackgroundServiceProvider (de.catma.backgroundservice.BackgroundServiceProvider)2 KwicProvider (de.catma.indexer.KwicProvider)2 Project (de.catma.project.Project)2