no message
This commit is contained in:
46
src/Visual_DVM_2021/Passes/All/ShowTestingServerFile.java
Normal file
46
src/Visual_DVM_2021/Passes/All/ShowTestingServerFile.java
Normal file
@@ -0,0 +1,46 @@
|
||||
package Visual_DVM_2021.Passes.All;
|
||||
import Common.UI.Windows.Dialog.Text.ReadOnlyMultilineTextForm;
|
||||
import Common.Utils.Utils;
|
||||
import GlobalData.RemoteFile.RemoteFile;
|
||||
import Repository.Server.ServerCode;
|
||||
import Repository.Server.ServerExchangeUnit_2021;
|
||||
import Visual_DVM_2021.Passes.PassException;
|
||||
import Visual_DVM_2021.Passes.Server.TestingSystemPass;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.Vector;
|
||||
public class ShowTestingServerFile extends TestingSystemPass<RemoteFile> {
|
||||
String title;
|
||||
File localFile;
|
||||
@Override
|
||||
protected boolean canStart(Object... args) throws Exception {
|
||||
title = (String) args[0];
|
||||
target = (RemoteFile) args[1];
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
protected void ServerAction() throws Exception {
|
||||
Command(new ServerExchangeUnit_2021(ServerCode.ReceiveFile, target.full_name));
|
||||
localFile = Utils.getTempFileName(target.name);
|
||||
if (response.object != null)
|
||||
response.Unpack(localFile);
|
||||
else throw new PassException("Файл не найден");
|
||||
}
|
||||
@Override
|
||||
protected boolean validate() {
|
||||
return localFile.exists();
|
||||
}
|
||||
@Override
|
||||
protected void showDone() throws Exception {
|
||||
ReadOnlyMultilineTextForm ff = new ReadOnlyMultilineTextForm();
|
||||
List<String> lines = FileUtils.readLines(localFile);
|
||||
Vector<String> res = new Vector<>();
|
||||
for (int i = lines.size() - 1; i >= 0; i--)
|
||||
res.add(lines.get(i));
|
||||
ff.ShowDialog(title,
|
||||
String.join("\n", res)
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user