Search in sources :

Example 6 with BaseElement

use of org.eclipse.bpmn2.BaseElement in project kie-wb-common by kiegroup.

the class Bpmn2JsonUnmarshaller method updateShapeBoundsInSubprocessInLanes.

public void updateShapeBoundsInSubprocessInLanes(BPMNPlane plane, BaseElement ele, SubProcess sub, float parentX, float parentY) {
    for (FlowElement subEle : sub.getFlowElements()) {
        Bounds subEleBounds = getBoundsForElement(subEle, plane);
        if (subEleBounds != null) {
            subEleBounds.setX(subEleBounds.getX() + parentX);
            subEleBounds.setY(subEleBounds.getY() + parentY);
        }
        if (subEle instanceof SubProcess) {
            updateShapeBoundsInSubprocessInLanes(plane, ele, (SubProcess) subEle, subEleBounds.getX(), subEleBounds.getY());
        }
    }
}
Also used : AdHocSubProcess(org.eclipse.bpmn2.AdHocSubProcess) SubProcess(org.eclipse.bpmn2.SubProcess) FlowElement(org.eclipse.bpmn2.FlowElement) Bounds(org.eclipse.dd.dc.Bounds)

Example 7 with BaseElement

use of org.eclipse.bpmn2.BaseElement in project kie-wb-common by kiegroup.

the class Bpmn2JsonUnmarshaller method createBpmnShapeForElement.

private void createBpmnShapeForElement(BpmnDiFactory factory, BPMNPlane plane, BaseElement element) {
    Bounds bounds = _bounds.get(element.getId());
    if (bounds != null) {
        BPMNShape shape = factory.createBPMNShape();
        shape.setBpmnElement(element);
        shape.setBounds(bounds);
        plane.getPlaneElement().add(shape);
    }
}
Also used : Bounds(org.eclipse.dd.dc.Bounds) BPMNShape(org.eclipse.bpmn2.di.BPMNShape)

Example 8 with BaseElement

use of org.eclipse.bpmn2.BaseElement in project kie-wb-common by kiegroup.

the class Bpmn2JsonUnmarshaller method applyBaseElementProperties.

protected void applyBaseElementProperties(BaseElement baseElement, Map<String, String> properties) {
    if (properties.get("documentation") != null && !"".equals(properties.get("documentation"))) {
        if (baseElement instanceof Definitions) {
            this.processDocs = properties.get("documentation");
        } else {
            baseElement.getDocumentation().add(createDocumentation(wrapInCDATABlock(properties.get("documentation"))));
        }
    }
    if (baseElement.getId() == null || baseElement.getId().length() < 1) {
        baseElement.setId(properties.get("resourceId"));
    }
    if (properties.get("bgcolor") != null && properties.get("bgcolor").length() > 0) {
        if (!(_elementColors.containsKey(baseElement.getId()))) {
            List<String> colorsList = new ArrayList<String>();
            colorsList.add("bgcolor:" + properties.get("bgcolor"));
            _elementColors.put(baseElement.getId(), colorsList);
        } else {
            _elementColors.get(baseElement.getId()).add("bgcolor:" + properties.get("bgcolor"));
        }
    }
    if (properties.get("isselectable") != null && properties.get("isselectable").length() > 0) {
        ExtendedMetaData metadata = ExtendedMetaData.INSTANCE;
        EAttributeImpl extensionAttribute = (EAttributeImpl) metadata.demandFeature("http://www.jboss.org/drools", "selectable", false, false);
        SimpleFeatureMapEntry extensionEntry = new SimpleFeatureMapEntry(extensionAttribute, properties.get("isselectable"));
        baseElement.getAnyAttribute().add(extensionEntry);
    }
    if (properties.get("bordercolor") != null && properties.get("bordercolor").length() > 0) {
        if (!(_elementColors.containsKey(baseElement.getId()))) {
            List<String> colorsList = new ArrayList<String>();
            colorsList.add("bordercolor:" + properties.get("bordercolor"));
            _elementColors.put(baseElement.getId(), colorsList);
        } else {
            _elementColors.get(baseElement.getId()).add("bordercolor:" + properties.get("bordercolor"));
        }
    }
    if (properties.get("fontsize") != null && properties.get("fontsize").length() > 0) {
        ExtendedMetaData metadata = ExtendedMetaData.INSTANCE;
        EAttributeImpl extensionAttribute = (EAttributeImpl) metadata.demandFeature("http://www.jboss.org/drools", "fontsize", false, false);
        SimpleFeatureMapEntry extensionEntry = new SimpleFeatureMapEntry(extensionAttribute, properties.get("fontsize"));
        baseElement.getAnyAttribute().add(extensionEntry);
    }
    if (properties.get("fontcolor") != null && properties.get("fontcolor").length() > 0) {
        if (!(_elementColors.containsKey(baseElement.getId()))) {
            List<String> colorsList = new ArrayList<String>();
            colorsList.add("fontcolor:" + properties.get("fontcolor"));
            _elementColors.put(baseElement.getId(), colorsList);
        } else {
            _elementColors.get(baseElement.getId()).add("fontcolor:" + properties.get("fontcolor"));
        }
    }
}
Also used : EAttributeImpl(org.eclipse.emf.ecore.impl.EAttributeImpl) Definitions(org.eclipse.bpmn2.Definitions) ArrayList(java.util.ArrayList) SimpleFeatureMapEntry(org.eclipse.emf.ecore.impl.EStructuralFeatureImpl.SimpleFeatureMapEntry) ExtendedMetaData(org.eclipse.emf.ecore.util.ExtendedMetaData)

