예제 #1
0
  /** Tests undo/redo of moving of a root element in a resource. */
  public void test_undoRootElementMove_RATLC00537680() {
    final Library secondRoot = EXTLibraryFactory.eINSTANCE.createLibrary();
    secondRoot.setName("secondRoot"); // $NON-NLS-1$

    // first, add a second root that we can move
    domain.runInUndoInterval(
        new Runnable() {
          public void run() {
            try {
              domain.runAsWrite(
                  new MRunnable() {
                    public Object run() {
                      testResource.getContents().add(secondRoot);
                      return null;
                    }
                  });
            } catch (MSLActionAbandonedException e) {
              fail(e);
            }
          }
        });

    // now, move it
    MUndoInterval undo =
        domain.runInUndoInterval(
            new Runnable() {
              public void run() {
                try {
                  domain.runAsWrite(
                      new MRunnable() {
                        public Object run() {
                          testResource.getContents().move(0, secondRoot);
                          return null;
                        }
                      });
                } catch (MSLActionAbandonedException e) {
                  fail(e);
                }
              }
            });

    assertEquals(0, testResource.getContents().indexOf(secondRoot));

    // try undoing
    undo.undo();

    // should be at position 1 again
    assertEquals(1, testResource.getContents().indexOf(secondRoot));

    // try redoing
    undo.redo();

    // should be back to position 0
    assertEquals(0, testResource.getContents().indexOf(secondRoot));
  }
예제 #2
0
  /** Tests undo/redo of removal of a root element to a resource. */
  public void test_undoRootElementRemove_RATLC00537680() {
    if (writing()) {
      testResource.getContents().remove(root);
    } else {
      MUndoInterval undo = getLastUndo();

      // try undoing
      undo.undo();

      // should be able to find it again
      assertFound("root"); // $NON-NLS-1$

      // try redoing
      undo.redo();

      // should have removed it again
      assertNotFound("root"); // $NON-NLS-1$
    }
  }
예제 #3
0
  /** Tests undo/redo of addition of a root element to a resource. */
  public void test_undoRootElementAdd_RATLC00537680() {
    if (writing()) {
      Library lib = EXTLibraryFactory.eINSTANCE.createLibrary();
      lib.setName("NewlyAdded"); // $NON-NLS-1$
      testResource.getContents().add(lib);
    } else {
      MUndoInterval undo = getLastUndo();

      // try undoing
      undo.undo();

      // should have removed the root that we added
      assertNotFound("NewlyAdded"); // $NON-NLS-1$

      // try redoing
      undo.redo();

      // should be able to find it again
      assertFound("NewlyAdded"); // $NON-NLS-1$
    }
  }