Search in sources :

Example 1 with DiagramNodeBounds

use of org.eclipse.sapphire.ui.diagram.editor.DiagramNodeBounds in project liferay-ide by liferay.

the class WorkflowDefinitionLayoutPersistenceService method _handleDiagramNodeEvent.

private void _handleDiagramNodeEvent(DiagramNodeEvent event) {
    DiagramNodePart nodePart = event.part();
    if (event instanceof DiagramNodeAddEvent) {
        _read(nodePart);
    } else if (event instanceof DiagramNodeDeleteEvent) {
        _refreshDirtyState();
    } else if (event instanceof DiagramNodeMoveEvent) {
        DiagramNodeBounds nodeBounds = nodePart.getNodeBounds();
        if (nodeBounds.isAutoLayout()) {
            /*
				 * need to add the node bounds to the persistence cache so that
				 * "revert" could work
				 */
            _addNodeToPersistenceCache(nodePart);
            _refreshDirtyState();
        } else if (!nodeBounds.isDefaultPosition()) {
            DiagramNodePart diagramNodePart = event.part();
            _write(diagramNodePart);
        }
    }
}
Also used : DiagramNodeDeleteEvent(org.eclipse.sapphire.ui.diagram.editor.DiagramNodeDeleteEvent) DiagramNodeAddEvent(org.eclipse.sapphire.ui.diagram.editor.DiagramNodeAddEvent) DiagramNodePart(org.eclipse.sapphire.ui.diagram.editor.DiagramNodePart) DiagramNodeMoveEvent(org.eclipse.sapphire.ui.diagram.editor.DiagramNodeMoveEvent) DiagramNodeBounds(org.eclipse.sapphire.ui.diagram.editor.DiagramNodeBounds)

Example 2 with DiagramNodeBounds

use of org.eclipse.sapphire.ui.diagram.editor.DiagramNodeBounds in project liferay-ide by liferay.

the class WorkflowDefinitionLayoutPersistenceService method _handleNodeLayoutChange.

private void _handleNodeLayoutChange(WorkflowNode workflowNode) {
    DiagramNodePart nodePart = _part().getDiagramNodePart(workflowNode);
    WorkflowNodeMetadata metadata = workflowNode.getMetadata().content();
    Position position = metadata.getPosition();
    Value<Integer> valueX = position.getX();
    Value<Integer> valueY = position.getY();
    DiagramNodeBounds nodeBounds = new DiagramNodeBounds(valueX.content(), valueY.content());
    nodePart.setNodeBounds(nodeBounds);
}
Also used : Position(com.liferay.ide.kaleo.core.model.Position) WorkflowNodeMetadata(com.liferay.ide.kaleo.core.model.WorkflowNodeMetadata) DiagramNodePart(org.eclipse.sapphire.ui.diagram.editor.DiagramNodePart) DiagramNodeBounds(org.eclipse.sapphire.ui.diagram.editor.DiagramNodeBounds)

Example 3 with DiagramNodeBounds

use of org.eclipse.sapphire.ui.diagram.editor.DiagramNodeBounds in project liferay-ide by liferay.

the class WorkflowDefinitionLayoutPersistenceService method _load.

