[jface.text] how to stop document change notification temporarily? [message #660803] |
Mon, 21 March 2011 12:09  |
Eclipse User |
|
|
|
Hello,
is there a way to stop a document sending document change events to its listeners temporarily?
I tried something like:
document.stopListenerNotification();
edits.apply( document ); // would normally fires document change events
document.resumeListenerNotification(); // events are fired here (delayed)
This method just "queues" the document change events caused by
applying the edits and fires the events as soon as the notification is
resumed.
Instead I would like to ignore the events caused by edits.apply( document )
which could be achieved with the following pseudo-code:
listeners = document.removeAllListeners();
edits.apply( document );
document.addListeners( listeners );
Thanks for any suggestions.
Kind regards
Harald
|
|
|
|
Re: [jface.text] how to stop document change notification temporarily? [message #660819 is a reply to message #660804] |
Mon, 21 March 2011 14:28   |
Eclipse User |
|
|
|
On 03/21/2011 05:27 PM, Daniel Megert wrote:
> On 21.03.2011 17:09, Harald Finster wrote:
>> Hello,
>>
>> is there a way to stop a document sending document change events to
>> its listeners temporarily?
> What's the use case for that? In general this would result in
> inconsistent states (in the listeners).
A bit complicated to explain, but anyways: my application keeps
a JavsScript program and a graphical representation of (parts of)
the program in sync. The JavaScript code is treated as the "model".
The information, which is required to paint the graphical elements
(location of boxes, bend points of arrows between boxes etc.) is
stored as JSDoc comments in the source code.
Something like
/**
* @box {x=5,y=5,with=100,height=100}
*/
box1 : { .... },
/**
* @box {x=5,y=100,with=100,height=100}
*/
box2 : { .... },
"Normally" a listener listens to document changes and triggers
an ASTParser which controls the graphical representation.
For example, if someone adds a 3rd "box" object to the source code,
the code is re-parsed and a 3rd "box" painted.
In case of changes, which affect only the graphical representation,
only the comments in the JavaScript code are affected and I can
be sure, that there are no structural/semantic changes in the
code, i.e. (computationally expensive) re-parsing the document is
not required.
Thanks for reflecting on my problem!
Harald
|
|
|
Re: [jface.text] how to stop document change notification temporarily? [message #661105 is a reply to message #660819] |
Wed, 23 March 2011 04:26   |
Eclipse User |
|
|
|
On 21.03.2011 19:28, Harald Finster wrote:
> On 03/21/2011 05:27 PM, Daniel Megert wrote:
>> On 21.03.2011 17:09, Harald Finster wrote:
>>> Hello,
>>>
>>> is there a way to stop a document sending document change events to
>>> its listeners temporarily?
>> What's the use case for that? In general this would result in
>> inconsistent states (in the listeners).
> A bit complicated to explain, but anyways: my application keeps
> a JavsScript program and a graphical representation of (parts of)
> the program in sync. The JavaScript code is treated as the "model".
>
> The information, which is required to paint the graphical elements
> (location of boxes, bend points of arrows between boxes etc.) is
> stored as JSDoc comments in the source code.
>
> Something like
>
> /**
> * @box {x=5,y=5,with=100,height=100}
> */
> box1 : { .... },
>
> /**
> * @box {x=5,y=100,with=100,height=100}
> */
> box2 : { .... },
>
> "Normally" a listener listens to document changes and triggers
> an ASTParser which controls the graphical representation.
>
> For example, if someone adds a 3rd "box" object to the source code,
> the code is re-parsed and a 3rd "box" painted.
>
> In case of changes, which affect only the graphical representation,
> only the comments in the JavaScript code are affected and I can
> be sure, that there are no structural/semantic changes in the
> code, i.e. (computationally expensive) re-parsing the document is
> not required.
There are other things that depend on the document changed events.
Disabling those can result in lots of unexpected problems and therefore
it's not supported to (temporarily) disable the notification. I assume
you implement your own editor. In that case what you really want to do
is tweaking the reconciler so that he only reconciles the model when needed.
Dani
> Thanks for reflecting on my problem!
>
> Harald
|
|
|
Re: [jface.text] how to stop document change notification temporarily? [message #661225 is a reply to message #661105] |
Wed, 23 March 2011 11:46  |
Eclipse User |
|
|
|
Hello
Am 23.03.2011 09:26, schrieb Daniel Megert:
> There are other things that depend on the document changed events. Disabling those can result in lots of unexpected problems and therefore it's not supported to (temporarily) disable the notification. I assume you implement your own editor. In that case what you really want to do is tweaking the reconciler so that he only reconciles the model when needed.
>
okay, yes, that makes sense. Thanks for your feedback.
Kind regards
Harald
|
|
|
Powered by
FUDForum. Page generated in 0.04337 seconds