diff --git a/gclc-swt/src/main/java/net/bigeon/gclc/swt/ConsoleOutputManager.java b/gclc-swt/src/main/java/net/bigeon/gclc/swt/ConsoleOutputManager.java index 1b0f51d..2ad7a0e 100644 --- a/gclc-swt/src/main/java/net/bigeon/gclc/swt/ConsoleOutputManager.java +++ b/gclc-swt/src/main/java/net/bigeon/gclc/swt/ConsoleOutputManager.java @@ -38,103 +38,14 @@ package net.bigeon.gclc.swt; */ import org.eclipse.swt.widgets.Text; -import org.eclipse.swt.widgets.Widget; -import net.bigeon.gclc.utils.AOutputForwardRunnable; +import net.bigeon.gclc.swt.tools.ToSWTConsoleForwardRunnable; import net.bigeon.gclc.utils.PipedConsoleOutput; /** The manager for console output to insert in a text. * * @author Emmanuel Bigeon */ public final class ConsoleOutputManager implements ConsoleOutputDisplay { - /** A runnable appending text to the content of a {@link Text} component. - * - * @author Emmanuel Bigeon */ - private static class TextAppendingRunnable implements Runnable { - /** The text to append on a line (possibly new). */ - private final String next; - /** The {@link Text} component. */ - private final Text text; - - /** Create the appending runnable. - * - * @param text the component to update - * @param next the text to append */ - public TextAppendingRunnable(final Text text, final String next) { - this.text = text; - this.next = next; - } - - /* (non-Javadoc) - * @see java.lang.Runnable#run() */ - @Override - public void run() { - final String initialText = text.getText(); - if (initialText != null && !initialText.isEmpty()) { - text.append(System.lineSeparator()); - } - text.append(next); - } - } - - /** The local implementation of the forwarding runnable. - * - * @author Emmanuel Bigeon */ - private static final class ToSWTConsoleForwardRunnable - extends AOutputForwardRunnable { - /** The running status. */ - private boolean running = true; - /** The console output. */ - private final PipedConsoleOutput out; - /** The console output display. */ - private final ConsoleOutputDisplay display; - /** The actual SWT component. */ - private final Widget element; - - /** Create the forwarding runnable. - * - * @param manager the manager - * @param display the display - * @param element the composite */ - public ToSWTConsoleForwardRunnable(final PipedConsoleOutput manager, - final ConsoleOutputDisplay display, - final Widget element) { - super(manager); - out = manager; - this.display = display; - this.element = element; - } - - /* (non-Javadoc) - * @see - * net.bigeon.gclc.utils.AOutputForwardRunnable#forwardLine(java.lang.String) */ - @Override - protected void forwardLine(final String m) { - display.appendLine(m); - } - - /* (non-Javadoc) - * @see net.bigeon.gclc.utils.AOutputForwardRunnable#isRunning() */ - @Override - protected boolean isRunning() { - return running && !element.isDisposed(); - } - - /** Set the running status. - * - * @param running the running to set */ - public void setRunning(final boolean running) { - this.running = running; - } - - /** Get the output. - * - * @return the currently forwarded output */ - public PipedConsoleOutput getOuput() { - return out; - } - } - /** The SWT component displaying the output content. */ private final Text text; /** The forwarding runnable. */ diff --git a/gclc-swt/src/main/java/net/bigeon/gclc/swt/ConsolePromptManager.java b/gclc-swt/src/main/java/net/bigeon/gclc/swt/ConsolePromptManager.java index 3ac8cb2..fa9098d 100644 --- a/gclc-swt/src/main/java/net/bigeon/gclc/swt/ConsolePromptManager.java +++ b/gclc-swt/src/main/java/net/bigeon/gclc/swt/ConsolePromptManager.java @@ -41,6 +41,8 @@ import java.io.BufferedReader; import org.eclipse.swt.widgets.Label; +import net.bigeon.gclc.swt.tools.PromptReadingRunnable; + /** The manager for the console prompt updates. * * @author Emmanuel Bigeon */ diff --git a/gclc-swt/src/main/java/net/bigeon/gclc/swt/TextAppendingRunnable.java b/gclc-swt/src/main/java/net/bigeon/gclc/swt/TextAppendingRunnable.java new file mode 100644 index 0000000..7fa603d --- /dev/null +++ b/gclc-swt/src/main/java/net/bigeon/gclc/swt/TextAppendingRunnable.java @@ -0,0 +1,36 @@ +/** + * + */ +package net.bigeon.gclc.swt; + +import org.eclipse.swt.widgets.Text; + +/** A runnable appending text to the content of a {@link Text} component. + * + * @author Emmanuel Bigeon */ +public class TextAppendingRunnable implements Runnable { + /** The text to append on a line (possibly new). */ + private final String next; + /** The {@link Text} component. */ + private final Text text; + + /** Create the appending runnable. + * + * @param text the component to update + * @param next the text to append */ + public TextAppendingRunnable(final Text text, final String next) { + this.text = text; + this.next = next; + } + + /* (non-Javadoc) + * @see java.lang.Runnable#run() */ + @Override + public void run() { + final String initialText = text.getText(); + if (initialText != null && !initialText.isEmpty()) { + text.append(System.lineSeparator()); + } + text.append(next); + } +} \ No newline at end of file diff --git a/gclc-swt/src/main/java/net/bigeon/gclc/swt/PromptReadingRunnable.java b/gclc-swt/src/main/java/net/bigeon/gclc/swt/tools/PromptReadingRunnable.java similarity index 96% rename from gclc-swt/src/main/java/net/bigeon/gclc/swt/PromptReadingRunnable.java rename to gclc-swt/src/main/java/net/bigeon/gclc/swt/tools/PromptReadingRunnable.java index 5bb89da..22baf61 100644 --- a/gclc-swt/src/main/java/net/bigeon/gclc/swt/PromptReadingRunnable.java +++ b/gclc-swt/src/main/java/net/bigeon/gclc/swt/tools/PromptReadingRunnable.java @@ -1,7 +1,7 @@ /** * */ -package net.bigeon.gclc.swt; +package net.bigeon.gclc.swt.tools; /*- * #%L diff --git a/gclc-swt/src/main/java/net/bigeon/gclc/swt/tools/ToSWTConsoleForwardRunnable.java b/gclc-swt/src/main/java/net/bigeon/gclc/swt/tools/ToSWTConsoleForwardRunnable.java new file mode 100644 index 0000000..2574373 --- /dev/null +++ b/gclc-swt/src/main/java/net/bigeon/gclc/swt/tools/ToSWTConsoleForwardRunnable.java @@ -0,0 +1,68 @@ +/** + * + */ +package net.bigeon.gclc.swt.tools; + +import org.eclipse.swt.widgets.Widget; + +import net.bigeon.gclc.swt.ConsoleOutputDisplay; +import net.bigeon.gclc.utils.AOutputForwardRunnable; +import net.bigeon.gclc.utils.PipedConsoleOutput; + +/** The local implementation of the forwarding runnable. + * + * @author Emmanuel Bigeon */ +public final class ToSWTConsoleForwardRunnable + extends AOutputForwardRunnable { + /** The running status. */ + private boolean running = true; + /** The console output. */ + private final PipedConsoleOutput out; + /** The console output display. */ + private final ConsoleOutputDisplay display; + /** The actual SWT component. */ + private final Widget element; + + /** Create the forwarding runnable. + * + * @param manager the manager + * @param display the display + * @param element the composite */ + public ToSWTConsoleForwardRunnable(final PipedConsoleOutput manager, + final ConsoleOutputDisplay display, + final Widget element) { + super(manager); + out = manager; + this.display = display; + this.element = element; + } + + /* (non-Javadoc) + * @see + * net.bigeon.gclc.utils.AOutputForwardRunnable#forwardLine(java.lang.String) */ + @Override + protected void forwardLine(final String m) { + display.appendLine(m); + } + + /* (non-Javadoc) + * @see net.bigeon.gclc.utils.AOutputForwardRunnable#isRunning() */ + @Override + protected boolean isRunning() { + return running && !element.isDisposed(); + } + + /** Set the running status. + * + * @param running the running to set */ + public void setRunning(final boolean running) { + this.running = running; + } + + /** Get the output. + * + * @return the currently forwarded output */ + public PipedConsoleOutput getOuput() { + return out; + } +} \ No newline at end of file diff --git a/gclc-swt/src/main/java/net/bigeon/gclc/swt/tools/package-info.java b/gclc-swt/src/main/java/net/bigeon/gclc/swt/tools/package-info.java new file mode 100644 index 0000000..5a65264 --- /dev/null +++ b/gclc-swt/src/main/java/net/bigeon/gclc/swt/tools/package-info.java @@ -0,0 +1,9 @@ +/** + * + */ +/** Tool classes for the library. External code should not rely on classes in + * there as they can be removed without notice. + * + * @author Emmanuel Bigeon */ +package net.bigeon.gclc.swt.tools; + diff --git a/gclc-swt/src/test/java/net/bigeon/gclc/swt/PromptReadingRunnableTest.java b/gclc-swt/src/test/java/net/bigeon/gclc/swt/PromptReadingRunnableTest.java index 64c98da..7c4f401 100644 --- a/gclc-swt/src/test/java/net/bigeon/gclc/swt/PromptReadingRunnableTest.java +++ b/gclc-swt/src/test/java/net/bigeon/gclc/swt/PromptReadingRunnableTest.java @@ -53,6 +53,8 @@ import org.junit.Test; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; +import net.bigeon.gclc.swt.tools.PromptReadingRunnable; + /** @author Emmanuel Bigeon */ public class PromptReadingRunnableTest { private final Label view = mock(Label.class); @@ -72,7 +74,7 @@ public class PromptReadingRunnableTest { }).when(display).syncExec(any(Runnable.class)); } - /** Test method for {@link net.bigeon.gclc.swt.PromptReadingRunnable#run()}. + /** Test method for {@link net.bigeon.gclc.swt.tools.PromptReadingRunnable#run()}. * * @throws IOException if an error occurred */ @Test @@ -85,7 +87,7 @@ public class PromptReadingRunnableTest { runnable.run(); } - /** Test method for {@link net.bigeon.gclc.swt.PromptReadingRunnable#run()}. + /** Test method for {@link net.bigeon.gclc.swt.tools.PromptReadingRunnable#run()}. * * @throws IOException if an error occurred */ @Test