}
if (file == null || !file.exists())
{
+ if (file != null)
+ {
+ jalview.bin.Console
+ .errPrintln("Could not load bootstrap preferences file '"
+ + file.getPath() + "'");
+ }
String channelPrefsFilename = ChannelProperties
.getProperty("preferences.filename");
String propertiesFilename = System.getProperty("user.home")
+ File.separatorChar + channelPrefsFilename;
+ jalview.bin.Console.errPrintln(
+ "Using default properties file '" + propertiesFilename + "'");
file = new File(propertiesFilename);
}
if (file == null || !file.exists())
+
{
String releasePrefsFilename = fallbackPropertiesFile;
String releasePropertiesFilename = System.getProperty("user.home")
+ File.separatorChar + releasePrefsFilename;
+ jalview.bin.Console.errPrintln("Falling back to properties file '"
+ + releasePropertiesFilename + "'");
file = new File(releasePropertiesFilename);
}
- if (filename == null)
- return null;
if (!file.exists())
{
jalview.bin.Console
.errPrintln("Could not load bootstrap preferences file '"
- + filename + "'");
+ + file.getPath() + "'");
return null;
}
package jalview.bin;
import java.io.PrintStream;
-import java.util.Locale;
import jalview.log.JLogger;
-import jalview.log.JLoggerI;
import jalview.log.JLoggerI.LogLevel;
import jalview.log.JLoggerLog4j;
import jalview.util.ChannelProperties;
{
JLogger.LogLevel logLevel = JLogger.LogLevel.INFO;
- if (JLogger.isLevel(providedLogLevel))
+ if (providedLogLevel != null && JLogger.isLevel(providedLogLevel))
{
logLevel = Console.getLogLevel(providedLogLevel);
}
public static void setLogLevel(String logLevelString)
{
- for (LogLevel logLevel : JLoggerI.LogLevel.values())
+ LogLevel l = null;
+ try
+ {
+ l = LogLevel.valueOf(logLevelString);
+ } catch (IllegalArgumentException | NullPointerException e1)
+ {
+ Console.debug("Invalid log level '" + logLevelString + "'");
+ return;
+ }
+ if (l != null)
{
- if (logLevel.toString().toLowerCase(Locale.ROOT)
- .equals(logLevelString.toLowerCase(Locale.ROOT)))
+ log.setLevel(l);
+ if (!Platform.isJS())
{
- log.setLevel(logLevel);
- if (!Platform.isJS())
- {
- Log4j.init(logLevel);
- }
- JLoggerLog4j.getLogger("org.apache.axis", logLevel);
- break;
+ Log4j.init(l);
}
+ JLoggerLog4j.getLogger("org.apache.axis", l);
}
}
try
{
Console.initLogger();
- } catch (
-
- NoClassDefFoundError error)
+ } catch (NoClassDefFoundError error)
{
error.printStackTrace();
String message = "\nEssential logging libraries not found."
+ "\nUse: java -classpath \"$PATH_TO_LIB$/*:$PATH_TO_CLASSES$\" jalview.bin.Jalview";
- Jalview.exit(message, ExitCode.OK);
+ Jalview.exit(message, ExitCode.NO_LOGGING);
}
desktop = null;
PromptUserConfig prompter = new PromptUserConfig(Desktop.desktop,
"USAGESTATS",
MessageManager.getString("prompt.analytics_title"),
- MessageManager.getString("prompt.analytics"),
- new Runnable()
+ MessageManager.getString("prompt.analytics"), new Runnable()
{
@Override
public void run()
// only add new ones to the end of the list (to preserve ordinal values)
OK, FILE_NOT_FOUND, FILE_NOT_READABLE, NO_FILES, INVALID_FORMAT,
INVALID_ARGUMENT, INVALID_VALUE, MIXED_CLI_ARGUMENTS,
- ERROR_RUNNING_COMMANDS;
+ ERROR_RUNNING_COMMANDS, NO_LOGGING;
}
/******************************
import javax.swing.border.Border;
import javax.swing.text.DefaultCaret;
+import jalview.bin.Cache;
import jalview.log.JLoggerI.LogLevel;
import jalview.log.JLoggerLog4j;
import jalview.log.JalviewAppender;
private JComboBox<LogLevel> logLevelCombo = new JComboBox<LogLevel>();
- protected LogLevel startingLogLevel = LogLevel.INFO;
+ protected LogLevel startingLogLevel = null;
public Console()
{
scrollPane.setBorder(noBorder);
textArea.addMouseListener(new MouseAdapter()
{
+ @Override
public void mouseClicked(MouseEvent e)
{
if (e.getButton() == MouseEvent.BUTTON1)
MessageManager.getString("label.copy_to_clipboard"));
copyToClipboardButton.addActionListener(new ActionListener()
{
+ @Override
public void actionPerformed(ActionEvent e)
{
copyConsoleTextToClipboard();
private Color fg = textArea.getForeground();
+ @Override
public void mousePressed(MouseEvent e)
{
textArea.setBackground(textArea.getSelectionColor());
textArea.setForeground(textArea.getSelectedTextColor());
}
+ @Override
public void mouseReleased(MouseEvent e)
{
textArea.setBackground(bg);
// logLevelCombo.addItem(LogLevel.ERROR);
// logLevelCombo.addItem(LogLevel.OFF);
// set startingLogLevel
- startingLogLevel = jalview.bin.Console.log == null ? LogLevel.INFO
- : jalview.bin.Console.log.getLevel();
+ if (jalview.bin.Console.log == null)
+ {
+ try
+ {
+ startingLogLevel = LogLevel
+ .valueOf(Cache.getDefault(Cache.JALVIEWLOGLEVEL, null));
+ } catch (IllegalArgumentException e1)
+ {
+ jalview.bin.Console.debug(
+ "Invalid value for preference " + Cache.JALVIEWLOGLEVEL);
+ } catch (NullPointerException e2)
+ {
+ // no value in preferences
+ } finally
+ {
+ if (startingLogLevel == null)
+ {
+ startingLogLevel = LogLevel.INFO;
+ }
+ }
+ }
+ else
+ {
+ startingLogLevel = jalview.bin.Console.log.getLevel();
+ }
setChosenLogLevelCombo();
logLevelCombo.addActionListener(new ActionListener()
{
+ @Override
public void actionPerformed(ActionEvent e)
{
if (jalview.bin.Console.log != null)
boolean added = false;
for (int i = 0; i < logLevelCombo.getItemCount(); i++)
{
- LogLevel l = (LogLevel) logLevelCombo.getItemAt(i);
+ LogLevel l = logLevelCombo.getItemAt(i);
if (l.compareTo(setLogLevel) >= 0)
{
logLevelCombo.insertItemAt(setLogLevel, i);
*/
public Console(Desktop desktop)
{
- this(desktop, true);
- }
-
- /**
- * attach a console to the desktop - the desktop will open it if requested.
- *
- * @param desktop
- * @param showjconsole
- * - if true, then redirect stdout immediately
- */
- public Console(Desktop desktop, boolean showjconsole)
- {
parent = desktop;
// window name - get x,y,width, height possibly scaled
- Rectangle bounds = desktop.getLastKnownDimensions("JAVA_CONSOLE_");
+ Rectangle bounds = parent.getLastKnownDimensions("JAVA_CONSOLE_");
if (bounds == null)
{
frame = initFrame(
ChannelProperties.getProperty("app_name") + " Java Console",
- desktop.getWidth() / 2, desktop.getHeight() / 4,
- desktop.getX(), desktop.getY());
+ parent.getWidth() / 2, parent.getHeight() / 4, parent.getX(),
+ parent.getY());
}
else
{
bounds.width, bounds.height, bounds.x, bounds.y);
}
frame.setMinimumSize(new Dimension(MIN_WIDTH, MIN_HEIGHT));
- // desktop.add(frame);
+ // parent.add(frame);
initConsole(false);
LogLevel level = (LogLevel) logLevelCombo.getSelectedItem();
if (!Platform.isJS())
boolean selmemusage = Cache.getDefault("SHOW_MEMUSAGE", false);
boolean showjconsole = Cache.getDefault("SHOW_JAVA_CONSOLE", false);
+
+ // start dialogue queue for single dialogues
+ startDialogQueue();
+
+ if (!Platform.isJS())
+ /**
+ * Java only
+ *
+ * @j2sIgnore
+ */
+ {
+ Desktop.instance.acquireDialogQueue();
+
+ jconsole = new Console(this);
+ jconsole.setHeader(Cache.getVersionDetailsForConsole());
+ showConsole(showjconsole);
+
+ Desktop.instance.releaseDialogQueue();
+ }
+
desktop = new MyDesktopPane(selmemusage);
showMemusage.setSelected(selmemusage);
setBounds(xPos, yPos, 900, 650);
}
- // start dialogue queue for single dialogues
- startDialogQueue();
-
if (!Platform.isJS())
/**
* Java only
* @j2sIgnore
*/
{
- jconsole = new Console(this, showjconsole);
- jconsole.setHeader(Cache.getVersionDetailsForConsole());
- showConsole(showjconsole);
-
showNews.setVisible(false);
experimentalFeatures.setSelected(showExperimental());