setAcceptAllFileFilter fixes bug on MacOSX
authoramwaterhouse <Andrew Waterhouse>
Fri, 9 Jun 2006 16:18:14 +0000 (16:18 +0000)
committeramwaterhouse <Andrew Waterhouse>
Fri, 9 Jun 2006 16:18:14 +0000 (16:18 +0000)
src/jalview/io/JalviewFileChooser.java

index 423f874..5484d38 100755 (executable)
@@ -36,13 +36,37 @@ public class JalviewFileChooser
     setAccessory(new RecentlyOpened());\r
   }\r
 \r
-  public JalviewFileChooser(String dir, String[] suffix, String[] desc,\r
+  public JalviewFileChooser(String dir,\r
+                            String[] suffix,\r
+                            String[] desc,\r
+                            String selected,\r
+                            boolean selectAll)\r
+  {\r
+    super(dir);\r
+    init( suffix, desc, selected, selectAll);\r
+  }\r
+\r
+  public JalviewFileChooser(String dir,\r
+                            String[] suffix,\r
+                            String[] desc,\r
                             String selected)\r
   {\r
     super(dir);\r
+    init( suffix, desc, selected, true);\r
+  }\r
+\r
+  void init(String[] suffix,\r
+            String[] desc,\r
+            String selected,\r
+            boolean selectAll)\r
+  {\r
 \r
     JalviewFileFilter chosen = null;\r
 \r
+    //SelectAllFilter needs to be set first before adding further\r
+    //file filters to fix bug on Mac OSX\r
+    setAcceptAllFileFilterUsed(selectAll);\r
+\r
     for (int i = 0; i < suffix.length; i++)\r
     {\r
       JalviewFileFilter jvf = new JalviewFileFilter(suffix[i], desc[i]);\r
@@ -58,6 +82,7 @@ public class JalviewFileChooser
     {\r
       setFileFilter(chosen);\r
     }\r
+\r
     setAccessory(new RecentlyOpened());\r
   }\r
 \r
@@ -66,6 +91,7 @@ public class JalviewFileChooser
   {\r
     super.setFileFilter(filter);\r
 \r
+\r
     try{\r
       if(getUI() instanceof javax.swing.plaf.basic.BasicFileChooserUI)\r
       {\r
@@ -92,6 +118,7 @@ public class JalviewFileChooser
       }\r
     }catch(Exception ex)\r
     {\r
+      ex.printStackTrace();\r
       // Some platforms do not have BasicFileChooserUI\r
     }\r
   }\r
@@ -142,9 +169,10 @@ public class JalviewFileChooser
   {\r
     this.setAccessory(null);\r
 \r
+\r
     setDialogType(SAVE_DIALOG);\r
 \r
-    int ret = showDialog(parent, null);\r
+    int ret = showDialog(parent, "Save");\r
 \r
     if (getFileFilter() instanceof JalviewFileFilter)\r
     {\r
@@ -213,6 +241,12 @@ public class JalviewFileChooser
       }\r
 \r
       list = new JList(recent);\r
+\r
+      DefaultListCellRenderer dlcr = new DefaultListCellRenderer();\r
+      dlcr.setHorizontalAlignment(DefaultListCellRenderer.RIGHT);\r
+      list.setCellRenderer(dlcr);\r
+\r
+\r
       list.addMouseListener(new MouseAdapter()\r
           {\r
             public void mousePressed(MouseEvent evt)\r
@@ -224,7 +258,7 @@ public class JalviewFileChooser
       this.setBorder(new javax.swing.border.TitledBorder("Recently Opened"));\r
 \r
       final JScrollPane scroller = new JScrollPane(list);\r
-      scroller.setPreferredSize(new Dimension(120, 200));\r
+      scroller.setPreferredSize(new Dimension(130, 200));\r
       this.add(scroller);\r
 \r
       javax.swing.SwingUtilities.invokeLater(new Runnable()\r