use of org.pentaho.di.core.undo.TransAction in project pentaho-kettle by pentaho.
the class AbstractMeta method addUndo.
/*
* (non-Javadoc)
*
* @see org.pentaho.di.core.gui.UndoInterface#addUndo(java.lang.Object[], java.lang.Object[], int[],
* org.pentaho.di.core.gui.Point[], org.pentaho.di.core.gui.Point[], int, boolean)
*/
@Override
public void addUndo(Object[] from, Object[] to, int[] pos, Point[] prev, Point[] curr, int type_of_change, boolean nextAlso) {
while (undo.size() > undo_position + 1 && undo.size() > 0) {
int last = undo.size() - 1;
undo.remove(last);
}
TransAction ta = new TransAction();
switch(type_of_change) {
case TYPE_UNDO_CHANGE:
ta.setChanged(from, to, pos);
break;
case TYPE_UNDO_DELETE:
ta.setDelete(from, pos);
break;
case TYPE_UNDO_NEW:
ta.setNew(from, pos);
break;
case TYPE_UNDO_POSITION:
ta.setPosition(from, pos, prev, curr);
break;
default:
break;
}
undo.add(ta);
undo_position++;
if (undo.size() > max_undo) {
undo.remove(0);
undo_position--;
}
}
use of org.pentaho.di.core.undo.TransAction in project pentaho-kettle by pentaho.
the class TableView method viewNextUndo.
private TransAction viewNextUndo() {
int size = undo.size();
if (size == 0 || undoPosition >= size - 1) {
// no redo left...
return null;
}
TransAction retval = undo.get(undoPosition + 1);
return retval;
}
use of org.pentaho.di.core.undo.TransAction in project pentaho-kettle by pentaho.
the class TableView method nextUndo.
private TransAction nextUndo() {
int size = undo.size();
if (size == 0 || undoPosition >= size - 1) {
// no redo left...
return null;
}
undoPosition++;
TransAction retval = undo.get(undoPosition);
return retval;
}
use of org.pentaho.di.core.undo.TransAction in project pentaho-kettle by pentaho.
the class TableView method keepSelected.
private void keepSelected() {
// Which items are selected?
int[] sels = table.getSelectionIndices();
int size = table.getItemCount();
// Which items do we delete?
int[] items = new int[size - sels.length];
if (items.length == 0) {
// everything is selected: keep everything, do nothing.
return;
}
// Set the item-indices to delete...
int nr = 0;
for (int i = 0; i < table.getItemCount(); i++) {
boolean selected = false;
for (int j = 0; j < sels.length && !selected; j++) {
if (sels[j] == i) {
selected = true;
}
}
if (!selected) {
items[nr] = i;
nr++;
}
}
// Save undo information
String[][] before = new String[items.length][];
for (int i = 0; i < items.length; i++) {
TableItem ti = table.getItem(items[i]);
before[i] = getItemText(ti);
}
TransAction ta = new TransAction();
ta.setDelete(before, items);
addUndo(ta);
// Delete selected items.
table.remove(items);
if (table.getItemCount() == 0) {
TableItem item = new TableItem(table, SWT.NONE);
// Save undo infomation!
String[] stritem = getItemText(item);
ta = new TransAction();
ta.setNew(new String[][] { stritem }, new int[] { 0 });
addUndo(ta);
}
/*
* try { table.getRow(); } catch(Exception e) // Index is too high: lower to last available value {
* setPosition(table.getItemCount()-1, 1); }
*/
setRowNums();
setModified();
}
use of org.pentaho.di.core.undo.TransAction in project pentaho-kettle by pentaho.
the class TableView method checkChanged.
private void checkChanged(String[][] before, String[][] after, int[] index) {
// Did we change anything: if so, add undo information
if (fieldChanged) {
TransAction ta = new TransAction();
ta.setChanged(before, after, index);
addUndo(ta);
}
}
Aggregations