Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » [jface.text] how to stop document change notification temporarily?
[jface.text] how to stop document change notification temporarily? [message #660803] Mon, 21 March 2011 16:09 Go to next message
Harald Finster is currently offline Harald FinsterFriend
Messages: 37
Registered: July 2009
Member
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 #660804 is a reply to message #660803] Mon, 21 March 2011 16:27 Go to previous messageGo to next message
Dani Megert is currently offline Dani MegertFriend
Messages: 3802
Registered: July 2009
Senior Member
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).

Dani
>
> 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 18:28 Go to previous messageGo to next message
Harald Finster is currently offline Harald FinsterFriend
Messages: 37
Registered: July 2009
Member
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 08:26 Go to previous messageGo to next message
Dani Megert is currently offline Dani MegertFriend
Messages: 3802
Registered: July 2009
Senior Member
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 15:46 Go to previous message
Harald Finster is currently offline Harald FinsterFriend
Messages: 37
Registered: July 2009
Member
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
Previous Topic:Google Map for RCP Application
Next Topic:Window's process for RCP app.
Goto Forum:
  


Current Time: Fri Apr 26 23:30:11 GMT 2024

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

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

Back to the top