Search in sources :

Example 1 with DatabasesCollector

use of org.pentaho.di.ui.spoon.DatabasesCollector in project pentaho-kettle by pentaho.

the class DBConnectionFolderProvider method refresh.

@Override
public void refresh(AbstractMeta meta, TreeNode treeNode, String filter) {
    DatabasesCollector collector = new DatabasesCollector(meta, spoon.getRepository());
    try {
        try {
            collector.collectDatabases();
        } catch (KettleException e) {
            if (e.getCause() instanceof KettleRepositoryLostException) {
                Spoon.getInstance().handleRepositoryLost((KettleRepositoryLostException) e.getCause());
                collector = new DatabasesCollector(meta, null);
                collector.collectDatabases();
            } else {
                throw e;
            }
        }
    } catch (KettleException e) {
        new ErrorDialog(Spoon.getInstance().getShell(), BaseMessages.getString(PKG, "Spoon.ErrorDialog.Title"), BaseMessages.getString(PKG, "Spoon.ErrorDialog.ErrorFetchingFromRepo.DbConnections"), e);
    }
    for (String dbName : collector.getDatabaseNames()) {
        if (!filterMatch(dbName, filter)) {
            continue;
        }
        DatabaseMeta databaseMeta = collector.getMetaFor(dbName);
        TreeNode childTreeNode = createTreeNode(treeNode, databaseMeta.getDisplayName(), guiResource.getImageConnectionTree());
        if (databaseMeta.isShared()) {
            childTreeNode.setFont(guiResource.getFontBold());
        }
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) DatabasesCollector(org.pentaho.di.ui.spoon.DatabasesCollector) TreeNode(org.pentaho.di.ui.core.widget.tree.TreeNode) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) KettleRepositoryLostException(org.pentaho.di.repository.KettleRepositoryLostException) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta)

Aggregations

DatabaseMeta (org.pentaho.di.core.database.DatabaseMeta)1 KettleException (org.pentaho.di.core.exception.KettleException)1 KettleRepositoryLostException (org.pentaho.di.repository.KettleRepositoryLostException)1 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)1 TreeNode (org.pentaho.di.ui.core.widget.tree.TreeNode)1 DatabasesCollector (org.pentaho.di.ui.spoon.DatabasesCollector)1