Removed suppress warning

Signed-off-by: Emmanuel Bigeon <emmanuel@bigeon.fr>
This commit is contained in:
Emmanuel Bigeon 2018-11-30 21:56:08 -05:00
parent 626f557aa0
commit bb06b2a799

View File

@ -13,17 +13,51 @@ import net.bigeon.gclc.utils.PipedConsoleOutput;
*
* @author Emmanuel Bigeon */
public final class ConsoleOutputManager implements ConsoleOutputDisplay {
/** A runnable appending text to the content of a {@link Text} component.
*
* @author Emmanuel Bigeon */
public 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 */
private TextAppendingRunnable(final Text text, final String next) {
this.text = text;
this.next = next;
}
/* (non-Javadoc)
* @see java.lang.Runnable#run() */
@Override
public void run() {
if (!text.getText().isEmpty()) {
text.append(System.lineSeparator());
}
text.append(next);
}
}
/** The local implementation of the forwarding runnable.
*
* @author Emmanuel Bigeon */
public static final class ToSWTConsoleForwardRunnable extends AOutputForwardRunnable {
/** The running status */
/** 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;
/** @param manager the manager
/** Create the forwarding runnable.
*
* @param manager the manager
* @param display the display
* @param element the composite */
public ToSWTConsoleForwardRunnable(final PipedConsoleOutput manager,
@ -35,51 +69,56 @@ public final class ConsoleOutputManager implements ConsoleOutputDisplay {
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();
}
/** @param running the running to set */
/** Set the running status.
*
* @param running the running to set */
public void setRunning(final boolean running) {
this.running = running;
}
/** @return the currently forwarded output */
/** 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 */
/** The forwarding runnable. */
private ToSWTConsoleForwardRunnable forward;
/** The forwarding thread. */
private Thread forwardThread;
/** @param text the text to display the output in. */
/** Create the manager.
*
* @param text the text to display the output in. */
public ConsoleOutputManager(final Text text) {
super();
this.text = text;
}
/** @param next the next message */
/* (non-Javadoc)
* @see net.bigeon.gclc.swt.ConsoleOutputDisplay#appendLine(java.lang.String) */
@Override
public void appendLine(final String next) {
text.getDisplay().syncExec(new Runnable() {
@SuppressWarnings("synthetic-access")
@Override
public void run() {
if (!text.getText().isEmpty()) {
text.append(System.lineSeparator());
}
text.append(next);
}
});
text.getDisplay().syncExec(new TextAppendingRunnable(text, next));
}
/** Set the output.
@ -102,7 +141,9 @@ public final class ConsoleOutputManager implements ConsoleOutputDisplay {
forwardThread.start();
}
/** @return the forwardThread */
/** Get the current thread forwarding the console output to the SWT components.
*
* @return the forwardThread */
public Thread getForwardThread() {
return forwardThread;
}