Search in sources :

Example 86 with ErrorDialog

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();
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) ObjectId(org.pentaho.di.repository.ObjectId) UIDatabaseConnection(org.pentaho.di.ui.repository.repositoryexplorer.model.UIDatabaseConnection) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta) MessageBox(org.eclipse.swt.widgets.MessageBox)

Example 87 with ErrorDialog

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;
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) JobMeta(org.pentaho.di.job.JobMeta) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) MissingEntryDialog(org.pentaho.di.ui.job.entries.missing.MissingEntryDialog) Date(java.util.Date)

Example 88 with ErrorDialog

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);
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) TableItemInsertListener(org.pentaho.di.ui.trans.step.TableItemInsertListener) TableItem(org.eclipse.swt.widgets.TableItem) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) Point(org.eclipse.swt.graphics.Point) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface)

Example 89 with ErrorDialog

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;
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) KettleException(org.pentaho.di.core.exception.KettleException) InvocationTargetException(java.lang.reflect.InvocationTargetException) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress)

Example 90 with ErrorDialog

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();
        }
    }
}
Also used : Database(org.pentaho.di.core.database.Database) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta) EnterSelectionDialog(org.pentaho.di.ui.core.dialog.EnterSelectionDialog) KettleException(org.pentaho.di.core.exception.KettleException) MessageBox(org.eclipse.swt.widgets.MessageBox)

Aggregations

ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)527 KettleException (org.pentaho.di.core.exception.KettleException)440 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)178 MessageBox (org.eclipse.swt.widgets.MessageBox)118 TableItem (org.eclipse.swt.widgets.TableItem)97 ValueMetaInterface (org.pentaho.di.core.row.ValueMetaInterface)76 DatabaseMeta (org.pentaho.di.core.database.DatabaseMeta)63 TransMeta (org.pentaho.di.trans.TransMeta)48 Shell (org.eclipse.swt.widgets.Shell)46 KettleRepositoryLostException (org.pentaho.di.repository.KettleRepositoryLostException)46 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)44 EnterTextDialog (org.pentaho.di.ui.core.dialog.EnterTextDialog)44 ArrayList (java.util.ArrayList)43 TableItemInsertListener (org.pentaho.di.ui.trans.step.TableItemInsertListener)43 EnterSelectionDialog (org.pentaho.di.ui.core.dialog.EnterSelectionDialog)42 SelectionEvent (org.eclipse.swt.events.SelectionEvent)40 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)39 StepMeta (org.pentaho.di.trans.step.StepMeta)38 FormData (org.eclipse.swt.layout.FormData)37 FormLayout (org.eclipse.swt.layout.FormLayout)37