public static JalviewFileChooser forWrite(String directory,
String selected)
{
+ return forWrite(directory, selected, false);
+ }
+
+ public static JalviewFileChooser forWrite(String directory,
+ String selected, boolean addSelectFormatFromFileExtension)
+ {
// 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<>();
}
return new JalviewFileChooser(directory,
extensions.toArray(new String[extensions.size()]),
- descs.toArray(new String[descs.size()]), selected, false);
+ descs.toArray(new String[descs.size()]), selected, false, false,
+ addSelectFormatFromFileExtension);
}
public JalviewFileChooser(String dir)
public JalviewFileChooser(String dir, String[] extensions, String[] descs,
String selected, boolean acceptAny, boolean allowBackupFiles)
{
+ this(dir, extensions, descs, selected, acceptAny, allowBackupFiles,
+ false);
+ }
+
+ public JalviewFileChooser(String dir, String[] extensions, String[] descs,
+ String selected, boolean acceptAny, boolean allowBackupFiles,
+ boolean addSelectFormatFromExtension)
+ {
super(safePath(dir));
if (extensions.length == descs.length)
{
{
formats.add(new String[] { extensions[i], descs[i] });
}
- init(formats, selected, acceptAny, allowBackupFiles);
+ init(formats, selected, acceptAny, allowBackupFiles,
+ addSelectFormatFromExtension);
}
else
{
void init(List<String[]> formats, String selected, boolean acceptAny,
boolean allowBackupFiles)
{
+ init(formats, selected, acceptAny, allowBackupFiles, false);
+ }
+
+ void init(List<String[]> formats, String selected, boolean acceptAny,
+ boolean allowBackupFiles, boolean addSelectFormatFromExtension)
+ {
JalviewFileFilter chosen = null;
}
}
}
-
- if (acceptAny)
+ allExtensions.sort(null);
+ // only add "All known alignment files" if acceptAny is allowed
+ if (acceptAny || addSelectFormatFromExtension)
{
- allExtensions.sort(null);
+ String label = MessageManager.getString(addSelectFormatFromExtension
+ ? "label.select_format_from_extension"
+ : "label.all_known_alignment_files");
JalviewFileFilter alljvf = new JalviewFileFilter(
- allExtensions.toArray(new String[] {}),
- MessageManager.getString("label.all_known_alignment_files"));
+ allExtensions.toArray(new String[] {}), label);
alljvf.setMultiFormat(true);
alljvf.setExtensionListInDescription(false);
addChoosableFileFilter(alljvf);
setFileFilter(chosen);
}
+ JPanel multi = new JPanel();
+ multi.setLayout(new BoxLayout(multi, BoxLayout.PAGE_AXIS));
+ multi.add(new RecentlyOpened());
if (allowBackupFiles)
{
- JPanel multi = new JPanel();
- multi.setLayout(new BoxLayout(multi, BoxLayout.PAGE_AXIS));
if (backupfilesCheckBox == null)
{
try
}
});
}
- multi.add(new RecentlyOpened());
multi.add(backupfilesCheckBox);
- setAccessory(multi);
}
else
{
// set includeBackupFiles=false to avoid other file choosers from picking
// up backup files (Just In Case)
includeBackupFiles = false;
- setAccessory(new RecentlyOpened());
}
+ setAccessory(multi);
}
@Override