Search in sources :

Example 1 with KettleWaitBox

use of org.pentaho.di.ui.xul.KettleWaitBox in project pentaho-kettle by pentaho.

the class Spoon method exploreRepository.

public void exploreRepository() {
    if (rep != null) {
        final RepositoryExplorerCallback cb = new RepositoryExplorerCallback() {

            @Override
            public boolean open(UIRepositoryContent element, String revision) throws Exception {
                String objName = element.getName();
                if (objName != null) {
                    RepositoryObjectType objectType = element.getRepositoryElementType();
                    RepositoryDirectory repDir = element.getRepositoryDirectory();
                    if (element.getObjectId() != null) {
                        // new way
                        loadObjectFromRepository(element.getObjectId(), objectType, revision);
                    } else {
                        // old way
                        loadObjectFromRepository(objName, objectType, repDir, revision);
                    }
                }
                // do not close explorer
                return false;
            }

            @Override
            public boolean error(String message) throws Exception {
                closeRepository();
                return true;
            }
        };
        try {
            final KettleWaitBox box = (KettleWaitBox) this.mainSpoonContainer.getDocumentRoot().createElement("iconwaitbox");
            box.setIndeterminate(true);
            box.setCanCancel(false);
            box.setIcon("ui/images/kettle_logo_small.svg");
            box.setTitle(BaseMessages.getString(RepositoryDialogInterface.class, "RepositoryExplorerDialog.Connection.Wait.Title"));
            box.setMessage(BaseMessages.getString(RepositoryDialogInterface.class, "RepositoryExplorerDialog.Explorer.Wait.Message"));
            box.setDialogParent(shell);
            box.setRunnable(new WaitBoxRunnable(box) {

                @Override
                public void run() {
                    shell.getDisplay().syncExec(new Runnable() {

                        @Override
                        public void run() {
                            RepositoryExplorer explorer;
                            try {
                                try {
                                    explorer = new RepositoryExplorer(shell, rep, cb, Variables.getADefaultVariableSpace(), sharedObjectSyncUtil);
                                } catch (final KettleRepositoryLostException krle) {
                                    handleRepositoryLost(krle);
                                    closeRepository();
                                    return;
                                } finally {
                                    box.stop();
                                }
                                if (explorer.isInitialized()) {
                                    explorer.show();
                                } else {
                                    return;
                                }
                                explorer.dispose();
                            } catch (final Throwable e) {
                                shell.getDisplay().asyncExec(new Runnable() {

                                    @Override
                                    public void run() {
                                        new ErrorDialog(shell, BaseMessages.getString(PKG, "Spoon.Error"), e.getMessage(), e);
                                    }
                                });
                            }
                        }
                    });
                }

                @Override
                public void cancel() {
                }
            });
            box.start();
        } catch (Throwable e) {
            new ErrorDialog(shell, BaseMessages.getString(PKG, "Spoon.Error"), e.getMessage(), e);
        }
    }
}
Also used : RepositoryExplorer(org.pentaho.di.ui.repository.repositoryexplorer.RepositoryExplorer) RepositoryDirectory(org.pentaho.di.repository.RepositoryDirectory) UIRepositoryContent(org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryContent) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) RepositoryExplorerCallback(org.pentaho.di.ui.repository.repositoryexplorer.RepositoryExplorerCallback) KettleRepositoryLostException(org.pentaho.di.repository.KettleRepositoryLostException) WaitBoxRunnable(org.pentaho.ui.xul.components.WaitBoxRunnable) WaitBoxRunnable(org.pentaho.ui.xul.components.WaitBoxRunnable) RepositoryObjectType(org.pentaho.di.repository.RepositoryObjectType) RepositoryDialogInterface(org.pentaho.di.ui.repository.dialog.RepositoryDialogInterface) KettleWaitBox(org.pentaho.di.ui.xul.KettleWaitBox)

Example 2 with KettleWaitBox

use of org.pentaho.di.ui.xul.KettleWaitBox in project pentaho-kettle by pentaho.

the class RepositoriesController method login.

public void login() {
    if (loginModel.isValid() == false) {
        return;
    }
    KettleWaitBox box;
    try {
        box = (KettleWaitBox) document.createElement("iconwaitbox");
        box.setIndeterminate(true);
        box.setCanCancel(false);
        box.setIcon("ui/images/kettle_logo_small.svg");
        box.setTitle(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Connection.Wait.Title"));
        box.setMessage(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Connection.Wait.Message"));
        final Shell loginShell = (Shell) loginDialog.getRootObject();
        final Display display = loginShell.getDisplay();
        box.setDialogParent(loginShell);
        box.setRunnable(new WaitBoxRunnable(box) {

            @Override
            public void run() {
                try {
                    helper.loginToRepository();
                    waitBox.stop();
                    display.syncExec(new Runnable() {

                        public void run() {
                            loginDialog.hide();
                            okButton.setDisabled(false);
                            cancelButton.setDisabled(false);
                            if (helper.getConnectedRepository().getConnectMessage() != null) {
                                getMessageBox().setTitle(BaseMessages.getString(PKG, "ConnectMessageTitle"));
                                getMessageBox().setMessage(helper.getConnectedRepository().getConnectMessage());
                                getMessageBox().open();
                            }
                            getCallback().onSuccess(helper.getConnectedRepository());
                        }
                    });
                } catch (final Throwable th) {
                    waitBox.stop();
                    try {
                        display.syncExec(new Runnable() {

                            public void run() {
                                getCallback().onError(th);
                                okButton.setDisabled(false);
                                cancelButton.setDisabled(false);
                            }
                        });
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            }

            @Override
            public void cancel() {
            }
        });
        okButton.setDisabled(true);
        cancelButton.setDisabled(true);
        box.start();
    } catch (XulException e1) {
        getCallback().onError(e1);
    }
}
Also used : WaitBoxRunnable(org.pentaho.ui.xul.components.WaitBoxRunnable) Shell(org.eclipse.swt.widgets.Shell) XulException(org.pentaho.ui.xul.XulException) WaitBoxRunnable(org.pentaho.ui.xul.components.WaitBoxRunnable) KettleWaitBox(org.pentaho.di.ui.xul.KettleWaitBox) XulException(org.pentaho.ui.xul.XulException) ControllerInitializationException(org.pentaho.di.ui.repository.repositoryexplorer.ControllerInitializationException) Display(org.eclipse.swt.widgets.Display)

Aggregations

KettleWaitBox (org.pentaho.di.ui.xul.KettleWaitBox)2 WaitBoxRunnable (org.pentaho.ui.xul.components.WaitBoxRunnable)2 Display (org.eclipse.swt.widgets.Display)1 Shell (org.eclipse.swt.widgets.Shell)1 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)1 KettleRepositoryLostException (org.pentaho.di.repository.KettleRepositoryLostException)1 RepositoryDirectory (org.pentaho.di.repository.RepositoryDirectory)1 RepositoryObjectType (org.pentaho.di.repository.RepositoryObjectType)1 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)1 RepositoryDialogInterface (org.pentaho.di.ui.repository.dialog.RepositoryDialogInterface)1 ControllerInitializationException (org.pentaho.di.ui.repository.repositoryexplorer.ControllerInitializationException)1 RepositoryExplorer (org.pentaho.di.ui.repository.repositoryexplorer.RepositoryExplorer)1 RepositoryExplorerCallback (org.pentaho.di.ui.repository.repositoryexplorer.RepositoryExplorerCallback)1 UIRepositoryContent (org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryContent)1 XulException (org.pentaho.ui.xul.XulException)1