Search in sources :

Example 6 with KettleRepositoryLostException

use of org.pentaho.di.repository.KettleRepositoryLostException in project pentaho-kettle by pentaho.

the class TransLoadProgressDialog method open.

public TransMeta open() {
    IRunnableWithProgress op = new IRunnableWithProgress() {

        public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
            Spoon spoon = Spoon.getInstance();
            try {
                // Call extension point(s) before the file has been opened
                ExtensionPointHandler.callExtensionPoint(spoon.getLog(), KettleExtensionPoint.TransBeforeOpen.id, (objectId == null) ? transname : objectId.toString());
                if (objectId != null) {
                    transInfo = rep.loadTransformation(objectId, versionLabel);
                } else {
                    transInfo = rep.loadTransformation(transname, repdir, new ProgressMonitorAdapter(monitor), true, versionLabel);
                }
                // Call extension point(s) now that the file has been opened
                ExtensionPointHandler.callExtensionPoint(spoon.getLog(), KettleExtensionPoint.TransAfterOpen.id, transInfo);
                if (transInfo.hasMissingPlugins()) {
                    StepMeta stepMeta = transInfo.getStep(0);
                    Display.getDefault().syncExec(() -> {
                        MissingTransDialog missingTransDialog = new MissingTransDialog(shell, transInfo.getMissingTrans(), stepMeta.getStepMetaInterface(), transInfo, stepMeta.getName());
                        if (missingTransDialog.open() == null) {
                            transInfo = null;
                        }
                    });
                }
            } catch (KettleException e) {
                throw new InvocationTargetException(e, BaseMessages.getString(PKG, "TransLoadProgressDialog.Exception.ErrorLoadingTransformation"));
            }
        }
    };
    try {
        ProgressMonitorDialog pmd = new ProgressMonitorDialog(shell);
        pmd.run(true, false, op);
    } catch (InvocationTargetException e) {
        KettleRepositoryLostException krle = KettleRepositoryLostException.lookupStackStrace(e);
        if (krle != null) {
            throw krle;
        }
        new ErrorDialog(shell, BaseMessages.getString(PKG, "TransLoadProgressDialog.ErrorLoadingTransformation.DialogTitle"), BaseMessages.getString(PKG, "TransLoadProgressDialog.ErrorLoadingTransformation.DialogMessage"), e);
        transInfo = null;
    } catch (InterruptedException e) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "TransLoadProgressDialog.ErrorLoadingTransformation.DialogTitle"), BaseMessages.getString(PKG, "TransLoadProgressDialog.ErrorLoadingTransformation.DialogMessage"), e);
        transInfo = null;
    }
    return transInfo;
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) MissingTransDialog(org.pentaho.di.ui.trans.steps.missing.MissingTransDialog) Spoon(org.pentaho.di.ui.spoon.Spoon) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) ProgressMonitorAdapter(org.pentaho.di.core.ProgressMonitorAdapter) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) StepMeta(org.pentaho.di.trans.step.StepMeta) KettleRepositoryLostException(org.pentaho.di.repository.KettleRepositoryLostException) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress)

Example 7 with KettleRepositoryLostException

use of org.pentaho.di.repository.KettleRepositoryLostException in project pentaho-kettle by pentaho.

the class Spoon method openFile.

