import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
setAccessory(multi);
}
+ private static String byExtensionTooltip = null;
+
private static void setByExtensionTooltip(JComboBox dd)
{
if (dd.getItemCount() > 0
{
if (((JalviewFileFilter) dd.getSelectedItem()).isMultiFormat())
{
- dd.setToolTipText(
- MessageManager.getString("label.by_extension_tooltip"));
+ if (byExtensionTooltip == null)
+ {
+ StringBuilder sb = new StringBuilder(
+ MessageManager.getString("label.by_extension_tooltip"));
+ JalviewFileFilter jvf = (JalviewFileFilter) dd.getSelectedItem();
+ Iterator<String> extensions = jvf.getExtensions();
+ if (extensions.hasNext())
+ {
+ sb.append(" (.");
+ while (extensions.hasNext())
+ {
+ sb.append(extensions.next());
+ if (extensions.hasNext())
+ {
+ sb.append(", .");
+ }
+ }
+ sb.append(")");
+ }
+ byExtensionTooltip = sb.toString();
+ }
+ dd.setToolTipText(byExtensionTooltip);
}
else
{
import java.io.File;
import java.util.Hashtable;
import java.util.Iterator;
-import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
import java.util.Locale;
-import java.util.Map;
+import java.util.Set;
import java.util.StringTokenizer;
import javax.swing.filechooser.FileFilter;
{
public static Hashtable suffixHash = new Hashtable();
- private Map<String, JalviewFileFilter> filters = null;
+ private Set<String> filters = null;
private String description = "no description";
public String getAcceptableExtension()
{
- return filters.keySet().iterator().next().toString();
+ return filters.iterator().next().toString();
}
// takes account of the fact that database is a directory
return true;
}
- if ((extension != null) && (filters.get(extension) != null))
+ if ((extension != null) && (filters.contains(extension)))
{
return true;
}
if (parentJFC != null && parentJFC.includeBackupFiles)
{
- Iterator<String> it = filters.keySet().iterator();
+ Iterator<String> it = filters.iterator();
EXTENSION: while (it.hasNext())
{
String ext = it.next();
{
if (filters == null)
{
- filters = new LinkedHashMap<>(5);
+ filters = new LinkedHashSet<String>(5);
}
- filters.put(extension.toLowerCase(Locale.ROOT), this);
+ filters.add(extension.toLowerCase(Locale.ROOT));
fullDescription = null;
}
: (description + " (");
// build the description from the extension list
- Iterator<String> extensions = filters.keySet().iterator();
+ Iterator<String> extensions = filters.iterator();
if (extensions != null)
{
{
multiFormat = b;
}
+
+ protected Iterator<String> getExtensions()
+ {
+ return filters.iterator();
+ }
}