Package org.eclipse.graphiti.ui.editor

Examples of org.eclipse.graphiti.ui.editor.DiagramEditor


  }

  @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());

    //Open reg view and select def
    mBot.menu("Window").menu("Show View").menu("Registry View").click();
    mBot.viewByTitle("Registry View").bot().table().getTableItem(
        "AssociatorXml").select();
   
    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();
                CreatePEFeature peFeat = null;
                for(ICreateFeature ic :
                  fp.getCreateFeatures()) {
                  if (ic instanceof CreatePEFeature) {
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(
            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();
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);
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");
   
    syncExec(new VoidResult() {
      @Override
      public void run() {
        //Have to set mouse location inside part for some annoying
        //reason
        de.getMouseLocation().x = 20;
        de.getMouseLocation().y = 20;

        final SWTBotGefEditor editor = mBot.gefEditor("test");
       
        //Should activate with double click
        SWTBotGefEditPart ep = editor.getEditPart("\"DirectEditTest\""
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);
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());

    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();
                CreateStringLiteralFeature litFeat = null;
                for(ICreateFeature ic : fp.getCreateFeatures()) {
                  if (ic instanceof CreateStringLiteralFeature) {
                    litFeat = (CreateStringLiteralFeature) ic;
View Full Code Here

    IEditorPart ep =  PlatformUI.getWorkbench(
        ).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

  public void runModelChange(final Runnable runnable) {
    PictogramElement pe = getSelectedPictogramElement();
    if (pe != null) {
      Object bo = getBusinessObject(pe);
      if (bo instanceof ServiceTask) {
        DiagramEditor diagramEditor = (DiagramEditor) getDiagramEditor();
        TransactionalEditingDomain editingDomain = diagramEditor.getEditingDomain();
        ActivitiUiUtil.runModelChange(runnable, editingDomain, "Model Update");
      }
    }
  }
View Full Code Here

            if (className != null) {
              classNameText.setText(className);
            }

            DiagramEditor diagramEditor = (DiagramEditor) getDiagramEditor();
            TransactionalEditingDomain editingDomain = diagramEditor.getEditingDomain();

            ActivitiUiUtil.runModelChange(new Runnable() {
              @Override
              public void run() {
                Object bo = getBusinessObject(getSelectedPictogramElement());
View Full Code Here

  private void saveImplementationType(final String type) {
    PictogramElement pe = getSelectedPictogramElement();
    if (pe != null) {
      final Object bo = getBusinessObject(pe);
      if (bo instanceof ServiceTask) {
        DiagramEditor diagramEditor = (DiagramEditor) getDiagramEditor();
        TransactionalEditingDomain editingDomain = diagramEditor.getEditingDomain();
        ActivitiUiUtil.runModelChange(new Runnable() {
          @Override
          public void run() {
            ServiceTask serviceTask = (ServiceTaskbo;
            serviceTask.setImplementationType(type);
View Full Code Here

TOP

Related Classes of org.eclipse.graphiti.ui.editor.DiagramEditor

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.