Search in sources :

Example 1 with VariableManager

use of org.eclipse.sirius.components.representations.VariableManager in project sirius-components by eclipse-sirius.

the class AbstractNodeMappingConverter method convert.

public NodeDescription convert(AbstractNodeMapping abstractNodeMapping, AQLInterpreter interpreter, Map<UUID, NodeDescription> id2NodeDescriptions) {
    LabelStyleDescriptionConverter labelStyleDescriptionConverter = new LabelStyleDescriptionConverter(interpreter, this.objectService);
    Function<VariableManager, org.eclipse.sirius.viewpoint.description.style.LabelStyleDescription> abstractNodeMappingDescriptionProvider = new LabelStyleDescriptionProvider(interpreter, abstractNodeMapping);
    Function<VariableManager, String> labelIdProvider = this.getLabelIdProvider();
    Function<VariableManager, String> labelExpressionProvider = this.getLabelExpressionProvider(interpreter, abstractNodeMappingDescriptionProvider);
    Function<VariableManager, LabelStyleDescription> labelStyleDescriptionProvider = this.getLabelStyleDescriptionProvider(labelStyleDescriptionConverter, abstractNodeMappingDescriptionProvider);
    // @formatter:off
    LabelDescription labelDescription = LabelDescription.newLabelDescription(this.identifierProvider.getIdentifier(abstractNodeMapping) + LabelDescription.LABEL_SUFFIX).idProvider(labelIdProvider).textProvider(labelExpressionProvider).styleDescriptionProvider(labelStyleDescriptionProvider).build();
    // @formatter:on
    Function<VariableManager, String> semanticTargetIdProvider = variableManager -> {
        return variableManager.get(VariableManager.SELF, Object.class).map(this.objectService::getId).orElse(null);
    };
    Function<VariableManager, String> semanticTargetKindProvider = variableManager -> {
        return variableManager.get(VariableManager.SELF, Object.class).map(this.objectService::getKind).orElse(null);
    };
    Function<VariableManager, String> semanticTargetLabelProvider = variableManager -> {
        return variableManager.get(VariableManager.SELF, Object.class).map(this.objectService::getLabel).orElse(null);
    };
    Function<VariableManager, INodeStyle> styleProvider = new AbstractNodeMappingStyleProvider(interpreter, abstractNodeMapping);
    Function<VariableManager, String> typeProvider = variableManager -> {
        var result = NodeType.NODE_RECTANGLE;
        INodeStyle style = styleProvider.apply(variableManager);
        if (style instanceof ImageNodeStyle) {
            result = NodeType.NODE_IMAGE;
        } else if (style instanceof ListItemNodeStyle) {
            result = NodeType.NODE_LIST_ITEM;
        } else if (style instanceof ListNodeStyle) {
            result = NodeType.NODE_LIST;
        }
        return result;
    };
    AbstractNodeMappingSizeProvider sizeProvider = new AbstractNodeMappingSizeProvider(interpreter, abstractNodeMapping);
    String domainClass = abstractNodeMapping.getDomainClass();
    String semanticCandidatesExpression = abstractNodeMapping.getSemanticCandidatesExpression();
    String preconditionExpression = abstractNodeMapping.getPreconditionExpression();
    Function<VariableManager, List<?>> semanticElementsProvider = this.semanticCandidatesProviderFactory.getSemanticCandidatesProvider(interpreter, domainClass, semanticCandidatesExpression, preconditionExpression);
    List<NodeDescription> childNodeDescriptions = this.getChildNodeDescriptions(abstractNodeMapping, interpreter, id2NodeDescriptions);
    // @formatter:off
    List<NodeDescription> borderNodeDescriptions = abstractNodeMapping.getBorderedNodeMappings().stream().map(borderNodeMapping -> this.convert(borderNodeMapping, interpreter, id2NodeDescriptions)).collect(Collectors.toList());
    // @formatter:on
    ToolConverter toolConverter = new ToolConverter(interpreter, this.editService, this.modelOperationHandlerSwitchProvider);
    var deleteHandler = toolConverter.createDeleteToolHandler(abstractNodeMapping.getDeletionDescription());
    var labelEditHandler = toolConverter.createDirectEditToolHandler(abstractNodeMapping.getLabelDirectEdit());
    SynchronizationPolicy synchronizationPolicy = SynchronizationPolicy.SYNCHRONIZED;
    if (!abstractNodeMapping.isCreateElements()) {
        synchronizationPolicy = SynchronizationPolicy.UNSYNCHRONIZED;
    }
    // @formatter:off
    NodeDescription description = NodeDescription.newNodeDescription(UUID.fromString(this.identifierProvider.getIdentifier(abstractNodeMapping))).typeProvider(typeProvider).targetObjectIdProvider(semanticTargetIdProvider).targetObjectKindProvider(semanticTargetKindProvider).targetObjectLabelProvider(semanticTargetLabelProvider).semanticElementsProvider(semanticElementsProvider).synchronizationPolicy(synchronizationPolicy).labelDescription(labelDescription).styleProvider(styleProvider).sizeProvider(sizeProvider).borderNodeDescriptions(borderNodeDescriptions).childNodeDescriptions(childNodeDescriptions).labelEditHandler(labelEditHandler).deleteHandler(deleteHandler).build();
    // @formatter:on
    id2NodeDescriptions.put(description.getId(), description);
    return description;
}
Also used : VariableManager(org.eclipse.sirius.components.representations.VariableManager) LabelDescription(org.eclipse.sirius.components.diagrams.description.LabelDescription) IObjectService(org.eclipse.sirius.components.core.api.IObjectService) SynchronizationPolicy(org.eclipse.sirius.components.diagrams.description.SynchronizationPolicy) AbstractNodeMapping(org.eclipse.sirius.diagram.description.AbstractNodeMapping) INodeStyle(org.eclipse.sirius.components.diagrams.INodeStyle) Function(java.util.function.Function) NodeDescription(org.eclipse.sirius.components.diagrams.description.NodeDescription) ArrayList(java.util.ArrayList) ListNodeStyle(org.eclipse.sirius.components.diagrams.ListNodeStyle) StringValueProvider(org.eclipse.sirius.components.compatibility.utils.StringValueProvider) Service(org.springframework.stereotype.Service) Map(java.util.Map) ISemanticCandidatesProviderFactory(org.eclipse.sirius.components.compatibility.api.ISemanticCandidatesProviderFactory) ContainerMapping(org.eclipse.sirius.diagram.description.ContainerMapping) BasicLabelStyleDescription(org.eclipse.sirius.viewpoint.description.style.BasicLabelStyleDescription) IEditService(org.eclipse.sirius.components.core.api.IEditService) StyleFactory(org.eclipse.sirius.viewpoint.description.style.StyleFactory) IModelOperationHandlerSwitchProvider(org.eclipse.sirius.components.compatibility.api.IModelOperationHandlerSwitchProvider) ImageNodeStyle(org.eclipse.sirius.components.diagrams.ImageNodeStyle) ListItemNodeStyle(org.eclipse.sirius.components.diagrams.ListItemNodeStyle) LabelStyleDescription(org.eclipse.sirius.components.diagrams.description.LabelStyleDescription) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) AQLInterpreter(org.eclipse.sirius.components.interpreter.AQLInterpreter) Objects(java.util.Objects) List(java.util.List) NodeType(org.eclipse.sirius.components.diagrams.NodeType) Optional(java.util.Optional) VariableManager(org.eclipse.sirius.components.representations.VariableManager) IIdentifierProvider(org.eclipse.sirius.components.compatibility.api.IIdentifierProvider) BasicLabelStyleDescription(org.eclipse.sirius.viewpoint.description.style.BasicLabelStyleDescription) LabelStyleDescription(org.eclipse.sirius.components.diagrams.description.LabelStyleDescription) LabelDescription(org.eclipse.sirius.components.diagrams.description.LabelDescription) NodeDescription(org.eclipse.sirius.components.diagrams.description.NodeDescription) ArrayList(java.util.ArrayList) List(java.util.List) ListNodeStyle(org.eclipse.sirius.components.diagrams.ListNodeStyle) ListItemNodeStyle(org.eclipse.sirius.components.diagrams.ListItemNodeStyle) SynchronizationPolicy(org.eclipse.sirius.components.diagrams.description.SynchronizationPolicy) ImageNodeStyle(org.eclipse.sirius.components.diagrams.ImageNodeStyle) INodeStyle(org.eclipse.sirius.components.diagrams.INodeStyle)