public void openFile(boolean importfile) {
    try {
        SpoonPerspective activePerspective = SpoonPerspectiveManager.getInstance().getActivePerspective();
        // 
        if (!importfile) {
            if (activePerspective instanceof SpoonPerspectiveOpenSaveInterface) {
                ((SpoonPerspectiveOpenSaveInterface) activePerspective).open();
                return;
            }
        }
        String activePerspectiveId = activePerspective.getId();
        boolean etlPerspective = activePerspectiveId.equals(MainSpoonPerspective.ID);
        if (rep == null || importfile || !etlPerspective) {
            // Load from XML
            FileDialog dialog = new FileDialog(shell, SWT.OPEN);
            LinkedHashSet<String> extensions = new LinkedHashSet<>();
            LinkedHashSet<String> extensionNames = new LinkedHashSet<>();
            StringBuilder allExtensions = new StringBuilder();
            for (FileListener l : fileListeners) {
                for (String ext : l.getSupportedExtensions()) {
                    extensions.add("*." + ext);
                    allExtensions.append("*.").append(ext).append(";");
                }
                Collections.addAll(extensionNames, l.getFileTypeDisplayNames(Locale.getDefault()));
            }
            extensions.add("*");
            extensionNames.add(BaseMessages.getString(PKG, "Spoon.Dialog.OpenFile.AllFiles"));
            String[] exts = new String[extensions.size() + 1];
            exts[0] = allExtensions.toString();
            System.arraycopy(extensions.toArray(new String[extensions.size()]), 0, exts, 1, extensions.size());
            String[] extNames = new String[extensionNames.size() + 1];
            extNames[0] = BaseMessages.getString(PKG, "Spoon.Dialog.OpenFile.AllTypes");
            System.arraycopy(extensionNames.toArray(new String[extensionNames.size()]), 0, extNames, 1, extensionNames.size());
            dialog.setFilterExtensions(exts);
            setFilterPath(dialog);
            String filename = dialog.open();
            if (filename != null) {
                if (importfile) {
                    if (activePerspective instanceof SpoonPerspectiveOpenSaveInterface) {
                        ((SpoonPerspectiveOpenSaveInterface) activePerspective).importFile(filename);
                        return;
                    }
                }
                lastDirOpened = dialog.getFilterPath();
                openFile(filename, importfile);
            }
        } else {
            try {
                FileDialogOperation fileDialogOperation = new FileDialogOperation(FileDialogOperation.OPEN, FileDialogOperation.ORIGIN_SPOON);
                ExtensionPointHandler.callExtensionPoint(log, KettleExtensionPoint.SpoonOpenSaveRepository.id, fileDialogOperation);
                if (fileDialogOperation.getRepositoryObject() != null) {
                    RepositoryObject repositoryObject = (RepositoryObject) fileDialogOperation.getRepositoryObject();
                    loadObjectFromRepository(repositoryObject.getObjectId(), repositoryObject.getObjectType(), null);
                }
            } catch (Exception e) {
            // Ignore
            }
        }
    } catch (KettleRepositoryLostException krle) {
        new ErrorDialog(getShell(), BaseMessages.getString(PKG, "Spoon.Error"), krle.getPrefaceMessage(), krle);
        this.closeRepository();
    }
}
Also used : LinkedHashSet(java.util.LinkedHashSet) RepositoryObject(org.pentaho.di.repository.RepositoryObject) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) KettleRepositoryLostException(org.pentaho.di.repository.KettleRepositoryLostException) SWTException(org.eclipse.swt.SWTException) KettleRowException(org.pentaho.di.core.exception.KettleRowException) FileSystemException(org.apache.commons.vfs2.FileSystemException) MetaStoreException(org.pentaho.metastore.api.exceptions.MetaStoreException) KettleValueException(org.pentaho.di.core.exception.KettleValueException) KettleAuthException(org.pentaho.di.core.exception.KettleAuthException) KettleRepositoryLostException(org.pentaho.di.repository.KettleRepositoryLostException) KettleXMLException(org.pentaho.di.core.exception.KettleXMLException) LifecycleException(org.pentaho.di.core.lifecycle.LifecycleException) KettleMissingPluginsException(org.pentaho.di.core.exception.KettleMissingPluginsException) KettleFileException(org.pentaho.di.core.exception.KettleFileException) KettleException(org.pentaho.di.core.exception.KettleException) MalformedURLException(java.net.MalformedURLException) KettlePropertiesFileDialog(org.pentaho.di.ui.core.dialog.KettlePropertiesFileDialog) FileDialog(org.eclipse.swt.widgets.FileDialog) FileDialogOperation(org.pentaho.di.ui.core.FileDialogOperation)

Example 8 with KettleRepositoryLostException

use of org.pentaho.di.repository.KettleRepositoryLostException in project pentaho-kettle by pentaho.

the class Spoon method saveFile.

