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);
}
}
Aggregations