Example 2 with VariableManager

use of org.eclipse.sirius.components.representations.VariableManager in project sirius-components by eclipse-sirius.

the class DomainBasedSourceNodesProvider method apply.

@Override
public List<Element> apply(VariableManager variableManager) {
    var optionalCache = variableManager.get(DiagramDescription.CACHE, DiagramRenderingCache.class);
    if (optionalCache.isEmpty()) {
        return List.of();
    }
    DiagramRenderingCache cache = optionalCache.get();
    String sourceFinderExpression = this.edgeMapping.getSourceFinderExpression();
    Result result = this.interpreter.evaluateExpression(variableManager.getVariables(), sourceFinderExpression);
    List<Object> semanticCandidates = result.asObjects().orElse(List.of());
    // @formatter:off
    return semanticCandidates.stream().flatMap(semanticObject -> cache.getElementsRepresenting(semanticObject).stream()).filter(this.isFromCompatibleSourceMapping()).filter(Objects::nonNull).collect(Collectors.toList());
// @formatter:on
}
Also used : Predicate(java.util.function.Predicate) DiagramDescription(org.eclipse.sirius.components.diagrams.description.DiagramDescription) Result(org.eclipse.sirius.components.interpreter.Result) EdgeMapping(org.eclipse.sirius.diagram.description.EdgeMapping) Function(java.util.function.Function) Collectors(java.util.stream.Collectors) AQLInterpreter(org.eclipse.sirius.components.interpreter.AQLInterpreter) Element(org.eclipse.sirius.components.representations.Element) Objects(java.util.Objects) List(java.util.List) DiagramElementMapping(org.eclipse.sirius.diagram.description.DiagramElementMapping) NodeElementProps(org.eclipse.sirius.components.diagrams.elements.NodeElementProps) VariableManager(org.eclipse.sirius.components.representations.VariableManager) IIdentifierProvider(org.eclipse.sirius.components.compatibility.api.IIdentifierProvider) DiagramRenderingCache(org.eclipse.sirius.components.diagrams.renderer.DiagramRenderingCache) DiagramRenderingCache(org.eclipse.sirius.components.diagrams.renderer.DiagramRenderingCache) Result(org.eclipse.sirius.components.interpreter.Result)

