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;
}
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;
}
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);
}
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);
}
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;
}
Aggregations