Search in sources :

Example 31 with ErrorDialog

use of org.pentaho.di.ui.core.dialog.ErrorDialog in project pentaho-kettle by pentaho.

the class RepositoryExplorerDialog method restoreSelectedObjects.

public boolean restoreSelectedObjects() {
    TreeItem[] items = wTree.getSelection();
    boolean error = false;
    for (int i = 0; i < items.length; i++) {
        final RepositoryElementMetaInterface repositoryObject = objectMap.get(ConstUI.getTreePath(items[i], 0));
        if (repositoryObject != null) {
            try {
                rep.undeleteObject(repositoryObject);
            } catch (Exception e) {
                new ErrorDialog(shell, BaseMessages.getString(PKG, "RepositoryExplorerDialog.Trans.Delete.ErrorRestoring.Title"), BaseMessages.getString(PKG, "RepositoryExplorerDialog.Trans.Delete.ErrorRestoring.Message"), e);
                error = true;
            }
        }
    }
    refreshTree();
    return !error;
}
Also used : TreeItem(org.eclipse.swt.widgets.TreeItem) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) IOException(java.io.IOException) KettleException(org.pentaho.di.core.exception.KettleException) RepositoryElementMetaInterface(org.pentaho.di.repository.RepositoryElementMetaInterface)

Example 32 with ErrorDialog

use of org.pentaho.di.ui.core.dialog.ErrorDialog in project pentaho-kettle by pentaho.

the class RepositoryExplorerDialog method moveJob.

public boolean moveJob(String xml, RepositoryDirectoryInterface repdir) {
    debug = "Move Job";
    boolean retval = false;
    try {
        debug = "parse xml";
        Document doc = XMLHandler.loadXMLString(xml);
        String dirname = XMLHandler.getTagValue(doc, "dragdrop", "directory");
        String jobname = XMLHandler.getTagValue(doc, "dragdrop", "job");
        if (dirname != null && jobname != null) {
            debug = "dirname=" + dirname + ", jobname=" + jobname;
            // OK, find this transformation...
            RepositoryDirectoryInterface fromdir = directoryTree.findDirectory(dirname);
            if (fromdir != null) {
                debug = "fromdir found: move job!";
                ObjectId existingjobID = rep.getJobId(jobname, repdir);
                if (existingjobID == null) {
                    ObjectId id = rep.getJobId(jobname, fromdir);
                    rep.renameJob(id, repdir, jobname);
                    retval = true;
                } else {
                    MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
                    mb.setMessage(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Job.Move.ErrorDuplicate.Message", jobname) + Const.CR);
                    mb.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Job.Move.ErrorDuplicate.Title"));
                    mb.open();
                }
            } else {
                MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
                mb.setMessage(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Job.Move.ErrorMoving.Message") + dirname + "]" + Const.CR);
                mb.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Job.Move.ErrorMoving.Title"));
                mb.open();
            }
        }
    } catch (Exception dbe) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "RepositoryExplorerDialog.Job.Move.UnexpectedError.Title"), BaseMessages.getString(PKG, "RepositoryExplorerDialog.Trans.Move.UnexpectedError.Message"), dbe);
    }
    return retval;
}
Also used : RepositoryDirectoryInterface(org.pentaho.di.repository.RepositoryDirectoryInterface) ObjectId(org.pentaho.di.repository.ObjectId) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) Document(org.w3c.dom.Document) IOException(java.io.IOException) KettleException(org.pentaho.di.core.exception.KettleException) MessageBox(org.eclipse.swt.widgets.MessageBox)

Example 33 with ErrorDialog

use of org.pentaho.di.ui.core.dialog.ErrorDialog in project pentaho-kettle by pentaho.

the class RepositoryExplorerDialog method exportTransformations.