Example 3 with VariableManager

use of org.eclipse.sirius.components.representations.VariableManager in project sirius-components by eclipse-sirius.

the class EdgeMappingConverter method createLabelDescription.

private LabelDescription createLabelDescription(AQLInterpreter interpreter, LabelStyleDescriptionConverter labelStyleDescriptionConverter, BasicLabelStyleDescription siriusBasicLabelStyleDescription, String idSuffix, EdgeMapping edgeMapping) {
    String labelExpression = siriusBasicLabelStyleDescription.getLabelExpression();
    Function<VariableManager, LabelStyleDescription> labelStyleDescriptionProvider = variableManager -> {
        return labelStyleDescriptionConverter.convert(siriusBasicLabelStyleDescription);
    };
    Function<VariableManager, String> labelIdProvider = variableManager -> {
        Object parentId = variableManager.getVariables().get(LabelDescription.OWNER_ID);
        return String.valueOf(parentId) + idSuffix;
    };
    String id = this.identifierProvider.getIdentifier(edgeMapping) + idSuffix;
    StringValueProvider textProvider = new StringValueProvider(interpreter, labelExpression);
    // @formatter:off
    return LabelDescription.newLabelDescription(id).idProvider(labelIdProvider).textProvider(textProvider).styleDescriptionProvider(labelStyleDescriptionProvider).build();
// @formatter:on
}
Also used : VariableManager(org.eclipse.sirius.components.representations.VariableManager) LabelDescription(org.eclipse.sirius.components.diagrams.description.LabelDescription) IObjectService(org.eclipse.sirius.components.core.api.IObjectService) EdgeMapping(org.eclipse.sirius.diagram.description.EdgeMapping) AbstractNodeMapping(org.eclipse.sirius.diagram.description.AbstractNodeMapping) EdgeStyleDescription(org.eclipse.sirius.diagram.description.style.EdgeStyleDescription) Function(java.util.function.Function) NodeDescription(org.eclipse.sirius.components.diagrams.description.NodeDescription) StringValueProvider(org.eclipse.sirius.components.compatibility.utils.StringValueProvider) Service(org.springframework.stereotype.Service) Map(java.util.Map) ISemanticCandidatesProviderFactory(org.eclipse.sirius.components.compatibility.api.ISemanticCandidatesProviderFactory) Builder(org.eclipse.sirius.components.diagrams.description.EdgeDescription.Builder) BasicLabelStyleDescription(org.eclipse.sirius.viewpoint.description.style.BasicLabelStyleDescription) IEditService(org.eclipse.sirius.components.core.api.IEditService) EdgeStyle(org.eclipse.sirius.components.diagrams.EdgeStyle) IModelOperationHandlerSwitchProvider(org.eclipse.sirius.components.compatibility.api.IModelOperationHandlerSwitchProvider) LabelStyleDescription(org.eclipse.sirius.components.diagrams.description.LabelStyleDescription) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) AQLInterpreter(org.eclipse.sirius.components.interpreter.AQLInterpreter) Element(org.eclipse.sirius.components.representations.Element) Objects(java.util.Objects) List(java.util.List) EdgeDescription(org.eclipse.sirius.components.diagrams.description.EdgeDescription) DiagramElementMapping(org.eclipse.sirius.diagram.description.DiagramElementMapping) Optional(java.util.Optional) VariableManager(org.eclipse.sirius.components.representations.VariableManager) IIdentifierProvider(org.eclipse.sirius.components.compatibility.api.IIdentifierProvider) StringValueProvider(org.eclipse.sirius.components.compatibility.utils.StringValueProvider) BasicLabelStyleDescription(org.eclipse.sirius.viewpoint.description.style.BasicLabelStyleDescription) LabelStyleDescription(org.eclipse.sirius.components.diagrams.description.LabelStyleDescription)