Example 9 with BaseElement

use of org.eclipse.bpmn2.BaseElement in project kie-wb-common by kiegroup.

the class Bpmn2JsonUnmarshaller method updateShapeBounds.

public void updateShapeBounds(Definitions def, BPMNPlane plane, BaseElement ele) {
    if (ele instanceof Lane) {
        Lane nextLane = (Lane) ele;
        Bounds laneBounds = getBoundsForElement(nextLane, plane);
        updateShapeBoundsInLanes(plane, ele, nextLane, laneBounds.getX(), laneBounds.getY());
    } else {
        List<RootElement> rootElements = def.getRootElements();
        for (RootElement root : rootElements) {
            if (root instanceof Process) {
                Process process = (Process) root;
                List<FlowElement> flowElements = process.getFlowElements();
                boolean foundAsTopLevel = false;
                for (FlowElement fe : flowElements) {
                    if (fe.getId().equals(ele.getId())) {
                        foundAsTopLevel = true;
                        break;
                    }
                }
                if (!foundAsTopLevel) {
                    for (FlowElement fe : flowElements) {
                        if (fe instanceof SubProcess) {
                            SubProcess sp = (SubProcess) fe;
                            // process if this subprocess is not in a lane already. otherwise we already updated it
                            if (sp.getLanes().size() < 1) {
                                // find the subprocess bounds
                                Bounds subprocessBounds = getBoundsForElement(fe, plane);
                                if (subprocessBounds != null) {
                                    updateShapeBoundsInSubprocess(plane, ele, (SubProcess) fe, subprocessBounds.getX(), subprocessBounds.getY());
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
Also used : AdHocSubProcess(org.eclipse.bpmn2.AdHocSubProcess) SubProcess(org.eclipse.bpmn2.SubProcess) RootElement(org.eclipse.bpmn2.RootElement) FlowElement(org.eclipse.bpmn2.FlowElement) Bounds(org.eclipse.dd.dc.Bounds) Lane(org.eclipse.bpmn2.Lane) AdHocSubProcess(org.eclipse.bpmn2.AdHocSubProcess) SubProcess(org.eclipse.bpmn2.SubProcess) Process(org.eclipse.bpmn2.Process)

Example 10 with BaseElement

use of org.eclipse.bpmn2.BaseElement in project kie-wb-common by kiegroup.

the class DIZorderComparator method compareShape.

private int compareShape(BPMNShape a, BPMNShape b) {
    BaseElement aElem = a.getBpmnElement();
    BaseElement bElem = b.getBpmnElement();
    boolean aIsSecondTier = aElem instanceof Lane || aElem instanceof SubProcess;
    boolean bIsSecondTier = bElem instanceof Lane || bElem instanceof SubProcess;
    if (aIsSecondTier && bIsSecondTier) {
        if (isParent(aElem, bElem)) {
            return -1;
        } else if (isParent(bElem, aElem)) {
            return 1;
        }
        return 0;
    } else if (aIsSecondTier && !bIsSecondTier) {
        return -1;
    } else if (!aIsSecondTier && bIsSecondTier) {
        return 1;
    }
    return 0;
}
Also used : SubProcess(org.eclipse.bpmn2.SubProcess) BaseElement(org.eclipse.bpmn2.BaseElement) Lane(org.eclipse.bpmn2.Lane)

Aggregations

SubProcess (org.eclipse.bpmn2.SubProcess)9 AdHocSubProcess (org.eclipse.bpmn2.AdHocSubProcess)8 Bounds (org.eclipse.dd.dc.Bounds)7 Lane (org.eclipse.bpmn2.Lane)6 Process (org.eclipse.bpmn2.Process)5 SimpleFeatureMapEntry (org.eclipse.emf.ecore.impl.EStructuralFeatureImpl.SimpleFeatureMapEntry)5 FeatureMap (org.eclipse.emf.ecore.util.FeatureMap)5 ArrayList (java.util.ArrayList)4 ExtensionAttributeValue (org.eclipse.bpmn2.ExtensionAttributeValue)4 FlowElement (org.eclipse.bpmn2.FlowElement)4 Artifact (org.eclipse.bpmn2.Artifact)3 FlowNode (org.eclipse.bpmn2.FlowNode)3 RootElement (org.eclipse.bpmn2.RootElement)3 List (java.util.List)2 Association (org.eclipse.bpmn2.Association)2 BaseElement (org.eclipse.bpmn2.BaseElement)2 DataInputAssociation (org.eclipse.bpmn2.DataInputAssociation)2 DataOutputAssociation (org.eclipse.bpmn2.DataOutputAssociation)2 Definitions (org.eclipse.bpmn2.Definitions)2 ItemDefinition (org.eclipse.bpmn2.ItemDefinition)2