From df94066e3af02ff02d5ab4d033a3d603f743234c Mon Sep 17 00:00:00 2001 From: bjculkin Date: Mon, 12 Feb 2018 22:45:04 -0500 Subject: Formatting pass --- .../bjc/utils/gui/awt/ExtensionFileFilter.java | 6 +- .../java/bjc/utils/gui/awt/SimpleFileDialog.java | 67 ++++++++++------------ 2 files changed, 33 insertions(+), 40 deletions(-) (limited to 'base/src/main/java/bjc/utils/gui/awt') diff --git a/base/src/main/java/bjc/utils/gui/awt/ExtensionFileFilter.java b/base/src/main/java/bjc/utils/gui/awt/ExtensionFileFilter.java index 5998345..ae424b4 100644 --- a/base/src/main/java/bjc/utils/gui/awt/ExtensionFileFilter.java +++ b/base/src/main/java/bjc/utils/gui/awt/ExtensionFileFilter.java @@ -22,10 +22,10 @@ public class ExtensionFileFilter implements FilenameFilter { * Create a new filter only showing files with the specified extensions. * * @param exts - * The extensions to show in this filter. + * The extensions to show in this filter. */ public ExtensionFileFilter(final List exts) { - if (exts == null) throw new NullPointerException("Extensions must not be null"); + if(exts == null) throw new NullPointerException("Extensions must not be null"); extensions = new FunctionalList<>(exts); } @@ -34,7 +34,7 @@ public class ExtensionFileFilter implements FilenameFilter { * Create a new filter only showing files with the specified extensions. * * @param exts - * The extensions to show in this filter. + * The extensions to show in this filter. */ public ExtensionFileFilter(final String... exts) { extensions = new FunctionalList<>(exts); diff --git a/base/src/main/java/bjc/utils/gui/awt/SimpleFileDialog.java b/base/src/main/java/bjc/utils/gui/awt/SimpleFileDialog.java index e9236fe..daea7cd 100644 --- a/base/src/main/java/bjc/utils/gui/awt/SimpleFileDialog.java +++ b/base/src/main/java/bjc/utils/gui/awt/SimpleFileDialog.java @@ -19,13 +19,12 @@ public class SimpleFileDialog { * Prompt the user to pick a file to open. * * @param parent - * The parent of the file picker. + * The parent of the file picker. * * @param title - * The title of the file picker. + * The title of the file picker. * - * @return - * The file the user picked. + * @return The file the user picked. */ public static File getOpenFile(final Frame parent, final String title) { return getOpenFile(parent, title, (String[]) null); @@ -35,34 +34,33 @@ public class SimpleFileDialog { * Prompt the user to pick a file to open. * * @param parent - * The parent of the file picker. + * The parent of the file picker. * * @param title - * The title of the file picker. + * The title of the file picker. * * @param extensions - * The extensions to accept as valid. + * The extensions to accept as valid. * - * @return - * The file the user picked. + * @return The file the user picked. */ public static File getOpenFile(final Frame parent, final String title, final String... extensions) { - if (parent == null) { + if(parent == null) { throw new NullPointerException("Parent must not be null"); - } else if (title == null) { + } else if(title == null) { throw new NullPointerException("Title must not be null"); } final FileDialog chooser = new FileDialog(parent, title, FileDialog.LOAD); - if (extensions != null) { + if(extensions != null) { final FilenameFilter filter = new ExtensionFileFilter(extensions); chooser.setFilenameFilter(filter); } chooser.setVisible(true); - while (chooser.getFile() == null) { + while(chooser.getFile() == null) { SimpleDialogs.showError(parent, "File I/O Error", "Please choose a file to open."); chooser.setVisible(true); } @@ -74,26 +72,24 @@ public class SimpleFileDialog { * Prompt the user to pick a file to open. * * @param parent - * The parent of the file picker. + * The parent of the file picker. * * @param title - * The title of the file picker. + * The title of the file picker. * * @param extensions - * The extensions to accept as valid. + * The extensions to accept as valid. * - * @return - * The file the user picked. + * @return The file the user picked. */ public static File[] getOpenFiles(final Frame parent, final String title, final String... extensions) { - if (parent == null) + if(parent == null) throw new NullPointerException("Parent must not be null"); - else if (title == null) - throw new NullPointerException("Title must not be null"); + else if(title == null) throw new NullPointerException("Title must not be null"); final FileDialog chooser = new FileDialog(parent, title, FileDialog.LOAD); - if (extensions != null) { + if(extensions != null) { final FilenameFilter filter = new ExtensionFileFilter(extensions); chooser.setFilenameFilter(filter); } @@ -101,7 +97,7 @@ public class SimpleFileDialog { chooser.setMultipleMode(true); chooser.setVisible(true); - while (chooser.getFile() == null) { + while(chooser.getFile() == null) { SimpleDialogs.showError(parent, "File I/O Error", "Please choose a file to open."); chooser.setVisible(true); } @@ -113,13 +109,12 @@ public class SimpleFileDialog { * Prompt the user to pick a file to save * * @param parent - * The parent of the file picker + * The parent of the file picker * * @param title - * The title of the file picker + * The title of the file picker * - * @return - * The file the user picked + * @return The file the user picked */ public static File getSaveFile(final Frame parent, final String title) { return getSaveFile(parent, title, (String[]) null); @@ -129,33 +124,31 @@ public class SimpleFileDialog { * Prompt the user to pick a file to save * * @param parent - * The parent of the file picker + * The parent of the file picker * * @param title - * The title of the file picker + * The title of the file picker * * @param extensions - * The extensions to accept as valid + * The extensions to accept as valid * - * @return - * The file the user picked + * @return The file the user picked */ public static File getSaveFile(final Frame parent, final String title, final String... extensions) { - if (parent == null) + if(parent == null) throw new NullPointerException("Parent must not be null"); - else if (title == null) - throw new NullPointerException("Title must not be null"); + else if(title == null) throw new NullPointerException("Title must not be null"); final FileDialog chooser = new FileDialog(parent, title, FileDialog.SAVE); - if (extensions != null) { + if(extensions != null) { final FilenameFilter filter = new ExtensionFileFilter(extensions); chooser.setFilenameFilter(filter); } chooser.setVisible(true); - while (chooser.getFile() == null) { + while(chooser.getFile() == null) { SimpleDialogs.showError(parent, "File I/O Error", "Please choose a file to save to."); chooser.setVisible(true); } -- cgit v1.2.3