use of org.pentaho.di.ui.core.dialog.ErrorDialog in project pentaho-kettle by pentaho.
the class DenormaliserDialog method getAgg.
private void getAgg() {
// The grouping fields: ignore those.
wGroup.removeEmptyRows();
final String[] groupingFields = wGroup.getItems(0);
try {
RowMetaInterface r = transMeta.getPrevStepFields(stepname);
if (r != null && !r.isEmpty()) {
BaseStepDialog.getFieldsFromPrevious(r, wTarget, 2, new int[] {}, new int[] {}, -1, -1, new TableItemInsertListener() {
@Override
public boolean tableItemInserted(TableItem tableItem, ValueMetaInterface v) {
if (Const.indexOfString(v.getName(), groupingFields) < 0) {
// Not a grouping field
if (!wKeyField.getText().equalsIgnoreCase(v.getName())) {
// Not the key field
int nr = tableItem.getParent().indexOf(tableItem) + 1;
tableItem.setText(1, BaseMessages.getString(PKG, "DenormaliserDialog.TargetFieldname.Label") + // the target fieldname
nr);
tableItem.setText(2, v.getName());
tableItem.setText(4, v.getTypeDesc());
if (v.getLength() >= 0) {
tableItem.setText(6, "" + v.getLength());
}
if (v.getPrecision() >= 0) {
tableItem.setText(7, "" + v.getPrecision());
}
}
}
return true;
}
});
}
} catch (KettleException ke) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "DenormaliserDialog.FailedToGetFields.DialogTitle"), BaseMessages.getString(PKG, "DenormaliserDialog.FailedToGetFields.DialogMessage"), ke);
}
}
use of org.pentaho.di.ui.core.dialog.ErrorDialog in project pentaho-kettle by pentaho.
the class ExcelInputDialog method getFields.
/**
* Get the list of fields in the Excel workbook and put the result in the fields table view.
*/
public void getFields() {
RowMetaInterface fields = new RowMeta();
ExcelInputMeta info = new ExcelInputMeta();
getInfo(info);
int clearFields = SWT.YES;
if (wFields.nrNonEmpty() > 0) {
MessageBox messageBox = new MessageBox(shell, SWT.YES | SWT.NO | SWT.CANCEL | SWT.ICON_QUESTION);
messageBox.setMessage(BaseMessages.getString(PKG, "ExcelInputDialog.ClearFieldList.DialogMessage"));
messageBox.setText(BaseMessages.getString(PKG, "ExcelInputDialog.ClearFieldList.DialogTitle"));
clearFields = messageBox.open();
if (clearFields == SWT.CANCEL) {
return;
}
}
FileInputList fileList = info.getFileList(transMeta);
for (FileObject file : fileList.getFiles()) {
try {
KWorkbook workbook = WorkbookFactory.getWorkbook(info.getSpreadSheetType(), KettleVFS.getFilename(file), info.getEncoding(), wPassword.getText());
processingWorkbook(fields, info, workbook);
workbook.close();
} catch (Exception e) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "System.Dialog.Error.Title"), BaseMessages.getString(PKG, "ExcelInputDialog.ErrorReadingFile2.DialogMessage", KettleVFS.getFilename(file), e.toString()), e);
}
}
if (fields.size() > 0) {
if (clearFields == SWT.YES) {
wFields.clearAll(false);
}
for (int j = 0; j < fields.size(); j++) {
ValueMetaInterface field = fields.getValueMeta(j);
wFields.add(new String[] { field.getName(), field.getTypeDesc(), "", "", "none", "N" });
}
wFields.removeEmptyRows();
wFields.setRowNums();
wFields.optWidth(true);
} else {
MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_WARNING);
mb.setMessage(BaseMessages.getString(PKG, "ExcelInputDialog.UnableToFindFields.DialogMessage"));
mb.setText(BaseMessages.getString(PKG, "ExcelInputDialog.UnableToFindFields.DialogTitle"));
mb.open();
}
checkAlerts();
}
use of org.pentaho.di.ui.core.dialog.ErrorDialog in project pentaho-kettle by pentaho.
the class FieldSplitterDialog method getFields.
private void getFields() {
if (!gotPreviousFields) {
try {
String field = wSplitfield.getText();
RowMetaInterface r = transMeta.getPrevStepFields(stepname);
if (r != null) {
wSplitfield.setItems(r.getFieldNames());
}
if (field != null) {
wSplitfield.setText(field);
}
} catch (KettleException ke) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "FieldSplitterDialog.FailedToGetFields.DialogTitle"), BaseMessages.getString(PKG, "FieldSplitterDialog.FailedToGetFields.DialogMessage"), ke);
}
gotPreviousFields = true;
}
}
use of org.pentaho.di.ui.core.dialog.ErrorDialog in project pentaho-kettle by pentaho.
the class DimensionLookupDialog method getFields.
private void getFields() {
if (!gotPreviousFields) {
try {
String field = wDatefield.getText();
RowMetaInterface r = transMeta.getPrevStepFields(stepname);
if (r != null) {
wDatefield.setItems(r.getFieldNames());
}
if (field != null) {
wDatefield.setText(field);
}
} catch (KettleException ke) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "DimensionLookupDialog.ErrorGettingFields.Title"), BaseMessages.getString(PKG, "DimensionLookupDialog.ErrorGettingFields.Message"), ke);
}
gotPreviousFields = true;
}
}
use of org.pentaho.di.ui.core.dialog.ErrorDialog 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;
}
Aggregations