Removed suppress warning
Signed-off-by: Emmanuel Bigeon <emmanuel@bigeon.fr>
This commit is contained in:
parent
626f557aa0
commit
bb06b2a799
@ -13,17 +13,51 @@ import net.bigeon.gclc.utils.PipedConsoleOutput;
|
|||||||
*
|
*
|
||||||
* @author Emmanuel Bigeon */
|
* @author Emmanuel Bigeon */
|
||||||
public final class ConsoleOutputManager implements ConsoleOutputDisplay {
|
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.
|
/** The local implementation of the forwarding runnable.
|
||||||
*
|
*
|
||||||
* @author Emmanuel Bigeon */
|
* @author Emmanuel Bigeon */
|
||||||
public static final class ToSWTConsoleForwardRunnable extends AOutputForwardRunnable {
|
public static final class ToSWTConsoleForwardRunnable extends AOutputForwardRunnable {
|
||||||
/** The running status */
|
/** The running status. */
|
||||||
private boolean running = true;
|
private boolean running = true;
|
||||||
|
/** The console output. */
|
||||||
private final PipedConsoleOutput out;
|
private final PipedConsoleOutput out;
|
||||||
|
/** The console output display. */
|
||||||
private final ConsoleOutputDisplay display;
|
private final ConsoleOutputDisplay display;
|
||||||
|
/** The actual SWT component. */
|
||||||
private final Widget element;
|
private final Widget element;
|
||||||
|
|
||||||
/** @param manager the manager
|
/** Create the forwarding runnable.
|
||||||
|
*
|
||||||
|
* @param manager the manager
|
||||||
* @param display the display
|
* @param display the display
|
||||||
* @param element the composite */
|
* @param element the composite */
|
||||||
public ToSWTConsoleForwardRunnable(final PipedConsoleOutput manager,
|
public ToSWTConsoleForwardRunnable(final PipedConsoleOutput manager,
|
||||||
@ -35,51 +69,56 @@ public final class ConsoleOutputManager implements ConsoleOutputDisplay {
|
|||||||
this.element = element;
|
this.element = element;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see
|
||||||
|
* net.bigeon.gclc.utils.AOutputForwardRunnable#forwardLine(java.lang.String) */
|
||||||
@Override
|
@Override
|
||||||
protected void forwardLine(final String m) {
|
protected void forwardLine(final String m) {
|
||||||
display.appendLine(m);
|
display.appendLine(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see net.bigeon.gclc.utils.AOutputForwardRunnable#isRunning() */
|
||||||
@Override
|
@Override
|
||||||
protected boolean isRunning() {
|
protected boolean isRunning() {
|
||||||
return running && !element.isDisposed();
|
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) {
|
public void setRunning(final boolean running) {
|
||||||
this.running = running;
|
this.running = running;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @return the currently forwarded output */
|
/** Get the output.
|
||||||
|
*
|
||||||
|
* @return the currently forwarded output */
|
||||||
public PipedConsoleOutput getOuput() {
|
public PipedConsoleOutput getOuput() {
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** The SWT component displaying the output content. */
|
||||||
private final Text text;
|
private final Text text;
|
||||||
/** The forwarding runnable */
|
/** The forwarding runnable. */
|
||||||
private ToSWTConsoleForwardRunnable forward;
|
private ToSWTConsoleForwardRunnable forward;
|
||||||
|
/** The forwarding thread. */
|
||||||
private Thread forwardThread;
|
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) {
|
public ConsoleOutputManager(final Text text) {
|
||||||
super();
|
super();
|
||||||
this.text = text;
|
this.text = text;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @param next the next message */
|
/* (non-Javadoc)
|
||||||
|
* @see net.bigeon.gclc.swt.ConsoleOutputDisplay#appendLine(java.lang.String) */
|
||||||
@Override
|
@Override
|
||||||
public void appendLine(final String next) {
|
public void appendLine(final String next) {
|
||||||
text.getDisplay().syncExec(new Runnable() {
|
text.getDisplay().syncExec(new TextAppendingRunnable(text, next));
|
||||||
@SuppressWarnings("synthetic-access")
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
if (!text.getText().isEmpty()) {
|
|
||||||
text.append(System.lineSeparator());
|
|
||||||
}
|
|
||||||
text.append(next);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Set the output.
|
/** Set the output.
|
||||||
@ -102,7 +141,9 @@ public final class ConsoleOutputManager implements ConsoleOutputDisplay {
|
|||||||
forwardThread.start();
|
forwardThread.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @return the forwardThread */
|
/** Get the current thread forwarding the console output to the SWT components.
|
||||||
|
*
|
||||||
|
* @return the forwardThread */
|
||||||
public Thread getForwardThread() {
|
public Thread getForwardThread() {
|
||||||
return forwardThread;
|
return forwardThread;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user