fix npe if nothing is selected
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sun, 1 Jun 2008 03:09:23 +0000 (05:09 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sun, 1 Jun 2008 03:09:23 +0000 (05:09 +0200)
src/net/pterodactylus/jsite/gui/FileManager.java

index 9a3a758..34b07a3 100644 (file)
@@ -591,12 +591,14 @@ public class FileManager extends JDialog implements I18nable, ActionListener, Tr
        private List<ProjectFileWrapper> getSelectedProjectFileWrappers(boolean filesOnly) {
                List<ProjectFileWrapper> selectedProjectFileWrappers = new ArrayList<ProjectFileWrapper>();
                TreePath[] selectedPaths = fileTree.getSelectionPaths();
-               for (TreePath selectedPath : selectedPaths) {
-                       ProjectFileWrapper projectFileWrapper = (ProjectFileWrapper) selectedPath.getLastPathComponent();
-                       if (filesOnly && !projectFileWrapper.getProjectFile().isFile()) {
-                               continue;
+               if (selectedPaths != null) {
+                       for (TreePath selectedPath : selectedPaths) {
+                               ProjectFileWrapper projectFileWrapper = (ProjectFileWrapper) selectedPath.getLastPathComponent();
+                               if (filesOnly && !projectFileWrapper.getProjectFile().isFile()) {
+                                       continue;
+                               }
+                               selectedProjectFileWrappers.add(projectFileWrapper);
                        }
-                       selectedProjectFileWrappers.add(projectFileWrapper);
                }
                return selectedProjectFileWrappers;
        }