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);
}
}
}
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);
}
}
Aggregations