diff options
| author | bjculkin <bjculkin@mix.wvu.edu> | 2018-02-12 22:45:04 -0500 |
|---|---|---|
| committer | bjculkin <bjculkin@mix.wvu.edu> | 2018-02-12 22:45:04 -0500 |
| commit | df94066e3af02ff02d5ab4d033a3d603f743234c (patch) | |
| tree | 168a1edaf58d386c175ffb601e9d4da8e13d31e2 /base/src/main/java/bjc/utils/gui/SimpleFileChooser.java | |
| parent | ae51c587c53f7ca311e556e3cbd0c5566d6c2843 (diff) | |
Formatting pass
Diffstat (limited to 'base/src/main/java/bjc/utils/gui/SimpleFileChooser.java')
| -rw-r--r-- | base/src/main/java/bjc/utils/gui/SimpleFileChooser.java | 60 |
1 files changed, 30 insertions, 30 deletions
diff --git a/base/src/main/java/bjc/utils/gui/SimpleFileChooser.java b/base/src/main/java/bjc/utils/gui/SimpleFileChooser.java index 7da0bd8..2bdd792 100644 --- a/base/src/main/java/bjc/utils/gui/SimpleFileChooser.java +++ b/base/src/main/java/bjc/utils/gui/SimpleFileChooser.java @@ -17,18 +17,18 @@ import bjc.utils.exceptions.FileNotChosenException; */ public class SimpleFileChooser { private static File doOpenFile(final Component parent, final String title, final JFileChooser files) { - if (title == null) throw new NullPointerException("Title must not be null"); + if(title == null) throw new NullPointerException("Title must not be null"); files.setDialogTitle(title); boolean success = false; - while (!success) { + while(!success) { try { maybeDoOpenFile(parent, files); success = true; - } catch (final FileNotChosenException fncx) { + } catch(final FileNotChosenException fncx) { // We don't care about specifics SimpleDialogs.showError(parent, "I/O Error", "Please pick a file to open"); } @@ -38,18 +38,18 @@ public class SimpleFileChooser { } private static File doSaveFile(final Component parent, final String title, final JFileChooser files) { - if (title == null) throw new NullPointerException("Title must not be null"); + if(title == null) throw new NullPointerException("Title must not be null"); files.setDialogTitle(title); final boolean success = false; - while (!success) { + while(!success) { try { maybeDoSaveFile(parent, files); return files.getSelectedFile(); - } catch (final FileNotChosenException fncex) { + } catch(final FileNotChosenException fncex) { // We don't care about specifics SimpleDialogs.showError(parent, "I/O Error", "Please pick a file to save to"); } @@ -61,9 +61,9 @@ public class SimpleFileChooser { * until they pick a file. * * @param parent - * The component to use as the parent for the dialog. + * The component to use as the parent for the dialog. * @param title - * The title of the dialog to prompt with. + * The title of the dialog to prompt with. * @return The file the user has chosen. */ public static File getOpenFile(final Component parent, final String title) { @@ -77,11 +77,11 @@ public class SimpleFileChooser { * until they pick a file. * * @param parent - * The component to use as the parent for the dialog. + * The component to use as the parent for the dialog. * @param title - * The title of the dialog to prompt with. + * The title of the dialog to prompt with. * @param extensions - * The list of file extensions the file should have. + * The list of file extensions the file should have. * @return The file the user has chosen. */ public static File getOpenFile(final Component parent, final String title, final String... extensions) { @@ -96,9 +96,9 @@ public class SimpleFileChooser { * Prompt the user with a "Save File..." dialog. * * @param parent - * The component to use as the parent for the dialog. + * The component to use as the parent for the dialog. * @param title - * The title of the dialog to prompt with. + * The title of the dialog to prompt with. * @return The file the user chose. */ public static File getSaveFile(final Component parent, final String title) { @@ -111,11 +111,11 @@ public class SimpleFileChooser { * Prompt the user with a "Save File..." dialog. * * @param parent - * The component to use as the parent for the dialog. + * The component to use as the parent for the dialog. * @param title - * The title of the dialog to prompt with. + * The title of the dialog to prompt with. * @param extensions - * The extensions of the files the user can choose. + * The extensions of the files the user can choose. * @return The file the user chose. */ public static File getSaveFile(final Component parent, final String title, final String... extensions) { @@ -128,44 +128,44 @@ public class SimpleFileChooser { private static void maybeDoOpenFile(final Component parent, final JFileChooser files) throws FileNotChosenException { - if (parent == null) + if(parent == null) throw new NullPointerException("Parent must not be null"); - else if (files == null) throw new NullPointerException("File chooser must not be null"); + else if(files == null) throw new NullPointerException("File chooser must not be null"); final int result = files.showSaveDialog(parent); - if (result != JFileChooser.APPROVE_OPTION) throw new FileNotChosenException(); + if(result != JFileChooser.APPROVE_OPTION) throw new FileNotChosenException(); } private static void maybeDoSaveFile(final Component parent, final JFileChooser files) throws FileNotChosenException { - if (parent == null) + if(parent == null) throw new NullPointerException("Parent must not be null"); - else if (files == null) throw new NullPointerException("File chooser must not be null"); + else if(files == null) throw new NullPointerException("File chooser must not be null"); final int result = files.showSaveDialog(parent); - if (result != JFileChooser.APPROVE_OPTION) throw new FileNotChosenException(); + if(result != JFileChooser.APPROVE_OPTION) throw new FileNotChosenException(); } /** * Prompt the user with a "Open File..." dialog. * * @param parent - * The component to use as the parent for the dialog. + * The component to use as the parent for the dialog. * @param title - * The title of the dialog to prompt with. + * The title of the dialog to prompt with. * @return The file if the user chose one or null if they didn't. */ public static File maybeOpenFile(final Component parent, final String title) { - if (title == null) throw new NullPointerException("Title must not be null"); + if(title == null) throw new NullPointerException("Title must not be null"); final JFileChooser files = new JFileChooser(); files.setDialogTitle(title); try { maybeDoOpenFile(parent, files); - } catch (final FileNotChosenException fncex) { + } catch(final FileNotChosenException fncex) { // We don't care about specifics } @@ -176,20 +176,20 @@ public class SimpleFileChooser { * Prompt the user with a "Save File..." dialog. * * @param parent - * The component to use as the parent for the dialog. + * The component to use as the parent for the dialog. * @param title - * The title of the dialog to prompt with. + * The title of the dialog to prompt with. * @return The file if the user chose one or null if they didn't. */ public static File maybeSaveFile(final Component parent, final String title) { - if (title == null) throw new NullPointerException("Title must not be null"); + if(title == null) throw new NullPointerException("Title must not be null"); final JFileChooser files = new JFileChooser(); files.setDialogTitle(title); try { maybeDoSaveFile(parent, files); - } catch (final FileNotChosenException fncex) { + } catch(final FileNotChosenException fncex) { // We don't care about specifics } |
