Search in sources :

Example 1 with ContextMenu

use of com.vaadin.contextmenu.ContextMenu in project catma by forTEXT.

the class ProjectView method initActions.

private void initActions() {
    documentGridComponent.setSearchFilterProvider(searchInput -> createSearchFilter(searchInput));
    documentGrid.addItemClickListener(itemClickEvent -> handleResourceItemClick(itemClickEvent));
    ContextMenu addContextMenu = documentGridComponent.getActionGridBar().getBtnAddContextMenu();
    MenuItem addDocumentBtn = addContextMenu.addItem("Add Document", clickEvent -> handleAddDocumentRequest());
    addDocumentBtn.setEnabled(false);
    rbacEnforcer.register(RBACConstraint.ifAuthorized(role -> (project.hasPermission(role, RBACPermission.DOCUMENT_CREATE_OR_UPLOAD)), () -> addDocumentBtn.setEnabled(true)));
    MenuItem addCollectionBtn = addContextMenu.addItem("Add Annotation Collection", e -> handleAddCollectionRequest());
    addCollectionBtn.setEnabled(false);
    rbacEnforcer.register(RBACConstraint.ifAuthorized(role -> (project.hasPermission(role, RBACPermission.COLLECTION_CREATE)), () -> addCollectionBtn.setEnabled(true)));
    ContextMenu documentsGridMoreOptionsContextMenu = documentGridComponent.getActionGridBar().getBtnMoreOptionsContextMenu();
    MenuItem editDocBtn = documentsGridMoreOptionsContextMenu.addItem("Edit Documents / Collections", (menuItem) -> handleEditResources());
    editDocBtn.setEnabled(false);
    rbacEnforcer.register(RBACConstraint.ifAuthorized(role -> (project.hasPermission(role, RBACPermission.COLLECTION_DELETE_OR_EDIT) || project.hasPermission(role, RBACPermission.DOCUMENT_DELETE_OR_EDIT)), () -> editDocBtn.setEnabled(true)));
    MenuItem deleteDocsBtn = documentsGridMoreOptionsContextMenu.addItem("Delete Documents / Collections", (menuItem) -> handleDeleteResources(menuItem, documentGrid));
    deleteDocsBtn.setEnabled(false);
    rbacEnforcer.register(RBACConstraint.ifAuthorized(role -> (project.hasPermission(role, RBACPermission.COLLECTION_DELETE_OR_EDIT) || project.hasPermission(role, RBACPermission.DOCUMENT_DELETE_OR_EDIT)), () -> deleteDocsBtn.setEnabled(true)));
    documentsGridMoreOptionsContextMenu.addItem("Analyze Documents / Collections", (menuItem) -> handleAnalyzeResources(menuItem, documentGrid));
    documentsGridMoreOptionsContextMenu.addItem("Import a Collection", mi -> handleImportCollectionRequest());
    MenuItem miExportCollections = documentsGridMoreOptionsContextMenu.addItem("Export Documents & Collections");
    StreamResource collectionXmlExportResource = new StreamResource(new CollectionXMLExportStreamSource(() -> getSelectedDocuments(), () -> documentGrid.getSelectedItems().stream().filter(resource -> resource.isCollection()).map(resource -> ((CollectionResource) resource).getCollectionReference()).collect(Collectors.toList()), () -> project), "CATMA-Corpus_Export-" + LocalDateTime.now().format(DateTimeFormatter.ISO_DATE_TIME) + ".tar.gz");
    collectionXmlExportResource.setCacheTime(0);
    collectionXmlExportResource.setMIMEType("application/gzip");
    FileDownloader collectionXmlExportFileDownloader = new FileDownloader(collectionXmlExportResource);
    collectionXmlExportFileDownloader.extend(miExportCollections);
    documentsGridMoreOptionsContextMenu.addItem("Select filtered entries", mi -> handleSelectFilteredDocuments());
    tagsetGridComponent.getActionGridBar().addBtnAddClickListener(click -> handleAddTagsetRequest());
    tagsetGridComponent.getActionGridBar().setAddBtnEnabled(false);
    rbacEnforcer.register(RBACConstraint.ifAuthorized(role -> project.hasPermission(role, RBACPermission.TAGSET_CREATE_OR_UPLOAD), () -> tagsetGridComponent.getActionGridBar().setAddBtnEnabled(true)));
    ContextMenu moreOptionsMenu = tagsetGridComponent.getActionGridBar().getBtnMoreOptionsContextMenu();
    MenuItem editTagset = moreOptionsMenu.addItem("Edit Tagset", mi -> handleEditTagsetRequest());
    editTagset.setEnabled(false);
    rbacEnforcer.register(RBACConstraint.ifAuthorized(role -> (project.hasPermission(role, RBACPermission.TAGSET_DELETE_OR_EDIT)), () -> editTagset.setEnabled(true)));
    MenuItem deleteTagSetBtn = moreOptionsMenu.addItem("Delete Tagset", mi -> handleDeleteTagsetRequest());
    deleteTagSetBtn.setEnabled(false);
    rbacEnforcer.register(RBACConstraint.ifAuthorized(role -> (project.hasPermission(role, RBACPermission.TAGSET_DELETE_OR_EDIT)), () -> deleteTagSetBtn.setEnabled(true)));
    MenuItem importTagSetBtn = moreOptionsMenu.addItem("Import Tagsets", mi -> handleImportTagsetsRequest());
    importTagSetBtn.setEnabled(false);
    rbacEnforcer.register(RBACConstraint.ifAuthorized(role -> (project.hasPermission(role, RBACPermission.TAGSET_CREATE_OR_UPLOAD)), () -> importTagSetBtn.setEnabled(true)));
    MenuItem miExportTagsets = moreOptionsMenu.addItem("Export Tagsets");
    MenuItem miExportTagsetsAsXML = miExportTagsets.addItem("as XML");
    StreamResource tagsetXmlExportResource = new StreamResource(new TagsetXMLExportStreamSource(() -> tagsetGrid.getSelectedItems(), () -> project), "CATMA-Tag-Library_Export-" + LocalDateTime.now().format(DateTimeFormatter.ISO_DATE_TIME) + ".xml");
    tagsetXmlExportResource.setCacheTime(0);
    tagsetXmlExportResource.setMIMEType("text/xml");
    FileDownloader tagsetXmlExportFileDownloader = new FileDownloader(tagsetXmlExportResource);
    tagsetXmlExportFileDownloader.extend(miExportTagsetsAsXML);
    MenuItem miExportTagsetsAsCSV = miExportTagsets.addItem("as CSV");
    StreamResource tagsetCsvExportResource = new StreamResource(new TagsetCSVExportStreamSource(() -> tagsetGrid.getSelectedItems(), () -> project), "CATMA-Tag-Library_Export-" + LocalDateTime.now().format(DateTimeFormatter.ISO_DATE_TIME) + ".csv");
    tagsetCsvExportResource.setCacheTime(0);
    tagsetCsvExportResource.setMIMEType("text/comma-separated-values");
    FileDownloader tagsetCsvExportFileDownloader = new FileDownloader(tagsetCsvExportResource);
    tagsetCsvExportFileDownloader.extend(miExportTagsetsAsCSV);
    moreOptionsMenu.addItem("Fork Tagsets into another Project", miForkTagset -> handleForkTagsetRequest());
    ContextMenu hugeCardMoreOptions = getMoreOptionsContextMenu();
    hugeCardMoreOptions.addItem("Commit all changes", mi -> handleCommitRequest());
    hugeCardMoreOptions.addItem("Synchronize with the team", mi -> handleSynchronizeRequest());
    hugeCardMoreOptions.addSeparator();
    hugeCardMoreOptions.addItem("Share project resources (experimental API)", mi -> handleShareProjectResources());
    MenuItem miImportCorpus = hugeCardMoreOptions.addItem("Import CATMA 5 Corpus", mi -> handleCorpusImport());
    miImportCorpus.setVisible(CATMAPropertyKey.EXPERT.getValue(false) || Boolean.valueOf(((CatmaApplication) UI.getCurrent()).getParameter(Parameter.EXPERT, Boolean.FALSE.toString())));
    btSynchBell.addClickListener(event -> handleBtSynchBellClick(event));
    // TODO:
    // hugeCardMoreOptions.addItem("Print status", e -> project.printStatus());
    tagsetGridComponent.setSearchFilterProvider(new SearchFilterProvider<TagsetDefinition>() {

        @Override
        public SerializablePredicate<TagsetDefinition> createSearchFilter(final String searchInput) {
            return new SerializablePredicate<TagsetDefinition>() {

                @Override
                public boolean test(TagsetDefinition t) {
                    if (t != null) {
                        String name = t.getName();
                        if (name != null) {
                            return name.toLowerCase().contains(searchInput.toLowerCase());
                        }
                    }
                    return false;
                }
            };
        }
    });
    tagsetGrid.addItemClickListener(clickEvent -> handleTagsetClick(clickEvent));
}
Also used : ArrayListMultimap(com.google.common.collect.ArrayListMultimap) BackgroundServiceProvider(de.catma.backgroundservice.BackgroundServiceProvider) HTMLNotification(de.catma.ui.component.HTMLNotification) Alignment(com.vaadin.ui.Alignment) IndexedProject(de.catma.indexer.IndexedProject) MembersChangedEvent(de.catma.ui.events.MembersChangedEvent) HeaderContextChangeEvent(de.catma.ui.events.HeaderContextChangeEvent) RouteToTagsEvent(de.catma.ui.events.routing.RouteToTagsEvent) TreeDataProvider(com.vaadin.data.provider.TreeDataProvider) TagsetImport(de.catma.ui.module.project.documentwizard.TagsetImport) DocumentChangeEvent(de.catma.project.event.DocumentChangeEvent) CorpusImporter(de.catma.ui.module.project.corpusimport.CorpusImporter) CommitInfo(de.catma.project.CommitInfo) ExecutionListener(de.catma.backgroundservice.ExecutionListener) MenuBar(com.vaadin.ui.MenuBar) VerticalFlexLayout(de.catma.ui.layout.VerticalFlexLayout) Set(java.util.Set) RBACConstraint(de.catma.rbac.RBACConstraint) TagInstance(de.catma.tag.TagInstance) CorpusImportDocumentMetadata(de.catma.ui.module.project.corpusimport.CorpusImportDocumentMetadata) ItemClick(com.vaadin.ui.Grid.ItemClick) Stream(java.util.stream.Stream) Type(com.vaadin.ui.Notification.Type) PropertyChangeListener(java.beans.PropertyChangeListener) SingleTextInputDialog(de.catma.ui.dialog.SingleTextInputDialog) CollectionChangeEvent(de.catma.project.event.CollectionChangeEvent) CanReloadAll(de.catma.ui.module.main.CanReloadAll) SelectionMode(com.vaadin.ui.Grid.SelectionMode) DocumentWizard(de.catma.ui.module.project.documentwizard.DocumentWizard) HugeCard(de.catma.ui.component.hugecard.HugeCard) ProjectChangedEvent(de.catma.ui.events.ProjectChangedEvent) DefaultProgressCallable(de.catma.backgroundservice.DefaultProgressCallable) TagManager(de.catma.tag.TagManager) com.vaadin.server(com.vaadin.server) LocalDateTime(java.time.LocalDateTime) WizardContext(de.catma.ui.dialog.wizard.WizardContext) ActionGridComponent(de.catma.ui.component.actiongrid.ActionGridComponent) ArrayList(java.util.ArrayList) Member(de.catma.user.Member) Pair(de.catma.util.Pair) TreeGridFactory(de.catma.ui.component.TreeGridFactory) SaveCancelListener(de.catma.ui.dialog.SaveCancelListener) Collator(java.text.Collator) ProgressListener(de.catma.backgroundservice.ProgressListener) XML2ContentHandler(de.catma.document.source.contenthandler.XML2ContentHandler) Property(de.catma.tag.Property) TreeData(com.vaadin.data.TreeData) IOException(java.io.IOException) SourceDocument(de.catma.document.source.SourceDocument) ProjectReadyEvent(de.catma.project.event.ProjectReadyEvent) AnnotationCollection(de.catma.document.annotation.AnnotationCollection) File(java.io.File) TagManagerEvent(de.catma.tag.TagManager.TagManagerEvent) Button(com.vaadin.ui.Button) ChangeType(de.catma.project.event.ChangeType) CRC32(java.util.zip.CRC32) HtmlRenderer(com.vaadin.ui.renderers.HtmlRenderer) Grid(com.vaadin.ui.Grid) MenuItem(com.vaadin.ui.MenuBar.MenuItem) GenericUploadDialog(de.catma.ui.dialog.GenericUploadDialog) URISyntaxException(java.net.URISyntaxException) UI(com.vaadin.ui.UI) FlexWrap(de.catma.ui.layout.FlexLayout.FlexWrap) ConfirmDialog(org.vaadin.dialogs.ConfirmDialog) SearchFilterProvider(de.catma.ui.component.actiongrid.SearchFilterProvider) RouteToAnalyzeEvent(de.catma.ui.events.routing.RouteToAnalyzeEvent) TikaContentHandler(de.catma.document.source.contenthandler.TikaContentHandler) ByteArrayInputStream(java.io.ByteArrayInputStream) HorizontalFlexLayout(de.catma.ui.layout.HorizontalFlexLayout) ErrorHandler(de.catma.ui.module.main.ErrorHandler) Locale(java.util.Locale) CatmaApplication(de.catma.ui.CatmaApplication) VaadinIcons(com.vaadin.icons.VaadinIcons) Version(de.catma.tag.Version) RouteToConflictedProjectEvent(de.catma.ui.events.routing.RouteToConflictedProjectEvent) ProgressBar(com.vaadin.ui.ProgressBar) IconButton(de.catma.ui.component.IconButton) CATMAPropertyKey(de.catma.properties.CATMAPropertyKey) Collection(java.util.Collection) TreeGrid(com.vaadin.ui.TreeGrid) Logger(java.util.logging.Logger) Collectors(java.util.stream.Collectors) SourceDocumentInfo(de.catma.document.source.SourceDocumentInfo) ProjectReference(de.catma.project.ProjectReference) TagReference(de.catma.document.annotation.TagReference) List(java.util.List) CloseSafe(de.catma.util.CloseSafe) Corpus(de.catma.document.corpus.Corpus) TagDefinition(de.catma.tag.TagDefinition) RBACConstraintEnforcer(de.catma.rbac.RBACConstraintEnforcer) RouteToAnnotateEvent(de.catma.ui.events.routing.RouteToAnnotateEvent) Optional(java.util.Optional) FileType(de.catma.document.source.FileType) RBACPermission(de.catma.rbac.RBACPermission) CorpusImportDialog(de.catma.ui.module.project.corpusimport.CorpusImportDialog) ProjectManager(de.catma.project.ProjectManager) PropertyDefinition(de.catma.tag.PropertyDefinition) UploadFile(de.catma.ui.module.project.documentwizard.UploadFile) RBACRole(de.catma.rbac.RBACRole) Multimap(com.google.common.collect.Multimap) Function(java.util.function.Function) User(de.catma.user.User) Level(java.util.logging.Level) HashSet(java.util.HashSet) EventBus(com.google.common.eventbus.EventBus) Charset(java.nio.charset.Charset) Notification(com.vaadin.ui.Notification) Label(com.vaadin.ui.Label) TagsetDefinition(de.catma.tag.TagsetDefinition) IDGenerator(de.catma.util.IDGenerator) Subscribe(com.google.common.eventbus.Subscribe) TagLibrary(de.catma.tag.TagLibrary) PropertyChangeEvent(java.beans.PropertyChangeEvent) OpenProjectListener(de.catma.project.OpenProjectListener) ListDataProvider(com.vaadin.data.provider.ListDataProvider) FileOSType(de.catma.document.source.FileOSType) ClickEvent(com.vaadin.ui.Button.ClickEvent) AnnotationCollectionReference(de.catma.document.annotation.AnnotationCollectionReference) Project(de.catma.project.Project) RepositoryChangeEvent(de.catma.project.Project.RepositoryChangeEvent) ConflictedProject(de.catma.project.conflict.ConflictedProject) TagsetDefinitionImportStatus(de.catma.serialization.TagsetDefinitionImportStatus) ContextMenu(com.vaadin.contextmenu.ContextMenu) SourceContentHandler(de.catma.document.source.contenthandler.SourceContentHandler) TagsetImportState(de.catma.ui.module.project.documentwizard.TagsetImportState) BOMFilterInputStream(de.catma.document.source.contenthandler.BOMFilterInputStream) DateTimeFormatter(java.time.format.DateTimeFormatter) HierarchicalQuery(com.vaadin.data.provider.HierarchicalQuery) Parameter(de.catma.ui.Parameter) Comparator(java.util.Comparator) Collections(java.util.Collections) BackgroundService(de.catma.backgroundservice.BackgroundService) InputStream(java.io.InputStream) Component(com.vaadin.ui.Component) ContextMenu(com.vaadin.contextmenu.ContextMenu) MenuItem(com.vaadin.ui.MenuBar.MenuItem) TagsetDefinition(de.catma.tag.TagsetDefinition)

