Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > How to repropagate resolved styles?

Reply
Thread Tools

How to repropagate resolved styles?

 
 
Jan Burse
Guest
Posts: n/a
 
      08-24-2011
Dear All

Maybe somebody could help me with the following. I am using
two styles as follows:

private Style output;
private Style input;

SimpleAttributeSet aset = new SimpleAttributeSet();
aset.setResolveParent(input);
replaceRange("Hello", 0, 0, aset);

SimpleAttributeSet aset = new SimpleAttributeSet();
aset.setResolveParent(output);
replaceRange(" World!", 5, 5, aset);

What get is a mixed attributed text, but the attribute was
provided via resolve parent. This works fine, the text comes
out as expected.

Now I am doing a side effect as follows:

StyleConstants.setXXX(input, XXX).
StyleConstants.setXXX(output, XXX).
repaint();

The repaint has no effect. The text is shown the same as before.
But astonishingly when I do the following:

setEditable(false);
setEditable(true);

The resolve parent styles repropagate and the text changes as if
the resolve parents were logical styles on character level. Is
there another more proper way then calling setEditable twice, to
cause this update? Maybe something needs to be done earlier on, such
as registering the styles somewhere?

Any help appreciated.

Best Regards
 
Reply With Quote
 
 
 
 
Jan Burse
Guest
Posts: n/a
 
      08-25-2011
Jan Burse schrieb:
> The repaint has no effect. The text is shown the same as before.
> But astonishingly when I do the following:
>
> setEditable(false);
> setEditable(true);
>
> The resolve parent styles repropagate and the text changes as if
> the resolve parents were logical styles on character level.



I did some diggging. The setEditable() does fire a property change
event with the property name "editable", which in turn calls in
BasicTextUI the following method:

/**
* Flags model changes.
* This is called whenever the model has changed.
* It is implemented to rebuild the view hierarchy
* to represent the default root element of the
* associated model.
*/
protected void modelChanged() {
// create a view hierarchy
ViewFactory f = rootView.getViewFactory();
Document doc = editor.getDocument();
Element elem = doc.getDefaultRootElement();
setView(f.create(elem));
}

Can I cause a JTextPane to do a model rebuild as above
without firing a property change event? Problem is
I have to fire two property change events, one
true -> false
And another:
false -> true
Because the fire property change method checks whether
the old property value equals the new property value. And
does nothing when they are equal.

So is there a more direct way to cause a model change
than via multiple fire property change events?

Bye

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Wireless XP SP2 netwk semi-resolved. =?Utf-8?B?VGluYS5W?= Wireless Networking 4 01-08-2005 02:05 AM
Remote Assistance fails to connect, remote remote host name could not be resolved Peter Sale Wireless Networking 1 12-11-2004 09:09 PM
Resolved Signals =?ISO-8859-1?Q?Dominik_Fr=F6hlich?= VHDL 1 02-09-2004 06:35 PM
SystemC std_logic resolved type zoro VHDL 2 07-05-2003 07:16 PM



Advertisments