/** * Prints line with selected color * @param io IO to print to * @param text a string to print to the tab * @param color a color for the line of text (null allowed). If null is passed default color (see {@link IOColors}) is used. */ public static void println(InputOutput io, CharSequence text, Color color) throws IOException { IOColorLines iocl = find(io); if (iocl != null) { iocl.println(text, null, false, color); } }
@Override public void publish(LogRecord record) { if ((record.getMessage() == null || record.getMessage().isEmpty()) && record.getThrown() == null) { //Nothing to log return; } Color color = Color.BLACK; if (record.getLevel().equals(Level.WARNING)) { color = Color.ORANGE; } else if (record.getLevel().equals(Level.SEVERE)) { color = Color.RED; } String msg = formatter.format(record); if (IOColorLines.isSupported(io)) { try { IOColorLines.println(io, msg, color); } catch (IOException ex) { outputWriter.println(msg); } } else { outputWriter.println(msg); } }
private static void print(InputOutput io, String message, Color color) { try { IOColorLines.println(io, message, color); } catch (IOException ex) { Exceptions.printStackTrace(ex); } }
/** * Checks whether this feature is supported for provided IO * @param io IO to check on * @return true if supported */ public static boolean isSupported(InputOutput io) { return find(io) != null; }
/** * Prints line with selected color * @param io IO to print to * @param text a string to print to the tab * @param listener a listener that will receive events about this line * @param important important mark the line as important. * Makes the UI respond appropriately, eg. stop the automatic scrolling * or highlight the hyperlink. * @param color a color for the line of text (null allowed). If null is passed default color (see {@link IOColors}) is used. */ public static void println(InputOutput io, CharSequence text, OutputListener listener, boolean important, Color color) throws IOException { IOColorLines iocl = find(io); if (iocl != null) { iocl.println(text, listener, important, color); } }