Search in sources :

Example 21 with StylingSet

use of org.kie.workbench.common.dmn.api.property.styling.StylingSet in project kie-wb-common by kiegroup.

the class StunnerConverter method internalAugmentStyles.

private void internalAugmentStyles(final JSIDMNShape drgShape, final StylingSet stylingSet) {
    final JSIStyle jsiStyle = drgShape.getStyle();
    if (Objects.isNull(jsiStyle)) {
        return;
    }
    final JSIStyle drgStyle = getUnwrappedJSIStyle(jsiStyle);
    final JSIDMNStyle dmnStyleOfDrgShape = isJSIDMNStyle(drgStyle) ? getJSIDmnStyle(drgStyle) : null;
    if (Objects.nonNull(dmnStyleOfDrgShape)) {
        if (Objects.nonNull(dmnStyleOfDrgShape.getFillColor())) {
            stylingSet.setBgColour(new BgColour(ColorUtils.wbFromDMN(dmnStyleOfDrgShape.getFillColor())));
        }
        if (Objects.nonNull(dmnStyleOfDrgShape.getStrokeColor())) {
            stylingSet.setBorderColour(new BorderColour(ColorUtils.wbFromDMN(dmnStyleOfDrgShape.getStrokeColor())));
        }
    }
    final StylingSet fontStylingSet = new StylingSet();
    if (Objects.nonNull(dmnStyleOfDrgShape)) {
        mergeFontStylingSet(fontStylingSet, FontStylingSetPropertyConverter.wbFromDMN(dmnStyleOfDrgShape));
    }
    if (Objects.nonNull(drgShape.getDMNLabel())) {
        final JSIDMNShape jsiLabel = Js.uncheckedCast(drgShape.getDMNLabel());
        final JSIStyle jsiLabelStyle = jsiLabel.getStyle();
        final Object jsiLabelSharedStyle = Js.uncheckedCast(jsiLabel.getSharedStyle());
        if (Objects.nonNull(jsiLabelSharedStyle) && JSIDMNStyle.instanceOf(jsiLabelSharedStyle)) {
            mergeFontStylingSet(fontStylingSet, FontStylingSetPropertyConverter.wbFromDMN((Js.uncheckedCast(jsiLabelSharedStyle))));
        }
        if (Objects.nonNull(jsiLabelStyle) && isJSIDMNStyle(jsiLabelStyle)) {
            mergeFontStylingSet(fontStylingSet, FontStylingSetPropertyConverter.wbFromDMN(Js.uncheckedCast(jsiLabelStyle)));
        }
    }
    mergeFontStylingSet(stylingSet, fontStylingSet);
}
Also used : BgColour(org.kie.workbench.common.dmn.api.property.styling.BgColour) JSIStyle(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.di.JSIStyle) JSIDMNShape(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmndi12.JSIDMNShape) StylingSet(org.kie.workbench.common.dmn.api.property.styling.StylingSet) JSIDMNStyle(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmndi12.JSIDMNStyle) BorderColour(org.kie.workbench.common.dmn.api.property.styling.BorderColour)

Example 22 with StylingSet

use of org.kie.workbench.common.dmn.api.property.styling.StylingSet in project kie-wb-common by kiegroup.

the class DecisionConverter method nodeFromDMN.