Example 4 with VariableManager

use of org.eclipse.sirius.components.representations.VariableManager in project sirius-components by eclipse-sirius.

the class NodeStylePropertiesConfigurer method getNodeStyleProperties.

private FormDescription getNodeStyleProperties() {
    // $NON-NLS-1$
    UUID formDescriptionId = UUID.nameUUIDFromBytes("nodestyle".getBytes());
    // @formatter:off
    List<AbstractControlDescription> controls = List.of(// $NON-NLS-1$ //$NON-NLS-2$
    this.createTextField(// $NON-NLS-1$ //$NON-NLS-2$
    "nodestyle.sizeExpression", // $NON-NLS-1$ //$NON-NLS-2$
    "Size Expression", style -> ((NodeStyle) style).getSizeComputationExpression(), (style, newSizeExpression) -> ((NodeStyle) style).setSizeComputationExpression(newSizeExpression), ViewPackage.Literals.NODE_STYLE__SIZE_COMPUTATION_EXPRESSION), // $NON-NLS-1$ //$NON-NLS-2$
    this.createTextField(// $NON-NLS-1$ //$NON-NLS-2$
    "nodestyle.labelColor", // $NON-NLS-1$ //$NON-NLS-2$
    "Label Color", style -> ((NodeStyle) style).getLabelColor(), (style, newLabelColor) -> ((NodeStyle) style).setLabelColor(newLabelColor), ViewPackage.Literals.NODE_STYLE__LABEL_COLOR), // $NON-NLS-1$ //$NON-NLS-2$
    this.createTextField(// $NON-NLS-1$ //$NON-NLS-2$
    "nodestyle.color", // $NON-NLS-1$ //$NON-NLS-2$
    "Color", style -> ((NodeStyle) style).getColor(), (style, newColor) -> ((NodeStyle) style).setColor(newColor), ViewPackage.Literals.STYLE__COLOR), // $NON-NLS-1$ //$NON-NLS-2$
    this.createTextField(// $NON-NLS-1$ //$NON-NLS-2$
    "nodestyle.borderColor", // $NON-NLS-1$ //$NON-NLS-2$
    "Border Color", style -> ((NodeStyle) style).getBorderColor(), (style, newColor) -> ((NodeStyle) style).setBorderColor(newColor), ViewPackage.Literals.BORDER_STYLE__BORDER_COLOR), // $NON-NLS-1$ //$NON-NLS-2$
    this.createTextField(// $NON-NLS-1$ //$NON-NLS-2$
    "nodestyle.borderRadius", // $NON-NLS-1$ //$NON-NLS-2$
    "Border Radius", style -> String.valueOf(((NodeStyle) style).getBorderRadius()), (style, newBorderRadius) -> {
        try {
            ((NodeStyle) style).setBorderRadius(Integer.parseInt(newBorderRadius));
        } catch (NumberFormatException nfe) {
        // Ignore.
        }
    }, ViewPackage.Literals.BORDER_STYLE__BORDER_RADIUS), // $NON-NLS-1$ //$NON-NLS-2$
    this.createTextField(// $NON-NLS-1$ //$NON-NLS-2$
    "nodestyle.borderSize", // $NON-NLS-1$ //$NON-NLS-2$
    "Border Size", style -> String.valueOf(((NodeStyle) style).getBorderSize()), (style, newBorderSize) -> {
        try {
            ((NodeStyle) style).setBorderSize(Integer.parseInt(newBorderSize));
        } catch (NumberFormatException nfe) {
        // Ignore.
        }
    }, ViewPackage.Literals.BORDER_STYLE__BORDER_SIZE), // $NON-NLS-1$
    this.createBorderLineStyleSelectionField("nodestyle.borderstyle", ViewPackage.Literals.BORDER_STYLE__BORDER_LINE_STYLE), // $NON-NLS-1$ //$NON-NLS-2$
    this.createCheckbox(// $NON-NLS-1$ //$NON-NLS-2$
    "nodestyle.listMode", // $NON-NLS-1$ //$NON-NLS-2$
    "List Mode", style -> ((NodeStyle) style).isListMode(), (style, newListMode) -> ((NodeStyle) style).setListMode(newListMode), ViewPackage.Literals.NODE_STYLE__LIST_MODE), // $NON-NLS-1$ //$NON-NLS-2$
    this.createTextField(// $NON-NLS-1$ //$NON-NLS-2$
    "nodestyle.fontSize", // $NON-NLS-1$ //$NON-NLS-2$
    "Font Size", style -> String.valueOf(((LabelStyle) style).getFontSize()), (style, newColor) -> {
        try {
            ((LabelStyle) style).setFontSize(Integer.parseInt(newColor));
        } catch (NumberFormatException nfe) {
        // Ignore.
        }
    }, ViewPackage.Literals.LABEL_STYLE__FONT_SIZE), // $NON-NLS-1$ //$NON-NLS-2$
    this.createCheckbox(// $NON-NLS-1$ //$NON-NLS-2$
    "nodestyle.italic", // $NON-NLS-1$ //$NON-NLS-2$
    "Italic", style -> ((LabelStyle) style).isItalic(), (style, newItalic) -> ((LabelStyle) style).setItalic(newItalic), ViewPackage.Literals.LABEL_STYLE__ITALIC), // $NON-NLS-1$ //$NON-NLS-2$
    this.createCheckbox(// $NON-NLS-1$ //$NON-NLS-2$
    "nodestyle.bold", // $NON-NLS-1$ //$NON-NLS-2$
    "Bold", style -> ((LabelStyle) style).isBold(), (style, newBold) -> ((LabelStyle) style).setBold(newBold), ViewPackage.Literals.LABEL_STYLE__BOLD), // $NON-NLS-1$ //$NON-NLS-2$
    this.createCheckbox(// $NON-NLS-1$ //$NON-NLS-2$
    "nodestyle.underline", // $NON-NLS-1$ //$NON-NLS-2$
    "Underline", style -> ((LabelStyle) style).isUnderline(), (style, newUnderline) -> ((LabelStyle) style).setUnderline(newUnderline), ViewPackage.Literals.LABEL_STYLE__UNDERLINE), // $NON-NLS-1$ //$NON-NLS-2$
    this.createCheckbox(// $NON-NLS-1$ //$NON-NLS-2$
    "nodestyle.strikeThrough", // $NON-NLS-1$ //$NON-NLS-2$
    "Strike Through", style -> ((LabelStyle) style).isStrikeThrough(), (style, newStrikeThrough) -> ((LabelStyle) style).setStrikeThrough(newStrikeThrough), ViewPackage.Literals.LABEL_STYLE__STRIKE_THROUGH), this.createShapeSelectionField(ViewPackage.Literals.NODE_STYLE__SHAPE));
    GroupDescription groupDescription = this.createSimpleGroupDescription(controls);
    Predicate<VariableManager> canCreatePagePredicate = variableManager -> variableManager.get(VariableManager.SELF, Object.class).filter(self -> self instanceof List<?>).map(self -> (List<?>) self).flatMap(self -> self.stream().findFirst()).filter(self -> self instanceof NodeStyle && !(self instanceof ConditionalNodeStyle)).isPresent();
    return FormDescription.newFormDescription(formDescriptionId).label(// $NON-NLS-1$
    "Node Style").labelProvider(variableManager -> variableManager.get(VariableManager.SELF, NodeStyle.class).map(NodeStyle::getColor).orElse(UNNAMED)).canCreatePredicate(variableManager -> true).idProvider(new GetOrCreateRandomIdProvider()).targetObjectIdProvider(this.getTargetObjectIdProvider()).pageDescriptions(List.of(this.createSimplePageDescription(groupDescription, canCreatePagePredicate))).groupDescriptions(List.of(groupDescription)).build();
// @formatter:on
}
Also used : IPropertiesDescriptionRegistryConfigurer(org.eclipse.sirius.components.collaborative.forms.services.api.IPropertiesDescriptionRegistryConfigurer) IEditingContext(org.eclipse.sirius.components.core.api.IEditingContext) LineStyle(org.eclipse.sirius.components.view.LineStyle) PageDescription(org.eclipse.sirius.components.forms.description.PageDescription) BiFunction(java.util.function.BiFunction) SelectComponent(org.eclipse.sirius.components.forms.components.SelectComponent) Function(java.util.function.Function) CustomImage(org.eclipse.sirius.components.emf.view.CustomImage) FormDescription(org.eclipse.sirius.components.forms.description.FormDescription) LabelStyle(org.eclipse.sirius.components.view.LabelStyle) IStatus(org.eclipse.sirius.components.representations.IStatus) TextfieldDescription(org.eclipse.sirius.components.forms.description.TextfieldDescription) ICustomImageSearchService(org.eclipse.sirius.components.emf.view.ICustomImageSearchService) BiConsumer(java.util.function.BiConsumer) IValidationService(org.eclipse.sirius.components.collaborative.validation.api.IValidationService) GroupDescription(org.eclipse.sirius.components.forms.description.GroupDescription) CheckboxDescription(org.eclipse.sirius.components.forms.description.CheckboxDescription) NodeStyle(org.eclipse.sirius.components.view.NodeStyle) Failure(org.eclipse.sirius.components.representations.Failure) Predicate(java.util.function.Predicate) SelectDescription(org.eclipse.sirius.components.forms.description.SelectDescription) Success(org.eclipse.sirius.components.representations.Success) Diagnostic(org.eclipse.emf.common.util.Diagnostic) EcoreUtil(org.eclipse.emf.ecore.util.EcoreUtil) EObject(org.eclipse.emf.ecore.EObject) UUID(java.util.UUID) ConditionalNodeStyle(org.eclipse.sirius.components.view.ConditionalNodeStyle) Collectors(java.util.stream.Collectors) ViewPackage(org.eclipse.sirius.components.view.ViewPackage) Objects(java.util.Objects) List(java.util.List) GetOrCreateRandomIdProvider(org.eclipse.sirius.components.representations.GetOrCreateRandomIdProvider) Component(org.springframework.stereotype.Component) AbstractControlDescription(org.eclipse.sirius.components.forms.description.AbstractControlDescription) BorderStyle(org.eclipse.sirius.components.view.BorderStyle) Optional(java.util.Optional) IPropertiesDescriptionRegistry(org.eclipse.sirius.components.collaborative.forms.services.api.IPropertiesDescriptionRegistry) VariableManager(org.eclipse.sirius.components.representations.VariableManager) Comparator(java.util.Comparator) VariableManager(org.eclipse.sirius.components.representations.VariableManager) NodeStyle(org.eclipse.sirius.components.view.NodeStyle) ConditionalNodeStyle(org.eclipse.sirius.components.view.ConditionalNodeStyle) LabelStyle(org.eclipse.sirius.components.view.LabelStyle) GroupDescription(org.eclipse.sirius.components.forms.description.GroupDescription) AbstractControlDescription(org.eclipse.sirius.components.forms.description.AbstractControlDescription) EObject(org.eclipse.emf.ecore.EObject) List(java.util.List) ConditionalNodeStyle(org.eclipse.sirius.components.view.ConditionalNodeStyle) UUID(java.util.UUID) GetOrCreateRandomIdProvider(org.eclipse.sirius.components.representations.GetOrCreateRandomIdProvider)

