+ // and a thread to append text to the textarea
+ textAppender = new Thread(this);
+ textAppender.setDaemon(true);
+ textAppender.start();
+ }
+
+ private void setChosenLogLevelCombo()
+ {
+ setChosenLogLevelCombo(startingLogLevel);
+ }
+
+ private void setChosenLogLevelCombo(Level setLogLevel)
+ {
+ logLevelCombo.setSelectedItem(setLogLevel);
+ if (!logLevelCombo.getSelectedItem().equals(setLogLevel))
+ {
+ // 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(setLogLevel))
+ {
+ logLevelCombo.insertItemAt(setLogLevel, i);
+ added = true;
+ break;
+ }
+ }
+ if (!added) // lower priority than others or some confusion -- add to
+ // end of list
+ {
+ logLevelCombo.addItem(setLogLevel);
+ }
+ logLevelCombo.setSelectedItem(setLogLevel);
+ }
+ else
+ {
+ logLevelCombo.setSelectedItem(Level.INFO);
+ }
+ }
+ }
+
+ private void copyConsoleTextToClipboard()
+ {
+ String consoleText = textArea.getText();
+ StringSelection consoleTextSelection = new StringSelection(consoleText);
+ Clipboard cb = Toolkit.getDefaultToolkit().getSystemClipboard();
+ cb.setContents(consoleTextSelection, null);
+ }
+
+ PipedOutputStream pout = null, perr = null;
+
+ public void redirectStreams()
+ {
+ if (pout == null)
+ {
+ try
+ {
+ pout = new PipedOutputStream(this.pin);
+ System.setOut(new PrintStream(pout, true));
+ } catch (java.io.IOException io)
+ {
+ textArea.append("Couldn't redirect STDOUT to this console\n"
+ + io.getMessage());
+ io.printStackTrace(stderr);
+ } catch (SecurityException se)
+ {
+ textArea.append("Couldn't redirect STDOUT to this console\n"
+ + se.getMessage());
+ se.printStackTrace(stderr);
+ }
+
+ try
+ {
+ perr = new PipedOutputStream(this.pin2);
+ System.setErr(new PrintStream(perr, true));
+ } catch (java.io.IOException io)
+ {
+ textArea.append("Couldn't redirect STDERR to this console\n"
+ + io.getMessage());
+ io.printStackTrace(stderr);
+ } catch (SecurityException se)
+ {
+ textArea.append("Couldn't redirect STDERR to this console\n"
+ + se.getMessage());
+ se.printStackTrace(stderr);
+ }
+ }