Search in sources :

Example 16 with TransAction

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--;
    }
}
Also used : TransAction(org.pentaho.di.core.undo.TransAction) Point(org.pentaho.di.core.gui.Point)

Example 17 with TransAction

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;
}
Also used : TransAction(org.pentaho.di.core.undo.TransAction) Point(org.eclipse.swt.graphics.Point)

Example 18 with TransAction

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;
}
Also used : TransAction(org.pentaho.di.core.undo.TransAction) Point(org.eclipse.swt.graphics.Point)

Example 19 with TransAction

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();
}
Also used : TransAction(org.pentaho.di.core.undo.TransAction) TableItem(org.eclipse.swt.widgets.TableItem) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) Point(org.eclipse.swt.graphics.Point)

Example 20 with TransAction

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);
    }
}
Also used : TransAction(org.pentaho.di.core.undo.TransAction)

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