Example 5 with VariableManager

use of org.eclipse.sirius.components.representations.VariableManager in project sirius-components by eclipse-sirius.

the class NodeStylePropertiesConfigurer method createTextField.

private TextfieldDescription createTextField(String id, String title, Function<Object, String> reader, BiConsumer<Object, String> writer, Object feature) {
    Function<VariableManager, String> valueProvider = variableManager -> variableManager.get(VariableManager.SELF, Object.class).map(reader).orElse(EMPTY);
    BiFunction<VariableManager, String, IStatus> newValueHandler = (variableManager, newValue) -> {
        var optionalDiagramMapping = variableManager.get(VariableManager.SELF, Object.class);
        if (optionalDiagramMapping.isPresent()) {
            writer.accept(optionalDiagramMapping.get(), newValue);
            return new Success();
        } else {
            // $NON-NLS-1$
            return new Failure("");
        }
    };
    // @formatter:off
    return TextfieldDescription.newTextfieldDescription(id).idProvider(variableManager -> id).labelProvider(variableManager -> title).valueProvider(valueProvider).newValueHandler(newValueHandler).diagnosticsProvider(this.getDiagnosticsProvider(feature)).kindProvider(this::kindProvider).messageProvider(this::messageProvider).build();
// @formatter:on
}
Also used : VariableManager(org.eclipse.sirius.components.representations.VariableManager) IPropertiesDescriptionRegistryConfigurer(org.eclipse.sirius.components.collaborative.forms.services.api.IPropertiesDescriptionRegistryConfigurer) IEditingContext(org.eclipse.sirius.components.core.api.IEditingContext) LineStyle(org.eclipse.sirius.components.view.LineStyle) PageDescription(org.eclipse.sirius.components.forms.description.PageDescription) BiFunction(java.util.function.BiFunction) SelectComponent(org.eclipse.sirius.components.forms.components.SelectComponent) Function(java.util.function.Function) CustomImage(org.eclipse.sirius.components.emf.view.CustomImage) FormDescription(org.eclipse.sirius.components.forms.description.FormDescription) LabelStyle(org.eclipse.sirius.components.view.LabelStyle) IStatus(org.eclipse.sirius.components.representations.IStatus) TextfieldDescription(org.eclipse.sirius.components.forms.description.TextfieldDescription) ICustomImageSearchService(org.eclipse.sirius.components.emf.view.ICustomImageSearchService) BiConsumer(java.util.function.BiConsumer) IValidationService(org.eclipse.sirius.components.collaborative.validation.api.IValidationService) GroupDescription(org.eclipse.sirius.components.forms.description.GroupDescription) CheckboxDescription(org.eclipse.sirius.components.forms.description.CheckboxDescription) NodeStyle(org.eclipse.sirius.components.view.NodeStyle) Failure(org.eclipse.sirius.components.representations.Failure) Predicate(java.util.function.Predicate) SelectDescription(org.eclipse.sirius.components.forms.description.SelectDescription) Success(org.eclipse.sirius.components.representations.Success) Diagnostic(org.eclipse.emf.common.util.Diagnostic) EcoreUtil(org.eclipse.emf.ecore.util.EcoreUtil) EObject(org.eclipse.emf.ecore.EObject) UUID(java.util.UUID) ConditionalNodeStyle(org.eclipse.sirius.components.view.ConditionalNodeStyle) Collectors(java.util.stream.Collectors) ViewPackage(org.eclipse.sirius.components.view.ViewPackage) Objects(java.util.Objects) List(java.util.List) GetOrCreateRandomIdProvider(org.eclipse.sirius.components.representations.GetOrCreateRandomIdProvider) Component(org.springframework.stereotype.Component) AbstractControlDescription(org.eclipse.sirius.components.forms.description.AbstractControlDescription) BorderStyle(org.eclipse.sirius.components.view.BorderStyle) Optional(java.util.Optional) IPropertiesDescriptionRegistry(org.eclipse.sirius.components.collaborative.forms.services.api.IPropertiesDescriptionRegistry) VariableManager(org.eclipse.sirius.components.representations.VariableManager) Comparator(java.util.Comparator) IStatus(org.eclipse.sirius.components.representations.IStatus) EObject(org.eclipse.emf.ecore.EObject) Success(org.eclipse.sirius.components.representations.Success) Failure(org.eclipse.sirius.components.representations.Failure)

