Package org.eclipse.bpmn2.di

Examples of org.eclipse.bpmn2.di.BPMNShape


  public static void resizePartipantBandContainerShapes(int w, int h, List<ContainerShape> top,
      List<ContainerShape> bottom, Diagram diagram) {

    int y = 0;
    for (ContainerShape container : top) {
      BPMNShape bpmnShape = BusinessObjectUtil.getFirstElementOfType(container, BPMNShape.class);
      Bounds bounds = bpmnShape.getBounds();
      int hAcc = (int) bounds.getHeight();
      gaService.setLocationAndSize(container.getGraphicsAlgorithm(), 0, y, w, hAcc);
      y += hAcc;
      resizeParticipantBandChildren(container, w);
      DIUtils.updateDIShape(container);
      AnchorUtil.relocateFixPointAnchors(container, w, (int) bounds.getHeight());
      AnchorUtil.reConnect(bpmnShape, diagram);
    }

    Collections.reverse(bottom); // start from bottom towards center
    y = h;
    for (ContainerShape container : bottom) {
      BPMNShape bpmnShape = BusinessObjectUtil.getFirstElementOfType(container, BPMNShape.class);
      Bounds bounds = bpmnShape.getBounds();
      y -= bounds.getHeight();
      gaService.setLocationAndSize(container.getGraphicsAlgorithm(), 0, y, w, (int) bounds.getHeight());
      resizeParticipantBandChildren(container, w);
      DIUtils.updateDIShape(container);
      AnchorUtil.relocateFixPointAnchors(container, w, (int) bounds.getHeight());
View Full Code Here


        EObject parent = c.getEnd().eContainer();
        if (parent instanceof PictogramElement) {
          peService.deletePictogramElement((PictogramElement) parent);
        }
      }
      BPMNShape bpmnShape = BusinessObjectUtil.getFirstElementOfType(container, BPMNShape.class);
      diElements.remove(bpmnShape);
      peService.deletePictogramElement(container);
    }

    GraphicsAlgorithm ga = choreographyContainer.getGraphicsAlgorithm();
    IDimension size = gaService.calculateSize(ga);

    List<ContainerShape> newContainers = new ArrayList<ContainerShape>();
    int y = 0;
    boolean first = true;

    List<InteractionNode> sources = new ArrayList<InteractionNode>();
    if (choreography instanceof ChoreographyTask) {
      for (MessageFlow message : ((ChoreographyTask) choreography).getMessageFlowRef()) {
        sources.add(message.getSourceRef());
      }
    }

    Iterator<Participant> iterator = newParticipants.iterator();
    while (iterator.hasNext()) {
      Participant participant = iterator.next();

      ContainerShape bandShape = peService.createContainerShape(choreographyContainer, true);

      ParticipantBandKind bandKind = getNewParticipantBandKind(choreography, participant, first,
          !iterator.hasNext());

      boolean multiple = participant.getParticipantMultiplicity() != null
          && participant.getParticipantMultiplicity().getMaximum() > 1;

      int w = size.getWidth();
      int h = multiple ? 40 : 20;

      BPMNShape bpmnShape = DIUtils.createDIShape(bandShape, participant, 0, y + h, w, h, fp, diagram);
      bpmnShape.setChoreographyActivityShape(BusinessObjectUtil.getFirstElementOfType(choreographyContainer,
          BPMNShape.class));
      bpmnShape.setIsMarkerVisible(multiple);
      bpmnShape.setParticipantBandKind(bandKind);
      bpmnShape.setIsMessageVisible(sources.contains(participant));
      createParticipantBandContainerShape(bandKind, choreographyContainer, bandShape, bpmnShape, showNames);
      if (multiple) {
        drawMultiplicityMarkers(bandShape);
      }
      newContainers.add(bandShape);
View Full Code Here

    }

    Iterator<ContainerShape> iterator = bandContainers.iterator();
    while (iterator.hasNext()) {
      ContainerShape bandContainer = iterator.next();
      BPMNShape bpmnShape = BusinessObjectUtil.getFirstElementOfType(bandContainer, BPMNShape.class);
      if (bpmnShape.isIsMessageVisible()) {
        shapesWithVisileMessages.add(bandContainer);
      }
    }

    boolean shouldDrawTopMessage = !Collections.disjoint(topAndBottom.getFirst(), shapesWithVisileMessages);
    boolean shouldDrawBottomMessage = !Collections.disjoint(topAndBottom.getSecond(), shapesWithVisileMessages);

    String topMessageName = null;
    String bottomMessageName = null;

    if (shouldDrawTopMessage) {
      topMessageName = getMessageName(messageFlows, topAndBottom.getFirst());
    }
    if (topMessageName == null) {
      topMessageName = new String();
    }

    if (shouldDrawBottomMessage) {
      bottomMessageName = getMessageName(messageFlows, topAndBottom.getSecond());
    }
    if (bottomMessageName == null) {
      bottomMessageName = new String();
    }

    BPMNShape bpmnShape = BusinessObjectUtil.getFirstElementOfType(choreographyContainer, BPMNShape.class);
    Bounds bounds = bpmnShape.getBounds();
    int x = (int) ((bounds.getX() + bounds.getWidth() / 2) - (ENV_W / 2));

    if (!hasTopMessage && shouldDrawTopMessage) {
      int y = (int) (bounds.getY() - ENVELOPE_HEIGHT_MODIFIER - ENV_H);
      drawMessageLink(topMessageName, topBoundaryAnchor, x, y, isFilled(topAndBottom.getFirst()));
View Full Code Here

  }

  private static boolean isFilled(List<ContainerShape> bands) {
    boolean filled = true;
    for (ContainerShape band : bands) {
      BPMNShape bpmnShape = BusinessObjectUtil.getFirstElementOfType(band, BPMNShape.class);
      if (!bpmnShape.isIsMessageVisible()) {
        continue;
      }
      ParticipantBandKind bandKind = bpmnShape.getParticipantBandKind();
      if (bandKind == ParticipantBandKind.TOP_INITIATING || bandKind == ParticipantBandKind.BOTTOM_INITIATING
          || bandKind == ParticipantBandKind.MIDDLE_INITIATING) {
        filled = false;
        break;
      }
View Full Code Here

  }

  private static String getMessageName(List<MessageFlow> messageFlows, List<ContainerShape> bands) {
    for (ContainerShape band : bands) {
      Participant participant = BusinessObjectUtil.getFirstElementOfType(band, Participant.class);
      BPMNShape bpmnShape = BusinessObjectUtil.getFirstElementOfType(band, BPMNShape.class);
      if (bpmnShape.isIsMessageVisible()) {
        for (MessageFlow flow : messageFlows) {
          if (flow.getSourceRef().equals(participant)) {
            return flow.getName();
          }
        }
View Full Code Here

    }
    return null;
  }

  public static void moveChoreographyMessageLinks(ContainerShape choreographyContainer) {
    BPMNShape bpmnShape = BusinessObjectUtil.getFirstElementOfType(choreographyContainer, BPMNShape.class);
    Bounds bounds = bpmnShape.getBounds();
    int x = (int) ((bounds.getX() + bounds.getWidth() / 2) - (ENV_W / 2));

    Map<AnchorLocation, BoundaryAnchor> boundaryAnchors = AnchorUtil.getBoundaryAnchors(choreographyContainer);
    BoundaryAnchor topBoundaryAnchor = boundaryAnchors.get(AnchorLocation.TOP);
    BoundaryAnchor bottomBoundaryAnchor = boundaryAnchors.get(AnchorLocation.BOTTOM);
View Full Code Here

  public IReason updateNeeded(IUpdateContext context) {
    if (!ChoreographyUtil.isChoreographyParticipantBand(context.getPictogramElement())) {
      return Reason.createFalseReason();
    }

    BPMNShape bpmnShape = BusinessObjectUtil.getFirstElementOfType(context.getPictogramElement(), BPMNShape.class);
    boolean visible = new Boolean(Graphiti.getPeService().getPropertyValue(context.getPictogramElement(),
        MESSAGE_VISIBLE));

    return bpmnShape.isIsMessageVisible() != visible ? Reason.createTrueReason() : Reason.createFalseReason();
  }
View Full Code Here

  @Override
  public boolean update(IUpdateContext context) {

    ChoreographyUtil.drawMessageLinks((ContainerShape) context.getPictogramElement().eContainer());

    BPMNShape bpmnShape = BusinessObjectUtil.getFirstElementOfType(context.getPictogramElement(), BPMNShape.class);
    Graphiti.getPeService().setPropertyValue(context.getPictogramElement(), MESSAGE_VISIBLE,
        Boolean.toString(bpmnShape.isIsMessageVisible()));

    return true;
  }
View Full Code Here

  @Override
  public void refresh() {
    PictogramElement pe = getSelectedPictogramElement();
    if (pe != null) {
      final EObject be = BusinessObjectUtil.getFirstElementOfType(pe, BaseElement.class);
      final BPMNShape shape = BusinessObjectUtil.getFirstElementOfType(pe, BPMNShape.class);
      final BPMN2Editor diagramEditor = (BPMN2Editor) getDiagramEditor();
      updateComposite(be, diagramEditor, shape);
    }
  }
View Full Code Here

      Participant participant = BusinessObjectUtil.getFirstElementOfType(band, Participant.class);
      boolean isInitiating = hasInitiatingParticipant
          && participant.equals(choreography.getInitiatingParticipantRef());
      Color color = manageColor(isInitiating ? IColorConstant.WHITE : IColorConstant.LIGHT_GRAY);
      band.getGraphicsAlgorithm().setBackground(color);
      BPMNShape bpmnShape = BusinessObjectUtil.getFirstElementOfType(band, BPMNShape.class);
      bpmnShape.setParticipantBandKind(getParticipantBandKind(isInitiating, bpmnShape.getParticipantBandKind()));
    }

    Participant initiatingParticipant = choreography.getInitiatingParticipantRef();
    String id = initiatingParticipant == null ? "null" : initiatingParticipant.getId();
    peService.setPropertyValue(context.getPictogramElement(), INITIATING_PARTICIPANT_REF, id);
View Full Code Here

TOP

Related Classes of org.eclipse.bpmn2.di.BPMNShape

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.