if (format.isReadable())
{
extensions.add(format.getExtensions());
- descs.add(format.getShortDescription());
+ descs.add(format.toString());
}
}
return new JalviewFileChooser(directory,
if (format.isWritable())
{
extensions.add(format.getExtensions());
- descs.add(format.getShortDescription());
+ descs.add(format.toString());
}
}
return new JalviewFileChooser(directory,
}
}
+ /**
+ * Returns the selected file format, or null if none selected
+ *
+ * @return
+ */
public FileFormatI getSelectedFormat()
{
if (getFileFilter() == null)
return null;
}
+ /*
+ * logic here depends on option description being formatted as
+ * formatName (extension, extension...)
+ * or the 'no option selected' value
+ * All Files
+ * @see JalviewFileFilter.getDescription
+ */
String format = getFileFilter().getDescription();
- return FileFormat.valueOf(format);
+ int parenPos = format.indexOf("(");
+ if (parenPos > 0)
+ {
+ format = format.substring(0, parenPos).trim();
+ try
+ {
+ return FileFormat.valueOf(format);
+ } catch (IllegalArgumentException e)
+ {
+ System.err.println("Unexpected format: " + format);
+ }
+ }
+ return null;
}
@Override