Search in sources :

Example 6 with SingleTextInputDialog

use of de.catma.ui.dialog.SingleTextInputDialog in project catma by forTEXT.

the class AddMetadataStep method initActions.

private void initActions() {
    fileActionGridComponent.getActionGridBar().getBtnMoreOptionsContextMenu().addItem("Set author", menuItem -> {
        if (fileGrid.getSelectedItems().isEmpty()) {
            Notification.show("Info", "Please select one or more entries first!", Type.HUMANIZED_MESSAGE);
        } else {
            SingleTextInputDialog authorInputDialog = new SingleTextInputDialog("Set the author", "Author", result -> {
                fileGrid.getSelectedItems().forEach(uploadFile -> uploadFile.setAuthor(result));
                fileDataProvider.refreshAll();
            });
            authorInputDialog.show();
        }
    });
    fileActionGridComponent.getActionGridBar().getBtnMoreOptionsContextMenu().addItem("Set author", menuItem -> {
        if (fileGrid.getSelectedItems().isEmpty()) {
            Notification.show("Info", "Please select one or more entries first!", Type.HUMANIZED_MESSAGE);
        } else {
            SingleTextInputDialog publisherInputDialog = new SingleTextInputDialog("Set the publisher", "Publisher", result -> {
                fileGrid.getSelectedItems().forEach(uploadFile -> uploadFile.setPublisher(result));
                fileDataProvider.refreshAll();
            });
            publisherInputDialog.show();
        }
    });
    fileActionGridComponent.getActionGridBar().getBtnMoreOptionsContextMenu().addItem("Set description", menuItem -> {
        if (fileGrid.getSelectedItems().isEmpty()) {
            Notification.show("Info", "Please select one or more entries first!", Type.HUMANIZED_MESSAGE);
        } else {
            SingleTextInputDialog descriptionInputDialog = new SingleTextInputDialog("Set the description", "Description", result -> {
                fileGrid.getSelectedItems().forEach(uploadFile -> uploadFile.setDescription(result));
                fileDataProvider.refreshAll();
            });
            descriptionInputDialog.show();
        }
    });
}
Also used : SingleTextInputDialog(de.catma.ui.dialog.SingleTextInputDialog)

Example 7 with SingleTextInputDialog

use of de.catma.ui.dialog.SingleTextInputDialog in project catma by forTEXT.

the class AnnotationPanel method handelAddCollectionRequest.

private void handelAddCollectionRequest() {
    final SourceDocument document = currentDocumentProvider.get();
    if (document != null) {
        SingleTextInputDialog collectionNameDlg = new SingleTextInputDialog("Add Annotation Collection", "Please enter the Collection name:", new SaveCancelListener<String>() {

            @Override
            public void savePressed(String result) {
                project.createUserMarkupCollection(result, document);
            }
        });
        collectionNameDlg.show();
    } else {
        Notification.show("Info", "Please select a Document first!", Type.HUMANIZED_MESSAGE);
    }
}
Also used : SourceDocument(de.catma.document.source.SourceDocument) SingleTextInputDialog(de.catma.ui.dialog.SingleTextInputDialog)

Example 8 with SingleTextInputDialog

use of de.catma.ui.dialog.SingleTextInputDialog in project catma by forTEXT.

the class AnnotateResourcePanel method handleAddCollectionRequest.

private void handleAddCollectionRequest() {
    Set<DocumentTreeItem> selectedItems = documentTree.getSelectedItems();
    Set<SourceDocument> selectedDocuments = new HashSet<>();
    for (DocumentTreeItem resource : selectedItems) {
        DocumentTreeItem root = documentData.getParent(resource);
        if (root == null) {
            root = resource;
        }
        DocumentDataItem documentDataItem = (DocumentDataItem) root;
        selectedDocuments.add(documentDataItem.getDocument());
    }
    if (selectedDocuments.isEmpty()) {
        SourceDocument document = getSelectedDocument();
        if (document != null) {
            selectedDocuments.add(document);
        }
    }
    if (selectedDocuments.isEmpty()) {
        Notification.show("Info", "Please select at least one Document first!", Type.HUMANIZED_MESSAGE);
    } else {
        SingleTextInputDialog collectionNameDlg = new SingleTextInputDialog("Add Annotation Collection", "Please enter the Collection name:", new SaveCancelListener<String>() {

            @Override
            public void savePressed(String result) {
                for (SourceDocument document : selectedDocuments) {
                    project.createUserMarkupCollection(result, document);
                }
            }
        });
        collectionNameDlg.show();
    }
}
Also used : SourceDocument(de.catma.document.source.SourceDocument) SingleTextInputDialog(de.catma.ui.dialog.SingleTextInputDialog) HashSet(java.util.HashSet)