Example 2 with ContextMenu

use of com.vaadin.contextmenu.ContextMenu in project catma by forTEXT.

the class TagsView method initActions.

private void initActions() {
    tagsetGrid.addColumn(tagsetTreeItem -> tagsetTreeItem.getColor(), new HtmlRenderer()).setCaption("Tagsets").setSortable(false).setWidth(200);
    tagsetGrid.setHierarchyColumn(tagsetGrid.addColumn(tagsetTreeItem -> tagsetTreeItem.getName()).setCaption("Tags").setSortable(false).setWidth(300));
    ButtonRenderer<TagsetTreeItem> propertySummaryRenderer = new ButtonRenderer<>(rendererClickEvent -> handlePropertySummaryClickEvent(rendererClickEvent));
    propertySummaryRenderer.setHtmlContentAllowed(true);
    tagsetGrid.addColumn(tagsetTreeItem -> tagsetTreeItem.getPropertySummary(), propertySummaryRenderer).setCaption("Properties").setSortable(false).setHidable(true).setWidth(300);
    tagsetGrid.addColumn(tagsetTreeItem -> tagsetTreeItem.getPropertyValue()).setCaption("Values").setSortable(false).setHidable(true).setWidth(300);
    ButtonRenderer<TagsetTreeItem> btRemovalRenderer = new ButtonRenderer<>(rendererClickEvent -> handleTagsetTreeItemRemovalRequest(rendererClickEvent));
    btRemovalRenderer.setHtmlContentAllowed(true);
    tagsetGrid.addColumn(tagsetTreeItem -> tagsetTreeItem.getRemoveIcon()).setRenderer(btRemovalRenderer).setSortable(false).setHidable(false).setExpandRatio(1);
    tagsetGrid.setStyleGenerator(new StyleGenerator<TagsetTreeItem>() {

        @Override
        public String apply(TagsetTreeItem item) {
            return item.generateStyle();
        }
    });
    tagsetGridComponent.setSearchFilterProvider(new SearchFilterProvider<TagsetTreeItem>() {

        @Override
        public SerializablePredicate<TagsetTreeItem> createSearchFilter(String searchInput) {
            return new TagsetSearchFilterProvider(searchInput, tagsetData);
        }
    });
    tagsetGrid.addExpandListener(expandEvent -> handleExpandCollapseTagset(expandEvent.getExpandedItem(), true));
    tagsetGrid.addCollapseListener(collapseEvent -> handleExpandCollapseTagset(collapseEvent.getCollapsedItem(), false));
    ContextMenu addContextMenu = tagsetGridComponent.getActionGridBar().getBtnAddContextMenu();
    addContextMenu.addItem("Add Tagset", clickEvent -> handleAddTagsetRequest());
    addContextMenu.addItem("Add Tag", clickEvent -> handleAddTagRequest());
    addContextMenu.addItem("Add Subtag", clickEvent -> handleAddSubtagRequest());
    addContextMenu.addItem("Add Property", clickEvent -> handleAddPropertyRequest());
    ContextMenu moreOptionsContextMenu = tagsetGridComponent.getActionGridBar().getBtnMoreOptionsContextMenu();
    moreOptionsContextMenu.addItem("Edit Tag", clickEvent -> handleEditTagRequest());
    moreOptionsContextMenu.addItem("Delete Tag", clickEvent -> handleDeleteTagRequest());
    moreOptionsContextMenu.addItem("Edit/Delete Properties", clickEvent -> handleEditPropertiesRequest());
    moreOptionsContextMenu.addItem("Edit Tagset", clickEvent -> handleEditTagsetRequest());
    moreOptionsContextMenu.addItem("Delete Tagset", clickEvent -> handleDeleteTagsetRequest());
    resourcePanel.setTagsetSelectionListener(selectedTagsets -> {
        tagsets.clear();
        tagsets.addAll(selectedTagsets);
        initData();
    });
}
Also used : ArrayListMultimap(com.google.common.collect.ArrayListMultimap) PropertyDefinition(de.catma.tag.PropertyDefinition) UI(com.vaadin.ui.UI) ConfirmDialog(org.vaadin.dialogs.ConfirmDialog) Multimap(com.google.common.collect.Multimap) ActionGridComponent(de.catma.ui.component.actiongrid.ActionGridComponent) SearchFilterProvider(de.catma.ui.component.actiongrid.SearchFilterProvider) ArrayList(java.util.ArrayList) EventBus(com.google.common.eventbus.EventBus) MaterialTheme(com.github.appreciated.material.MaterialTheme) Notification(com.vaadin.ui.Notification) ErrorHandler(de.catma.ui.module.main.ErrorHandler) Label(com.vaadin.ui.Label) TagsetDefinition(de.catma.tag.TagsetDefinition) SliderPanel(org.vaadin.sliderpanel.SliderPanel) TreeDataProvider(com.vaadin.data.provider.TreeDataProvider) Pair(de.catma.util.Pair) Version(de.catma.tag.Version) TreeGridFactory(de.catma.ui.component.TreeGridFactory) IDGenerator(de.catma.util.IDGenerator) ButtonRenderer(com.vaadin.ui.renderers.ButtonRenderer) SaveCancelListener(de.catma.ui.dialog.SaveCancelListener) PropertyChangeEvent(java.beans.PropertyChangeEvent) TreeData(com.vaadin.data.TreeData) Project(de.catma.project.Project) Collection(java.util.Collection) Set(java.util.Set) IOException(java.io.IOException) TreeGrid(com.vaadin.ui.TreeGrid) Collectors(java.util.stream.Collectors) TagManagerEvent(de.catma.tag.TagManager.TagManagerEvent) ContextMenu(com.vaadin.contextmenu.ContextMenu) List(java.util.List) Type(com.vaadin.ui.Notification.Type) RendererClickEvent(com.vaadin.ui.renderers.ClickableRenderer.RendererClickEvent) PropertyChangeListener(java.beans.PropertyChangeListener) HorizontalLayout(com.vaadin.ui.HorizontalLayout) TagDefinition(de.catma.tag.TagDefinition) SerializablePredicate(com.vaadin.server.SerializablePredicate) Optional(java.util.Optional) HtmlRenderer(com.vaadin.ui.renderers.HtmlRenderer) SingleTextInputDialog(de.catma.ui.dialog.SingleTextInputDialog) SliderPanelBuilder(org.vaadin.sliderpanel.SliderPanelBuilder) SelectionMode(com.vaadin.ui.Grid.SelectionMode) StyleGenerator(com.vaadin.ui.StyleGenerator) RBACPermission(de.catma.rbac.RBACPermission) SliderMode(org.vaadin.sliderpanel.client.SliderMode) HugeCard(de.catma.ui.component.hugecard.HugeCard) HtmlRenderer(com.vaadin.ui.renderers.HtmlRenderer) SerializablePredicate(com.vaadin.server.SerializablePredicate) ContextMenu(com.vaadin.contextmenu.ContextMenu) ButtonRenderer(com.vaadin.ui.renderers.ButtonRenderer)

