From: hansonr Date: Thu, 20 Dec 2018 11:41:12 +0000 (-0600) Subject: preliminary hack fix for synthetic reference issue X-Git-Tag: Release_2_11_4_0~45^2~18^2~338 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=79642858bc4aac41afaff6a3c20c130aa4200840;p=jalview.git preliminary hack fix for synthetic reference issue RecentlyOpened inner/ /subclasses JalviewFileChooser \ / JFileChooser Component So Component can be retrieved two ways through JFileChooser. (1) as the original JalviewFileChooser object (2) as the superclass of RecentlyOpened. I will look into it. For now it is sufficient to simply move RecentlyOpened to be at least a static class. I just made it another top-level class. --- diff --git a/src/jalview/io/JalviewFileChooser.java b/src/jalview/io/JalviewFileChooser.java index 88a337a..9667d7f 100755 --- a/src/jalview/io/JalviewFileChooser.java +++ b/src/jalview/io/JalviewFileChooser.java @@ -126,7 +126,7 @@ public class JalviewFileChooser extends JFileChooser implements DialogRunnerI, public JalviewFileChooser(String dir) { super(safePath(dir)); - setAccessory(new RecentlyOpened()); + setAccessory(new RecentlyOpened(this)); } public JalviewFileChooser(String dir, String[] suffix, String[] desc, @@ -197,7 +197,12 @@ public class JalviewFileChooser extends JFileChooser implements DialogRunnerI, * code below here is not reached in JalviewJS, instead * propertyChange() is called for dialog action */ + /** + * @j2sNative + */ + { handleResponse(value); + } return value; } @@ -233,7 +238,7 @@ public class JalviewFileChooser extends JFileChooser implements DialogRunnerI, setFileFilter(chosen); } - setAccessory(new RecentlyOpened()); + setAccessory(new RecentlyOpened(this)); } @Override @@ -418,78 +423,6 @@ public class JalviewFileChooser extends JFileChooser implements DialogRunnerI, } } - class RecentlyOpened extends JPanel - { - private static final long serialVersionUID = 1L; - JList list; - - RecentlyOpened() - { - setPreferredSize(new Dimension(300,100)); - String historyItems = Cache.getProperty("RECENT_FILE"); - StringTokenizer st; - Vector recent = new Vector<>(); - - if (historyItems != null) - { - st = new StringTokenizer(historyItems, "\t"); - - while (st.hasMoreTokens()) - { - recent.addElement(st.nextToken()); - } - } - - list = new JList<>(recent); - - DefaultListCellRenderer dlcr = new DefaultListCellRenderer(); -// dlcr.setHorizontalAlignment(DefaultListCellRenderer.RIGHT); - list.setCellRenderer(dlcr); - - list.addMouseListener(new MouseAdapter() - { - @Override - public void mousePressed(MouseEvent evt) - { - recentListSelectionChanged(list.getSelectedValue()); - } - }); - - this.setBorder(new javax.swing.border.TitledBorder( - MessageManager.getString("label.recently_opened"))); - - final JScrollPane scroller = new JScrollPane(list); - - SpringLayout layout = new SpringLayout(); - layout.putConstraint(SpringLayout.WEST, scroller, 5, - SpringLayout.WEST, this); - layout.putConstraint(SpringLayout.NORTH, scroller, 5, - SpringLayout.NORTH, this); - - if (Platform.isAMac()) - { - scroller.setPreferredSize(new Dimension(500, 100)); - } - else - { - scroller.setPreferredSize(new Dimension(530, 200)); - } - - this.add(scroller); - - javax.swing.SwingUtilities.invokeLater(new Runnable() - { - @Override - public void run() - { - scroller.getHorizontalScrollBar() - .setValue(scroller.getHorizontalScrollBar().getMaximum()); - } - }); - - } - - } @Override public DialogRunnerI setResponseHandler(Object response, Runnable action) @@ -537,3 +470,78 @@ public class JalviewFileChooser extends JFileChooser implements DialogRunnerI, } } } + +class RecentlyOpened extends JPanel +{ + private static final long serialVersionUID = 1L; + JList list; + private JalviewFileChooser chooser; + + RecentlyOpened(JalviewFileChooser chooser) + { + this.chooser = chooser; + setPreferredSize(new Dimension(300,100)); + String historyItems = Cache.getProperty("RECENT_FILE"); + StringTokenizer st; + Vector recent = new Vector<>(); + + if (historyItems != null) + { + st = new StringTokenizer(historyItems, "\t"); + + while (st.hasMoreTokens()) + { + recent.addElement(st.nextToken()); + } + } + + list = new JList<>(recent); + + DefaultListCellRenderer dlcr = new DefaultListCellRenderer(); +// dlcr.setHorizontalAlignment(DefaultListCellRenderer.RIGHT); + list.setCellRenderer(dlcr); + + list.addMouseListener(new MouseAdapter() + { + @Override + public void mousePressed(MouseEvent evt) + { + chooser.recentListSelectionChanged(list.getSelectedValue()); + } + }); + + this.setBorder(new javax.swing.border.TitledBorder( + MessageManager.getString("label.recently_opened"))); + + final JScrollPane scroller = new JScrollPane(list); + + SpringLayout layout = new SpringLayout(); + layout.putConstraint(SpringLayout.WEST, scroller, 5, + SpringLayout.WEST, this); + layout.putConstraint(SpringLayout.NORTH, scroller, 5, + SpringLayout.NORTH, this); + + if (Platform.isAMac()) + { + scroller.setPreferredSize(new Dimension(500, 100)); + } + else + { + scroller.setPreferredSize(new Dimension(530, 200)); + } + + this.add(scroller); + + javax.swing.SwingUtilities.invokeLater(new Runnable() + { + @Override + public void run() + { + scroller.getHorizontalScrollBar() + .setValue(scroller.getHorizontalScrollBar().getMaximum()); + } + }); + + } + +}