@Override
public Node<View<Decision>, ?> nodeFromDMN(final NodeEntry nodeEntry) {
    final JSITDecision dmn = Js.uncheckedCast(nodeEntry.getDmnElement());
    @SuppressWarnings("unchecked") final Node<View<Decision>, ?> node = (Node<View<Decision>, ?>) factoryManager.newElement(nodeEntry.getId(), getDefinitionId(Decision.class)).asNode();
    final Id id = IdPropertyConverter.wbFromDMN(dmn.getId());
    final Description description = DescriptionPropertyConverter.wbFromDMN(dmn.getDescription());
    final Name name = new Name(dmn.getName());
    final InformationItemPrimary informationItem = InformationItemPrimaryPropertyConverter.wbFromDMN(dmn.getVariable(), dmn);
    Expression expression = null;
    final JSITExpression jsiWrapped = dmn.getExpression();
    if (Objects.nonNull(jsiWrapped)) {
        final JSITExpression jsiExpression = Js.uncheckedCast(JsUtils.getUnwrappedElement(jsiWrapped));
        expression = ExpressionPropertyConverter.wbFromDMN(jsiExpression, Js.uncheckedCast(dmn), nodeEntry.getComponentWidthsConsumer());
    }
    final Decision decision = new Decision(id, description, name, new Question(), new AllowedAnswers(), informationItem, expression, new StylingSet(), new GeneralRectangleDimensionsSet());
    decision.setDiagramId(nodeEntry.getDiagramId());
    decision.setQuestion(QuestionPropertyConverter.wbFromDMN(dmn.getQuestion()));
    decision.setAllowedAnswers(AllowedAnswersPropertyConverter.wbFromDMN(dmn.getAllowedAnswers()));
    node.getContent().setDefinition(decision);
    if (Objects.nonNull(informationItem)) {
        informationItem.setParent(decision);
    }
    if (Objects.nonNull(expression)) {
        expression.setParent(decision);
    }
    DMNExternalLinksToExtensionElements.loadExternalLinksFromExtensionElements(dmn, decision);
    return node;
}
Also used : InformationItemPrimary(org.kie.workbench.common.dmn.api.definition.model.InformationItemPrimary) Description(org.kie.workbench.common.dmn.api.property.dmn.Description) Node(org.kie.workbench.common.stunner.core.graph.Node) JSITDecision(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITDecision) GeneralRectangleDimensionsSet(org.kie.workbench.common.dmn.api.property.dimensions.GeneralRectangleDimensionsSet) AllowedAnswers(org.kie.workbench.common.dmn.api.property.dmn.AllowedAnswers) View(org.kie.workbench.common.stunner.core.graph.content.view.View) JSITDecision(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITDecision) Decision(org.kie.workbench.common.dmn.api.definition.model.Decision) Name(org.kie.workbench.common.dmn.api.property.dmn.Name) JSITExpression(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITExpression) Expression(org.kie.workbench.common.dmn.api.definition.model.Expression) StylingSet(org.kie.workbench.common.dmn.api.property.styling.StylingSet) Question(org.kie.workbench.common.dmn.api.property.dmn.Question) Id(org.kie.workbench.common.dmn.api.property.dmn.Id) IdUtils.getRawId(org.kie.workbench.common.dmn.client.marshaller.common.IdUtils.getRawId) BindableAdapterUtils.getDefinitionId(org.kie.workbench.common.stunner.core.definition.adapter.binding.BindableAdapterUtils.getDefinitionId) JSITExpression(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITExpression)

Example 23 with StylingSet

use of org.kie.workbench.common.dmn.api.property.styling.StylingSet in project kie-wb-common by kiegroup.

the class DecisionServiceConverter method nodeFromDMN.

