Finish code sweep
[nikiroo-utils.git] / src / jexer / TDirectoryList.java
index c47b33054e95e8c200a24ee8c80f307ef11a86fe..9ff0b6bfde9ac1ec5e85fbb1a19a4179b5227a10 100644 (file)
@@ -30,6 +30,7 @@ package jexer;
 
 import java.io.File;
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
 
 /**
@@ -37,6 +38,10 @@ import java.util.List;
  */
 public class TDirectoryList extends TList {
 
+    // ------------------------------------------------------------------------
+    // Variables --------------------------------------------------------------
+    // ------------------------------------------------------------------------
+
     /**
      * Files in the directory.
      */
@@ -47,6 +52,53 @@ public class TDirectoryList extends TList {
      */
     private File path;
 
+    // ------------------------------------------------------------------------
+    // Constructors -----------------------------------------------------------
+    // ------------------------------------------------------------------------
+
+    /**
+     * Public constructor.
+     *
+     * @param parent parent widget
+     * @param path directory path, must be a directory
+     * @param x column relative to parent
+     * @param y row relative to parent
+     * @param width width of text area
+     * @param height height of text area
+     */
+    public TDirectoryList(final TWidget parent, final String path, final int x,
+        final int y, final int width, final int height) {
+
+        this(parent, path, x, y, width, height, null);
+    }
+
+    /**
+     * Public constructor.
+     *
+     * @param parent parent widget
+     * @param path directory path, must be a directory
+     * @param x column relative to parent
+     * @param y row relative to parent
+     * @param width width of text area
+     * @param height height of text area
+     * @param action action to perform when an item is selected
+     */
+    public TDirectoryList(final TWidget parent, final String path, final int x,
+        final int y, final int width, final int height, final TAction action) {
+
+        super(parent, null, x, y, width, height, action);
+        files = new ArrayList<File>();
+        setPath(path);
+    }
+
+    // ------------------------------------------------------------------------
+    // TList ------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+
+    // ------------------------------------------------------------------------
+    // TDirectoryList ---------------------------------------------------------
+    // ------------------------------------------------------------------------
+
     /**
      * Set the new path to display.
      *
@@ -72,6 +124,7 @@ public class TDirectoryList extends TList {
                 newStrings.add(renderFile(files.size() - 1));
             }
         }
+        Collections.sort(newStrings);
         setList(newStrings);
 
         // Select the first entry
@@ -105,39 +158,4 @@ public class TDirectoryList extends TList {
         return String.format("%-20s %5dk", name, (file.length() / 1024));
     }
 
-    /**
-     * Public constructor.
-     *
-     * @param parent parent widget
-     * @param path directory path, must be a directory
-     * @param x column relative to parent
-     * @param y row relative to parent
-     * @param width width of text area
-     * @param height height of text area
-     */
-    public TDirectoryList(final TWidget parent, final String path, final int x,
-        final int y, final int width, final int height) {
-
-        this(parent, path, x, y, width, height, null);
-    }
-
-    /**
-     * Public constructor.
-     *
-     * @param parent parent widget
-     * @param path directory path, must be a directory
-     * @param x column relative to parent
-     * @param y row relative to parent
-     * @param width width of text area
-     * @param height height of text area
-     * @param action action to perform when an item is selected
-     */
-    public TDirectoryList(final TWidget parent, final String path, final int x,
-        final int y, final int width, final int height, final TAction action) {
-
-        super(parent, null, x, y, width, height, action);
-        files = new ArrayList<File>();
-        setPath(path);
-    }
-
 }