private Path stripFileName( final Path path ) { String uri = path.toURI(); uri = uri.replace( path.getFileName(), "" ); return PathFactory.newPath( path.getFileSystem(), path.getFileName(), uri ); }
public void save(final Path path, final CommandWithCommitMessage saveCommand) { checkNotNull("command", saveCommand); if (path.getFileSystem().supportedFileAttributeViews().contains("version")) { new SavePopup(saveCommand).show(); } else { saveCommand.execute(""); } }
@Override public Path rename( final Path path, final String newName, final String comment ) { System.out.println( "USER:" + identity.getName() + " RENAMING asset [" + path.getFileName() + "] to [" + newName + "]" ); String originalFileName = path.getFileName().substring( path.getFileName().lastIndexOf( "/" ) + 1 ); final String extension = originalFileName.substring( originalFileName.indexOf( "." ) ); final String targetName = path.getFileName().substring( 0, path.getFileName().lastIndexOf( "/" ) + 1 ) + newName + extension; final String targetURI = path.toURI().substring( 0, path.toURI().lastIndexOf( "/" ) + 1 ) + newName + extension; final Path targetPath = PathFactory.newPath( path.getFileSystem(), targetName, targetURI ); ioService.move( paths.convert( path ), paths.convert( targetPath ), new CommentedOption( identity.getName(), comment ) ); resourceRenamedEvent.fire( new ResourceRenamedEvent( path, targetPath ) ); return targetPath; }
@Override public Path copy( final Path path, final String newName, final String comment ) { System.out.println( "USER:" + identity.getName() + " COPYING asset [" + path.getFileName() + "] to [" + newName + "]" ); String originalFileName = path.getFileName().substring( path.getFileName().lastIndexOf( "/" ) + 1 ); final String extension = originalFileName.substring( originalFileName.indexOf( "." ) ); final String targetName = path.getFileName().substring( 0, path.getFileName().lastIndexOf( "/" ) + 1 ) + newName + extension; final String targetURI = path.toURI().substring( 0, path.toURI().lastIndexOf( "/" ) + 1 ) + newName + extension; final Path targetPath = PathFactory.newPath( path.getFileSystem(), targetName, targetURI ); ioService.copy( paths.convert( path ), paths.convert( targetPath ), new CommentedOption( identity.getName(), comment ) ); resourceCopiedEvent.fire( new ResourceCopiedEvent( path, targetPath ) ); return targetPath; }
public void onClick( ClickEvent event ) { final Path path = PathFactory.newPath( metadata.getPath().getFileSystem(), metadata.getPath().getFileName(), history.getValue( history.getSelectedIndex() ) ); placeManager().goTo( new ReadOnlyPathPlaceRequest( path ) ); }