public void exportTransformations(RepositoryDirectoryInterface root) {
    try {
        DirectoryDialog dialog = new DirectoryDialog(shell, SWT.OPEN);
        if (dialog.open() != null) {
            String directory = dialog.getFilterPath();
            ObjectId[] dirids = ((root == null) ? directoryTree : root).getDirectoryIDs();
            for (int d = 0; d < dirids.length; d++) {
                RepositoryDirectoryInterface repdir = directoryTree.findDirectory(dirids[d]);
                String[] trans = rep.getTransformationNames(dirids[d], false);
                // See if the directory exists...
                File dir = new File(directory + repdir.getPath());
                if (!dir.exists()) {
                    dir.mkdir();
                    log.logBasic("Exporting transformation", "Created directory [" + dir.getName() + "]");
                }
                for (int i = 0; i < trans.length; i++) {
                    // reads last version
                    TransMeta ti = rep.loadTransformation(trans[i], repdir, null, true, null);
                    if (log.isBasic()) {
                        log.logBasic("Exporting transformation", "[" + trans[i] + "] in directory [" + repdir.getPath() + "]");
                    }
                    String xml = XMLHandler.getXMLHeader() + ti.getXML();
                    String filename = directory + repdir.getPath() + Const.FILE_SEPARATOR + fixFileName(trans[i]) + ".ktr";
                    File f = new File(filename);
                    try {
                        FileOutputStream fos = new FileOutputStream(f);
                        fos.write(xml.getBytes(Const.XML_ENCODING));
                        fos.close();
                    } catch (IOException e) {
                        throw new RuntimeException("Exporting transformation: Couldn't create file [" + filename + "]", e);
                    }
                }
            }
        }
    } catch (Exception e) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "RepositoryExplorerDialog.ExportTrans.UnexpectedError.Title"), BaseMessages.getString(PKG, "RepositoryExplorerDialog.ExportTrans.UnexpectedError.Message"), e);
    }
}
Also used : RepositoryDirectoryInterface(org.pentaho.di.repository.RepositoryDirectoryInterface) ObjectId(org.pentaho.di.repository.ObjectId) TransMeta(org.pentaho.di.trans.TransMeta) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) IOException(java.io.IOException) IOException(java.io.IOException) KettleException(org.pentaho.di.core.exception.KettleException) FileOutputStream(java.io.FileOutputStream) File(java.io.File) DirectoryDialog(org.eclipse.swt.widgets.DirectoryDialog)

Example 34 with ErrorDialog

use of org.pentaho.di.ui.core.dialog.ErrorDialog in project pentaho-kettle by pentaho.

the class RepositoryExplorerDialog method delSelectedObjects.

public boolean delSelectedObjects() {
    TreeItem[] items = wTree.getSelection();
    boolean error = false;
    MessageBox mb = new MessageBox(shell, SWT.ICON_WARNING | SWT.YES | SWT.NO);
    mb.setMessage(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Trans.Delete.Confirm.Message1") + (items.length > 1 ? BaseMessages.getString(PKG, "RepositoryExplorerDialog.Trans.Delete.Confirm.Message2") + items.length + BaseMessages.getString(PKG, "RepositoryExplorerDialog.Trans.Delete.Confirm.Message3") : BaseMessages.getString(PKG, "RepositoryExplorerDialog.Trans.Delete.Confirm.Message4")));
    mb.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Trans.Delete.Confirm.Title"));
    int answer = mb.open();
    if (answer != SWT.YES) {
        return false;
    }
    for (int i = 0; i < items.length; i++) {
        final RepositoryElementMetaInterface repositoryObject = objectMap.get(ConstUI.getTreePath(items[i], 0));
        if (repositoryObject != null) {
            try {
                switch(repositoryObject.getObjectType()) {
                    case TRANSFORMATION:
                        rep.deleteTransformation(repositoryObject.getObjectId());
                        break;
                    case JOB:
                        rep.deleteJob(repositoryObject.getObjectId());
                        break;
                    default:
                        break;
                }
            } catch (Exception e) {
                new ErrorDialog(shell, BaseMessages.getString(PKG, "RepositoryExplorerDialog.Trans.Delete.ErrorRemoving.Title"), BaseMessages.getString(PKG, "RepositoryExplorerDialog.Trans.Delete.ErrorRemoving.Message") + repositoryObject.getName() + "]", e);
                error = true;
            }
        }
    }
    refreshTree();
    return !error;
}
Also used : TreeItem(org.eclipse.swt.widgets.TreeItem) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) IOException(java.io.IOException) KettleException(org.pentaho.di.core.exception.KettleException) MessageBox(org.eclipse.swt.widgets.MessageBox) RepositoryElementMetaInterface(org.pentaho.di.repository.RepositoryElementMetaInterface)

Example 35 with ErrorDialog

use of org.pentaho.di.ui.core.dialog.ErrorDialog in project pentaho-kettle by pentaho.

the class RepositoryExplorerDialog method delDatabase.

public void delDatabase(String databasename) {
    try {
        rep.deleteDatabaseMeta(databasename);
        refreshTree();
    } catch (KettleException e) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "RepositoryExplorerDialog.Connection.Delete.UnexpectedError.Title"), BaseMessages.getString(PKG, "RepositoryExplorerDialog.Connection.Delete.UnexpectedError.Message"), e);
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog)

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