From d5bffcbde0079308cb4909983140e7bacf35b7cf Mon Sep 17 00:00:00 2001 From: Ben Soares Date: Thu, 2 Jul 2020 15:36:41 +0100 Subject: [PATCH] JAL-3676 code review -- added non-listed Level into dropdown list --- src/jalview/gui/Console.java | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/src/jalview/gui/Console.java b/src/jalview/gui/Console.java index c0063c7..dc5968d 100644 --- a/src/jalview/gui/Console.java +++ b/src/jalview/gui/Console.java @@ -162,13 +162,13 @@ public class Console extends WindowAdapter MessageManager.getString("label.log_level") + ":"); // logLevelCombo.addItem(Level.ALL); + logLevelCombo.addItem(Level.TRACE); logLevelCombo.addItem(Level.DEBUG); logLevelCombo.addItem(Level.INFO); logLevelCombo.addItem(Level.WARN); // logLevelCombo.addItem(Level.ERROR); // logLevelCombo.addItem(Level.FATAL); // logLevelCombo.addItem(Level.OFF); - // logLevelCombo.addItem(Level.TRACE); setChosenLogLevelCombo(); logLevelCombo.addActionListener(new ActionListener() { @@ -253,9 +253,34 @@ public class Console extends WindowAdapter Level currentLogLevel = Cache.log == null ? Level.INFO : Cache.log.getLevel(); logLevelCombo.setSelectedItem(currentLogLevel); - if (!logLevelCombo.getSelectedItem().equals(currentLogLevel)) + if (!logLevelCombo.getSelectedItem().equals(currentLogLevel)) // currentLogLevel + // not in list { - logLevelCombo.setSelectedItem(Level.INFO); + if (currentLogLevel != null && currentLogLevel instanceof Level) + { + // add new item to list (might be set via .jalview_properties) + boolean added = false; + for (int i = 0; i < logLevelCombo.getItemCount(); i++) + { + Level l = (Level) logLevelCombo.getItemAt(i); + if (l.isGreaterOrEqual(currentLogLevel)) + { + logLevelCombo.insertItemAt(currentLogLevel, i); + added = true; + break; + } + } + if (!added) // lower priority than others or some confusion -- add to + // end of list + { + logLevelCombo.addItem(currentLogLevel); + } + logLevelCombo.setSelectedItem(currentLogLevel); + } + else + { + logLevelCombo.setSelectedItem(Level.INFO); + } } } @@ -267,11 +292,6 @@ public class Console extends WindowAdapter cb.setContents(consoleTextSelection, null); } - private void setLogLevel() - { - - } - PipedOutputStream pout = null, perr = null; public void redirectStreams() -- 1.7.10.2