diff -r 65d7d9fc4df3 extexecution/src/org/netbeans/modules/extexecution/api/ExecutionDescriptor.java
--- a/extexecution/src/org/netbeans/modules/extexecution/api/ExecutionDescriptor.java Thu Nov 06 11:31:49 2008 +0100
+++ b/extexecution/src/org/netbeans/modules/extexecution/api/ExecutionDescriptor.java Thu Nov 06 17:33:57 2008 +0100
@@ -58,6 +58,8 @@
*/
public final class ExecutionDescriptor {
+ // TODO provide constants for common descriptors (are there any?)
+
private final Runnable preExecution;
private final Runnable postExecution;
@@ -71,6 +73,10 @@
private final boolean input;
private final boolean controllable;
+
+ private boolean outLineBased;
+
+ private boolean errLineBased;
private final LineConvertorFactory outConvertorFactory;
@@ -102,6 +108,8 @@
this.front = data.front;
this.input = data.input;
this.controllable = data.controllable;
+ this.outLineBased = data.outLineBased;
+ this.errLineBased = data.errLineBased;
this.outConvertorFactory = data.outConvertorFactory;
this.errConvertorFactory = data.errConvertorFactory;
this.outProcessorFactory = data.outProcessorFactory;
@@ -249,6 +257,46 @@
}
/**
+ * Returns a descriptor with configured flag indicating line based standard
+ * output. When configured value is true
the default printing
+ * processor will always wait for the whole line before converting and
+ * printing it.
+ *
+ * @param outLineBased line based flag
+ * @return descriptor with configured flag indicating line based
+ * standard output
+ * @see #outProcessorFactory(org.netbeans.modules.extexecution.api.ExecutionDescriptor.InputProcessorFactory)
+ */
+ public ExecutionDescriptor outLineBased(boolean outLineBased) {
+ DescriptorData data = new DescriptorData(this);
+ return new ExecutionDescriptor(data.outLineBased(outLineBased));
+ }
+
+ boolean isOutLineBased() {
+ return outLineBased;
+ }
+
+ /**
+ * Returns a descriptor with configured flag indicating line based standard
+ * error output. When configured value is true
the default
+ * printing processor will always wait for the whole line before
+ * converting and printing it.
+ *
+ * @param errLineBased line based flag
+ * @return descriptor with configured flag indicating line based
+ * standard error output
+ * @see #errProcessorFactory(org.netbeans.modules.extexecution.api.ExecutionDescriptor.InputProcessorFactory)
+ */
+ public ExecutionDescriptor errLineBased(boolean errLineBased) {
+ DescriptorData data = new DescriptorData(this);
+ return new ExecutionDescriptor(data.errLineBased(errLineBased));
+ }
+
+ boolean isErrLineBased() {
+ return errLineBased;
+ }
+
+ /**
* Returns a descriptor with configured factory for standard output
* processor. The factory is used by {@link ExecutionService} to create
* additional processor for standard output.
@@ -256,6 +304,9 @@
* Note that {@link ExecutionService} automatically uses
* the printing processor created by
* {@link org.netbeans.modules.extexecution.api.input.InputProcessors#printing(org.openide.windows.OutputWriter, org.netbeans.modules.extexecution.api.print.LineConvertor, boolean)}
+ * or
+ * {@link org.netbeans.modules.extexecution.api.input.LineProcessors#printing(org.openide.windows.OutputWriter, org.netbeans.modules.extexecution.api.print.LineConvertor, boolean)}
+ * (in case {@link #outLineBased(boolean)} is configured to true
)
* if there is no configured factory.
*
* The default (not configured) value is null
.
@@ -285,6 +336,9 @@
* Note that {@link ExecutionService} automatically uses
* the printing processor created by
* {@link org.netbeans.modules.extexecution.api.input.InputProcessors#printing(org.openide.windows.OutputWriter, org.netbeans.modules.extexecution.api.print.LineConvertor, boolean)}
+ * or
+ * {@link org.netbeans.modules.extexecution.api.input.LineProcessors#printing(org.openide.windows.OutputWriter, org.netbeans.modules.extexecution.api.print.LineConvertor, boolean)}
+ * (in case {@link #errLineBased(boolean)} is configured to true
)
* if there is no configured factory.
*
* The default (not configured) value is null
.
@@ -314,7 +368,7 @@
* Note that {@link ExecutionService} always uses the printing processor
* for the standard output. Convertor created by the returned factory will
* be passed to this default printing processor. See
- * {@link #getOutProcessorFactory()} too.
+ * {@link #outProcessorFactory()} too.
*
* The default (not configured) value is null
.
*
@@ -343,7 +397,7 @@ * Note that {@link ExecutionService} always uses the printing processor * for the standard error output. Convertor created by the returned * factory will be passed to this default printing processor. See - * {@link #getErrProcessorFactory()} too. + * {@link #errProcessorFactory()} too. *
* The default (not configured) value is null
.
*
@@ -533,6 +587,10 @@ private boolean controllable; + private boolean outLineBased; + + private boolean errLineBased; + private LineConvertorFactory outConvertorFactory; private LineConvertorFactory errConvertorFactory; @@ -559,6 +617,8 @@ this.front = descriptor.front; this.input = descriptor.input; this.controllable = descriptor.controllable; + this.outLineBased = descriptor.outLineBased; + this.errLineBased = descriptor.errLineBased; this.outConvertorFactory = descriptor.outConvertorFactory; this.errConvertorFactory = descriptor.errConvertorFactory; this.outProcessorFactory = descriptor.outProcessorFactory; @@ -595,6 +655,16 @@ public DescriptorData showSuspended(boolean showSuspended) { this.suspend = showSuspended; + return this; + } + + public DescriptorData outLineBased(boolean outLineBased) { + this.outLineBased = outLineBased; + return this; + } + + public DescriptorData errLineBased(boolean errLineBased) { + this.errLineBased = errLineBased; return this; } diff -r 65d7d9fc4df3 extexecution/src/org/netbeans/modules/extexecution/api/ExecutionService.java --- a/extexecution/src/org/netbeans/modules/extexecution/api/ExecutionService.java Thu Nov 06 11:31:49 2008 +0100 +++ b/extexecution/src/org/netbeans/modules/extexecution/api/ExecutionService.java Thu Nov 06 17:33:57 2008 +0100 @@ -75,6 +75,7 @@ import org.netbeans.modules.extexecution.api.input.InputProcessors; import org.netbeans.modules.extexecution.api.input.InputReaderTask; import org.netbeans.modules.extexecution.api.input.InputReaders; +import org.netbeans.modules.extexecution.api.input.LineProcessors; import org.openide.util.Cancellable; import org.openide.util.Mutex; import org.openide.util.NbBundle; @@ -533,8 +534,14 @@ private InputProcessor createOutProcessor(OutputWriter writer) { LineConvertorFactory convertorFactory = descriptor.getOutConvertorFactory(); - InputProcessor outProcessor = InputProcessors.printing(writer, - convertorFactory != null ? convertorFactory.newLineConvertor() : null, true); + InputProcessor outProcessor = null; + if (descriptor.isOutLineBased()) { + outProcessor = InputProcessors.bridge(LineProcessors.printing(writer, + convertorFactory != null ? convertorFactory.newLineConvertor() : null, true)); + } else { + outProcessor = InputProcessors.printing(writer, + convertorFactory != null ? convertorFactory.newLineConvertor() : null, true); + } InputProcessorFactory descriptorOutFactory = descriptor.getOutProcessorFactory(); if (descriptorOutFactory != null) { @@ -546,8 +553,14 @@ private InputProcessor createErrProcessor(OutputWriter writer) { LineConvertorFactory convertorFactory = descriptor.getErrConvertorFactory(); - InputProcessor errProcessor = InputProcessors.printing(writer, - convertorFactory != null ? convertorFactory.newLineConvertor() : null, false); + InputProcessor errProcessor = null; + if (descriptor.isErrLineBased()) { + errProcessor = InputProcessors.bridge(LineProcessors.printing(writer, + convertorFactory != null ? convertorFactory.newLineConvertor() : null, false)); + } else { + errProcessor = InputProcessors.printing(writer, + convertorFactory != null ? convertorFactory.newLineConvertor() : null, false); + } InputProcessorFactory descriptorErrFactory = descriptor.getErrProcessorFactory(); if (descriptorErrFactory != null) {