use of com.liferay.ide.kaleo.core.model.TransitionMetadata in project liferay-ide by liferay.
the class WorkflowDefinitionLayoutPersistenceService method _handleConnectionBendpointChange.
private void _handleConnectionBendpointChange(Transition transition) {
ConnectionService connService = _part().service(ConnectionService.class);
DiagramConnectionPart connPart = _getConnectionPart(connService, transition);
if (connPart != null) {
List<Point> bendpoints = new ArrayList<>();
WorkflowNode wfNode = transition.nearest(WorkflowNode.class);
ElementHandle<WorkflowNodeMetadata> nodeMetadata = wfNode.getMetadata();
WorkflowNodeMetadata metadata = nodeMetadata.content(false);
TransitionMetadata transitionMetadata = _getTransitionMetadata(transition, metadata);
for (ConnectionBendpoint bendpoint : transitionMetadata.getBendpoints()) {
bendpoints.add(new Point(bendpoint.getX().content(), bendpoint.getY().content()));
}
connPart.resetBendpoints(bendpoints);
}
}
use of com.liferay.ide.kaleo.core.model.TransitionMetadata in project liferay-ide by liferay.
the class WorkflowDefinitionLayoutPersistenceService method _writeTransitionBendPoints.
private void _writeTransitionBendPoints(Transition transition, DiagramConnectionPart connPart) {
WorkflowNode workflowNode = transition.nearest(WorkflowNode.class);
ElementHandle<WorkflowNodeMetadata> nodeMetadata = workflowNode.getMetadata();
WorkflowNodeMetadata metadata = nodeMetadata.content(true);
TransitionMetadata transitionMetadata = _getTransitionMetadata(transition, metadata, true);
transitionMetadata.setName(transition.getName().content());
ElementList<ConnectionBendpoint> bendpointsInMetadataList = transitionMetadata.getBendpoints();
int bendpointsInMetadataSize = bendpointsInMetadataList.size();
List<Point> bendpointsInPartList = connPart.getBendpoints();
int bendpointsInPartSize = bendpointsInPartList.size();
for (int i = 0, n = min(bendpointsInMetadataSize, bendpointsInPartSize); i < n; i++) {
ConnectionBendpoint bendpointInMetadata = bendpointsInMetadataList.get(i);
Point bendpointInPart = bendpointsInPartList.get(i);
if (bendpointInMetadata.getX().content() != bendpointInPart.getX()) {
bendpointInMetadata.setX(bendpointInPart.getX());
}
if (bendpointInMetadata.getY().content() != bendpointInPart.getY()) {
bendpointInMetadata.setY(bendpointInPart.getY());
}
}
if (bendpointsInMetadataSize < bendpointsInPartSize) {
for (int i = bendpointsInMetadataSize; i < bendpointsInPartSize; i++) {
ConnectionBendpoint bendpointInMetadata = bendpointsInMetadataList.insert();
Point bendpointInPart = bendpointsInPartList.get(i);
bendpointInMetadata.setX(bendpointInPart.getX());
bendpointInMetadata.setY(bendpointInPart.getY());
}
} else if (bendpointsInMetadataSize > bendpointsInPartSize) {
for (int i = bendpointsInMetadataSize - 1; i >= bendpointsInPartSize; i--) {
bendpointsInMetadataList.remove(i);
}
}
if ((connPart.getLabelPosition() != null) && !connPart.getLabelPosition().equals(DEFAULT_POINT)) {
transitionMetadata.getLabelLocation().setX(connPart.getLabelPosition().getX());
transitionMetadata.getLabelLocation().setY(connPart.getLabelPosition().getY());
}
}
use of com.liferay.ide.kaleo.core.model.TransitionMetadata in project liferay-ide by liferay.
the class WorkflowDefinitionLayoutPersistenceService method _getTransitionMetadata.
private TransitionMetadata _getTransitionMetadata(Transition transition, WorkflowNodeMetadata nodeMetadata, boolean createIfNecessary) {
TransitionMetadata retval = null;
ElementList<TransitionMetadata> transitionsData = nodeMetadata.getTransitionsMetadata();
for (TransitionMetadata transitionData : transitionsData) {
if (transition.getName().content() != null) {
String transitionName = transition.getName().content();
if (transitionName.equals(transitionData.getName().content())) {
}
retval = transitionData;
break;
}
}
if ((retval == null) && createIfNecessary) {
retval = nodeMetadata.getTransitionsMetadata().insert();
}
return retval;
}
use of com.liferay.ide.kaleo.core.model.TransitionMetadata 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 com.liferay.ide.kaleo.core.model.TransitionMetadata 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);
}
}
}
}
}
Aggregations