Aggregations

VariableManager (org.eclipse.sirius.components.representations.VariableManager)121 List (java.util.List)66 ArrayList (java.util.ArrayList)55 Element (org.eclipse.sirius.components.representations.Element)53 Function (java.util.function.Function)52 Objects (java.util.Objects)47 AQLInterpreter (org.eclipse.sirius.components.interpreter.AQLInterpreter)47 UUID (java.util.UUID)46 Optional (java.util.Optional)43 Failure (org.eclipse.sirius.components.representations.Failure)39 NodeDescription (org.eclipse.sirius.components.diagrams.description.NodeDescription)38 Test (org.junit.jupiter.api.Test)37 Collectors (java.util.stream.Collectors)35 IStatus (org.eclipse.sirius.components.representations.IStatus)34 LabelDescription (org.eclipse.sirius.components.diagrams.description.LabelDescription)32 Size (org.eclipse.sirius.components.diagrams.Size)30 DiagramDescription (org.eclipse.sirius.components.diagrams.description.DiagramDescription)30 INodeStyle (org.eclipse.sirius.components.diagrams.INodeStyle)29 LabelStyleDescription (org.eclipse.sirius.components.diagrams.description.LabelStyleDescription)29 IObjectService (org.eclipse.sirius.components.core.api.IObjectService)27