Search in sources :

Example 1 with RepositoryExplorerCallback

use of org.pentaho.di.ui.repository.repositoryexplorer.RepositoryExplorerCallback 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 RepositoryExplorerCallback

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

the class ExplorerHarness method main.

/**
 * @param args
 */
@SuppressWarnings("nls")
public static void main(String[] args) {
    KettleDatabaseRepositoryMeta repositoryMeta;
    KettleDatabaseRepository repository;
    @SuppressWarnings("unused") UserInfo userInfo;
    repositoryMeta = new KettleDatabaseRepositoryMeta();
    repositoryMeta.setName("Kettle Database Repository");
    repositoryMeta.setDescription("Kettle database test repository");
    DatabaseMeta connection = new DatabaseMeta();
    connection.setDatabaseType("Hypersonic");
    connection.setHostname("localhost");
    connection.setDBName("kettle_repository_4x");
    connection.setDBPort("9002");
    connection.setUsername("sa");
    repositoryMeta.setConnection(connection);
    userInfo = new UserInfo("admin", "admin", "Administrator", "The system administrator", true);
    repository = new KettleDatabaseRepository();
    repository.init(repositoryMeta);
    @SuppressWarnings("unused") RepositoryExplorerCallback cb = new RepositoryExplorerCallback() {

        public boolean open(UIRepositoryContent element, String revision) throws Exception {
            System.out.println("Name: ".concat(element.getName()));
            System.out.println("Type: ".concat(element.getRepositoryElementType().name()));
            System.out.println("Directory: ".concat(element.getRepositoryDirectory().toString()));
            System.out.println("Revision: ".concat(revision == null ? "null" : revision));
            // do not close explorer
            return false;
        }

        @Override
        public boolean error(String message) throws Exception {
            System.out.println("Error message: ".concat(message));
            return true;
        }
    };
/*
     * try { repository.connect(userInfo.getLogin(), userInfo.getPassword()); //RepositoryExplorer explorer = new
     * RepositoryExplorer(new Shell(), repository, cb, null); //explorer.show(); } catch (XulException e) {
     * e.printStackTrace(); } catch (KettleSecurityException e) { e.printStackTrace(); } catch (KettleException e) {
     * e.printStackTrace(); }
     */
}
Also used : KettleDatabaseRepositoryMeta(org.pentaho.di.repository.kdr.KettleDatabaseRepositoryMeta) UIRepositoryContent(org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryContent) UserInfo(org.pentaho.di.repository.UserInfo) KettleDatabaseRepository(org.pentaho.di.repository.kdr.KettleDatabaseRepository) RepositoryExplorerCallback(org.pentaho.di.ui.repository.repositoryexplorer.RepositoryExplorerCallback) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta)

Aggregations

RepositoryExplorerCallback (org.pentaho.di.ui.repository.repositoryexplorer.RepositoryExplorerCallback)2 UIRepositoryContent (org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryContent)2 DatabaseMeta (org.pentaho.di.core.database.DatabaseMeta)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 UserInfo (org.pentaho.di.repository.UserInfo)1 KettleDatabaseRepository (org.pentaho.di.repository.kdr.KettleDatabaseRepository)1 KettleDatabaseRepositoryMeta (org.pentaho.di.repository.kdr.KettleDatabaseRepositoryMeta)1 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)1 RepositoryDialogInterface (org.pentaho.di.ui.repository.dialog.RepositoryDialogInterface)1 RepositoryExplorer (org.pentaho.di.ui.repository.repositoryexplorer.RepositoryExplorer)1 KettleWaitBox (org.pentaho.di.ui.xul.KettleWaitBox)1 WaitBoxRunnable (org.pentaho.ui.xul.components.WaitBoxRunnable)1