@Override
public Node<View<DecisionService>, ?> nodeFromDMN(final NodeEntry nodeEntry) {
    final JSITDecisionService dmn = Js.uncheckedCast(nodeEntry.getDmnElement());
    @SuppressWarnings("unchecked") final Node<View<DecisionService>, ?> node = (Node<View<DecisionService>, ?>) factoryManager.newElement(nodeEntry.getId(), getDefinitionId(DecisionService.class)).asNode();
    final Id id = IdPropertyConverter.wbFromDMN(dmn.getId());
    final Description description = DescriptionPropertyConverter.wbFromDMN(dmn.getDescription());
    final Name name = new Name(dmn.getName());
    final InformationItemPrimary informationItem = InformationItemPrimaryPropertyConverter.wbFromDMN(dmn.getVariable(), dmn);
    final List<DMNElementReference> outputDecision = new ArrayList<>();
    final List<DMNElementReference> encapsulatedDecision = new ArrayList<>();
    final List<DMNElementReference> inputDecision = new ArrayList<>();
    final List<DMNElementReference> inputData = new ArrayList<>();
    final List<JSITDMNElementReference> jsiOutputDecisions = dmn.getOutputDecision();
    if (Objects.nonNull(jsiOutputDecisions)) {
        for (int i = 0; i < jsiOutputDecisions.size(); i++) {
            final JSITDMNElementReference jsiOutputDecision = Js.uncheckedCast(jsiOutputDecisions.get(i));
            outputDecision.add(DMNElementReferenceConverter.wbFromDMN(jsiOutputDecision));
        }
    }
    final List<JSITDMNElementReference> jsiEncapsulatedDecisions = dmn.getEncapsulatedDecision();
    if (Objects.nonNull(jsiEncapsulatedDecisions)) {
        for (int i = 0; i < jsiEncapsulatedDecisions.size(); i++) {
            final JSITDMNElementReference jsiEncapsulatedDecision = Js.uncheckedCast(jsiEncapsulatedDecisions.get(i));
            encapsulatedDecision.add(DMNElementReferenceConverter.wbFromDMN(jsiEncapsulatedDecision));
        }
    }
    final List<JSITDMNElementReference> jsiInputDecisions = dmn.getInputDecision();
    if (Objects.nonNull(jsiInputDecisions)) {
        for (int i = 0; i < jsiInputDecisions.size(); i++) {
            final JSITDMNElementReference jsiInputDecision = Js.uncheckedCast(jsiInputDecisions.get(i));
            inputDecision.add(DMNElementReferenceConverter.wbFromDMN(jsiInputDecision));
        }
    }
    final List<JSITDMNElementReference> jsiInputDatas = dmn.getInputData();
    if (Objects.nonNull(jsiInputDatas)) {
        for (int i = 0; i < jsiInputDatas.size(); i++) {
            final JSITDMNElementReference jsiInputData = Js.uncheckedCast(jsiInputDatas.get(i));
            inputData.add(DMNElementReferenceConverter.wbFromDMN(jsiInputData));
        }
    }
    final DecisionService decisionService = new DecisionService(id, description, name, informationItem, outputDecision, encapsulatedDecision, inputDecision, inputData, new StylingSet(), new DecisionServiceRectangleDimensionsSet(), new DecisionServiceDividerLineY());
    decisionService.setDiagramId(nodeEntry.getDiagramId());
    node.getContent().setDefinition(decisionService);
    if (Objects.nonNull(informationItem)) {
        informationItem.setParent(decisionService);
    }
    DMNExternalLinksToExtensionElements.loadExternalLinksFromExtensionElements(dmn, decisionService);
    return node;
}
Also used : InformationItemPrimary(org.kie.workbench.common.dmn.api.definition.model.InformationItemPrimary) Description(org.kie.workbench.common.dmn.api.property.dmn.Description) Node(org.kie.workbench.common.stunner.core.graph.Node) ArrayList(java.util.ArrayList) JSITDMNElementReference(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITDMNElementReference) View(org.kie.workbench.common.stunner.core.graph.content.view.View) JSITDecisionService(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITDecisionService) DecisionService(org.kie.workbench.common.dmn.api.definition.model.DecisionService) Name(org.kie.workbench.common.dmn.api.property.dmn.Name) DecisionServiceDividerLineY(org.kie.workbench.common.dmn.api.property.dmn.DecisionServiceDividerLineY) JSITDMNElementReference(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITDMNElementReference) DMNElementReference(org.kie.workbench.common.dmn.api.definition.model.DMNElementReference) JSITDecisionService(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITDecisionService) StylingSet(org.kie.workbench.common.dmn.api.property.styling.StylingSet) Id(org.kie.workbench.common.dmn.api.property.dmn.Id) BindableAdapterUtils.getDefinitionId(org.kie.workbench.common.stunner.core.definition.adapter.binding.BindableAdapterUtils.getDefinitionId) DecisionServiceRectangleDimensionsSet(org.kie.workbench.common.dmn.api.property.dimensions.DecisionServiceRectangleDimensionsSet)

Example 24 with StylingSet

use of org.kie.workbench.common.dmn.api.property.styling.StylingSet in project kie-wb-common by kiegroup.

the class KnowledgeSourceConverter method nodeFromDMN.

@Override
public Node<View<KnowledgeSource>, ?> nodeFromDMN(final org.kie.dmn.model.api.KnowledgeSource dmn, final BiConsumer<String, HasComponentWidths> hasComponentWidthsConsumer) {
    @SuppressWarnings("unchecked") final Node<View<KnowledgeSource>, ?> node = (Node<View<KnowledgeSource>, ?>) factoryManager.newElement(dmn.getId(), getDefinitionId(KnowledgeSource.class)).asNode();
    final Id id = new Id(dmn.getId());
    final Description description = DescriptionPropertyConverter.wbFromDMN(dmn.getDescription());
    final Name name = new Name(dmn.getName());
    final KnowledgeSourceType ksType = new KnowledgeSourceType(dmn.getType());
    final LocationURI locationURI = new LocationURI(dmn.getLocationURI());
    final KnowledgeSource ks = new KnowledgeSource(id, description, name, ksType, locationURI, new StylingSet(), new GeneralRectangleDimensionsSet());
    node.getContent().setDefinition(ks);
    DMNExternalLinksToExtensionElements.loadExternalLinksFromExtensionElements(dmn, ks);
    return node;
}
Also used : LocationURI(org.kie.workbench.common.dmn.api.property.dmn.LocationURI) Description(org.kie.workbench.common.dmn.api.property.dmn.Description) KnowledgeSource(org.kie.workbench.common.dmn.api.definition.model.KnowledgeSource) KnowledgeSourceType(org.kie.workbench.common.dmn.api.property.dmn.KnowledgeSourceType) Node(org.kie.workbench.common.stunner.core.graph.Node) StylingSet(org.kie.workbench.common.dmn.api.property.styling.StylingSet) GeneralRectangleDimensionsSet(org.kie.workbench.common.dmn.api.property.dimensions.GeneralRectangleDimensionsSet) Id(org.kie.workbench.common.dmn.api.property.dmn.Id) BindableAdapterUtils.getDefinitionId(org.kie.workbench.common.stunner.core.definition.adapter.binding.BindableAdapterUtils.getDefinitionId) View(org.kie.workbench.common.stunner.core.graph.content.view.View) Name(org.kie.workbench.common.dmn.api.property.dmn.Name)

