X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fbin%2FJalview.java;h=071d700e1569ac9b082ba39cc118b42a341b59cc;hb=9b3bed72df9fa38b8f8007b87a019356d55a030b;hp=546e9317567c25f3232a04b7e9b1a3cb48685ecb;hpb=dc3a780cb6d3fbf782b53f5eac3d4d6318121519;p=jalview.git diff --git a/src/jalview/bin/Jalview.java b/src/jalview/bin/Jalview.java index 546e931..071d700 100755 --- a/src/jalview/bin/Jalview.java +++ b/src/jalview/bin/Jalview.java @@ -45,12 +45,16 @@ import java.util.logging.ConsoleHandler; import java.util.logging.Level; import java.util.logging.Logger; +import javax.swing.JDialog; +import javax.swing.JFrame; import javax.swing.JOptionPane; import javax.swing.SwingUtilities; import javax.swing.UIManager; import javax.swing.UIManager.LookAndFeelInfo; +import javax.swing.UnsupportedLookAndFeelException; import com.formdev.flatlaf.FlatLightLaf; +import com.formdev.flatlaf.themes.FlatMacLightLaf; import com.formdev.flatlaf.util.SystemInfo; import com.threerings.getdown.util.LaunchUtil; @@ -61,6 +65,8 @@ import jalview.ext.so.SequenceOntology; import jalview.gui.AlignFrame; import jalview.gui.Desktop; import jalview.gui.PromptUserConfig; +import jalview.gui.QuitHandler; +import jalview.gui.QuitHandler.QResponse; import jalview.io.AppletFormatAdapter; import jalview.io.BioJsHTMLOutput; import jalview.io.DataSourceType; @@ -73,8 +79,6 @@ import jalview.io.HtmlSvgOutput; import jalview.io.IdentifyFile; import jalview.io.NewickFile; import jalview.io.gff.SequenceOntologyFactory; -import jalview.jbgui.QuitHandler; -import jalview.jbgui.QuitHandler.QResponse; import jalview.schemes.ColourSchemeI; import jalview.schemes.ColourSchemeProperty; import jalview.util.ChannelProperties; @@ -876,6 +880,8 @@ public class Jalview * @j2sIgnore */ { + boolean defaultStartupFile = Cache.getDefault("STARTUP_FILE", + null) == null; file = Cache.getDefault("STARTUP_FILE", Cache.getDefault("www.jalview.org", "https://www.jalview.org") + "/examples/exampleFile_2_7.jvp"); @@ -889,6 +895,7 @@ public class Jalview file.replace("2_7.jar", "2_7.jvp"); // and remove the stale setting Cache.removeProperty("STARTUP_FILE"); + defaultStartupFile = true; } protocol = AppletFormatAdapter.checkProtocol(file); @@ -910,6 +917,11 @@ public class Jalview startUpAlframe = fileLoader.LoadFileWaitTillLoaded(file, protocol, format); + if (defaultStartupFile) + { + Console.debug("Resetting up-to-date flag for startup file"); + startUpAlframe.getViewport().setSavedUpToDate(true); + } // extract groovy arguments before anything else. } @@ -1001,20 +1013,6 @@ public class Jalview Console.error("Could not set requested laf=" + laf); } break; - case "quaqua": - lafSet = setQuaquaLookAndFeel(); - if (!lafSet) - { - Console.error("Could not set requested laf=" + laf); - } - break; - case "vaqua": - lafSet = setVaquaLookAndFeel(); - if (!lafSet) - { - Console.error("Could not set requested laf=" + laf); - } - break; case "mac": lafSet = setMacLookAndFeel(); if (!lafSet) @@ -1032,7 +1030,7 @@ public class Jalview setSystemLookAndFeel(); if (Platform.isLinux()) { - setMetalLookAndFeel(); + setLinuxLookAndFeel(); } if (Platform.isMac()) { @@ -1123,55 +1121,112 @@ public class Jalview private static boolean setFlatLookAndFeel() { - boolean set = setSpecificLookAndFeel("flatlaf light", - "com.formdev.flatlaf.FlatLightLaf", false); - if (set) + boolean set = false; + if (SystemInfo.isMacOS) { - if (Platform.isMac()) + try { - System.setProperty("apple.laf.useScreenMenuBar", "true"); - System.setProperty("apple.awt.application.name", - ChannelProperties.getProperty("app_name")); - System.setProperty("apple.awt.application.appearance", "system"); - if (SystemInfo.isMacFullWindowContentSupported - && Desktop.desktop != null) - { - Desktop.desktop.getRootPane() - .putClientProperty("apple.awt.fullWindowContent", true); - Desktop.desktop.getRootPane() - .putClientProperty("apple.awt.transparentTitleBar", true); - } + UIManager.setLookAndFeel("com.formdev.flatlaf.FlatMacLightLaf"); + set = true; + Console.debug("Using FlatMacLightLaf"); + } catch (ClassNotFoundException | InstantiationException + | IllegalAccessException | UnsupportedLookAndFeelException e) + { + Console.debug("Exception loading FlatLightLaf", e); + } + System.setProperty("apple.laf.useScreenMenuBar", "true"); + System.setProperty("apple.awt.application.name", + ChannelProperties.getProperty("app_name")); + System.setProperty("apple.awt.application.appearance", "system"); + if (SystemInfo.isMacFullWindowContentSupported + && Desktop.desktop != null) + { + Console.debug("Setting transparent title bar"); + Desktop.desktop.getRootPane() + .putClientProperty("apple.awt.fullWindowContent", true); + Desktop.desktop.getRootPane() + .putClientProperty("apple.awt.transparentTitleBar", true); + Desktop.desktop.getRootPane() + .putClientProperty("apple.awt.fullscreenable", true); + } + SwingUtilities.invokeLater(() -> { + FlatMacLightLaf.setup(); + }); + Console.debug("Using FlatMacLightLaf"); + set = true; + } + else if (SystemInfo.isWindows) + { + try + { + UIManager.setLookAndFeel("com.formdev.flatlaf.FlatLightLaf"); + set = true; + Console.debug("Using FlatLightLaf"); + } catch (ClassNotFoundException | InstantiationException + | IllegalAccessException | UnsupportedLookAndFeelException e) + { + Console.debug("Exception loading FlatLightLaf", e); + } + // Windows specific properties here + SwingUtilities.invokeLater(() -> { + FlatLightLaf.setup(); + }); + Console.debug("Using FlatLightLaf"); + set = true; + } + else if (SystemInfo.isLinux) + { + try + { + UIManager.setLookAndFeel("com.formdev.flatlaf.FlatLightLaf"); + set = true; + Console.debug("Using FlatLightLaf"); + } catch (ClassNotFoundException | InstantiationException + | IllegalAccessException | UnsupportedLookAndFeelException e) + { + Console.debug("Exception loading FlatLightLaf", e); + } + // enable custom window decorations + JFrame.setDefaultLookAndFeelDecorated(true); + JDialog.setDefaultLookAndFeelDecorated(true); + SwingUtilities.invokeLater(() -> { + FlatLightLaf.setup(); + }); + Console.debug("Using FlatLightLaf"); + set = true; + } - SwingUtilities.invokeLater(() -> { - FlatLightLaf.setup(); - }); + if (!set) + { + try + { + UIManager.setLookAndFeel("com.formdev.flatlaf.FlatLightLaf"); + set = true; + Console.debug("Using FlatLightLaf"); + } catch (ClassNotFoundException | InstantiationException + | IllegalAccessException | UnsupportedLookAndFeelException e) + { + Console.debug("Exception loading FlatLightLaf", e); } + } + if (set) + { + UIManager.put("TabbedPane.tabType", "card"); UIManager.put("TabbedPane.showTabSeparators", true); + UIManager.put("TabbedPane.showContentSeparator", true); UIManager.put("TabbedPane.tabSeparatorsFullHeight", true); UIManager.put("TabbedPane.tabsOverlapBorder", true); - // UIManager.put("TabbedPane.hasFullBorder", true); + UIManager.put("TabbedPane.hasFullBorder", true); UIManager.put("TabbedPane.tabLayoutPolicy", "scroll"); UIManager.put("TabbedPane.scrollButtonsPolicy", "asNeeded"); UIManager.put("TabbedPane.smoothScrolling", true); UIManager.put("TabbedPane.tabWidthMode", "compact"); UIManager.put("TabbedPane.selectedBackground", Color.white); } - return set; - } - private static boolean setQuaquaLookAndFeel() - { - return setSpecificLookAndFeel("quaqua", - ch.randelshofer.quaqua.QuaquaManager.getLookAndFeel().getClass() - .getName(), - false); - } - - private static boolean setVaquaLookAndFeel() - { - return setSpecificLookAndFeel("vaqua", - "org.violetlib.aqua.AquaLookAndFeel", false); + Desktop.setLiveDragMode(Cache.getDefault("FLAT_LIVE_DRAG_MODE", true)); + return set; } private static boolean setMacLookAndFeel() @@ -1193,6 +1248,18 @@ public class Jalview return set; } + private static boolean setLinuxLookAndFeel() + { + boolean set = false; + set = setFlatLookAndFeel(); + if (!set) + set = setMetalLookAndFeel(); + // avoid GtkLookAndFeel -- not good results especially on HiDPI + if (!set) + set = setNimbusLookAndFeel(); + return set; + } + private static void showUsage() { System.out.println(