use of org.pentaho.di.core.undo.TransAction in project pentaho-kettle by pentaho.
the class TableView method pasteSelected.
private void pasteSelected() {
int rownr = getCurrentRownr();
if (clipboard != null) {
clipboard.dispose();
clipboard = null;
}
clipboard = new Clipboard(getDisplay());
TextTransfer tran = TextTransfer.getInstance();
String text = (String) clipboard.getContents(tran);
if (text != null) {
String[] lines = text.split(Const.CR);
if (lines.length > 1) {
// ALlocate complete paste grid!
String[][] grid = new String[lines.length - 1][];
int[] idx = new int[lines.length - 1];
for (int i = 1; i < lines.length; i++) {
grid[i - 1] = lines[i].split("\t");
idx[i - 1] = rownr + i;
addItem(idx[i - 1], grid[i - 1]);
}
TransAction ta = new TransAction();
ta.setNew(grid, idx);
addUndo(ta);
}
if (rownr == 0 && table.getItemCount() > rownr + 1) {
if (isEmpty(rownr, -1)) {
table.remove(rownr);
}
}
setRowNums();
unEdit();
setModified();
}
}
use of org.pentaho.di.core.undo.TransAction in project pentaho-kettle by pentaho.
the class TableView method copyToAll.
private void copyToAll() {
TableItem row = activeTableItem;
if (row == null || row.isDisposed()) {
return;
}
int colnr = activeTableColumn;
if (colnr == 0) {
return;
}
String str = row.getText(colnr);
// Get undo information: all columns
int size = table.getItemCount();
String[][] before = new String[size][];
String[][] after = new String[size][];
int[] index = new int[size];
for (int i = 0; i < table.getItemCount(); i++) {
TableItem item = table.getItem(i);
index[i] = i;
before[i] = getItemText(item);
item.setText(colnr, str);
after[i] = getItemText(item);
}
// Add the undo information!
TransAction ta = new TransAction();
ta.setChanged(before, after, index);
addUndo(ta);
}
use of org.pentaho.di.core.undo.TransAction in project pentaho-kettle by pentaho.
the class TableView method previousUndo.
// get previous undo, change position
private TransAction previousUndo() {
if (undo.isEmpty() || undoPosition < 0) {
// No undo left!
return null;
}
TransAction retval = undo.get(undoPosition);
undoPosition--;
return retval;
}
use of org.pentaho.di.core.undo.TransAction in project pentaho-kettle by pentaho.
the class TableView method insertRow.
private void insertRow(int ronr) {
TableItem item = new TableItem(table, SWT.NONE, ronr);
item.setText(1, "");
// Add undo information
TransAction ta = new TransAction();
String[] str = getItemText(item);
ta.setNew(new String[][] { str }, new int[] { ronr });
addUndo(ta);
setRowNums();
edit(ronr, 1);
tableViewModifyListener.insertRow(ronr);
}
use of org.pentaho.di.core.undo.TransAction in project pentaho-kettle by pentaho.
the class TableView method delSelected.
private void delSelected() {
if (nrNonEmpty() == 0) {
return;
}
// Which items do we delete?
int[] items = table.getSelectionIndices();
if (items.length == 0) {
return;
}
// 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);
TableItem row = activeTableItem;
if (row == null) {
return;
}
int rowbefore = table.indexOf(row);
// 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);
}
// If the last row is gone, put the selection back on last-1!
if (rowbefore >= table.getItemCount()) {
rowbefore = table.getItemCount() - 1;
}
// After the delete, we put the cursor on the same row as before (if we can)
if (rowbefore < table.getItemCount() && table.getItemCount() > 0) {
setPosition(rowbefore, 1);
table.setSelection(rowbefore);
activeTableRow = rowbefore;
}
tableViewModifyListener.delete(items);
setRowNums();
setModified();
}
Aggregations