ShichimiFX 1.0.3 released

I have released ShichimiFX 1.0.3.

Get the code from my ShichimiFX Bitbucket Repo

Maven

<dependency>
  <groupId>de.jensd</groupId>
  <artifactId>shichimifx</artifactId>
  <version>1.0.3</version>
</dependency>

This release mostly focuses on the ConsoleStream. I have fixed some performance issues. Also optionally now an alternate stream can be given, e.g. to pass through System.out.
This is used for displaying the logging stream in my lastest release of MQTT.fx.

mqttfx-log-tab

public class ConsoleDude {

    public final static PrintStream STD_OUT = System.out;
    public final static PrintStream STD_ERR = System.err;
    private static BooleanProperty stdStreamsHooked = new SimpleBooleanProperty();

    public static void hookStdStreams(TextInputControl outputArea) {
        PrintStream psOut = new PrintStream(new ConsoleStream(outputArea, System.out), true);
        System.setOut(psOut);
        PrintStream psErr = new PrintStream(new ConsoleStream(outputArea, System.err), true);
        System.setOut(psErr);
        stdStreamsHookedProperty().set(true);
    }

    public static void restoreStdStreams() {
        System.setOut(STD_OUT);
        System.setErr(STD_ERR);
        stdStreamsHookedProperty().set(false);
    }

    public static BooleanProperty stdStreamsHookedProperty() {
        if (stdStreamsHooked == null) {
            stdStreamsHooked = new SimpleBooleanProperty();
        }
        return stdStreamsHooked;
    }

    public boolean isHooked() {
        return stdStreamsHookedProperty().get();
    }

    public static ConsoleStreamHandler createConsoleStreamHandler(TextInputControl outputArea) {
        return createConsoleStreamHandler(outputArea, new SimpleFormatter());
    }

    public static ConsoleStreamHandler createConsoleStreamHandler(TextInputControl outputArea, Formatter formatter) {
        return new ConsoleStreamHandler(new ConsoleStream(outputArea), formatter);
    }

}
public class ConsoleStream extends ByteArrayOutputStream {

    private final TextInputControl textOutputComponent;
    private final StringBuilder buffer;
    private final String EOL = System.getProperty("line.separator");
    private final PrintStream printStream;

    public ConsoleStream(TextInputControl ta) {
        this(ta, null);
    }

    public ConsoleStream(TextInputControl ta, PrintStream printStream) {
        this.textOutputComponent = ta;
        this.printStream = printStream;
        buffer = new StringBuilder(80);
    }

    @Override
    public void flush() throws IOException {
        String text = toString();
        if (text.length() == 0) {
            return;
        }
        append(text);
        reset();
    }

    private void append(String text) {
        if (textOutputComponent.getLength() == 0) {
            buffer.setLength(0);
        }
        if (EOL.equals(text)) {
            buffer.append(text);
        } else {
            buffer.append(text);
            clearBuffer();
        }
    }

    private void clearBuffer() {
        String line = buffer.toString();
        Platform.runLater(() -> {
            textOutputComponent.appendText(line);
        });
        if (printStream != null) {
            printStream.print(line);
        }
        buffer.setLength(0);
    }

}

MQTT.fx 0.0.12 released

Download latest binaries at mqttfx.org.
Bugs and feature requests can be reported via the issue tracker.

New in this version:

MQTT version support for 3.1 and 3.1.1
The MQTT version can be set via ConnectonProfile (default: 3.1.1, if not supported by broker: 3.1)
mqttfx-mqtt-version

New: “Log”-tab
MQTT.fx 0.0.12 introduces a new tab to capture/show the logging stream:
mqttfx-log-tab

Changed rendering of messages
mqttfx-message-tile

Wildcard Topics
Improved handling of topics containing wildcards.

MQTT.fx is now using paho 1.0.1

Fixed bugs and issues
Fixed some issues when connect/disconnect/connection lost