use of org.pentaho.di.trans.step.StepMeta in project pentaho-kettle by pentaho.
the class SortedMergeDialog method open.
public String open() {
Shell parent = getParent();
Display display = parent.getDisplay();
shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MIN | SWT.MAX);
props.setLook(shell);
setShellImage(shell, input);
ModifyListener lsMod = new ModifyListener() {
public void modifyText(ModifyEvent e) {
input.setChanged();
}
};
changed = input.hasChanged();
FormLayout formLayout = new FormLayout();
formLayout.marginWidth = Const.FORM_MARGIN;
formLayout.marginHeight = Const.FORM_MARGIN;
shell.setLayout(formLayout);
shell.setText(BaseMessages.getString(PKG, "SortedMergeDialog.Shell.Title"));
int middle = props.getMiddlePct();
int margin = Const.MARGIN;
// Stepname line
wlStepname = new Label(shell, SWT.RIGHT);
wlStepname.setText(BaseMessages.getString(PKG, "SortedMergeDialog.Stepname.Label"));
props.setLook(wlStepname);
fdlStepname = new FormData();
fdlStepname.left = new FormAttachment(0, 0);
fdlStepname.right = new FormAttachment(middle, -margin);
fdlStepname.top = new FormAttachment(0, margin);
wlStepname.setLayoutData(fdlStepname);
wStepname = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
wStepname.setText(stepname);
props.setLook(wStepname);
wStepname.addModifyListener(lsMod);
fdStepname = new FormData();
fdStepname.left = new FormAttachment(middle, 0);
fdStepname.top = new FormAttachment(0, margin);
fdStepname.right = new FormAttachment(100, 0);
wStepname.setLayoutData(fdStepname);
// Some buttons
wOK = new Button(shell, SWT.PUSH);
wOK.setText(BaseMessages.getString(PKG, "System.Button.OK"));
wGet = new Button(shell, SWT.PUSH);
wGet.setText(BaseMessages.getString(PKG, "System.Button.GetFields"));
wCancel = new Button(shell, SWT.PUSH);
wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel"));
setButtonPositions(new Button[] { wOK, wCancel, wGet }, margin, null);
wlFields = new Label(shell, SWT.NONE);
wlFields.setText(BaseMessages.getString(PKG, "SortedMergeDialog.Fields.Label"));
props.setLook(wlFields);
fdlFields = new FormData();
fdlFields.left = new FormAttachment(0, 0);
fdlFields.top = new FormAttachment(wStepname, margin);
wlFields.setLayoutData(fdlFields);
final int FieldsCols = 2;
final int FieldsRows = input.getFieldName().length;
colinf = new ColumnInfo[FieldsCols];
colinf[0] = new ColumnInfo(BaseMessages.getString(PKG, "SortedMergeDialog.Fieldname.Column"), ColumnInfo.COLUMN_TYPE_CCOMBO, new String[] { "" }, false);
colinf[1] = new ColumnInfo(BaseMessages.getString(PKG, "SortedMergeDialog.Ascending.Column"), ColumnInfo.COLUMN_TYPE_CCOMBO, new String[] { BaseMessages.getString(PKG, "System.Combo.Yes"), BaseMessages.getString(PKG, "System.Combo.No") });
wFields = new TableView(transMeta, shell, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI, colinf, FieldsRows, lsMod, props);
fdFields = new FormData();
fdFields.left = new FormAttachment(0, 0);
fdFields.top = new FormAttachment(wlFields, margin);
fdFields.right = new FormAttachment(100, 0);
fdFields.bottom = new FormAttachment(wOK, -2 * margin);
wFields.setLayoutData(fdFields);
//
// Search the fields in the background
final Runnable runnable = new Runnable() {
public void run() {
StepMeta stepMeta = transMeta.findStep(stepname);
if (stepMeta != null) {
try {
RowMetaInterface row = transMeta.getPrevStepFields(stepMeta);
// Remember these fields...
for (int i = 0; i < row.size(); i++) {
inputFields.put(row.getValueMeta(i).getName(), Integer.valueOf(i));
}
setComboBoxes();
} catch (KettleException e) {
logError(BaseMessages.getString(PKG, "System.Dialog.GetFieldsFailed.Message"));
}
}
}
};
new Thread(runnable).start();
// Add listeners
wCancel.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event e) {
cancel();
}
});
wGet.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event e) {
get();
}
});
wOK.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event e) {
ok();
}
});
lsDef = new SelectionAdapter() {
public void widgetDefaultSelected(SelectionEvent e) {
ok();
}
};
wStepname.addSelectionListener(lsDef);
// Detect X or ALT-F4 or something that kills this window...
shell.addShellListener(new ShellAdapter() {
public void shellClosed(ShellEvent e) {
cancel();
}
});
// Set the shell size, based upon previous time...
setSize();
getData();
input.setChanged(changed);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
return stepname;
}
use of org.pentaho.di.trans.step.StepMeta in project pentaho-kettle by pentaho.
the class SQLFileOutputDialog method sql.
// Generate code for create table...
// Conversions done by Database
//
private void sql() {
try {
SQLFileOutputMeta info = new SQLFileOutputMeta();
getInfo(info);
RowMetaInterface prev = transMeta.getPrevStepFields(stepname);
StepMeta stepMeta = transMeta.findStep(stepname);
SQLStatement sql = info.getSQLStatements(transMeta, stepMeta, prev, repository, metaStore);
if (!sql.hasError()) {
if (sql.hasSQL()) {
SQLEditor sqledit = new SQLEditor(transMeta, shell, SWT.NONE, info.getDatabaseMeta(), transMeta.getDbCache(), sql.getSQL());
sqledit.open();
} else {
MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_INFORMATION);
mb.setMessage(BaseMessages.getString(PKG, "SQLFileOutputDialog.NoSQL.DialogMessage"));
mb.setText(BaseMessages.getString(PKG, "SQLFileOutputDialog.NoSQL.DialogTitle"));
mb.open();
}
} else {
MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
mb.setMessage(sql.getError());
mb.setText(BaseMessages.getString(PKG, "System.Dialog.Error.Title"));
mb.open();
}
} catch (KettleException ke) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "SQLFileOutputDialog.BuildSQLError.DialogTitle"), BaseMessages.getString(PKG, "SQLFileOutputDialog.BuildSQLError.DialogMessage"), ke);
}
}
use of org.pentaho.di.trans.step.StepMeta in project pentaho-kettle by pentaho.
the class StepsMetricsDialog method getInfo.
private void getInfo(StepsMetricsMeta in) {
// return value
stepname = wStepname.getText();
int nrsteps = wFields.nrNonEmpty();
in.allocate(nrsteps);
for (int i = 0; i < nrsteps; i++) {
TableItem ti = wFields.getNonEmpty(i);
StepMeta tm = transMeta.findStep(ti.getText(1));
// CHECKSTYLE:Indentation:OFF
if (tm != null) {
in.getStepName()[i] = tm.getName();
in.getStepCopyNr()[i] = "" + Const.toInt(ti.getText(2), 0);
in.getStepRequired()[i] = in.getRequiredStepsCode(ti.getText(3));
}
}
in.setStepNameFieldName(wStepnameField.getText());
in.setStepIdFieldName(wStepidField.getText());
in.setStepLinesInputFieldName(wLinesinputField.getText());
in.setStepLinesOutputFieldName(wLinesoutputField.getText());
in.setStepLinesReadFieldName(wLinesreadField.getText());
in.setStepLinesWrittenFieldName(wLineswrittenField.getText());
in.setStepLinesUpdatedFieldName(wLinesupdatedField.getText());
in.setStepLinesErrorsFieldName(wLineserrorsField.getText());
in.setStepSecondsFieldName(wSecondsField.getText());
}
use of org.pentaho.di.trans.step.StepMeta in project pentaho-kettle by pentaho.
the class StreamLookupDialog method open.
public String open() {
Shell parent = getParent();
Display display = parent.getDisplay();
shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MAX | SWT.MIN);
props.setLook(shell);
setShellImage(shell, input);
ModifyListener lsMod = new ModifyListener() {
public void modifyText(ModifyEvent e) {
input.setChanged();
}
};
SelectionListener lsSelection = new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
input.setChanged();
setComboBoxesLookup();
}
};
changed = input.hasChanged();
FormLayout formLayout = new FormLayout();
formLayout.marginWidth = Const.FORM_MARGIN;
formLayout.marginHeight = Const.FORM_MARGIN;
shell.setLayout(formLayout);
shell.setText(BaseMessages.getString(PKG, "StreamLookupDialog.Shell.Title"));
int middle = props.getMiddlePct();
int margin = Const.MARGIN;
// Stepname line
wlStepname = new Label(shell, SWT.RIGHT);
wlStepname.setText(BaseMessages.getString(PKG, "StreamLookupDialog.Stepname.Label"));
props.setLook(wlStepname);
fdlStepname = new FormData();
fdlStepname.left = new FormAttachment(0, 0);
fdlStepname.right = new FormAttachment(middle, -margin);
fdlStepname.top = new FormAttachment(0, margin);
wlStepname.setLayoutData(fdlStepname);
wStepname = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
wStepname.setText(stepname);
props.setLook(wStepname);
wStepname.addModifyListener(lsMod);
fdStepname = new FormData();
fdStepname.left = new FormAttachment(middle, 0);
fdStepname.top = new FormAttachment(0, margin);
fdStepname.right = new FormAttachment(100, 0);
wStepname.setLayoutData(fdStepname);
// Lookup step line...
wlStep = new Label(shell, SWT.RIGHT);
wlStep.setText(BaseMessages.getString(PKG, "StreamLookupDialog.LookupStep.Label"));
props.setLook(wlStep);
fdlStep = new FormData();
fdlStep.left = new FormAttachment(0, 0);
fdlStep.right = new FormAttachment(middle, -margin);
fdlStep.top = new FormAttachment(wStepname, margin * 2);
wlStep.setLayoutData(fdlStep);
wStep = new CCombo(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wStep);
List<StepMeta> previousSteps = transMeta.findPreviousSteps(stepMeta, true);
for (StepMeta previousStep : previousSteps) {
wStep.add(previousStep.getName());
}
// transMeta.getInfoStep()
wStep.addModifyListener(lsMod);
wStep.addSelectionListener(lsSelection);
fdStep = new FormData();
fdStep.left = new FormAttachment(middle, 0);
fdStep.top = new FormAttachment(wStepname, margin * 2);
fdStep.right = new FormAttachment(100, 0);
wStep.setLayoutData(fdStep);
wlKey = new Label(shell, SWT.NONE);
wlKey.setText(BaseMessages.getString(PKG, "StreamLookupDialog.Key.Label"));
props.setLook(wlKey);
fdlKey = new FormData();
fdlKey.left = new FormAttachment(0, 0);
fdlKey.top = new FormAttachment(wStep, margin);
wlKey.setLayoutData(fdlKey);
int nrKeyCols = 2;
int nrKeyRows = (input.getKeystream() != null ? input.getKeystream().length : 1);
ciKey = new ColumnInfo[nrKeyCols];
ciKey[0] = new ColumnInfo(BaseMessages.getString(PKG, "StreamLookupDialog.ColumnInfo.Field"), ColumnInfo.COLUMN_TYPE_CCOMBO, new String[] { "" }, false);
ciKey[1] = new ColumnInfo(BaseMessages.getString(PKG, "StreamLookupDialog.ColumnInfo.LookupField"), ColumnInfo.COLUMN_TYPE_CCOMBO, new String[] { "" }, false);
wKey = new TableView(transMeta, shell, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL, ciKey, nrKeyRows, lsMod, props);
fdKey = new FormData();
fdKey.left = new FormAttachment(0, 0);
fdKey.top = new FormAttachment(wlKey, margin);
fdKey.right = new FormAttachment(100, 0);
fdKey.bottom = new FormAttachment(wlKey, 180);
wKey.setLayoutData(fdKey);
// THE UPDATE/INSERT TABLE
wlReturn = new Label(shell, SWT.NONE);
wlReturn.setText(BaseMessages.getString(PKG, "StreamLookupDialog.ReturnFields.Label"));
props.setLook(wlReturn);
fdlReturn = new FormData();
fdlReturn.left = new FormAttachment(0, 0);
fdlReturn.top = new FormAttachment(wKey, margin);
wlReturn.setLayoutData(fdlReturn);
int UpInsCols = 4;
int UpInsRows = (input.getValue() != null ? input.getValue().length : 1);
ciReturn = new ColumnInfo[UpInsCols];
ciReturn[0] = new ColumnInfo(BaseMessages.getString(PKG, "StreamLookupDialog.ColumnInfo.FieldReturn"), ColumnInfo.COLUMN_TYPE_CCOMBO, new String[] { "" }, false);
ciReturn[1] = new ColumnInfo(BaseMessages.getString(PKG, "StreamLookupDialog.ColumnInfo.NewName"), ColumnInfo.COLUMN_TYPE_TEXT, false);
ciReturn[2] = new ColumnInfo(BaseMessages.getString(PKG, "StreamLookupDialog.ColumnInfo.Default"), ColumnInfo.COLUMN_TYPE_TEXT, false);
ciReturn[3] = new ColumnInfo(BaseMessages.getString(PKG, "StreamLookupDialog.ColumnInfo.Type"), ColumnInfo.COLUMN_TYPE_CCOMBO, ValueMetaFactory.getValueMetaNames());
wReturn = new TableView(transMeta, shell, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL, ciReturn, UpInsRows, lsMod, props);
// START MEMORY PRESERVE GROUP
fdReturn = new FormData();
fdReturn.left = new FormAttachment(0, 0);
fdReturn.top = new FormAttachment(wlReturn, margin);
fdReturn.right = new FormAttachment(100, 0);
fdReturn.bottom = new FormAttachment(100, -125);
wReturn.setLayoutData(fdReturn);
wlPreserveMemory = new Label(shell, SWT.RIGHT);
wlPreserveMemory.setText(BaseMessages.getString(PKG, "StreamLookupDialog.PreserveMemory.Label"));
props.setLook(wlPreserveMemory);
fdlPreserveMemory = new FormData();
fdlPreserveMemory.left = new FormAttachment(0, 0);
fdlPreserveMemory.top = new FormAttachment(wReturn, margin);
fdlPreserveMemory.right = new FormAttachment(middle, -margin);
wlPreserveMemory.setLayoutData(fdlPreserveMemory);
wPreserveMemory = new Button(shell, SWT.CHECK);
props.setLook(wPreserveMemory);
fdPreserveMemory = new FormData();
fdPreserveMemory.left = new FormAttachment(middle, 0);
fdPreserveMemory.top = new FormAttachment(wReturn, margin);
fdPreserveMemory.right = new FormAttachment(100, 0);
wPreserveMemory.setLayoutData(fdPreserveMemory);
wPreserveMemory.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
input.setChanged();
}
});
wlIntegerPair = new Label(shell, SWT.RIGHT);
wlIntegerPair.setText(BaseMessages.getString(PKG, "StreamLookupDialog.IntegerPair.Label"));
props.setLook(wlIntegerPair);
fdlIntegerPair = new FormData();
fdlIntegerPair.left = new FormAttachment(0, 0);
fdlIntegerPair.top = new FormAttachment(wPreserveMemory, margin);
fdlIntegerPair.right = new FormAttachment(middle, -margin);
wlIntegerPair.setLayoutData(fdlIntegerPair);
wIntegerPair = new Button(shell, SWT.RADIO);
wIntegerPair.setEnabled(false);
props.setLook(wIntegerPair);
fdIntegerPair = new FormData();
fdIntegerPair.left = new FormAttachment(middle, 0);
fdIntegerPair.top = new FormAttachment(wPreserveMemory, margin);
fdIntegerPair.right = new FormAttachment(100, 0);
wIntegerPair.setLayoutData(fdIntegerPair);
wIntegerPair.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
input.setChanged();
}
});
wlSortedList = new Label(shell, SWT.RIGHT);
wlSortedList.setText(BaseMessages.getString(PKG, "StreamLookupDialog.SortedList.Label"));
props.setLook(wlSortedList);
fdlSortedList = new FormData();
fdlSortedList.left = new FormAttachment(0, 0);
fdlSortedList.top = new FormAttachment(wIntegerPair, margin);
fdlSortedList.right = new FormAttachment(middle, -margin);
wlSortedList.setLayoutData(fdlSortedList);
wSortedList = new Button(shell, SWT.RADIO);
wSortedList.setEnabled(false);
props.setLook(wSortedList);
fdSortedList = new FormData();
fdSortedList.left = new FormAttachment(middle, 0);
fdSortedList.top = new FormAttachment(wIntegerPair, margin);
fdSortedList.right = new FormAttachment(100, 0);
wSortedList.setLayoutData(fdSortedList);
wSortedList.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
input.setChanged();
}
});
// PDI-2107 preserve memory should be enabled to have this options on.
wPreserveMemory.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event event) {
boolean selection = wPreserveMemory.getSelection();
wSortedList.setEnabled(selection);
wIntegerPair.setEnabled(selection);
}
});
// END MEMORY PRESERVE
// THE BUTTONS
wOK = new Button(shell, SWT.PUSH);
wOK.setText(BaseMessages.getString(PKG, "System.Button.OK"));
wGet = new Button(shell, SWT.PUSH);
wGet.setText(BaseMessages.getString(PKG, "StreamLookupDialog.GetFields.Button"));
wGetLU = new Button(shell, SWT.PUSH);
wGetLU.setText(BaseMessages.getString(PKG, "StreamLookupDialog.GetLookupFields.Button"));
wCancel = new Button(shell, SWT.PUSH);
wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel"));
setButtonPositions(new Button[] { wOK, wCancel, wGet, wGetLU }, margin, null);
// Add listeners
lsOK = new Listener() {
public void handleEvent(Event e) {
ok();
}
};
lsGet = new Listener() {
public void handleEvent(Event e) {
get();
}
};
lsGetLU = new Listener() {
public void handleEvent(Event e) {
getlookup();
}
};
lsCancel = new Listener() {
public void handleEvent(Event e) {
cancel();
}
};
wOK.addListener(SWT.Selection, lsOK);
wGet.addListener(SWT.Selection, lsGet);
wGetLU.addListener(SWT.Selection, lsGetLU);
wCancel.addListener(SWT.Selection, lsCancel);
lsDef = new SelectionAdapter() {
public void widgetDefaultSelected(SelectionEvent e) {
ok();
}
};
wStepname.addSelectionListener(lsDef);
// Detect X or ALT-F4 or something that kills this window...
shell.addShellListener(new ShellAdapter() {
public void shellClosed(ShellEvent e) {
cancel();
}
});
// Set the shell size, based upon previous time...
setSize();
getData();
setComboBoxes();
setComboBoxesLookup();
input.setChanged(changed);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
return stepname;
}
use of org.pentaho.di.trans.step.StepMeta in project pentaho-kettle by pentaho.
the class StreamLookupDialog method setComboBoxesLookup.
protected void setComboBoxesLookup() {
Runnable fieldLoader = new Runnable() {
public void run() {
StepMeta lookupStepMeta = transMeta.findStep(wStep.getText());
if (lookupStepMeta != null) {
try {
RowMetaInterface row = transMeta.getStepFields(lookupStepMeta);
Map<String, Integer> lookupFields = new HashMap<String, Integer>();
// Remember these fields...
for (int i = 0; i < row.size(); i++) {
lookupFields.put(row.getValueMeta(i).getName(), Integer.valueOf(i));
}
// Something was changed in the row.
//
final Map<String, Integer> fields = new HashMap<String, Integer>();
// Add the currentMeta fields...
fields.putAll(lookupFields);
Set<String> keySet = fields.keySet();
List<String> entries = new ArrayList<String>(keySet);
String[] fieldNames = entries.toArray(new String[entries.size()]);
Const.sortStrings(fieldNames);
// return fields
ciReturn[0].setComboValues(fieldNames);
ciKey[1].setComboValues(fieldNames);
} catch (KettleException e) {
logError("It was not possible to retrieve the list of fields for step [" + wStep.getText() + "]!");
}
}
}
};
shell.getDisplay().asyncExec(fieldLoader);
}
Aggregations