Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Papyrus » Problem with model-view update
icon3.gif  Problem with model-view update [message #549939] Wed, 28 July 2010 14:01 Go to next message
123star  is currently offline 123star Friend
Messages: 70
Registered: June 2010
Member
Hi,

I'm writing a plugin for Papyrus that implements notifyChanged estension point:

it checks if a generalization between two classes is created and then copies all the ports of superclass in the subclass.

I used getNotifier that returns a Generalization object and then I took the two classes with getSources and getTargets.

I used a RecordingCommand to:
copy the ports of superclass with EcoreUtil.Copier, then
I added them to subclass with subclass.getOwnedPorts().add(copiedPort)

I execute the command but here's what appens:

I can see the changes in the navigation bar, but I can't see them in the editor.

What is missing? What did I do wrong?

Thanks in advance, star123
Re: Problem with model-view update [message #549953 is a reply to message #549939] Wed, 28 July 2010 14:43 Go to previous messageGo to next message
Remi Schnekenburger is currently offline Remi SchnekenburgerFriend
Messages: 169
Registered: July 2009
Location: Palaiseau, France
Senior Member
Hi,

If the model explorer has been updated , this means that the semantic model (UML model for instance) has been correctly modified. But there is in Papyrus (and usual UML graphical editors) a separation between what you see and what is in the semantic model. Let me explain!

You can have several times the same element displayed on the diagram - for example, several times the same package on the same class diagram. You can also have several times the same package represented in various diagrams. This is the concept of diagrams in UML, where a diagram is only the point of view that you want to have on the model.
This means that we never proceed to a strong synchronization of the views depending on the model modifications, especially in case of model elements addition. We do not always represent an element if it is added in the semantic model. The only moment we have to perform a strong synchronisation is in case of semantic model deletions.
In the case we have several times the same package represented in various diagrams: when we perform a deletion of the package element, we have to remove its views from all diagrams.

To graphically represent the elements you have just created, you should create views corresponding to the new semantic elements. You can see example of view creation in the org.eclipse.papyrus.diagram.common plugin, where the drag and drop is managed. Look in the class org.eclipse.papyrus.diagram.common.editpolicies.CommonDiagra mDragDropEditPolicy.
In fact, Drag'n'dropping an element from the model explorer is equivalent to the creation of a view: the semantic model element already exists, you just want to display it in the diagram.

Regards,
Rémi



Remi Schnekenburger

Get professional Eclipse developer support:
http://eclipsesource.com/en/services/developer-support/
Re: Problem with model-view update [message #549991 is a reply to message #549953] Wed, 28 July 2010 16:31 Go to previous messageGo to next message
123star  is currently offline 123star Friend
Messages: 70
Registered: June 2010
Member
Hi,

I looked the class org.eclipse.papyrus.diagram.common.editpolicies.CommonDiagra mDragDropEditPolicy

here's the questions:

I'm writing code inside method notifyChanged(Notification ne) in a class that implements IPapyrusListener, so I can't see the method getHost( ), do I have to extend the class with DiagramDragDropEditPolicy?

My only goal is to add a programmatically created Port to a Class, so I still have the problem to set the location of the view of the Port.

I'm trying this, note that I can't see getHost method:
---
ViewDescriptor descriptor =
new ViewDescriptor(new EObjectAdapter(thePort), Node.class, null, ViewUtil.APPEND, false, ((IGraphicalEditPart)getHost()).getDiagramPreferencesHint()) ;

CreateViewRequest createViewRequest =
new CreateViewRequest(descriptor );
createViewRequest.setLocation(unknownLocation);

Command createCommand = getHost().getCommand(createViewRequest);
---

I have to resolve the problem of unknownLocation, maybe taking the view of the class and calculating its bounds location.

Then I have to execute the command, but I don't know how...

Thanks in advance, 123star





[Updated on: Thu, 12 August 2010 12:19]

Report message to a moderator

Re: Problem with model-view update [message #552533 is a reply to message #549939] Thu, 12 August 2010 14:37 Go to previous messageGo to next message
123star  is currently offline 123star Friend
Messages: 70
Registered: June 2010
Member
Up
Re: Problem with model-view update [message #556260 is a reply to message #549939] Tue, 31 August 2010 14:04 Go to previous messageGo to next message
123star  is currently offline 123star Friend
Messages: 70
Registered: June 2010
Member
Up
Re: Problem with model-view update [message #602633 is a reply to message #549939] Wed, 28 July 2010 14:43 Go to previous messageGo to next message
Remi Schnekenburger is currently offline Remi SchnekenburgerFriend
Messages: 169
Registered: July 2009
Location: Palaiseau, France
Senior Member
Hi,

If the model explorer has been updated , this means that the semantic model (UML model for instance) has been correctly modified. But there is in Papyrus (and usual UML graphical editors) a separation between what you see and what is in the semantic model. Let me explain!

You can have several times the same element displayed on the diagram - for example, several times the same package on the same class diagram. You can also have several times the same package represented in various diagrams. This is the concept of diagrams in UML, where a diagram is only the point of view that you want to have on the model.
This means that we never proceed to a strong synchronization of the views depending on the model modifications, especially in case of model elements addition. We do not always represent an element if it is added in the semantic model. The only moment we have to perform a strong synchronisation is in case of semantic model deletions.
In the case we have several times the same package represented in various diagrams: when we perform a deletion of the package element, we have to remove its views from all diagrams.

To graphically represent the elements you have just created, you should create views corresponding to the new semantic elements. You can see example of view creation in the org.eclipse.papyrus.diagram.common plugin, where the drag and drop is managed. Look in the class org.eclipse.papyrus.diagram.common.editpolicies.CommonDiagra mDragDropEditPolicy.
In fact, Drag'n'dropping an element from the model explorer is equivalent to the creation of a view: the semantic model element already exists, you just want to display it in the diagram.

Regards,
Rémi


--
http://www.eclipse.org/papyrus


Remi Schnekenburger

Get professional Eclipse developer support:
http://eclipsesource.com/en/services/developer-support/
Re: Problem with model-view update [message #602636 is a reply to message #602633] Wed, 28 July 2010 16:31 Go to previous messageGo to next message
123star  is currently offline 123star Friend
Messages: 70
Registered: June 2010
Member
Thank you very much!
Re: Problem with model-view update [message #605993 is a reply to message #549939] Thu, 12 August 2010 14:37 Go to previous messageGo to next message
123star  is currently offline 123star Friend
Messages: 70
Registered: June 2010
Member
Up
Re: Problem with model-view update [message #606929 is a reply to message #549939] Tue, 31 August 2010 14:04 Go to previous message
123star  is currently offline 123star Friend
Messages: 70
Registered: June 2010
Member
Up
Previous Topic:modeling projects by reverse engineering in future releases ?
Next Topic:Export to PNG and Problems with class diagrams
Goto Forum:
  


Current Time: Fri Mar 29 07:18:46 GMT 2024

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

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

Back to the top