private void _load() {
    SapphireDiagramEditorPagePart part = _part();
    part.setGridVisible(part.adapt(WorkflowDefinitionEditor.class).isGridVisible());
    part.setShowGuides(part.adapt(WorkflowDefinitionEditor.class).isShowGuides());
    ConnectionService connService = part.service(ConnectionService.class);
    for (WorkflowNode workflowNode : _definition().getDiagramNodes()) {
        DiagramNodePart nodePart = part.getDiagramNodePart(workflowNode);
        if (nodePart != null) {
            WorkflowNodeMetadata metadata = workflowNode.getMetadata().content(false);
            Position position = metadata.getPosition();
            Value<Integer> valueX = position.getX();
            Value<Integer> valueY = position.getY();
            DiagramNodeBounds bounds = new DiagramNodeBounds(valueX.content(), valueY.content(), -1, -1, false, false);
            nodePart.setNodeBounds(bounds);
            ListFactory<Transition> transitionsList = ListFactory.start();
            for (Transition transition : workflowNode.nearest(CanTransition.class).getTransitions()) {
                transitionsList.add(transition);
            }
            List<Transition> transitions = transitionsList.result();
            for (Transition transition : transitions) {
                DiagramConnectionPart connPart = _getConnectionPart(connService, transition);
                if (connPart != null) {
                    TransitionMetadata transitionMetadata = _getTransitionMetadata(transition, metadata);
                    if (transitionMetadata == null) {
                        continue;
                    }
                    List<ConnectionBendpoint> bendpoints = transitionMetadata.getBendpoints();
                    if (ListUtil.isNotEmpty(bendpoints)) {
                        int index = 0;
                        for (ConnectionBendpoint bendpoint : bendpoints) {
                            connPart.addBendpoint(index++, bendpoint.getX().content(), bendpoint.getY().content());
                        }
                    }
                    Position labelPosition = transitionMetadata.getLabelLocation();
                    if (labelPosition != null) {
                        connPart.setLabelPosition(new Point(labelPosition.getX().content(), labelPosition.getY().content()));
                    }
                }
            }
        }
    }
    for (DiagramConnectionPart connPart : connService.list()) {
        connPart.attach(_connectionPartListener);
    }
}
Also used : ConnectionService(org.eclipse.sapphire.ui.diagram.ConnectionService) ConnectionBendpoint(com.liferay.ide.kaleo.core.model.ConnectionBendpoint) Position(com.liferay.ide.kaleo.core.model.Position) TransitionMetadata(com.liferay.ide.kaleo.core.model.TransitionMetadata) CanTransition(com.liferay.ide.kaleo.core.model.CanTransition) WorkflowNodeMetadata(com.liferay.ide.kaleo.core.model.WorkflowNodeMetadata) Point(org.eclipse.sapphire.ui.Point) WorkflowNode(com.liferay.ide.kaleo.core.model.WorkflowNode) ConnectionBendpoint(com.liferay.ide.kaleo.core.model.ConnectionBendpoint) Point(org.eclipse.sapphire.ui.Point) DiagramNodeBounds(org.eclipse.sapphire.ui.diagram.editor.DiagramNodeBounds) SapphireDiagramEditorPagePart(org.eclipse.sapphire.ui.diagram.editor.SapphireDiagramEditorPagePart) DiagramConnectionPart(org.eclipse.sapphire.ui.diagram.DiagramConnectionPart) CanTransition(com.liferay.ide.kaleo.core.model.CanTransition) Transition(com.liferay.ide.kaleo.core.model.Transition) DiagramNodePart(org.eclipse.sapphire.ui.diagram.editor.DiagramNodePart)

Example 4 with DiagramNodeBounds

use of org.eclipse.sapphire.ui.diagram.editor.DiagramNodeBounds in project liferay-ide by liferay.

the class WorkflowDefinitionLayoutPersistenceService method _handleWorkflowNodeMetaChange.

