Bob first commit JAL-3032
authorhansonr <hansonr@stolaf.edu>
Wed, 20 Jun 2018 09:59:05 +0000 (10:59 +0100)
committerhansonr <hansonr@stolaf.edu>
Wed, 20 Jun 2018 09:59:05 +0000 (10:59 +0100)
- jalview/bin/cache.java
 propsAreReadable true for JS
 authordetails, builddetails "xxx" for JS for now
- org.apache.log4j -> jalview.javascript.log4j (minimal)
- jalview/util/MessageManager switch to org.apache.log4j

JavaScript Status:

jalview.io.FileFormatException: Failed to read data from source: CANNOT
ACCESS DATA AT URL 'http://www.jalview.org/examples/uniref50.fa'
((intermediate value).toBIS$O is not a function

17 files changed:
.gitignore
.j2s [new file with mode: 0644]
SwingJS-site.zip [new file with mode: 0644]
src/jalview/bin/Cache.java
src/jalview/javascript/log4j/Appender.java [new file with mode: 0644]
src/jalview/javascript/log4j/ConsoleAppender.java [new file with mode: 0644]
src/jalview/javascript/log4j/Layout.java [new file with mode: 0644]
src/jalview/javascript/log4j/Level.java [new file with mode: 0644]
src/jalview/javascript/log4j/Logger.java [new file with mode: 0644]
src/jalview/javascript/log4j/Priority.java [new file with mode: 0644]
src/jalview/javascript/log4j/SimpleLayout.java [new file with mode: 0644]
src/jalview/javascript/log4j/WriterAppender.java [new file with mode: 0644]
src/jalview/javascript/log4j/spi/LoggingEvent.java [new file with mode: 0644]
src/jalview/javascript/log4j/spi/OptionHandler.java [new file with mode: 0644]
src/jalview/util/MessageManager.java
src/jalview/util/Platform.java
template.html [new file with mode: 0644]

index 2a55560..012a802 100644 (file)
@@ -12,4 +12,6 @@
 TESTNG
 /jalviewApplet.jar
 /benchmarking/lib
-*.class
\ No newline at end of file
+*.class
+/site/
+/srcjar/
diff --git a/.j2s b/.j2s
new file mode 100644 (file)
index 0000000..10e5647
--- /dev/null
+++ b/.j2s
@@ -0,0 +1,3 @@
+j2s.compiler.status=enable
+j2s.class.replacements=org.apache.log4j.->jalview.javascript.log4j.;
+
diff --git a/SwingJS-site.zip b/SwingJS-site.zip
new file mode 100644 (file)
index 0000000..4d17c4c
Binary files /dev/null and b/SwingJS-site.zip differ
index dcd6546..d374682 100755 (executable)
@@ -288,7 +288,8 @@ public class Cache
   /** Default file is ~/.jalview_properties */
   static String propertiesFile;
 
-  private static boolean propsAreReadOnly = false;
+  private static boolean propsAreReadOnly = /** @j2sNative true || */
+          false;
 
   public static void initLogger()
   {
@@ -399,7 +400,8 @@ public class Cache
     // LOAD THE AUTHORS FROM THE authors.props file
     try
     {
-      String authorDetails = "jar:"
+      String authorDetails = /** @j2sNative "xxx" || */
+              "jar:"
               .concat(Cache.class.getProtectionDomain().getCodeSource()
                       .getLocation().toString().concat("!/authors.props"));
 
@@ -421,7 +423,8 @@ public class Cache
     // VERSION MAY HAVE CHANGED SINCE LAST USING JALVIEW
     try
     {
-      String buildDetails = "jar:".concat(Cache.class.getProtectionDomain()
+      String buildDetails = /** @j2sNative "xxx" || */
+              "jar:".concat(Cache.class.getProtectionDomain()
               .getCodeSource().getLocation().toString()
               .concat("!/.build_properties"));
 
diff --git a/src/jalview/javascript/log4j/Appender.java b/src/jalview/javascript/log4j/Appender.java
new file mode 100644 (file)
index 0000000..1b2b676
--- /dev/null
@@ -0,0 +1,9 @@
+package jalview.javascript.log4j;
+
+import jalview.javascript.log4j.spi.LoggingEvent;
+
+public abstract class Appender
+{
+  public abstract void append(LoggingEvent loggingEvent);
+
+}
diff --git a/src/jalview/javascript/log4j/ConsoleAppender.java b/src/jalview/javascript/log4j/ConsoleAppender.java
new file mode 100644 (file)
index 0000000..f1aca45
--- /dev/null
@@ -0,0 +1,41 @@
+package jalview.javascript.log4j;
+
+import jalview.javascript.log4j.spi.LoggingEvent;
+
+public class ConsoleAppender
+{
+
+  private String name;
+
+  private Layout layout;
+
+
+  public ConsoleAppender()
+  {
+  }
+
+  public ConsoleAppender(Layout layout, String name)
+  {
+    this.layout = layout;
+    this.name = name;
+  }
+
+  public void setLayout(Layout layout)
+  {
+    this.layout = layout;
+  }
+
+  public void setName(String name)
+  {
+    this.name = name;
+  }
+
+  public void append(LoggingEvent event)
+  {
+
+    System.out
+            .println(event.getLevel() + ": " + event.getRenderedMessage());
+
+  }
+
+}
diff --git a/src/jalview/javascript/log4j/Layout.java b/src/jalview/javascript/log4j/Layout.java
new file mode 100644 (file)
index 0000000..ea79e1b
--- /dev/null
@@ -0,0 +1,86 @@
+/*
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
+ * 
+ * This file is part of Jalview.
+ * 
+ * Jalview is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License 
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
+ *  
+ * Jalview is distributed in the hope that it will be useful, but 
+ * WITHOUT ANY WARRANTY; without even the implied warranty 
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
+ * PURPOSE.  See the GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
+ */
+package jalview.javascript.log4j;
+
+import jalview.javascript.log4j.spi.LoggingEvent;
+import jalview.javascript.log4j.spi.OptionHandler;
+
+import org.apache.log4j.PatternLayout;
+import org.apache.log4j.TTCCLayout;
+
+public abstract class Layout implements OptionHandler
+{
+
+  // Note that the line.separator property can be looked up even by
+  // applets.
+  public final static String LINE_SEP = System
+          .getProperty("line.separator");
+
+  public final static int LINE_SEP_LEN = LINE_SEP.length();
+
+  /**
+   * Implement this method to create your own layout format.
+   */
+  abstract public String format(LoggingEvent event);
+
+  /**
+   * Returns the content type output by this layout. The base class returns
+   * "text/plain".
+   */
+  public String getContentType()
+  {
+    return "text/plain";
+  }
+
+  /**
+   * Returns the header for the layout format. The base class returns
+   * <code>null</code>.
+   */
+  public String getHeader()
+  {
+    return null;
+  }
+
+  /**
+   * Returns the footer for the layout format. The base class returns
+   * <code>null</code>.
+   */
+  public String getFooter()
+  {
+    return null;
+  }
+
+  /**
+   * If the layout handles the throwable object contained within
+   * {@link LoggingEvent}, then the layout should return <code>false</code>.
+   * Otherwise, if the layout ignores throwable object, then the layout should
+   * return <code>true</code>. If ignoresThrowable is true, the appender is
+   * responsible for rendering the throwable.
+   * <p>
+   * The {@link SimpleLayout}, {@link TTCCLayout}, {@link PatternLayout} all
+   * return <code>true</code>. The {@link org.apache.log4j.xml.XMLLayout}
+   * returns <code>false</code>.
+   * 
+   * @since 0.8.4
+   */
+  abstract public boolean ignoresThrowable();
+
+}
diff --git a/src/jalview/javascript/log4j/Level.java b/src/jalview/javascript/log4j/Level.java
new file mode 100644 (file)
index 0000000..5691a47
--- /dev/null
@@ -0,0 +1,271 @@
+package jalview.javascript.log4j;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.ObjectStreamException;
+import java.io.Serializable;
+
+/**
+ * Defines the minimum set of levels recognized by the system, that is
+ * <code>OFF</code>, <code>FATAL</code>, <code>ERROR</code>, <code>WARN</code>,
+ * <code>INFO</code>, <code>DEBUG</code> and <code>ALL</code>.
+ * 
+ * <p>
+ * The <code>Level</code> class may be subclassed to define a larger level set.
+ * </p>
+ * 
+ * @author Ceki G&uuml;lc&uuml;
+ */
+public class Level extends Priority implements Serializable
+{
+
+  private static final String ALL_NAME = "ALL";
+
+  private static final String TRACE_NAME = "TRACE";
+
+  private static final String DEBUG_NAME = "DEBUG";
+
+  private static final String INFO_NAME = "INFO";
+
+  private static final String WARN_NAME = "WARN";
+
+  private static final String ERROR_NAME = "ERROR";
+
+  private static final String FATAL_NAME = "FATAL";
+
+  private static final String OFF_NAME = "OFF";
+
+  /**
+   * TRACE level integer value.
+   * 
+   * @since 1.2.12
+   */
+  public static final int TRACE_INT = 5000;
+
+  /**
+   * The <code>OFF</code> has the highest possible rank and is intended to turn
+   * off logging.
+   */
+  final static public Level OFF = new Level(OFF_INT, OFF_NAME, 0);
+
+  /**
+   * The <code>FATAL</code> level designates very severe error events that will
+   * presumably lead the application to abort.
+   */
+  final static public Level FATAL = new Level(FATAL_INT, FATAL_NAME, 0);
+
+  /**
+   * The <code>ERROR</code> level designates error events that might still allow
+   * the application to continue running.
+   */
+  final static public Level ERROR = new Level(ERROR_INT, ERROR_NAME, 3);
+
+  /**
+   * The <code>WARN</code> level designates potentially harmful situations.
+   */
+  final static public Level WARN = new Level(WARN_INT, WARN_NAME, 4);
+
+  /**
+   * The <code>INFO</code> level designates informational messages that
+   * highlight the progress of the application at coarse-grained level.
+   */
+  final static public Level INFO = new Level(INFO_INT, INFO_NAME, 6);
+
+  /**
+   * The <code>DEBUG</code> Level designates fine-grained informational events
+   * that are most useful to debug an application.
+   */
+  final static public Level DEBUG = new Level(DEBUG_INT, DEBUG_NAME, 7);
+
+  /**
+   * The <code>TRACE</code> Level designates finer-grained informational events
+   * than the <code>DEBUG</code level.
+   * 
+   * @since 1.2.12
+   */
+  public static final Level TRACE = new Level(TRACE_INT, TRACE_NAME, 7);
+
+  /**
+   * The <code>ALL</code> has the lowest possible rank and is intended to turn
+   * on all logging.
+   */
+  final static public Level ALL = new Level(ALL_INT, ALL_NAME, 7);
+
+  /**
+   * Serialization version id.
+   */
+  static final long serialVersionUID = 3491141966387921974L;
+
+  /**
+   * Instantiate a Level object.
+   */
+  protected Level(int level, String levelStr, int syslogEquivalent)
+  {
+    super(level, levelStr, syslogEquivalent);
+  }
+
+  /**
+   * Convert the string passed as argument to a level. If the conversion fails,
+   * then this method returns {@link #DEBUG}.
+   */
+  public static Level toLevel(String sArg)
+  {
+    return toLevel(sArg, Level.DEBUG);
+  }
+
+  /**
+   * Convert an integer passed as argument to a level. If the conversion fails,
+   * then this method returns {@link #DEBUG}.
+   */
+  public static Level toLevel(int val)
+  {
+    return toLevel(val, Level.DEBUG);
+  }
+
+  /**
+   * Convert an integer passed as argument to a level. If the conversion fails,
+   * then this method returns the specified default.
+   */
+  public static Level toLevel(int val, Level defaultLevel)
+  {
+    switch (val)
+    {
+    case ALL_INT:
+      return ALL;
+    case DEBUG_INT:
+      return Level.DEBUG;
+    case INFO_INT:
+      return Level.INFO;
+    case WARN_INT:
+      return Level.WARN;
+    case ERROR_INT:
+      return Level.ERROR;
+    case FATAL_INT:
+      return Level.FATAL;
+    case OFF_INT:
+      return OFF;
+    case TRACE_INT:
+      return Level.TRACE;
+    default:
+      return defaultLevel;
+    }
+  }
+
+  /**
+   * Convert the string passed as argument to a level. If the conversion fails,
+   * then this method returns the value of <code>defaultLevel</code>.
+   */
+  public static Level toLevel(String sArg, Level defaultLevel)
+  {
+    if (sArg == null)
+    {
+      return defaultLevel;
+    }
+    String s = sArg.toUpperCase();
+
+    if (s.equals(ALL_NAME))
+    {
+      return Level.ALL;
+    }
+    if (s.equals(DEBUG_NAME))
+    {
+      return Level.DEBUG;
+    }
+    if (s.equals(INFO_NAME))
+    {
+      return Level.INFO;
+    }
+    if (s.equals(WARN_NAME))
+    {
+      return Level.WARN;
+    }
+    if (s.equals(ERROR_NAME))
+    {
+      return Level.ERROR;
+    }
+    if (s.equals(FATAL_NAME))
+    {
+      return Level.FATAL;
+    }
+    if (s.equals(OFF_NAME))
+    {
+      return Level.OFF;
+    }
+    if (s.equals(TRACE_NAME))
+    {
+      return Level.TRACE;
+    }
+    //
+    // For Turkish i problem, see bug 40937
+    //
+    if (s.equals("\u0130NFO"))
+    {
+      return Level.INFO;
+    }
+    return defaultLevel;
+  }
+
+  /**
+   * Custom deserialization of Level.
+   * 
+   * @param s
+   *          serialization stream.
+   * @throws IOException
+   *           if IO exception.
+   * @throws ClassNotFoundException
+   *           if class not found.
+   */
+  private void readObject(final ObjectInputStream s)
+          throws IOException, ClassNotFoundException
+  {
+    s.defaultReadObject();
+    level = s.readInt();
+    syslogEquivalent = s.readInt();
+    levelStr = s.readUTF();
+    if (levelStr == null)
+    {
+      levelStr = "";
+    }
+  }
+
+  /**
+   * Serialize level.
+   * 
+   * @param s
+   *          serialization stream.
+   * @throws IOException
+   *           if exception during serialization.
+   */
+  private void writeObject(final ObjectOutputStream s) throws IOException
+  {
+    s.defaultWriteObject();
+    s.writeInt(level);
+    s.writeInt(syslogEquivalent);
+    s.writeUTF(levelStr);
+  }
+
+  /**
+   * Resolved deserialized level to one of the stock instances. May be overriden
+   * in classes derived from Level.
+   * 
+   * @return resolved object.
+   * @throws ObjectStreamException
+   *           if exception during resolution.
+   */
+  private Object readResolve() throws ObjectStreamException
+  {
+    //
+    // if the deserizalized object is exactly an instance of Level
+    //
+    if (getClass() == Level.class)
+    {
+      return toLevel(level);
+    }
+    //
+    // extension of Level can't substitute stock item
+    //
+    return this;
+  }
+
+}
diff --git a/src/jalview/javascript/log4j/Logger.java b/src/jalview/javascript/log4j/Logger.java
new file mode 100644 (file)
index 0000000..bb7eb34
--- /dev/null
@@ -0,0 +1,194 @@
+/*
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
+ * 
+ * This file is part of Jalview.
+ * 
+ * Jalview is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License 
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
+ *  
+ * Jalview is distributed in the hope that it will be useful, but 
+ * WITHOUT ANY WARRANTY; without even the implied warranty 
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
+ * PURPOSE.  See the GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
+ */
+package jalview.javascript.log4j;
+
+import jalview.javascript.log4j.spi.LoggingEvent;
+
+import java.util.Hashtable;
+import java.util.Map;
+
+public class Logger
+{
+
+  private static Map<String, Logger> registry;
+
+  private String name;
+
+  private Level level;
+
+  private boolean enabled = true;
+
+  private boolean isEnabled;
+
+  private Appender appender;
+
+  private Logger(String name)
+  {
+    this.name = name;
+  }
+
+  public static Logger getLogger(String name)
+  {
+    if (registry == null)
+    {
+      registry = new Hashtable<>();
+      getLogger("root");
+    }
+    Logger logger = registry.get(name);
+    if (logger == null)
+    {
+      registry.put(name, logger = new Logger(name));
+      logger.setLevel(Level.INFO);
+    }
+    return logger;
+  }
+
+  public static Logger getRootLogger()
+  {
+    return getLogger("root");
+  }
+
+  public void setLevel(Level l)
+  {
+    this.level = l;
+  }
+
+  public void addAppender(Appender appender)
+  {
+    this.appender = appender;
+  }
+
+  public boolean isDebugEnabled()
+  {
+    return isEnabled;
+  }
+
+  public void debug(Object o)
+  {
+    debug(o, null);
+  }
+
+  public void debug(Object o, Throwable e)
+  {
+    switch (level.level)
+    {
+    case Priority.FATAL_INT:
+    case Priority.ERROR_INT:
+    case Priority.WARN_INT:
+    case Priority.INFO_INT:
+    case Priority.DEBUG_INT:
+      log(o, e);
+      break;
+    }
+  }
+
+  public void info(Object o)
+  {
+    info(o, null);
+  }
+
+  public void info(Object o, Throwable e)
+  {
+    switch (level.level)
+    {
+    case Priority.FATAL_INT:
+    case Priority.ERROR_INT:
+    case Priority.WARN_INT:
+    case Priority.INFO_INT:
+      log(o, e);
+      break;
+    }
+
+  }
+
+  public void warn(Object o)
+  {
+    warn(o, null);
+  }
+
+  public void warn(Object o, Throwable e)
+  {
+    switch (level.level)
+    {
+    case Priority.FATAL_INT:
+    case Priority.ERROR_INT:
+    case Priority.WARN_INT:
+      log(o, e);
+      break;
+    }
+
+  }
+
+  public void error(Object o)
+  {
+    error(o, null);
+  }
+
+  public void error(Object o, Throwable e)
+  {
+    switch (level.level)
+    {
+    case Priority.FATAL_INT:
+    case Priority.ERROR_INT:
+      log(o, e);
+      break;
+    }
+
+  }
+
+  private void log(Object s, Throwable e)
+  {
+    switch (level.level)
+    {
+    case Priority.ERROR_INT:
+      if (appender == null)
+      {
+        System.err.println(s);
+        return;
+      }
+      break;
+    case Priority.WARN_INT:
+      if (appender == null)
+      {
+        System.err.println(s);
+        return;
+      }
+      break;
+    case Priority.INFO_INT:
+      if (appender == null)
+      {
+        System.out.println(s);
+        return;
+      }
+      break;
+    case Priority.DEBUG_INT:
+      if (appender == null)
+      {
+        System.out.println(s);
+        return;
+      }
+      break;
+    }
+    e.printStackTrace();
+    appender.append(new LoggingEvent(this, s.toString(), level));
+  }
+
+}
diff --git a/src/jalview/javascript/log4j/Priority.java b/src/jalview/javascript/log4j/Priority.java
new file mode 100644 (file)
index 0000000..2ace1eb
--- /dev/null
@@ -0,0 +1,204 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// Contributors:  Kitching Simon <Simon.Kitching@orange.ch>
+
+package jalview.javascript.log4j;
+
+/**
+   <font color="#AA4444">Refrain from using this class directly, use
+   the {@link Level} class instead</font>.
+
+   @author Ceki G&uuml;lc&uuml; */
+public class Priority {
+
+  transient int level;
+  transient String levelStr;
+  transient int syslogEquivalent;
+
+  public final static int OFF_INT = Integer.MAX_VALUE;
+  public final static int FATAL_INT = 50000;
+  public final static int ERROR_INT = 40000;
+  public final static int WARN_INT  = 30000;
+  public final static int INFO_INT  = 20000;
+  public final static int DEBUG_INT = 10000;
+    //public final static int FINE_INT = DEBUG_INT;
+  public final static int ALL_INT = Integer.MIN_VALUE;
+
+  // too twisted for J2S -- Level class initializer initializes Priority, which
+  // creates a
+  // new Level before Priority is indicated to be a superclass of Level.
+  /**
+   * @deprecated Use {@link Level#FATAL} instead.
+   */
+  @Deprecated
+  final static public Priority FATAL = null;// new Level(FATAL_INT, "FATAL", 0);
+
+  /**
+   * @deprecated Use {@link Level#ERROR} instead.
+   */
+  @Deprecated
+  final static public Priority ERROR = null;// new Level(ERROR_INT, "ERROR", 3);
+
+  /**
+   * @deprecated Use {@link Level#WARN} instead.
+   */
+  @Deprecated
+  final static public Priority WARN = null;// new Level(WARN_INT, "WARN", 4);
+
+  /**
+   * @deprecated Use {@link Level#INFO} instead.
+   */
+  @Deprecated
+  final static public Priority INFO = null;// new Level(INFO_INT, "INFO", 6);
+
+  /**
+   * @deprecated Use {@link Level#DEBUG} instead.
+   */
+  @Deprecated
+  final static public Priority DEBUG = null;// new Level(DEBUG_INT, "DEBUG", 7);
+
+  /**
+    * Default constructor for deserialization.
+    */
+  protected Priority() {
+      level = DEBUG_INT;
+      levelStr = "DEBUG";
+      syslogEquivalent = 7;
+  }
+
+  /**
+     Instantiate a level object.
+   */
+  protected
+  Priority(int level, String levelStr, int syslogEquivalent) {
+    this.level = level;
+    this.levelStr = levelStr;
+    this.syslogEquivalent = syslogEquivalent;
+  }
+
+  /**
+     Two priorities are equal if their level fields are equal.
+     @since 1.2
+   */
+  @Override
+  public
+  boolean equals(Object o) {
+    if(o instanceof Priority) {
+      Priority r = (Priority) o;
+      return (this.level == r.level);
+    } else {
+      return false;
+    }
+  }
+
+  /**
+     Return the syslog equivalent of this priority as an integer.
+   */
+  public
+  final
+  int getSyslogEquivalent() {
+    return syslogEquivalent;
+  }
+
+
+   
+  /**
+     Returns <code>true</code> if this level has a higher or equal
+     level than the level passed as argument, <code>false</code>
+     otherwise.  
+     
+     <p>You should think twice before overriding the default
+     implementation of <code>isGreaterOrEqual</code> method.
+
+  */
+  public
+  boolean isGreaterOrEqual(Priority r) {
+    return level >= r.level;
+  }
+
+  // /**
+  // Return all possible priorities as an array of Level objects in
+  // descending order.
+  //
+  // @deprecated This method will be removed with no replacement.
+  // */
+  // public
+  // static
+  // Priority[] getAllPossiblePriorities() {
+  // return new Priority[] {Priority.FATAL, Priority.ERROR, Level.WARN,
+  // Priority.INFO, Priority.DEBUG};
+  // }
+
+
+  /**
+     Returns the string representation of this priority.
+   */
+  @Override
+  final
+  public
+  String toString() {
+    return levelStr;
+  }
+
+  /**
+     Returns the integer representation of this level.
+   */
+  public
+  final
+  int toInt() {
+    return level;
+  }
+
+  // /**
+  // * @deprecated Please use the {@link Level#toLevel(String)} method instead.
+  // */
+  // public
+  // static
+  // Priority toPriority(String sArg) {
+  // return Level.toLevel(sArg);
+  // }
+
+  // /**
+  // * @deprecated Please use the {@link Level#toLevel(int)} method instead.
+  // */
+  // public
+  // static
+  // Priority toPriority(int val) {
+  // return toPriority(val, Priority.DEBUG);
+  // }
+
+  // /**
+  // * @deprecated Please use the {@link Level#toLevel(int, Level)} method
+  // instead.
+  // */
+  // public
+  // static
+  // Priority toPriority(int val, Priority defaultPriority) {
+  // return Level.toLevel(val, (Level) defaultPriority);
+  // }
+  //
+  // /**
+  // * @deprecated Please use the {@link Level#toLevel(String, Level)} method
+  // instead.
+  // */
+  // public
+  // static
+  // Priority toPriority(String sArg, Priority defaultPriority) {
+  // return Level.toLevel(sArg, (Level) defaultPriority);
+  // }
+}
diff --git a/src/jalview/javascript/log4j/SimpleLayout.java b/src/jalview/javascript/log4j/SimpleLayout.java
new file mode 100644 (file)
index 0000000..9e5cbba
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
+ * 
+ * This file is part of Jalview.
+ * 
+ * Jalview is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License 
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
+ *  
+ * Jalview is distributed in the hope that it will be useful, but 
+ * WITHOUT ANY WARRANTY; without even the implied warranty 
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
+ * PURPOSE.  See the GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
+ */
+package jalview.javascript.log4j;
+
+import jalview.javascript.log4j.spi.LoggingEvent;
+
+public class SimpleLayout extends Layout
+{
+
+  StringBuffer sbuf = new StringBuffer(128);
+
+  @Override
+  public void activateOptions()
+  {
+    // TODO Auto-generated method stub
+
+  }
+
+  @Override
+  public String format(LoggingEvent event)
+  {
+
+    sbuf.setLength(0);
+    sbuf.append(event.getLevel().toString());
+    sbuf.append(" - ");
+    sbuf.append(event.getRenderedMessage());
+    sbuf.append(LINE_SEP);
+    return sbuf.toString();
+  }
+  @Override
+  public boolean ignoresThrowable()
+  {
+    // TODO Auto-generated method stub
+    return false;
+  }
+
+}
diff --git a/src/jalview/javascript/log4j/WriterAppender.java b/src/jalview/javascript/log4j/WriterAppender.java
new file mode 100644 (file)
index 0000000..1a015f2
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package jalview.javascript.log4j;
+
+public abstract class WriterAppender extends Appender
+{
+
+}
diff --git a/src/jalview/javascript/log4j/spi/LoggingEvent.java b/src/jalview/javascript/log4j/spi/LoggingEvent.java
new file mode 100644 (file)
index 0000000..669ae52
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
+ * 
+ * This file is part of Jalview.
+ * 
+ * Jalview is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License 
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
+ *  
+ * Jalview is distributed in the hope that it will be useful, but 
+ * WITHOUT ANY WARRANTY; without even the implied warranty 
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
+ * PURPOSE.  See the GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
+ */
+package jalview.javascript.log4j.spi;
+
+import jalview.javascript.log4j.Logger;
+
+public class LoggingEvent
+{
+
+  private Object level;
+
+  private String msg;
+
+  private Logger logger;
+
+  public LoggingEvent(Logger logger, String level, Object message)
+  {
+    this.logger = logger;
+    this.level = level;
+    this.msg = message.toString();
+
+  }
+
+  public Object getLevel()
+  {
+    return level;
+  }
+
+  public String getRenderedMessage()
+  {
+    return msg;
+  }
+}
diff --git a/src/jalview/javascript/log4j/spi/OptionHandler.java b/src/jalview/javascript/log4j/spi/OptionHandler.java
new file mode 100644 (file)
index 0000000..9cd0f01
--- /dev/null
@@ -0,0 +1,8 @@
+package jalview.javascript.log4j.spi;
+
+public interface OptionHandler
+{
+
+  void activateOptions();
+
+}
index 66d8f9f..1cfe0c6 100644 (file)
@@ -24,8 +24,10 @@ import java.text.MessageFormat;
 import java.util.Locale;
 import java.util.ResourceBundle;
 import java.util.ResourceBundle.Control;
-import java.util.logging.Level;
-import java.util.logging.Logger;
+//import java.util.logging.Level;
+//import java.util.logging.Logger;
+
+import org.apache.log4j.Logger;
 
 /**
  * 
@@ -37,6 +39,8 @@ import java.util.logging.Logger;
 public class MessageManager
 {
 
+  // BH 2018 switched to org.apache.llog4j.Logger
+
   private static ResourceBundle rb;
 
   private static Logger log = Logger
@@ -55,19 +59,19 @@ public class MessageManager
       log.info("Getting messages for lang: " + loc);
       Control control = Control.getControl(Control.FORMAT_PROPERTIES);
       rb = ResourceBundle.getBundle("lang.Messages", loc, control);
-      if (log.isLoggable(Level.FINEST))
-      {
-        // this might take a while, so we only do it if it will be shown
-        log.finest("Language keys: " + rb.keySet());
-      }
+      // if (log.isLoggable(Level.FINEST))
+      // {
+      // // this might take a while, so we only do it if it will be shown
+      // log.info("Language keys: " + rb.keySet()); // was FINEST
+      // }
     } catch (Exception q)
     {
-      log.warning("Exception when initting Locale for i18n messages\n"
+      log.warn("Exception when initting Locale for i18n messages\n"
               + q.getMessage());
       q.printStackTrace();
     } catch (Error v)
     {
-      log.warning("Error when initting Locale for i18n messages\n"
+      log.warn("Error when initting Locale for i18n messages\n"
               + v.getMessage());
       v.printStackTrace();
     }
@@ -82,7 +86,7 @@ public class MessageManager
       value = rb.getString(key);
     } catch (Exception e)
     {
-      log.warning("I18N missing: " + loc + "\t" + key);
+      log.warn("I18N missing: " + loc + "\t" + key);
     }
     return value;
   }
@@ -121,8 +125,8 @@ public class MessageManager
       name = rb.getString(smkey);
     } catch (Exception x)
     {
-      log.finest("I18N missing key with root " + keyroot + ": " + loc + "\t"
-              + smkey);
+      log.info("I18N missing key with root " + keyroot + ": " + loc + "\t"
+              + smkey); // was FINEST
     }
     return name;
   }
index 2c74609..6a5f133 100644 (file)
@@ -30,6 +30,7 @@ import java.awt.event.MouseEvent;
  */
 public class Platform
 {
+
   private static Boolean isAMac = null, isWindows = null;
 
   private static Boolean isHeadless = null;
@@ -37,13 +38,16 @@ public class Platform
   /**
    * sorry folks - Macs really are different
    * 
+   * BH: disabled for SwingJS -- will need to check key-press issues
+   * 
    * @return true if we do things in a special way.
    */
   public static boolean isAMac()
   {
     if (isAMac == null)
     {
-      isAMac = System.getProperty("os.name").indexOf("Mac") > -1;
+      isAMac = /** @j2sNative false && */
+              System.getProperty("os.name").indexOf("Mac") > -1;
     }
 
     return isAMac.booleanValue();
@@ -59,7 +63,8 @@ public class Platform
   {
     if (isWindows == null)
     {
-      isWindows = System.getProperty("os.name").indexOf("Win") > -1;
+      isWindows = /** @j2sNative false && */
+              System.getProperty("os.name").indexOf("Win") > -1;
     }
     return isWindows.booleanValue();
   }
diff --git a/template.html b/template.html
new file mode 100644 (file)
index 0000000..5005060
--- /dev/null
@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>SwingJS test _NAME_</title><meta charset="utf-8" />
+<script src="swingjs/swingjs2.js"></script>
+<script>
+if (!self.SwingJS)alert('swingjs2.js was not found. It needs to be in swingjs folder in the same directory as ' + document.location.href)
+Info = {
+  code: _CODE_,
+  main: _MAIN_,
+       width: 850,
+       height: 550,
+  readyFunction: null,
+       serverURL: 'https://chemapps.stolaf.edu/jmol/jsmol/php/jsmol.php',
+       j2sPath: 'swingjs/j2s',
+       console:'sysoutdiv',
+       allowjavascript: true
+}
+</script>
+</head>
+<body>
+<script>
+SwingJS.getApplet('testApplet', Info)
+getClassList = function(){J2S._saveFile('_j2sclasslist.txt', Clazz.ClassFilesLoaded.sort().join('\n'))}
+</script>
+<div style="position:absolute;left:900px;top:30px;width:600px;height:300px;">
+<div id="sysoutdiv" style="border:1px solid green;width:100%;height:95%;overflow:auto"></div>
+This is System.out. <a href="javascript:testApplet._clearConsole()">clear it</a> <br>Add ?j2snocore to URL to see full class list; ?j2sdebug to use uncompressed j2s/core files <br><a href="javascript:getClassList()">get _j2sClassList.txt</a>
+</div>
+</body>
+</html>