Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » Automatic refresh of the diagram editor at runtime
Automatic refresh of the diagram editor at runtime [message #988855] Mon, 03 December 2012 13:22 Go to next message
Saniya Mirajkar is currently offline Saniya MirajkarFriend
Messages: 31
Registered: August 2012
Member
I need help around following 2 points:

1.Need to remove the Undo/Redo options that is provided by framework in the context menu.
I could remove other default features from context menu by overriding the corresponding methods in Feature-provider to return null.But I could not get something similar for Undo/Redo feature.

2.Need to implement auto-updation feature at runtime when diagram editor is already open.
I have to update the diagram once the values in the model have changed.From the forum I get to learn that there is isAutoUpdateAtRuntimeWhenEditorIsSaved() method that can be overridden in DiagramTypeProvider which will take care of Auto-updation.
Do I need to fire any onchange()/resourceSetChanged event when my model values are changed?

What all do I need to do to achieve this features?
Re: Automatic refresh of the diagram editor at runtime [message #989228 is a reply to message #988855] Wed, 05 December 2012 09:59 Go to previous messageGo to next message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1931
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Hemlata,

1. Have a look into DiagramEditorContextMenuProvider. There's a method
addDefaultMenuGroupUndo that adds the two entries to the context menu. You
may register your own context menu provider in
DiagramEditor.createContextMenuProvider().

2. With an EMF model you do not need to fire an event. In case of a change
to an EObject in a loaded resource Graphiti has a listener in place that
will trigger an update of the diagram in case there is a pictogram element
on the diagram that is linked to the changed domain object.

Michael
Re: Automatic refresh of the diagram editor at runtime [message #989484 is a reply to message #989228] Thu, 06 December 2012 12:35 Go to previous messageGo to next message
Saniya Mirajkar is currently offline Saniya MirajkarFriend
Messages: 31
Registered: August 2012
Member
Thanks Michael for the reply.

For point 2, I use Non-Emf model in which I just have the POJO objects as model. I change values in my POJO object which I want to reflect in diagram as well at runtime.

How should this be done for Non-EMF model?

Re: Automatic refresh of the diagram editor at runtime [message #989709 is a reply to message #989484] Fri, 07 December 2012 11:24 Go to previous messageGo to next message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1931
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Hemlata,

for non-EMF domain models you will need to implement such a change listener
on your own (technology dependend). As soon as a domain model object
changes, you would trigger an update of the diagram e.g. via the
notification service you can retrieve from the diagram type provider. You
would also implement an IIndependenceSolver that handles the linking between
the shapes and your domain objects.

There's a section of non-EMF domain models in the Eclipse help for Graphiti,
see
http://help.eclipse.org/juno/index.jsp?topic=%2Forg.eclipse.graphiti.doc%2Fresources%2Fdocu%2Fgfw%2FNon-EMF+domain+objects.htm&cp=27_1_12

Michael
Re: Automatic refresh of the diagram editor at runtime [message #989933 is a reply to message #989709] Mon, 10 December 2012 07:12 Go to previous messageGo to next message
Saniya Mirajkar is currently offline Saniya MirajkarFriend
Messages: 31
Registered: August 2012
Member
Hi Michael,

Thanks for info.
I have the classes in place as said in the Eclipse help.
In addition I have an Update feature corresponding to my domain model.

In my case updateneeded() method of update feature class is properly triggered when the domain model changes.But actual update is not happening.

Should I trigger the update of the diagram via the notification service or I need to trigger ResourceSetChanged event for DomainModelListener when the domain model changes?

DomainModelListener class internally calls the notification service.
Re: Automatic refresh of the diagram editor at runtime [message #990041 is a reply to message #989933] Mon, 10 December 2012 16:10 Go to previous messageGo to next message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1931
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Hemlata,

you should trigger that using the notification service. The
DomainModelListener should only be in place for EMF domain models (unless it
is not your own one...)

Michael
Re: Automatic refresh of the diagram editor at runtime [message #990151 is a reply to message #990041] Tue, 11 December 2012 07:35 Go to previous messageGo to next message
Saniya Mirajkar is currently offline Saniya MirajkarFriend
Messages: 31
Registered: August 2012
Member
Hi,

I do the following stuff when my domain model is changed:


final Set<DomainObject> changedBOs = new HashSet<DomainObject>();

//Add the changed domain object to set
changedBOs.add(this.domainModel);

final PictogramElement[] dirtyPes = editor.getDiagramTypeProvider()
.getNotificationService()
.calculateRelatedPictogramElements(changedBOs.toArray());

// Do nothing if no BO linked to the diagram changed.
if (dirtyPes.length == 0) {
return;
}


// Do an asynchronous update in the UI thread.
Display.getDefault().asyncExec(new Runnable() {

@Override
public void run() {
if (editor.getDiagramTypeProvider() .isAutoUpdateAtRuntimeWhenEditorIsSaved()) {

// The notification service takes care of not only the
// linked BOs but also asks the diagram provider about related BOs.

editor.getDiagramTypeProvider() .getNotificationService() .updatePictogramElements(dirtyPes);

} else {

editor.getDiagramTypeProvider() .getNotificationService() .updatePictogramElements(dirtyPes);

editor.getDiagramTypeProvider().getDiagramEditor() .refresh();
}
}

});

With this the diagram editor is refreshed with new value of one of the domain object.But the same is getting reflected for other pictograms elemnts which are of same type(i.e Domain Object.)
Re: Automatic refresh of the diagram editor at runtime [message #990362 is a reply to message #990151] Wed, 12 December 2012 07:42 Go to previous messageGo to next message
Saniya Mirajkar is currently offline Saniya MirajkarFriend
Messages: 31
Registered: August 2012
Member
Hi,

After little more investigation I have the following observation:

Say I have 2 objects A and B of same Domain type, and X and Y are the corresponding pictogramElements related to domain objects.

Now when update is fired, the getBusinessObjectForPictogramElement() method is always returning the Buisness object A even though the recieved update context is for pictogramElement Y which is related to domain object B.

I am not sure where exactly the problem is.
Re: Automatic refresh of the diagram editor at runtime [message #990716 is a reply to message #990362] Thu, 13 December 2012 13:00 Go to previous message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1931
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Hemlata,

are you sure your independence solver returns the correct domain object for
the shape?

Michael
Previous Topic:Utilizing Graphiti Diagrams
Next Topic:Nesting Shapes etc...
Goto Forum:
  


Current Time: Fri Apr 19 20:04:45 GMT 2024

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

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

Back to the top