private void _handleWorkflowNodeMetaChange(WorkflowNodeMetadata workflowNodeMetadata) {
    WorkflowNode workflowNode = workflowNodeMetadata.nearest(WorkflowNode.class);
    if (workflowNode == null) {
        return;
    }
    DiagramNodePart nodePart = _part().getDiagramNodePart(workflowNode);
    if (nodePart != null) {
        Position position = workflowNodeMetadata.getPosition();
        Value<Integer> valueX = position.getX();
        Value<Integer> valueY = position.getY();
        DiagramNodeBounds nodeBounds = nodePart.getNodeBounds();
        if ((nodeBounds.getX() != valueX.content()) || (nodeBounds.getY() != valueY.content())) {
            nodePart.setNodeBounds(new DiagramNodeBounds(valueX.content(), valueY.content()));
        }
    }
    ConnectionService connService = _part().service(ConnectionService.class);
    if (workflowNode instanceof CanTransition) {
        CanTransition canTransition = (CanTransition) workflowNode;
        ElementList<Transition> transitions = canTransition.getTransitions();
        for (Transition transition : transitions) {
            List<Point> bendpoints = new ArrayList<>();
            DiagramConnectionPart connPart = _getConnectionPart(connService, transition);
            if (connPart != null) {
                TransitionMetadata transitionMetadata = _getTransitionMetadata(transition, workflowNodeMetadata);
                if (transitionMetadata != null) {
                    for (ConnectionBendpoint bendpoint : transitionMetadata.getBendpoints()) {
                        bendpoints.add(new Point(bendpoint.getX().content(), bendpoint.getY().content()));
                    }
                    connPart.resetBendpoints(bendpoints);
                }
            }
        }
    }
}
Also used : ConnectionService(org.eclipse.sapphire.ui.diagram.ConnectionService) ConnectionBendpoint(com.liferay.ide.kaleo.core.model.ConnectionBendpoint) Position(com.liferay.ide.kaleo.core.model.Position) TransitionMetadata(com.liferay.ide.kaleo.core.model.TransitionMetadata) ArrayList(java.util.ArrayList) CanTransition(com.liferay.ide.kaleo.core.model.CanTransition) Point(org.eclipse.sapphire.ui.Point) WorkflowNode(com.liferay.ide.kaleo.core.model.WorkflowNode) DiagramNodeBounds(org.eclipse.sapphire.ui.diagram.editor.DiagramNodeBounds) DiagramConnectionPart(org.eclipse.sapphire.ui.diagram.DiagramConnectionPart) CanTransition(com.liferay.ide.kaleo.core.model.CanTransition) Transition(com.liferay.ide.kaleo.core.model.Transition) DiagramNodePart(org.eclipse.sapphire.ui.diagram.editor.DiagramNodePart)

Example 5 with DiagramNodeBounds

use of org.eclipse.sapphire.ui.diagram.editor.DiagramNodeBounds in project liferay-ide by liferay.

the class WorkflowDefinitionLayoutPersistenceService method _isNodeLayoutChanged.

private boolean _isNodeLayoutChanged(DiagramNodePart nodePart) {
    DiagramNodeBounds newBounds = nodePart.getNodeBounds();
    boolean changed = false;
    String nodeId = nodePart.getId();
    if (_nodeBounds.containsKey(nodeId)) {
        DiagramNodeBounds oldBounds = _nodeBounds.get(nodeId);
        if (!newBounds.equals(oldBounds)) {
            changed = true;
        }
    } else {
        changed = true;
    }
    return changed;
}
Also used : DiagramNodeBounds(org.eclipse.sapphire.ui.diagram.editor.DiagramNodeBounds)

Aggregations

DiagramNodeBounds (org.eclipse.sapphire.ui.diagram.editor.DiagramNodeBounds)6 DiagramNodePart (org.eclipse.sapphire.ui.diagram.editor.DiagramNodePart)5 CanTransition (com.liferay.ide.kaleo.core.model.CanTransition)3 Position (com.liferay.ide.kaleo.core.model.Position)3 Transition (com.liferay.ide.kaleo.core.model.Transition)3 WorkflowNode (com.liferay.ide.kaleo.core.model.WorkflowNode)3 DiagramConnectionPart (org.eclipse.sapphire.ui.diagram.DiagramConnectionPart)3 ConnectionBendpoint (com.liferay.ide.kaleo.core.model.ConnectionBendpoint)2 TransitionMetadata (com.liferay.ide.kaleo.core.model.TransitionMetadata)2 WorkflowNodeMetadata (com.liferay.ide.kaleo.core.model.WorkflowNodeMetadata)2 Point (org.eclipse.sapphire.ui.Point)2 ConnectionService (org.eclipse.sapphire.ui.diagram.ConnectionService)2 ArrayList (java.util.ArrayList)1 Element (org.eclipse.sapphire.Element)1 DiagramNodeAddEvent (org.eclipse.sapphire.ui.diagram.editor.DiagramNodeAddEvent)1 DiagramNodeDeleteEvent (org.eclipse.sapphire.ui.diagram.editor.DiagramNodeDeleteEvent)1 DiagramNodeMoveEvent (org.eclipse.sapphire.ui.diagram.editor.DiagramNodeMoveEvent)1 SapphireDiagramEditorPagePart (org.eclipse.sapphire.ui.diagram.editor.SapphireDiagramEditorPagePart)1