Package org.eclipse.graphiti.features.context.impl

Examples of org.eclipse.graphiti.features.context.impl.CreateConnectionContext


                IDiagramTypeProvider dtp =
                    de.getDiagramTypeProvider();
                IFeatureProvider fp = dtp.getFeatureProvider();
                ICreateConnectionFeature cf =
                    fp.getCreateConnectionFeatures()[0];
                CreateConnectionContext cc =
                    new CreateConnectionContext();
               
                cc.setSourceAnchor(
                    fLiteralShape.getAnchors().get(0));
                cc.setSourcePictogramElement(fLiteralShape);
               
                cc.setTargetAnchor(
                    fParamShape.getAnchors().get(0));
                cc.setTargetPictogramElement(fParamShape);
                assertTrue(cf.canCreate(cc));
                cf.execute(cc);
              }
            });
      }
View Full Code Here


    // 3. add one domain specific context-button, which offers all
    // available connection-features as drag&drop features...

    // 3.a. create new CreateConnectionContext
    {
      CreateConnectionContext ccc = new CreateConnectionContext();
      ccc.setSourcePictogramElement(pe);
      Anchor anchor = null;
      if (pe instanceof Anchor) {
        anchor = (Anchor) pe;
      } else if (pe instanceof AnchorContainer) {
        // assume, that our shapes always have chopbox anchors
        anchor = Graphiti.getPeService().getChopboxAnchor((AnchorContainer) pe);
      }
      ccc.setSourceAnchor(anchor);

      // 3.b. create context button and add all applicable features
      ContextButtonEntry button = new ContextButtonEntry(null, context);
      button.setText("Create connection"); //$NON-NLS-1$
      button.setIconId(ImageProvider.IMG_FLOW);
View Full Code Here

        // lets remove the current connection between the parent and node so that
        // createFeature.canCreate() returns true
        route.removeConnection(node);

        CreateFlowFeature createFeature = new CreateFlowFeature(featureProvider);
        CreateConnectionContext connectContext = new CreateConnectionContext();
        PictogramElement srcState = featureProvider.getPictogramElementForBusinessObject(route);
        //PictogramElement destState = featureProvider.getPictogramElementForBusinessObject(node);
        if (srcState == destState) {
          Activator.getLogger().debug("Should not be the same element for different nodes: " + route + " and " + node);
        }
        connectContext.setSourcePictogramElement(srcState);
        connectContext.setTargetPictogramElement(destState);
        Anchor srcAnchor = DiagramUtils.getAnchor(srcState);
        Anchor destAnchor = DiagramUtils.getAnchor(destState);
        if (srcAnchor != null && destAnchor != null) {
          connectContext.setSourceAnchor(srcAnchor);
          connectContext.setTargetAnchor(destAnchor);
          if (createFeature.canCreate(connectContext)) {
            createFeature.execute(connectContext);
          }
        }
      }
View Full Code Here

    PictogramElement srcState  = null;
    PictogramElement destState = null;
    if (!firstNode) {
      CreateFlowFeature createFeature = new CreateFlowFeature(getFeatureProvider());
      CreateConnectionContext connectContext = new CreateConnectionContext();
      srcState = context.getPictogramElements()[0];
      destState = getFeatureProvider().getPictogramElementForBusinessObject(node);
      if (srcState == destState) {
        Activator.getLogger().warning("Should not be the same element for different nodes: " + context.getPictogramElements()[0].getLink().getBusinessObjects().get(0) + " and " + node);
      }
      connectContext.setSourcePictogramElement(srcState);
      connectContext.setTargetPictogramElement(destState);
      Anchor srcAnchor = DiagramUtils.getAnchor(srcState);
      Anchor destAnchor = DiagramUtils.getAnchor(destState);
      if (destAnchor != null) {
        connectContext.setSourceAnchor(srcAnchor);
        connectContext.setTargetAnchor(destAnchor);
        if (createFeature.canCreate(connectContext)) {
          createFeature.execute(connectContext);
        }
      }
    }
View Full Code Here

    setGenericContextButtons(data, pe, CONTEXT_BUTTON_DELETE);

    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);
    }
    ccc.setSourceAnchor(anchor);

    ContextButtonEntry button = new ContextButtonEntry(null, context);
    button.setText("Create connection"); //$NON-NLS-1$
    button.setIconId(PluginImage.IMG_EREFERENCE.getImageKey());
    ICreateConnectionFeature[] features = getFeatureProvider().getCreateConnectionFeatures();
View Full Code Here

  }
 
  private void setLocation(BaseElement targetElement, CreateContext context) {
    if(context.getProperty(CONNECTION_ATTRIBUTE) != null) {
     
      CreateConnectionContext connectionContext = (CreateConnectionContext)
          context.getProperty(CONNECTION_ATTRIBUTE);
      PictogramElement sourceElement = connectionContext.getSourcePictogramElement();
      Object sourceObject = getBusinessObjectForPictogramElement(sourceElement);
      if(sourceObject instanceof Event && (targetElement instanceof Task || targetElement instanceof CallActivity)) {
        context.setLocation(sourceElement.getGraphicsAlgorithm().getX() + 80,
            sourceElement.getGraphicsAlgorithm().getY() - 10);
     
View Full Code Here

  }

  private void createConnectionIfNeeded(PictogramElement element, ICreateContext context) {
    if(context.getProperty(CONNECTION_ATTRIBUTE) != null) {
     
      CreateConnectionContext connectionContext = (CreateConnectionContext)
          context.getProperty(CONNECTION_ATTRIBUTE);
      connectionContext.setTargetPictogramElement(element);
      connectionContext.setTargetAnchor(Graphiti.getPeService().getChopboxAnchor((AnchorContainer) element));
      CreateSequenceFlowFeature sequenceFeature = new CreateSequenceFlowFeature(getFeatureProvider());
      sequenceFeature.create(connectionContext);
    }
  }
View Full Code Here

TOP

Related Classes of org.eclipse.graphiti.features.context.impl.CreateConnectionContext

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.