Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Problems caused by the call to the factory as part of the collectNewChildDescriptors in the Edit Plu
Problems caused by the call to the factory as part of the collectNewChildDescriptors in the Edit Plu [message #425292] Fri, 21 November 2008 20:54 Go to next message
Pierre is currently offline PierreFriend
Messages: 3
Registered: July 2009
Junior Member
Hi all,

I have created an EMF model that contains Node that can have Nodes as
children (Node contains a list of children). In the Edit setting of the
..genmodel, I set both the Children and Create Child to true (so that I
can see them and select them in the outline).

While this result in having the required behaviour in the Outline view,
I found that the collectNewChildDescriptors() method in the
NodeItemProvider actually calls the plugin factory to instanciate a Node
every time I select a node in the outline.

In my application, this causes problems. I have a Robot class that
inherits from Node. This robot, when created by the RobotFactory,
initialize a connection with the robot hardware. Lets say I load an XML
file that contains a Robot using the generated EMF editor. Then when I
explore the hierarchy of Node in the Outline, I get a Robot instanciated
every time I select the robot in the outline !

It seem to me that the only case where my RobotFactory,createRobot()
should be called is when a model is loaded or I explicitly make such a
call in my code. I could see that this could also become a problem if my
factory implements some sort of tracking of instances created. Having
instances created "in the background" by the GUI is a bit misleading.

Is there a way of preventing the Edit layer from instantiating objects
while retaining the capability to display an Object's child in the outline ?

Thanks in advance,

Pierre.
Re: Problems caused by the call to the factory as part of the collectNewChildDescriptors in the Edit [message #425295 is a reply to message #425292] Fri, 21 November 2008 23:42 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 30896
Registered: July 2009
Senior Member
Pierre,

Comments below.


Pierre Allard wrote:
> Hi all,
>
> I have created an EMF model that contains Node that can have Nodes as
> children (Node contains a list of children). In the Edit setting of
> the .genmodel, I set both the Children and Create Child to true (so
> that I can see them and select them in the outline).
>
> While this result in having the required behaviour in the Outline
> view, I found that the collectNewChildDescriptors() method in the
> NodeItemProvider actually calls the plugin factory to instanciate a
> Node every time I select a node in the outline.
>
> In my application, this causes problems. I have a Robot class that
> inherits from Node. This robot, when created by the RobotFactory,
> initialize a connection with the robot hardware.
Creating initialized objects sounds like a bad idea. When you
deserialize, the created object should not be initialized at all.
> Lets say I load an XML file that contains a Robot using the generated
> EMF editor. Then when I explore the hierarchy of Node in the Outline,
> I get a Robot instanciated every time I select the robot in the
> outline !
Well, there you go. That's why it's a bad idea.
>
> It seem to me that the only case where my RobotFactory,createRobot()
> should be called is when a model is loaded or I explicitly make such a
> call in my code. I could see that this could also become a problem if
> my factory implements some sort of tracking of instances created.
> Having instances created "in the background" by the GUI is a bit
> misleading.
A copier could create instances. Any client could create instances. I
don't think you should make assumptions about why instances are created
and when it's valid.
>
> Is there a way of preventing the Edit layer from instantiating objects
> while retaining the capability to display an Object's child in the
> outline ?
I think you should reconsider creating objects that aren't in the
"ground" state.
>
> Thanks in advance,
>
> Pierre.
>
Previous Topic:Iteration of non-containment references
Next Topic:[Teneo] Problem in using Named Queries
Goto Forum:
  


Current Time: Sat Feb 22 23:25:34 GMT 2020

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

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

Back to the top