Example 9 with SingleTextInputDialog

use of de.catma.ui.dialog.SingleTextInputDialog in project catma by forTEXT.

the class CollectionSelectionStep method handleAddCollectionRequest.

private void handleAddCollectionRequest() {
    try {
        if (!project.hasPermission(project.getRoleOnProject(), RBACPermission.COLLECTION_CREATE)) {
            Notification.show("Info", "You do not have the permission to create Collections, please contact a Project maintainer!", Type.HUMANIZED_MESSAGE);
            return;
        }
        @SuppressWarnings("unchecked") TreeDataProvider<Resource> resourceDataProvider = (TreeDataProvider<Resource>) documentGrid.getDataProvider();
        Set<Resource> selectedResources = documentGrid.getSelectedItems();
        Set<SourceDocument> selectedDocuments = new HashSet<>();
        for (Resource resource : selectedResources) {
            Resource root = resourceDataProvider.getTreeData().getParent(resource);
            if (root == null) {
                root = resource;
            }
            DocumentResource documentResource = (DocumentResource) root;
            selectedDocuments.add(documentResource.getDocument());
        }
        if (!selectedDocuments.isEmpty()) {
            SingleTextInputDialog collectionNameDlg = new SingleTextInputDialog("Add Annotation Collection(s)", "Please enter the Collection name:", new SaveCancelListener<String>() {

                @Override
                public void savePressed(String result) {
                    for (SourceDocument document : selectedDocuments) {
                        project.createUserMarkupCollection(result, document);
                    }
                }
            });
            collectionNameDlg.show();
        } else {
            Notification.show("Info", "Please select one or more Documents first!", Type.HUMANIZED_MESSAGE);
        }
    } catch (Exception e) {
        ((ErrorHandler) UI.getCurrent()).showAndLogError("error adding a Collection", e);
    }
}
Also used : Resource(de.catma.ui.module.project.Resource) CollectionResource(de.catma.ui.module.project.CollectionResource) DocumentResource(de.catma.ui.module.project.DocumentResource) SourceDocument(de.catma.document.source.SourceDocument) SingleTextInputDialog(de.catma.ui.dialog.SingleTextInputDialog) DocumentResource(de.catma.ui.module.project.DocumentResource) TreeDataProvider(com.vaadin.data.provider.TreeDataProvider) HashSet(java.util.HashSet)

Example 10 with SingleTextInputDialog

use of de.catma.ui.dialog.SingleTextInputDialog in project catma by forTEXT.

the class ProjectView method handleAddTagsetRequest.

private void handleAddTagsetRequest() {
    SingleTextInputDialog collectionNameDlg = new SingleTextInputDialog("Add Tagset", "Please enter the Tagset name:", new SaveCancelListener<String>() {

        @Override
        public void savePressed(String result) {
            IDGenerator idGenerator = new IDGenerator();
            project.getTagManager().addTagsetDefinition(new TagsetDefinition(idGenerator.generateTagsetId(), result, new Version()));
        }
    });
    collectionNameDlg.show();
}
Also used : TagsetDefinition(de.catma.tag.TagsetDefinition) Version(de.catma.tag.Version) SingleTextInputDialog(de.catma.ui.dialog.SingleTextInputDialog) IDGenerator(de.catma.util.IDGenerator)

Aggregations

SingleTextInputDialog (de.catma.ui.dialog.SingleTextInputDialog)17 TagsetDefinition (de.catma.tag.TagsetDefinition)7 Version (de.catma.tag.Version)6 IOException (java.io.IOException)6 SourceDocument (de.catma.document.source.SourceDocument)5 IDGenerator (de.catma.util.IDGenerator)5 URISyntaxException (java.net.URISyntaxException)5 TreeDataProvider (com.vaadin.data.provider.TreeDataProvider)2 Pair (de.catma.util.Pair)2 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 List (java.util.List)2 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 ContextMenu (com.vaadin.contextmenu.ContextMenu)1 TreeData (com.vaadin.data.TreeData)1 SerializablePredicate (com.vaadin.server.SerializablePredicate)1 SelectionMode (com.vaadin.ui.Grid.SelectionMode)1