Java Code Examples for org.pentaho.di.ui.spoon.Spoon#closeRepository()

The following examples show how to use org.pentaho.di.ui.spoon.Spoon#closeRepository() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RepositoryConnectController.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
public void connectToRepository( RepositoryMeta repositoryMeta, String username, String password ) throws KettleException {
  final Repository repository = loadRepositoryObject( repositoryMeta.getId() );
  repository.init( repositoryMeta );
  repositoryConnect( repository, username, password );
  if ( username != null ) {
    getPropsUI().setLastRepositoryLogin( username );
  }
  Spoon spoon = spoonSupplier.get();
  Runnable execute = () -> {
    if ( spoon.getRepository() != null ) {
      spoon.closeRepository();
    } else {
      spoon.closeAllJobsAndTransformations( true );
    }
    spoon.setRepository( repository );
    setConnectedRepository( repositoryMeta );
    fireListeners();
    spoon.updateTreeForActiveAbstractMetas();
  };
  if ( spoon.getShell() != null ) {
    spoon.getShell().getDisplay().asyncExec( execute );
  } else {
    execute.run();
  }
}
 
Example 2
Source File: RepositoryConnectController.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
public boolean deleteRepository( String name ) {
  RepositoryMeta repositoryMeta = repositoriesMeta.findRepository( name );
  int index = repositoriesMeta.indexOfRepository( repositoryMeta );
  if ( index != -1 ) {
    repositoriesMeta.removeRepository( index );
    save();
    Spoon spoon = spoonSupplier.get();
    Runnable execute = () -> {
      if ( spoon.getRepositoryName() != null && spoon.getRepositoryName().equals( repositoryMeta.getName() ) ) {
        spoon.closeRepository();
        setConnectedRepository( null );
      }
      fireListeners();
    };
    if ( spoon.getShell() != null ) {
      spoon.getShell().getDisplay().asyncExec( execute );
    } else {
      execute.run();
    }
  }
  return true;
}