Package org.eclipse.graphiti.mm.pictograms

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


   
    ILinkService ls = Graphiti.getLinkService();
    EObject linked = null;
    LocalVariableStatement modelObject = null;
    //Find PE
    Shape peShape = null;
    for (Shape s : d.getChildren()) {
      linked = ls.getBusinessObjectForLinkedPictogramElement(s);
      if (linked instanceof LocalVariableStatement) {
        LocalVariableStatement lvs = (LocalVariableStatement) linked;
View Full Code Here


   
    assertNotNull(peShape);
    assertNotNull(linked.eContainer());
   
    //Find Literal
    Shape literalShape = null;
    for (Shape s : d.getChildren()) {
      linked = ls.getBusinessObjectForLinkedPictogramElement(s);
      if (linked instanceof ConnectionInitialization) {
        ConnectionInitialization ci = (ConnectionInitialization) linked;
        EObject e = Utility.getChildLiteral(ci);
        if (Utility.getLiteralValue(
            Utility.getChildLiteral(ci)).equals("\"Connection\"")) {
          literalShape = s;
          break;
        }
      }
    }
   
    assertNotNull(literalShape);
    assertNotNull(linked.eContainer());
    assertTrue(literalShape.getAnchors().size() > 0);
   
    ProcessingElementParameter param = null;
    Shape paramShape = null;
    for (Shape s :peShape.getChildren()) {
      linked = ls.getBusinessObjectForLinkedPictogramElement(s);
      if (linked instanceof ProcessingElementParameter) {
        ProcessingElementParameter paramTmp =
            (ProcessingElementParameter) linked;
        if (paramTmp.getName().equals("input")) {
          param = paramTmp;
          paramShape = s;
          break;
        }
      }
    }
   
    assertNotNull(param);
    assertNotNull(paramShape);
    assertTrue(paramShape.getAnchors().size() > 0);
   
    final Shape fLiteralShape = literalShape;
    final Shape fParamShape = paramShape;
   
    syncExec((new VoidResult() {
      @Override
      public void run() {

        de.getEditingDomain().getCommandStack().execute(
            new RecordingCommand(de.getEditingDomain()) {

              @Override
              protected void doExecute() {
                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

    //Just make sure they're linked
    for (Connection c : cons) {
      assertNotNull(c.getParent());
    }
 
    final Shape deleteShape = ciPair.getLeft();
 
    //Have to async call delete within transaction, then use swtbot to
    //confirm
    asyncExec((new VoidResult() {
      @Override
View Full Code Here

    final DiagramEditor de = TestUtil.loadFile("test.dispel");
 
    Diagram d = de.getDiagramTypeProvider().getDiagram();
    ILinkService ls = Graphiti.getLinkService();
   
    Shape peShape = null;
    EObject linked = null;

    //Find a PE
    for (Shape s : d.getChildren()) {
      linked = ls.getBusinessObjectForLinkedPictogramElement(s);
      if (linked instanceof LocalVariableStatement) {
        if (((LocalVariableStatement) linked).getVariable().getName(
            ).equals("DemoEcho")) {
          peShape = s;
          break;
        }
      }
    }
   
    assertNotNull(peShape);
    assertNotNull(linked.eContainer());
   
    //Take a note of any incoming connections
    List<Connection> cons = new ArrayList<Connection>();
    for (Anchor a :peShape.getAnchors()) {
      cons.addAll(a.getIncomingConnections());
    }

    //Just make sure they're linked
    for (Connection c : cons) {
      assertNotNull(c.getParent());
    }
 
    final Shape deleteShape = peShape;
 
    //Have to async call delete within transaction, then use swtbot to
    //confirm
    asyncExec((new VoidResult() {
      @Override
View Full Code Here

      String name, Diagram d) {
    ILinkService ls = Graphiti.getLinkService();
    EObject linked = null;
    EObject modelObject = null;
    //Find Literal
    Shape literalShape = null;
    for (Shape s : d.getChildren()) {
      linked = ls.getBusinessObjectForLinkedPictogramElement(s);
      if (linked instanceof ConnectionInitialization) {
        ConnectionInitialization ci = (ConnectionInitialization) linked;
        EObject e = Utility.getChildLiteral(ci);
View Full Code Here

   */
  private void addText(ContainerShape containerShape,
      String peName, LocalVariableStatement lvs) {

    // create shape for text
    Shape shape = Graphiti.getPeCreateService().createShape(
        containerShape, false);

    // create and set text graphics algorithm
    Text text = Graphiti.getGaService().createDefaultText(
        getDiagram(), shape,
View Full Code Here

   *
   * @param containerShape Shape to add line to
   */
  private void addLineToBox(ContainerShape containerShape) {
    // create shape for line
    Shape shape = Graphiti.getPeCreateService().createShape(
        containerShape, false);
    // create and set graphics algorithm
    Polyline polyline = Graphiti.getGaService().createPolyline(
        shape, new int[] { 0, 40, BOX_WIDTH, 40 });
    polyline.setStyle(StyleUtil.getStyleForPE(getDiagram()));
View Full Code Here

    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());
View Full Code Here

      // set container shape for direct editing after object creation
      directEditingInfo.setMainPictogramElement(pe);
      // set shape and graphics algorithm where the editor for
      // direct editing shall be opened after object creation
   
      Shape textShape = null;
      if (pe instanceof ContainerShape) {
        //Need to find child shape
        List<Shape> shapes = ((ContainerShape) pe).getChildren();
        for (Shape s : shapes) {
          if (s.getGraphicsAlgorithm() instanceof AbstractText) {
            textShape = s;
            break;
          }
        }
      }
     
      if (textShape != null) {
        //pe should be shape and ga text
        directEditingInfo.setPictogramElement(textShape);
        directEditingInfo.setGraphicsAlgorithm(
            textShape.getGraphicsAlgorithm());
        directEditingInfo.setActive(true);
        getDiagramEditor().refresh();
      }
    }
  }
View Full Code Here

    NodeList myNodes = new NodeList();
    myNodes.addAll(graph.nodes);
    myNodes.addAll(graph.subgraphs);
    for (Object object : myNodes) {
      Node node = (Node) object;
      Shape shape = (Shape) node.data;
      shape.getGraphicsAlgorithm().setX(node.x);
      shape.getGraphicsAlgorithm().setY(node.y);
      /**
       * We can also set the size of the elements, but I'd rather they
       * just kept the original size. Uncomment following if you want
       * to try this.
       *
 
View Full Code Here

TOP

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

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.