Search in sources :

Example 1 with RepositoryDialogInterface

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

the class RepositoriesHelper method newRepository.

public void newRepository() {
    PluginRegistry registry = PluginRegistry.getInstance();
    Class<? extends PluginTypeInterface> pluginType = RepositoryPluginType.class;
    List<PluginInterface> plugins = registry.getPlugins(pluginType);
    String[] names = new String[plugins.size()];
    for (int i = 0; i < names.length; i++) {
        PluginInterface plugin = plugins.get(i);
        names[i] = plugin.getName() + " - " + plugin.getDescription();
    }
    // TODO: make this a bit fancier!
    EnterSelectionDialog selectRepositoryType = new EnterSelectionDialog(this.shell, names, BaseMessages.getString(PKG, "RepositoryLogin.SelectRepositoryType"), BaseMessages.getString(PKG, "RepositoryLogin.SelectRepositoryTypeCreate"));
    String choice = selectRepositoryType.openRepoDialog();
    if (choice != null) {
        int index = selectRepositoryType.getSelectionNr();
        PluginInterface plugin = plugins.get(index);
        String id = plugin.getIds()[0];
        try {
            // With this ID we can create a new Repository object...
            // 
            RepositoryMeta repositoryMeta = PluginRegistry.getInstance().loadClass(RepositoryPluginType.class, id, RepositoryMeta.class);
            RepositoryDialogInterface dialog = getRepositoryDialog(plugin, repositoryMeta, input, this.shell);
            RepositoryMeta meta = dialog.open(MODE.ADD);
            if (meta != null) {
                // If it does then display a error to the user
                if (meta.getName() != null) {
                    input.addRepository(meta);
                    fillRepositories();
                    model.setSelectedRepository(meta);
                    writeData();
                }
            }
        } catch (Exception e) {
            log.logDetailed(BaseMessages.getString(PKG, "RepositoryLogin.ErrorCreatingRepository", e.getLocalizedMessage()));
            new ErrorDialog(shell, BaseMessages.getString(PKG, "Dialog.Error"), BaseMessages.getString(PKG, "RepositoryLogin.ErrorCreatingRepository", e.getLocalizedMessage()), e);
        }
    }
}
Also used : RepositoryPluginType(org.pentaho.di.core.plugins.RepositoryPluginType) PluginInterface(org.pentaho.di.core.plugins.PluginInterface) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) KettleException(org.pentaho.di.core.exception.KettleException) KettleSecurityException(org.pentaho.di.core.exception.KettleSecurityException) RepositoryMeta(org.pentaho.di.repository.RepositoryMeta) PluginRegistry(org.pentaho.di.core.plugins.PluginRegistry) RepositoryDialogInterface(org.pentaho.di.ui.repository.dialog.RepositoryDialogInterface) EnterSelectionDialog(org.pentaho.di.ui.core.dialog.EnterSelectionDialog)

Example 2 with RepositoryDialogInterface

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

the class RepositoriesHelper method editRepository.

public void editRepository() {
    try {
        PluginInterface plugin = null;
        RepositoryMeta ri = input.searchRepository(model.getSelectedRepository().getName());
        if (ri != null) {
            plugin = PluginRegistry.getInstance().getPlugin(RepositoryPluginType.class, ri.getId());
            if (plugin == null) {
                throw new KettleException(BaseMessages.getString(PKG, "RepositoryLogin.ErrorFindingPlugin", ri.getId()));
            }
        }
        RepositoryDialogInterface dd = getRepositoryDialog(plugin, ri, input, this.shell);
        if (dd.open(MODE.EDIT) != null) {
            fillRepositories();
            int idx = input.indexOfRepository(ri);
            model.setSelectedRepository(input.getRepository(idx));
            writeData();
        }
    } catch (Exception e) {
        log.logDetailed(BaseMessages.getString(PKG, "RepositoryLogin.ErrorEditingRepository", e.getLocalizedMessage()));
        new ErrorDialog(shell, BaseMessages.getString(PKG, "Dialog.Error"), BaseMessages.getString(PKG, "RepositoryLogin.ErrorEditingRepository", e.getLocalizedMessage()), e);
    }
}
Also used : RepositoryMeta(org.pentaho.di.repository.RepositoryMeta) KettleException(org.pentaho.di.core.exception.KettleException) RepositoryPluginType(org.pentaho.di.core.plugins.RepositoryPluginType) PluginInterface(org.pentaho.di.core.plugins.PluginInterface) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) RepositoryDialogInterface(org.pentaho.di.ui.repository.dialog.RepositoryDialogInterface) KettleException(org.pentaho.di.core.exception.KettleException) KettleSecurityException(org.pentaho.di.core.exception.KettleSecurityException)

Aggregations

KettleException (org.pentaho.di.core.exception.KettleException)2 KettleSecurityException (org.pentaho.di.core.exception.KettleSecurityException)2 PluginInterface (org.pentaho.di.core.plugins.PluginInterface)2 RepositoryPluginType (org.pentaho.di.core.plugins.RepositoryPluginType)2 RepositoryMeta (org.pentaho.di.repository.RepositoryMeta)2 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)2 RepositoryDialogInterface (org.pentaho.di.ui.repository.dialog.RepositoryDialogInterface)2 PluginRegistry (org.pentaho.di.core.plugins.PluginRegistry)1 EnterSelectionDialog (org.pentaho.di.ui.core.dialog.EnterSelectionDialog)1