Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Nebula » [RichTextPainter] IllegalArgumentException in ResetSpanStylePaintInstruction
[RichTextPainter] IllegalArgumentException in ResetSpanStylePaintInstruction [message #1743513] Fri, 16 September 2016 06:52 Go to next message
Volker Bier is currently offline Volker BierFriend
Messages: 7
Registered: August 2016
Junior Member
Whenever I have nested span elements like in the following HTML:
Quote:
<span style="color:rgb(255, 0, 0)"><span style="color:rgb(210, 105, 30)">ERROR, STOP_FTC:SAS_Startup failed for ODN_SAS:Ground_Common: COMMUNICATION_ERROR: Error on the communication channel</span></span>


The painter throws an IllegalArgumentException:
Quote:
Caused by: java.lang.IllegalArgumentException: Argument cannot be null
at org.eclipse.swt.SWT.error(SWT.java:4472)
at org.eclipse.swt.SWT.error(SWT.java:4406)
at org.eclipse.swt.SWT.error(SWT.java:4377)
at org.eclipse.swt.graphics.GC.setForeground(GC.java:3513)
at org.eclipse.nebula.widgets.richtext.painter.instructions.ResetSpanStylePaintInstruction.paint(ResetSpanStylePaintInstruction.java:40)


The problem is that the ResetSpanStylePaintInstruction sets the state color to null instead to the color of the parent span. So when there are two adjacent </span> elements, the first one sets the state color to null and the second one then sets the gc foreground to null.

Shall I file a bug for this, or am I doing something wrong?
Re: [RichTextPainter] IllegalArgumentException in ResetSpanStylePaintInstruction [message #1743518 is a reply to message #1743513] Fri, 16 September 2016 07:41 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2903
Registered: July 2012
Senior Member
Well looking at your html snippet I wonder why you have a nested span? The outer span is kind of useless.

But since it is valid html feel free to create a ticket for this.
Re: [RichTextPainter] IllegalArgumentException in ResetSpanStylePaintInstruction [message #1743521 is a reply to message #1743518] Fri, 16 September 2016 07:49 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2903
Registered: July 2012
Senior Member
Just checked the implementation. In TagProcessingState I commented that stacking of colors is not necessary. IIRC the ckeditor does not produce such combinations. But I could be wrong.

The solution would be to introduce the same stacking behaviour as for fonts.
Re: [RichTextPainter] IllegalArgumentException in ResetSpanStylePaintInstruction [message #1743527 is a reply to message #1743521] Fri, 16 September 2016 08:33 Go to previous messageGo to next message
Volker Bier is currently offline Volker BierFriend
Messages: 7
Registered: August 2016
Junior Member
The problem is that the html formatting directives are inserted into normal text by markup display converters (working with user defined regular expressions). Since I have no control over the converters defined by the users, I somehow have to make this work. One possibility obviously would be to remove all superfluous markup before passing the text to the painter, but that would not fix all cases. If the HTML looked like this:
Quote:
<span style="color:rgb(255, 0, 0)">lots of text with red color in a the top span<span style="color:rgb(210, 105, 30)">some more text with a different color</span></span>

removing spans would no longer work.

[Updated on: Fri, 16 September 2016 08:35]

Report message to a moderator

Re: [RichTextPainter] IllegalArgumentException in ResetSpanStylePaintInstruction [message #1743532 is a reply to message #1743527] Fri, 16 September 2016 08:55 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2903
Registered: July 2012
Senior Member
so file a bug and we introduce stacking also for colours. ckeditor is closing a color span before applying a new one. Therefore it is implemented as it is.
Re: [RichTextPainter] IllegalArgumentException in ResetSpanStylePaintInstruction [message #1743534 is a reply to message #1743532] Fri, 16 September 2016 09:08 Go to previous messageGo to next message
Volker Bier is currently offline Volker BierFriend
Messages: 7
Registered: August 2016
Junior Member
Thanks for looking into this, I have written a bug report: https://bugs.eclipse.org/bugs/show_bug.cgi?id=501568
Re: [RichTextPainter] IllegalArgumentException in ResetSpanStylePaintInstruction [message #1743560 is a reply to message #1743534] Fri, 16 September 2016 11:43 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2903
Registered: July 2012
Senior Member
I provided a patch that needs to be checked. Is it possible for you to checkout and test it before I merge it into the repository? If we are lucky it can be part of the 1.1.0 release of Nebula next week then.
Re: [RichTextPainter] IllegalArgumentException in ResetSpanStylePaintInstruction [message #1743604 is a reply to message #1743560] Fri, 16 September 2016 19:38 Go to previous messageGo to next message
Wim Jongman is currently offline Wim JongmanFriend
Messages: 493
Registered: July 2009
Senior Member

A Gerrit P2 repo can be found here:

https://hudson.eclipse.org/nebula/job/nebula.stable.gerrit/lastSuccessfulBuild/artifact/releng/org.eclipse.nebula.updatesite/target/repository/
Re: [RichTextPainter] IllegalArgumentException in ResetSpanStylePaintInstruction [message #1743694 is a reply to message #1743604] Mon, 19 September 2016 05:41 Go to previous message
Volker Bier is currently offline Volker BierFriend
Messages: 7
Registered: August 2016
Junior Member
Thanks you for the repo url. I have tested the fix and it works for my cases.
Previous Topic:news.eclipse.org is shutting down.
Next Topic:[Richtext Editor] How to wait to load of browser
Goto Forum:
  


Current Time: Sat Oct 12 02:53:51 GMT 2024

Powered by FUDForum. Page generated in 0.04262 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top