JAL-1643 Modified JalviewFileChooser to have a more native laf on mac
authorCharles Ofoegbu <tcnofoegbu@dundee.ac.uk>
Wed, 4 Feb 2015 05:39:03 +0000 (05:39 +0000)
committerCharles Ofoegbu <tcnofoegbu@dundee.ac.uk>
Wed, 4 Feb 2015 05:39:03 +0000 (05:39 +0000)
.classpath
lib/libquaqua.jnilib [new file with mode: 0644]
lib/libquaqua64.jnilib [new file with mode: 0644]
lib/quaqua-filechooser-only.jar [new file with mode: 0644]
src/jalview/bin/Jalview.java
src/jalview/io/JalviewFileChooser.java

index f87dd26..1714959 100644 (file)
        <classpathentry kind="lib" path="lib/log4j-to-slf4j-2.0-rc2.jar"/>
        <classpathentry kind="lib" path="lib/slf4j-log4j12-1.7.7.jar"/>
        <classpathentry kind="lib" path="lib/VARNAv3-91.jar"/>
-
        <classpathentry kind="lib" path="lib/jfreesvg-2.1.jar"/>
        <classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/plugin.jar"/>
        <classpathentry kind="lib" path="lib/xml-apis.jar"/>
        <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
        <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
        <classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/Plugin.jar"/>
+       <classpathentry kind="lib" path="lib/quaqua-filechooser-only.jar"/>
        <classpathentry kind="output" path="classes"/>
 </classpath>
diff --git a/lib/libquaqua.jnilib b/lib/libquaqua.jnilib
new file mode 100644 (file)
index 0000000..a3c9e8a
Binary files /dev/null and b/lib/libquaqua.jnilib differ
diff --git a/lib/libquaqua64.jnilib b/lib/libquaqua64.jnilib
new file mode 100644 (file)
index 0000000..5378540
Binary files /dev/null and b/lib/libquaqua64.jnilib differ
diff --git a/lib/quaqua-filechooser-only.jar b/lib/quaqua-filechooser-only.jar
new file mode 100644 (file)
index 0000000..429fe77
Binary files /dev/null and b/lib/quaqua-filechooser-only.jar differ
index ff1b180..42202dd 100755 (executable)
@@ -49,6 +49,7 @@ import java.util.Map;
 import java.util.Vector;
 
 import javax.swing.UIManager;
+import javax.swing.UnsupportedLookAndFeelException;
 
 /**
  * Main class for Jalview Application <br>
@@ -91,12 +92,23 @@ public class Jalview
     System.out.println(System.getProperty("os.arch") + " "
             + System.getProperty("os.name") + " "
             + System.getProperty("os.version"));
-    if (new Platform().isAMac())
-    {
-      System.setProperty("com.apple.mrj.application.apple.menu.about.name",
-              "Jalview");
-      System.setProperty("apple.laf.useScreenMenuBar", "true");
-    }
+    // if (new Platform().isAMac())
+    // {
+    // // System.setProperty("com.apple.mrj.application.apple.menu.about.name",
+    // // "Jalview");
+    // // System.setProperty("apple.laf.useScreenMenuBar", "true");
+    // try
+    // {
+    // UIManager.setLookAndFeel(ch.randelshofer.quaqua.QuaquaManager
+    // .getLookAndFeel());
+    // System.out
+    // .println("--------------------------------------------> in here");
+    // } catch (UnsupportedLookAndFeelException e)
+    // {
+    // // TODO Auto-generated catch block
+    // e.printStackTrace();
+    // }
+    // }
 
     ArgsParser aparser = new ArgsParser(args);
     boolean headless = false;
@@ -172,6 +184,21 @@ public class Jalview
     } catch (Exception ex)
     {
     }
+    if (new Platform().isAMac())
+    {
+      System.setProperty("com.apple.mrj.application.apple.menu.about.name",
+              "Jalview");
+      System.setProperty("apple.laf.useScreenMenuBar", "true");
+      try
+      {
+        UIManager.setLookAndFeel(ch.randelshofer.quaqua.QuaquaManager
+                .getLookAndFeel());
+      } catch (UnsupportedLookAndFeelException e)
+      {
+        // TODO Auto-generated catch block
+        e.printStackTrace();
+      }
+    }
 
     if (!headless)
     {
index df8decf..f0e0cb1 100755 (executable)
@@ -39,6 +39,7 @@ import javax.swing.JList;
 import javax.swing.JOptionPane;
 import javax.swing.JPanel;
 import javax.swing.JScrollPane;
+import javax.swing.SpringLayout;
 
 /**
  * Enhanced file chooser dialog box.
@@ -260,6 +261,7 @@ public class JalviewFileChooser extends JFileChooser
 
     public RecentlyOpened()
     {
+
       String historyItems = jalview.bin.Cache.getProperty("RECENT_FILE");
       StringTokenizer st;
       Vector recent = new Vector();
@@ -292,7 +294,17 @@ public class JalviewFileChooser extends JFileChooser
       this.setBorder(new javax.swing.border.TitledBorder(MessageManager.getString("label.recently_opened")));
 
       final JScrollPane scroller = new JScrollPane(list);
-      scroller.setPreferredSize(new Dimension(130, 200));
+
+      SpringLayout layout = new SpringLayout();
+      layout.putConstraint(SpringLayout.WEST, scroller, 5,
+              SpringLayout.WEST, this);
+      layout.putConstraint(SpringLayout.NORTH, scroller, 5,
+              SpringLayout.NORTH, this);
+
+      // scroller.setPreferredSize(new Dimension(130, 200));
+
+
+      scroller.setPreferredSize(new Dimension(500, 100));
       this.add(scroller);
 
       javax.swing.SwingUtilities.invokeLater(new Runnable()