Search in sources :

Example 26 with PropertyDefinition

use of de.catma.tag.PropertyDefinition in project catma by forTEXT.

the class TagsView method showExpandedPossibleValues.

private void showExpandedPossibleValues(PropertyDataItem propertyDataItem) {
    PropertyDefinition propertyDefinition = propertyDataItem.getPropertyDefinition();
    for (String possibleValue : propertyDefinition.getPossibleValueList()) {
        tagsetGrid.getTreeData().addItem(propertyDataItem, new PossibleValueDataItem(possibleValue, propertyDataItem.isEditable()));
    }
    tagsetGrid.expand(propertyDataItem);
}
Also used : PropertyDefinition(de.catma.tag.PropertyDefinition)

Example 27 with PropertyDefinition

use of de.catma.tag.PropertyDefinition in project catma by forTEXT.

the class TagsView method handleSingleEditProperties.

private void handleSingleEditProperties(List<PropertyDefinition> editedPropertyDefs, TagDefinition tag) {
    TagsetDefinition tagset = project.getTagManager().getTagLibrary().getTagsetDefinition(tag);
    for (PropertyDefinition existingPropertyDef : new ArrayList<>(tag.getUserDefinedPropertyDefinitions())) {
        // handle deleted PropertyDefs
        if (!editedPropertyDefs.contains(existingPropertyDef)) {
            project.getTagManager().removeUserDefinedPropertyDefinition(existingPropertyDef, tag, tagset);
        } else // handle updated PropertyDefs
        {
            editedPropertyDefs.stream().filter(possiblyChangedPd -> possiblyChangedPd.getUuid().equals(existingPropertyDef.getUuid())).findFirst().ifPresent(editedPropertyDef -> {
                if (!existingPropertyDef.getName().equals(editedPropertyDef.getName()) || !existingPropertyDef.getPossibleValueList().equals(editedPropertyDef.getPossibleValueList())) {
                    existingPropertyDef.setName(editedPropertyDef.getName());
                    existingPropertyDef.setPossibleValueList(editedPropertyDef.getPossibleValueList());
                    project.getTagManager().updateUserDefinedPropertyDefinition(tag, existingPropertyDef);
                }
            });
        }
    }
    // handle created PropertyDefs
    for (PropertyDefinition pd : editedPropertyDefs) {
        if (tag.getPropertyDefinitionByUuid(pd.getUuid()) == null) {
            PropertyDefinition createdPropertyDefinition = new PropertyDefinition(pd);
            pd.setUuid(idGenerator.generate());
            project.getTagManager().addUserDefinedPropertyDefinition(tag, createdPropertyDefinition);
        }
    }
}
Also used : TagsetDefinition(de.catma.tag.TagsetDefinition) ArrayList(java.util.ArrayList) PropertyDefinition(de.catma.tag.PropertyDefinition)

Example 28 with PropertyDefinition

use of de.catma.tag.PropertyDefinition in project catma by forTEXT.

the class TagsView method showExpandedProperties.

private void showExpandedProperties(TagDataItem tagDataItem) {
    TagDefinition tag = tagDataItem.getTag();
    PropertyDataItem lastPropertyDataItem = null;
    for (PropertyDefinition propertyDefinition : tag.getUserDefinedPropertyDefinitions()) {
        lastPropertyDataItem = new PropertyDataItem(propertyDefinition, tagDataItem.isEditable());
        tagsetGrid.getTreeData().addItem(tagDataItem, lastPropertyDataItem);
    }
    List<TagsetTreeItem> children = tagsetData.getChildren(tagDataItem).stream().filter(tagsetTreeItem -> tagsetTreeItem instanceof TagDataItem).collect(Collectors.toList());
    for (int i = children.size() - 1; i >= 0; i--) {
        tagsetData.moveAfterSibling(children.get(i), lastPropertyDataItem);
    }
    tagsetGrid.expand(tagDataItem);
}
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) TagDefinition(de.catma.tag.TagDefinition) PropertyDefinition(de.catma.tag.PropertyDefinition)

Example 29 with PropertyDefinition

use of de.catma.tag.PropertyDefinition in project catma by forTEXT.

the class AddParenttagDialog method getResult.

@Override
protected Pair<TagsetDefinition, TagDefinition> getResult() {
    TagDefinition tag = new TagDefinition(idGenerator.generate(), tfName.getValue(), null, cbTagsets.getValue().getUuid());
    tag.addSystemPropertyDefinition(new PropertyDefinition(idGenerator.generate(PropertyDefinition.SystemPropertyName.catma_displaycolor.name()), PropertyDefinition.SystemPropertyName.catma_displaycolor.name(), Collections.singletonList(String.valueOf(colorPicker.getValue().getRGB()))));
    for (PropertyDefinition propertyDefinition : propertyDefDataProvider.getItems()) {
        tag.addUserDefinedPropertyDefinition(propertyDefinition);
    }
    return new Pair<>(cbTagsets.getValue(), tag);
}
Also used : TagDefinition(de.catma.tag.TagDefinition) PropertyDefinition(de.catma.tag.PropertyDefinition) Pair(de.catma.util.Pair)

Example 30 with PropertyDefinition

use of de.catma.tag.PropertyDefinition in project catma by forTEXT.

the class AddSubtagDialog method getResult.

@Override
protected TagDefinition getResult() {
    TagDefinition tag = new TagDefinition(idGenerator.generate(), tfName.getValue(), null, isWithTagsetSelection() ? cbTagsets.getValue().getUuid() : null);
    tag.addSystemPropertyDefinition(new PropertyDefinition(idGenerator.generate(PropertyDefinition.SystemPropertyName.catma_displaycolor.name()), PropertyDefinition.SystemPropertyName.catma_displaycolor.name(), Collections.singletonList(String.valueOf(colorPicker.getValue().getRGB()))));
    for (PropertyDefinition propertyDefinition : propertyDefDataProvider.getItems()) {
        tag.addUserDefinedPropertyDefinition(propertyDefinition);
    }
    return tag;
}
Also used : TagDefinition(de.catma.tag.TagDefinition) PropertyDefinition(de.catma.tag.PropertyDefinition)

Aggregations

PropertyDefinition (de.catma.tag.PropertyDefinition)40 TagDefinition (de.catma.tag.TagDefinition)24 ArrayList (java.util.ArrayList)20 TagsetDefinition (de.catma.tag.TagsetDefinition)18 Pair (de.catma.util.Pair)14 IDGenerator (de.catma.util.IDGenerator)13 UI (com.vaadin.ui.UI)12 Property (de.catma.tag.Property)12 IOException (java.io.IOException)12 Collection (java.util.Collection)12 List (java.util.List)12 ArrayListMultimap (com.google.common.collect.ArrayListMultimap)11 Multimap (com.google.common.collect.Multimap)11 TreeData (com.vaadin.data.TreeData)11 TreeDataProvider (com.vaadin.data.provider.TreeDataProvider)11 Project (de.catma.project.Project)11 ErrorHandler (de.catma.ui.module.main.ErrorHandler)11 PropertyChangeEvent (java.beans.PropertyChangeEvent)11 PropertyChangeListener (java.beans.PropertyChangeListener)11 Set (java.util.Set)11