Package org.eclipse.graphiti.mm.pictograms

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


  @Test
  public void testAddPE() {
   
    final DiagramEditor de = TestUtil.loadFile("test.dispel");
   
    final Diagram d = de.getDiagramTypeProvider().getDiagram();
   
    //Shouldn't have a PE with this type yet
    Pair<Shape, LocalVariableStatement> notHere = getPEWithType(
        "AssociatorXml", d);
    assertNull(notHere.getLeft());
View Full Code Here


  @Test
  public void testLiteralToPEConnection() {
   
    final DiagramEditor de = TestUtil.loadFile("addConnection.dispel");
   
    Diagram d = de.getDiagramTypeProvider().getDiagram();
    ILinkService ls = Graphiti.getLinkService();
   
    ContainerShape peShape = null;
    EObject linked = null;
   
    //Get Demo Echo PE
    for (Shape s : d.getChildren()) {
      linked = ls.getBusinessObjectForLinkedPictogramElement(s);
      if (linked instanceof LocalVariableStatement) {
        if (((LocalVariableStatement) linked).getVariable().getName(
            ).equals("DemoEcho")) {
          assertTrue(s instanceof ContainerShape);
          peShape = (ContainerShape) s;
          break;
        }
      }
    }
   
    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(
View Full Code Here

  @Test
  public void testDeleteCI() {
   
    final DiagramEditor de = TestUtil.loadFile("test.dispel");
 
    Diagram d = de.getDiagramTypeProvider().getDiagram();
   
    Pair<Shape, EObject> ciPair = TestUtil.getLiteralWithName(
        "\"Hello World\"", d);
   
    assertNotNull(ciPair.getLeft());
    assertNotNull(ciPair.getRight());
    assertNotNull(Utility.getParentConnectionStatement(ciPair.getRight()));
    assertNotNull(Utility.getParentConnectionStatement(ciPair.getRight()
        ).eContainer());
   
    //Take a note of any outgoing connections
    List<Connection> cons = new ArrayList<Connection>();
    for (Anchor a : ciPair.getLeft().getAnchors()) {
      cons.addAll(a.getOutgoingConnections());
    }

    //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
      public void run() {

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

              @Override
              protected void doExecute() {
                IDiagramTypeProvider dtp =
                    de.getDiagramTypeProvider();
                IFeatureProvider fp = dtp.getFeatureProvider();

                final DeleteContext dc = new DeleteContext(
                    deleteShape);
                final IDeleteFeature df =
                    de.getDiagramTypeProvider(
                    ).getFeatureProvider().getDeleteFeature(
                        dc);

                assert(df.canDelete(dc));
                df.delete(dc);
              }});
      }}));
   
    SWTBotShell shell = mBot.shell("Confirm Delete");
    shell.activate();
    mBot.button("Yes").click();   
    mBot.sleep(1000);
    mBot.menu("File").menu("Save").click();
    mBot.sleep(1000);

    //Make sure deleted from diagram and model   
    assertFalse(d.getChildren().contains(deleteShape));
    assertNull(Utility.getParentConnectionStatement(ciPair.getRight()
        ).eContainer());
    //Outgoing connections should be dead too
    for (Connection c : cons) {
      assertNull(c.getParent());
View Full Code Here

    //Have to put commands in a transaction if we want to change things
    final Runnable runnable = new Runnable() {
      public void run() {

        Diagram diagram = Graphiti.getPeCreateService().createDiagram(
            "DISPEL", localName, false);
        diagramResource.getContents().add(diagram);
      }
    };

    editingDomain.getCommandStack().execute(
        new RecordingCommand(editingDomain, "create diagram") {
          protected void doExecute() {
            runnable.run();
          }
        });

    try {
      diagramResource.save(getSaveOptions());
    } catch (IOException e) {
      MessageDialog.openError(Utility.getShell(),
          "Save Failed",
          "Failed to save diagram resource");
      Activator.logError("Failed to save diagram resource", e);
     
    }

    List<EObject> contents = diagramResource.getContents();

    Diagram d = null;
    CompilationUnit compUnit = null;
    String fragment = "";
    for (EObject e : contents) {
      if ((compUnit == null) && (e instanceof CompilationUnit)) {
        compUnit = (CompilationUnit) e;
View Full Code Here

  @Test
  public void editLiteralTest() throws Exception {
   
    final DiagramEditor de = TestUtil.loadFile("test.dispel");
   
    final Diagram d = de.getDiagramTypeProvider().getDiagram();
   
    //Create a string literal
    //We know it will appear in the top left
    createCI(de, "DirectEditTest");
   
View Full Code Here

    mBot.menu("File").menu("Save").click();
    mBot.sleep(1000);
  }
 
  public void createCI(final DiagramEditor de, String name) {
    final Diagram d = de.getDiagramTypeProvider().getDiagram();
    asyncExec((new VoidResult() {
      @Override
      public void run() {

        de.getEditingDomain().getCommandStack().execute(
View Full Code Here

  @Test
  public void testDeletePE() {
   
    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
      public void run() {

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

              @Override
              protected void doExecute() {
                IDiagramTypeProvider dtp =
                    de.getDiagramTypeProvider();
                IFeatureProvider fp = dtp.getFeatureProvider();

                final DeleteContext dc = new DeleteContext(
                    deleteShape);
                final IDeleteFeature df =
                    de.getDiagramTypeProvider(
                    ).getFeatureProvider().getDeleteFeature(
                        dc);

                assert(df.canDelete(dc));
                df.delete(dc);
              }});
      }}));


   
    //Select the PE
    //final SWTBotGefEditor editor = mBot.gefEditor("test");
    //editor.getEditPart("DemoEcho\nEcho").click();
    //editor.
    //Pause, then hit delete
    //mBot.sleep(1000);
    /*
    final Event down = new Event();
    down.type = SWT.KeyDown;
    down.keyCode = SWT.DEL;
    down.character = SWT.DEL;
    final Event up = new Event();
    up.type = SWT.KeyUp;
    up.keyCode = SWT.DEL;
    up.character = SWT.DEL;
    editor.getWidget().notifyListeners(eventType, event)
    editor.getWidget().getDisplay().syncExec(new Runnable() {
      public void run() {       
        assertTrue(editor.getWidget().getDisplay().post(down));
        assertTrue(editor.getWidget().getDisplay().post(up));
      }
    });
    */
    //char del = 0x7F;
    //Keyboard k = KeyboardFactory.getMockKeyboard(editor.getWidget(), null);
 
   
    //mBot.waitUntil(Conditions.shellIsActive("Confirm Delete"));
    //Close confirmation
   
    SWTBotShell shell = mBot.shell("Confirm Delete");
    shell.activate();
    mBot.button("Yes").click();   
    mBot.sleep(1000);
    mBot.menu("File").menu("Save").click();
    mBot.sleep(1000);

    //Make sure deleted from diagram and model   
    assertFalse(d.getChildren().contains(peShape));
    assertNull(linked.eContainer());
    //Incoming connections should be dead too
    for (Connection c : cons) {
      assertNull(c.getParent());
    }
View Full Code Here

  @Test
  public void testAddCI() {
   
    final DiagramEditor de = TestUtil.loadFile("test.dispel");
   
    final Diagram d = de.getDiagramTypeProvider().getDiagram();
   
    //Shouldn't have a literal with this name yet
    Pair<Shape, EObject> notHere = TestUtil.getLiteralWithName(
        "\"Test String Literal\"", d);
    assertNull(notHere.getLeft());
View Full Code Here

        ).getActiveWorkbenchWindow().getActivePage().getActiveEditor();
   
    assertTrue(ep instanceof DiagramEditor);
   
    DiagramEditor de = (DiagramEditor) ep;
    Diagram d = di.getDiagram();
   
    de.getDiagramTypeProvider().getFeatureProvider(
        ).updateIfPossible(new UpdateContext(d));
   
    return de;
View Full Code Here

      lvs = (LocalVariableStatement) context.getNewObject();
    }
   
    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);
View Full Code Here

TOP

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

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.