no message
This commit is contained in:
61
src/_VisualDVM/Passes/All/DownloadProject.java
Normal file
61
src/_VisualDVM/Passes/All/DownloadProject.java
Normal file
@@ -0,0 +1,61 @@
|
||||
package _VisualDVM.Passes.All;
|
||||
import Common.Utils.Utils_;
|
||||
import Common.Visual.UI_;
|
||||
import _VisualDVM.Current;
|
||||
import _VisualDVM.Global;
|
||||
import _VisualDVM.Visual.UI;
|
||||
import _VisualDVM.Utils;
|
||||
import _VisualDVM.GlobalData.RemoteFile.RemoteFile;
|
||||
import _VisualDVM.Passes.PassCode;
|
||||
import Common.Passes.PassException;
|
||||
import _VisualDVM.Passes.SSH.CurrentConnectionPass;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Paths;
|
||||
public class DownloadProject extends CurrentConnectionPass {
|
||||
private static final int maxSize = 10240;
|
||||
boolean dialogOK = false;
|
||||
RemoteFile src;
|
||||
RemoteFile remote_archive;
|
||||
File local_archive;
|
||||
@Override
|
||||
protected void ServerAction() throws Exception {
|
||||
dialogOK = (UI.getRemoteFileChooser().ShowDialog(getDescription(), this, true));
|
||||
if (dialogOK) {
|
||||
src = Global.mainModule.getRemoteFile();
|
||||
remote_archive = new RemoteFile(src.full_name, src.name + ".zip", false);
|
||||
local_archive = Utils.getTempFileName(remote_archive.name);
|
||||
if ((user.connection.getFileKBSize(src.full_name)) <= maxSize) {
|
||||
ShowMessage2("Запаковка папки проекта..");
|
||||
user.connection.Command(
|
||||
"cd " + Utils_.DQuotes(src.full_name),
|
||||
"zip -r " + Utils_.DQuotes(remote_archive.full_name) + " ./"
|
||||
);
|
||||
// try {
|
||||
ShowMessage2("Загрузка проекта..");
|
||||
user.connection.getSingleFile(remote_archive.full_name, local_archive.getAbsolutePath());
|
||||
// } catch (Exception ex) {
|
||||
// throw new PassException("Ошибка загрузки");
|
||||
// }
|
||||
user.connection.sftpChannel.rm(remote_archive.full_name);
|
||||
} else throw new PassException("Размер проекта превышает " + maxSize + " KB.\n");
|
||||
} else {
|
||||
//диалога не вышло, сбрасываем файл.
|
||||
Global.mainModule.set(Current.RemoteFile, null);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
protected boolean validate() {
|
||||
Global.mainModule.Check(Log, Current.RemoteFile);
|
||||
return (Log.isEmpty());
|
||||
}
|
||||
@Override
|
||||
protected void performDone() throws Exception {
|
||||
File project = Paths.get(Global.visualiser.getWorkspace().getAbsolutePath(),
|
||||
Utils_.getDateName(src.name)).toFile();
|
||||
if ( Global.mainModule.getPass(PassCode.UnzipFolderPass).Do(local_archive.getAbsolutePath(), project.getAbsolutePath())) {
|
||||
if (UI_.Question("Проект " + Utils_.Brackets(src.name) + " успешно загружен. Открыть его"))
|
||||
Global.mainModule.getPass(PassCode.OpenCurrentProject).Do(project);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user