/** * Find the root of the directory tree starting from this directory. * * @return the root of the directory tree */ @Override public RepositoryDirectoryInterface findRoot() { if ( isRoot() ) { return this; } return getParent().findRoot(); }
public static RepositoryDirectoryInterface chooseDirectory( Shell shell, Repository rep, RepositoryDirectoryInterface directoryFrom ) { if ( rep == null ) { return null; } if ( directoryFrom == null ) { try { directoryFrom = rep.getUserHomeDirectory(); } catch ( KettleException ex ) { directoryFrom = new RepositoryDirectory(); } } ObjectId idDirectoryFrom = directoryFrom.getObjectId(); SelectDirectoryDialog sdd = new SelectDirectoryDialog( shell, SWT.NONE, rep ); //PDI-13867: root dir and its direct subdirectories are restricted. HashSet<String> restrictedPaths = new HashSet<String>(); restrictedPaths.add( directoryFrom.findRoot().getPath() ); restrictedPaths.add( "/home" ); sdd.setRestrictedPaths( restrictedPaths ); //TODO: expand and select directoryFrom in the dialog. RepositoryDirectoryInterface rd = sdd.open(); if ( rd == null || idDirectoryFrom == rd.getObjectId() ) { return null; } return rd; }
directory = this.repository.loadRepositoryDirectoryTree().findRoot();