Package org.activiti.bpmn.model

Examples of org.activiti.bpmn.model.SequenceFlow


  public void validateExclusiveGateway(Process process, ExclusiveGateway exclusiveGateway, List<ValidationError> errors) {
    if (exclusiveGateway.getOutgoingFlows().isEmpty()) {
      addError(errors, Problems.EXCLUSIVE_GATEWAY_NO_OUTGOING_SEQ_FLOW, process, exclusiveGateway,
          "Exclusive gateway has no outgoing sequence flow");
    } else if (exclusiveGateway.getOutgoingFlows().size() == 1) {
      SequenceFlow sequenceFlow = exclusiveGateway.getOutgoingFlows().get(0);
       if (StringUtils.isNotEmpty(sequenceFlow.getConditionExpression())) {
         addError(errors, Problems.EXCLUSIVE_GATEWAY_CONDITION_NOT_ALLOWED_ON_SINGLE_SEQ_FLOW, process, exclusiveGateway,
             "Exclusive gateway has only one outgoing sequence flow. This is not allowed to have a condition.");
      }
    } else {
      String defaultSequenceFlow = exclusiveGateway.getDefaultFlow();
View Full Code Here


    process.addFlowElement(startEvent);
    UserTask task = new UserTask();
    task.setId("reviewTask");
    task.setAssignee("kermit");
    process.addFlowElement(task);
    SequenceFlow flow1 = new SequenceFlow();
    flow1.setId("flow1");
    flow1.setSourceRef("startEvent1");
    flow1.setTargetRef("reviewTask");
    process.addFlowElement(flow1);
    EndEvent endEvent = new EndEvent();
    endEvent.setId("endEvent1");
    process.addFlowElement(endEvent);
   
View Full Code Here

  }

  @SuppressWarnings("unchecked")
  public PictogramElement add(IAddContext context) {
    IAddConnectionContext addConContext = (IAddConnectionContext) context;
    SequenceFlow addedSequenceFlow = (SequenceFlow) context.getNewObject();
   
    Anchor sourceAnchor = null;
    Anchor targetAnchor = null;
    if(addConContext.getSourceAnchor() == null) {
      EList<Shape> shapeList = getDiagram().getChildren();
      for (Shape shape : shapeList) {
        FlowNode flowNode = (FlowNode) getBusinessObjectForPictogramElement(shape.getGraphicsAlgorithm().getPictogramElement());
        if(flowNode == null || flowNode.getId() == null || addedSequenceFlow.getSourceRef() == null ||
                addedSequenceFlow.getTargetRef() == null) continue;
        if(flowNode.getId().equals(addedSequenceFlow.getSourceRef())) {
          EList<Anchor> anchorList = ((ContainerShape) shape).getAnchors();
          for (Anchor anchor : anchorList) {
            if(anchor instanceof ChopboxAnchor) {
              sourceAnchor = anchor;
              break;
            }
          }
        }
       
        if(flowNode.getId().equals(addedSequenceFlow.getTargetRef())) {
          EList<Anchor> anchorList = ((ContainerShape) shape).getAnchors();
          for (Anchor anchor : anchorList) {
            if(anchor instanceof ChopboxAnchor) {
              targetAnchor = anchor;
              break;
            }
          }
        }
      }
    } else {
      sourceAnchor = addConContext.getSourceAnchor();
      targetAnchor = addConContext.getTargetAnchor();
    }
   
    if(sourceAnchor == null || targetAnchor == null) {
      return null;
    }

    IPeCreateService peCreateService = Graphiti.getPeCreateService();
    // CONNECTION WITH POLYLINE
    FreeFormConnection connection = peCreateService.createFreeFormConnection(getDiagram());
    connection.setStart(sourceAnchor);
    connection.setEnd(targetAnchor);
    sourceAnchor.getOutgoingConnections().add(connection);
    targetAnchor.getIncomingConnections().add(connection);

    Bpmn2MemoryModel model = ModelHandler.getModel(EcoreUtil.getURI(getDiagram()));
   
    FlowElement sourceElement = model.getFlowElement(addedSequenceFlow.getSourceRef());
    FlowElement targetElement = model.getFlowElement(addedSequenceFlow.getTargetRef());
   
    GraphicsAlgorithm sourceGraphics = getPictogramElement(sourceElement).getGraphicsAlgorithm();
    GraphicsAlgorithm targetGraphics = getPictogramElement(targetElement).getGraphicsAlgorithm();
   
    List<GraphicInfo> bendpointList = null;
    if(addConContext.getProperty("org.activiti.designer.bendpoints") != null) {
      bendpointList = (List<GraphicInfo>) addConContext.getProperty("org.activiti.designer.bendpoints");
    }
   
    if(bendpointList != null && bendpointList.size() >= 0) {
      for (GraphicInfo graphicInfo : bendpointList) {
        Point bendPoint = StylesFactory.eINSTANCE.createPoint();
        bendPoint.setX((int)graphicInfo.getX());
        bendPoint.setY((int)graphicInfo.getY());
        connection.getBendpoints().add(bendPoint);
      }
     
    } else {
     
      Shape sourceShape = (Shape) getPictogramElement(sourceElement);
      ILocation sourceShapeLocation = Graphiti.getLayoutService().getLocationRelativeToDiagram(sourceShape);
      int sourceX = sourceShapeLocation.getX();
      int sourceY = sourceShapeLocation.getY();
     
      Shape targetShape = (Shape) getPictogramElement(targetElement);
      ILocation targetShapeLocation = Graphiti.getLayoutService().getLocationRelativeToDiagram(targetShape);
      int targetX = targetShapeLocation.getX();
      int targetY = targetShapeLocation.getY();
     
      if (sourceElement instanceof Gateway && targetElement instanceof Gateway == false) {
        if (((sourceGraphics.getY() + 10) < targetGraphics.getY()
            || (sourceGraphics.getY() - 10) > targetGraphics.getY())  &&
            (sourceGraphics.getX() + (sourceGraphics.getWidth() / 2)) < targetGraphics.getX()) {
         
          boolean subProcessWithBendPoint = false;
          if(targetElement instanceof SubProcess) {
            int middleSub = targetGraphics.getY() + (targetGraphics.getHeight() / 2);
            if((sourceGraphics.getY() + 20) < middleSub || (sourceGraphics.getY() - 20) > middleSub) {
              subProcessWithBendPoint = true;
            }
          }
         
          if(targetElement instanceof SubProcess == false || subProcessWithBendPoint == true) {
            Point bendPoint = StylesFactory.eINSTANCE.createPoint();
            bendPoint.setX(sourceX + 20);
            bendPoint.setY(targetY + (targetGraphics.getHeight() / 2));
            connection.getBendpoints().add(bendPoint);
          }
        }
      } else if (targetElement instanceof Gateway) {
        if (((sourceGraphics.getY() + 10) < targetGraphics.getY()
            || (sourceGraphics.getY() - 10) > targetGraphics.getY()) &&
            (sourceGraphics.getX() + sourceGraphics.getWidth()) < targetGraphics.getX()) {
         
          boolean subProcessWithBendPoint = false;
          if(sourceElement instanceof SubProcess) {
            int middleSub = sourceGraphics.getY() + (sourceGraphics.getHeight() / 2);
            if((middleSub + 20) < targetGraphics.getY() || (middleSub - 20) > targetGraphics.getY()) {
              subProcessWithBendPoint = true;
            }
          }
         
          if(sourceElement instanceof SubProcess == false || subProcessWithBendPoint == true) {
            Point bendPoint = StylesFactory.eINSTANCE.createPoint();
            bendPoint.setX(targetX + 20);
            bendPoint.setY(sourceY + (sourceGraphics.getHeight() / 2));
            connection.getBendpoints().add(bendPoint);
          }
        }
      } else if (targetElement instanceof EndEvent) {
        int middleSource = sourceGraphics.getY() + (sourceGraphics.getHeight() / 2);
        int middleTarget = targetGraphics.getY() + (targetGraphics.getHeight() / 2);
        if (((middleSource + 10) < middleTarget &&
            (sourceGraphics.getX() + sourceGraphics.getWidth()) < targetGraphics.getX()) ||
           
            ((middleSource - 10) > middleTarget &&
            (sourceGraphics.getX() + sourceGraphics.getWidth()) < targetGraphics.getX())) {
         
          Point bendPoint = StylesFactory.eINSTANCE.createPoint();
          bendPoint.setX(targetX + (targetGraphics.getWidth() / 2));
          bendPoint.setY(sourceY + (sourceGraphics.getHeight() / 2));
          connection.getBendpoints().add(bendPoint);
        }
      }
    }

    IGaService gaService = Graphiti.getGaService();
    Polyline polyline = gaService.createPolyline(connection);
    polyline.setLineStyle(LineStyle.SOLID);
    polyline.setForeground(Graphiti.getGaService().manageColor(getDiagram(), IColorConstant.BLACK));

    // create link and wire it
    link(connection, addedSequenceFlow);

    // add dynamic text decorator for the reference name
    ConnectionDecorator textDecorator = peCreateService.createConnectionDecorator(connection, true, 0.5, true);
    MultiText text = gaService.createDefaultMultiText(getDiagram(), textDecorator);
    text.setStyle(StyleUtil.getStyleForTask((getDiagram())));
    text.setHorizontalAlignment(Orientation.ALIGNMENT_LEFT);
    text.setVerticalAlignment(Orientation.ALIGNMENT_CENTER);
    if (OSUtil.getOperatingSystem() == OSEnum.Mac) {
      text.setFont(gaService.manageFont(getDiagram(), text.getFont().getName(), 11));
    }
   
    if(addConContext.getProperty("org.activiti.designer.connectionlabel") != null) {
      GraphicInfo labelLocation = (GraphicInfo) addConContext.getProperty("org.activiti.designer.connectionlabel");
      gaService.setLocation(text, (int)labelLocation.getX(), (int)labelLocation.getY());
    } else {
      gaService.setLocation(text, 10, 0);
    }
   
    if (StringUtils.isNotEmpty(addedSequenceFlow.getName())) {
      TextUtil.setTextSize(addedSequenceFlow.getName(), text);
    }

    // set reference name in the text decorator
    text.setValue(addedSequenceFlow.getName());

    // add static graphical decorators (composition and navigable)
    ConnectionDecorator cd = peCreateService.createConnectionDecorator(connection, false, 1.0, true);
    createArrow(cd);
View Full Code Here

   
    for (final PictogramElement pictogramElement : context.getPictogramElements()) {
      if(getBusinessObjectForPictogramElement(pictogramElement) == null) continue;
      final Object boObject = getBusinessObjectForPictogramElement(pictogramElement);
      if(boObject instanceof SequenceFlow == true) {
        final SequenceFlow sequenceFlow = (SequenceFlow) boObject;
       
        getDiagram().getPictogramLinks().remove(pictogramElement.getLink());
        getDiagram().getConnections().remove(pictogramElement);
       
        Bpmn2MemoryModel model = ModelHandler.getModel(EcoreUtil.getURI(getDiagram()));
        FlowNode sourceNode = null;
        String sourceRef = sequenceFlow.getSourceRef();
        if (StringUtils.isNotEmpty(sourceRef)) {
          sourceNode = (FlowNode) model.getBpmnModel().getFlowElement(sourceRef);
        }
       
        FlowNode targetNode = null;
        String targetRef = sequenceFlow.getTargetRef();
        if (StringUtils.isNotEmpty(targetRef)) {
          targetNode = (FlowNode) model.getBpmnModel().getFlowElement(targetRef);
        }
       
        if (sourceNode != null) {
          sourceNode.getOutgoingFlows().remove(sequenceFlow);
        }
       
        if (targetNode != null) {
          targetNode.getIncomingFlows().remove(sequenceFlow);
        }
       
        List<Process> processes = model.getBpmnModel().getProcesses();
        for (Process process : processes) {
          process.removeFlowElement(sequenceFlow.getId());
          removeFlow(sequenceFlow, process);
        }
      }
    }
  }
View Full Code Here

    FlowNode source = getFlowNode(context.getSourceAnchor());
    FlowNode target = getFlowNode(context.getTargetAnchor());

    if (source != null && target != null) {
      // create new business object
      SequenceFlow sequenceFlow = createSequenceFlow(source, target, context);

      // add connection for business object
      AddConnectionContext addContext = new AddConnectionContext(context.getSourceAnchor(), context.getTargetAnchor());
      addContext.setNewObject(sequenceFlow);
      newConnection = (Connection) getFeatureProvider().addIfPossible(addContext);
View Full Code Here

  /**
   * Creates a SequenceFlow between two BaseElements.
   */
  private SequenceFlow createSequenceFlow(FlowNode source, FlowNode target, ICreateConnectionContext context) {
    SequenceFlow sequenceFlow = new SequenceFlow();

    sequenceFlow.setId(getNextId());
    sequenceFlow.setSourceRef(source.getId());
    sequenceFlow.setTargetRef(target.getId());

    if (PreferencesUtil.getBooleanPreference(Preferences.EDITOR_ADD_LABELS_TO_NEW_SEQUENCEFLOWS)) {
      sequenceFlow.setName(String.format("to %s", target.getName()));
    } else {
      sequenceFlow.setName("");
    }

    ContainerShape targetContainer = null;
    if (source instanceof BoundaryEvent) {
      BoundaryEvent boundaryEvent = (BoundaryEvent) source;
View Full Code Here

    return FEATURE_ID_KEY;
  }

  @Override
  protected Class< ? extends BaseElement> getFeatureClass() {
    return new SequenceFlow().getClass();
  }
View Full Code Here

  public void postReconnect(IReconnectionContext context) {
    Bpmn2MemoryModel model = ModelHandler.getModel(EcoreUtil.getURI(getDiagram()));
    Object connectionObject = getFeatureProvider().getBusinessObjectForPictogramElement(context.getConnection());
    if(connectionObject instanceof SequenceFlow == false) return;
   
    SequenceFlow flow = (SequenceFlow) connectionObject;
   
    Object targetObject = getFeatureProvider().getBusinessObjectForPictogramElement(context.getTargetPictogramElement());
    if(targetObject instanceof FlowNode == false) return;
    FlowNode targetElement = (FlowNode) targetObject;
   
    if(ReconnectionContext.RECONNECT_TARGET.equalsIgnoreCase(context.getReconnectType())) {
      List<SequenceFlow> flowList = targetElement.getIncomingFlows();
      boolean found = false;
      for (SequenceFlow sequenceFlow : flowList) {
        if(sequenceFlow.getId().equals(flow.getId())) {
          found = true;
        }
      }
     
      if(found == false) {
       
        FlowNode targetFlowNode = (FlowNode) model.getBpmnModel().getFlowElement(flow.getTargetRef());
      
        if (targetFlowNode != null) {
          // remove old target
          targetFlowNode.getIncomingFlows().remove(flow);
        }
       
        targetElement.getIncomingFlows().add(flow);
        flow.setTargetRef(targetElement.getId());
      }
     
    } else if(ReconnectionContext.RECONNECT_SOURCE.equalsIgnoreCase(context.getReconnectType())) {
      // targetElement is the source side of the sequence flow
      List<SequenceFlow> flowList = targetElement.getOutgoingFlows();
      boolean found = false;
      for (SequenceFlow sequenceFlow : flowList) {
        if(sequenceFlow.equals(flow)) {
          found = true;
        }
      }
     
      if(found == false) {
       
        FlowNode sourceFlowNode = (FlowNode) model.getBpmnModel().getFlowElement(flow.getSourceRef());
        ContainerShape sourceElement = (ContainerShape) getFeatureProvider().getPictogramElementForBusinessObject(sourceFlowNode);
        ContainerShape oldParentContainer = sourceElement.getContainer();
        ContainerShape newParentContainer = ((ContainerShape) context.getTargetPictogramElement()).getContainer();
       
        if (oldParentContainer != newParentContainer) {
         
          if (oldParentContainer instanceof Diagram) {
            ModelHandler.getModel(EcoreUtil.getURI(getDiagram())).getBpmnModel().getMainProcess().removeFlowElement(flow.getId());

          } else {
            Object parentObject = getFeatureProvider().getBusinessObjectForPictogramElement(oldParentContainer);
            if (parentObject instanceof SubProcess) {
              ((SubProcess) parentObject).removeFlowElement(flow.getId());

            } else if (parentObject instanceof Lane) {
              Lane lane = (Lane) parentObject;
              lane.getParentProcess().removeFlowElement(flow.getId());
            }
          }
         
          if (newParentContainer instanceof Diagram) {
            ModelHandler.getModel(EcoreUtil.getURI(getDiagram())).getBpmnModel().getMainProcess().addFlowElement(flow);

          } else {
            Object parentObject = getBusinessObjectForPictogramElement(newParentContainer);
            if (parentObject instanceof SubProcess) {
              ((SubProcess) parentObject).addFlowElement(flow);

            } else if (parentObject instanceof Lane) {
              Lane lane = (Lane) parentObject;
              lane.getParentProcess().addFlowElement(flow);
            }
          }
        }
       
        // remove old source
        if (sourceFlowNode != null) {
          sourceFlowNode.getOutgoingFlows().remove(flow);
        }
       
        targetElement.getOutgoingFlows().add(flow);
        flow.setSourceRef(targetElement.getId());
       
      }
    }
   
    super.postReconnect(context);
View Full Code Here

      Object bo = getBusinessObject(pe);
      // the filter assured, that it is a EClass
      if (bo == null)
        return;

      SequenceFlow sequenceFlow = ((SequenceFlow) bo);
      if(sequenceFlow.getConditionExpression() != null) {
       
        conditionExpressionText.removeFocusListener(listener);
        String condition = sequenceFlow.getConditionExpression();
        conditionExpressionText.setText(condition);
        conditionExpressionText.addFocusListener(listener);
      } else {
        conditionExpressionText.setText("");
      }
View Full Code Here

        drawAssociationsInList(((SubProcess) flowElement).getArtifacts(), model);

      } else if (flowElement instanceof SequenceFlow == false) {
        continue;
      } else {
        SequenceFlow sequenceFlow = (SequenceFlow) flowElement;
        drawSequenceFlow(sequenceFlow, model);
      }
    }
  }
View Full Code Here

TOP

Related Classes of org.activiti.bpmn.model.SequenceFlow

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.