From: Ben Soares Date: Thu, 2 Jul 2020 14:36:41 +0000 (+0100) Subject: JAL-3676 code review -- added non-listed Level into dropdown list X-Git-Tag: Release_2_11_1_1~13^2~26^2~6^2~3^2~4 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=c6584ae5dccdd8166a863a29f265973aab82e784;p=jalview.git JAL-3676 code review -- added non-listed Level into dropdown list --- diff --git a/src/jalview/gui/Console.java b/src/jalview/gui/Console.java index e9cf150..d91985d 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()