Search in sources :

Example 1 with SingleTextInputDialog

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

the class ProjectView method handleEditTagsetRequest.

private void handleEditTagsetRequest() {
    final Set<TagsetDefinition> tagsets = tagsetGrid.getSelectedItems();
    if (!tagsets.isEmpty()) {
        final TagsetDefinition tagset = tagsets.iterator().next();
        SingleTextInputDialog tagsetNameDlg = new SingleTextInputDialog("Edit Tagset", "Please enter the new Tagset name:", tagset.getName(), new SaveCancelListener<String>() {

            @Override
            public void savePressed(String result) {
                project.getTagManager().setTagsetDefinitionName(tagset, result);
            }
        });
        tagsetNameDlg.show();
    } else {
        Notification.show("Info", "Please select a Tagset first!", Type.HUMANIZED_MESSAGE);
    }
}
Also used : TagsetDefinition(de.catma.tag.TagsetDefinition) SingleTextInputDialog(de.catma.ui.dialog.SingleTextInputDialog)

Example 2 with SingleTextInputDialog

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

the class ProjectView method handleAddCollectionRequest.

private void handleAddCollectionRequest() {
    Set<SourceDocument> selectedDocuments = getSelectedDocuments();
    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);
    }
}
Also used : SourceDocument(de.catma.document.source.SourceDocument) SingleTextInputDialog(de.catma.ui.dialog.SingleTextInputDialog)

Example 3 with SingleTextInputDialog

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

the class ProjectView method handleCorpusImport.

private void handleCorpusImport() {
    try {
        if (project.hasUncommittedChanges()) {
            SingleTextInputDialog dlg = new SingleTextInputDialog("Commit all changes", "You have changes, that need to be committed first, please enter a short description for this commit:", commitMsg -> {
                try {
                    project.commitChanges(commitMsg);
                    importCollection();
                } catch (Exception e) {
                    setEnabled(true);
                    ((ErrorHandler) UI.getCurrent()).showAndLogError("error committing changes", e);
                }
            });
            dlg.show();
        } else {
            CorpusImportDialog corpusImportDialog = new CorpusImportDialog(new SaveCancelListener<Pair<File, List<CorpusImportDocumentMetadata>>>() {

                @Override
                public void savePressed(Pair<File, List<CorpusImportDocumentMetadata>> result) {
                    importCorpus(result.getFirst(), result.getSecond());
                }
            });
            corpusImportDialog.show();
        }
    } catch (Exception e) {
        errorHandler.showAndLogError("Error accessing Project!", e);
    }
}
Also used : CorpusImportDocumentMetadata(de.catma.ui.module.project.corpusimport.CorpusImportDocumentMetadata) CorpusImportDialog(de.catma.ui.module.project.corpusimport.CorpusImportDialog) ArrayList(java.util.ArrayList) List(java.util.List) SingleTextInputDialog(de.catma.ui.dialog.SingleTextInputDialog) File(java.io.File) UploadFile(de.catma.ui.module.project.documentwizard.UploadFile) IOException(java.io.IOException) URISyntaxException(java.net.URISyntaxException) Pair(de.catma.util.Pair)

Example 4 with SingleTextInputDialog

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

the class ProjectView method handleEditResources.

private void handleEditResources() {
    final Set<Resource> selectedResources = documentGrid.getSelectedItems();
    if (selectedResources.isEmpty()) {
        Notification.show("Info", "Please select a resource first!", Type.HUMANIZED_MESSAGE);
    } else {
        final Resource resource = selectedResources.iterator().next();
        if (selectedResources.size() > 1) {
            documentGridComponent.setSelectionMode(SelectionMode.SINGLE);
        }
        if (resource.isCollection()) {
            final AnnotationCollectionReference collectionRef = ((CollectionResource) selectedResources.iterator().next()).getCollectionReference();
            SingleTextInputDialog collectionNameDlg = new SingleTextInputDialog("Edit Collection", "Please enter the new collection name:", new SaveCancelListener<String>() {

                @Override
                public void savePressed(String result) {
                    collectionRef.getContentInfoSet().setTitle(result);
                    try {
                        project.update(collectionRef, collectionRef.getContentInfoSet());
                        documentGrid.getDataProvider().refreshItem(resource);
                    } catch (Exception e) {
                        errorHandler.showAndLogError("Error updating collection", e);
                    }
                }
            });
            collectionNameDlg.show();
        } else {
            final SourceDocument document = ((DocumentResource) selectedResources.iterator().next()).getDocument();
            SingleTextInputDialog collectionNameDlg = new SingleTextInputDialog("Edit Document", "Please enter the new document name:", new SaveCancelListener<String>() {

                @Override
                public void savePressed(String result) {
                    document.getSourceContentHandler().getSourceDocumentInfo().getContentInfoSet().setTitle(result);
                    try {
                        project.update(document, document.getSourceContentHandler().getSourceDocumentInfo().getContentInfoSet());
                    } catch (Exception e) {
                        errorHandler.showAndLogError("Error updating document", e);
                    }
                }
            });
            collectionNameDlg.show();
        }
    }
}
Also used : SourceDocument(de.catma.document.source.SourceDocument) AnnotationCollectionReference(de.catma.document.annotation.AnnotationCollectionReference) SingleTextInputDialog(de.catma.ui.dialog.SingleTextInputDialog) IOException(java.io.IOException) URISyntaxException(java.net.URISyntaxException)

Example 5 with SingleTextInputDialog

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

the class TagsView method handleEditTagsetRequest.

private void handleEditTagsetRequest() {
    if (project.isAuthorizedOnProject(RBACPermission.TAGSET_DELETE_OR_EDIT)) {
        Collection<TagsetDefinition> selectedTagsets = tagsetGrid.getSelectedItems().stream().filter(tagsetTreeItem -> tagsetTreeItem instanceof TagsetDataItem).map(tagsetDataItem -> ((TagsetDataItem) tagsetDataItem).getTagset()).collect(Collectors.toList());
        if (!selectedTagsets.isEmpty()) {
            final TagsetDefinition tagset = selectedTagsets.iterator().next();
            SingleTextInputDialog tagsetNameDlg = new SingleTextInputDialog("Edit Tagset", "Please enter the new Tagset name:", tagset.getName(), new SaveCancelListener<String>() {

                @Override
                public void savePressed(String result) {
                    project.getTagManager().setTagsetDefinitionName(tagset, result);
                }
            });
            tagsetNameDlg.show();
        } else {
            Notification.show("Info", "Please select a Tagset first!", Type.HUMANIZED_MESSAGE);
        }
    } else {
        Notification.show("Info", "You do not have the permission to edit Tagsets! " + "Please contact the Project maintainer for changes!", Type.HUMANIZED_MESSAGE);
    }
}
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) TagsetDefinition(de.catma.tag.TagsetDefinition) SingleTextInputDialog(de.catma.ui.dialog.SingleTextInputDialog)

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