use of org.pentaho.di.core.exception.KettleException in project pentaho-kettle by pentaho.
the class TextFileInputDialog method first.
// Get the first x lines
private void first(boolean skipHeaders) {
TextFileInputMeta info = new TextFileInputMeta();
getInfo(info);
try {
if (info.getTextFileList(transMeta).nrOfFiles() > 0) {
String shellText = BaseMessages.getString(PKG, "TextFileInputDialog.LinesToView.DialogTitle");
String lineText = BaseMessages.getString(PKG, "TextFileInputDialog.LinesToView.DialogMessage");
EnterNumberDialog end = new EnterNumberDialog(shell, 100, shellText, lineText);
int nrLines = end.open();
if (nrLines >= 0) {
List<String> linesList = getFirst(nrLines, skipHeaders);
if (linesList != null && linesList.size() > 0) {
String firstlines = "";
for (String aLinesList : linesList) {
firstlines += aLinesList + Const.CR;
}
EnterTextDialog etd = new EnterTextDialog(shell, BaseMessages.getString(PKG, "TextFileInputDialog.ContentOfFirstFile.DialogTitle"), (nrLines == 0 ? BaseMessages.getString(PKG, "TextFileInputDialog.ContentOfFirstFile.AllLines.DialogMessage") : BaseMessages.getString(PKG, "TextFileInputDialog.ContentOfFirstFile.NLines.DialogMessage", "" + nrLines)), firstlines, true);
etd.setReadOnly();
etd.open();
} else {
MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
mb.setMessage(BaseMessages.getString(PKG, "TextFileInputDialog.UnableToReadLines.DialogMessage"));
mb.setText(BaseMessages.getString(PKG, "TextFileInputDialog.UnableToReadLines.DialogTitle"));
mb.open();
}
}
} else {
MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
mb.setMessage(BaseMessages.getString(PKG, "TextFileInputDialog.NoValidFile.DialogMessage"));
mb.setText(BaseMessages.getString(PKG, "System.Dialog.Error.Title"));
mb.open();
}
} catch (KettleException e) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "System.Dialog.Error.Title"), BaseMessages.getString(PKG, "TextFileInputDialog.ErrorGettingData.DialogMessage"), e);
}
}
use of org.pentaho.di.core.exception.KettleException in project pentaho-kettle by pentaho.
the class TextFileOutputDialog method getFields.
private void getFields() {
if (!gotPreviousFields) {
try {
String field = wFileNameField.getText();
RowMetaInterface r = transMeta.getPrevStepFields(stepname);
if (r != null) {
wFileNameField.setItems(r.getFieldNames());
}
if (field != null) {
wFileNameField.setText(field);
}
} catch (KettleException ke) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "TextFileOutputDialog.FailedToGetFields.DialogTitle"), BaseMessages.getString(PKG, "TextFileOutputDialog.FailedToGetFields.DialogMessage"), ke);
}
gotPreviousFields = true;
}
}
use of org.pentaho.di.core.exception.KettleException in project pentaho-kettle by pentaho.
the class TextFileOutputDialog 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.isNumeric()) {
// currency symbol
tableItem.setText(6, Const.NVL(v.getCurrencySymbol(), ""));
// decimal and grouping
tableItem.setText(7, Const.NVL(v.getDecimalSymbol(), ""));
tableItem.setText(8, Const.NVL(v.getGroupingSymbol(), ""));
}
// trim type
tableItem.setText(9, Const.NVL(ValueMetaString.getTrimTypeDesc(v.getTrimType()), ""));
// conversion mask
if (!Utils.isEmpty(v.getConversionMask())) {
tableItem.setText(3, v.getConversionMask());
} else {
if (v.isNumber()) {
if (v.getLength() > 0) {
int le = v.getLength();
int pr = v.getPrecision();
if (v.getPrecision() <= 0) {
pr = 0;
}
String mask = "";
for (int m = 0; m < le - pr; m++) {
mask += "0";
}
if (pr > 0) {
mask += ".";
}
for (int m = 0; m < pr; m++) {
mask += "0";
}
tableItem.setText(3, mask);
}
}
}
return true;
}
};
BaseStepDialog.getFieldsFromPrevious(r, wFields, 1, new int[] { 1 }, new int[] { 2 }, 4, 5, listener);
}
} catch (KettleException ke) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "System.Dialog.GetFieldsFailed.Title"), BaseMessages.getString(PKG, "System.Dialog.GetFieldsFailed.Message"), ke);
}
}
use of org.pentaho.di.core.exception.KettleException in project pentaho-kettle by pentaho.
the class TransExecutorDialog method selectFileTrans.
private void selectFileTrans() {
String curFile = transMeta.environmentSubstitute(wPath.getText());
FileObject root = null;
String parentFolder = null;
try {
parentFolder = KettleVFS.getFileObject(transMeta.environmentSubstitute(transMeta.getFilename())).getParent().toString();
} catch (Exception e) {
// Take no action
}
try {
root = KettleVFS.getFileObject(curFile != null ? curFile : Const.getUserHomeDirectory());
VfsFileChooserDialog vfsFileChooser = Spoon.getInstance().getVfsFileChooserDialog(root.getParent(), root);
FileObject file = vfsFileChooser.open(shell, null, Const.STRING_TRANS_FILTER_EXT, Const.getTransformationFilterNames(), VfsFileChooserDialog.VFS_DIALOG_OPEN_FILE);
if (file == null) {
return;
}
String fileName = file.getName().toString();
if (fileName != null) {
loadFileTrans(fileName);
if (parentFolder != null && fileName.startsWith(parentFolder)) {
fileName = fileName.replace(parentFolder, "${" + Const.INTERNAL_VARIABLE_ENTRY_CURRENT_DIRECTORY + "}");
}
wPath.setText(fileName);
specificationMethod = ObjectLocationSpecificationMethod.FILENAME;
}
} catch (IOException | KettleException e) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "TransExecutorDialog.ErrorLoadingTransformation.DialogTitle"), BaseMessages.getString(PKG, "TransExecutorDialog.ErrorLoadingTransformation.DialogMessage"), e);
}
}
use of org.pentaho.di.core.exception.KettleException in project pentaho-kettle by pentaho.
the class TransExecutorDialog method getByReferenceData.
private void getByReferenceData(ObjectId transObjectId) {
try {
RepositoryObject transInf = repository.getObjectInformation(transObjectId, RepositoryObjectType.TRANSFORMATION);
String path = DialogUtils.getPath(transMeta.getRepositoryDirectory().getPath(), transInf.getRepositoryDirectory().getPath());
String fullPath = Const.NVL(path, "") + "/" + Const.NVL(transInf.getName(), "");
wPath.setText(fullPath);
} catch (KettleException e) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "JobEntryTransDialog.Exception.UnableToReferenceObjectId.Title"), BaseMessages.getString(PKG, "JobEntryTransDialog.Exception.UnableToReferenceObjectId.Message"), e);
}
}
Aggregations