Package org.eclipse.graphiti.mm.pictograms

Examples of org.eclipse.graphiti.mm.pictograms.Anchor


    }
  }

  private void drawAssociation(Association association, Bpmn2MemoryModel model) {

    Anchor sourceAnchor = null;
    Anchor targetAnchor = null;
    BaseElement sourceElement = model.getFlowElement(association.getSourceRef());
    if (sourceElement == null) {
      sourceElement = model.getArtifact(association.getSourceRef());
    }
    if (sourceElement == null) {
View Full Code Here


    Object bo = getFeatureProvider().getBusinessObjectForPictogramElement(pe);

    CreateConnectionContext connectionContext = new CreateConnectionContext();
    connectionContext.setSourcePictogramElement(pe);
    Anchor connectionAnchor = null;
    if (pe instanceof Anchor) {
      connectionAnchor = (Anchor) pe;
    } else if (pe instanceof AnchorContainer) {
      connectionAnchor = Graphiti.getPeService().getChopboxAnchor((AnchorContainer) pe);
    }
    connectionContext.setSourceAnchor(connectionAnchor);

    if (pe.eContainer() instanceof ContainerShape == false) {
      return data;
    }

    CreateContext taskContext = new CreateContext();
    taskContext.setTargetContainer((ContainerShape) pe.eContainer());
    taskContext.putProperty("org.activiti.designer.connectionContext", connectionContext);

    if (bo instanceof StartEvent || bo instanceof Task || bo instanceof CallActivity || bo instanceof Gateway) {

      CreateUserTaskFeature userTaskfeature = new CreateUserTaskFeature(getFeatureProvider());
      ContextButtonEntry newUserTaskButton = new ContextButtonEntry(userTaskfeature, taskContext);
      newUserTaskButton.setText("new user task"); //$NON-NLS-1$
      newUserTaskButton.setDescription("Create a new task"); //$NON-NLS-1$
      newUserTaskButton.setIconId(PluginImage.IMG_USERTASK.getImageKey());
      data.getDomainSpecificContextButtons().add(newUserTaskButton);

      CreateExclusiveGatewayFeature exclusiveGatewayFeature = new CreateExclusiveGatewayFeature(getFeatureProvider());
      ContextButtonEntry newExclusiveGatewayButton = new ContextButtonEntry(exclusiveGatewayFeature, taskContext);
      newExclusiveGatewayButton.setText("new exclusive gateway"); //$NON-NLS-1$
      newExclusiveGatewayButton.setDescription("Create a new exclusive gateway"); //$NON-NLS-1$
      newExclusiveGatewayButton.setIconId(PluginImage.IMG_GATEWAY_EXCLUSIVE.getImageKey());
      data.getDomainSpecificContextButtons().add(newExclusiveGatewayButton);

      CreateEndEventFeature endFeature = new CreateEndEventFeature(getFeatureProvider());
      ContextButtonEntry newEndButton = new ContextButtonEntry(endFeature, taskContext);
      newEndButton.setText("new end event"); //$NON-NLS-1$
      newEndButton.setDescription("Create a new end event"); //$NON-NLS-1$
      newEndButton.setIconId(PluginImage.IMG_ENDEVENT_NONE.getImageKey());
      data.getDomainSpecificContextButtons().add(newEndButton);
    }

    CreateConnectionContext ccc = new CreateConnectionContext();
    ccc.setSourcePictogramElement(pe);
    Anchor anchor = null;
    if (pe instanceof Anchor) {
      anchor = (Anchor) pe;
    } else if (pe instanceof AnchorContainer) {
      anchor = Graphiti.getPeService().getChopboxAnchor((AnchorContainer) pe);
    }
View Full Code Here

  @Override
  public PictogramElement add(final IAddContext context) {   
    final IAddConnectionContext addConnectionContext = (IAddConnectionContext) context;
    final Association association = (Association) context.getNewObject();
   
    Anchor sourceAnchor = addConnectionContext.getSourceAnchor();
    Anchor targetAnchor = addConnectionContext.getTargetAnchor();
   
    if (sourceAnchor == null) {
      final List<Shape> shapes = getDiagram().getChildren();
     
      for (final Shape shape : shapes) {
        final BaseElement baseElement
          = (BaseElement) getBusinessObjectForPictogramElement(shape.getGraphicsAlgorithm()
                                                                  .getPictogramElement());
        if (baseElement == null || baseElement.getId() == null
                || association.getSourceRef() == null || association.getTargetRef() == null) {
          continue;
        }
       
        if (baseElement.getId().equals(association.getSourceRef())) {
          final List<Anchor> anchors = ((ContainerShape) shape).getAnchors();
          for (final Anchor anchor : anchors) {
            if (anchor instanceof ChopboxAnchor) {
              sourceAnchor = anchor;
             
              break;
            }
          }
        }
       
        if (baseElement.getId().equals(association.getTargetRef())) {
          final List<Anchor> anchors = ((ContainerShape) shape).getAnchors();
          for (final Anchor anchor : anchors) {
            if (anchor instanceof ChopboxAnchor) {
              targetAnchor = anchor;
             
              break;
            }
          }
        }
      }
    }
   
    if (sourceAnchor == null || targetAnchor == null) {
      return null;
    }
   
    final IPeCreateService peCreateService = Graphiti.getPeCreateService();
   
    // CONNECTION WITH POLYLINE
    final 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()));
   
    BaseElement sourceElement = model.getFlowElement(association.getSourceRef());
    if (sourceElement == null) {
View Full Code Here

  protected void addGraphicalContent(ICreateContext context, BaseElement targetElement) {
    setLocation(targetElement, (CreateContext) context);
    PictogramElement element = addGraphicalRepresentation(context, targetElement);
    createConnectionIfNeeded(element, context);
   
    Anchor elementAnchor = null;
    EList<Anchor> anchorList = ((ContainerShape) element).getAnchors();
    for (Anchor anchor : anchorList) {
      if(anchor instanceof ChopboxAnchor) {
        elementAnchor = anchor;
        break;
      }
    }
   
    if(context.getProperty("org.activiti.designer.changetype.sourceflows") != null) {
      List<SequenceFlow> sourceFlows = (List<SequenceFlow>) context.getProperty("org.activiti.designer.changetype.sourceflows");
      for (SequenceFlow sourceFlow : sourceFlows) {
        sourceFlow.setSourceRef(targetElement.getId());
        if (targetElement instanceof FlowNode) {
          ((FlowNode) targetElement).getOutgoingFlows().add(sourceFlow);
        }
        Connection connection = (Connection) getFeatureProvider().getPictogramElementForBusinessObject(sourceFlow);
        connection.setStart(elementAnchor);
        elementAnchor.getOutgoingConnections().add(connection);
      }
      List<SequenceFlow> targetFlows = (List<SequenceFlow>) context.getProperty("org.activiti.designer.changetype.targetflows");
      for (SequenceFlow targetFlow : targetFlows) {
        targetFlow.setTargetRef(targetElement.getId());
        if (targetElement instanceof FlowNode) {
          ((FlowNode) targetElement).getIncomingFlows().add(targetFlow);
        }
        Connection connection = (Connection) getFeatureProvider().getPictogramElementForBusinessObject(targetFlow);
        connection.setEnd(elementAnchor);
        elementAnchor.getIncomingConnections().add(connection);
      }
    }
  }
View Full Code Here

TOP

Related Classes of org.eclipse.graphiti.mm.pictograms.Anchor

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.