Search in sources :

Example 11 with TransAction

use of org.pentaho.di.core.undo.TransAction in project pentaho-kettle by pentaho.

the class AbstractMeta method previousUndo.

// get previous undo, change position
/*
   * (non-Javadoc)
   *
   * @see org.pentaho.di.core.gui.UndoInterface#previousUndo()
   */
@Override
public TransAction previousUndo() {
    if (undo.isEmpty() || undo_position < 0) {
        // No undo left!
        return null;
    }
    TransAction retval = undo.get(undo_position);
    undo_position--;
    return retval;
}
Also used : TransAction(org.pentaho.di.core.undo.TransAction)

Example 12 with TransAction

use of org.pentaho.di.core.undo.TransAction in project pentaho-kettle by pentaho.

the class AbstractMeta method nextUndo.

/*
   * (non-Javadoc)
   *
   * @see org.pentaho.di.core.gui.UndoInterface#nextUndo()
   */
@Override
public TransAction nextUndo() {
    int size = undo.size();
    if (size == 0 || undo_position >= size - 1) {
        // no redo left...
        return null;
    }
    undo_position++;
    TransAction retval = undo.get(undo_position);
    return retval;
}
Also used : TransAction(org.pentaho.di.core.undo.TransAction) Point(org.pentaho.di.core.gui.Point)

Example 13 with TransAction

use of org.pentaho.di.core.undo.TransAction in project pentaho-kettle by pentaho.

the class AbstractMetaTest method testAddRemoveViewUndo.

@Test
public void testAddRemoveViewUndo() throws Exception {
    // addUndo() right now will fail with an NPE
    assertEquals(0, meta.getUndoSize());
    meta.clearUndo();
    assertEquals(0, meta.getUndoSize());
    assertEquals(0, meta.getMaxUndo());
    meta.setMaxUndo(3);
    assertEquals(3, meta.getMaxUndo());
    // viewThisUndo() and viewPreviousUndo() have the same logic
    assertNull(meta.viewThisUndo());
    assertNull(meta.viewPreviousUndo());
    assertNull(meta.viewNextUndo());
    assertNull(meta.previousUndo());
    assertNull(meta.nextUndo());
    StepMeta fromMeta = mock(StepMeta.class);
    StepMeta toMeta = mock(StepMeta.class);
    Object[] from = new Object[] { fromMeta };
    Object[] to = new Object[] { toMeta };
    int[] pos = new int[0];
    Point[] prev = new Point[0];
    Point[] curr = new Point[0];
    meta.addUndo(from, to, pos, prev, curr, AbstractMeta.TYPE_UNDO_NEW, false);
    assertNotNull(meta.viewThisUndo());
    assertNotNull(meta.viewPreviousUndo());
    assertNull(meta.viewNextUndo());
    meta.addUndo(from, to, pos, prev, curr, AbstractMeta.TYPE_UNDO_CHANGE, false);
    assertNotNull(meta.viewThisUndo());
    assertNotNull(meta.viewPreviousUndo());
    assertNull(meta.viewNextUndo());
    TransAction action = meta.previousUndo();
    assertNotNull(action);
    assertEquals(AbstractMeta.TYPE_UNDO_CHANGE, action.getType());
    assertNotNull(meta.viewThisUndo());
    assertNotNull(meta.viewPreviousUndo());
    assertNotNull(meta.viewNextUndo());
    meta.addUndo(from, to, pos, prev, curr, AbstractMeta.TYPE_UNDO_DELETE, false);
    meta.addUndo(from, to, pos, prev, curr, AbstractMeta.TYPE_UNDO_POSITION, false);
    assertNotNull(meta.previousUndo());
    assertNotNull(meta.nextUndo());
    meta.setMaxUndo(1);
    assertEquals(1, meta.getUndoSize());
    meta.addUndo(from, to, pos, prev, curr, AbstractMeta.TYPE_UNDO_NEW, false);
}
Also used : TransAction(org.pentaho.di.core.undo.TransAction) Matchers.anyObject(org.mockito.Matchers.anyObject) Point(org.pentaho.di.core.gui.Point) StepMeta(org.pentaho.di.trans.step.StepMeta) Test(org.junit.Test)

Example 14 with TransAction

use of org.pentaho.di.core.undo.TransAction in project pentaho-kettle by pentaho.

the class Spoon method setUndoMenu.

/**
 * Sets the text and enabled settings for the undo and redo menu items
 *
 * @param undoInterface
 *          the object which holds the undo/redo information
 */
public void setUndoMenu(UndoInterface undoInterface) {
    if (shell.isDisposed()) {
        return;
    }
    TransAction prev = undoInterface != null ? undoInterface.viewThisUndo() : null;
    TransAction next = undoInterface != null ? undoInterface.viewNextUndo() : null;
    // Set the menubar text and enabled flags
    XulMenuitem item = (XulMenuitem) mainSpoonContainer.getDocumentRoot().getElementById(UNDO_MENU_ITEM);
    item.setLabel(prev == null ? UNDO_UNAVAILABLE : BaseMessages.getString(PKG, "Spoon.Menu.Undo.Available", prev.toString()));
    item.setDisabled(prev == null);
    item = (XulMenuitem) mainSpoonContainer.getDocumentRoot().getElementById(REDO_MENU_ITEM);
    item.setLabel(next == null ? REDO_UNAVAILABLE : BaseMessages.getString(PKG, "Spoon.Menu.Redo.Available", next.toString()));
    item.setDisabled(next == null);
}
Also used : TransAction(org.pentaho.di.core.undo.TransAction) XulMenuitem(org.pentaho.ui.xul.components.XulMenuitem)

Example 15 with TransAction

use of org.pentaho.di.core.undo.TransAction in project pentaho-kettle by pentaho.

the class AbstractMeta method viewNextUndo.

/*
   * (non-Javadoc)
   *
   * @see org.pentaho.di.core.gui.UndoInterface#viewNextUndo()
   */
@Override
public TransAction viewNextUndo() {
    int size = undo.size();
    if (size == 0 || undo_position >= size - 1) {
        // no redo left...
        return null;
    }
    TransAction retval = undo.get(undo_position + 1);
    return retval;
}
Also used : TransAction(org.pentaho.di.core.undo.TransAction) Point(org.pentaho.di.core.gui.Point)

Aggregations

TransAction (org.pentaho.di.core.undo.TransAction)22 Point (org.eclipse.swt.graphics.Point)10 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)7 TableItem (org.eclipse.swt.widgets.TableItem)6 Point (org.pentaho.di.core.gui.Point)4 JobMeta (org.pentaho.di.job.JobMeta)2 TransMeta (org.pentaho.di.trans.TransMeta)2 JobGraph (org.pentaho.di.ui.spoon.job.JobGraph)2 TransGraph (org.pentaho.di.ui.spoon.trans.TransGraph)2 Clipboard (org.eclipse.swt.dnd.Clipboard)1 TextTransfer (org.eclipse.swt.dnd.TextTransfer)1 Test (org.junit.Test)1 Matchers.anyObject (org.mockito.Matchers.anyObject)1 StepMeta (org.pentaho.di.trans.step.StepMeta)1 XulMenuitem (org.pentaho.ui.xul.components.XulMenuitem)1