Search in sources :

Example 6 with DiscreteConnection

use of org.kie.workbench.common.stunner.core.graph.content.view.DiscreteConnection in project kie-wb-common by kiegroup.

the class WiresConnectorView method updateConnection.

private static void updateConnection(final Connection connection, final MagnetManager.Magnets magnets, final com.ait.lienzo.client.core.types.Point2D abeLocation, final Consumer<Boolean> isAutoConnectionConsumer, final Consumer<WiresMagnet> magnetConsumer) {
    final WiresMagnet[] magnet = new WiresMagnet[] { null };
    final boolean[] auto = new boolean[] { false };
    if (null != connection) {
        final DiscreteConnection dc = connection instanceof DiscreteConnection ? (DiscreteConnection) connection : null;
        if (null != dc) {
            // Obtain the magnet index and auto flag, if the connection is a discrete type and it has been already set.
            dc.getMagnetIndex().ifPresent(index -> magnet[0] = magnets.getMagnet(index));
            auto[0] = dc.isAuto();
        }
        // If still no magnet found from the connection's cache, figure it out as by the connection's location.
        if (null == magnet[0]) {
            magnet[0] = getMagnetForConnection(connection, magnets, abeLocation);
            // Update the discrete connection magnet cached index, if possible.
            if (null != dc) {
                dc.setIndex(magnet[0].getIndex());
            }
        }
    }
    // Call the magnet and auto connection consumers to assign the new values.
    isAutoConnectionConsumer.accept(auto[0]);
    magnetConsumer.accept(magnet[0]);
}
Also used : DiscreteConnection(org.kie.workbench.common.stunner.core.graph.content.view.DiscreteConnection) WiresMagnet(com.ait.lienzo.client.core.shape.wires.WiresMagnet)

Aggregations

DiscreteConnection (org.kie.workbench.common.stunner.core.graph.content.view.DiscreteConnection)6 BusinessRuleTask (org.kie.workbench.common.stunner.bpmn.definition.BusinessRuleTask)2 ScriptTask (org.kie.workbench.common.stunner.bpmn.definition.ScriptTask)2 UserTask (org.kie.workbench.common.stunner.bpmn.definition.UserTask)2 Node (org.kie.workbench.common.stunner.core.graph.Node)2 ViewConnector (org.kie.workbench.common.stunner.core.graph.content.view.ViewConnector)2 WiresMagnet (com.ait.lienzo.client.core.shape.wires.WiresMagnet)1