Example 25 with StylingSet

use of org.kie.workbench.common.dmn.api.property.styling.StylingSet in project kie-wb-common by kiegroup.

the class TextAnnotationConverter method nodeFromDMN.

@Override
public Node<View<TextAnnotation>, ?> nodeFromDMN(final org.kie.dmn.model.api.TextAnnotation dmn, final BiConsumer<String, HasComponentWidths> hasComponentWidthsConsumer) {
    @SuppressWarnings("unchecked") final Node<View<TextAnnotation>, ?> node = (Node<View<TextAnnotation>, ?>) factoryManager.newElement(dmn.getId(), getDefinitionId(TextAnnotation.class)).asNode();
    final Id id = new Id(dmn.getId());
    final Description description = DescriptionPropertyConverter.wbFromDMN(dmn.getDescription());
    final Text text = new Text(dmn.getText());
    final TextFormat textFormat = new TextFormat(dmn.getTextFormat());
    final TextAnnotation textAnnotation = new TextAnnotation(id, description, text, textFormat, new StylingSet(), new GeneralRectangleDimensionsSet());
    node.getContent().setDefinition(textAnnotation);
    return node;
}
Also used : Description(org.kie.workbench.common.dmn.api.property.dmn.Description) Node(org.kie.workbench.common.stunner.core.graph.Node) StylingSet(org.kie.workbench.common.dmn.api.property.styling.StylingSet) GeneralRectangleDimensionsSet(org.kie.workbench.common.dmn.api.property.dimensions.GeneralRectangleDimensionsSet) TextFormat(org.kie.workbench.common.dmn.api.property.dmn.TextFormat) Text(org.kie.workbench.common.dmn.api.property.dmn.Text) Id(org.kie.workbench.common.dmn.api.property.dmn.Id) BindableAdapterUtils.getDefinitionId(org.kie.workbench.common.stunner.core.definition.adapter.binding.BindableAdapterUtils.getDefinitionId) TextAnnotation(org.kie.workbench.common.dmn.api.definition.model.TextAnnotation) View(org.kie.workbench.common.stunner.core.graph.content.view.View)

Aggregations

StylingSet (org.kie.workbench.common.dmn.api.property.styling.StylingSet)26 Description (org.kie.workbench.common.dmn.api.property.dmn.Description)22 Id (org.kie.workbench.common.dmn.api.property.dmn.Id)22 GeneralRectangleDimensionsSet (org.kie.workbench.common.dmn.api.property.dimensions.GeneralRectangleDimensionsSet)18 Name (org.kie.workbench.common.dmn.api.property.dmn.Name)18 Node (org.kie.workbench.common.stunner.core.graph.Node)14 View (org.kie.workbench.common.stunner.core.graph.content.view.View)14 BindableAdapterUtils.getDefinitionId (org.kie.workbench.common.stunner.core.definition.adapter.binding.BindableAdapterUtils.getDefinitionId)13 Test (org.junit.Test)11 InformationItemPrimary (org.kie.workbench.common.dmn.api.definition.model.InformationItemPrimary)8 QName (org.kie.workbench.common.dmn.api.property.dmn.QName)7 FontSize (org.kie.workbench.common.dmn.api.property.styling.FontSize)6 Decision (org.kie.workbench.common.dmn.api.definition.model.Decision)4 DecisionServiceDividerLineY (org.kie.workbench.common.dmn.api.property.dmn.DecisionServiceDividerLineY)4 BusinessKnowledgeModel (org.kie.workbench.common.dmn.api.definition.model.BusinessKnowledgeModel)3 DecisionService (org.kie.workbench.common.dmn.api.definition.model.DecisionService)3 TextAnnotation (org.kie.workbench.common.dmn.api.definition.model.TextAnnotation)3 AllowedAnswers (org.kie.workbench.common.dmn.api.property.dmn.AllowedAnswers)3 Question (org.kie.workbench.common.dmn.api.property.dmn.Question)3 Text (org.kie.workbench.common.dmn.api.property.dmn.Text)3