use of org.pentaho.di.ui.core.dialog.ErrorDialog in project pentaho-kettle by pentaho.
the class ConnectionsController method editConnection.
public void editConnection() {
try {
Collection<UIDatabaseConnection> connections = connectionsTable.getSelectedItems();
if (connections != null && !connections.isEmpty()) {
// Grab the first item in the list & send it to the database dialog
DatabaseMeta databaseMeta = ((UIDatabaseConnection) connections.toArray()[0]).getDatabaseMeta();
// Make sure this connection already exists and store its id for updating
ObjectId idDatabase = repository.getDatabaseID(databaseMeta.getName());
if (idDatabase == null) {
MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
mb.setMessage(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Connection.Edit.DoesNotExists.Message"));
mb.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Connection.Edit.DoesNotExists.Title"));
mb.open();
} else {
getDatabaseDialog().setDatabaseMeta(databaseMeta);
String dbName = getDatabaseDialog().open();
if (dbName != null) {
dbName = dbName.trim();
databaseMeta.setName(dbName);
databaseMeta.setDisplayName(dbName);
if (!dbName.isEmpty()) {
ObjectId idRenamed = repository.getDatabaseID(dbName);
if (idRenamed == null || idRenamed.equals(idDatabase)) {
// renaming to non-existing name or updating the current
repository.insertLogEntry(BaseMessages.getString(PKG, "ConnectionsController.Message.UpdatingDatabase", databaseMeta.getName()));
repository.save(databaseMeta, Const.VERSION_COMMENT_EDIT_VERSION, null);
reloadLoadedJobsAndTransformations();
} else {
// trying to rename to an existing name - show error dialog
showAlreadyExistsMessage();
}
}
}
// We should be able to tell the difference between a cancel and an empty database name
//
// else {
// MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
// mb.setMessage(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Connection.Edit.MissingName.Message"));
// mb.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Connection.Edit.MissingName.Title"));
// mb.open();
// }
}
} else {
MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
mb.setMessage(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Connection.Edit.NoItemSelected.Message"));
mb.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Connection.Edit.NoItemSelected.Title"));
mb.open();
}
} catch (KettleException e) {
if (mainController == null || !mainController.handleLostRepository(e)) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "RepositoryExplorerDialog.Connection.Create.UnexpectedError.Title"), BaseMessages.getString(PKG, "RepositoryExplorerDialog.Connection.Edit.UnexpectedError.Message"), e);
}
} finally {
refreshConnectionList();
}
}
use of org.pentaho.di.ui.core.dialog.ErrorDialog in project pentaho-kettle by pentaho.
the class JobFileListener method open.
public boolean open(Node jobNode, String fname, String connection, boolean importfile) {
Spoon spoon = Spoon.getInstance();
try {
// Call extension point(s) before the file has been opened
ExtensionPointHandler.callExtensionPoint(spoon.getLog(), KettleExtensionPoint.JobBeforeOpen.id, fname);
JobMeta jobMeta = new JobMeta();
jobMeta.loadXML(jobNode, fname, spoon.getRepository(), spoon.getMetaStore(), false, spoon);
if (jobMeta.hasMissingPlugins()) {
MissingEntryDialog missingDialog = new MissingEntryDialog(spoon.getShell(), jobMeta.getMissingEntries());
if (missingDialog.open() == null) {
return true;
}
}
// same fix as in PDI-18786 where the clearCurrentDirectoryChangedListeners method was added
clearCurrentDirectoryChangedListenersWhenImporting(importfile, jobMeta);
jobMeta.setRepositoryDirectory(spoon.getDefaultSaveLocation(jobMeta));
jobMeta.setRepository(spoon.getRepository());
jobMeta.setMetaStore(spoon.getMetaStore());
if (connection != null) {
jobMeta.setVariable(Spoon.CONNECTION, connection);
}
spoon.setJobMetaVariables(jobMeta);
spoon.getProperties().addLastFile(LastUsedFile.FILE_TYPE_JOB, fname, null, false, null, null, new Date(), connection);
spoon.addMenuLast();
// if any exist.
if (importfile) {
if (spoon.getRepository() != null) {
jobMeta = fixLinks(jobMeta);
}
} else {
jobMeta.clearChanged();
}
jobMeta.setFilename(fname);
spoon.delegates.jobs.addJobGraph(jobMeta);
// Call extension point(s) now that the file has been opened
ExtensionPointHandler.callExtensionPoint(spoon.getLog(), KettleExtensionPoint.JobAfterOpen.id, jobMeta);
spoon.refreshTree();
SpoonPerspectiveManager.getInstance().activatePerspective(MainSpoonPerspective.class);
return true;
} catch (KettleException e) {
new ErrorDialog(spoon.getShell(), BaseMessages.getString(PKG, "Spoon.Dialog.ErrorOpening.Title"), BaseMessages.getString(PKG, "Spoon.Dialog.ErrorOpening.Message") + fname, e);
}
return false;
}
use of org.pentaho.di.ui.core.dialog.ErrorDialog in project pentaho-kettle by pentaho.
the class ExcelOutputDialog method get.
private void get() {
try {
RowMetaInterface r = transMeta.getPrevStepFields(stepname);
if (r != null) {
TableItemInsertListener listener = new TableItemInsertListener() {
@Override
public boolean tableItemInserted(TableItem tableItem, ValueMetaInterface v) {
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.ui.core.dialog.ErrorDialog in project pentaho-kettle by pentaho.
the class TextFileCSVImportProgressDialog method open.
/**
* @param failOnParseError if set to true, parsing failure on any line will cause parsing to be terminated; when
* set to false, parsing failure on a given line will not prevent remaining lines from
* being parsed - this allows us to analyze fields, even if some field is mis-configured
* and causes a parsing error for the values of that field.
*/
@Override
public String open(final boolean failOnParseError) {
IRunnableWithProgress op = new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
try {
message = doScan(monitor, failOnParseError);
} catch (Exception e) {
e.printStackTrace();
throw new InvocationTargetException(e, BaseMessages.getString(PKG, "TextFileCSVImportProgressDialog.Exception.ErrorScanningFile", "" + rownumber, debug, e.toString()));
}
}
};
try {
ProgressMonitorDialog pmd = new ProgressMonitorDialog(shell);
pmd.run(true, true, op);
} catch (InvocationTargetException e) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "TextFileCSVImportProgressDialog.ErrorScanningFile.Title"), BaseMessages.getString(PKG, "TextFileCSVImportProgressDialog.ErrorScanningFile.Message"), e);
} catch (InterruptedException e) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "TextFileCSVImportProgressDialog.ErrorScanningFile.Title"), BaseMessages.getString(PKG, "TextFileCSVImportProgressDialog.ErrorScanningFile.Message"), e);
}
return message;
}
use of org.pentaho.di.ui.core.dialog.ErrorDialog in project pentaho-kettle by pentaho.
the class DeleteDialog method getSchemaNames.
private void getSchemaNames() {
DatabaseMeta databaseMeta = transMeta.findDatabase(wConnection.getText());
if (databaseMeta != null) {
Database database = new Database(loggingObject, databaseMeta);
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, "DeleteDialog.AvailableSchemas.Title", wConnection.getText()), BaseMessages.getString(PKG, "DeleteDialog.AvailableSchemas.Message", wConnection.getText()));
String d = dialog.open();
if (d != null) {
wSchema.setText(Const.NVL(d, ""));
setTableFieldCombo();
}
} else {
MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
mb.setMessage(BaseMessages.getString(PKG, "DeleteDialog.NoSchema.Error"));
mb.setText(BaseMessages.getString(PKG, "DeleteDialog.GetSchemas.Error"));
mb.open();
}
} catch (Exception e) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "System.Dialog.Error.Title"), BaseMessages.getString(PKG, "DeleteDialog.ErrorGettingSchemas"), e);
} finally {
database.disconnect();
}
}
}
Aggregations