Examples of IPeCreateService


Examples of org.eclipse.graphiti.services.IPeCreateService

    ProcessingElementInstance pei =
        (ProcessingElementInstance) lvs.getVariable().getValue();
    Diagram targetDiagram = (Diagram) context.getTargetContainer();

    // Container shape for everything
    IPeCreateService peCreateService = Graphiti.getPeCreateService();
    ContainerShape containerShape =
        peCreateService.createContainerShape(targetDiagram, true);
   
    //Don't think this should happen, but want to check
    if (lvs.eResource() == null) {
      Activator.logInfo("PE has no resource");
    }

    // create link and wire it
    link(containerShape, lvs);

    addLineToBox(containerShape);
   
    int paramHeight = createInputsAndOutputs(containerShape, pei);
    createBox(context, lvs, containerShape, paramHeight + 10);
 
    addText(containerShape, pei.getName(), lvs);
     
    // add a chopbox anchor to the shape
        peCreateService.createChopboxAnchor(containerShape);
        // call the layout feature
        layoutPictogramElement(containerShape);

    return containerShape;
  }
View Full Code Here

Examples of org.eclipse.graphiti.services.IPeCreateService

   * @return Height required to hold all ports
   */
  private int createInputsAndOutputs(ContainerShape containerShape,
      ProcessingElementInstance pei) {
   
    IPeCreateService peCreateService = Graphiti.getPeCreateService();
    IGaService gaService = Graphiti.getGaService();
    int inputs = 0;
    int outputs = 0;
    int x = 0;
    int y = 0;
   
    for (ProcessingElementParameter p :
      pei.getProcessingElementParameters()) {
     
      Shape shape = peCreateService.createShape(containerShape, true);
      Rectangle r = gaService.createRectangle(shape);
      r.setStyle(StyleUtil.getStyleForPEPort(getDiagram()));

      Text text = gaService.createDefaultText(getDiagram(), r,
          p.getName());
      text.setStyle(StyleUtil.getStyleForText(getDiagram()));
      text.setVerticalAlignment(Orientation.ALIGNMENT_CENTER);
     
      //Put inputs on the left and outputs on the right
      if (p instanceof Output) {
        x = BOX_WIDTH/2 + 2;
        y = PORT_TOP_MARGIN + ((PORT_HEIGHT + 1) * outputs);
        outputs ++;
        text.setHorizontalAlignment(Orientation.ALIGNMENT_RIGHT);
      } else {
        y = PORT_TOP_MARGIN + ((PORT_HEIGHT + 1) * inputs);
        inputs ++;
        text.setHorizontalAlignment(Orientation.ALIGNMENT_LEFT);
      }
     
      gaService.setLocationAndSize(r, x, y, (BOX_WIDTH/2) - 2 ,
          PORT_HEIGHT);
      link(shape, p);
     
      gaService.setLocationAndSize(text, 3, 0, ((BOX_WIDTH/2) -2) - 6,
          PORT_TEXT_HEIGHT);
     
      peCreateService.createChopboxAnchor(shape);
    }
 
    return PORT_TOP_MARGIN +
        ((Math.max(0, (Math.max(inputs, outputs) -1))) *
            (PORT_HEIGHT + 1)) + 20;
View Full Code Here

Examples of org.eclipse.graphiti.services.IPeCreateService

    LocalVariableStatement addedVar =
        (LocalVariableStatement) context.getNewObject();
    Diagram targetDiagram = (Diagram) context.getTargetContainer();

    // CONTAINER SHAPE WITH ROUNDED RECTANGLE
    IPeCreateService peCreateService = Graphiti.getPeCreateService();
    ContainerShape containerShape =
        peCreateService.createContainerShape(targetDiagram, true);

    // check whether the context has a size (e.g. from a create feature)
    // otherwise define a default size for the shape
    int width = context.getWidth() <= 0 ? 200 : context.getWidth();
    int height = context.getHeight() <= 0 ? 44 : context.getHeight();

    IGaService gaService = Graphiti.getGaService();

    {
      // create and set graphics algorithm
      RoundedRectangle roundedRectangle =
          gaService.createRoundedRectangle(containerShape, 5, 5);
      roundedRectangle.setStyle(StyleUtil.getStyleForCI(getDiagram()));
      gaService.setLocationAndSize(roundedRectangle,
          context.getX(), context.getY(), width, height);

      //Don't think this should happen, but want to be sure
      if (addedVar.eResource() == null) {
        Activator.logInfo("ConnectionInitialization has no resource");
      }

      // create link and wire it
      link(containerShape, addedVar);
    }

    //Check for child literal
    Object lit = Utility.getChildLiteral(addedVar.getVariable(
        ).getInitialValue());
    if (lit != null) {
      AddContext addLiteralContext = new AddContext(
          new AreaContext(), lit);
      addLiteralContext.setTargetContainer(containerShape);
      addGraphicalRepresentation(addLiteralContext, lit);
    }
   
    // add a chopbox anchor to the shape
        peCreateService.createChopboxAnchor(containerShape);
        // call the layout feature
        layoutPictogramElement(containerShape);
       
    return containerShape;
  }
