@Override public void onDownload() { final FileImageLabelTreeItem selection = fileTreePresenter.getSelectedItem(); if (selection != null) { final String selectionPath = selection.getFileInfo().getFilePath(); if (selectionPath != null) { fileService.getDownloadPath( Authentication.getInstance().getToken(), selectionPath, new RPCCallback<String>() { @Override public void onResult(String result) { // target=" + result.getData() + "&directory=yes Window.Location.replace( URL.encode( "/etcsite/download/?target=" + result + "&username="******"&" + "sessionID=" + Authentication.getInstance().getSessionID())); /*Window.open("/etcsite/download/?target=" + result.getData() + "&username="******"&" + "sessionID=" + Authentication.getInstance().getSessionID() , "download", "resizable=yes,scrollbars=yes,menubar=yes,location=yes,status=yes"); */ } }); } else { messagePresenter.showMessage("File Manager", "Not downloadable"); } } else { messagePresenter.showMessage("File Manager", "Please select a file to download"); } }
@Override public void onCreateSemanticMarkupFiles() { final FileImageLabelTreeItem selection = fileTreePresenter.getSelectedItem(); if (selection != null && selection.getFileInfo().isAllowsNewChildren()) { createSemanticMarkupFilesDialogPresenter.setCloseHandler( new ICloseHandler() { @Override public void onClose(int filesCreated) { if (filesCreated > 0) refresh(fileFilter); } }); createSemanticMarkupFilesDialogPresenter.show( fileTreePresenter.getSelectedItem().getFileInfo().getFilePath()); } else messagePresenter.showMessage( "No destination selected", "Please select a valid parent directory"); }
@Override public void onCreate() { final FileImageLabelTreeItem selection = fileTreePresenter.getSelectedItem(); if (selection != null && selection.getFileInfo().isAllowsNewChildren()) { int level = getLevel(selection); if (level < Configuration.fileManagerMaxDepth) { textInputPresenter.show( "Create folder", "Folder name:", "", new ITextInputListener() { @Override public void onConfirm(final String directoryName) { final FileImageLabelTreeItem selection = fileTreePresenter.getSelectedItem(); final String selectionPath = selection.getFileInfo().getFilePath(); fileService.isDirectory( Authentication.getInstance().getToken(), selectionPath, new RPCCallback<Boolean>() { @Override public void onResult(Boolean result) { String newDirectoryParent = selectionPath; if (!result) newDirectoryParent = getParent(selection); if (newDirectoryParent != null) { fileService.createDirectory( Authentication.getInstance().getToken(), newDirectoryParent, directoryName, false, new RPCCallback<String>() { @Override public void onResult(String result) { fileTreePresenter.refresh(fileFilter); } }); } } }); } @Override public void onCancel() {} }); } else { messagePresenter.showMessage( "File Manager", "Only a directory depth of " + Configuration.fileManagerMaxDepth + " is allowed."); } } else { messagePresenter.showMessage("File Manager", "Please select a valid parent directory."); } }
@Inject public ManagableFileTreePresenter( IManagableFileTreeView view, IFileTreeView.Presenter fileTreePresenter, IFileServiceAsync fileService, MessageView.Presenter messagePresenter, ITextInputView.Presenter textInputPresenter, ICreateSemanticMarkupFilesDialogView.Presenter createSemanticMarkupFilesDialogPresenter) { this.fileService = fileService; this.view = view; this.view.setPresenter(this); this.fileTreePresenter = fileTreePresenter; fileTreePresenter.addSelectionListener(this); this.messagePresenter = messagePresenter; this.textInputPresenter = textInputPresenter; this.createSemanticMarkupFilesDialogPresenter = createSemanticMarkupFilesDialogPresenter; this.defaultServletPath = view.getUploader().getServletPath() + "?username="******"&sessionID=" + Authentication.getInstance().getSessionID(); view.getUploader().setServletPath(defaultServletPath); view.getUploader().addOnFinishUploadHandler(new OnFinishUploadHandler()); view.getUploader().addOnStartUploadHandler(new OnStartUploadHandler()); view.getUploader().setI18Constants(new MyUploaderConstants()); IUploadStatus statusWidget = new BaseUploadStatus(); statusWidget.setCancelConfiguration(IUploadStatus.DEFAULT_CANCEL_CFG); // show uploading constantly, instead of the files /*display.getUploader().addOnStatusChangedHandler(new OnStatusChangedHandler() { @Override public void onStatusChanged(IUploader uploader) { uploader.getStatusWidget().setFileName("Uploading..."); } }); display.getUploader().addOnChangeUploadHandler(new OnChangeUploaderHandler() { @Override public void onChange(IUploader uploader) { System.out.println("on change"); } });*/ view.getUploader().setStatusWidget(statusWidget); view.setStatusWidget(statusWidget.getWidget()); view.getUploader().setFileInput(new MyFileInput(view.getAddButton())); initActions(); }
@Override public void onDelete() { FileImageLabelTreeItem selection = fileTreePresenter.getSelectedItem(); if (selection != null && !selection.getFileInfo().isSystemFile()) { fileService.deleteFile( Authentication.getInstance().getToken(), selection.getFileInfo().getFilePath(), new RPCCallback<Void>() { @Override public void onResult(Void result) { ManagableFileTreePresenter.this.initActions(); fileTreePresenter.clearSelection(); fileTreePresenter.refresh(fileFilter); } }); } else { messagePresenter.showMessage( "File Manager", "Please select a valid file or directory to delete"); } }
@Override public void onRename() { FileImageLabelTreeItem selection = fileTreePresenter.getSelectedItem(); // don't allow rename of root node if (selection != null && !selection.getFileInfo().isSystemFile()) { textInputPresenter.show( "Rename", "New name", selection.getFileInfo().getName(), new ITextInputListener() { @Override public void onConfirm(final String newFileName) { final FileImageLabelTreeItem selection = fileTreePresenter.getSelectedItem(); if (selection != null && !selection.getFileInfo().isSystemFile()) { fileService.renameFile( Authentication.getInstance().getToken(), selection.getFileInfo().getFilePath(), newFileName, new RPCCallback<Void>() { @Override public void onResult(Void result) { fileTreePresenter.refresh(fileFilter); selection.getFileInfo().setName(newFileName); } }); } } @Override public void onCancel() {} }); } else { messagePresenter.showMessage( "File Manager", "Please select a valid file or directory to rename"); } }
@Override public void refresh(FileFilter fileFilter) { this.fileFilter = fileFilter; fileTreePresenter.refresh(fileFilter); setInputFileMultiple(); }