public boolean saveFile() {
    try {
        EngineMetaInterface meta = getActiveMeta();
        if (meta != null) {
            if (AbstractMeta.class.isAssignableFrom(meta.getClass()) && ((AbstractMeta) meta).hasMissingPlugins()) {
                MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
                mb.setMessage(BaseMessages.getString(PKG, "Spoon.ErrorDialog.MissingPlugin.Error"));
                mb.setText(BaseMessages.getString(PKG, "Spoon.ErrorDialog.MissingPlugin.Title"));
                mb.open();
                return false;
            }
            if (meta != null) {
                return saveToFile(meta);
            }
        }
    } catch (Exception e) {
        KettleRepositoryLostException krle = KettleRepositoryLostException.lookupStackStrace(e);
        if (krle != null) {
            new ErrorDialog(shell, BaseMessages.getString(PKG, "Spoon.File.Save.Fail.Title"), krle.getPrefaceMessage(), krle);
            closeRepository();
        } else {
            new ErrorDialog(shell, BaseMessages.getString(PKG, "Spoon.File.Save.Fail.Title"), BaseMessages.getString(PKG, "Spoon.File.Save.Fail.Message"), e);
        }
    }
    return false;
}
Also used : AbstractMeta(org.pentaho.di.base.AbstractMeta) EngineMetaInterface(org.pentaho.di.core.EngineMetaInterface) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) KettleRepositoryLostException(org.pentaho.di.repository.KettleRepositoryLostException) SWTException(org.eclipse.swt.SWTException) KettleRowException(org.pentaho.di.core.exception.KettleRowException) FileSystemException(org.apache.commons.vfs2.FileSystemException) MetaStoreException(org.pentaho.metastore.api.exceptions.MetaStoreException) KettleValueException(org.pentaho.di.core.exception.KettleValueException) KettleAuthException(org.pentaho.di.core.exception.KettleAuthException) KettleRepositoryLostException(org.pentaho.di.repository.KettleRepositoryLostException) KettleXMLException(org.pentaho.di.core.exception.KettleXMLException) LifecycleException(org.pentaho.di.core.lifecycle.LifecycleException) KettleMissingPluginsException(org.pentaho.di.core.exception.KettleMissingPluginsException) KettleFileException(org.pentaho.di.core.exception.KettleFileException) KettleException(org.pentaho.di.core.exception.KettleException) MalformedURLException(java.net.MalformedURLException) MessageBox(org.eclipse.swt.widgets.MessageBox)

Example 9 with KettleRepositoryLostException

use of org.pentaho.di.repository.KettleRepositoryLostException in project pentaho-kettle by pentaho.

the class Spoon method saveFileAs.

public boolean saveFileAs() throws KettleException {
    try {
        EngineMetaInterface meta = getActiveMeta();
        if (meta != null && AbstractMeta.class.isAssignableFrom(meta.getClass())) {
            if (((AbstractMeta) meta).hasMissingPlugins()) {
                MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
                mb.setMessage(BaseMessages.getString(PKG, "Spoon.ErrorDialog.MissingPlugin.Error"));
                mb.setText(BaseMessages.getString(PKG, "Spoon.ErrorDialog.MissingPlugin.Title"));
                mb.open();
                return false;
            }
        }
        if (meta != null) {
            if (meta.canSave()) {
                return saveFileAs(meta);
            }
        }
    } catch (Exception e) {
        KettleRepositoryLostException krle = KettleRepositoryLostException.lookupStackStrace(e);
        if (krle != null) {
            new ErrorDialog(shell, BaseMessages.getString(PKG, "Spoon.File.Save.Fail.Title"), krle.getPrefaceMessage(), krle);
            closeRepository();
        } else {
            new ErrorDialog(shell, BaseMessages.getString(PKG, "Spoon.File.Save.Fail.Title"), BaseMessages.getString(PKG, "Spoon.File.Save.Fail.Message"), e);
        }
    }
    return false;
}
Also used : AbstractMeta(org.pentaho.di.base.AbstractMeta) EngineMetaInterface(org.pentaho.di.core.EngineMetaInterface) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) KettleRepositoryLostException(org.pentaho.di.repository.KettleRepositoryLostException) SWTException(org.eclipse.swt.SWTException) KettleRowException(org.pentaho.di.core.exception.KettleRowException) FileSystemException(org.apache.commons.vfs2.FileSystemException) MetaStoreException(org.pentaho.metastore.api.exceptions.MetaStoreException) KettleValueException(org.pentaho.di.core.exception.KettleValueException) KettleAuthException(org.pentaho.di.core.exception.KettleAuthException) KettleRepositoryLostException(org.pentaho.di.repository.KettleRepositoryLostException) KettleXMLException(org.pentaho.di.core.exception.KettleXMLException) LifecycleException(org.pentaho.di.core.lifecycle.LifecycleException) KettleMissingPluginsException(org.pentaho.di.core.exception.KettleMissingPluginsException) KettleFileException(org.pentaho.di.core.exception.KettleFileException) KettleException(org.pentaho.di.core.exception.KettleException) MalformedURLException(java.net.MalformedURLException) MessageBox(org.eclipse.swt.widgets.MessageBox)

