Search in sources :

Example 11 with ErrorHandler

use of de.catma.ui.module.main.ErrorHandler in project catma by forTEXT.

the class AnnotationDetailsPanel method handleEditAnnotationRequest.

private void handleEditAnnotationRequest(RendererClickEvent<AnnotationTreeItem> clickEvent) {
    AnnotationDataItem item = (AnnotationDataItem) clickEvent.getItem();
    final Annotation annotation = item.getAnnotation();
    if (project.hasPermission(project.getRoleForCollection(annotation.getUserMarkupCollection().getUuid()), RBACPermission.COLLECTION_WRITE)) {
        String tagId = annotation.getTagInstance().getTagDefinitionId();
        TagDefinition tag = project.getTagManager().getTagLibrary().getTagDefinition(tagId);
        if (tag.getUserDefinedPropertyDefinitions().isEmpty()) {
            Notification.show("Info", "There are no Properties defined for the Tag of this Annotation!", Type.HUMANIZED_MESSAGE);
        } else {
            EditAnnotationPropertiesDialog editAnnotationPropertiesDialog = new EditAnnotationPropertiesDialog(project, annotation, new SaveCancelListener<List<Property>>() {

                @Override
                public void savePressed(List<Property> result) {
                    try {
                        collectionManager.updateProperty(annotation.getUserMarkupCollection(), annotation.getTagInstance(), result);
                    } catch (IOException e) {
                        ((ErrorHandler) UI.getCurrent()).showAndLogError("error updating Annotation Properties", e);
                    }
                }
            });
            editAnnotationPropertiesDialog.show();
        }
    } else {
        Notification.show("Info", "You do not have the permission to make changes to the Collection of this Annotation, " + "please contact the Project maintainer!", Type.HUMANIZED_MESSAGE);
    }
}
Also used : TagDefinition(de.catma.tag.TagDefinition) ErrorHandler(de.catma.ui.module.main.ErrorHandler) List(java.util.List) ArrayList(java.util.ArrayList) IOException(java.io.IOException) Property(de.catma.tag.Property) Annotation(de.catma.document.annotation.Annotation)

Aggregations

ErrorHandler (de.catma.ui.module.main.ErrorHandler)11 UI (com.vaadin.ui.UI)8 ArrayList (java.util.ArrayList)8 List (java.util.List)8 Label (com.vaadin.ui.Label)6 Notification (com.vaadin.ui.Notification)6 Type (com.vaadin.ui.Notification.Type)6 VerticalLayout (com.vaadin.ui.VerticalLayout)6 SourceDocument (de.catma.document.source.SourceDocument)6 Project (de.catma.project.Project)6 Set (java.util.Set)6 Collectors (java.util.stream.Collectors)6 BackgroundServiceProvider (de.catma.backgroundservice.BackgroundServiceProvider)5 AnnotationCollectionReference (de.catma.document.annotation.AnnotationCollectionReference)5 TagDefinition (de.catma.tag.TagDefinition)5 ActionGridComponent (de.catma.ui.component.actiongrid.ActionGridComponent)5 Collection (java.util.Collection)5 EventBus (com.google.common.eventbus.EventBus)4 ListDataProvider (com.vaadin.data.provider.ListDataProvider)4 VaadinIcons (com.vaadin.icons.VaadinIcons)4