private int MIN_HEIGHT = 250;
- private JComboBox logLevelCombo = new JComboBox();
+ private JComboBox<Level> logLevelCombo = new JComboBox<Level>();
+
+ protected Level startingLogLevel = Level.INFO;
public Console()
{
// logLevelCombo.addItem(Level.ERROR);
// logLevelCombo.addItem(Level.FATAL);
// logLevelCombo.addItem(Level.OFF);
+ // set startingLogLevel
+ startingLogLevel = Cache.log == null ? Level.INFO
+ : Cache.log.getLevel();
setChosenLogLevelCombo();
logLevelCombo.addActionListener(new ActionListener()
{
logLevelPanel.setAlignmentX(JPanel.LEFT_ALIGNMENT);
logLevelPanel.add(logLevelLabel);
logLevelPanel.add(logLevelCombo);
- logLevelLabel.setToolTipText(
- MessageManager.getString("label.log_level_tooltip"));
- logLevelCombo.setToolTipText(
- MessageManager.getString("label.log_level_tooltip"));
+ String logLevelTooltip = MessageManager.formatMessage(
+ "label.log_level_tooltip", startingLogLevel.toString());
+ logLevelLabel.setToolTipText(logLevelTooltip);
+ logLevelCombo.setToolTipText(logLevelTooltip);
GridBagConstraints gbc = new GridBagConstraints();
gbc.gridx = 0;
private void setChosenLogLevelCombo()
{
- Level currentLogLevel = Cache.log == null ? Level.INFO
- : Cache.log.getLevel();
- logLevelCombo.setSelectedItem(currentLogLevel);
- if (!logLevelCombo.getSelectedItem().equals(currentLogLevel)) // currentLogLevel
- // not in list
+ setChosenLogLevelCombo(startingLogLevel);
+ }
+
+ private void setChosenLogLevelCombo(Level setLogLevel)
+ {
+ logLevelCombo.setSelectedItem(setLogLevel);
+ if (!logLevelCombo.getSelectedItem().equals(setLogLevel))
{
- if (currentLogLevel != null && currentLogLevel instanceof Level)
+ // setLogLevel not (yet) in list
+ if (setLogLevel != null && setLogLevel 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))
+ if (l.isGreaterOrEqual(setLogLevel))
{
- logLevelCombo.insertItemAt(currentLogLevel, i);
+ logLevelCombo.insertItemAt(setLogLevel, i);
added = true;
break;
}
if (!added) // lower priority than others or some confusion -- add to
// end of list
{
- logLevelCombo.addItem(currentLogLevel);
+ logLevelCombo.addItem(setLogLevel);
}
- logLevelCombo.setSelectedItem(currentLogLevel);
+ logLevelCombo.setSelectedItem(setLogLevel);
}
else
{
}
else
{
- // reset log level to user preference
+ // reset log level to what it was before
if (Cache.log != null)
{
- String userLogLevel = Cache.getDefault("logs.Jalview.level",
- Level.INFO.toString());
- Cache.log.setLevel(Level.toLevel(userLogLevel));
+ Cache.log.setLevel(startingLogLevel);
}
unredirectStreams();