Search in sources :

Example 1 with GraphicalConfiguration

use of org.osate.ge.GraphicalConfiguration in project osate2 by osate.

the class DiagramUpdater method updateElements.

/**
 * @param container is the container for which to update the elements
 * @param bos
 * @param connectionElements is a collection to populate with connection elements.
 */
private void updateElements(final DiagramModification m, final DiagramNode container, final Collection<BusinessObjectNode> bos, final Collection<DiagramElement> connectionElements) {
    for (final BusinessObjectNode n : bos) {
        // Get existing element. The updateStructure() pass should have ensured that it exists if a valid element could be created.
        final DiagramElement element = container.getChildByRelativeReference(n.getRelativeReference());
        if (element == null) {
            continue;
        }
        // Set fields
        m.setCompleteness(element, n.getCompleteness());
        // Set name fields
        m.setLabelName(element, infoProvider.getLabelName(element));
        m.setUserInterfaceName(element, infoProvider.getUserInterfaceName(element));
        // Set the graphical Configuration
        final GraphicalConfiguration graphicalConfiguration = infoProvider.getGraphicalConfiguration(element);
        if (graphicalConfiguration == null) {
            ghostAndRemove(m, element);
        } else {
            // Reset position of flow indicators if the start element has changed. This can occur when feature groups are expanded for example.
            if (element.hasPosition() && DiagramElementPredicates.isFlowIndicator(element) && graphicalConfiguration.getConnectionSource() != element.getStartElement()) {
                m.setPosition(element, null);
            }
            m.setGraphicalConfiguration(element, graphicalConfiguration);
            // Set the dock area based on the default docking position
            final DockingPosition defaultDockingPosition = graphicalConfiguration.getDefaultDockingPosition();
            final boolean dockable = defaultDockingPosition != DockingPosition.NOT_DOCKABLE;
            if (dockable) {
                // If parent is docked, the child should use the group docking area
                if (container instanceof DiagramElement && ((DiagramElement) container).getDockArea() != null) {
                    m.setDockArea(element, DockArea.GROUP);
                } else if (element.getDockArea() == null) {
                    m.setDockArea(element, DockArea.fromDockingPosition(defaultDockingPosition));
                }
            } else {
                // Ensure the dock area is null
                m.setDockArea(element, null);
            }
            // Set the initial position if there is a value in the future element position map
            // Set the position after the dock area so that setPosition() will know whether the element is dockable.
            final Map<RelativeBusinessObjectReference, FutureElementInfo> futureElementInfos = futureElementInfoMap.get(container);
            final FutureElementInfo futureElementInfo = futureElementInfos == null ? null : futureElementInfos.get(n.getRelativeReference());
            final Point initialPosition = futureElementInfo != null ? futureElementInfo.position : null;
            if (initialPosition != null) {
                m.setPosition(element, initialPosition);
            }
            if (element.getGraphic() instanceof AgeConnection) {
                // Add connection elements to the list so that they can be access later.
                connectionElements.add(element);
            }
            // Update the element's children
            updateElements(m, element, n.getChildren(), connectionElements);
        }
    }
}
Also used : DiagramElement(org.osate.ge.internal.diagram.runtime.DiagramElement) AgeConnection(org.osate.ge.graphics.internal.AgeConnection) GraphicalConfiguration(org.osate.ge.GraphicalConfiguration) DockingPosition(org.osate.ge.DockingPosition) RelativeBusinessObjectReference(org.osate.ge.RelativeBusinessObjectReference) Point(org.osate.ge.graphics.Point)

Aggregations

DockingPosition (org.osate.ge.DockingPosition)1 GraphicalConfiguration (org.osate.ge.GraphicalConfiguration)1 RelativeBusinessObjectReference (org.osate.ge.RelativeBusinessObjectReference)1 Point (org.osate.ge.graphics.Point)1 AgeConnection (org.osate.ge.graphics.internal.AgeConnection)1 DiagramElement (org.osate.ge.internal.diagram.runtime.DiagramElement)1