use of org.pentaho.di.core.row.RowMetaInterface in project pentaho-kettle by pentaho.
the class StreamLookupDialog method get.
private void get() {
if (transMeta.findStep(wStep.getText()) == null) {
MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
mb.setMessage(BaseMessages.getString(PKG, "StreamLookupDialog.PleaseSelectAStepToReadFrom.DialogMessage"));
mb.setText(BaseMessages.getString(PKG, "StreamLookupDialog.PleaseSelectAStepToReadFrom.DialogTitle"));
mb.open();
return;
}
try {
RowMetaInterface r = transMeta.getPrevStepFields(stepname);
if (r != null && !r.isEmpty()) {
BaseStepDialog.getFieldsFromPrevious(r, wKey, 1, new int[] { 1, 2 }, new int[] {}, -1, -1, null);
} else {
String stepFrom = wStep.getText();
if (!Utils.isEmpty(stepFrom)) {
r = transMeta.getStepFields(stepFrom);
if (r != null) {
BaseStepDialog.getFieldsFromPrevious(r, wKey, 2, new int[] { 1, 2 }, new int[] {}, -1, -1, null);
} else {
MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
mb.setMessage(BaseMessages.getString(PKG, "StreamLookupDialog.CouldNotFindFields.DialogMessage"));
mb.setText(BaseMessages.getString(PKG, "StreamLookupDialog.CouldNotFindFields.DialogTitle"));
mb.open();
}
} else {
MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
mb.setMessage(BaseMessages.getString(PKG, "StreamLookupDialog.StepNameRequired.DialogMessage"));
mb.setText(BaseMessages.getString(PKG, "StreamLookupDialog.StepNameRequired.DialogTitle"));
mb.open();
}
}
} catch (KettleException ke) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "StreamLookupDialog.FailedToGetFields.DialogTitle"), BaseMessages.getString(PKG, "StreamLookupDialog.FailedToGetFields.DialogMessage"), ke);
}
}
use of org.pentaho.di.core.row.RowMetaInterface 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);
}
use of org.pentaho.di.core.row.RowMetaInterface in project pentaho-kettle by pentaho.
the class StringCutDialog 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();
}
};
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, "StringCutDialog.Shell.Title"));
int middle = props.getMiddlePct();
int margin = Const.MARGIN;
// Stepname line
wlStepname = new Label(shell, SWT.RIGHT);
wlStepname.setText(BaseMessages.getString(PKG, "StringCutDialog.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);
wlKey = new Label(shell, SWT.NONE);
wlKey.setText(BaseMessages.getString(PKG, "StringCutDialog.Fields.Label"));
props.setLook(wlKey);
fdlKey = new FormData();
fdlKey.left = new FormAttachment(0, 0);
fdlKey.top = new FormAttachment(wStepname, 2 * margin);
wlKey.setLayoutData(fdlKey);
int nrFieldCols = 4;
int nrFieldRows = (input.getFieldInStream() != null ? input.getFieldInStream().length : 1);
ciKey = new ColumnInfo[nrFieldCols];
ciKey[0] = new ColumnInfo(BaseMessages.getString(PKG, "StringCutDialog.ColumnInfo.InStreamField"), ColumnInfo.COLUMN_TYPE_CCOMBO, new String[] { "" }, false);
ciKey[1] = new ColumnInfo(BaseMessages.getString(PKG, "StringCutDialog.ColumnInfo.OutStreamField"), ColumnInfo.COLUMN_TYPE_TEXT, false);
ciKey[2] = new ColumnInfo(BaseMessages.getString(PKG, "StringCutDialog.ColumnInfo.CutFrom"), ColumnInfo.COLUMN_TYPE_TEXT, false);
ciKey[3] = new ColumnInfo(BaseMessages.getString(PKG, "StringCutDialog.ColumnInfo.CutTo"), ColumnInfo.COLUMN_TYPE_TEXT, false);
ciKey[2].setUsingVariables(true);
ciKey[1].setToolTip(BaseMessages.getString(PKG, "StringCutDialog.ColumnInfo.OutStreamField.Tooltip"));
ciKey[3].setUsingVariables(true);
wFields = new TableView(transMeta, shell, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL, ciKey, nrFieldRows, lsMod, props);
fdKey = new FormData();
fdKey.left = new FormAttachment(0, 0);
fdKey.top = new FormAttachment(wlKey, margin);
fdKey.right = new FormAttachment(100, -margin);
fdKey.bottom = new FormAttachment(100, -30);
wFields.setLayoutData(fdKey);
//
// 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(), new Integer(i));
}
setComboBoxes();
} catch (KettleException e) {
logError("It was not possible to get the fields from the previous step(s).");
}
}
}
};
new Thread(runnable).start();
// THE BUTTONS
wOK = new Button(shell, SWT.PUSH);
wOK.setText(BaseMessages.getString(PKG, "System.Button.OK"));
wCancel = new Button(shell, SWT.PUSH);
wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel"));
wGet = new Button(shell, SWT.PUSH);
wGet.setText(BaseMessages.getString(PKG, "StringCutDialog.GetFields.Button"));
fdGet = new FormData();
fdGet.right = new FormAttachment(100, 0);
fdGet.top = new FormAttachment(wStepname, 3 * middle);
wGet.setLayoutData(fdGet);
setButtonPositions(new Button[] { wOK, wGet, wCancel }, margin, null);
// Add listeners
lsOK = new Listener() {
public void handleEvent(Event e) {
ok();
}
};
lsGet = new Listener() {
public void handleEvent(Event e) {
get();
}
};
lsCancel = new Listener() {
public void handleEvent(Event e) {
cancel();
}
};
wOK.addListener(SWT.Selection, lsOK);
wGet.addListener(SWT.Selection, lsGet);
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();
input.setChanged(changed);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
return stepname;
}
use of org.pentaho.di.core.row.RowMetaInterface in project pentaho-kettle by pentaho.
the class StringCutDialog method get.
private void get() {
try {
RowMetaInterface r = transMeta.getPrevStepFields(stepname);
if (r != null) {
TableItemInsertListener listener = new TableItemInsertListener() {
public boolean tableItemInserted(TableItem tableItem, ValueMetaInterface v) {
if (v.getType() == ValueMetaInterface.TYPE_STRING) {
// Only process strings
return true;
} else {
return false;
}
}
};
BaseStepDialog.getFieldsFromPrevious(r, wFields, 1, new int[] { 1 }, new int[] {}, -1, -1, listener);
}
} catch (KettleException ke) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "StringCutDialog.FailedToGetFields.DialogTitle"), BaseMessages.getString(PKG, "StringCutDialog.FailedToGetFields.DialogMessage"), ke);
}
}
use of org.pentaho.di.core.row.RowMetaInterface in project pentaho-kettle by pentaho.
the class StringOperationsDialog method get.
private void get() {
try {
RowMetaInterface r = transMeta.getPrevStepFields(stepname);
if (r != null) {
TableItemInsertListener listener = new TableItemInsertListener() {
public boolean tableItemInserted(TableItem tableItem, ValueMetaInterface v) {
if (v.getType() == ValueMetaInterface.TYPE_STRING) {
// Only process strings
tableItem.setText(3, BaseMessages.getString(PKG, "StringOperationsMeta.TrimType.None"));
tableItem.setText(4, BaseMessages.getString(PKG, "StringOperationsMeta.LowerUpper.None"));
tableItem.setText(5, BaseMessages.getString(PKG, "StringOperationsMeta.Padding.None"));
tableItem.setText(8, BaseMessages.getString(PKG, "System.Combo.No"));
tableItem.setText(9, BaseMessages.getString(PKG, "StringOperationsMeta.MaskXML.None"));
tableItem.setText(10, BaseMessages.getString(PKG, "StringOperationsMeta.Digits.None"));
tableItem.setText(11, BaseMessages.getString(PKG, "StringOperationsMeta.RemoveSpecialCharacters.None"));
return true;
} else {
return false;
}
}
};
BaseStepDialog.getFieldsFromPrevious(r, wFields, 1, new int[] { 1 }, new int[] {}, -1, -1, listener);
}
} catch (KettleException ke) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "StringOperationsDialog.FailedToGetFields.DialogTitle"), BaseMessages.getString(PKG, "StringOperationsDialog.FailedToGetFields.DialogMessage"), ke);
}
}
Aggregations