X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fjexer%2FTDirectoryList.java;h=9ff0b6bfde9ac1ec5e85fbb1a19a4179b5227a10;hb=615a0d99fd0aa4437116dd083147f9150d5e6527;hp=c47b33054e95e8c200a24ee8c80f307ef11a86fe;hpb=7d922e0dfd9a6da42b84e01d52adeec6fff10025;p=fanfix.git diff --git a/src/jexer/TDirectoryList.java b/src/jexer/TDirectoryList.java index c47b330..9ff0b6b 100644 --- a/src/jexer/TDirectoryList.java +++ b/src/jexer/TDirectoryList.java @@ -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(); + 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(); - setPath(path); - } - }