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);
}
}
}
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);
}
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);
}
}
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);
}
}
}
}
}
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;
}
Aggregations