Hooking into the console's Document [message #604903] |
Fri, 05 March 2010 15:44 |
Marian Schedenig Messages: 25 Registered: July 2009 |
Junior Member |
|
|
Hi!
Styling individual lines in the console is quite simple; I just register an
IConsolePageParticipant, get the StyledText instance from the view page and
add a line style listener.
What I now want to do is *filter* lines, i.e. decide on a line by line basis
whether a line should be displayed or omitted completely. That doesn't seem
to be so easy.
It looks like one way to do this is to switch the StyledText's original
StyledTextContent with my own which takes its data from the original content
and filters it.
But it seems to me that a better solution would be to switch either the
Document or the document adapter used by the console's text viewer. From
what I understand, these are used earlier in the chain, so filtering lines
there would save work (and time) on the StyledTextContent side.
Only I'm not sure how to do this. The only way to change the document
adapter (which can't be set from outside as far as I can see) seems to be to
subclass TextViewer and override the createDocumentAdapter method. Clearly,
this is not an option since I'm trying to hook into an existing TextViewer.
And when I try to replace the TextConsoleViewer's Document with one of my
own (a very simple test instance for now - new
Document("This\nis\na\ntest.")), the console stops working and just throws
exceptions.
Is there any sane way to hook into the Document part of the data chain? Or
should I stick to my original idea and handle everything on the
StyledTextContent side? Or have I missed a much simpler solution?
Thanks,
Marian.
|
|
|
Powered by
FUDForum. Page generated in 0.03262 seconds