From c79bb9a1196f46d8728657c489d1ed10167c7417 Mon Sep 17 00:00:00 2001 From: Bruno Medeiros Date: Thu, 15 Dec 2016 19:01:49 +0000 Subject: [PATCH 1/2] make public --- melnorme_util/src/melnorme/utilbox/fields/EventSource.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/melnorme_util/src/melnorme/utilbox/fields/EventSource.java b/melnorme_util/src/melnorme/utilbox/fields/EventSource.java index 7e5648f0..a734861d 100644 --- a/melnorme_util/src/melnorme/utilbox/fields/EventSource.java +++ b/melnorme_util/src/melnorme/utilbox/fields/EventSource.java @@ -29,7 +29,7 @@ public void removeListener(T listener) { listeners.removeListener(listener); } - protected Indexable getListeners() { + public Indexable getListeners() { return listeners.getListeners(); } From f3ed0b114548f0eb044e431d18ca812c329f075f Mon Sep 17 00:00:00 2001 From: Bruno Medeiros Date: Thu, 15 Dec 2016 19:00:25 +0000 Subject: [PATCH 2/2] Additions to help tests, especially the manager singletons. --- .../operations/build/BuildManager_Test.java | 20 +++++ .../lang/ide/core/tests/CommonCoreTest.java | 5 ++ .../core/operations/build/BuildManager.java | 16 +++- .../build/CompositeBuildOperation.java | 4 + .../operation/EclipseAsynchJobAdapter.java | 5 +- .../AbstractProcessMessageConsole.java | 12 +-- .../console/ConsoleOutputProcessListener.java | 31 ++------ .../ui/tools/console/EngineToolsConsole.java | 17 ++-- .../LangOperationsConsoleUIHandler.java | 36 +++------ .../ide/ui/tools/console/ToolsConsole.java | 79 ++++++++++++++++--- 10 files changed, 144 insertions(+), 81 deletions(-) diff --git a/plugin_ide.core.tests/src-lang/melnorme/lang/ide/core/operations/build/BuildManager_Test.java b/plugin_ide.core.tests/src-lang/melnorme/lang/ide/core/operations/build/BuildManager_Test.java index 93f6f59c..774148af 100644 --- a/plugin_ide.core.tests/src-lang/melnorme/lang/ide/core/operations/build/BuildManager_Test.java +++ b/plugin_ide.core.tests/src-lang/melnorme/lang/ide/core/operations/build/BuildManager_Test.java @@ -18,6 +18,8 @@ import static melnorme.utilbox.core.Assert.AssertNamespace.assertNotNull; import static melnorme.utilbox.core.Assert.AssertNamespace.assertTrue; +import java.util.Collection; + import org.eclipse.core.resources.IProject; import org.junit.Test; @@ -29,6 +31,7 @@ import melnorme.lang.ide.core.operations.ILangOperationsListener_Default.NullToolOperationMonitor; import melnorme.lang.ide.core.operations.ToolManager; import melnorme.lang.ide.core.operations.build.BuildManager_Test.TestsBuildManager.SampleStrictBuildType; +import melnorme.lang.ide.core.operations.build.BuildOperationCreator.ProjectBuildOperation; import melnorme.lang.ide.core.operations.build.BuildTargetOperation.BuildOperationParameters; import melnorme.lang.ide.core.project_model.LangBundleModel; import melnorme.lang.ide.core.tests.CoreTestWithProject; @@ -413,4 +416,21 @@ protected Iterable getBuildOperation(ProjectBuildInfo buildInfo, BuildTa } + /* ----------------- ----------------- */ + + // Util for other projects + public static void clearExistingBuilds(BuildManager buildManager, boolean awaitTermination) { + Collection oldBuilds = buildManager.cancelAllBuilds(); + if(awaitTermination) { + for (ProjectBuildOperation oldOperation : oldBuilds) { + oldOperation.tryCancel(); + try { + oldOperation.asFuture().awaitResult2(); + } catch(OperationCancellation e) { + // Ok + } + } + } + } + } \ No newline at end of file diff --git a/plugin_ide.core.tests/src-lang/melnorme/lang/ide/core/tests/CommonCoreTest.java b/plugin_ide.core.tests/src-lang/melnorme/lang/ide/core/tests/CommonCoreTest.java index 9813ce88..044bb6e3 100644 --- a/plugin_ide.core.tests/src-lang/melnorme/lang/ide/core/tests/CommonCoreTest.java +++ b/plugin_ide.core.tests/src-lang/melnorme/lang/ide/core/tests/CommonCoreTest.java @@ -40,8 +40,10 @@ import org.junit.Before; import org.junit.BeforeClass; +import melnorme.lang.ide.core.LangCore; import melnorme.lang.ide.core.LangCorePlugin; import melnorme.lang.ide.core.LangNature; +import melnorme.lang.ide.core.operations.build.BuildManager_Test; import melnorme.lang.ide.core.tests.utils.ErrorLogListener; import melnorme.lang.ide.core.utils.EclipseUtils; import melnorme.lang.ide.core.utils.ResourceUtils; @@ -111,8 +113,11 @@ public static void checkLogErrors_() throws Throwable { // be obtained the if the method fails its check. @Before public void checkLogErrors_before() throws Throwable { + BuildManager_Test.clearExistingBuilds(LangCore.getBuildManager(), true); + doCheckLogErrors(); } + @After public void checkLogErrors_after() throws Throwable { doCheckLogErrors(); diff --git a/plugin_ide.core/src-lang/melnorme/lang/ide/core/operations/build/BuildManager.java b/plugin_ide.core/src-lang/melnorme/lang/ide/core/operations/build/BuildManager.java index 60e4218d..3b1ccf8a 100644 --- a/plugin_ide.core/src-lang/melnorme/lang/ide/core/operations/build/BuildManager.java +++ b/plugin_ide.core/src-lang/melnorme/lang/ide/core/operations/build/BuildManager.java @@ -19,6 +19,7 @@ import static melnorme.utilbox.core.CoreUtil.option; import java.text.MessageFormat; +import java.util.Collection; import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; @@ -588,9 +589,15 @@ protected BuildOperationCreator createBuildOperationCreator( /* ----------------- ----------------- */ - protected final HashMap2 buildOps = new HashMap2<>(); + protected HashMap2 buildOps = new HashMap2<>(); protected final Object buildOps_mutex = new Object(); + public ProjectBuildOperation getBuildOperation(Location location) { + synchronized (buildOps_mutex) { + return buildOps.get0(location); + } + } + public ProjectBuildOperation setNewBuildOperation(ProjectBuildOperation newOperation) { Location location = newOperation.getLocation(); ProjectBuildOperation oldOp; @@ -603,15 +610,16 @@ public ProjectBuildOperation setNewBuildOperation(ProjectBuildOperation newOpera return oldOp; } - public void cancelAllBuilds() { + public Collection cancelAllBuilds() { HashMap2 oldBuildOps; synchronized (buildOps_mutex) { - oldBuildOps = buildOps.copy(); - buildOps.clear(); + oldBuildOps = buildOps; + buildOps = new HashMap2<>(); } for (ProjectBuildOperation buildOp : oldBuildOps.values()) { buildOp.tryCancel(); } + return oldBuildOps.values(); } } \ No newline at end of file diff --git a/plugin_ide.core/src-lang/melnorme/lang/ide/core/operations/build/CompositeBuildOperation.java b/plugin_ide.core/src-lang/melnorme/lang/ide/core/operations/build/CompositeBuildOperation.java index 92e6b36d..d6307048 100644 --- a/plugin_ide.core/src-lang/melnorme/lang/ide/core/operations/build/CompositeBuildOperation.java +++ b/plugin_ide.core/src-lang/melnorme/lang/ide/core/operations/build/CompositeBuildOperation.java @@ -30,6 +30,10 @@ public CompositeBuildOperation(Indexable operations) { this.opFuture = OperationFuture2.fromOperation(this::innerExecute); } + public OperationFuture2 asFuture() { + return opFuture; + } + @Override public void execute(IOperationMonitor om) throws CommonException, OperationCancellation { assertTrue(opFuture.canExecute()); diff --git a/plugin_ide.core/src-lang/melnorme/lang/ide/core/utils/operation/EclipseAsynchJobAdapter.java b/plugin_ide.core/src-lang/melnorme/lang/ide/core/utils/operation/EclipseAsynchJobAdapter.java index 632c59e8..becdf253 100644 --- a/plugin_ide.core/src-lang/melnorme/lang/ide/core/utils/operation/EclipseAsynchJobAdapter.java +++ b/plugin_ide.core/src-lang/melnorme/lang/ide/core/utils/operation/EclipseAsynchJobAdapter.java @@ -42,7 +42,9 @@ protected IStatus run(IProgressMonitor monitor) { } - public static void runUnderAsynchJob(String jobName, IRunnableWithJob runnable) throws InterruptedException { + public static Job runUnderAsynchJob( + String jobName, IRunnableWithJob runnable + ) throws InterruptedException { EclipseAsynchJobAdapter job = new EclipseAsynchJobAdapter(jobName); job.schedule(); @@ -55,6 +57,7 @@ public static void runUnderAsynchJob(String jobName, IRunnableWithJob runnable) } finally { job.done(EclipseCore.createOkStatus(null)); } + return job; } public static interface IRunnableWithJob { diff --git a/plugin_ide.ui/src-lang/melnorme/lang/ide/ui/tools/console/AbstractProcessMessageConsole.java b/plugin_ide.ui/src-lang/melnorme/lang/ide/ui/tools/console/AbstractProcessMessageConsole.java index 22bc730d..df86cff3 100644 --- a/plugin_ide.ui/src-lang/melnorme/lang/ide/ui/tools/console/AbstractProcessMessageConsole.java +++ b/plugin_ide.ui/src-lang/melnorme/lang/ide/ui/tools/console/AbstractProcessMessageConsole.java @@ -16,8 +16,8 @@ import org.eclipse.jface.text.source.ISharedTextColors; import org.eclipse.swt.widgets.Display; import org.eclipse.ui.console.IOConsole; -import org.eclipse.ui.console.IOConsoleOutputStream; +import melnorme.lang.ide.ui.tools.console.ToolsConsole.IOConsoleOutputStreamExt; import melnorme.util.swt.jface.text.ColorManager; public abstract class AbstractProcessMessageConsole extends IOConsole { @@ -29,8 +29,8 @@ protected ProcessMessageConsole(String name, ImageDescriptor imageDescriptor) { } } - public final IOConsoleOutputStream stdOut; - public final IOConsoleOutputStream stdErr; + public final IOConsoleOutputStreamExt stdOut; + public final IOConsoleOutputStreamExt stdErr; public volatile boolean disposed; @@ -41,9 +41,9 @@ protected ProcessMessageConsole(String name, ImageDescriptor imageDescriptor) { protected AbstractProcessMessageConsole(String name, ImageDescriptor imageDescriptor) { super(name, imageDescriptor); - stdOut = newOutputStream(); - stdErr = newOutputStream(); - stdErr.setActivateOnWrite(true); + stdOut = new IOConsoleOutputStreamExt(newOutputStream()); + stdErr = new IOConsoleOutputStreamExt(newOutputStream()); + stdErr.console().setActivateOnWrite(true); } protected void postToUI_initOutputStreamColors() { diff --git a/plugin_ide.ui/src-lang/melnorme/lang/ide/ui/tools/console/ConsoleOutputProcessListener.java b/plugin_ide.ui/src-lang/melnorme/lang/ide/ui/tools/console/ConsoleOutputProcessListener.java index 93b86dbb..950d9722 100644 --- a/plugin_ide.ui/src-lang/melnorme/lang/ide/ui/tools/console/ConsoleOutputProcessListener.java +++ b/plugin_ide.ui/src-lang/melnorme/lang/ide/ui/tools/console/ConsoleOutputProcessListener.java @@ -10,48 +10,33 @@ *******************************************************************************/ package melnorme.lang.ide.ui.tools.console; -import java.io.IOException; - +import melnorme.lang.ide.ui.tools.console.ToolsConsole.IOConsoleOutputStreamExt; import melnorme.utilbox.process.ExternalProcessNotifyingHelper.IProcessOutputListener; -import org.eclipse.ui.console.IOConsoleOutputStream; - public class ConsoleOutputProcessListener implements IProcessOutputListener { - protected final IOConsoleOutputStream processStdOut; - protected final IOConsoleOutputStream processStdErr; + protected final IOConsoleOutputStreamExt processStdOut; + protected final IOConsoleOutputStreamExt processStdErr; - public ConsoleOutputProcessListener(IOConsoleOutputStream processStdOut, IOConsoleOutputStream processStdErr) { + public ConsoleOutputProcessListener(IOConsoleOutputStreamExt processStdOut, IOConsoleOutputStreamExt processStdErr) { this.processStdOut = processStdOut; this.processStdErr = processStdErr; } @Override public void notifyStdOutListeners(byte[] buffer, int offset, int readCount) { - try { - processStdOut.write(buffer, offset, readCount); - } catch (IOException e) { - // Ignore, it could simply mean the console page has been closed - } + processStdOut.write(buffer, offset, readCount); } @Override public void notifyStdErrListeners(byte[] buffer, int offset, int readCount) { - try { - processStdErr.write(buffer, offset, readCount); - } catch (IOException e) { - // Ignore, it could simply mean the console page has been closed - } + processStdErr.write(buffer, offset, readCount); } @Override public void notifyProcessTerminatedAndRead(int exitCode) { - try { - processStdOut.flush(); - processStdErr.flush(); - } catch (IOException e) { - // Ignore - } + processStdOut.flush(); + processStdErr.flush(); } } \ No newline at end of file diff --git a/plugin_ide.ui/src-lang/melnorme/lang/ide/ui/tools/console/EngineToolsConsole.java b/plugin_ide.ui/src-lang/melnorme/lang/ide/ui/tools/console/EngineToolsConsole.java index 250c8fa8..d70dab97 100644 --- a/plugin_ide.ui/src-lang/melnorme/lang/ide/ui/tools/console/EngineToolsConsole.java +++ b/plugin_ide.ui/src-lang/melnorme/lang/ide/ui/tools/console/EngineToolsConsole.java @@ -13,7 +13,6 @@ import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.RGB; -import org.eclipse.ui.console.IOConsoleOutputStream; import melnorme.lang.ide.ui.LangImages; import melnorme.lang.ide.ui.LangUIPlugin_Actual; @@ -21,14 +20,14 @@ public class EngineToolsConsole extends ToolsConsole { - public final IOConsoleOutputStream serverStdOut; - public final IOConsoleOutputStream serverStdErr; + public final IOConsoleOutputStreamExt serverStdOut; + public final IOConsoleOutputStreamExt serverStdErr; public EngineToolsConsole(String name, ImageDescriptor imageDescriptor) { super(name, imageDescriptor, false); - serverStdOut = newOutputStream(); - serverStdErr = newOutputStream(); + serverStdOut = new IOConsoleOutputStreamExt(newOutputStream()); + serverStdErr = new IOConsoleOutputStreamExt(newOutputStream()); postToUI_initOutputStreamColors(); } @@ -37,11 +36,11 @@ public EngineToolsConsole(String name, ImageDescriptor imageDescriptor) { protected void ui_initStreamColors() { super.ui_initStreamColors(); - serverStdOut.setColor(getColorManager().getColor(new RGB(128, 0, 128))); - serverStdErr.setColor(getColorManager().getColor(new RGB(255, 0, 200))); - serverStdErr.setFontStyle(SWT.BOLD); + serverStdOut.console().setColor(getColorManager().getColor(new RGB(128, 0, 128))); + serverStdErr.console().setColor(getColorManager().getColor(new RGB(255, 0, 200))); + serverStdErr.console().setFontStyle(SWT.BOLD); - stdErr.setActivateOnWrite(false); + stdErr.console().setActivateOnWrite(false); } public static EngineToolsConsole getConsole() { diff --git a/plugin_ide.ui/src-lang/melnorme/lang/ide/ui/tools/console/LangOperationsConsoleUIHandler.java b/plugin_ide.ui/src-lang/melnorme/lang/ide/ui/tools/console/LangOperationsConsoleUIHandler.java index 3e5b907e..42849f60 100644 --- a/plugin_ide.ui/src-lang/melnorme/lang/ide/ui/tools/console/LangOperationsConsoleUIHandler.java +++ b/plugin_ide.ui/src-lang/melnorme/lang/ide/ui/tools/console/LangOperationsConsoleUIHandler.java @@ -13,7 +13,6 @@ import static melnorme.utilbox.core.Assert.AssertNamespace.assertFail; import static melnorme.utilbox.core.Assert.AssertNamespace.assertNotNull; -import java.io.IOException; import java.util.Collections; import java.util.HashSet; import java.util.List; @@ -23,12 +22,12 @@ import org.eclipse.debug.core.DebugPlugin; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.console.IOConsoleOutputStream; import melnorme.lang.ide.core.ILangOperationsListener; import melnorme.lang.ide.core.utils.process.AbstractRunProcessTask.ProcessStartHelper; import melnorme.lang.ide.ui.LangImages; import melnorme.lang.ide.ui.LangUIPlugin_Actual; +import melnorme.lang.ide.ui.tools.console.ToolsConsole.IOConsoleOutputStreamExt; import melnorme.lang.ide.ui.utils.ConsoleUtils; import melnorme.lang.ide.ui.utils.StatusMessageDialog2; import melnorme.lang.ide.ui.utils.StatusMessageDialogWithIgnore; @@ -143,7 +142,7 @@ protected IToolOperationMonitor doBeginOperation(ProcessStartKind kind, boolean } protected OperationConsoleMonitor createConsoleHandler(ProcessStartKind kind, ToolsConsole console, - IOConsoleOutputStream stdOut, IOConsoleOutputStream stdErr) { + IOConsoleOutputStreamExt stdOut, IOConsoleOutputStreamExt stdErr) { return new OperationConsoleMonitor(kind, console, stdOut, stdErr); } @@ -153,14 +152,14 @@ public class OperationConsoleMonitor implements IToolOperationMonitor { protected final ProcessStartKind kind; protected final ToolsConsole console; - protected final IOConsoleOutputStream infoOut; - protected final IOConsoleOutputStream stdOut; - protected final IOConsoleOutputStream stdErr; + protected final IOConsoleOutputStreamExt infoOut; + protected final IOConsoleOutputStreamExt stdOut; + protected final IOConsoleOutputStreamExt stdErr; public boolean errorOnNonZeroExitValueForBuild = false; public OperationConsoleMonitor(ProcessStartKind kind, ToolsConsole console, - IOConsoleOutputStream stdOut, IOConsoleOutputStream stdErr) { + IOConsoleOutputStreamExt stdOut, IOConsoleOutputStreamExt stdErr) { this.kind = assertNotNull(kind); this.console = assertNotNull(console); this.infoOut = console.infoOut; @@ -179,12 +178,8 @@ public void handleProcessStart(String prefixText, String suffixText, ProcessBuil { String infoPrefaceText = getPrefaceText(prefixText, suffixText, pb); - try { - if(infoPrefaceText != null) { - infoOut.write(infoPrefaceText); - } - } catch (IOException e) { - // Do nothing + if(infoPrefaceText != null) { + infoOut.write(infoPrefaceText); } connectProcessOutputListener(processStartHelper); @@ -200,12 +195,7 @@ protected void connectProcessOutputListener(ProcessStartHelper processStartHelpe if(cause != null) { text += " Reason: " + cause.getMessage() + "\n"; } - try { - infoOut.write(text); - } catch (IOException e) { - // Do nothing - } - + infoOut.write(text); } } @@ -227,12 +217,8 @@ protected void handleProcessTerminated(int exitCode) { console.activate(); } - try { - infoOut.write(getProcessTerminatedMessage(exitCode)); - infoOut.flush(); - } catch (IOException e) { - // Ignore - } + infoOut.write(getProcessTerminatedMessage(exitCode)); + infoOut.flush(); } @Override diff --git a/plugin_ide.ui/src-lang/melnorme/lang/ide/ui/tools/console/ToolsConsole.java b/plugin_ide.ui/src-lang/melnorme/lang/ide/ui/tools/console/ToolsConsole.java index 4b50e876..157d2232 100644 --- a/plugin_ide.ui/src-lang/melnorme/lang/ide/ui/tools/console/ToolsConsole.java +++ b/plugin_ide.ui/src-lang/melnorme/lang/ide/ui/tools/console/ToolsConsole.java @@ -10,6 +10,7 @@ *******************************************************************************/ package melnorme.lang.ide.ui.tools.console; +import static melnorme.utilbox.core.Assert.AssertNamespace.assertNotNull; import static melnorme.utilbox.core.Assert.AssertNamespace.assertTrue; import java.io.IOException; @@ -17,18 +18,20 @@ import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.widgets.Display; +import org.eclipse.ui.PlatformUI; import org.eclipse.ui.console.IConsoleView; import org.eclipse.ui.console.IOConsoleOutputStream; import org.eclipse.ui.part.IPageBookViewPage; import melnorme.lang.ide.ui.text.coloring.TextStyling; import melnorme.util.swt.jface.text.ColorManager; +import melnorme.utilbox.core.DevelopmentCodeMarkers; import melnorme.utilbox.ownership.OwnedObjects; public class ToolsConsole extends AbstractProcessMessageConsole { - public final IOConsoleOutputStream infoOut; - public final IOConsoleOutputStream stdErr_silent; // An alternative to stdErr that never activate on write + public final IOConsoleOutputStreamExt infoOut; + public final IOConsoleOutputStreamExt stdErr_silent; // An alternative to stdErr that never activate on write protected final OwnedObjects owned = new OwnedObjects(); @@ -39,8 +42,8 @@ public ToolsConsole(String name, ImageDescriptor imageDescriptor) { protected ToolsConsole(String name, ImageDescriptor imageDescriptor, boolean initializeColors) { super(name, imageDescriptor); - infoOut = newOutputStream(); - stdErr_silent = newOutputStream(); + infoOut = new IOConsoleOutputStreamExt(newOutputStream()); + stdErr_silent = new IOConsoleOutputStreamExt(newOutputStream()); if(initializeColors) { postToUI_initOutputStreamColors(); @@ -54,21 +57,21 @@ protected void ui_initStreamColors() { ui_bindActivateOnErrorsListeners(); ToolsConsolePrefs.INFO_COLOR.asField().bindOwnedListener(owned, true, - (newValue) -> infoOut.setColor(getManagedColor(newValue))); + (newValue) -> infoOut.console().setColor(getManagedColor(newValue))); ToolsConsolePrefs.STDERR_COLOR.asField().bindOwnedListener(owned, true, (newValue) -> { - stdErr.setColor(getManagedColor(newValue)); - stdErr_silent.setColor(getManagedColor(newValue)); + stdErr.console().setColor(getManagedColor(newValue)); + stdErr_silent.console().setColor(getManagedColor(newValue)); }); ToolsConsolePrefs.STDOUT_COLOR.asField().bindOwnedListener(owned, true, - (newValue) -> stdOut.setColor(getManagedColor(newValue))); + (newValue) -> stdOut.console().setColor(getManagedColor(newValue))); ToolsConsolePrefs.BACKGROUND_COLOR.asField().bindOwnedListener(owned, true, (newValue) -> setBackground(getManagedColor(newValue))); } protected void ui_bindActivateOnErrorsListeners() { ToolsConsolePrefs.ACTIVATE_ON_ERROR_MESSAGES.asField().bindOwnedListener(owned, true, - (newValue) -> stdErr.setActivateOnWrite(newValue) + (newValue) -> stdErr.console().setActivateOnWrite(newValue) ); } @@ -90,11 +93,61 @@ public IPageBookViewPage createPage(IConsoleView view) { } public void writeOperationInfo(String string) { - try { - infoOut.write(string); - } catch (IOException e) { - // Do nothing + infoOut.write(string); + } + + public static class IOConsoleOutputStreamExt { + + protected IOConsoleOutputStream console; + + public IOConsoleOutputStreamExt(IOConsoleOutputStream console) { + this.console = assertNotNull(console); + } + + public IOConsoleOutputStream console() { + return console; + } + + public boolean isIgnorinCommands() { + return !PlatformUI.isWorkbenchRunning() && DevelopmentCodeMarkers.TESTS_MODE; } + + public void write(byte[] b, int off, int len) { + if(isIgnorinCommands()) { + return; + } + + try { + console.write(b, off, len); + } catch(IOException e) { + // Ignore + } + } + + public void write(String string) { + if(isIgnorinCommands()) { + return; + } + + try { + console.write(string); + } catch (IOException e) { + // Ignore + } + } + + public void flush() { + if(isIgnorinCommands()) { + return; + } + + try { + console.flush(); + } catch (IOException e) { + // Ignore + } + } + } } \ No newline at end of file