use of org.pentaho.di.ui.core.dialog.ErrorDialog in project pentaho-kettle by pentaho.
the class AccessInputDialog method preview.
// Preview the data
private void preview() {
try {
// Create the Access input step
AccessInputMeta oneMeta = new AccessInputMeta();
getInfo(oneMeta);
// check if the path is given
if (!checkInputTableName(oneMeta)) {
return;
}
TransMeta previewMeta = TransPreviewFactory.generatePreviewTransformation(transMeta, oneMeta, wStepname.getText());
EnterNumberDialog numberDialog = new EnterNumberDialog(shell, props.getDefaultPreviewSize(), BaseMessages.getString(PKG, "AccessInputDialog.NumberRows.DialogTitle"), BaseMessages.getString(PKG, "AccessInputDialog.NumberRows.DialogMessage"));
int previewSize = numberDialog.open();
if (previewSize > 0) {
TransPreviewProgressDialog progressDialog = new TransPreviewProgressDialog(shell, previewMeta, new String[] { wStepname.getText() }, new int[] { previewSize });
progressDialog.open();
if (!progressDialog.isCancelled()) {
Trans trans = progressDialog.getTrans();
String loggingText = progressDialog.getLoggingText();
if (trans.getResult() != null && trans.getResult().getNrErrors() > 0) {
EnterTextDialog etd = new EnterTextDialog(shell, BaseMessages.getString(PKG, "System.Dialog.PreviewError.Title"), BaseMessages.getString(PKG, "System.Dialog.PreviewError.Message"), loggingText, true);
etd.setReadOnly();
etd.open();
}
PreviewRowsDialog prd = new PreviewRowsDialog(shell, transMeta, SWT.NONE, wStepname.getText(), progressDialog.getPreviewRowsMeta(wStepname.getText()), progressDialog.getPreviewRows(wStepname.getText()), loggingText);
prd.open();
}
}
} catch (KettleException e) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "AccessInputDialog.ErrorPreviewingData.DialogTitle"), BaseMessages.getString(PKG, "AccessInputDialog.ErrorPreviewingData.DialogMessage"), e);
}
}
use of org.pentaho.di.ui.core.dialog.ErrorDialog in project pentaho-kettle by pentaho.
the class MetaInjectDialog method ok.
private void ok() {
if (Utils.isEmpty(wStepname.getText())) {
return;
}
// return value
stepname = wStepname.getText();
try {
loadTransformation();
} catch (KettleException e) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "MetaInjectDialog.ErrorLoadingSpecifiedTransformation.Title"), BaseMessages.getString(PKG, "MetaInjectDialog.ErrorLoadingSpecifiedTransformation.Message"), e);
}
if (repository != null) {
specificationMethod = ObjectLocationSpecificationMethod.REPOSITORY_BY_NAME;
} else {
specificationMethod = ObjectLocationSpecificationMethod.FILENAME;
}
metaInjectMeta.setSpecificationMethod(specificationMethod);
switch(specificationMethod) {
case FILENAME:
metaInjectMeta.setFileName(wPath.getText());
metaInjectMeta.setDirectoryPath(null);
metaInjectMeta.setTransName(null);
metaInjectMeta.setTransObjectId(null);
break;
case REPOSITORY_BY_NAME:
String transPath = wPath.getText();
String transName = transPath;
String directory = "";
int index = transPath.lastIndexOf("/");
if (index != -1) {
transName = transPath.substring(index + 1);
directory = transPath.substring(0, index);
}
metaInjectMeta.setDirectoryPath(directory);
metaInjectMeta.setTransName(transName);
metaInjectMeta.setFileName(null);
metaInjectMeta.setTransObjectId(null);
break;
default:
break;
}
metaInjectMeta.setSourceStepName(wSourceStep.getText());
metaInjectMeta.setSourceOutputFields(new ArrayList<MetaInjectOutputField>());
for (int i = 0; i < wSourceFields.nrNonEmpty(); i++) {
TableItem item = wSourceFields.getNonEmpty(i);
int colIndex = 1;
String name = item.getText(colIndex++);
int type = ValueMetaFactory.getIdForValueMeta(item.getText(colIndex++));
int length = Const.toInt(item.getText(colIndex++), -1);
int precision = Const.toInt(item.getText(colIndex++), -1);
metaInjectMeta.getSourceOutputFields().add(new MetaInjectOutputField(name, type, length, precision));
}
metaInjectMeta.setTargetFile(wTargetFile.getText());
metaInjectMeta.setNoExecution(!wNoExecution.getSelection());
final StepMeta streamSourceStep = transMeta.findStep(wStreamingSourceStep.getText());
metaInjectMeta.setStreamSourceStep(streamSourceStep);
// PDI-15989 Save streamSourceStepname to find streamSourceStep when loading
metaInjectMeta.setStreamSourceStepname(streamSourceStep != null ? streamSourceStep.getName() : "");
metaInjectMeta.setStreamTargetStepname(wStreamingTargetStep.getText());
metaInjectMeta.setTargetSourceMapping(targetSourceMapping);
metaInjectMeta.setChanged(true);
dispose();
}
use of org.pentaho.di.ui.core.dialog.ErrorDialog in project pentaho-kettle by pentaho.
the class MetaInjectDialog method selectFileTrans.
private void selectFileTrans(boolean useVfs) {
String curFile = transMeta.environmentSubstitute(wPath.getText());
if (useVfs) {
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, "SingleThreaderDialog.ErrorLoadingTransformation.DialogTitle"), BaseMessages.getString(PKG, "SingleThreaderDialog.ErrorLoadingTransformation.DialogMessage"), e);
}
}
}
use of org.pentaho.di.ui.core.dialog.ErrorDialog in project pentaho-kettle by pentaho.
the class JobEntryColumnsExistDialog method getSchemaNames.
private void getSchemaNames() {
if (wSchemaname.isDisposed()) {
return;
}
DatabaseMeta databaseMeta = jobMeta.findDatabase(wConnection.getText());
if (databaseMeta != null) {
Database database = new Database(loggingObject, databaseMeta);
database.shareVariablesWith(jobMeta);
try {
database.connect();
String[] schemas = database.getSchemas();
if (null != schemas && schemas.length > 0) {
schemas = Const.sortStrings(schemas);
EnterSelectionDialog dialog = new EnterSelectionDialog(shell, schemas, BaseMessages.getString(PKG, "System.Dialog.AvailableSchemas.Title", wConnection.getText()), BaseMessages.getString(PKG, "System.Dialog.AvailableSchemas.Message"));
String d = dialog.open();
if (d != null) {
wSchemaname.setText(Const.NVL(d.toString(), ""));
}
} else {
MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
mb.setMessage(BaseMessages.getString(PKG, "System.Dialog.AvailableSchemas.Empty.Message"));
mb.setText(BaseMessages.getString(PKG, "System.Dialog.AvailableSchemas.Empty.Title"));
mb.open();
}
} catch (Exception e) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "System.Dialog.Error.Title"), BaseMessages.getString(PKG, "System.Dialog.AvailableSchemas.ConnectionError"), e);
} finally {
if (database != null) {
database.disconnect();
database = null;
}
}
}
}
use of org.pentaho.di.ui.core.dialog.ErrorDialog in project pentaho-kettle by pentaho.
the class MailInputDialog method preview.
// Preview the data
private void preview() {
try {
MailInputMeta oneMeta = new MailInputMeta();
getInfo(oneMeta);
TransMeta previewMeta = TransPreviewFactory.generatePreviewTransformation(transMeta, oneMeta, wStepname.getText());
EnterNumberDialog numberDialog = new EnterNumberDialog(shell, props.getDefaultPreviewSize(), BaseMessages.getString(PKG, "MailInputDialog.NumberRows.DialogTitle"), BaseMessages.getString(PKG, "MailInputDialog.NumberRows.DialogMessage"));
int previewSize = numberDialog.open();
if (previewSize > 0) {
TransPreviewProgressDialog progressDialog = new TransPreviewProgressDialog(shell, previewMeta, new String[] { wStepname.getText() }, new int[] { previewSize });
progressDialog.open();
if (!progressDialog.isCancelled()) {
Trans trans = progressDialog.getTrans();
String loggingText = progressDialog.getLoggingText();
if (trans.getResult() != null && trans.getResult().getNrErrors() > 0) {
EnterTextDialog etd = new EnterTextDialog(shell, BaseMessages.getString(PKG, "System.Dialog.PreviewError.Title"), BaseMessages.getString(PKG, "System.Dialog.PreviewError.Message"), loggingText, true);
etd.setReadOnly();
etd.open();
}
PreviewRowsDialog prd = new PreviewRowsDialog(shell, transMeta, SWT.NONE, wStepname.getText(), progressDialog.getPreviewRowsMeta(wStepname.getText()), progressDialog.getPreviewRows(wStepname.getText()), loggingText);
prd.open();
}
}
} catch (KettleException e) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "MailInputDialog.ErrorPreviewingData.DialogTitle"), BaseMessages.getString(PKG, "MailInputDialog.ErrorPreviewingData.DialogMessage"), e);
}
}
Aggregations