This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository scmwebeditor. See http://git.nuiton.org/scmwebeditor.git commit c1bb575d53ed63a879ff560f0af62732c8d86ec4 Author: Hugo PIGEON <hpigeon@codelutin.com> Date: Fri May 29 11:25:51 2015 +0200 Add the ability to move a file on the repository --- .../org/nuiton/scmwebeditor/git/GitConnection.java | 267 +++++++++++++++++---- .../org/nuiton/scmwebeditor/api/ScmConnection.java | 12 +- .../api/dto/{RemoveDto.java => MoveFileDto.java} | 17 +- .../api/dto/{RemoveDto.java => RemoveFileDto.java} | 2 +- .../api/dto/{UploadDto.java => UploadFileDto.java} | 2 +- ...RemoveResultDto.java => MoveFileResultDto.java} | 2 +- ...moveResultDto.java => RemoveFileResultDto.java} | 2 +- ...loadResultDto.java => UploadFileResultDto.java} | 2 +- .../org/nuiton/scmwebeditor/svn/SvnConnection.java | 162 +++++++++++-- .../uiweb/actions/CreateDirectoryAction.java | 2 +- .../{RemoveAction.java => MoveFileAction.java} | 43 +++- .../uiweb/actions/RemoveDirectoryAction.java | 2 +- .../{RemoveAction.java => RemoveFileAction.java} | 22 +- .../{UploadAction.java => UploadFileAction.java} | 18 +- .../i18n/scmwebeditor-ui-web_en_GB.properties | 5 + .../i18n/scmwebeditor-ui-web_fr_FR.properties | 5 + swe-ui-web/src/main/resources/struts.xml | 29 ++- .../src/main/webapp/WEB-INF/content/browse.jsp | 14 +- .../webapp/WEB-INF/content/modificationViewer.jsp | 71 ++---- .../popups/{uploadForm.jsp => moveFileForm.jsp} | 58 +++-- .../{removeSuccess.jsp => moveFileSuccess.jsp} | 4 +- .../popups/{removeForm.jsp => removeFileForm.jsp} | 2 +- .../{removeSuccess.jsp => removeFileSuccess.jsp} | 0 .../popups/{uploadForm.jsp => uploadFileForm.jsp} | 2 +- .../{uploadSuccess.jsp => uploadFileSuccess.jsp} | 0 swe-ui-web/src/main/webapp/css/main.css | 44 ++-- swe-ui-web/src/main/webapp/js/editor.js | 50 ++++ 27 files changed, 617 insertions(+), 222 deletions(-) diff --git a/swe-git/src/main/java/org/nuiton/scmwebeditor/git/GitConnection.java b/swe-git/src/main/java/org/nuiton/scmwebeditor/git/GitConnection.java index 57d0cce..fadcc9b 100644 --- a/swe-git/src/main/java/org/nuiton/scmwebeditor/git/GitConnection.java +++ b/swe-git/src/main/java/org/nuiton/scmwebeditor/git/GitConnection.java @@ -406,9 +406,9 @@ public class GitConnection implements ScmConnection { handlePushException(e); if (e.getMessage().endsWith("not authorized")) { - resultDto.setError(RemoveResultDto.AUTH_ERROR); + resultDto.setError(RemoveFileResultDto.AUTH_ERROR); } else { - resultDto.setError(RemoveResultDto.ERROR); + resultDto.setError(RemoveFileResultDto.ERROR); } return resultDto; @@ -428,9 +428,9 @@ public class GitConnection implements ScmConnection { } @Override - public UploadResultDto uploadFile(UploadDto dto) { + public UploadFileResultDto uploadFile(UploadFileDto dto) { - UploadResultDto resultDto = new UploadResultDto(); + UploadFileResultDto resultDto = new UploadFileResultDto(); // getting the last version of the repository try { @@ -441,7 +441,7 @@ public class GitConnection implements ScmConnection { log.error("Error while cloning or pulling the repository", e); } - resultDto.setError(UploadResultDto.ERROR); + resultDto.setError(UploadFileResultDto.ERROR); return resultDto; } catch (IOException e) { @@ -449,7 +449,7 @@ public class GitConnection implements ScmConnection { if (log.isErrorEnabled()) { log.error("Error while cloning or pulling the repository", e); } - resultDto.setError(UploadResultDto.ERROR); + resultDto.setError(UploadFileResultDto.ERROR); return resultDto; } catch (AuthenticationException e) { @@ -457,7 +457,7 @@ public class GitConnection implements ScmConnection { if (log.isErrorEnabled()) { log.error("Error while cloning or pulling the repository", e); } - resultDto.setError(UploadResultDto.AUTH_ERROR); + resultDto.setError(UploadFileResultDto.AUTH_ERROR); return resultDto; } @@ -466,7 +466,7 @@ public class GitConnection implements ScmConnection { // if there is no file to upload, we get back to the upload form if (dto.getUpload() == null) { - resultDto.setError(UploadResultDto.REDIRECT); + resultDto.setError(UploadFileResultDto.REDIRECT); return resultDto; } @@ -495,7 +495,7 @@ public class GitConnection implements ScmConnection { log.error("Can't copy the file to the local directory", e); } - resultDto.setError(UploadResultDto.ERROR); + resultDto.setError(UploadFileResultDto.ERROR); return resultDto; } @@ -533,7 +533,7 @@ public class GitConnection implements ScmConnection { log.error("Can not commit", e); } - resultDto.setError(UploadResultDto.ERROR); + resultDto.setError(UploadFileResultDto.ERROR); return resultDto; } @@ -555,9 +555,9 @@ public class GitConnection implements ScmConnection { handlePushException(e); if (e.getMessage().endsWith("not authorized")) { - resultDto.setError(RemoveResultDto.AUTH_ERROR); + resultDto.setError(RemoveFileResultDto.AUTH_ERROR); } else { - resultDto.setError(RemoveResultDto.ERROR); + resultDto.setError(RemoveFileResultDto.ERROR); } return resultDto; @@ -568,7 +568,7 @@ public class GitConnection implements ScmConnection { } file.delete(); - resultDto.setError(UploadResultDto.ERROR); + resultDto.setError(UploadFileResultDto.ERROR); return resultDto; } @@ -576,9 +576,9 @@ public class GitConnection implements ScmConnection { } @Override - public RemoveResultDto removeFile(RemoveDto dto) { + public RemoveFileResultDto removeFile(RemoveFileDto dto) { - RemoveResultDto resultDto = new RemoveResultDto(); + RemoveFileResultDto resultDto = new RemoveFileResultDto(); // getting the last version of the repository try { @@ -589,7 +589,7 @@ public class GitConnection implements ScmConnection { log.error("Error while cloning or pulling the repository", e); } - resultDto.setError(RemoveResultDto.ERROR); + resultDto.setError(RemoveFileResultDto.ERROR); return resultDto; } catch (IOException e) { @@ -597,7 +597,7 @@ public class GitConnection implements ScmConnection { if (log.isErrorEnabled()) { log.error("Error while cloning or pulling the repository", e); } - resultDto.setError(RemoveResultDto.ERROR); + resultDto.setError(RemoveFileResultDto.ERROR); return resultDto; } catch (AuthenticationException e) { @@ -605,7 +605,7 @@ public class GitConnection implements ScmConnection { if (log.isErrorEnabled()) { log.error("Error while cloning or pulling the repository", e); } - resultDto.setError(RemoveResultDto.AUTH_ERROR); + resultDto.setError(RemoveFileResultDto.AUTH_ERROR); return resultDto; } @@ -615,13 +615,13 @@ public class GitConnection implements ScmConnection { // if there is no file to remove, we get back to the remove form if (dto.getScmPath() == null) { - resultDto.setError(RemoveResultDto.REDIRECT); + resultDto.setError(RemoveFileResultDto.REDIRECT); return resultDto; } else if (dto.getScmPath().equals("")) { - resultDto.setError(RemoveResultDto.REDIRECT); + resultDto.setError(RemoveFileResultDto.REDIRECT); return resultDto; } else if (dto.getScmPath().equals(addressGit)) { - resultDto.setError(RemoveResultDto.REDIRECT); + resultDto.setError(RemoveFileResultDto.REDIRECT); return resultDto; } @@ -662,7 +662,7 @@ public class GitConnection implements ScmConnection { log.error("Can not remove Git file " + pathOnRepo, e); } - resultDto.setError(RemoveResultDto.ERROR); + resultDto.setError(RemoveFileResultDto.ERROR); return resultDto; } file.delete(); @@ -675,7 +675,7 @@ public class GitConnection implements ScmConnection { log.error("Can not commit", e); } - resultDto.setError(RemoveResultDto.ERROR); + resultDto.setError(RemoveFileResultDto.ERROR); return resultDto; } @@ -707,9 +707,9 @@ public class GitConnection implements ScmConnection { } if (e.getMessage().endsWith("not authorized")) { - resultDto.setError(RemoveResultDto.AUTH_ERROR); + resultDto.setError(RemoveFileResultDto.AUTH_ERROR); } else { - resultDto.setError(RemoveResultDto.ERROR); + resultDto.setError(RemoveFileResultDto.ERROR); } return resultDto; @@ -719,7 +719,7 @@ public class GitConnection implements ScmConnection { log.error("Can not open git local repository : " + localDirectory.getAbsolutePath(), e); } - resultDto.setError(RemoveResultDto.ERROR); + resultDto.setError(RemoveFileResultDto.ERROR); return resultDto; } @@ -740,7 +740,7 @@ public class GitConnection implements ScmConnection { log.error("Error while cloning or pulling the repository", e); } - resultDto.setError(UploadResultDto.ERROR); + resultDto.setError(UploadFileResultDto.ERROR); return resultDto; } catch (IOException e) { @@ -748,7 +748,7 @@ public class GitConnection implements ScmConnection { if (log.isErrorEnabled()) { log.error("Error while cloning or pulling the repository", e); } - resultDto.setError(UploadResultDto.ERROR); + resultDto.setError(UploadFileResultDto.ERROR); return resultDto; } catch (AuthenticationException e) { @@ -756,7 +756,7 @@ public class GitConnection implements ScmConnection { if (log.isErrorEnabled()) { log.error("Error while cloning or pulling the repository", e); } - resultDto.setError(UploadResultDto.AUTH_ERROR); + resultDto.setError(UploadFileResultDto.AUTH_ERROR); return resultDto; } @@ -766,13 +766,13 @@ public class GitConnection implements ScmConnection { // if the name of the new directory is empty we get back to the create directory form if (dto.getDirectoryName() == null) { - resultDto.setError(UploadResultDto.REDIRECT); + resultDto.setError(UploadFileResultDto.REDIRECT); return resultDto; } if (dto.getDirectoryName().equals("")) { - resultDto.setError(UploadResultDto.REDIRECT); + resultDto.setError(UploadFileResultDto.REDIRECT); return resultDto; } @@ -840,7 +840,7 @@ public class GitConnection implements ScmConnection { log.error("Can not commit", e); } - resultDto.setError(UploadResultDto.ERROR); + resultDto.setError(UploadFileResultDto.ERROR); return resultDto; } @@ -863,9 +863,9 @@ public class GitConnection implements ScmConnection { handlePushException(e); if (e.getMessage().endsWith("not authorized")) { - resultDto.setError(RemoveResultDto.AUTH_ERROR); + resultDto.setError(RemoveFileResultDto.AUTH_ERROR); } else { - resultDto.setError(RemoveResultDto.ERROR); + resultDto.setError(RemoveFileResultDto.ERROR); } return resultDto; @@ -877,7 +877,7 @@ public class GitConnection implements ScmConnection { emptyFile.delete(); file.delete(); - resultDto.setError(UploadResultDto.ERROR); + resultDto.setError(UploadFileResultDto.ERROR); return resultDto; } @@ -898,7 +898,7 @@ public class GitConnection implements ScmConnection { log.error("Error while cloning or pulling the repository", e); } - resultDto.setError(RemoveResultDto.ERROR); + resultDto.setError(RemoveFileResultDto.ERROR); return resultDto; } catch (IOException e) { @@ -906,7 +906,7 @@ public class GitConnection implements ScmConnection { if (log.isErrorEnabled()) { log.error("Error while cloning or pulling the repository", e); } - resultDto.setError(RemoveResultDto.ERROR); + resultDto.setError(RemoveFileResultDto.ERROR); return resultDto; } catch (AuthenticationException e) { @@ -914,7 +914,7 @@ public class GitConnection implements ScmConnection { if (log.isErrorEnabled()) { log.error("Error while cloning or pulling the repository", e); } - resultDto.setError(RemoveResultDto.AUTH_ERROR); + resultDto.setError(RemoveFileResultDto.AUTH_ERROR); return resultDto; } @@ -924,11 +924,11 @@ public class GitConnection implements ScmConnection { // if there is no file to remove, we get back to the remove form if (dto.getDirectoryToRemove() == null) { - resultDto.setError(RemoveResultDto.REDIRECT); + resultDto.setError(RemoveFileResultDto.REDIRECT); return resultDto; } if (dto.getDirectoryToRemove().equals("") || dto.getDirectoryToRemove().equals(addressGit)) { - resultDto.setError(RemoveResultDto.REDIRECT); + resultDto.setError(RemoveFileResultDto.REDIRECT); return resultDto; } @@ -962,10 +962,10 @@ public class GitConnection implements ScmConnection { rm.call(); } catch (GitAPIException e) { if (log.isErrorEnabled()) { - log.error("Can not remove Git remove " + pathOnRepo, e); + log.error("Can not execute Git remove " + pathOnRepo, e); } - resultDto.setError(RemoveResultDto.ERROR); + resultDto.setError(RemoveFileResultDto.ERROR); return resultDto; } directory.delete(); @@ -978,7 +978,7 @@ public class GitConnection implements ScmConnection { log.error("Can not commit", e); } - resultDto.setError(RemoveResultDto.ERROR); + resultDto.setError(RemoveFileResultDto.ERROR); return resultDto; } @@ -1010,9 +1010,9 @@ public class GitConnection implements ScmConnection { } if (e.getMessage().endsWith("not authorized")) { - resultDto.setError(RemoveResultDto.AUTH_ERROR); + resultDto.setError(RemoveFileResultDto.AUTH_ERROR); } else { - resultDto.setError(RemoveResultDto.ERROR); + resultDto.setError(RemoveFileResultDto.ERROR); } return resultDto; @@ -1022,7 +1022,182 @@ public class GitConnection implements ScmConnection { log.error("Can not open git local repository : " + localDirectory.getAbsolutePath(), e); } - resultDto.setError(RemoveResultDto.ERROR); + resultDto.setError(RemoveFileResultDto.ERROR); + return resultDto; + } + + return resultDto; + } + + @Override + public MoveFileResultDto moveFile(MoveFileDto dto) { + + MoveFileResultDto resultDto = new MoveFileResultDto(); + + // getting the last version of the repository + try { + updateRepository(dto.getUsername(), dto.getPassword()); + } catch (RepositoryNotFoundException e) { + + if (log.isErrorEnabled()) { + log.error("Error while cloning or pulling the repository", e); + } + + resultDto.setError(RemoveFileResultDto.ERROR); + return resultDto; + + } catch (IOException e) { + + if (log.isErrorEnabled()) { + log.error("Error while cloning or pulling the repository", e); + } + resultDto.setError(RemoveFileResultDto.ERROR); + return resultDto; + + } catch (AuthenticationException e) { + + if (log.isErrorEnabled()) { + log.error("Error while cloning or pulling the repository", e); + } + resultDto.setError(RemoveFileResultDto.AUTH_ERROR); + return resultDto; + } + + resultDto.setFileRoot(addressGit); + resultDto.setScmRoot(addressGit); + + // if the name of the file to move is empty we get back to the move a file form + if (dto.getFileToMove() == null) { + resultDto.setError(MoveFileResultDto.REDIRECT); + return resultDto; + } + + if (dto.getFileToMove().equals("") || dto.getFileToMove().equals(resultDto.getFileRoot())) { + resultDto.setError(MoveFileResultDto.REDIRECT); + return resultDto; + } + + // if the name of the destination directory is empty we get back to the move a file form + if (dto.getDestinationDirectory() == null) { + resultDto.setError(MoveFileResultDto.REDIRECT); + return resultDto; + } + + if (dto.getDestinationDirectory().equals("")) { + resultDto.setError(MoveFileResultDto.REDIRECT); + return resultDto; + } + + // Moving the file on the local directory + String pathOnRepoFile = dto.getFileToMove(); + + if (pathOnRepoFile.length() > addressGit.length()) { + pathOnRepoFile = pathOnRepoFile.replace(addressGit + "/", ""); + } + + String pathOnRepoDirectory = dto.getDestinationDirectory(); + + if (pathOnRepoDirectory.length() > addressGit.length()) { + pathOnRepoDirectory = pathOnRepoDirectory.replace(addressGit + "/", ""); + } + + String sourceFileName = pathOnRepoFile.substring(pathOnRepoFile.lastIndexOf('/') + 1); + + File sourceFile = new File(localDirectory.getAbsolutePath() + File.separator + pathOnRepoFile); + File destFile = new File(localDirectory.getAbsolutePath() + File.separator + pathOnRepoDirectory + + File.separator + sourceFileName); + + try { + FileUtils.moveFile(sourceFile, destFile); + } catch (IOException e) { + if (log.isErrorEnabled()) { + log.error("Can not move file " + sourceFile.getAbsolutePath() + " to " + destFile.getAbsolutePath(), e); + } + return resultDto; + } + + // authentication + if (dto.getUsername() == null) { + dto.setUsername("anonymous"); + } + + if (dto.getPassword() == null) { + dto.setPassword("anonymous"); + } + + CredentialsProvider credentials = new UsernamePasswordCredentialsProvider(dto.getUsername(), dto.getPassword()); + + try { + Git git = Git.open(localDirectory); + + // adding the moved file + AddCommand add = git.add(); + add.addFilepattern(pathOnRepoDirectory + "/" + sourceFileName); + try { + add.call(); + } catch (GitAPIException e) { + if (log.isErrorEnabled()) { + log.error("Can not execute Git add " + pathOnRepoDirectory + "/" + sourceFileName, e); + } + + resultDto.setError(MoveFileResultDto.ERROR); + return resultDto; + } + + // commit + try { + doCommit(git, dto.getUsername(), "unknown", "From scmwebeditor -- move the file : " + pathOnRepoFile + + " to : " + pathOnRepoDirectory); + } catch (GitAPIException e) { + if (log.isErrorEnabled()) { + log.error("Can not commit", e); + } + + resultDto.setError(MoveFileResultDto.ERROR); + return resultDto; + } + + // push + if (log.isDebugEnabled()) { + log.debug("Preparing push"); + } + + PushCommand push = git.push(); + push.setRemote(addressGit); + push.setCredentialsProvider(credentials); + + try { + push.call(); + } catch (GitAPIException e) { + + handlePushException(e); + + try { + cloneRepository(credentials); + } catch (AuthenticationException e1) { + if (log.isErrorEnabled()) { + log.error("Can not clone repository at address " + addressGit); + } + } catch (RepositoryNotFoundException e1) { + if (log.isErrorEnabled()) { + log.error("Can not clone repository at address " + addressGit); + } + } + + if (e.getMessage().endsWith("not authorized")) { + resultDto.setError(MoveFileResultDto.AUTH_ERROR); + } else { + resultDto.setError(MoveFileResultDto.ERROR); + } + + return resultDto; + } + } catch (IOException e) { + if (log.isErrorEnabled()) { + log.error("Can not open git local repository : " + localDirectory.getAbsolutePath(), e); + } + + resultDto.setError(MoveFileResultDto.ERROR); return resultDto; } diff --git a/swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/ScmConnection.java b/swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/ScmConnection.java index 682c57e..65010ec 100644 --- a/swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/ScmConnection.java +++ b/swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/ScmConnection.java @@ -53,7 +53,7 @@ public interface ScmConnection { * @param dto the DTO which contains all the parameters * @return a DTO which contains all the results */ - UploadResultDto uploadFile(UploadDto dto); + UploadFileResultDto uploadFile(UploadFileDto dto); /** @@ -61,7 +61,7 @@ public interface ScmConnection { * @param dto the DTO which contains all the parameters * @return a DTO which contains all the results */ - RemoveResultDto removeFile(RemoveDto dto); + RemoveFileResultDto removeFile(RemoveFileDto dto); /** @@ -81,6 +81,14 @@ public interface ScmConnection { /** + * Moves a file to a directory in the repository + * @param dto the DTO which contains all the parameters + * @return a DTo which contains all the results + */ + MoveFileResultDto moveFile(MoveFileDto dto); + + + /** * Gives the content of a file as a String * @param path the path to the file to get the content from * @param username the user's login for the SCM diff --git a/swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/dto/RemoveDto.java b/swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/dto/MoveFileDto.java similarity index 73% copy from swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/dto/RemoveDto.java copy to swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/dto/MoveFileDto.java index 1e93a8d..ea653e8 100644 --- a/swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/dto/RemoveDto.java +++ b/swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/dto/MoveFileDto.java @@ -21,7 +21,7 @@ */ package org.nuiton.scmwebeditor.api.dto; -public class RemoveDto { +public class MoveFileDto { /** the username used to connect to the SCM */ protected String username; @@ -32,6 +32,12 @@ public class RemoveDto { /** path to the repository */ protected String scmPath; + /** path to the file to move */ + protected String fileToMove; + + /** path to the destination directory */ + protected String destinationDirectory; + public String getUsername() { return username; @@ -52,4 +58,13 @@ public class RemoveDto { public String getScmPath() { return scmPath; } public void setScmPath(String scmPath) { this.scmPath = scmPath; } + + public String getFileToMove() { return fileToMove; } + + public void setFileToMove(String fileToMove) { this.fileToMove = fileToMove; } + + public String getDestinationDirectory() { return destinationDirectory; } + + public void setDestinationDirectory( + String destinationDirectory) { this.destinationDirectory = destinationDirectory; } } diff --git a/swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/dto/RemoveDto.java b/swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/dto/RemoveFileDto.java similarity index 98% rename from swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/dto/RemoveDto.java rename to swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/dto/RemoveFileDto.java index 1e93a8d..0ab5415 100644 --- a/swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/dto/RemoveDto.java +++ b/swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/dto/RemoveFileDto.java @@ -21,7 +21,7 @@ */ package org.nuiton.scmwebeditor.api.dto; -public class RemoveDto { +public class RemoveFileDto { /** the username used to connect to the SCM */ protected String username; diff --git a/swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/dto/UploadDto.java b/swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/dto/UploadFileDto.java similarity index 98% rename from swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/dto/UploadDto.java rename to swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/dto/UploadFileDto.java index ed7a053..7418463 100644 --- a/swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/dto/UploadDto.java +++ b/swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/dto/UploadFileDto.java @@ -2,7 +2,7 @@ package org.nuiton.scmwebeditor.api.dto; import java.io.File; -public class UploadDto { +public class UploadFileDto { /** the username used to connect to the SCM */ protected String username; diff --git a/swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/dto/result/RemoveResultDto.java b/swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/dto/result/MoveFileResultDto.java similarity index 95% copy from swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/dto/result/RemoveResultDto.java copy to swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/dto/result/MoveFileResultDto.java index 37917ac..5e216ac 100644 --- a/swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/dto/result/RemoveResultDto.java +++ b/swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/dto/result/MoveFileResultDto.java @@ -21,7 +21,7 @@ */ package org.nuiton.scmwebeditor.api.dto.result; -public class RemoveResultDto extends AbstractResultDto { +public class MoveFileResultDto extends AbstractResultDto { public static String REDIRECT = "redirect"; diff --git a/swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/dto/result/RemoveResultDto.java b/swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/dto/result/RemoveFileResultDto.java similarity index 95% rename from swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/dto/result/RemoveResultDto.java rename to swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/dto/result/RemoveFileResultDto.java index 37917ac..df30d81 100644 --- a/swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/dto/result/RemoveResultDto.java +++ b/swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/dto/result/RemoveFileResultDto.java @@ -21,7 +21,7 @@ */ package org.nuiton.scmwebeditor.api.dto.result; -public class RemoveResultDto extends AbstractResultDto { +public class RemoveFileResultDto extends AbstractResultDto { public static String REDIRECT = "redirect"; diff --git a/swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/dto/result/UploadResultDto.java b/swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/dto/result/UploadFileResultDto.java similarity index 95% rename from swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/dto/result/UploadResultDto.java rename to swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/dto/result/UploadFileResultDto.java index 0ba235e..e48d397 100644 --- a/swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/dto/result/UploadResultDto.java +++ b/swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/dto/result/UploadFileResultDto.java @@ -21,7 +21,7 @@ */ package org.nuiton.scmwebeditor.api.dto.result; -public class UploadResultDto extends AbstractResultDto { +public class UploadFileResultDto extends AbstractResultDto { public static String REDIRECT = "redirect"; diff --git a/swe-svn/src/main/java/org/nuiton/scmwebeditor/svn/SvnConnection.java b/swe-svn/src/main/java/org/nuiton/scmwebeditor/svn/SvnConnection.java index 64e65dc..d8808bc 100644 --- a/swe-svn/src/main/java/org/nuiton/scmwebeditor/svn/SvnConnection.java +++ b/swe-svn/src/main/java/org/nuiton/scmwebeditor/svn/SvnConnection.java @@ -413,9 +413,9 @@ public class SvnConnection implements ScmConnection { @Override - public UploadResultDto uploadFile(UploadDto dto) { + public UploadFileResultDto uploadFile(UploadFileDto dto) { - UploadResultDto resultDto = new UploadResultDto(); + UploadFileResultDto resultDto = new UploadFileResultDto(); if (dto.getUsername() == null) { dto.setUsername("anonymous"); @@ -446,7 +446,7 @@ public class SvnConnection implements ScmConnection { log.debug("Test connection fail", e); } - resultDto.setError(UploadResultDto.CONNECTION_FAILED); + resultDto.setError(UploadFileResultDto.CONNECTION_FAILED); return resultDto; } @@ -454,7 +454,7 @@ public class SvnConnection implements ScmConnection { // if there is no file to upload we get back to the upload form if (dto.getUpload() == null) { - resultDto.setError(UploadResultDto.REDIRECT); + resultDto.setError(UploadFileResultDto.REDIRECT); return resultDto; } @@ -473,7 +473,7 @@ public class SvnConnection implements ScmConnection { if (log.isErrorEnabled()) { log.error("authentication fail", authexep); } - resultDto.setError(UploadResultDto.AUTH_ERROR); + resultDto.setError(UploadFileResultDto.AUTH_ERROR); return resultDto; @@ -482,7 +482,7 @@ public class SvnConnection implements ScmConnection { if (log.isErrorEnabled()) { log.error("Error SVN import", e); } - resultDto.setError(UploadResultDto.ERROR); + resultDto.setError(UploadFileResultDto.ERROR); return resultDto; @@ -492,9 +492,9 @@ public class SvnConnection implements ScmConnection { } @Override - public RemoveResultDto removeFile(RemoveDto dto) { + public RemoveFileResultDto removeFile(RemoveFileDto dto) { - RemoveResultDto resultDto = new RemoveResultDto(); + RemoveFileResultDto resultDto = new RemoveFileResultDto(); if (dto.getUsername() == null) { dto.setUsername("anonymous"); @@ -525,7 +525,7 @@ public class SvnConnection implements ScmConnection { log.debug("Test connection fail", e); } - resultDto.setError(UploadResultDto.CONNECTION_FAILED); + resultDto.setError(RemoveFileResultDto.CONNECTION_FAILED); return resultDto; } @@ -533,7 +533,7 @@ public class SvnConnection implements ScmConnection { // if there is no file to remove we get back to the remove form if (dto.getScmPath() == null) { - resultDto.setError(UploadResultDto.REDIRECT); + resultDto.setError(RemoveFileResultDto.REDIRECT); return resultDto; } @@ -548,7 +548,7 @@ public class SvnConnection implements ScmConnection { if (log.isErrorEnabled()) { log.error("authentication fail", authexep); } - resultDto.setError(UploadResultDto.AUTH_ERROR); + resultDto.setError(RemoveFileResultDto.AUTH_ERROR); return resultDto; @@ -557,7 +557,7 @@ public class SvnConnection implements ScmConnection { if (log.isErrorEnabled()) { log.error("Error SVN import", e); } - resultDto.setError(UploadResultDto.ERROR); + resultDto.setError(RemoveFileResultDto.ERROR); return resultDto; @@ -600,7 +600,7 @@ public class SvnConnection implements ScmConnection { log.debug("Test connection fail", e); } - resultDto.setError(UploadResultDto.CONNECTION_FAILED); + resultDto.setError(CreateDirectoryResultDto.CONNECTION_FAILED); return resultDto; } @@ -608,13 +608,13 @@ public class SvnConnection implements ScmConnection { // if the name of the new directory is empty we get back to the create directory form if (dto.getDirectoryName() == null) { - resultDto.setError(UploadResultDto.REDIRECT); + resultDto.setError(CreateDirectoryResultDto.REDIRECT); return resultDto; } if (dto.getDirectoryName().equals("")) { - resultDto.setError(UploadResultDto.REDIRECT); + resultDto.setError(CreateDirectoryResultDto.REDIRECT); return resultDto; } @@ -630,7 +630,7 @@ public class SvnConnection implements ScmConnection { if (log.isErrorEnabled()) { log.error("authentication fail", authexep); } - resultDto.setError(UploadResultDto.AUTH_ERROR); + resultDto.setError(CreateDirectoryResultDto.AUTH_ERROR); return resultDto; @@ -639,7 +639,7 @@ public class SvnConnection implements ScmConnection { if (log.isErrorEnabled()) { log.error("Error SVN import", e); } - resultDto.setError(UploadResultDto.ERROR); + resultDto.setError(CreateDirectoryResultDto.ERROR); return resultDto; @@ -682,7 +682,7 @@ public class SvnConnection implements ScmConnection { log.debug("Test connection fail", e); } - resultDto.setError(UploadResultDto.CONNECTION_FAILED); + resultDto.setError(RemoveDirectoryResultDto.CONNECTION_FAILED); return resultDto; } @@ -690,13 +690,13 @@ public class SvnConnection implements ScmConnection { // if the name of the directory to remove is empty we get back to the remove directory form if (dto.getDirectoryToRemove() == null) { - resultDto.setError(UploadResultDto.REDIRECT); + resultDto.setError(RemoveDirectoryResultDto.REDIRECT); return resultDto; } if (dto.getDirectoryToRemove().equals("") || dto.getDirectoryToRemove().equals(resultDto.getFileRoot())) { - resultDto.setError(UploadResultDto.REDIRECT); + resultDto.setError(RemoveDirectoryResultDto.REDIRECT); return resultDto; } @@ -712,7 +712,7 @@ public class SvnConnection implements ScmConnection { if (log.isErrorEnabled()) { log.error("authentication fail", authexep); } - resultDto.setError(UploadResultDto.AUTH_ERROR); + resultDto.setError(RemoveDirectoryResultDto.AUTH_ERROR); return resultDto; @@ -721,7 +721,125 @@ public class SvnConnection implements ScmConnection { if (log.isErrorEnabled()) { log.error("Error SVN import", e); } - resultDto.setError(UploadResultDto.ERROR); + resultDto.setError(RemoveDirectoryResultDto.ERROR); + + return resultDto; + + } + + return resultDto; + } + + @Override + public MoveFileResultDto moveFile(MoveFileDto dto) { + + MoveFileResultDto resultDto = new MoveFileResultDto(); + + if (dto.getUsername() == null) { + dto.setUsername("anonymous"); + } + + if (dto.getPassword() == null) { + dto.setPassword("anonymous"); + } + + resultDto.setScmRoot(getSvnRoot(dto.getUsername(), dto.getPassword())); + + if (resultDto.getScmRoot() == null) { + resultDto.setScmRoot(svnPath); + } + + if (svnPath.endsWith("/")) { + resultDto.setFileRoot(svnPath.substring(0, svnPath.lastIndexOf('/'))); + } else { + resultDto.setFileRoot(svnPath); + } + + updateAuthentication(dto.getUsername(), dto.getPassword()); + + try { + testConnection(); + } catch (SVNException e) { + if (log.isDebugEnabled()) { + log.debug("Test connection fail", e); + } + + resultDto.setError(MoveFileResultDto.CONNECTION_FAILED); + return resultDto; + } + + // if the name of the file to move is empty we get back to the move a file form + if (dto.getFileToMove() == null) { + resultDto.setError(MoveFileResultDto.REDIRECT); + return resultDto; + } + + if (dto.getFileToMove().equals("") || dto.getFileToMove().equals(resultDto.getFileRoot())) { + resultDto.setError(MoveFileResultDto.REDIRECT); + return resultDto; + } + + // if the name of the destination directory is empty we get back to the move a file form + if (dto.getDestinationDirectory() == null) { + resultDto.setError(MoveFileResultDto.REDIRECT); + return resultDto; + } + + if (dto.getDestinationDirectory().equals("")) { + resultDto.setError(MoveFileResultDto.REDIRECT); + return resultDto; + } + + // getting thr URLs + + String fileName = dto.getFileToMove().substring(dto.getFileToMove().lastIndexOf('/') + 1); + + SVNURL sourceUrl; + + try { + sourceUrl = SVNURL.parseURIEncoded(dto.getFileToMove()); + } catch (SVNException e) { + if (log.isErrorEnabled()) { + log.error("Can not get source file URL " + dto.getFileToMove(), e); + } + return resultDto; + } + + SVNURL destUrl; + + try { + destUrl = SVNURL.parseURIEncoded(dto.getDestinationDirectory() + "/" + fileName); + } catch (SVNException e) { + if (log.isErrorEnabled()) { + log.error("Can not get destination file URL " + dto.getDestinationDirectory() + "/" + fileName, e); + } + return resultDto; + } + + SVNCopySource[] sourceFileTab = new SVNCopySource[1]; + sourceFileTab[0] = new SVNCopySource(SVNRevision.HEAD, SVNRevision.HEAD, sourceUrl); + + // moving the file + SVNCopyClient copyClient = new SVNCopyClient(manager, svnOption); + + try { + copyClient.doCopy(sourceFileTab, destUrl, true, false, true, "From scmwebeditor -- move the file : " + + sourceUrl.getPath() + " to : " + destUrl.getPath(), null); + } catch (SVNAuthenticationException authexep) { + + if (log.isErrorEnabled()) { + log.error("authentication fail", authexep); + } + resultDto.setError(MoveFileResultDto.AUTH_ERROR); + + return resultDto; + + } catch (SVNException e) { + + if (log.isErrorEnabled()) { + log.error("Error SVN import", e); + } + resultDto.setError(MoveFileResultDto.ERROR); return resultDto; diff --git a/swe-ui-web/src/main/java/org/nuiton/scmwebeditor/uiweb/actions/CreateDirectoryAction.java b/swe-ui-web/src/main/java/org/nuiton/scmwebeditor/uiweb/actions/CreateDirectoryAction.java index 7d37297..665870a 100644 --- a/swe-ui-web/src/main/java/org/nuiton/scmwebeditor/uiweb/actions/CreateDirectoryAction.java +++ b/swe-ui-web/src/main/java/org/nuiton/scmwebeditor/uiweb/actions/CreateDirectoryAction.java @@ -72,7 +72,7 @@ public class CreateDirectoryAction extends AbstractScmWebEditorAction implements /** the HTTP request sent to the server */ protected transient HttpServletRequest request; - /** the full path of the file to remove */ + /** the full path of the root */ protected String fileRoot; diff --git a/swe-ui-web/src/main/java/org/nuiton/scmwebeditor/uiweb/actions/RemoveAction.java b/swe-ui-web/src/main/java/org/nuiton/scmwebeditor/uiweb/actions/MoveFileAction.java similarity index 79% copy from swe-ui-web/src/main/java/org/nuiton/scmwebeditor/uiweb/actions/RemoveAction.java copy to swe-ui-web/src/main/java/org/nuiton/scmwebeditor/uiweb/actions/MoveFileAction.java index 4c372de..1241515 100644 --- a/swe-ui-web/src/main/java/org/nuiton/scmwebeditor/uiweb/actions/RemoveAction.java +++ b/swe-ui-web/src/main/java/org/nuiton/scmwebeditor/uiweb/actions/MoveFileAction.java @@ -27,21 +27,21 @@ import org.apache.struts2.interceptor.ServletRequestAware; import org.nuiton.scmwebeditor.api.ScmConnection; import org.nuiton.scmwebeditor.api.ScmProvider; import org.nuiton.scmwebeditor.api.ScmWebEditorConfig; -import org.nuiton.scmwebeditor.api.dto.RemoveDto; -import org.nuiton.scmwebeditor.api.dto.result.RemoveResultDto; +import org.nuiton.scmwebeditor.api.dto.MoveFileDto; +import org.nuiton.scmwebeditor.api.dto.result.MoveFileResultDto; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; import java.io.File; /** - * Removes a file from the repository + * Moves a file in the repository */ -public class RemoveAction extends AbstractScmWebEditorAction implements ServletRequestAware { +public class MoveFileAction extends AbstractScmWebEditorAction implements ServletRequestAware { private static final long serialVersionUID = 4244339447567114412L; - private static final Log log = LogFactory.getLog(RemoveAction.class); + private static final Log log = LogFactory.getLog(MoveFileAction.class); public static final String REDIRECT = "redirect"; @@ -66,12 +66,18 @@ public class RemoveAction extends AbstractScmWebEditorAction implements ServletR /** the HTTP request sent to the server */ protected transient HttpServletRequest request; - /** the full path to the file to remove */ + /** the full path to the root */ protected String scmPath; - /** the full path of the file to remove */ + /** the full path of the root */ protected String fileRoot; + /** the full path to the file to move */ + protected String fileToMove; + + /** the full path of the destination directory */ + protected String destinationDirectory; + public String getUsername() { return username; @@ -125,8 +131,17 @@ public class RemoveAction extends AbstractScmWebEditorAction implements ServletR public void setFileRoot(String fileRoot) { this.fileRoot = fileRoot; } + public String getFileToMove() { return fileToMove; } + + public void setFileToMove(String fileToMove) { this.fileToMove = fileToMove; } + + public String getDestinationDirectory() { return destinationDirectory; } + + public void setDestinationDirectory( + String destinationDirectory) { this.destinationDirectory = destinationDirectory; } + /** - * Execution of the remove action + * Execution of the move a file action * @return a code interpreted in the file struts.xml */ public String execute() { @@ -153,12 +168,14 @@ public class RemoveAction extends AbstractScmWebEditorAction implements ServletR username = usernamePw[0]; pw = usernamePw[1]; - RemoveDto dto = new RemoveDto(); + MoveFileDto dto = new MoveFileDto(); dto.setUsername(username); dto.setPassword(pw); dto.setScmPath(scmPath); + dto.setFileToMove(fileToMove); + dto.setDestinationDirectory(destinationDirectory); - RemoveResultDto resultDto = scmConn.removeFile(dto); + MoveFileResultDto resultDto = scmConn.moveFile(dto); if (resultDto.getScmRoot() != null) { scmRoot = resultDto.getScmRoot(); @@ -180,7 +197,7 @@ public class RemoveAction extends AbstractScmWebEditorAction implements ServletR String errorMessage = resultDto.getError(); error = true; - if (errorMessage.equals(RemoveResultDto.CONNECTION_FAILED)) { + if (errorMessage.equals(MoveFileResultDto.CONNECTION_FAILED)) { getScmSession().delScmUser(scmConn.getRepositoryId()); username = null; @@ -188,7 +205,7 @@ public class RemoveAction extends AbstractScmWebEditorAction implements ServletR return ERROR; - } else if (errorMessage.equals(RemoveResultDto.AUTH_ERROR)) { + } else if (errorMessage.equals(MoveFileResultDto.AUTH_ERROR)) { badLogin = true; username = null; @@ -197,7 +214,7 @@ public class RemoveAction extends AbstractScmWebEditorAction implements ServletR return LOGIN; - } else if (errorMessage.equals(RemoveResultDto.REDIRECT)) { + } else if (errorMessage.equals(MoveFileResultDto.REDIRECT)) { error = false; diff --git a/swe-ui-web/src/main/java/org/nuiton/scmwebeditor/uiweb/actions/RemoveDirectoryAction.java b/swe-ui-web/src/main/java/org/nuiton/scmwebeditor/uiweb/actions/RemoveDirectoryAction.java index ffed038..244b99e 100644 --- a/swe-ui-web/src/main/java/org/nuiton/scmwebeditor/uiweb/actions/RemoveDirectoryAction.java +++ b/swe-ui-web/src/main/java/org/nuiton/scmwebeditor/uiweb/actions/RemoveDirectoryAction.java @@ -69,7 +69,7 @@ public class RemoveDirectoryAction extends AbstractScmWebEditorAction implements /** the HTTP request sent to the server */ protected transient HttpServletRequest request; - /** the full path of the file to remove */ + /** the full path of the root */ protected String fileRoot; diff --git a/swe-ui-web/src/main/java/org/nuiton/scmwebeditor/uiweb/actions/RemoveAction.java b/swe-ui-web/src/main/java/org/nuiton/scmwebeditor/uiweb/actions/RemoveFileAction.java similarity index 88% rename from swe-ui-web/src/main/java/org/nuiton/scmwebeditor/uiweb/actions/RemoveAction.java rename to swe-ui-web/src/main/java/org/nuiton/scmwebeditor/uiweb/actions/RemoveFileAction.java index 4c372de..d8f4d4d 100644 --- a/swe-ui-web/src/main/java/org/nuiton/scmwebeditor/uiweb/actions/RemoveAction.java +++ b/swe-ui-web/src/main/java/org/nuiton/scmwebeditor/uiweb/actions/RemoveFileAction.java @@ -27,8 +27,8 @@ import org.apache.struts2.interceptor.ServletRequestAware; import org.nuiton.scmwebeditor.api.ScmConnection; import org.nuiton.scmwebeditor.api.ScmProvider; import org.nuiton.scmwebeditor.api.ScmWebEditorConfig; -import org.nuiton.scmwebeditor.api.dto.RemoveDto; -import org.nuiton.scmwebeditor.api.dto.result.RemoveResultDto; +import org.nuiton.scmwebeditor.api.dto.RemoveFileDto; +import org.nuiton.scmwebeditor.api.dto.result.RemoveFileResultDto; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; @@ -37,11 +37,11 @@ import java.io.File; /** * Removes a file from the repository */ -public class RemoveAction extends AbstractScmWebEditorAction implements ServletRequestAware { +public class RemoveFileAction extends AbstractScmWebEditorAction implements ServletRequestAware { private static final long serialVersionUID = 4244339447567114412L; - private static final Log log = LogFactory.getLog(RemoveAction.class); + private static final Log log = LogFactory.getLog(RemoveFileAction.class); public static final String REDIRECT = "redirect"; @@ -66,10 +66,10 @@ public class RemoveAction extends AbstractScmWebEditorAction implements ServletR /** the HTTP request sent to the server */ protected transient HttpServletRequest request; - /** the full path to the file to remove */ + /** the full path to the root */ protected String scmPath; - /** the full path of the file to remove */ + /** the full path of the root */ protected String fileRoot; @@ -153,12 +153,12 @@ public class RemoveAction extends AbstractScmWebEditorAction implements ServletR username = usernamePw[0]; pw = usernamePw[1]; - RemoveDto dto = new RemoveDto(); + RemoveFileDto dto = new RemoveFileDto(); dto.setUsername(username); dto.setPassword(pw); dto.setScmPath(scmPath); - RemoveResultDto resultDto = scmConn.removeFile(dto); + RemoveFileResultDto resultDto = scmConn.removeFile(dto); if (resultDto.getScmRoot() != null) { scmRoot = resultDto.getScmRoot(); @@ -180,7 +180,7 @@ public class RemoveAction extends AbstractScmWebEditorAction implements ServletR String errorMessage = resultDto.getError(); error = true; - if (errorMessage.equals(RemoveResultDto.CONNECTION_FAILED)) { + if (errorMessage.equals(RemoveFileResultDto.CONNECTION_FAILED)) { getScmSession().delScmUser(scmConn.getRepositoryId()); username = null; @@ -188,7 +188,7 @@ public class RemoveAction extends AbstractScmWebEditorAction implements ServletR return ERROR; - } else if (errorMessage.equals(RemoveResultDto.AUTH_ERROR)) { + } else if (errorMessage.equals(RemoveFileResultDto.AUTH_ERROR)) { badLogin = true; username = null; @@ -197,7 +197,7 @@ public class RemoveAction extends AbstractScmWebEditorAction implements ServletR return LOGIN; - } else if (errorMessage.equals(RemoveResultDto.REDIRECT)) { + } else if (errorMessage.equals(RemoveFileResultDto.REDIRECT)) { error = false; diff --git a/swe-ui-web/src/main/java/org/nuiton/scmwebeditor/uiweb/actions/UploadAction.java b/swe-ui-web/src/main/java/org/nuiton/scmwebeditor/uiweb/actions/UploadFileAction.java similarity index 90% rename from swe-ui-web/src/main/java/org/nuiton/scmwebeditor/uiweb/actions/UploadAction.java rename to swe-ui-web/src/main/java/org/nuiton/scmwebeditor/uiweb/actions/UploadFileAction.java index a338de8..9841096 100644 --- a/swe-ui-web/src/main/java/org/nuiton/scmwebeditor/uiweb/actions/UploadAction.java +++ b/swe-ui-web/src/main/java/org/nuiton/scmwebeditor/uiweb/actions/UploadFileAction.java @@ -27,8 +27,8 @@ import org.apache.struts2.interceptor.ServletRequestAware; import org.nuiton.scmwebeditor.api.ScmConnection; import org.nuiton.scmwebeditor.api.ScmProvider; import org.nuiton.scmwebeditor.api.ScmWebEditorConfig; -import org.nuiton.scmwebeditor.api.dto.UploadDto; -import org.nuiton.scmwebeditor.api.dto.result.UploadResultDto; +import org.nuiton.scmwebeditor.api.dto.UploadFileDto; +import org.nuiton.scmwebeditor.api.dto.result.UploadFileResultDto; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; @@ -37,11 +37,11 @@ import java.io.File; /** * Uploads a file from the client to the repository */ -public class UploadAction extends AbstractScmWebEditorAction implements ServletRequestAware { +public class UploadFileAction extends AbstractScmWebEditorAction implements ServletRequestAware { private static final long serialVersionUID = 4244339447567114412L; - private static final Log log = LogFactory.getLog(UploadAction.class); + private static final Log log = LogFactory.getLog(UploadFileAction.class); public static final String REDIRECT = "redirect"; @@ -189,7 +189,7 @@ public class UploadAction extends AbstractScmWebEditorAction implements ServletR username = usernamePw[0]; pw = usernamePw[1]; - UploadDto dto = new UploadDto(); + UploadFileDto dto = new UploadFileDto(); dto.setUsername(username); dto.setPassword(pw); dto.setUpload(upload); @@ -197,7 +197,7 @@ public class UploadAction extends AbstractScmWebEditorAction implements ServletR dto.setUploadContentType(uploadContentType); dto.setScmPath(scmPath); - UploadResultDto resultDto = scmConn.uploadFile(dto); + UploadFileResultDto resultDto = scmConn.uploadFile(dto); if (resultDto.getFileRoot() != null) { fileRoot = resultDto.getFileRoot(); @@ -211,7 +211,7 @@ public class UploadAction extends AbstractScmWebEditorAction implements ServletR String errorMessage = resultDto.getError(); error = true; - if (errorMessage.equals(UploadResultDto.CONNECTION_FAILED)) { + if (errorMessage.equals(UploadFileResultDto.CONNECTION_FAILED)) { getScmSession().delScmUser(scmConn.getRepositoryId()); username = null; @@ -219,7 +219,7 @@ public class UploadAction extends AbstractScmWebEditorAction implements ServletR return ERROR; - } else if (errorMessage.equals(UploadResultDto.AUTH_ERROR)) { + } else if (errorMessage.equals(UploadFileResultDto.AUTH_ERROR)) { badLogin = true; username = null; @@ -228,7 +228,7 @@ public class UploadAction extends AbstractScmWebEditorAction implements ServletR return LOGIN; - } else if (errorMessage.equals(UploadResultDto.REDIRECT)) { + } else if (errorMessage.equals(UploadFileResultDto.REDIRECT)) { error = false; diff --git a/swe-ui-web/src/main/resources/i18n/scmwebeditor-ui-web_en_GB.properties b/swe-ui-web/src/main/resources/i18n/scmwebeditor-ui-web_en_GB.properties index fa31fb5..704d9a5 100644 --- a/swe-ui-web/src/main/resources/i18n/scmwebeditor-ui-web_en_GB.properties +++ b/swe-ui-web/src/main/resources/i18n/scmwebeditor-ui-web_en_GB.properties @@ -19,12 +19,14 @@ scm.createBranchSuccess=Branch successfully created scm.createDirectory=Create a directory scm.createDirectorySuccess=Directory created successfully scm.createDirectoryTitle=Create a new directory on the repository +scm.destinationDirectory=Destination directory\: scm.directoryToRemove=Directory to remove\: scm.exit=Exit scm.exitJavascript=Exit ScmWebEditor? scm.exitJavascriptChanges=Exit ScmWebEditor without saving? All modification will be lost. scm.exitTitle=Exit ScmWebEditor without saving. scm.fileModify=File modify while editing. +scm.fileToMove=File to move\: scm.forceSave=Force save scm.formTransferred=You should be transferred automatically to the form page. If not please scm.info.ProblemWithRst=For any problem with RestructuredText visit @@ -42,6 +44,9 @@ scm.modificationViewer.previewPosition=Preview's position\: scm.modificationViewer.previewPosition.below=Below scm.modificationViewer.previewPosition.none=No preview scm.modificationViewer.previewPosition.side=On the side +scm.moveFile=Move a file +scm.moveFileSuccess=File moved successfully +scm.moveFileTitle=Move a file on the repository scm.mustBeLog=You must be login to see this repository. scm.newDirectoryName=Name of the new directory\: scm.no=No diff --git a/swe-ui-web/src/main/resources/i18n/scmwebeditor-ui-web_fr_FR.properties b/swe-ui-web/src/main/resources/i18n/scmwebeditor-ui-web_fr_FR.properties index 364b0ed..469e56d 100644 --- a/swe-ui-web/src/main/resources/i18n/scmwebeditor-ui-web_fr_FR.properties +++ b/swe-ui-web/src/main/resources/i18n/scmwebeditor-ui-web_fr_FR.properties @@ -19,12 +19,14 @@ scm.createBranchSuccess=Branche créée avec succès scm.createDirectory=Créer un répertoire scm.createDirectorySuccess=Répertoire créé avec succès scm.createDirectoryTitle=Créer un nouveau répertoire sur le dépôt +scm.destinationDirectory=Répertoire de destination \: scm.directoryToRemove=Répertoire à supprimer \: scm.exit=Quitter scm.exitJavascript=Quitter ScmWebEditor ? scm.exitJavascriptChanges=Quitter ScmWebEditor sans sauvegarder ? Toutes les modifications seront perdues. scm.exitTitle=Quitter ScmWebEditor sans sauvegarder. scm.fileModify=Fichier modifié pendant l'édition. +scm.fileToMove=Fichier à déplacer \: scm.forceSave=Forcer la sauvegarde scm.formTransferred=Vous devriez être redirigé vers la page du formulaire. si non scm.info.ProblemWithRst=Si vous rencontrez des problèmes avec RestructuredText, visitez le @@ -42,6 +44,9 @@ scm.modificationViewer.previewPosition=Position de l'aperçu \: scm.modificationViewer.previewPosition.below=En dessous scm.modificationViewer.previewPosition.none=Pas d'aperçu scm.modificationViewer.previewPosition.side=Sur le côté +scm.moveFile=Déplacer un fichier +scm.moveFileSuccess=Fichier déplacé avec succès +scm.moveFileTitle=Déplacer un fichier au sein du dépôt scm.mustBeLog=Vous devez vous identifier pour parcourir ce dépôt. scm.newDirectoryName=Nom du nouveau répertoire \: scm.no=Non diff --git a/swe-ui-web/src/main/resources/struts.xml b/swe-ui-web/src/main/resources/struts.xml index 78449d5..e7034d4 100644 --- a/swe-ui-web/src/main/resources/struts.xml +++ b/swe-ui-web/src/main/resources/struts.xml @@ -99,18 +99,18 @@ <result>/WEB-INF/content/logout.jsp</result> </action> - <action name="doUpload" class="org.nuiton.scmwebeditor.uiweb.actions.UploadAction"> - <result>/WEB-INF/content/popups/uploadSuccess.jsp</result> - <result name="redirect" >/WEB-INF/content/popups/uploadForm.jsp</result> - <result name="login" >/WEB-INF/content/popups/uploadForm.jsp</result> - <result name="error" >/WEB-INF/content/popups/uploadForm.jsp</result> + <action name="doUploadFile" class="org.nuiton.scmwebeditor.uiweb.actions.UploadFileAction"> + <result>/WEB-INF/content/popups/uploadFileSuccess.jsp</result> + <result name="redirect" >/WEB-INF/content/popups/uploadFileForm.jsp</result> + <result name="login" >/WEB-INF/content/popups/uploadFileForm.jsp</result> + <result name="error" >/WEB-INF/content/popups/uploadFileForm.jsp</result> </action> - <action name="doRemove" class="org.nuiton.scmwebeditor.uiweb.actions.RemoveAction"> - <result>/WEB-INF/content/popups/removeSuccess.jsp</result> - <result name="redirect" >/WEB-INF/content/popups/removeForm.jsp</result> - <result name="login" >/WEB-INF/content/popups/removeForm.jsp</result> - <result name="error" >/WEB-INF/content/popups/removeForm.jsp</result> + <action name="doRemoveFile" class="org.nuiton.scmwebeditor.uiweb.actions.RemoveFileAction"> + <result>/WEB-INF/content/popups/removeFileSuccess.jsp</result> + <result name="redirect" >/WEB-INF/content/popups/removeFileForm.jsp</result> + <result name="login" >/WEB-INF/content/popups/removeFileForm.jsp</result> + <result name="error" >/WEB-INF/content/popups/removeFileForm.jsp</result> </action> <action name="doCreateDirectory" class="org.nuiton.scmwebeditor.uiweb.actions.CreateDirectoryAction"> @@ -127,6 +127,15 @@ <result name="error" >/WEB-INF/content/popups/removeDirectoryForm.jsp</result> </action> + + <action name="doMoveFile" class="org.nuiton.scmwebeditor.uiweb.actions.MoveFileAction"> + <result>/WEB-INF/content/popups/moveFileSuccess.jsp</result> + <result name="redirect" >/WEB-INF/content/popups/moveFileForm.jsp</result> + <result name="login" >/WEB-INF/content/popups/moveFileForm.jsp</result> + <result name="error" >/WEB-INF/content/popups/moveFileForm.jsp</result> + </action> + + <action name="createBranch" class="org.nuiton.scmwebeditor.uiweb.actions.CreateBranchAction"> <result name="success">/WEB-INF/content/popups/createBranchSuccess.jsp</result> <result name="redirect">/WEB-INF/content/popups/createBranchForm.jsp</result> diff --git a/swe-ui-web/src/main/webapp/WEB-INF/content/browse.jsp b/swe-ui-web/src/main/webapp/WEB-INF/content/browse.jsp index 5360bbc..bbbff4b 100644 --- a/swe-ui-web/src/main/webapp/WEB-INF/content/browse.jsp +++ b/swe-ui-web/src/main/webapp/WEB-INF/content/browse.jsp @@ -165,21 +165,31 @@ <s:text name="scm.removeDirectoryTitle"/> </s:set> + <s:set id="scm.moveFile"> + <s:text name="scm.moveFile"/> + </s:set> + <s:set id="scm.moveFileTitle"> + <s:text name="scm.moveFileTitle"/> + </s:set> + <s:set name="address"> <s:property value="address"/> </s:set> <center id="repositoryButtonsBrowse"> <s:submit name="uploadButton" value="%{scm.upload}" title="%{scm.uploadTitle}" - onClick="javascript:open_popup('doUpload.action', 'upload' , scmAddress, '%{scmType}' );"/> + onClick="javascript:open_popup('doUploadFile.action', 'upload' , scmAddress, '%{scmType}' );"/> <s:submit name="removeButton" value="%{scm.removeFile}" title="%{scm.removeFileTitle}" - onClick="javascript:open_popup('doRemove.action', 'remove' , scmAddress, '%{scmType}' );"/> + onClick="javascript:open_popup('doRemoveFile.action', 'remove' , scmAddress, '%{scmType}' );"/> <s:submit name="createDirectoryButton" value="%{scm.createDirectory}" title="%{scm.createDirectoryTitle}" onClick="javascript:open_popup('doCreateDirectory.action', 'create directory',scmAddress,'%{scmType}');"/> <s:submit name="removeDirectoryButton" value="%{scm.removeDirectory}" title="%{scm.removeDirectoryTitle}" onClick="javascript:open_popup('doRemoveDirectory.action', 'remove directory',scmAddress,'%{scmType}');"/> + + <s:submit name="moveFileButton" value="%{scm.moveFile}" title="%{scm.moveFileTitle}" + onClick="javascript:open_popup('doMoveFile.action', 'move file', scmAddress, '%{scmType}');"/> </center> </s:else> diff --git a/swe-ui-web/src/main/webapp/WEB-INF/content/modificationViewer.jsp b/swe-ui-web/src/main/webapp/WEB-INF/content/modificationViewer.jsp index 4218ecc..ac2ef6b 100644 --- a/swe-ui-web/src/main/webapp/WEB-INF/content/modificationViewer.jsp +++ b/swe-ui-web/src/main/webapp/WEB-INF/content/modificationViewer.jsp @@ -62,13 +62,6 @@ <script type="text/javascript"> - var exitAfterCommit = false; - - /* Changes the value of the new text */ - function loadChange() { - document.getElementById('newTextId').value = editor.getValue(); - } - /* Asks the user if he really wants to exit when changes are made */ function confirmExit() { var text = '<s:text name="scm.exitJavascript"/>'; @@ -87,25 +80,6 @@ } } - /* Opens the popin for the commit */ - function openPopin(popinId) { - document.getElementById(popinId).style.display = "block"; - document.getElementById("popinBackground").style.display = "block"; - } - - /* Closes the popin for the commit */ - function closePopin(popinId) { - document.getElementById(popinId).style.display = "none"; - document.getElementById("popinBackground").style.display = "none"; - } - - /* Exits the edit page if asked */ - function checkExit() { - if (exitAfterCommit) { - document.location.href = "checkout.action"; - } - } - /* Commit form validation */ $.subscribe("beforeCommit", function(event, data) { var commitMessage = document.getElementById("commitMessage").value; @@ -125,9 +99,7 @@ } }); - /* - Functions related to the browsing tree - */ + // Opens the selected file in the tree $.subscribe('treeClicked', function(event, data) { var item = event.originalEvent.data.rslt.obj; @@ -145,27 +117,10 @@ }); - // automatically expand the directory when there is no other file - $.subscribe('treeChanged', function(event, data) { - - var json = event.originalEvent.data.responseJSON; - - if (json.length == 1) { - var object = json[0]; - - if (object.state == "closed") { - var htmlObject = document.getElementById(object.id); - var children = htmlObject.children; - children.item('ins').click(); - } - } - }); - - - window.onbeforeunload = confirmExitOnUnload; - </script> + <script type="text/javascript" src="js/editor.js"></script> + <s:if test="format == 'rst'"> <script type="text/javascript" src="js/preview.js"></script> </s:if> @@ -173,6 +128,7 @@ </head> <body> + <div id="wrapper"> <form method="POST" action="commit.action" id="editForm"> @@ -357,6 +313,13 @@ <s:text name="scm.removeDirectoryTitle"/> </s:set> + <s:set id="scm.moveFile"> + <s:text name="scm.moveFile"/> + </s:set> + <s:set id="scm.moveFileTitle"> + <s:text name="scm.moveFileTitle"/> + </s:set> + <s:set name="address"> <s:property value="address"/> </s:set> @@ -364,19 +327,23 @@ <ul id="repositoryButtons"> <li> <s:submit name="uploadButton" value="%{scm.upload}" title="%{scm.uploadTitle}" - onClick="javascript:open_popup('doUpload.action', 'upload', getElementById('address').value, '%{scmType}');"/> + onClick="javascript:open_popup('doUploadFile.action', 'upload', getElementById('address').value, '%{scmType}'); return false;"/> </li> <li> <s:submit name="removeButton" value="%{scm.removeFile}" title="%{scm.removeFileTitle}" - onClick="javascript:open_popup('doRemove.action', 'remove', getElementById('address').value, '%{scmType}');"/> + onClick="javascript:open_popup('doRemoveFile.action', 'remove', getElementById('address').value, '%{scmType}'); return false;"/> </li> <li> <s:submit name="createDirectoryButton" value="%{scm.createDirectory}" title="%{scm.createDirectoryTitle}" - onClick="javascript:open_popup('doCreateDirectory.action', 'create directory',getElementById('address').value,'%{scmType}');"/> + onClick="javascript:open_popup('doCreateDirectory.action', 'create directory',getElementById('address').value,'%{scmType}'); return false;"/> </li> <li> <s:submit name="removeDirectoryButton" value="%{scm.removeDirectory}" title="%{scm.removeDirectoryTitle}" - onClick="javascript:open_popup('doRemoveDirectory.action', 'remove directory',getElementById('address').value,'%{scmType}');"/> + onClick="javascript:open_popup('doRemoveDirectory.action', 'remove directory',getElementById('address').value,'%{scmType}'); return false;"/> + </li> + <li> + <s:submit name="moveFileButton" value="%{scm.moveFile}" title="%{scm.moveFileTitle}" + onClick="javascript:open_popup('doMoveFile.action', 'move file',getElementById('address').value,'%{scmType}'); return false;"/> </li> </ul> diff --git a/swe-ui-web/src/main/webapp/WEB-INF/content/popups/uploadForm.jsp b/swe-ui-web/src/main/webapp/WEB-INF/content/popups/moveFileForm.jsp similarity index 68% copy from swe-ui-web/src/main/webapp/WEB-INF/content/popups/uploadForm.jsp copy to swe-ui-web/src/main/webapp/WEB-INF/content/popups/moveFileForm.jsp index 777a881..9b36f7c 100644 --- a/swe-ui-web/src/main/webapp/WEB-INF/content/popups/uploadForm.jsp +++ b/swe-ui-web/src/main/webapp/WEB-INF/content/popups/moveFileForm.jsp @@ -31,26 +31,38 @@ <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> - <title><s:text name="scm.titles.upload"/></title> + <title><s:text name="scm.moveFile"/></title> <link rel="stylesheet" type="text/css" href="css/main.css"> <link rel="stylesheet" type="text/css" href="css/uploadForm.css"> <link rel="icon" href="img/machine-a-ecrire_little.png" type="image/png"> - </head> <body> <sj:head debug="true" jquerytheme="default"/> <script> - $.subscribe('treeClicked', function(event, data) { + $.subscribe('treeClickedFileToMove', function(event, data) { + var item = event.originalEvent.data.rslt.obj; + + if (item.length == 1) { + var classAttr = item[0].getAttribute("class"); + + if (classAttr.contains("jstree-leaf")) { + window.document.getElementById("fileToMove").value = item.attr("id"); + } + } + + }); + + $.subscribe('treeClickedDestinationDirectory', function(event, data) { var item = event.originalEvent.data.rslt.obj; if (item.length == 1) { var classAttr = item[0].getAttribute("class"); if (!classAttr.contains("jstree-leaf")) { - window.document.getElementById("scmPath").value = item.attr("id"); + window.document.getElementById("destinationDirectory").value = item.attr("id"); } } @@ -75,30 +87,42 @@ </script> -<form method="POST" id="uploadForm" action="doUpload.action" - enctype="multipart/form-data"> +<form method="POST" id="moveFileForm" action="doMoveFile.action"> <s:hidden name="scmType" value="%{scmType}"/> - <center><h1><s:text name="scm.upload"></s:text></h1></center> - - <label><s:text name="scm.uploadFile"/> : <input type="file" - name="upload"/></label><br/> - <label><s:text name="scm.uploadPath"/> : <s:textfield size="50px" type="text" - name="scmPath" - id="scmPath" - value="%{fileRoot}"/></label><br/> + <center><h1><s:text name="scm.moveFile"></s:text></h1></center> + <label><s:text name="scm.fileToMove"/> <s:textfield size="50px" type="text" name="fileToMove" + id="fileToMove" value="%{fileRoot}"/> + </label><br/> - <div id="searchTree"> + <div id="searchTreeFileToMove"> <s:url id="searchTreeUrl" action="browse?address=%{scmRoot}&username=%{username}&pw=%{pw}&selectedBranch=%{selectedBranch}&scmType=%{scmType}"/> - <sjt:tree id="scmTree" + + <sjt:tree id="scmTreeFileToMove" + htmlTitles="true" + jstreetheme="classic" + href="%{searchTreeUrl}" + onClickTopics="treeClickedFileToMove" + onSuccessTopics="treeChanged" + /> + + </div> + + <label><s:text name="scm.destinationDirectory"/> <s:textfield size="50px" type="text" name="destinationDirectory" + id="destinationDirectory" value="%{fileRoot}"/> + </label><br/> + + <div id="searchTreeDestinationDirectory"> + + <sjt:tree id="scmTreeDestinationDirectory" htmlTitles="true" jstreetheme="classic" href="%{searchTreeUrl}" - onClickTopics="treeClicked" + onClickTopics="treeClickedDestinationDirectory" onSuccessTopics="treeChanged" /> diff --git a/swe-ui-web/src/main/webapp/WEB-INF/content/popups/removeSuccess.jsp b/swe-ui-web/src/main/webapp/WEB-INF/content/popups/moveFileSuccess.jsp similarity index 97% copy from swe-ui-web/src/main/webapp/WEB-INF/content/popups/removeSuccess.jsp copy to swe-ui-web/src/main/webapp/WEB-INF/content/popups/moveFileSuccess.jsp index b920c05..0fff419 100644 --- a/swe-ui-web/src/main/webapp/WEB-INF/content/popups/removeSuccess.jsp +++ b/swe-ui-web/src/main/webapp/WEB-INF/content/popups/moveFileSuccess.jsp @@ -27,8 +27,8 @@ <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> - <link rel="icon" href="img/machine-a-ecrire_little.png" type="image/png"> <link rel="stylesheet" type="text/css" href="css/main.css"> + <link rel="icon" href="img/machine-a-ecrire_little.png" type="image/png"> <script type="text/javascript" src="js/popup.js"></script> <title><s:text name="scm.titles.success"/></title> @@ -38,7 +38,7 @@ </head> <body> -<p><s:text name="scm.removeSuccess"/></p> +<p><s:text name="scm.moveFileSuccess"/></p> <s:set id="close"> <s:text name="scm.close"/> diff --git a/swe-ui-web/src/main/webapp/WEB-INF/content/popups/removeForm.jsp b/swe-ui-web/src/main/webapp/WEB-INF/content/popups/removeFileForm.jsp similarity index 97% rename from swe-ui-web/src/main/webapp/WEB-INF/content/popups/removeForm.jsp rename to swe-ui-web/src/main/webapp/WEB-INF/content/popups/removeFileForm.jsp index fc41c59..04a5b36 100644 --- a/swe-ui-web/src/main/webapp/WEB-INF/content/popups/removeForm.jsp +++ b/swe-ui-web/src/main/webapp/WEB-INF/content/popups/removeFileForm.jsp @@ -86,7 +86,7 @@ </script> -<form method="POST" id="removeForm" action="doRemove.action" onsubmit="return confirmRemove();"> +<form method="POST" id="removeForm" action="doRemoveFile.action" onsubmit="return confirmRemove();"> <s:hidden name="scmType" value="%{scmType}"/> diff --git a/swe-ui-web/src/main/webapp/WEB-INF/content/popups/removeSuccess.jsp b/swe-ui-web/src/main/webapp/WEB-INF/content/popups/removeFileSuccess.jsp similarity index 100% rename from swe-ui-web/src/main/webapp/WEB-INF/content/popups/removeSuccess.jsp rename to swe-ui-web/src/main/webapp/WEB-INF/content/popups/removeFileSuccess.jsp diff --git a/swe-ui-web/src/main/webapp/WEB-INF/content/popups/uploadForm.jsp b/swe-ui-web/src/main/webapp/WEB-INF/content/popups/uploadFileForm.jsp similarity index 98% rename from swe-ui-web/src/main/webapp/WEB-INF/content/popups/uploadForm.jsp rename to swe-ui-web/src/main/webapp/WEB-INF/content/popups/uploadFileForm.jsp index 777a881..a9ca7ad 100644 --- a/swe-ui-web/src/main/webapp/WEB-INF/content/popups/uploadForm.jsp +++ b/swe-ui-web/src/main/webapp/WEB-INF/content/popups/uploadFileForm.jsp @@ -75,7 +75,7 @@ </script> -<form method="POST" id="uploadForm" action="doUpload.action" +<form method="POST" id="uploadForm" action="doUploadFile.action" enctype="multipart/form-data"> <s:hidden name="scmType" value="%{scmType}"/> diff --git a/swe-ui-web/src/main/webapp/WEB-INF/content/popups/uploadSuccess.jsp b/swe-ui-web/src/main/webapp/WEB-INF/content/popups/uploadFileSuccess.jsp similarity index 100% rename from swe-ui-web/src/main/webapp/WEB-INF/content/popups/uploadSuccess.jsp rename to swe-ui-web/src/main/webapp/WEB-INF/content/popups/uploadFileSuccess.jsp diff --git a/swe-ui-web/src/main/webapp/css/main.css b/swe-ui-web/src/main/webapp/css/main.css index 02680d7..a5d3fac 100644 --- a/swe-ui-web/src/main/webapp/css/main.css +++ b/swe-ui-web/src/main/webapp/css/main.css @@ -125,25 +125,14 @@ ul.flags li { display:inline; } -#wwctrl_uploadButton, #wwctrl_removeButton, #wwctrl_createDirectoryButton, #wwctrl_removeDirectoryButton { - display: inline; -} - -#repositoryButtonsBrowse #wwctrl_uploadButton { - margin-right: 1%; -} - -#repositoryButtonsBrowse #wwctrl_removeButton, #repositoryButtonsBrowse #wwctrl_createDirectoryButton { - margin-left: 1%; - margin-right: 1%; -} - -#repositoryButtonsBrowse #wwctrl_removeDirectoryButton { - margin-left: 1%; +#repositoryButtonsBrowse { + display: table; + border-spacing: 10px; + margin: auto; } -#repositoryButtonsBrowse #wwgrp_username { - float:left; +#repositoryButtonsBrowse div { + display: table-cell; } #wrapperConfig { @@ -230,7 +219,7 @@ ul.flags li { width:170px; height:32px; position:relative; - top:20px; + bottom:20px; left: 70%; } @@ -325,7 +314,7 @@ ul.flags li { margin:auto; width:198px; position:relative; - top:20px; + top:10px; right:10px; } @@ -457,7 +446,7 @@ ul.flags li { #openAnotherFile { position: relative; - top: 40px; + top: 20px; } #wwctrl_openAnotherFile { @@ -465,15 +454,18 @@ ul.flags li { } ul#repositoryButtons { - display: inline; - float: right; - text-align: right; + display: table; list-style: none; + border-spacing: 10px; position: relative; - bottom: 105px; - right: 5px; + bottom: 10px; + margin: auto; } ul#repositoryButtons li { - margin-bottom: 5px; + display: table-cell; +} + +.jstree { + background: #FFF none repeat scroll 0% 0%; } \ No newline at end of file diff --git a/swe-ui-web/src/main/webapp/js/editor.js b/swe-ui-web/src/main/webapp/js/editor.js new file mode 100644 index 0000000..113ee6b --- /dev/null +++ b/swe-ui-web/src/main/webapp/js/editor.js @@ -0,0 +1,50 @@ +var exitAfterCommit = false; + +/* Changes the value of the new text */ +function loadChange() { + document.getElementById('newTextId').value = editor.getValue(); +} + +/* Opens the popin */ +function openPopin(popinId) { + document.getElementById(popinId).style.display = "block"; + document.getElementById("popinBackground").style.display = "block"; +} + +/* Closes the popin */ +function closePopin(popinId) { + document.getElementById(popinId).style.display = "none"; + document.getElementById("popinBackground").style.display = "none"; +} + +/* Exits the edit page if asked */ +function checkExit() { + if (exitAfterCommit) { + document.location.href = "checkout.action"; + } +} + +// automatically expand the directory when there is no other file +$.subscribe('treeChanged', function(event, data) { + + var json = event.originalEvent.data.responseJSON; + + if (json.length == 1) { + var object = json[0]; + + if (object.state == "closed") { + var htmlObject = document.getElementById(object.id); + var children = htmlObject.children; + children.item('ins').click(); + } + } +}); + +//function autoSave() { +// alert("auto save"); +//} + +// Every 5 minutes, the file is automatically saved +//setInterval(autoSave, 300000); + +window.onbeforeunload = confirmExitOnUnload; \ No newline at end of file -- To stop receiving notification emails like this one, please contact nuiton.org SCM administrator <admin+scm@nuiton.org>.