Skip to main content



      Home
Home » Eclipse Projects » GEF » multiple selections question
multiple selections question [message #135110] Sun, 30 May 2004 21:45 Go to next message
Eclipse UserFriend
all,

i am curious how other people are handling this situation:

i have several SelectionActions that allow for selecting more than one
object. when the user selects multiple object, the SelectionAction
iterates through the selected objects and creates commands for each
object. it then executes the commands in a compound command.

this all works well, but i fire property events for each selected object
in its model, i.e.

public void setFoo(Object foo) {
this.foo = foo;
firePropertyEvent("FOO");
}

this means that the diagram is going to refreshChildren() on each selected
object. this may be a lot of unnecessary overhead, versus setting all the
models, and then calling refreshChildren once.

i am wondering how others are handling this situation.

thanks,
steve
Re: multiple selections question [message #135123 is a reply to message #135110] Mon, 31 May 2004 06:53 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: rlemaigr.ulb.ac.be

I'm handling it just like you, because it is, the simplest way to do thi=
s =

I think, and I have the same "problem" of efficiency as you.

But this problem of efficiency is not really a big problem because:
- the users usually don't trigger operations very often, so they can be =
a =

little slow to execute, for me that's acceptable,
- the method refreshChildren is smart: it don't rebuild an EditPart for =
=

each model object each time the refreshChildren is called, it only build=
s =

a new EditPart only for the new objects which are in the List returned b=
y =

getModelChildren and wasn't there the last time the method =

getModelChildren was called.

And after all, when you think about it, when a user select one object an=
d =

triggers an operation that takes, let's say, 1/50 second to execute, if =
he =

selects 50 objects, he shouldn't be surprised that the operation takes n=
ow =

1 second to execute.

You could write special commands for handling a group of operations, =

writing special methods in your model for hanling such group operations =
=

and firing special events for signaling such group operation but that's =
=

not very funny :S

r=E9gis


On Mon, 31 May 2004 01:45:24 +0000 (UTC), steven melzer =

<steven.melzer@verizon.net> wrote:

> all,
>
> i am curious how other people are handling this situation:
>
> i have several SelectionActions that allow for selecting more than one=

> object. when the user selects multiple object, the SelectionAction
> iterates through the selected objects and creates commands for each
> object. it then executes the commands in a compound command.
>
> this all works well, but i fire property events for each selected obje=
ct
> in its model, i.e.
>
> public void setFoo(Object foo) {
> this.foo =3D foo;
> firePropertyEvent("FOO");
> }
>
> this means that the diagram is going to refreshChildren() on each =

> selected
> object. this may be a lot of unnecessary overhead, versus setting all=
=

> the
> models, and then calling refreshChildren once.
>
> i am wondering how others are handling this situation.
>
> thanks,
> steve
>
>



-- =

Using Opera's revolutionary e-mail client: http://www.opera.com/m2/
Re: multiple selections question [message #135183 is a reply to message #135110] Mon, 31 May 2004 20:37 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

> i am curious how other people are handling this situation:
>
> i have several SelectionActions that allow for selecting more than one
> object. when the user selects multiple object, the SelectionAction
> iterates through the selected objects and creates commands for each
> object. it then executes the commands in a compound command.
>
> this all works well, but i fire property events for each selected object
> in its model, i.e.
>
> public void setFoo(Object foo) {
> this.foo = foo;
> firePropertyEvent("FOO");
> }
>
> this means that the diagram is going to refreshChildren() on each selected

Does the FOO property actually involve children? If not, you could call
only the specific refresh methods relevant to the propertychange. Secondly,
consider calling removeChild(editpart) and addChild(editpart, index) instead
of calling refreshChildren. If you can call these methods instead, then you
will see order of magnitude speed improvements.

> object. this may be a lot of unnecessary overhead, versus setting all the
> models, and then calling refreshChildren once.

refreshChildren() is O(n). Calling it N times means you have N^2
performance. add and removeChild are O(1).
>
> i am wondering how others are handling this situation.
>
> thanks,
> steve
>
>
Re: multiple selections question [message #135334 is a reply to message #135183] Tue, 01 June 2004 08:48 Go to previous message
Eclipse UserFriend
thank you. this is very helpful. i will change my otherwise ignorant
propertyChange method in my diagram edit part to make better decisions for
refreshChildren vs. add/remove child.

steve

Randy Hudson wrote:

> > i am curious how other people are handling this situation:
> >
> > i have several SelectionActions that allow for selecting more than one
> > object. when the user selects multiple object, the SelectionAction
> > iterates through the selected objects and creates commands for each
> > object. it then executes the commands in a compound command.
> >
> > this all works well, but i fire property events for each selected object
> > in its model, i.e.
> >
> > public void setFoo(Object foo) {
> > this.foo = foo;
> > firePropertyEvent("FOO");
> > }
> >
> > this means that the diagram is going to refreshChildren() on each selected

> Does the FOO property actually involve children? If not, you could call
> only the specific refresh methods relevant to the propertychange. Secondly,
> consider calling removeChild(editpart) and addChild(editpart, index) instead
> of calling refreshChildren. If you can call these methods instead, then you
> will see order of magnitude speed improvements.

> > object. this may be a lot of unnecessary overhead, versus setting all the
> > models, and then calling refreshChildren once.

> refreshChildren() is O(n). Calling it N times means you have N^2
> performance. add and removeChild are O(1).
> >
> > i am wondering how others are handling this situation.
> >
> > thanks,
> > steve
> >
> >
Previous Topic:figure in Swing or awt container ?
Next Topic:Selectable but not movable
Goto Forum:
  


Current Time: Wed Nov 05 18:45:36 EST 2025

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

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

Back to the top