*/
package jalview.bin;
-import jalview.datamodel.PDBEntry;
-import jalview.gui.UserDefinedColours;
-import jalview.schemes.ColourSchemeLoader;
-import jalview.schemes.ColourSchemes;
-import jalview.schemes.UserColourScheme;
-import jalview.structure.StructureImportSettings;
-import jalview.urls.IdOrgSettings;
-import jalview.util.ColorUtils;
-import jalview.util.Platform;
-import jalview.ws.sifts.SiftsSettings;
-
import java.awt.Color;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
+import java.io.PrintWriter;
+import java.io.StringWriter;
import java.net.URL;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import org.apache.log4j.Logger;
import org.apache.log4j.SimpleLayout;
+import jalview.datamodel.PDBEntry;
+import jalview.gui.UserDefinedColours;
+import jalview.schemes.ColourSchemeLoader;
+import jalview.schemes.ColourSchemes;
+import jalview.schemes.UserColourScheme;
+import jalview.structure.StructureImportSettings;
+import jalview.urls.IdOrgSettings;
+import jalview.util.ColorUtils;
+import jalview.util.Platform;
+import jalview.ws.sifts.SiftsSettings;
+
/**
* Stores and retrieves Jalview Application Properties Lists and fields within
* list entries are separated by '|' symbols unless otherwise stated (|) clauses
// lcastor.setLevel(Level.toLevel(Cache.getDefault("logs.Castor.Level",
// Level.INFO.toString())));
// we shouldn't need to do this
- org.apache.log4j.Logger.getRootLogger().setLevel(org.apache.log4j.Level.INFO);
+ org.apache.log4j.Logger.getRootLogger()
+ .setLevel(org.apache.log4j.Level.INFO);
jalview.bin.Cache.log.setLevel(Level.toLevel(Cache
.getDefault("logs.Jalview.level", Level.INFO.toString())));
InputStream fis;
try
{
- fis = new java.net.URL(propertiesFile).openStream();
+ fis = new URL(propertiesFile).openStream();
System.out.println(
"Loading jalview properties from : " + propertiesFile);
System.out.println(
}
if (authorDetails == null)
{
- applicationProperties.remove("AUTHORS");
- applicationProperties.remove("AUTHORFNAMES");
- applicationProperties.remove("YEAR");
+ applicationProperties.remove("AUTHORS");
+ applicationProperties.remove("AUTHORFNAMES");
+ applicationProperties.remove("YEAR");
}
loadBuildProperties(false);
String jnlpVersion = System.getProperty("jalview.version");
- // jnlpVersion will be null if a latest version check for the channel needs to
- // be done
+ // jnlpVersion will be null if a latest version check for the channel needs
+ // to be done
// Dont do this check if running in headless mode
if (jnlpVersion == null && getDefault("VERSION_CHECK", true)
&& (System.getProperty("java.awt.headless") == null || System
.getProperty("java.awt.headless").equals("false")))
{
- new Thread()
+
+ class VersionChecker extends Thread
{
@Override
public void run()
setProperty("LATEST_VERSION", remoteVersion);
}
- }.start();
+ }
+
+ VersionChecker vc = new VersionChecker();
+ vc.start();
}
else
{
url = Cache.class.getResource(resourcePath).toString();
} catch (Exception ex)
{
- System.err.println("Failed to resolve resource " + resourcePath + ": "
- + ex.getMessage());
+ System.err.println("Failed to resolve resource " + resourcePath
+ + ": " + ex.getMessage());
}
}
else
new BuildDetails(codeVersion, null, codeInstallation);
if (printVersion && reportVersion)
{
- System.out
- .println("Jalview Version: " + codeVersion + codeInstallation);
+ System.out.println(
+ "Jalview Version: " + codeVersion + codeInstallation);
}
}
public static String getVersionDetailsForConsole()
{
StringBuilder sb = new StringBuilder();
- sb.append("Jalview Version: " + jalview.bin.Cache.getDefault("VERSION", "TEST"));
+ sb.append("Jalview Version: ");
+ sb.append(jalview.bin.Cache.getDefault("VERSION", "TEST"));
sb.append("\n");
- sb.append("Jalview Installation: "
- + jalview.bin.Cache.getDefault("INSTALLATION", "unknown"));
+ sb.append("Jalview Installation: ");
+ sb.append(jalview.bin.Cache.getDefault("INSTALLATION", "unknown"));
sb.append("\n");
- sb.append("Build Date: " + jalview.bin.Cache.getDefault("BUILD_DATE", "unknown"));
+ sb.append("Build Date: ");
+ sb.append(jalview.bin.Cache.getDefault("BUILD_DATE", "unknown"));
sb.append("\n");
- sb.append("Java version: " + System.getProperty("java.version"));
+ sb.append("Java version: ");
+ sb.append(System.getProperty("java.version"));
sb.append("\n");
- sb.append(System.getProperty("os.arch") + " " + System.getProperty("os.name") + " " + System.getProperty("os.version"));
+ sb.append(System.getProperty("os.arch"));
+ sb.append(" ");
+ sb.append(System.getProperty("os.name"));
+ sb.append(" ");
+ sb.append(System.getProperty("os.version"));
sb.append("\n");
appendIfNotNull(sb, "Install4j version: ",
System.getProperty("sys.install4jVersion"), "\n", null);
appendIfNotNull(sb, "Launcher version: ",
System.getProperty("launcher_version"), "\n", null);
LookAndFeel laf = UIManager.getLookAndFeel();
- String lafName = laf == null?"Not obtained":laf.getName();
- String lafClass = laf == null?"unknown":laf.getClass().getName();
- appendIfNotNull(sb, "LookAndFeel: ", lafName+" ("+lafClass+")", "\n", null);
- // Not displayed in release version ( determined by possible version number regex 9[9.]*9[.-_a9]* )
- if (Pattern.matches("^\\d[\\d\\.]*\\d[\\.\\-\\w]*$", jalview.bin.Cache.getDefault("VERSION", "TEST"))) {
+ String lafName = laf == null ? "Not obtained" : laf.getName();
+ String lafClass = laf == null ? "unknown" : laf.getClass().getName();
+ sb.append("LookAndFeel: ");
+ sb.append(lafName);
+ sb.append(" (");
+ sb.append(lafClass);
+ sb.append(")\n");
+ // Not displayed in release version ( determined by possible version number
+ // regex 9[9.]*9[.-_a9]* )
+ if (Pattern.matches("^\\d[\\d\\.]*\\d[\\.\\-\\w]*$",
+ jalview.bin.Cache.getDefault("VERSION", "TEST")))
+ {
appendIfNotNull(sb, "Getdown appdir: ",
System.getProperty("getdownappdir"), "\n", null);
appendIfNotNull(sb, "Java home: ", System.getProperty("java.home"),
// eg 'built from Source' or update channel
return jalview.bin.Cache.getDefault("INSTALLATION", "unknown");
}
+
+ public static String getStackTraceString(Throwable t)
+ {
+ StringWriter sw = new StringWriter();
+ PrintWriter pw = new PrintWriter(sw);
+ t.printStackTrace(pw);
+ return sw.toString();
+ }
}
Platform.getURLCommandArguments();
}
- // singleton instance of this class
-
+ /*
+ * singleton instance of this class
+ */
private static Jalview instance;
private Desktop desktop;
ArgsParser aparser = new ArgsParser(args);
boolean headless = false;
+ if (aparser.contains("help") || aparser.contains("h"))
+ {
+ showUsage();
+ System.exit(0);
+ }
+ if (aparser.contains("nodisplay") || aparser.contains("nogui")
+ || aparser.contains("headless"))
+ {
+ System.setProperty("java.awt.headless", "true");
+ headless = true;
+ }
String usrPropsFile = aparser.getValue("props");
Cache.loadProperties(usrPropsFile); // must do this before
if (usrPropsFile != null)
"Invalid jabaws parameter: " + jabawsUrl + " ignored");
}
}
-
}
+
String defs = aparser.getValue("setprop");
while (defs != null)
{
{
Cache.setProperty(defs.substring(0, p), defs.substring(p + 1));
}
+ // DISABLED FOR SECURITY REASONS
+ // TODO: add a property to allow properties to be overriden by cli args
+ // Cache.setProperty(defs.substring(0,p), defs.substring(p+1));
}
defs = aparser.getValue("setprop");
}
desktop = null;
- // property laf = "crossplatform", "system", "gtk", "metal" or "mac"
- // If not set (or chosen laf fails), use the normal SystemLaF and if on Mac,
- // try Quaqua/Vaqua.
- String lafProp = System.getProperty("laf");
- String lafSetting = Cache.getDefault("PREFERRED_LAF", null);
- String laf = "none";
- if (lafProp != null)
- {
- laf = lafProp;
- }
- else if (lafSetting != null)
- {
- laf = lafSetting;
- }
- boolean lafSet = false;
- switch (laf)
- {
- case "crossplatform":
- lafSet = setCrossPlatformLookAndFeel();
- if (!lafSet)
- {
- System.err.println("Could not set requested laf=" + laf);
- }
- break;
- case "system":
- lafSet = setSystemLookAndFeel();
- if (!lafSet)
- {
- System.err.println("Could not set requested laf=" + laf);
- }
- break;
- case "gtk":
- lafSet = setGtkLookAndFeel();
- {
- System.err.println("Could not set requested laf=" + laf);
- }
- break;
- case "metal":
- lafSet = setMetalLookAndFeel();
- {
- System.err.println("Could not set requested laf=" + laf);
- }
- break;
- case "nimbus":
- lafSet = setNimbusLookAndFeel();
- {
- System.err.println("Could not set requested laf=" + laf);
- }
- break;
- case "quaqua":
- lafSet = setQuaquaLookAndFeel();
- {
- System.err.println("Could not set requested laf=" + laf);
- }
- break;
- case "vaqua":
- lafSet = setVaquaLookAndFeel();
- {
- System.err.println("Could not set requested laf=" + laf);
- }
- break;
- case "mac":
- lafSet = setMacLookAndFeel();
- if (!lafSet)
- {
- System.err.println("Could not set requested laf=" + laf);
- }
- break;
- case "none":
- break;
- default:
- System.err.println("Requested laf=" + laf + " not implemented");
- }
- if (!lafSet)
- {
- setSystemLookAndFeel();
- if (Platform.isLinux() && !Platform.isJS())
- {
- setMetalLookAndFeel();
- }
- if (Platform.isAMacAndNotJS())
- {
- setMacLookAndFeel();
- }
- }
+ setLookAndFeel();
/*
* configure 'full' SO model if preferences say to, else use the default (full SO)
if (!headless)
{
-
desktop = new Desktop();
desktop.setInBatchMode(true); // indicate we are starting up
try
{
JalviewTaskbar.setTaskbar(this);
+ } catch (Exception e)
+ {
+ Cache.log.info("Cannot set Taskbar");
+ Cache.log.error(e.getMessage());
+ // e.printStackTrace();
} catch (Throwable t)
{
- System.out.println("Error setting Taskbar: " + t.getMessage());
+ Cache.log.info("Cannot set Taskbar");
+ Cache.log.error(t.getMessage());
+ // t.printStackTrace();
}
desktop.setVisible(true);
}
}
- private static boolean setCrossPlatformLookAndFeel()
+ private static void setLookAndFeel()
{
- return setGenericLookAndFeel(false);
+ // property laf = "crossplatform", "system", "gtk", "metal", "nimbus" or
+ // "mac"
+ // If not set (or chosen laf fails), use the normal SystemLaF and if on Mac,
+ // try Quaqua/Vaqua.
+ String lafProp = System.getProperty("laf");
+ String lafSetting = Cache.getDefault("PREFERRED_LAF", null);
+ String laf = "none";
+ if (lafProp != null)
+ {
+ laf = lafProp;
+ }
+ else if (lafSetting != null)
+ {
+ laf = lafSetting;
+ }
+ boolean lafSet = false;
+ switch (laf)
+ {
+ case "crossplatform":
+ lafSet = setCrossPlatformLookAndFeel();
+ if (!lafSet)
+ {
+ Cache.log.error("Could not set requested laf=" + laf);
+ }
+ break;
+ case "system":
+ lafSet = setSystemLookAndFeel();
+ if (!lafSet)
+ {
+ Cache.log.error("Could not set requested laf=" + laf);
+ }
+ break;
+ case "gtk":
+ lafSet = setGtkLookAndFeel();
+ if (!lafSet)
+ {
+ Cache.log.error("Could not set requested laf=" + laf);
+ }
+ break;
+ case "metal":
+ lafSet = setMetalLookAndFeel();
+ if (!lafSet)
+ {
+ Cache.log.error("Could not set requested laf=" + laf);
+ }
+ break;
+ case "nimbus":
+ lafSet = setNimbusLookAndFeel();
+ if (!lafSet)
+ {
+ Cache.log.error("Could not set requested laf=" + laf);
+ }
+ break;
+ case "quaqua":
+ lafSet = setQuaquaLookAndFeel();
+ if (!lafSet)
+ {
+ Cache.log.error("Could not set requested laf=" + laf);
+ }
+ break;
+ case "vaqua":
+ lafSet = setVaquaLookAndFeel();
+ if (!lafSet)
+ {
+ Cache.log.error("Could not set requested laf=" + laf);
+ }
+ break;
+ case "mac":
+ lafSet = setMacLookAndFeel();
+ if (!lafSet)
+ {
+ Cache.log.error("Could not set requested laf=" + laf);
+ }
+ break;
+ case "none":
+ break;
+ default:
+ Cache.log.error("Requested laf=" + laf + " not implemented");
+ }
+ if (!lafSet)
+ {
+ setSystemLookAndFeel();
+ if (Platform.isLinux())
+ {
+ setMetalLookAndFeel();
+ }
+ if (Platform.isMac())
+ {
+ setMacLookAndFeel();
+ }
+ }
}
- private static boolean setSystemLookAndFeel()
+ private static boolean setCrossPlatformLookAndFeel()
{
- return setGenericLookAndFeel(true);
+ boolean set = false;
+ try
+ {
+ UIManager.setLookAndFeel(
+ UIManager.getCrossPlatformLookAndFeelClassName());
+ set = true;
+ } catch (Exception ex)
+ {
+ Cache.log.error("Unexpected Look and Feel Exception");
+ Cache.log.error(ex.getMessage());
+ Cache.log.debug(Cache.getStackTraceString(ex));
+ }
+ return set;
}
- private static boolean setGenericLookAndFeel(boolean system)
+ private static boolean setSystemLookAndFeel()
{
boolean set = false;
try
{
- UIManager.setLookAndFeel(
- system ? UIManager.getSystemLookAndFeelClassName()
- : UIManager.getCrossPlatformLookAndFeelClassName());
+ UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
set = true;
} catch (Exception ex)
{
- System.err.println("Unexpected Look and Feel Exception");
- ex.printStackTrace();
+ Cache.log.error("Unexpected Look and Feel Exception");
+ Cache.log.error(ex.getMessage());
+ Cache.log.debug(Cache.getStackTraceString(ex));
}
return set;
}
set = true;
} catch (Exception ex)
{
- System.err.println("Unexpected Look and Feel Exception");
- ex.printStackTrace();
+ Cache.log.error("Unexpected Look and Feel Exception");
+ Cache.log.error(ex.getMessage());
+ Cache.log.debug(Cache.getStackTraceString(ex));
}
return set;
}
+ "-jabaws URL\tSpecify URL for Jabaws services (e.g. for a local installation).\n"
+ "-fetchfrom nickname\tQuery nickname for features for the alignments and display them.\n"
+ "-groovy FILE\tExecute groovy script in FILE, after all other arguments have been processed (if FILE is the text 'STDIN' then the file will be read from STDIN)\n"
- + "-jvmmempc=PERCENT\tOnly available with standalone executable jar or jalview.bin.Launcher. Limit maximum heap size (memory) to PERCENT% of total physical memory detected. This defaults to 90 if total physical memory can be detected. See https://www.jalview.org/help/html/memory.html for more details.\n"
- + "-jvmmemmax=MAXMEMORY\tOnly available with standalone executable jar or jalview.bin.Launcher. Limit maximum heap size (memory) to MAXMEMORY. MAXMEMORY can be specified in bytes, kilobytes(k), megabytes(m), gigabytes(g) or if you're lucky enough, terabytes(t). This defaults to 32g if total physical memory can be detected, or to 8g if total physical memory cannot be detected. See https://www.jalview.org/help/html/memory.html for more details.\n"
+ "\n~Read documentation in Application or visit http://www.jalview.org for description of Features and Annotations file~\n\n");
}