use of org.pentaho.di.ui.core.dialog.ErrorDialog in project pentaho-kettle by pentaho.
the class JsonInputDialog method setSourceStreamField.
private void setSourceStreamField() {
try {
String value = wFieldValue.getText();
wFieldValue.removeAll();
RowMetaInterface r = transMeta.getPrevStepFields(stepname);
if (r != null) {
wFieldValue.setItems(r.getFieldNames());
}
if (value != null) {
wFieldValue.setText(value);
}
} catch (KettleException ke) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "JsonInputDialog.FailedToGetFields.DialogTitle"), BaseMessages.getString(PKG, "JsonInputDialog.FailedToGetFields.DialogMessage"), ke);
}
}
use of org.pentaho.di.ui.core.dialog.ErrorDialog in project pentaho-kettle by pentaho.
the class JsonInputDialog 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);
lsMod = 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, "JsonInputDialog.DialogTitle"));
middle = props.getMiddlePct();
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.top = new FormAttachment(0, margin);
fdlStepname.right = new FormAttachment(middle, -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);
wTabFolder = new CTabFolder(shell, SWT.BORDER);
props.setLook(wTabFolder, Props.WIDGET_STYLE_TAB);
addFileTab();
addContentTab();
addFieldsTab();
addAdditionalFieldsTab();
FormData fdTabFolder = new FormData();
fdTabFolder.left = new FormAttachment(0, 0);
fdTabFolder.top = new FormAttachment(wStepname, margin);
fdTabFolder.right = new FormAttachment(100, 0);
fdTabFolder.bottom = new FormAttachment(100, -50);
wTabFolder.setLayoutData(fdTabFolder);
wOK = new Button(shell, SWT.PUSH);
wOK.setText(BaseMessages.getString(PKG, "System.Button.OK"));
wPreview = new Button(shell, SWT.PUSH);
wPreview.setText(BaseMessages.getString(PKG, "JsonInputDialog.Button.PreviewRows"));
wCancel = new Button(shell, SWT.PUSH);
wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel"));
setButtonPositions(new Button[] { wOK, wPreview, wCancel }, margin, wTabFolder);
// Add listeners
lsOK = e -> ok();
lsGet = e -> get();
lsPreview = e -> preview();
lsCancel = e -> cancel();
wOK.addListener(SWT.Selection, lsOK);
wGet.addListener(SWT.Selection, lsGet);
wPreview.addListener(SWT.Selection, lsPreview);
wCancel.addListener(SWT.Selection, lsCancel);
lsDef = new SelectionAdapter() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
ok();
}
};
wStepname.addSelectionListener(lsDef);
wLimit.addSelectionListener(lsDef);
wInclRownumField.addSelectionListener(lsDef);
wInclFilenameField.addSelectionListener(lsDef);
// Add the file to the list of files...
SelectionAdapter selA = new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent arg0) {
String[] items = new String[] { wFilename.getText(), wFilemask.getText(), wExcludeFilemask.getText(), JsonInputMeta.RequiredFilesCode[0], JsonInputMeta.RequiredFilesCode[0] };
wFilenameList.add(items);
wFilename.setText("");
wFilemask.setText("");
wExcludeFilemask.setText("");
wFilenameList.removeEmptyRows();
wFilenameList.setRowNums();
wFilenameList.optWidth(true);
}
};
wbaFilename.addSelectionListener(selA);
wFilename.addSelectionListener(selA);
// Delete files from the list of files...
wbdFilename.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent arg0) {
int[] idx = wFilenameList.getSelectionIndices();
wFilenameList.remove(idx);
wFilenameList.removeEmptyRows();
wFilenameList.setRowNums();
}
});
// Edit the selected file & remove from the list...
wbeFilename.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent arg0) {
int idx = wFilenameList.getSelectionIndex();
if (idx >= 0) {
String[] string = wFilenameList.getItem(idx);
wFilename.setText(string[0]);
wFilemask.setText(string[1]);
wExcludeFilemask.setText(string[2]);
wFilenameList.remove(idx);
}
wFilenameList.removeEmptyRows();
wFilenameList.setRowNums();
}
});
// Show the files that are selected at this time...
wbShowFiles.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
try {
JsonInputMeta tfii = new JsonInputMeta();
getInfo(tfii);
FileInputList fileInputList = tfii.getFiles(transMeta);
String[] files = fileInputList.getFileStrings();
if (files != null && files.length > 0) {
EnterSelectionDialog esd = new EnterSelectionDialog(shell, files, BaseMessages.getString(PKG, "JsonInputDialog.FilesReadSelection.DialogTitle"), BaseMessages.getString(PKG, "JsonInputDialog.FilesReadSelection.DialogMessage"));
esd.setViewOnly();
esd.open();
} else {
MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
mb.setMessage(BaseMessages.getString(PKG, "JsonInputDialog.NoFileFound.DialogMessage"));
mb.setText(BaseMessages.getString(PKG, "System.Dialog.Error.Title"));
mb.open();
}
} catch (KettleException ex) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "JsonInputDialog.ErrorParsingData.DialogTitle"), BaseMessages.getString(PKG, "JsonInputDialog.ErrorParsingData.DialogMessage"), ex);
}
}
});
// Enable/disable the right fields to allow a filename to be added to each row...
wInclFilename.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
setIncludeFilename();
}
});
// Enable/disable the right fields to allow a row number to be added to each row...
wInclRownum.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
setIncludeRownum();
}
});
// Whenever something changes, set the tooltip to the expanded version of the filename:
wFilename.addModifyListener(e -> wFilename.setToolTipText(wFilename.getText()));
// Listen to the Browse... button
wbbFilename.addSelectionListener(new SelectionAdapterFileDialogTextVar(log, wFilename, transMeta, new SelectionAdapterOptions(SelectionOperation.FILE_OR_FOLDER, new FilterType[] { FilterType.JSON, FilterType.JS, FilterType.ALL }, FilterType.JSON)));
// Detect X or ALT-F4 or something that kills this window...
shell.addShellListener(new ShellAdapter() {
@Override
public void shellClosed(ShellEvent e) {
cancel();
}
});
wTabFolder.setSelection(0);
// Set the shell size, based upon previous time...
setSize();
getData(input);
activeStreamField();
setIncludeFilename();
setIncludeRownum();
input.setChanged(changed);
wFields.optWidth(true);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
return stepname;
}
use of org.pentaho.di.ui.core.dialog.ErrorDialog in project pentaho-kettle by pentaho.
the class XulDatabaseDialog method createDialog.
@SuppressWarnings("deprecation")
private void createDialog() {
XulDomContainer container = null;
try {
databaseDialogInstance = new DatabaseConnectionDialog();
if (((Shell) this.parentShell).getText().contains("Metadata Editor")) {
databaseDialogInstance.registerClass(EXTENDED_WIDGET_ID, PMD_WIDGET_CLASSNAME);
databaseDialogInstance.registerClass(EXTENDED_MENULIST_WIDGET_ID, PMD_MENULIST_WIDGET_CLASSNAME);
} else {
databaseDialogInstance.registerClass(EXTENDED_WIDGET_ID, EXTENDED_WIDGET_CLASSNAME);
databaseDialogInstance.registerClass(EXTENDED_MENULIST_WIDGET_ID, EXTENDED_MENULIST_WIDGET_CLASSNAME);
}
/*
* Attention: onload: loadConnectionData() is called here the first time, see below for second time
*/
container = databaseDialogInstance.getSwtInstance(new KettleXulLoader(), parentShell);
container.addEventHandler(EVENT_ID, DataOverrideHandler.class.getName());
SpoonPluginManager.getInstance().applyPluginsForContainer("connection_dialog", container);
dataHandler = (DataOverrideHandler) container.getEventHandler(EVENT_ID);
if (databaseMeta != null) {
dataHandler.setData(databaseMeta);
}
dataHandler.setDatabases(databases);
dataHandler.getControls();
} catch (XulException e) {
new ErrorDialog(parentShell, BaseMessages.getString(PKG, "XulDatabaseDialog.Error.Title"), BaseMessages.getString(PKG, "XulDatabaseDialog.Error.HandleXul"), e);
return;
}
try {
// Inject the button panel that contains the "Feature List" and "Explore" buttons
XulComponent boxElement = container.getDocumentRoot().getElementById(FRAGMENT_ID);
XulComponent parentElement = boxElement.getParent();
ResourceBundle res = null;
try {
res = GlobalMessages.getBundle(MESSAGES);
} catch (MissingResourceException e) {
log.logError(BaseMessages.getString(PKG, "XulDatabaseDialog.Error.ResourcesNotFound.Title"), e.getMessage(), e);
}
XulDomContainer fragmentContainer = null;
String pkg = getClass().getPackage().getName().replace('.', '/');
// to check for it here.
if (res != null) {
fragmentContainer = container.loadFragment(pkg.concat(DIALOG_FRAGMENT_FILE), res);
} else {
fragmentContainer = container.loadFragment(pkg.concat(DIALOG_FRAGMENT_FILE));
}
XulComponent newBox = fragmentContainer.getDocumentRoot().getFirstChild();
parentElement.replaceChild(boxElement, newBox);
} catch (Exception e) {
new ErrorDialog(parentShell, BaseMessages.getString(PKG, "XulDatabaseDialog.Error.Title"), BaseMessages.getString(PKG, "XulDatabaseDialog.Error.HandleXul"), e);
return;
}
try {
xulDialogComponent = (XulDialog) container.getDocumentRoot().getRootElement();
parentShell.addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent arg0) {
xulDialogComponent.hide();
}
});
} catch (Exception e) {
new ErrorDialog(parentShell, BaseMessages.getString(PKG, "XulDatabaseDialog.Error.Title"), BaseMessages.getString(PKG, "XulDatabaseDialog.Error.Dialog"), e);
return;
}
}
use of org.pentaho.di.ui.core.dialog.ErrorDialog in project pentaho-kettle by pentaho.
the class XulDatabaseExplorerController method dataProfile.
public void dataProfile() {
if (model.getTable() == null) {
return;
}
Shell dbShell = (Shell) dbExplorerDialog.getRootObject();
try {
TransProfileFactory profileFactory = new TransProfileFactory(this.model.getDatabaseMeta(), getSchemaAndTable(this.model));
TransMeta transMeta = profileFactory.generateTransformation(new LoggingObject(model.getTable()));
TransPreviewProgressDialog progressDialog = new TransPreviewProgressDialog(dbShell, transMeta, new String[] { TransProfileFactory.RESULT_STEP_NAME }, new int[] { 25000 });
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(dbShell, BaseMessages.getString(PKG, "System.Dialog.PreviewError.Title"), BaseMessages.getString(PKG, "System.Dialog.PreviewError.Message"), loggingText, true);
etd.setReadOnly();
etd.open();
}
PreviewRowsDialog prd = new PreviewRowsDialog(dbShell, transMeta, SWT.NONE, TransProfileFactory.RESULT_STEP_NAME, progressDialog.getPreviewRowsMeta(TransProfileFactory.RESULT_STEP_NAME), progressDialog.getPreviewRows(TransProfileFactory.RESULT_STEP_NAME), loggingText);
prd.open();
}
} catch (Exception e) {
new ErrorDialog(this.dbExplorerDialog.getShell(), BaseMessages.getString(PKG, "DatabaseExplorerDialog.UnexpectedProfilingError.Title"), BaseMessages.getString(PKG, "DatabaseExplorerDialog.UnexpectedProfilingError.Message"), e);
}
}
use of org.pentaho.di.ui.core.dialog.ErrorDialog in project pentaho-kettle by pentaho.
the class XulDatabaseExplorerController method getDDLForOther.
public void getDDLForOther() {
if (databases != null) {
try {
// Now select the other connection...
// Only take non-SAP ERP connections....
List<DatabaseMeta> dbs = new ArrayList<DatabaseMeta>();
for (int i = 0; i < databases.size(); i++) {
if (((databases.get(i)).getDatabaseInterface().isExplorable())) {
dbs.add(databases.get(i));
}
}
String[] conn = new String[dbs.size()];
for (int i = 0; i < conn.length; i++) {
conn[i] = (dbs.get(i)).getName();
}
EnterSelectionDialog esd = new EnterSelectionDialog(this.dbExplorerDialog.getShell(), conn, BaseMessages.getString(PKG, "DatabaseExplorerDialog.TargetDatabase.Title"), BaseMessages.getString(PKG, "DatabaseExplorerDialog.TargetDatabase.Message"));
String target = esd.open();
if (target != null) {
DatabaseMeta targetdbi = DatabaseMeta.findDatabase(dbs, target);
Database targetdb = new Database(null, targetdbi);
try {
targetdb.connect();
String tableName = getSchemaAndTable(model);
RowMetaInterface r = targetdb.getTableFields(tableName);
String sql = targetdb.getCreateTableStatement(tableName, r, null, false, null, true);
SQLEditor se = new SQLEditor(this.getDatabaseMeta(), this.dbExplorerDialog.getShell(), SWT.NONE, this.model.getDatabaseMeta(), this.dbcache, sql);
se.open();
} finally {
targetdb.disconnect();
}
}
} catch (KettleDatabaseException dbe) {
new ErrorDialog(this.dbExplorerDialog.getShell(), BaseMessages.getString(PKG, "Dialog.Error.Header"), BaseMessages.getString(PKG, "DatabaseExplorerDialog.Error.GenDDL"), dbe);
}
} else {
MessageBox mb = new MessageBox(this.dbExplorerDialog.getShell(), SWT.NONE | SWT.ICON_INFORMATION);
mb.setMessage(BaseMessages.getString(PKG, "DatabaseExplorerDialog.NoConnectionsKnown.Message"));
mb.setText(BaseMessages.getString(PKG, "DatabaseExplorerDialog.NoConnectionsKnown.Title"));
mb.open();
}
}
Aggregations