mirror of
https://github.com/xfarrow/guify.git
synced 2025-02-20 05:50:36 +01:00
Removed unused SftpExceptions
This commit is contained in:
parent
31b5a2c1a6
commit
abeae2f4a4
@ -214,7 +214,7 @@ public class SshEngine {
|
|||||||
* will be uploaded in
|
* will be uploaded in
|
||||||
*/
|
*/
|
||||||
public static void uploadDirectoriesRecursively(File directory,
|
public static void uploadDirectoriesRecursively(File directory,
|
||||||
String remoteDirectory) throws SftpException {
|
String remoteDirectory) {
|
||||||
// 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
|
||||||
|
@ -144,10 +144,8 @@ public class DesktopController {
|
|||||||
* Uploads files and folders to the remote server
|
* Uploads files and folders to the remote server
|
||||||
*
|
*
|
||||||
* @param selectedNodes
|
* @param selectedNodes
|
||||||
* @throws SftpException
|
|
||||||
*/
|
*/
|
||||||
public void uploadToRemoteServer(File[] selectedNodes)
|
public void uploadToRemoteServer(File[] selectedNodes) {
|
||||||
throws SftpException {
|
|
||||||
if (selectedNodes.length == 0) {
|
if (selectedNodes.length == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -162,21 +162,13 @@ public class Desktop extends JFrame implements IDesktopFrame {
|
|||||||
.getTransferData(
|
.getTransferData(
|
||||||
DataFlavor.javaFileListFlavor)))
|
DataFlavor.javaFileListFlavor)))
|
||||||
.size()]);
|
.size()]);
|
||||||
try {
|
|
||||||
((DesktopController) controller)
|
((DesktopController) controller)
|
||||||
.uploadToRemoteServer(droppedFileArray);
|
.uploadToRemoteServer(droppedFileArray);
|
||||||
drawComponentsForDirectory(
|
drawComponentsForDirectory(
|
||||||
((DesktopController) controller)
|
((DesktopController) controller)
|
||||||
.getCurrentWorkingDirectory());
|
.getCurrentWorkingDirectory());
|
||||||
} catch (SftpException e) {
|
|
||||||
if (e.getMessage().contains("Permission denied")) {
|
|
||||||
JOptionPane.showMessageDialog(new JFrame(),
|
|
||||||
"Permission denied",
|
|
||||||
"Permission denied",
|
|
||||||
JOptionPane.ERROR_MESSAGE);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (UnsupportedFlavorException | IOException e) {
|
} catch (UnsupportedFlavorException | IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@ -201,26 +193,25 @@ public class Desktop extends JFrame implements IDesktopFrame {
|
|||||||
* @param directory
|
* @param directory
|
||||||
*/
|
*/
|
||||||
public void drawComponentsForDirectory(String directory) {
|
public void drawComponentsForDirectory(String directory) {
|
||||||
controller.clearSelectedNodes();
|
unselectAllNodes();
|
||||||
updateToolBarItems();
|
|
||||||
controller.setCurrentWorkingDirectory(directory);
|
controller.setCurrentWorkingDirectory(directory);
|
||||||
|
|
||||||
// Only loadDesktop() can tell whether we have the permission to view
|
// Only loadDesktop() can tell whether we have the permission to view
|
||||||
// the content of the directory
|
// the content of the directory
|
||||||
try {
|
try {
|
||||||
loadDesktop();
|
loadDesktop();
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
if (controller.getLastSafeDirectory() == null) {
|
if (ex.getMessage().contains("Permission denied")) {
|
||||||
System.exit(ERROR);
|
JOptionPane.showMessageDialog(new JFrame(), "Permission denied",
|
||||||
|
"Permission denied", JOptionPane.ERROR_MESSAGE);
|
||||||
} else {
|
} else {
|
||||||
String lastSafeDirectory = controller.getLastSafeDirectory();
|
JOptionPane.showMessageDialog(new JFrame(),
|
||||||
controller.setLastSafeDirectory(null); // Prevents infinite
|
"An unknown error has occurred: " + ex.getMessage(),
|
||||||
// re-tries
|
"Error", JOptionPane.ERROR_MESSAGE);
|
||||||
drawComponentsForDirectory(lastSafeDirectory);
|
}
|
||||||
|
controller.setCurrentWorkingDirectory(
|
||||||
|
controller.getLastSafeDirectory());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
loadTree();
|
loadTree();
|
||||||
pathTextBox.setText(controller.getCurrentWorkingDirectory());
|
pathTextBox.setText(controller.getCurrentWorkingDirectory());
|
||||||
controller.setLastSafeDirectory(directory);
|
controller.setLastSafeDirectory(directory);
|
||||||
@ -235,8 +226,6 @@ public class Desktop extends JFrame implements IDesktopFrame {
|
|||||||
* if the content of the directory cannot be displayed
|
* if the content of the directory cannot be displayed
|
||||||
*/
|
*/
|
||||||
private void loadDesktop() throws SftpException {
|
private void loadDesktop() throws SftpException {
|
||||||
desktopPanel.removeAll();
|
|
||||||
|
|
||||||
Image folderIcon = null;
|
Image folderIcon = null;
|
||||||
Image fileIcon = null;
|
Image fileIcon = null;
|
||||||
try {
|
try {
|
||||||
@ -252,19 +241,12 @@ public class Desktop extends JFrame implements IDesktopFrame {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Vector<LsEntry> elementsToDisplay = null;
|
Vector<LsEntry> elementsToDisplay = null;
|
||||||
try {
|
|
||||||
elementsToDisplay = controller.getDirectoryElements();
|
elementsToDisplay = controller.getDirectoryElements();
|
||||||
|
desktopPanel.removeAll();
|
||||||
|
// No content
|
||||||
if (elementsToDisplay == null) {
|
if (elementsToDisplay == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} catch (SftpException e) {
|
|
||||||
if (e.getMessage().contains("Permission denied")) {
|
|
||||||
JOptionPane.showMessageDialog(new JFrame(), "Permission denied",
|
|
||||||
"Permission denied", JOptionPane.ERROR_MESSAGE);
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (LsEntry node : elementsToDisplay) {
|
for (LsEntry node : elementsToDisplay) {
|
||||||
ImageIcon icon = new ImageIcon(
|
ImageIcon icon = new ImageIcon(
|
||||||
node.getAttrs().isDir() ? folderIcon : fileIcon);
|
node.getAttrs().isDir() ? folderIcon : fileIcon);
|
||||||
@ -954,18 +936,8 @@ public class Desktop extends JFrame implements IDesktopFrame {
|
|||||||
"Upload");
|
"Upload");
|
||||||
if (choiceFileChooser == JFileChooser.APPROVE_OPTION
|
if (choiceFileChooser == JFileChooser.APPROVE_OPTION
|
||||||
&& fileChooser.getSelectedFiles().length > 0) {
|
&& fileChooser.getSelectedFiles().length > 0) {
|
||||||
try {
|
|
||||||
controller.uploadToRemoteServer(
|
controller.uploadToRemoteServer(
|
||||||
fileChooser.getSelectedFiles());
|
fileChooser.getSelectedFiles());
|
||||||
} catch (SftpException e1) {
|
|
||||||
if (e1.getMessage().contains("Permission denied")) {
|
|
||||||
JOptionPane.showMessageDialog(new JFrame(),
|
|
||||||
"Not enough permissions to upload in this location",
|
|
||||||
"Permission denied",
|
|
||||||
JOptionPane.ERROR_MESSAGE);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
drawComponentsForDirectory(
|
drawComponentsForDirectory(
|
||||||
controller.getCurrentWorkingDirectory());
|
controller.getCurrentWorkingDirectory());
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user