View Full Code Here

Examples of org.eclipse.graphiti.services.IPeCreateService

        IAddConnectionContext addConContext = (IAddConnectionContext) context;

        ConnectionStatement addedConn =
            (ConnectionStatement) context.getNewObject();
        IPeCreateService peCreateService = Graphiti.getPeCreateService();
       
        // CONNECTION WITH POLYLINE

        Connection connection = peCreateService
            .createFreeFormConnection(getDiagram());
        connection.setStart(addConContext.getSourceAnchor());
        connection.setEnd(addConContext.getTargetAnchor());

        IGaService gaService = Graphiti.getGaService();
        Polyline polyline = gaService.createPolyline(connection);
        polyline.setStyle(StyleUtil.getStyleForConn(getDiagram()));
        ConnectionDecorator cd = peCreateService.createConnectionDecorator(
            connection, false, 1.0, true);

        createArrow(cd);

        // create link and wire it
View Full Code Here

Examples of org.eclipse.graphiti.services.IPeCreateService

  public PictogramElement add(IAddContext context) {

    EObject addedObj = (EObject) context.getNewObject();
   
    // CONTAINER SHAPE WITH ROUNDED RECTANGLE
    IPeCreateService peCreateService = Graphiti.getPeCreateService();
    ContainerShape containerShape =
        peCreateService.createContainerShape(
            context.getTargetContainer(), true);

    peCreateService.createChopboxAnchor(containerShape);

    // check whether the context has a size (e.g. from a create feature)
    // otherwise define a default size for the shape
    int width = context.getWidth() <= 0 ? 180 : context.getWidth();
    int height = context.getHeight() <= 0 ? 24 : context.getHeight();

    IGaService gaService = Graphiti.getGaService();

    {
      // create and set graphics algorithm
      RoundedRectangle roundedRectangle =
          gaService.createRoundedRectangle(containerShape, 5, 5);
      roundedRectangle.setStyle(StyleUtil.getStyleForLiteral(getDiagram()));
      gaService.setLocationAndSize(roundedRectangle,
          context.getX() + 10, context.getY() + 10, width, height);

      //Don't think this should happen, but want to check
      if (addedObj.eResource() == null) {
        Activator.logInfo("Literal has no resource");
      }

      // create link and wire it
      link(containerShape, addedObj);
    }


    // SHAPE WITH TEXT
    {
      // create shape for text
      Shape shape = peCreateService.createShape(containerShape, false);

      // create and set text graphics algorithm
      MultiText text = gaService.createDefaultMultiText(
          getDiagram(), shape, Utility.getLiteralValue(addedObj));
      text.setStyle(StyleUtil.getStyleForText(getDiagram()));
View Full Code Here

Examples of org.eclipse.graphiti.services.IPeCreateService

  @Override
  public PictogramElement add(IAddContext context) {
    IAddConnectionContext addConContext = (IAddConnectionContext) context;
    Flow addedEReference = (Flow) context.getNewObject();

    IPeCreateService peCreateService = Graphiti.getPeCreateService();
    // CONNECTION WITH POLYLINE
    Connection connection = peCreateService.createFreeFormConnection(getDiagram());
    connection.setStart(addConContext.getSourceAnchor());
    connection.setEnd(addConContext.getTargetAnchor());
   
    IGaService gaService = Graphiti.getGaService();
    Polyline polyline = gaService.createPolyline(connection);
    polyline.setStyle(StyleUtil.getStyleForEClass(getDiagram()));
    polyline.setForeground(manageColor(StyleUtil.getColorConstant(PreferenceManager.getInstance().loadPreferenceAsString(PreferencesConstants.EDITOR_CONNECTION_COLOR))));

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

    // add dynamic text decorator for the reference name
    ConnectionDecorator textDecorator = peCreateService.createConnectionDecorator(connection, true, 0.5, true);
    Text text = gaService.createDefaultText(getDiagram(), getDiagram().getGraphicsAlgorithm());
    textDecorator.setConnection(connection);
    text.setStyle(StyleUtil.getStyleForCamelText((getDiagram())));
    gaService.setLocation(text, 10, 0);
    // set reference name in the text decorator
    Flow flow = (Flow) context.getNewObject();
    text.setValue(flow.getName());
   
    // add static graphical decorators (composition and navigable)
    ConnectionDecorator cd;
    cd = peCreateService.createConnectionDecorator(connection, false, 1.0, true);
    createArrow(cd);
   
    return connection;
  }
View Full Code Here

Examples of org.eclipse.graphiti.services.IPeCreateService

    final AbstractNode addedClass = (AbstractNode) context.getNewObject();
    //    final EClass addedClass = (EClass) context.getNewObject();
    final Diagram targetDiagram = (Diagram) context.getTargetContainer();

    // CONTAINER SHAPE WITH ROUNDED RECTANGLE
    final IPeCreateService peCreateService = Graphiti.getPeCreateService();
    final ContainerShape containerShape = peCreateService.createContainerShape(targetDiagram, true);

    String label = DiagramUtils.filterFigureLabel(addedClass.getDisplayText());
   
    // check whether the context has a size (e.g. from a create feature)
    // otherwise define a default size for the shape
    // now try to use the image dimension as figure dimension plus some height spacing
    // for the display label
    Font f = StyleUtil.getStyleForCamelText(getDiagram()).getFont();
    IDimension fontDimension = GraphitiUi.getUiLayoutService().calculateTextSize(label, f);
    Dimension imageDimension = ImageUtils.getImageSize(addedClass.getIconName());

    int image_width = imageDimension.width;
    int image_height = imageDimension.height;
   
    int label_width = fontDimension.getWidth() + LABEL_SPACER_X + LABEL_SPACER_X;
    int label_height = Math.max(fontDimension.getHeight(), TEXT_LABEL_SIZE);

    int content_width = Math.max(Math.max(label_width, image_width), DEFAULT_FIGURE_CONTENT_WIDTH);
   
    // now lets define the shape dimensions
    org.eclipse.swt.graphics.Rectangle baseRect = new org.eclipse.swt.graphics.Rectangle(context.getX(), context.getY(), content_width + BASE_RECT_SPACE_X + BASE_RECT_SPACE_X + SHADOW_WIDTH + INVISIBLE_RIGHT_SPACE, BASE_RECT_SPACE_Y + BASE_RECT_SPACE_Y + image_height + SHADOW_HEIGHT + IMAGE_LABEL_SPACE + label_height + TOP_BOTTOM_SPACE + TOP_BOTTOM_SPACE);
    org.eclipse.swt.graphics.Rectangle shadowRect = new org.eclipse.swt.graphics.Rectangle(0 + BASE_RECT_SPACE_X + SHADOW_WIDTH, 0 + BASE_RECT_SPACE_Y + SHADOW_HEIGHT, content_width, image_height + label_height + IMAGE_LABEL_SPACE + TOP_BOTTOM_SPACE + TOP_BOTTOM_SPACE);
    org.eclipse.swt.graphics.Rectangle contentRect = new org.eclipse.swt.graphics.Rectangle(0 + BASE_RECT_SPACE_X, 0 + BASE_RECT_SPACE_Y, content_width, image_height + label_height + IMAGE_LABEL_SPACE + TOP_BOTTOM_SPACE + TOP_BOTTOM_SPACE);
    org.eclipse.swt.graphics.Rectangle imageRect = new org.eclipse.swt.graphics.Rectangle(0 + BASE_RECT_SPACE_X, 0 + BASE_RECT_SPACE_Y + TOP_BOTTOM_SPACE, content_width, image_height);
    org.eclipse.swt.graphics.Rectangle labelRect = new org.eclipse.swt.graphics.Rectangle(0 + BASE_RECT_SPACE_X, 0 + BASE_RECT_SPACE_Y + image_height + IMAGE_LABEL_SPACE, content_width, label_height + TOP_BOTTOM_SPACE);
   
    final IGaService gaService = Graphiti.getGaService();
    final RoundedRectangle baseRectangle = gaService.createRoundedRectangle(containerShape, ROUNDED_RECTANGLE_WIDTH, ROUNDED_RECTANGLE_HEIGHT);

    // create invisible outer rectangle expanded by
    // the width needed for the anchor
    gaService.setLocationAndSize(baseRectangle, baseRect.x, baseRect.y, baseRect.width, baseRect.height);
    baseRectangle.setFilled(false);
    baseRectangle.setLineVisible(false);
   
    // shadow
    RoundedRectangle shadowRectangle; // need to access it later
    {
      // create and set visible rectangle inside invisible rectangle
      shadowRectangle = gaService.createRoundedRectangle(baseRectangle, ROUNDED_RECTANGLE_WIDTH, ROUNDED_RECTANGLE_HEIGHT);
      shadowRectangle.setParentGraphicsAlgorithm(baseRectangle);
      shadowRectangle.setStyle(StyleUtil.getShadowStyleForCamelClass(getDiagram()));
      shadowRectangle.setLineVisible(false);
      shadowRectangle.setFilled(true);
      gaService.setLocationAndSize(shadowRectangle, shadowRect.x, shadowRect.y, shadowRect.width, shadowRect.height);
    }

    // the real figure
    RoundedRectangle roundedRectangle; // need to access it later
    {
      // create and set visible rectangle inside invisible rectangle
      roundedRectangle = gaService.createRoundedRectangle(baseRectangle, ROUNDED_RECTANGLE_WIDTH, ROUNDED_RECTANGLE_HEIGHT);
      roundedRectangle.setParentGraphicsAlgorithm(baseRectangle);
      roundedRectangle.setStyle(StyleUtil.getStyleForCamelClass(getDiagram()));
      gaService.setLocationAndSize(roundedRectangle, contentRect.x, contentRect.y, contentRect.width, contentRect.height);
    }
   
    // image
    {
      // create shape for image
      final Shape shape = peCreateService.createShape(containerShape, false);

      // create and set image
      final Image image = gaService.createImage(shape, ImageProvider.getKeyForLargeIcon(addedClass.getIconName()));
      gaService.setLocationAndSize(image, imageRect.x, imageRect.y, imageRect.width, imageRect.height);

      // if addedClass has no resource we add it to the resource of the diagram
      // in a real scenario the business model would have its own resource
//      if (addedClass.eResource() == null) {
//        getDiagram().eResource().getContents().add(addedClass);
//      }
    }

    // SHAPE WITH TEXT
    {
      // create shape for text
      final Shape shape = peCreateService.createShape(containerShape, false);

      // create and set text graphics algorithm
      final Text text = gaService.createDefaultText(getDiagram(), shape, label);

      Style style = StyleUtil.getStyleForCamelText(getDiagram());
      text.setStyle(style);
      text.setHorizontalAlignment(Orientation.ALIGNMENT_CENTER);
      text.setVerticalAlignment(Orientation.ALIGNMENT_CENTER);
      text.setFont(style.getFont());

      gaService.setLocationAndSize(text, labelRect.x, labelRect.y, labelRect.width, labelRect.height);

      // create link and wire it
      //        link(shape, addedClass);

      // provide information to support direct-editing directly
      // after object creation (must be activated additionally)
      final IDirectEditingInfo directEditingInfo = getFeatureProvider().getDirectEditingInfo();
      // set container shape for direct editing after object creation
      directEditingInfo.setMainPictogramElement(containerShape);
      // set shape and graphics algorithm where the editor for
      // direct editing shall be opened after object creation
      directEditingInfo.setPictogramElement(shape);
      directEditingInfo.setGraphicsAlgorithm(text);
    }

    // add a chopbox anchor to the shape
    peCreateService.createChopboxAnchor(containerShape);

    // call the layout feature
    layoutPictogramElement(containerShape);
   
    // create link and wire it
View Full Code Here

Examples of org.eclipse.graphiti.services.IPeCreateService

    Participant p = (Participant) context.getNewObject();
    IGaService gaService = Graphiti.getGaService();
    IPeService peService = Graphiti.getPeService();

    Diagram targetDiagram = (Diagram) context.getTargetContainer();
    IPeCreateService peCreateService = Graphiti.getPeCreateService();
    ContainerShape containerShape = peCreateService.createContainerShape(targetDiagram, true);

    int width = context.getWidth() > 0 ? context.getWidth() : 600;
    int height = context.getHeight() > 0 ? context.getHeight() : 100;

    Rectangle rect = gaService.createRectangle(containerShape);
    StyleUtil.applyBGStyle(rect, this);
    gaService.setLocationAndSize(rect, context.getX(), context.getY(), width, height);

    Shape lineShape = peCreateService.createShape(containerShape, false);
    Polyline line = gaService.createPolyline(lineShape, new int[] { 15, 0, 15, height });
    line.setForeground(manageColor(StyleUtil.CLASS_FOREGROUND));

    Shape textShape = peCreateService.createShape(containerShape, false);
    Text text = gaService.createText(textShape, p.getName());
    text.setStyle(StyleUtil.getStyleForText(getDiagram()));
    text.setVerticalAlignment(Orientation.ALIGNMENT_CENTER);
    text.setHorizontalAlignment(Orientation.ALIGNMENT_CENTER);
    text.setAngle(-90);
    gaService.setLocationAndSize(text, 0, 0, 15, height);
    peService.setPropertyValue(containerShape, MULTIPLICITY, Boolean.toString(false));

    createDIShape(containerShape, p);
    link(textShape, p);
    peCreateService.createChopboxAnchor(containerShape);
    AnchorUtil.addFixedPointAnchors(containerShape, rect);
    updatePictogramElement(containerShape);
    layoutPictogramElement(containerShape);
    return containerShape;
  }
View Full Code Here

Examples of org.eclipse.graphiti.services.IPeCreateService

  @Override
  public PictogramElement add(IAddContext context) {
    TextAnnotation annotation = (TextAnnotation) context.getNewObject();

    IPeCreateService peCreateService = Graphiti.getPeCreateService();
    ContainerShape containerShape = peCreateService.createContainerShape(context.getTargetContainer(), true);

    IGaService gaService = Graphiti.getGaService();

    int width = context.getWidth() > 0 ? context.getWidth() : 50;
    int height = context.getHeight() > 0 ? context.getHeight() : 100;
    int commentEdge = 15;

    Rectangle rect = gaService.createInvisibleRectangle(containerShape);
    gaService.setLocationAndSize(rect, context.getX(), context.getY(), width, height);

    Shape lineShape = peCreateService.createShape(containerShape, false);
    Polyline line = gaService.createPolyline(lineShape, new int[] { commentEdge, 0, 0, 0, 0, height, commentEdge,
        height });
    line.setStyle(StyleUtil.getStyleForClass(getDiagram()));
    line.setLineWidth(2);
    gaService.setLocationAndSize(line, 0, 0, commentEdge, height);

    Shape textShape = peCreateService.createShape(containerShape, false);
    MultiText text = gaService.createDefaultMultiText(getDiagram(), textShape, annotation.getText());
    text.setStyle(StyleUtil.getStyleForText(getDiagram()));
    text.setVerticalAlignment(Orientation.ALIGNMENT_TOP);
    gaService.setLocationAndSize(text, 5, 5, width - 5, height - 5);

    createDIShape(containerShape, annotation);
    link(textShape, annotation);

    peCreateService.createChopboxAnchor(containerShape);
    AnchorUtil.addFixedPointAnchors(containerShape, rect);
   
    layoutPictogramElement(containerShape);
    return containerShape;
  }
View Full Code Here

Examples of org.eclipse.graphiti.services.IPeCreateService

  @Override
  public PictogramElement add(IAddContext context) {
    Lane lane = (Lane) context.getNewObject();

    IPeCreateService peCreateService = Graphiti.getPeCreateService();
    ContainerShape containerShape = peCreateService.createContainerShape(context.getTargetContainer(), true);
    IGaService gaService = Graphiti.getGaService();

    int width = context.getWidth() > 0 ? context.getWidth() : 600;
    int height = context.getHeight() > 0 ? context.getHeight() : 100;

    Rectangle rect = gaService.createRectangle(containerShape);

    StyleUtil.applyBGStyle(rect, this);

    if (FeatureSupport.isTargetLane(context) || FeatureSupport.isTargetParticipant(context)) {
      GraphicsAlgorithm ga = context.getTargetContainer().getGraphicsAlgorithm();

      if (getNumberOfLanes(context) == 1) {
        gaService.setLocationAndSize(rect, 15, 0, width - 15, height);
        for (Shape s : getFlowNodeShapes(context, lane)) {
          Graphiti.getPeService().sendToFront(s);
          s.setContainer(containerShape);
        }
      } else {
        if (context.getWidth() == -1 || context.getHeight() == -1) {
          gaService.setLocationAndSize(rect, 15, ga.getWidth() - 1, ga.getHeight() - 15, height);
          // gaService.setLocationAndSize(rect, context.getX(), context.getY(), width, height);
        } else {
          ILayoutService layoutService = Graphiti.getLayoutService();
          ILocation loc = layoutService.getLocationRelativeToDiagram(containerShape);
          int x = context.getX() - loc.getX();
          int y = context.getY() - loc.getY();
          gaService.setLocationAndSize(rect, x - 15, y, ga.getWidth() - 15, height);
        }
      }
      containerShape.setContainer(context.getTargetContainer());
    } else {
      gaService.setLocationAndSize(rect, context.getX(), context.getY(), width, height);
    }

    Shape textShape = peCreateService.createShape(containerShape, false);
    Text text = gaService.createText(textShape, lane.getName());
    text.setStyle(StyleUtil.getStyleForText(getDiagram()));
    text.setVerticalAlignment(Orientation.ALIGNMENT_CENTER);
    text.setHorizontalAlignment(Orientation.ALIGNMENT_CENTER);
    text.setAngle(-90);
    gaService.setLocationAndSize(text, 0, 0, 15, height);

    createDIShape(containerShape, lane);
    link(textShape, lane);

    peCreateService.createChopboxAnchor(containerShape);
    AnchorUtil.addFixedPointAnchors(containerShape, rect);

    if (context.getProperty(DIImport.IMPORT_PROPERTY) == null
        && (FeatureSupport.isTargetLane(context) || FeatureSupport.isTargetParticipant(context))) {
      FeatureSupport.redraw(context.getTargetContainer());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.