Example 10 with KettleRepositoryLostException

use of org.pentaho.di.repository.KettleRepositoryLostException in project pentaho-kettle by pentaho.

the class TransDialog method open.

public TransMeta open() {
    Shell parent = getParent();
    Display display = parent.getDisplay();
    shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MAX | SWT.MIN);
    props.setLook(shell);
    shell.setImage(GUIResource.getInstance().getImageTransGraph());
    lsMod = new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            changed = true;
        }
    };
    lsModSel = new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            changed = true;
        }
    };
    FormLayout formLayout = new FormLayout();
    formLayout.marginWidth = Const.FORM_MARGIN;
    formLayout.marginHeight = Const.FORM_MARGIN;
    shell.setLayout(formLayout);
    shell.setText(BaseMessages.getString(PKG, "TransDialog.Shell.Title"));
    middle = props.getMiddlePct();
    margin = Const.MARGIN;
    wTabFolder = new CTabFolder(shell, SWT.BORDER);
    props.setLook(wTabFolder, Props.WIDGET_STYLE_TAB);
    wTabFolder.setSimple(false);
    addTransTab();
    addParamTab();
    addLogTab();
    addDateTab();
    addDepTab();
    addMiscTab();
    addMonitoringTab();
    // See if there are any other tabs to be added...
    extraTabs = new ArrayList<TransDialogPluginInterface>();
    java.util.List<PluginInterface> transDialogPlugins = PluginRegistry.getInstance().getPlugins(TransDialogPluginType.class);
    for (PluginInterface transDialogPlugin : transDialogPlugins) {
        try {
            TransDialogPluginInterface extraTab = (TransDialogPluginInterface) PluginRegistry.getInstance().loadClass(transDialogPlugin);
            extraTab.addTab(transMeta, parent, wTabFolder);
            extraTabs.add(extraTab);
        } catch (Exception e) {
            KettleRepositoryLostException krle = KettleRepositoryLostException.lookupStackStrace(e);
            if (krle != null) {
                throw krle;
            }
            new ErrorDialog(shell, "Error", "Error loading transformation dialog plugin with id " + transDialogPlugin.getIds()[0], e);
        }
    }
    fdTabFolder = new FormData();
    fdTabFolder.left = new FormAttachment(0, 0);
    fdTabFolder.top = new FormAttachment(0, 0);
    fdTabFolder.right = new FormAttachment(100, 0);
    fdTabFolder.bottom = new FormAttachment(100, -50);
    wTabFolder.setLayoutData(fdTabFolder);
    // THE BUTTONS
    wOK = new Button(shell, SWT.PUSH);
    wOK.setText(BaseMessages.getString(PKG, "System.Button.OK"));
    wSQL = new Button(shell, SWT.PUSH);
    wSQL.setText(BaseMessages.getString(PKG, "System.Button.SQL"));
    wCancel = new Button(shell, SWT.PUSH);
    wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel"));
    BaseStepDialog.positionBottomButtons(shell, new Button[] { wOK, wSQL, wCancel }, Const.MARGIN, null);
    // Add listeners
    lsOK = new Listener() {

        public void handleEvent(Event e) {
            ok();
        }
    };
    lsGet = new Listener() {

        public void handleEvent(Event e) {
            get();
        }
    };
    lsSQL = new Listener() {

        public void handleEvent(Event e) {
            sql();
        }
    };
    lsCancel = new Listener() {

        public void handleEvent(Event e) {
            cancel();
        }
    };
    wOK.addListener(SWT.Selection, lsOK);
    wGet.addListener(SWT.Selection, lsGet);
    wSQL.addListener(SWT.Selection, lsSQL);
    wCancel.addListener(SWT.Selection, lsCancel);
    lsDef = new SelectionAdapter() {

        public void widgetDefaultSelected(SelectionEvent e) {
            ok();
        }
    };
    wTransname.addSelectionListener(lsDef);
    wTransdescription.addSelectionListener(lsDef);
    wTransversion.addSelectionListener(lsDef);
    wMaxdatetable.addSelectionListener(lsDef);
    wMaxdatefield.addSelectionListener(lsDef);
    wMaxdateoffset.addSelectionListener(lsDef);
    wMaxdatediff.addSelectionListener(lsDef);
    wSizeRowset.addSelectionListener(lsDef);
    wUniqueConnections.addSelectionListener(lsDef);
    wFeedbackSize.addSelectionListener(lsDef);
    wStepPerfInterval.addSelectionListener(lsDef);
    // Detect X or ALT-F4 or something that kills this window...
    shell.addShellListener(new ShellAdapter() {

        public void shellClosed(ShellEvent e) {
            cancel();
        }
    });
    if (currentTab != null) {
        setCurrentTab(currentTab);
    } else {
        wTabFolder.setSelection(0);
    }
    getData();
    BaseStepDialog.setSize(shell);
    changed = false;
    sharedObjectsFileChanged = false;
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
    return transMeta;
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) ShellAdapter(org.eclipse.swt.events.ShellAdapter) CTabFolder(org.eclipse.swt.custom.CTabFolder) FieldDisabledListener(org.pentaho.di.ui.core.widget.FieldDisabledListener) Listener(org.eclipse.swt.widgets.Listener) ModifyListener(org.eclipse.swt.events.ModifyListener) ModifyListener(org.eclipse.swt.events.ModifyListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) PluginInterface(org.pentaho.di.core.plugins.PluginInterface) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) ShellEvent(org.eclipse.swt.events.ShellEvent) KettleRepositoryLostException(org.pentaho.di.repository.KettleRepositoryLostException) DuplicateParamException(org.pentaho.di.core.parameters.DuplicateParamException) UnknownParamException(org.pentaho.di.core.parameters.UnknownParamException) KettleException(org.pentaho.di.core.exception.KettleException) KettleRepositoryLostException(org.pentaho.di.repository.KettleRepositoryLostException) Shell(org.eclipse.swt.widgets.Shell) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Button(org.eclipse.swt.widgets.Button) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Event(org.eclipse.swt.widgets.Event) ShellEvent(org.eclipse.swt.events.ShellEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) FormAttachment(org.eclipse.swt.layout.FormAttachment) Display(org.eclipse.swt.widgets.Display)

Aggregations

KettleRepositoryLostException (org.pentaho.di.repository.KettleRepositoryLostException)10 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)9 KettleException (org.pentaho.di.core.exception.KettleException)8 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)4 MalformedURLException (java.net.MalformedURLException)3 FileSystemException (org.apache.commons.vfs2.FileSystemException)3 SWTException (org.eclipse.swt.SWTException)3 AbstractMeta (org.pentaho.di.base.AbstractMeta)3 KettleAuthException (org.pentaho.di.core.exception.KettleAuthException)3 KettleFileException (org.pentaho.di.core.exception.KettleFileException)3 KettleMissingPluginsException (org.pentaho.di.core.exception.KettleMissingPluginsException)3 KettleRowException (org.pentaho.di.core.exception.KettleRowException)3 KettleValueException (org.pentaho.di.core.exception.KettleValueException)3 KettleXMLException (org.pentaho.di.core.exception.KettleXMLException)3 LifecycleException (org.pentaho.di.core.lifecycle.LifecycleException)3 MetaStoreException (org.pentaho.metastore.api.exceptions.MetaStoreException)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2 ProgressMonitorDialog (org.eclipse.jface.dialogs.ProgressMonitorDialog)2 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)2