From: amwaterhouse Date: Fri, 9 Jun 2006 16:18:14 +0000 (+0000) Subject: setAcceptAllFileFilter fixes bug on MacOSX X-Git-Tag: Release_2_1~365 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=822b1c37262fba8b1cfdb840747cc18113270d1a;p=jalview.git setAcceptAllFileFilter fixes bug on MacOSX --- diff --git a/src/jalview/io/JalviewFileChooser.java b/src/jalview/io/JalviewFileChooser.java index 423f874..5484d38 100755 --- a/src/jalview/io/JalviewFileChooser.java +++ b/src/jalview/io/JalviewFileChooser.java @@ -36,13 +36,37 @@ public class JalviewFileChooser setAccessory(new RecentlyOpened()); } - public JalviewFileChooser(String dir, String[] suffix, String[] desc, + public JalviewFileChooser(String dir, + String[] suffix, + String[] desc, + String selected, + boolean selectAll) + { + super(dir); + init( suffix, desc, selected, selectAll); + } + + public JalviewFileChooser(String dir, + String[] suffix, + String[] desc, String selected) { super(dir); + init( suffix, desc, selected, true); + } + + void init(String[] suffix, + String[] desc, + String selected, + boolean selectAll) + { JalviewFileFilter chosen = null; + //SelectAllFilter needs to be set first before adding further + //file filters to fix bug on Mac OSX + setAcceptAllFileFilterUsed(selectAll); + for (int i = 0; i < suffix.length; i++) { JalviewFileFilter jvf = new JalviewFileFilter(suffix[i], desc[i]); @@ -58,6 +82,7 @@ public class JalviewFileChooser { setFileFilter(chosen); } + setAccessory(new RecentlyOpened()); } @@ -66,6 +91,7 @@ public class JalviewFileChooser { super.setFileFilter(filter); + try{ if(getUI() instanceof javax.swing.plaf.basic.BasicFileChooserUI) { @@ -92,6 +118,7 @@ public class JalviewFileChooser } }catch(Exception ex) { + ex.printStackTrace(); // Some platforms do not have BasicFileChooserUI } } @@ -142,9 +169,10 @@ public class JalviewFileChooser { this.setAccessory(null); + setDialogType(SAVE_DIALOG); - int ret = showDialog(parent, null); + int ret = showDialog(parent, "Save"); if (getFileFilter() instanceof JalviewFileFilter) { @@ -213,6 +241,12 @@ public class JalviewFileChooser } list = new JList(recent); + + DefaultListCellRenderer dlcr = new DefaultListCellRenderer(); + dlcr.setHorizontalAlignment(DefaultListCellRenderer.RIGHT); + list.setCellRenderer(dlcr); + + list.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent evt) @@ -224,7 +258,7 @@ public class JalviewFileChooser this.setBorder(new javax.swing.border.TitledBorder("Recently Opened")); final JScrollPane scroller = new JScrollPane(list); - scroller.setPreferredSize(new Dimension(120, 200)); + scroller.setPreferredSize(new Dimension(130, 200)); this.add(scroller); javax.swing.SwingUtilities.invokeLater(new Runnable()