Example 3 with ContextMenu

use of com.vaadin.contextmenu.ContextMenu 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 4 with ContextMenu

use of com.vaadin.contextmenu.ContextMenu in project catma by forTEXT.

the class QueryResultPanel method createButtonBar.

private void createButtonBar(boolean cardStyle) {
    buttonPanel = new HorizontalLayout();
    buttonPanel.setWidth("100%");
    searchField = new TextField();
    searchField.setPlaceholder("\u2315");
    buttonPanel.addComponent(searchField);
    buttonPanel.setComponentAlignment(searchField, Alignment.MIDDLE_RIGHT);
    buttonPanel.setExpandRatio(searchField, 1f);
    caretRightBt = new IconButton(VaadinIcons.CARET_RIGHT);
    caretRightBt.setVisible(cardStyle);
    caretDownBt = new IconButton(VaadinIcons.CARET_DOWN);
    caretDownBt.setVisible(cardStyle);
    optionsBt = new IconButton(VaadinIcons.ELLIPSIS_DOTS_V);
    optionsMenu = new ContextMenu(optionsBt, true);
    removeBt = new IconButton(VaadinIcons.ERASER);
    buttonPanel.addComponents(removeBt, optionsBt, caretRightBt);
    buttonPanel.setComponentAlignment(caretRightBt, Alignment.MIDDLE_RIGHT);
    buttonPanel.setComponentAlignment(optionsBt, Alignment.MIDDLE_RIGHT);
    buttonPanel.setComponentAlignment(removeBt, Alignment.MIDDLE_RIGHT);
    if (cardStyle) {
        buttonPanel.addStyleName("analyze-card-buttonbar");
        searchField.setEnabled(false);
    } else {
        buttonPanel.addStyleName("analyze-query-result-panel-buttonbar");
    }
    addComponent(buttonPanel);
}
Also used : IconButton(de.catma.ui.component.IconButton) TextField(com.vaadin.ui.TextField) ContextMenu(com.vaadin.contextmenu.ContextMenu) HorizontalLayout(com.vaadin.ui.HorizontalLayout)

