use of org.pentaho.di.trans.step.BaseStepData.StepExecutionStatus in project pentaho-kettle by pentaho.
the class TransGridDelegate method refreshView.
private void refreshView() {
boolean insert = true;
int nrSteps = -1;
int totalSteps = -1;
if (transGridView == null || transGridView.isDisposed()) {
return;
}
if (refresh_busy) {
return;
}
List<StepMeta> selectedSteps = new ArrayList<StepMeta>();
if (showSelectedSteps) {
selectedSteps = transGraph.trans.getTransMeta().getSelectedSteps();
}
int topIdx = transGridView.getTable().getTopIndex();
refresh_busy = true;
Table table = transGridView.table;
long time = new Date().getTime();
long msSinceLastUpdate = time - lastUpdateView;
if (transGraph.trans != null && !transGraph.trans.isPreparing() && msSinceLastUpdate > UPDATE_TIME_VIEW) {
lastUpdateView = time;
nrSteps = transGraph.trans.nrSteps();
totalSteps = nrSteps;
if (hideInactiveSteps) {
nrSteps = transGraph.trans.nrActiveSteps();
}
StepExecutionStatus[] stepStatusLookup = transGraph.trans.getTransStepExecutionStatusLookup();
boolean[] isRunningLookup = transGraph.trans.getTransStepIsRunningLookup();
int sortColumn = transGridView.getSortField();
boolean sortDescending = transGridView.isSortingDescending();
int[] selectedItems = transGridView.getSelectionIndices();
if (table.getItemCount() != nrSteps) {
table.removeAll();
} else {
insert = false;
}
if (nrSteps == 0 && table.getItemCount() == 0) {
new TableItem(table, SWT.NONE);
refresh_busy = false;
return;
}
int nr = 0;
for (int i = 0; i < totalSteps; i++) {
StepInterface baseStep = transGraph.trans.getRunThread(i);
// See if the step is selected & in need of display
//
boolean showSelected;
if (showSelectedSteps) {
if (selectedSteps.size() == 0) {
showSelected = true;
} else {
showSelected = false;
for (StepMeta stepMeta : selectedSteps) {
if (baseStep.getStepMeta().equals(stepMeta)) {
showSelected = true;
break;
}
}
}
} else {
showSelected = true;
}
//
if (showSelected && (hideInactiveSteps && (isRunningLookup[i] || stepStatusLookup[i] != StepExecutionStatus.STATUS_FINISHED)) || (!hideInactiveSteps && stepStatusLookup[i] != StepExecutionStatus.STATUS_EMPTY)) {
TableItem ti = null;
if (insert) {
ti = new TableItem(table, SWT.NONE);
} else {
ti = table.getItem(nr);
}
if (ti == null) {
continue;
}
String num = "" + (i + 1);
if (ti.getText(0).length() < 1) {
ti.setText(0, num);
}
if (ti.getText(0).length() > 0) {
Integer tIndex = Integer.parseInt(ti.getText(0));
tIndex--;
baseStep = transGraph.trans.getRunThread(tIndex);
}
StepStatus stepStatus = new StepStatus(baseStep);
String[] fields = stepStatus.getTransLogFields();
// screen!
for (int f = 1; f < fields.length; f++) {
if (!fields[f].equalsIgnoreCase(ti.getText(f))) {
ti.setText(f, fields[f]);
}
}
// Error lines should appear in red:
if (baseStep.getErrors() > 0) {
ti.setBackground(GUIResource.getInstance().getColorRed());
}
nr++;
Collection<StepStatus> stepStatuses = baseStep.subStatuses();
int subIndex = 1;
for (StepStatus status : stepStatuses) {
String[] subFields = status.getTransLogFields(baseStep.getStatus().getDescription());
subFields[1] = " " + subFields[1];
TableItem subItem = new TableItem(table, SWT.NONE);
subItem.setText(0, num + "." + subIndex++);
for (int f = 1; f < subFields.length; f++) {
subItem.setText(f, subFields[f]);
}
}
}
}
for (int i = 0; i < table.getItems().length; i++) {
TableItem item = table.getItem(i);
item.setForeground(GUIResource.getInstance().getColorBlack());
if (!item.getBackground().equals(GUIResource.getInstance().getColorRed())) {
item.setBackground(i % 2 == 0 ? GUIResource.getInstance().getColorWhite() : GUIResource.getInstance().getColorBlueCustomGrid());
}
}
// default
if (table.getItemCount() > 0 && (sortColumn != 0 || !sortDescending)) {
transGridView.sortTable(sortColumn, sortDescending, false);
}
// if (updateRowNumbers) { transGridView.setRowNums(); }
transGridView.optWidth(true);
if (selectedItems != null && selectedItems.length > 0) {
transGridView.setSelection(selectedItems);
}
// transGridView.getTable().setTopIndex(topIdx);
if (transGridView.getTable().getTopIndex() != topIdx) {
transGridView.getTable().setTopIndex(topIdx);
}
} else {
// We need at least one table-item in a table!
if (table.getItemCount() == 0) {
new TableItem(table, SWT.NONE);
}
}
refresh_busy = false;
}
use of org.pentaho.di.trans.step.BaseStepData.StepExecutionStatus in project pentaho-kettle by pentaho.
the class Trans method getTransStepExecutionStatusLookup.
/**
* Checks the execution status of each step in the transformations.
*
* @return an array associated with the step list, indicating the status of that step.
*/
public StepExecutionStatus[] getTransStepExecutionStatusLookup() {
if (steps == null) {
return null;
}
// we need this snapshot for the TransGridDelegate refresh method to handle the
// difference between a timed refresh and continual step status updates
int totalSteps = steps.size();
StepExecutionStatus[] tList = new StepExecutionStatus[totalSteps];
for (int i = 0; i < totalSteps; i++) {
StepMetaDataCombi sid = steps.get(i);
tList[i] = sid.step.getStatus();
}
return tList;
}
Aggregations