Search in sources :

Example 1 with RepositoriesDialog

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

the class Spoon method openRepository.

public void openRepository() {
    // Check to tabs are dirty and warn user that they must save tabs prior to connecting.  Don't connect!
    if (Spoon.getInstance().isTabsChanged()) {
        MessageBox mb = new MessageBox(Spoon.getInstance().getShell(), SWT.OK);
        mb.setMessage(BaseMessages.getString(PKG, "Spoon.Dialog.WarnToSaveAllPriorToConnect.Message"));
        mb.setText(BaseMessages.getString(PKG, "Spoon.Dialog.WarnToCloseAllForce.Disconnect.Title"));
        mb.open();
        // Don't connect, user will need to save all their dirty tabs.
        return;
    }
    loginDialog = new RepositoriesDialog(shell, null, new ILoginCallback() {

        @Override
        public void onSuccess(Repository repository) {
            // Close previous repository...
            if (rep != null) {
                rep.disconnect();
                SpoonPluginManager.getInstance().notifyLifecycleListeners(SpoonLifeCycleEvent.REPOSITORY_DISCONNECTED);
            }
            setRepository(repository);
            loadSessionInformation(repository, true);
            refreshTree();
            setShellText();
            SpoonPluginManager.getInstance().notifyLifecycleListeners(SpoonLifeCycleEvent.REPOSITORY_CONNECTED);
        }

        @Override
        public void onError(Throwable t) {
            closeRepository();
            onLoginError(t);
        }

        @Override
        public void onCancel() {
        }
    });
    loginDialog.show();
}
Also used : RepositoriesDialog(org.pentaho.di.ui.repository.RepositoriesDialog) Repository(org.pentaho.di.repository.Repository) ILoginCallback(org.pentaho.di.ui.repository.ILoginCallback) MessageBox(org.eclipse.swt.widgets.MessageBox)

Aggregations

MessageBox (org.eclipse.swt.widgets.MessageBox)1 Repository (org.pentaho.di.repository.Repository)1 ILoginCallback (org.pentaho.di.ui.repository.ILoginCallback)1 RepositoriesDialog (org.pentaho.di.ui.repository.RepositoriesDialog)1