mirror of https://github.com/xfarrow/guify.git
Code readability
This commit is contained in:
parent
5115bb028b
commit
31b5a2c1a6
|
@ -173,8 +173,7 @@ public class SshEngine {
|
||||||
* Uploads a file from the local machine to the remote host. Executed
|
* Uploads a file from the local machine to the remote host. Executed
|
||||||
* asynchronously.
|
* asynchronously.
|
||||||
*/
|
*/
|
||||||
public static void uploadFile(File fileToUpload, String remoteDirectory)
|
public static void uploadFile(File fileToUpload, String remoteDirectory) {
|
||||||
throws SftpException {
|
|
||||||
// We execute the lengthy and time-consuming operation on a different
|
// We execute the lengthy and time-consuming operation on a different
|
||||||
// thread instead of the Event Dispatch Thread.
|
// thread instead of the Event Dispatch Thread.
|
||||||
// We use SwingWorker so any GUI changes requested by this thread will
|
// We use SwingWorker so any GUI changes requested by this thread will
|
||||||
|
|
|
@ -3,7 +3,6 @@ package controllers;
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.jcraft.jsch.ChannelSftp;
|
import com.jcraft.jsch.ChannelSftp;
|
||||||
import com.jcraft.jsch.SftpException;
|
import com.jcraft.jsch.SftpException;
|
||||||
|
|
||||||
import code.Constants;
|
import code.Constants;
|
||||||
import code.Constants.Constants_FSOperations;
|
import code.Constants.Constants_FSOperations;
|
||||||
import code.GuiAbstractions.Implementations.JFrameFactory;
|
import code.GuiAbstractions.Implementations.JFrameFactory;
|
||||||
|
@ -71,7 +70,6 @@ public class DesktopController {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLastSafeDirectory(String directory) {
|
public void setLastSafeDirectory(String directory) {
|
||||||
|
|
||||||
if (directory == null) {
|
if (directory == null) {
|
||||||
lastSafeDirectory = null;
|
lastSafeDirectory = null;
|
||||||
return;
|
return;
|
||||||
|
@ -150,27 +148,26 @@ public class DesktopController {
|
||||||
*/
|
*/
|
||||||
public void uploadToRemoteServer(File[] selectedNodes)
|
public void uploadToRemoteServer(File[] selectedNodes)
|
||||||
throws SftpException {
|
throws SftpException {
|
||||||
if (selectedNodes.length > 0) {
|
if (selectedNodes.length == 0) {
|
||||||
List<File> selectedFiles = new ArrayList<File>();
|
return;
|
||||||
List<File> selectedDirectories = new ArrayList<File>();
|
}
|
||||||
for (java.io.File file : selectedNodes) {
|
List<File> selectedFiles = new ArrayList<File>();
|
||||||
if (file.isFile()) {
|
List<File> selectedDirectories = new ArrayList<File>();
|
||||||
selectedFiles.add(file);
|
for (java.io.File file : selectedNodes) {
|
||||||
} else if (file.isDirectory()) {
|
if (file.isFile()) {
|
||||||
selectedDirectories.add(file);
|
selectedFiles.add(file);
|
||||||
}
|
} else if (file.isDirectory()) {
|
||||||
|
selectedDirectories.add(file);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (File file : selectedFiles) {
|
for (File file : selectedFiles) {
|
||||||
SshEngine.uploadFile(file, this.getCurrentWorkingDirectory());
|
SshEngine.uploadFile(file, this.getCurrentWorkingDirectory());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (selectedDirectories.size() > 0) {
|
for (File directory : selectedDirectories) {
|
||||||
for (File directory : selectedDirectories) {
|
SshEngine.uploadDirectoriesRecursively(directory,
|
||||||
SshEngine.uploadDirectoriesRecursively(directory,
|
this.getCurrentWorkingDirectory());
|
||||||
this.getCurrentWorkingDirectory());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -304,7 +301,7 @@ public class DesktopController {
|
||||||
// cannot write on destination
|
// cannot write on destination
|
||||||
// we keep using isWriteable as
|
// we keep using isWriteable as
|
||||||
// the executeCommand() does not fire
|
// the executeCommand() does not fire
|
||||||
// an exception in case of fail
|
// an exception in case of failure
|
||||||
if (!isWriteable(destination)) {
|
if (!isWriteable(destination)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -232,6 +232,7 @@ public class Desktop extends JFrame implements IDesktopFrame {
|
||||||
* Loads the desktop view
|
* Loads the desktop view
|
||||||
*
|
*
|
||||||
* @throws SftpException
|
* @throws SftpException
|
||||||
|
* if the content of the directory cannot be displayed
|
||||||
*/
|
*/
|
||||||
private void loadDesktop() throws SftpException {
|
private void loadDesktop() throws SftpException {
|
||||||
desktopPanel.removeAll();
|
desktopPanel.removeAll();
|
||||||
|
|
Loading…
Reference in New Issue