+ DialogRunner<JalviewFileChooser> runner = new DialogRunner<>(this);
+
+ /**
+ * Factory method to return a file chooser that offers readable alignment file
+ * formats
+ *
+ * @param directory
+ * @param selected
+ * @return
+ */
+ public static JalviewFileChooser forRead(String directory,
+ String selected)
+ {
+ List<String> extensions = new ArrayList<>();
+ List<String> descs = new ArrayList<>();
+ for (FileFormatI format : FileFormats.getInstance().getFormats())
+ {
+ if (format.isReadable())
+ {
+ extensions.add(format.getExtensions());
+ descs.add(format.getName());
+ }
+ }
+ return new JalviewFileChooser(directory,
+ extensions.toArray(new String[extensions.size()]),
+ descs.toArray(new String[descs.size()]), selected, true);
+ }
+
+ /**
+ * Factory method to return a file chooser that offers writable alignment file
+ * formats
+ *
+ * @param directory
+ * @param selected
+ * @return
+ */
+ public static JalviewFileChooser forWrite(String directory,
+ String selected)
+ {
+ // TODO in Java 8, forRead and forWrite can be a single method
+ // with a lambda expression parameter for isReadable/isWritable
+ List<String> extensions = new ArrayList<>();
+ List<String> descs = new ArrayList<>();
+ for (FileFormatI format : FileFormats.getInstance().getFormats())
+ {
+ if (format.isWritable())
+ {
+ extensions.add(format.getExtensions());
+ descs.add(format.getName());
+ }
+ }
+ return new JalviewFileChooser(directory,
+ extensions.toArray(new String[extensions.size()]),
+ descs.toArray(new String[descs.size()]), selected, false);
+ }
+