Package org.eclipse.graphiti.services

Examples of org.eclipse.graphiti.services.IPeService


      return null;
    }
  }

  private Shape getShape(ContainerShape container, String propertyKey) {
    IPeService peService = Graphiti.getPeService();
    Iterator<Shape> iterator = peService.getAllContainedShapes(container).iterator();
    while (iterator.hasNext()) {
      Shape shape = iterator.next();
      String property = peService.getPropertyValue(shape, propertyKey);
      if (property != null && new Boolean(property)) {
        return shape;
      }
    }
    return null;
View Full Code Here


      }

      @Override
      public PictogramElement add(IAddContext context) {
        IGaService gaService = Graphiti.getGaService();
        IPeService peService = Graphiti.getPeService();
        Message msg = (Message) context.getNewObject();

        int width = context.getWidth() > 0 ? context.getWidth() : 30;
        int height = context.getHeight() > 0 ? context.getHeight() : 20;
        int textArea = 15;

        ContainerShape container = peService.createContainerShape(context.getTargetContainer(), true);
        Rectangle invisibleRect = gaService.createInvisibleRectangle(container);
        gaService.setLocationAndSize(invisibleRect, context.getX(), context.getY(), width, height + textArea);

        Envelope envelope = GraphicsUtil.createEnvelope(invisibleRect, 0, 0, width, height);
        envelope.rect.setFilled(true);
        StyleUtil.applyBGStyle(envelope.rect, this);
        envelope.line.setForeground(manageColor(StyleUtil.CLASS_FOREGROUND));

        Shape textShape = peService.createShape(container, false);
        peService
            .setPropertyValue(textShape, UpdateBaseElementNameFeature.TEXT_ELEMENT, Boolean.toString(true));
        Text text = gaService.createDefaultText(getDiagram(), textShape, msg.getName());
        text.setStyle(StyleUtil.getStyleForText(getDiagram()));
        text.setHorizontalAlignment(Orientation.ALIGNMENT_CENTER);
        text.setVerticalAlignment(Orientation.ALIGNMENT_TOP);
        gaService.setLocationAndSize(text, 0, height, width, textArea);

        peService.createChopboxAnchor(container);
        AnchorUtil.addFixedPointAnchors(container, invisibleRect);

        createDIShape(container, msg);
        layoutPictogramElement(container);
        return container;
View Full Code Here

  @Override
  public PictogramElement add(IAddContext context) {
    Activity activity = (Activity) context.getNewObject();

    IGaService gaService = Graphiti.getGaService();
    IPeService peService = Graphiti.getPeService();

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

    ContainerShape containerShape = peService.createContainerShape(context.getTargetContainer(), true);
    Rectangle invisibleRect = gaService.createInvisibleRectangle(containerShape);
    gaService.setLocationAndSize(invisibleRect, context.getX(), context.getY(), width, height);

    Shape rectShape = peService.createShape(containerShape, false);
    RoundedRectangle rect = gaService.createRoundedRectangle(rectShape, 5, 5);
    StyleUtil.applyBGStyle(rect, this);
    gaService.setLocationAndSize(rect, 0, 0, width, height);
    link(rectShape, activity);
    decorateActivityRectangle(rect);
    peService.setPropertyValue(rectShape, "activity", Boolean.toString(true));

    ContainerShape markerContainer = peService.createContainerShape(containerShape, false);
    Rectangle markerInvisibleRect = gaService.createInvisibleRectangle(markerContainer);
    int h = 10;
    int y = height - h - 3 - getMarkerContainerOffset();
    gaService.setLocationAndSize(markerInvisibleRect, 0, y, invisibleRect.getWidth(), h);
    peService.setPropertyValue(markerContainer, GraphicsUtil.ACTIVITY_MARKER_CONTAINER, Boolean.toString(true));

    hook(activity, containerShape, context, width, height); // hook for subclasses to inject extra code

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

    createDIShape(containerShape, activity);

    Graphiti.getPeService().setPropertyValue(containerShape, IS_COMPENSATE_PROPERTY, Boolean.toString(false));
View Full Code Here

      return callActivity != null && context.getPictogramElement() instanceof ContainerShape;
    }

    @Override
    public IReason updateNeeded(IUpdateContext context) {
      IPeService peService = Graphiti.getPeService();
      PictogramElement element = context.getPictogramElement();
      String property = peService.getPropertyValue(element, CALL_ACTIITY_REF_PROPERTY);
      if (property == null) {
        return Reason.createFalseReason();
      }
      CallActivity callActivity = BusinessObjectUtil.getFirstElementOfType(context.getPictogramElement(),
          CallActivity.class);
View Full Code Here

      return changed ? Reason.createTrueReason() : Reason.createFalseReason();
    }

    @Override
    public boolean update(IUpdateContext context) {
      IPeService peService = Graphiti.getPeService();
      IGaService gaService = Graphiti.getGaService();

      ContainerShape container = (ContainerShape) context.getPictogramElement();
      CallActivity callActivity = BusinessObjectUtil.getFirstElementOfType(context.getPictogramElement(),
          CallActivity.class);

      ContainerShape markerContainer = (ContainerShape) getShape(container,
          GraphicsUtil.ACTIVITY_MARKER_CONTAINER);
      Shape globalTaskShape = getShape(container, GLOBAL_TASK_SHAPE_PROPERTY);

      if (callActivity.getCalledElementRef() == null) {
        GraphicsUtil.clearActivityMarker(markerContainer, GraphicsUtil.ACTIVITY_MARKER_EXPAND);
        if (globalTaskShape != null) {
          peService.deletePictogramElement(globalTaskShape);
        }
      }

      else if (callActivity.getCalledElementRef() instanceof GlobalTask) {
        GraphicsUtil.clearActivityMarker(markerContainer, GraphicsUtil.ACTIVITY_MARKER_EXPAND);
        GlobalTask t = (GlobalTask) callActivity.getCalledElementRef();
        if (globalTaskShape == null) {
          globalTaskShape = peService.createShape(container, false);
          peService.setPropertyValue(globalTaskShape, GLOBAL_TASK_SHAPE_PROPERTY, Boolean.toString(true));
        }
        String imageId = getImageId(t);
        if (imageId != null) {
          Image image = gaService.createImage(globalTaskShape, imageId);
          gaService.setLocationAndSize(image, MARKER_OFFSET + 2, MARKER_OFFSET + 2, 16, 16);
        }
      }

      else if (callActivity.getCalledElementRef() instanceof Process) {
        if (globalTaskShape != null) {
          peService.deletePictogramElement(globalTaskShape);
        }
        Expand expand = GraphicsUtil.createActivityMarkerExpand(markerContainer);
        expand.rect.setForeground(manageColor(StyleUtil.CLASS_FOREGROUND));
        expand.horizontal.setForeground(manageColor(StyleUtil.CLASS_FOREGROUND));
        expand.vertical.setForeground(manageColor(StyleUtil.CLASS_FOREGROUND));
      }

      peService.setPropertyValue(container, CALL_ACTIITY_REF_PROPERTY,
          getCallableElementStringValue(callActivity.getCalledElementRef()));
      return true;
    }
View Full Code Here

  }

  @Override
  protected void postMoveShape(final IMoveShapeContext context) {
    super.postMoveShape(context);
    IPeService peService = Graphiti.getPeService();
    Collection<Shape> shapes = peService.getAllContainedShapes((ContainerShape) context.getShape());
    for (Shape s : shapes) {
      Participant participant = BusinessObjectUtil.getFirstElementOfType(s, Participant.class);
      if (participant != null) {
        ContainerShape container = (ContainerShape) s;
        GraphicsAlgorithm ga = container.getGraphicsAlgorithm();
View Full Code Here

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

    SubProcess subprocess = (SubProcess) context.getNewObject();

    IGaService gaService = Graphiti.getGaService();
    IPeService peService = Graphiti.getPeService();

    ContainerShape containerShape = peService.createContainerShape(context.getTargetContainer(), true);
    Rectangle invisibleRect = gaService.createInvisibleRectangle(containerShape);

    gaService.setLocationAndSize(invisibleRect, context.getX(), context.getY(), width, height + 18);

    Shape rectShape = peService.createShape(containerShape, false);
    RoundedRectangle rect = gaService.createRoundedRectangle(rectShape, 5, 5);
       
    StyleUtil.applyBGStyle(rect, this);   

    gaService.setLocationAndSize(rect, 0, 0, width, height);
    decorateRect(rect);
    link(rectShape, subprocess);

    Rectangle box = gaService.createRectangle(rect);
    gaService.setLocationAndSize(box, 40, 80, 20, 20);
    box.setFilled(false);
    box.setForeground(manageColor(StyleUtil.CLASS_FOREGROUND));
    decorateBox(box);

    Shape textShape = peService.createShape(containerShape, false);
    MultiText text = gaService.createDefaultMultiText(getDiagram(), textShape, subprocess.getName());
    gaService.setLocationAndSize(text, 10, 10, 80, 80);
    text.setStyle(StyleUtil.getStyleForText(getDiagram()));
    text.setHorizontalAlignment(Orientation.ALIGNMENT_CENTER);
    text.setVerticalAlignment(Orientation.ALIGNMENT_TOP);
    text.getFont().setBold(true);
    link(textShape, subprocess);

    Polyline lineHorizontal = gaService.createPolyline(box, new int[] { 2, 10, 18, 10 });
    lineHorizontal.setForeground(manageColor(StyleUtil.CLASS_FOREGROUND));

    Polyline lineVertical = gaService.createPolyline(box, new int[] { 10, 2, 10, 18 });
    lineVertical.setForeground(manageColor(StyleUtil.CLASS_FOREGROUND));

    ChopboxAnchor anchor = peService.createChopboxAnchor(containerShape);
    anchor.setReferencedGraphicsAlgorithm(rect);

    peService.setPropertyValue(containerShape, TRIGGERED_BY_EVENT, "false");
    link(containerShape, subprocess);
    return containerShape;
  }
View Full Code Here

  @Override
  public PictogramElement add(IAddContext context) {
    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);
View Full Code Here

      }

      @Override
      public PictogramElement add(IAddContext context) {
        IGaService gaService = Graphiti.getGaService();
        IPeService peService = Graphiti.getPeService();
        Group group = (Group) context.getNewObject();

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

        ContainerShape container = peService.createContainerShape(context.getTargetContainer(), true);
        RoundedRectangle rect = gaService.createRoundedRectangle(container, 5, 5);
        rect.setFilled(false);
        rect.setLineWidth(2);
        rect.setForeground(manageColor(StyleUtil.CLASS_FOREGROUND));
        rect.setLineStyle(LineStyle.DASHDOT);
        gaService.setLocationAndSize(rect, context.getX(), context.getY(), width, height);

        peService.createChopboxAnchor(container);
        AnchorUtil.addFixedPointAnchors(container, rect);

        link(container, group);
        createDIShape(container, group);
        return container;
View Full Code Here

  }

  @Override
  public PictogramElement add(IAddContext context) {
    IGaService gaService = Graphiti.getGaService();
    IPeService peService = Graphiti.getPeService();
    @SuppressWarnings("unchecked")
    T t = (T) context.getNewObject();

    int width = GraphicsUtil.DATA_WIDTH;
    int height = GraphicsUtil.DATA_HEIGHT;
    int e = 10;
    int textArea = 15;
   
    ContainerShape container = peService.createContainerShape(context.getTargetContainer(), true);
    Rectangle invisibleRect = gaService.createInvisibleRectangle(container);
    gaService.setLocationAndSize(invisibleRect, context.getX(), context.getY(), width, height + textArea);

    Shape rectShape = peService.createShape(container, false);
    Polygon rect = gaService.createPolygon(rectShape, new int[] { 0, 0, width - e, 0, width, e, width, height, 0,
        height });
    rect.setLineWidth(1);
    StyleUtil.applyBGStyle(rect, this);
    decorate(rect);

    int p = width - e - 1;
    Polyline edge = gaService.createPolyline(rect, new int[] { p, 0, p, e + 1, width, e + 1 });
    edge.setForeground(manageColor(StyleUtil.CLASS_FOREGROUND));
    edge.setLineWidth(1);

    if (isSupportCollectionMarkers()) {
      int whalf = width / 2;
      createCollectionShape(container, new int[] { whalf - 2, height - 8, whalf - 2, height });
      createCollectionShape(container, new int[] { whalf, height - 8, whalf, height });
      createCollectionShape(container, new int[] { whalf + 2, height - 8, whalf + 2, height });

      Graphiti.getPeService().setPropertyValue(container, Properties.COLLECTION_PROPERTY, Boolean.toString(false));
    }
   
    Shape textShape = peService.createShape(container, false);
    peService.setPropertyValue(textShape, UpdateBaseElementNameFeature.TEXT_ELEMENT, Boolean.toString(true));
    Text text = gaService.createDefaultText(getDiagram(), textShape, getName(t));
    text.setStyle(StyleUtil.getStyleForText(getDiagram()));
    text.setHorizontalAlignment(Orientation.ALIGNMENT_CENTER);
    text.setVerticalAlignment(Orientation.ALIGNMENT_TOP);
    gaService.setLocationAndSize(text, 0, height, width, textArea);
   
    peService.createChopboxAnchor(container);
    AnchorUtil.addFixedPointAnchors(container, invisibleRect);
    createDIShape(container, t);
    layoutPictogramElement(container);
    return container;
  }
View Full Code Here

TOP

Related Classes of org.eclipse.graphiti.services.IPeService

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.