Search in sources :

Example 1 with AddSubtagDialog

use of de.catma.ui.module.tags.AddSubtagDialog in project catma by forTEXT.

the class AnnotationPanel method handleAddSubtagRequest.

private void handleAddSubtagRequest() {
    final List<TagDefinition> parentTags = tagsetGrid.getSelectedItems().stream().filter(tagsetTreeItem -> tagsetTreeItem instanceof TagDataItem).map(tagsetTreeItem -> ((TagDataItem) tagsetTreeItem).getTag()).collect(Collectors.toList());
    for (TagDefinition parentTag : parentTags) {
        if (!project.hasPermission(project.getRoleForTagset(parentTag.getTagsetDefinitionUuid()), RBACPermission.TAGSET_WRITE)) {
            Notification.show("Info", String.format("You do not have the permission to make changes to the Tagset of Tag %1$s, " + "Please contact the Project maintainer!", parentTag.getName()), Type.HUMANIZED_MESSAGE);
            return;
        }
    }
    if (!parentTags.isEmpty()) {
        AddSubtagDialog addTagDialog = new AddSubtagDialog(new SaveCancelListener<TagDefinition>() {

            public void savePressed(TagDefinition result) {
                for (TagDefinition parent : parentTags) {
                    TagsetDefinition tagset = project.getTagManager().getTagLibrary().getTagsetDefinition(parent);
                    TagDefinition tag = new TagDefinition(result);
                    tag.setUuid(idGenerator.generate());
                    tag.setParentUuid(parent.getUuid());
                    tag.setTagsetDefinitionUuid(tagset.getUuid());
                    project.getTagManager().addTagDefinition(tagset, tag);
                }
            }
        });
        addTagDialog.show();
    } else {
        Notification.show("Info", "Please select at least one parent Tag!", Type.HUMANIZED_MESSAGE);
    }
}
Also used : ArrayListMultimap(com.google.common.collect.ArrayListMultimap) BackgroundServiceProvider(de.catma.backgroundservice.BackgroundServiceProvider) VerticalSplitPanel(com.vaadin.ui.VerticalSplitPanel) Alignment(com.vaadin.ui.Alignment) UI(com.vaadin.ui.UI) XmlMarkupCollectionSerializationHandler(de.catma.serialization.intrinsic.xml.XmlMarkupCollectionSerializationHandler) SearchFilterProvider(de.catma.ui.component.actiongrid.SearchFilterProvider) ErrorHandler(de.catma.ui.module.main.ErrorHandler) TreeDataProvider(com.vaadin.data.provider.TreeDataProvider) VaadinIcons(com.vaadin.icons.VaadinIcons) IconButton(de.catma.ui.component.IconButton) Collection(java.util.Collection) Set(java.util.Set) TreeGrid(com.vaadin.ui.TreeGrid) Collectors(java.util.stream.Collectors) ItemClick(com.vaadin.ui.Grid.ItemClick) TagReference(de.catma.document.annotation.TagReference) Objects(java.util.Objects) List(java.util.List) Type(com.vaadin.ui.Notification.Type) RendererClickEvent(com.vaadin.ui.renderers.ClickableRenderer.RendererClickEvent) PropertyChangeListener(java.beans.PropertyChangeListener) TagDefinition(de.catma.tag.TagDefinition) Optional(java.util.Optional) SingleTextInputDialog(de.catma.ui.dialog.SingleTextInputDialog) CollectionChangeEvent(de.catma.project.event.CollectionChangeEvent) SelectionMode(com.vaadin.ui.Grid.SelectionMode) StyleGenerator(com.vaadin.ui.StyleGenerator) RBACPermission(de.catma.rbac.RBACPermission) PropertyDefinition(de.catma.tag.PropertyDefinition) VerticalLayout(com.vaadin.ui.VerticalLayout) AnnotationCollectionManager(de.catma.document.annotation.AnnotationCollectionManager) ComboBox(com.vaadin.ui.ComboBox) Multimap(com.google.common.collect.Multimap) ActionGridComponent(de.catma.ui.component.actiongrid.ActionGridComponent) Supplier(java.util.function.Supplier) ArrayList(java.util.ArrayList) EventBus(com.google.common.eventbus.EventBus) AddEditPropertyDialog(de.catma.ui.module.tags.AddEditPropertyDialog) MaterialTheme(com.github.appreciated.material.MaterialTheme) EditTagDialog(de.catma.ui.module.tags.EditTagDialog) Notification(com.vaadin.ui.Notification) Label(com.vaadin.ui.Label) TagsetDefinition(de.catma.tag.TagsetDefinition) Pair(de.catma.util.Pair) TreeGridFactory(de.catma.ui.component.TreeGridFactory) IDGenerator(de.catma.util.IDGenerator) Subscribe(com.google.common.eventbus.Subscribe) ButtonRenderer(com.vaadin.ui.renderers.ButtonRenderer) SaveCancelListener(de.catma.ui.dialog.SaveCancelListener) PropertyChangeEvent(java.beans.PropertyChangeEvent) ListDataProvider(com.vaadin.data.provider.ListDataProvider) TreeData(com.vaadin.data.TreeData) AnnotationCollectionReference(de.catma.document.annotation.AnnotationCollectionReference) Project(de.catma.project.Project) AddSubtagDialog(de.catma.ui.module.tags.AddSubtagDialog) IOException(java.io.IOException) AddParenttagDialog(de.catma.ui.module.tags.AddParenttagDialog) SourceDocument(de.catma.document.source.SourceDocument) AnnotationCollection(de.catma.document.annotation.AnnotationCollection) Annotation(de.catma.document.annotation.Annotation) TimeUnit(java.util.concurrent.TimeUnit) Consumer(java.util.function.Consumer) TagManagerEvent(de.catma.tag.TagManager.TagManagerEvent) ContextMenu(com.vaadin.contextmenu.ContextMenu) Button(com.vaadin.ui.Button) ChangeType(de.catma.project.event.ChangeType) HorizontalLayout(com.vaadin.ui.HorizontalLayout) SerializablePredicate(com.vaadin.server.SerializablePredicate) HtmlRenderer(com.vaadin.ui.renderers.HtmlRenderer) TagDefinition(de.catma.tag.TagDefinition) TagsetDefinition(de.catma.tag.TagsetDefinition) AddSubtagDialog(de.catma.ui.module.tags.AddSubtagDialog)

Aggregations

MaterialTheme (com.github.appreciated.material.MaterialTheme)1 ArrayListMultimap (com.google.common.collect.ArrayListMultimap)1 Multimap (com.google.common.collect.Multimap)1 EventBus (com.google.common.eventbus.EventBus)1 Subscribe (com.google.common.eventbus.Subscribe)1 ContextMenu (com.vaadin.contextmenu.ContextMenu)1 TreeData (com.vaadin.data.TreeData)1 ListDataProvider (com.vaadin.data.provider.ListDataProvider)1 TreeDataProvider (com.vaadin.data.provider.TreeDataProvider)1 VaadinIcons (com.vaadin.icons.VaadinIcons)1 SerializablePredicate (com.vaadin.server.SerializablePredicate)1 Alignment (com.vaadin.ui.Alignment)1 Button (com.vaadin.ui.Button)1 ComboBox (com.vaadin.ui.ComboBox)1 ItemClick (com.vaadin.ui.Grid.ItemClick)1 SelectionMode (com.vaadin.ui.Grid.SelectionMode)1 HorizontalLayout (com.vaadin.ui.HorizontalLayout)1 Label (com.vaadin.ui.Label)1 Notification (com.vaadin.ui.Notification)1 Type (com.vaadin.ui.Notification.Type)1