diff -r 2532d50dca21 extexecution/src/org/netbeans/modules/extexecution/api/ExecutionDescriptor.java --- a/extexecution/src/org/netbeans/modules/extexecution/api/ExecutionDescriptor.java Wed Oct 29 21:34:37 2008 +0100 +++ b/extexecution/src/org/netbeans/modules/extexecution/api/ExecutionDescriptor.java Thu Oct 30 15:52:07 2008 +0100 @@ -253,9 +253,10 @@ * processor. The factory is used by {@link ExecutionService} to create * additional processor for standard output. *
- * Note that {@link ExecutionService} always automatically uses + * 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)}. + * {@link org.netbeans.modules.extexecution.api.input.InputProcessors#printing(org.openide.windows.OutputWriter, org.netbeans.modules.extexecution.api.print.LineConvertor, boolean)} + * if there is no configured factory. *
* The default (not configured) value is null
.
*
@@ -281,9 +282,10 @@ * processor. The factory is used by {@link ExecutionService} to create * additional processor for standard error output. *
- * Note that {@link ExecutionService} always automatically uses + * 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)}. + * {@link org.netbeans.modules.extexecution.api.input.InputProcessors#printing(org.openide.windows.OutputWriter, org.netbeans.modules.extexecution.api.print.LineConvertor, boolean)} + * if there is no configured factory. *
* The default (not configured) value is null
.
*
@@ -493,9 +495,11 @@
/**
* Creates and returns new input processor.
*
+ * @param defaultProcessor default processor created by
+ * infrastructure that is printing chars to the output window
* @return new input processor
*/
- InputProcessor newInputProcessor();
+ InputProcessor newInputProcessor(InputProcessor defaultProcessor);
}
diff -r 2532d50dca21 extexecution/src/org/netbeans/modules/extexecution/api/ExecutionService.java
--- a/extexecution/src/org/netbeans/modules/extexecution/api/ExecutionService.java Wed Oct 29 21:34:37 2008 +0100
+++ b/extexecution/src/org/netbeans/modules/extexecution/api/ExecutionService.java Thu Oct 30 15:52:07 2008 +0100
@@ -533,13 +533,12 @@
private InputProcessor createOutProcessor(OutputWriter writer) {
LineConvertorFactory convertorFactory = descriptor.getOutConvertorFactory();
- InputProcessor outProcessor = InputProcessors.ansiStripping(
- InputProcessors.printing(writer,
- convertorFactory != null ? convertorFactory.newLineConvertor() : null, true));
+ InputProcessor outProcessor = InputProcessors.printing(writer,
+ convertorFactory != null ? convertorFactory.newLineConvertor() : null, true);
InputProcessorFactory descriptorOutFactory = descriptor.getOutProcessorFactory();
if (descriptorOutFactory != null) {
- outProcessor = InputProcessors.proxy(outProcessor, descriptorOutFactory.newInputProcessor());
+ outProcessor = descriptorOutFactory.newInputProcessor(outProcessor);
}
return outProcessor;
@@ -547,13 +546,12 @@
private InputProcessor createErrProcessor(OutputWriter writer) {
LineConvertorFactory convertorFactory = descriptor.getErrConvertorFactory();
- InputProcessor errProcessor = InputProcessors.ansiStripping(
- InputProcessors.printing(writer,
- convertorFactory != null ? convertorFactory.newLineConvertor() : null, false));
+ InputProcessor errProcessor = InputProcessors.printing(writer,
+ convertorFactory != null ? convertorFactory.newLineConvertor() : null, false);
InputProcessorFactory descriptorErrFactory = descriptor.getErrProcessorFactory();
if (descriptorErrFactory != null) {
- errProcessor = InputProcessors.proxy(errProcessor, descriptorErrFactory.newInputProcessor());
+ errProcessor = descriptorErrFactory.newInputProcessor(errProcessor);
}
return errProcessor;
diff -r 2532d50dca21 extexecution/src/org/netbeans/modules/extexecution/api/input/InputProcessors.java
--- a/extexecution/src/org/netbeans/modules/extexecution/api/input/InputProcessors.java Wed Oct 29 21:34:37 2008 +0100
+++ b/extexecution/src/org/netbeans/modules/extexecution/api/input/InputProcessors.java Thu Oct 30 15:52:07 2008 +0100
@@ -136,7 +136,8 @@
/**
* Returns the processor converting whole lines with convertor and
* printing the result including unterminated tail (if present) to the
- * given output writer.
+ * given output writer. If the covertor does not handle line passed to it
+ * (returning null
) raw lines are printed.
*
* Reset action on the returned processor resets the writer if it is enabled
* by passing
* Reset action on the returned processor resets the writer if it is enabled
* by passing
+ * On call to {@link LineConvertor#convert(java.lang.String)} converters
+ * are asked one by one for conversion in the same order they were
+ * passed to constructor. The first non
+ * Returned convertor is not thread safe.
+ *
+ * @param convertors convertors that will be proxied; the same order
+ * is used on {@link LineConvertor#convert(java.lang.String)}
+ * invocation
+ * @return the convertor proxying passed convertors
+ */
+ public static LineConvertor proxy(LineConvertor... convertors) {
+ return new ProxyLineConvertor(convertors);
+ }
+
+ /**
* Returns the convertor searching for lines matching the patterns,
* considering matched lines as being files.
*
@@ -84,9 +105,8 @@
* will use value
* When the line does not match the
* Resulting converted line contains the original text and a listener
* that consults the
* Returned convertor is not thread safe.
*
- * @param chain the converter to which the line will be passed when it is
- * not recognized as file; may be
* If line is not recognized as
* Returned convertor is not thread safe.
*
- * @param chain the converter to which the line will be passed when it is
- * not recognized as URL; may be true
as resetEnabled
. Processor
@@ -345,7 +346,13 @@
return;
}
- for (ConvertedLine converted : convertor.convert(line)) {
+ Listnull
) raw
+ * lines are printed.
* true
as resetEnabled
. Processor
@@ -213,17 +215,22 @@
LOGGER.log(Level.FINEST, line);
if (convertor != null) {
- for (ConvertedLine converted : convertor.convert(line)) {
- if (converted.getListener() == null) {
- out.println(converted.getText());
- } else {
- try {
- out.println(converted.getText(), converted.getListener());
- } catch (IOException ex) {
- LOGGER.log(Level.INFO, null, ex);
+ Listnull
+ * @return converted line
+ */
+ public static ConvertedLine forText(String text, OutputListener listener) {
+ Parameters.notNull("text", text);
+ return new ConvertedLine(text, listener);
+ }
/**
* Returns the text to display.
*
* @return the text to display
*/
- String getText();
+ public String getText() {
+ return text;
+ }
/**
* Returns the corresponding listener for actions taken on the line
@@ -63,6 +90,8 @@
* @return the corresponding listener for actions taken on the line
* or null
*/
- OutputListener getListener();
+ public OutputListener getListener() {
+ return listener;
+ }
}
diff -r 2532d50dca21 extexecution/src/org/netbeans/modules/extexecution/api/print/LineConvertor.java
--- a/extexecution/src/org/netbeans/modules/extexecution/api/print/LineConvertor.java Wed Oct 29 21:34:37 2008 +0100
+++ b/extexecution/src/org/netbeans/modules/extexecution/api/print/LineConvertor.java Thu Oct 30 15:52:07 2008 +0100
@@ -53,8 +53,9 @@
/**
* Converts the line to lines for output window. Method may return
- * no line or any other number of lines for single input line, however it
- * must not return null
.
+ * no line or any other number of lines for single input line. If
+ * the method returns null
the line was not handled by the
+ * convertor.
*
* @param line input line to convert
* @return converted lines for output window
diff -r 2532d50dca21 extexecution/src/org/netbeans/modules/extexecution/api/print/LineConvertors.java
--- a/extexecution/src/org/netbeans/modules/extexecution/api/print/LineConvertors.java Wed Oct 29 21:34:37 2008 +0100
+++ b/extexecution/src/org/netbeans/modules/extexecution/api/print/LineConvertors.java Thu Oct 30 15:52:07 2008 +0100
@@ -41,6 +41,7 @@
import java.net.MalformedURLException;
import java.net.URL;
+import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.logging.Level;
@@ -68,6 +69,26 @@
}
/**
+ * Returns the convertor that will delegate to passed converters.
+ * null
value
+ * is returned. If all coverters return null
for particular
+ * line null
is returned.
+ * 1
as a line number.
* linePattern
or
- * received filename does not match filePattern
the work is
- * delegated to chain
convertor. If this convertor is
- * null
the line containing just the original text is returned.
+ * received filename does not match filePattern
+ * null
is returned.
* fileLocator
(if any) when clicked
@@ -97,8 +117,6 @@
* null
* @param fileLocator locator that is consulted for real file; used in
* listener for the converted line; may be null
* @param linePattern pattern for matching the line
@@ -111,15 +129,15 @@
* @return the convertor searching for lines matching the patterns,
* considering matched lines as being files (names or paths)
*/
- public static LineConvertor filePattern(LineConvertor chain, FileLocator fileLocator,
- Pattern linePattern, Pattern filePattern, int fileGroup, int lineGroup) {
+ public static LineConvertor filePattern(FileLocator fileLocator, Pattern linePattern,
+ Pattern filePattern, int fileGroup, int lineGroup) {
Parameters.notNull("linePattern", linePattern);
if (fileGroup < 0) {
throw new IllegalArgumentException("File goup must be non negative: " + fileGroup); // NOI18N
}
- return new FilePatternConvertor(chain, fileLocator, linePattern, filePattern, fileGroup, lineGroup);
+ return new FilePatternConvertor(fileLocator, linePattern, filePattern, fileGroup, lineGroup);
}
/**
@@ -130,18 +148,15 @@
* line and listener opening browser with recognized url on click.
* http
or https
- * URL it is passed to the given chaining convertor. If chaining convertor
- * does not exist only the line containing the original text is returned.
+ * URL null
is returned.
* null
* @return the convertor parsing the line and searching for
* http
or https
URL
*/
- public static LineConvertor httpUrl(LineConvertor chain) {
- return new HttpUrlConvertor(chain);
+ public static LineConvertor httpUrl() {
+ return new HttpUrlConvertor();
}
/**
@@ -163,16 +178,31 @@
}
- private static List