Example 5 with ContextMenu

use of com.vaadin.contextmenu.ContextMenu in project catma by forTEXT.

the class CollectionSelectionStep method initActions.

private void initActions() {
    documentGridComponent.setSearchFilterProvider(searchInput -> createSearchFilter(searchInput));
    documentGridComponent.getActionGridBar().addBtnAddClickListener(clickEvent -> handleAddCollectionRequest());
    ContextMenu documentsGridMoreOptionsContextMenu = documentGridComponent.getActionGridBar().getBtnMoreOptionsContextMenu();
    documentsGridMoreOptionsContextMenu.addItem("Select filtered Documents", mi -> handleSelectFilteredDocuments());
    documentsGridMoreOptionsContextMenu.addItem("Select filtered Collections", mi -> handleSelectFilteredCollections());
    documentGrid.addSelectionListener(event -> {
        if (stepChangeListener != null) {
            stepChangeListener.stepChanged(this);
        }
    });
}
Also used : ContextMenu(com.vaadin.contextmenu.ContextMenu)

Aggregations

ContextMenu (com.vaadin.contextmenu.ContextMenu)10 SelectionMode (com.vaadin.ui.Grid.SelectionMode)6 Label (com.vaadin.ui.Label)6 Notification (com.vaadin.ui.Notification)6 Type (com.vaadin.ui.Notification.Type)6 UI (com.vaadin.ui.UI)6 HtmlRenderer (com.vaadin.ui.renderers.HtmlRenderer)6 Project (de.catma.project.Project)6 RBACPermission (de.catma.rbac.RBACPermission)6 TagDefinition (de.catma.tag.TagDefinition)6 ActionGridComponent (de.catma.ui.component.actiongrid.ActionGridComponent)6 SearchFilterProvider (de.catma.ui.component.actiongrid.SearchFilterProvider)6 SaveCancelListener (de.catma.ui.dialog.SaveCancelListener)6 ErrorHandler (de.catma.ui.module.main.ErrorHandler)6 IDGenerator (de.catma.util.IDGenerator)6 List (java.util.List)6 Collectors (java.util.stream.Collectors)6 EventBus (com.google.common.eventbus.EventBus)5 TreeData (com.vaadin.data.TreeData)5 TreeDataProvider (com.vaadin.data.provider.TreeDataProvider)5