use of org.pentaho.di.core.row.RowMetaInterface in project pentaho-kettle by pentaho.
the class JoinRowsDialog 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();
backupCondition = (Condition) condition.clone();
FormLayout formLayout = new FormLayout();
formLayout.marginWidth = Const.FORM_MARGIN;
formLayout.marginHeight = Const.FORM_MARGIN;
shell.setLayout(formLayout);
shell.setText(BaseMessages.getString(PKG, "JoinRowsDialog.Shell.Title"));
int middle = props.getMiddlePct();
int margin = Const.MARGIN;
// Stepname line
wlStepname = new Label(shell, SWT.RIGHT);
wlStepname.setText(BaseMessages.getString(PKG, "JoinRowsDialog.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);
// Connection line
wlSortDir = new Label(shell, SWT.RIGHT);
wlSortDir.setText(BaseMessages.getString(PKG, "JoinRowsDialog.TempDir.Label"));
props.setLook(wlSortDir);
fdlSortDir = new FormData();
fdlSortDir.left = new FormAttachment(0, 0);
fdlSortDir.right = new FormAttachment(middle, -margin);
fdlSortDir.top = new FormAttachment(wStepname, margin);
wlSortDir.setLayoutData(fdlSortDir);
wbSortDir = new Button(shell, SWT.PUSH | SWT.CENTER);
props.setLook(wbSortDir);
wbSortDir.setText(BaseMessages.getString(PKG, "JoinRowsDialog.Browse.Button"));
fdbSortDir = new FormData();
fdbSortDir.right = new FormAttachment(100, 0);
fdbSortDir.top = new FormAttachment(wStepname, margin);
wbSortDir.setLayoutData(fdbSortDir);
wSortDir = new TextVar(transMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
wSortDir.setText(BaseMessages.getString(PKG, "JoinRowsDialog.Temp.Label"));
props.setLook(wSortDir);
wSortDir.addModifyListener(lsMod);
fdSortDir = new FormData();
fdSortDir.left = new FormAttachment(middle, 0);
fdSortDir.top = new FormAttachment(wStepname, margin);
fdSortDir.right = new FormAttachment(wbSortDir, -margin);
wSortDir.setLayoutData(fdSortDir);
wbSortDir.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent arg0) {
DirectoryDialog dd = new DirectoryDialog(shell, SWT.NONE);
dd.setFilterPath(wSortDir.getText());
String dir = dd.open();
if (dir != null) {
wSortDir.setText(dir);
}
}
});
// Whenever something changes, set the tooltip to the expanded version:
wSortDir.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
wSortDir.setToolTipText(transMeta.environmentSubstitute(wSortDir.getText()));
}
});
// Table line...
wlPrefix = new Label(shell, SWT.RIGHT);
wlPrefix.setText(BaseMessages.getString(PKG, "JoinRowsDialog.TempFilePrefix.Label"));
props.setLook(wlPrefix);
fdlPrefix = new FormData();
fdlPrefix.left = new FormAttachment(0, 0);
fdlPrefix.right = new FormAttachment(middle, -margin);
fdlPrefix.top = new FormAttachment(wbSortDir, margin * 2);
wlPrefix.setLayoutData(fdlPrefix);
wPrefix = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wPrefix);
wPrefix.addModifyListener(lsMod);
fdPrefix = new FormData();
fdPrefix.left = new FormAttachment(middle, 0);
fdPrefix.top = new FormAttachment(wbSortDir, margin * 2);
fdPrefix.right = new FormAttachment(100, 0);
wPrefix.setLayoutData(fdPrefix);
wPrefix.setText(BaseMessages.getString(PKG, "JoinRowsDialog.Prefix.Label"));
// Cache size...
wlCache = new Label(shell, SWT.RIGHT);
wlCache.setText(BaseMessages.getString(PKG, "JoinRowsDialog.Cache.Label"));
props.setLook(wlCache);
fdlCache = new FormData();
fdlCache.left = new FormAttachment(0, 0);
fdlCache.right = new FormAttachment(middle, -margin);
fdlCache.top = new FormAttachment(wPrefix, margin * 2);
wlCache.setLayoutData(fdlCache);
wCache = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wCache);
wCache.addModifyListener(lsMod);
fdCache = new FormData();
fdCache.left = new FormAttachment(middle, 0);
fdCache.top = new FormAttachment(wPrefix, margin * 2);
fdCache.right = new FormAttachment(100, 0);
wCache.setLayoutData(fdCache);
// Read date from...
wlMainStep = new Label(shell, SWT.RIGHT);
wlMainStep.setText(BaseMessages.getString(PKG, "JoinRowsDialog.MainStep.Label"));
props.setLook(wlMainStep);
fdlMainStep = new FormData();
fdlMainStep.left = new FormAttachment(0, 0);
fdlMainStep.right = new FormAttachment(middle, -margin);
fdlMainStep.top = new FormAttachment(wCache, margin);
wlMainStep.setLayoutData(fdlMainStep);
wMainStep = new CCombo(shell, SWT.BORDER);
props.setLook(wMainStep);
List<StepMeta> prevSteps = transMeta.findPreviousSteps(transMeta.findStep(stepname));
for (StepMeta stepMeta : prevSteps) {
wMainStep.add(stepMeta.getName());
}
wMainStep.addModifyListener(lsMod);
fdMainStep = new FormData();
fdMainStep.left = new FormAttachment(middle, 0);
fdMainStep.top = new FormAttachment(wCache, margin);
fdMainStep.right = new FormAttachment(100, 0);
wMainStep.setLayoutData(fdMainStep);
// Condition widget...
wlCondition = new Label(shell, SWT.NONE);
wlCondition.setText(BaseMessages.getString(PKG, "JoinRowsDialog.Condition.Label"));
props.setLook(wlCondition);
fdlCondition = new FormData();
fdlCondition.left = new FormAttachment(0, 0);
fdlCondition.top = new FormAttachment(wMainStep, margin);
wlCondition.setLayoutData(fdlCondition);
RowMetaInterface inputfields = null;
try {
inputfields = transMeta.getPrevStepFields(stepname);
} catch (KettleException ke) {
inputfields = new RowMeta();
new ErrorDialog(shell, BaseMessages.getString(PKG, "JoinRowsDialog.FailedToGetFields.DialogTitle"), BaseMessages.getString(PKG, "JoinRowsDialog.FailedToGetFields.DialogMessage"), ke);
}
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"));
setButtonPositions(new Button[] { wOK, wCancel }, margin, null);
wCondition = new ConditionEditor(shell, SWT.BORDER, condition, inputfields);
fdCondition = new FormData();
fdCondition.left = new FormAttachment(0, 0);
fdCondition.top = new FormAttachment(wlCondition, margin);
fdCondition.right = new FormAttachment(100, 0);
fdCondition.bottom = new FormAttachment(wOK, -2 * margin);
wCondition.setLayoutData(fdCondition);
wCondition.addModifyListener(lsMod);
// Add listeners
lsOK = new Listener() {
public void handleEvent(Event e) {
ok();
}
};
lsCancel = new Listener() {
public void handleEvent(Event e) {
cancel();
}
};
wOK.addListener(SWT.Selection, lsOK);
wCancel.addListener(SWT.Selection, lsCancel);
lsDef = new SelectionAdapter() {
public void widgetDefaultSelected(SelectionEvent e) {
ok();
}
};
wStepname.addSelectionListener(lsDef);
wSortDir.addSelectionListener(lsDef);
wPrefix.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 LDAPOutputDialog method setFieldsCombo.
public void setFieldsCombo() {
Display display = shell.getDisplay();
if (!(display == null || display.isDisposed())) {
display.asyncExec(new Runnable() {
public void run() {
// clear
for (int i = 0; i < tableFieldColumns.size(); i++) {
ColumnInfo colInfo = tableFieldColumns.get(i);
colInfo.setComboValues(new String[] {});
}
if (wBaseDN.isDisposed()) {
return;
}
String baseDn = transMeta.environmentSubstitute(wBaseDN.getText());
if (!Utils.isEmpty(baseDn)) {
try {
RowMetaInterface fields = getLDAPFields();
// loop through the objects and find build the list of fields
String[] fieldsName = new String[fields.size()];
for (int i = 0; i < fields.size(); i++) {
fieldsName[i] = fields.getValueMeta(i).getName();
}
if (fieldsName != null) {
for (int i = 0; i < tableFieldColumns.size(); i++) {
ColumnInfo colInfo = tableFieldColumns.get(i);
colInfo.setComboValues(fieldsName);
}
}
} catch (Exception e) {
for (int i = 0; i < tableFieldColumns.size(); i++) {
ColumnInfo colInfo = tableFieldColumns.get(i);
colInfo.setComboValues(new String[] {});
}
// ignore any errors here. drop downs will not be
// filled, but no problem for the user
}
}
}
});
}
}
use of org.pentaho.di.core.row.RowMetaInterface in project pentaho-kettle by pentaho.
the class FilesToResultDialog method open.
public String open() {
Shell parent = getParent();
Display display = parent.getDisplay();
shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.MIN | SWT.MAX | SWT.RESIZE);
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, "FilesToResultDialog.Shell.Title"));
int middle = props.getMiddlePct();
int margin = Const.MARGIN;
// Stepname line
wlStepname = new Label(shell, SWT.RIGHT);
wlStepname.setText(BaseMessages.getString(PKG, "FilesToResultDialog.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);
// The rest...
// FilenameField line
wlFilenameField = new Label(shell, SWT.RIGHT);
wlFilenameField.setText(BaseMessages.getString(PKG, "FilesToResultDialog.FilenameField.Label"));
props.setLook(wlFilenameField);
fdlFilenameField = new FormData();
fdlFilenameField.left = new FormAttachment(0, 0);
fdlFilenameField.top = new FormAttachment(wStepname, margin);
fdlFilenameField.right = new FormAttachment(middle, -margin);
wlFilenameField.setLayoutData(fdlFilenameField);
wFilenameField = new CCombo(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
wFilenameField.setToolTipText(BaseMessages.getString(PKG, "FilesToResultDialog.FilenameField.Tooltip"));
props.setLook(wFilenameField);
wFilenameField.addModifyListener(lsMod);
fdFilenameField = new FormData();
fdFilenameField.left = new FormAttachment(middle, 0);
fdFilenameField.top = new FormAttachment(wStepname, margin);
fdFilenameField.right = new FormAttachment(100, 0);
wFilenameField.setLayoutData(fdFilenameField);
/*
* Get the field names from the previous steps, in the background though
*/
Runnable runnable = new Runnable() {
public void run() {
try {
RowMetaInterface inputfields = transMeta.getPrevStepFields(stepname);
if (inputfields != null) {
for (int i = 0; i < inputfields.size(); i++) {
wFilenameField.add(inputfields.getValueMeta(i).getName());
}
}
} catch (Exception ke) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "FilesToResultDialog.FailedToGetFields.DialogTitle"), BaseMessages.getString(PKG, "FilesToResultDialog.FailedToGetFields.DialogMessage"), ke);
}
}
};
display.asyncExec(runnable);
// Some 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"));
setButtonPositions(new Button[] { wOK, wCancel }, margin, null);
// Include Files?
wlTypes = new Label(shell, SWT.RIGHT);
wlTypes.setText(BaseMessages.getString(PKG, "FilesToResultDialog.TypeOfFile.Label"));
props.setLook(wlTypes);
fdlTypes = new FormData();
fdlTypes.left = new FormAttachment(0, 0);
fdlTypes.top = new FormAttachment(wFilenameField, margin);
fdlTypes.right = new FormAttachment(middle, -margin);
wlTypes.setLayoutData(fdlTypes);
wTypes = new List(shell, SWT.SINGLE | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
wTypes.setToolTipText(BaseMessages.getString(PKG, "FilesToResultDialog.TypeOfFile.Tooltip"));
props.setLook(wTypes);
fdTypes = new FormData();
fdTypes.left = new FormAttachment(middle, 0);
fdTypes.top = new FormAttachment(wFilenameField, margin);
fdTypes.bottom = new FormAttachment(wOK, -margin * 3);
fdTypes.right = new FormAttachment(100, 0);
wTypes.setLayoutData(fdTypes);
for (int i = 0; i < ResultFile.getAllTypeDesc().length; i++) {
wTypes.add(ResultFile.getAllTypeDesc()[i]);
}
// Add listeners
lsCancel = new Listener() {
public void handleEvent(Event e) {
cancel();
}
};
lsOK = new Listener() {
public void handleEvent(Event e) {
ok();
}
};
wCancel.addListener(SWT.Selection, lsCancel);
wOK.addListener(SWT.Selection, lsOK);
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 FormulaDialog method open.
@Override
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, currentMeta);
ModifyListener lsMod = new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
currentMeta.setChanged();
}
};
changed = currentMeta.hasChanged();
FormLayout formLayout = new FormLayout();
formLayout.marginWidth = Const.FORM_MARGIN;
formLayout.marginHeight = Const.FORM_MARGIN;
shell.setLayout(formLayout);
shell.setText(BaseMessages.getString(PKG, "FormulaDialog.DialogTitle"));
int middle = props.getMiddlePct();
int margin = Const.MARGIN;
// Stepname line
wlStepname = new Label(shell, SWT.RIGHT);
wlStepname.setText(BaseMessages.getString(PKG, "System.Label.StepName"));
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);
wlFields = new Label(shell, SWT.NONE);
wlFields.setText(BaseMessages.getString(PKG, "FormulaDialog.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 FieldsRows = currentMeta.getFormula() != null ? currentMeta.getFormula().length : 1;
colinf = new ColumnInfo[] { new ColumnInfo(BaseMessages.getString(PKG, "FormulaDialog.NewField.Column"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, "FormulaDialog.Formula.Column"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, "FormulaDialog.ValueType.Column"), ColumnInfo.COLUMN_TYPE_CCOMBO, ValueMetaFactory.getValueMetaNames()), new ColumnInfo(BaseMessages.getString(PKG, "FormulaDialog.Length.Column"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, "FormulaDialog.Precision.Column"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, "FormulaDialog.Replace.Column"), ColumnInfo.COLUMN_TYPE_CCOMBO, new String[] {}) };
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(100, -50);
wFields.setLayoutData(fdFields);
//
// Search the fields in the background
//
final Runnable runnable = new Runnable() {
@Override
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(BaseMessages.getString(PKG, "FormulaDialog.Log.UnableToFindInput"));
}
}
}
};
new Thread(runnable).start();
colinf[1].setSelectionAdapter(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if (fieldNames == null) {
return;
}
TableView tv = (TableView) e.widget;
TableItem item = tv.table.getItem(e.y);
String formula = item.getText(e.x);
try {
if (!shell.isDisposed()) {
LibFormulaEditor libFormulaEditor = new LibFormulaEditor(shell, SWT.APPLICATION_MODAL | SWT.SHEET, Const.NVL(formula, ""), fieldNames);
formula = libFormulaEditor.open();
if (formula != null && !tv.isDisposed()) {
tv.setText(formula, e.x, e.y);
}
}
} catch (Exception ex) {
new ErrorDialog(shell, "Error", "There was an unexpected error in the formula editor", ex);
}
}
});
wFields.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent arg0) {
// Now set the combo's
shell.getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
setComboBoxes();
}
});
}
});
// Some 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"));
setButtonPositions(new Button[] { wOK, wCancel }, margin, null);
// Add listeners
lsCancel = new Listener() {
@Override
public void handleEvent(Event e) {
cancel();
}
};
lsOK = new Listener() {
@Override
public void handleEvent(Event e) {
ok();
}
};
wCancel.addListener(SWT.Selection, lsCancel);
wOK.addListener(SWT.Selection, lsOK);
lsDef = new SelectionAdapter() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
ok();
}
};
wStepname.addSelectionListener(lsDef);
// Detect X or ALT-F4 or something that kills this window...
shell.addShellListener(new ShellAdapter() {
@Override
public void shellClosed(ShellEvent e) {
cancel();
}
});
// Set the shell size, based upon previous time...
setSize();
getData();
currentMeta.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 FuzzyMatchDialog method setMainStreamField.
private void setMainStreamField() {
if (!gotPreviousFields) {
String field = wMainStreamField.getText();
try {
wMainStreamField.removeAll();
RowMetaInterface r = transMeta.getPrevStepFields(stepname);
if (r != null) {
wMainStreamField.setItems(r.getFieldNames());
}
} catch (KettleException ke) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "FuzzyMatchDialog.FailedToGetFields.DialogTitle"), BaseMessages.getString(PKG, "FuzzyMatchDialog.FailedToGetFields.DialogMessage"), ke);
}
if (field != null) {
wMainStreamField.setText(field);
}
gotPreviousFields = true;
}
}
Aggregations