Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » Auto update not fully working ?
Auto update not fully working ? [message #1384226] Wed, 28 May 2014 13:08 Go to next message
Laurent Le Moux is currently offline Laurent Le MouxFriend
Messages: 184
Registered: September 2011
Senior Member
Hi all,

Following Graphiti tutorial, I did override the following methods in my diagram type provider :
@Override
public boolean isAutoUpdateAtStartup() {
	return true;
}

@Override
public boolean isAutoUpdateAtRuntimeWhenEditorIsSaved() {
	return true;
}


Considering the default behavior is 'true' for 'isAutoUpdateAtRuntime' and 'isAutoUpdateAtReset', my diagram should be updated automatically in all situations.

But it only successfully happens at startup...

Any idea why ?

Regards,

Laurent
Re: Auto update not fully working ? [message #1384276 is a reply to message #1384226] Wed, 28 May 2014 15:27 Go to previous messageGo to next message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1931
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Laurent,

the update is triggered by calling the DefaultUpdateDiagramFeature in the
first place. The default implementation tries to find update features for
the direct child shapes in the dagram. Can you check if
a) anything is found here
b) what these update features do

Michael
Re: Auto update not fully working ? [message #1384597 is a reply to message #1384276] Thu, 29 May 2014 12:36 Go to previous messageGo to next message
Laurent Le Moux is currently offline Laurent Le MouxFriend
Messages: 184
Registered: September 2011
Senior Member
Hi Michael,

To be more precise, I have two open diagrams of different types.
In one of them, I 'direct edit' an element to change its name.
As this element also appears in the other diagram I would expect this 2nd diagram to be updated.
At least, when I click on its tab so that it becomes visible and active.

But DefaultUpdateDiagramFeature gets called only for the diagram I edited.
And nothing seems to trigger the 2nd diagram feature provider getUpdateFeature either.

It's only when I set the mouse on the element that should be updated in the 2nd diagram, that the update mechanism is brought to life.

Where and when is the update actually supposed to be triggered ?

Regards,

Laurent
Re: Auto update not fully working ? [message #1384608 is a reply to message #1384597] Thu, 29 May 2014 13:11 Go to previous messageGo to next message
Laurent Le Moux is currently offline Laurent Le MouxFriend
Messages: 184
Registered: September 2011
Senior Member
Hi again,

Just for test, I declared the following PartListener in my XXGraphitiEditor.init():
@Override
public void partBroughtToTop(IWorkbenchPart part) {
	if (part instanceof XXGraphitiEditor && part.getTitle().equals(getDiagramTypeProvider().getDiagram().getName()))
		XXGraphitiEditor.this.getDiagramTypeProvider().getFeatureProvider()
			.updateIfPossible(new UpdateContext(XXGraphitiEditor.this.getDiagramTypeProvider().getDiagram()));
}


And now the update gets triggered when I click on the 2nd diagram tab.

Laurent
Re: Auto update not fully working ? [message #1384689 is a reply to message #1384597] Fri, 30 May 2014 12:31 Go to previous messageGo to next message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1931
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Laurent,

do you save the diagram after direct editing? Only then can the second
diagram be updated.

The diagram editor checks if there resource changes and in case yes,
triggers the update, see DefaultUpdateBehavior.handleActivate().

Michael
Re: Auto update not fully working ? [message #1384731 is a reply to message #1384689] Fri, 30 May 2014 21:01 Go to previous messageGo to next message
Laurent Le Moux is currently offline Laurent Le MouxFriend
Messages: 184
Registered: September 2011
Senior Member
Hi Michael,

I didn't know the first editor had to be saved to provoke the update of the 2nd one.
But even then, in my case, the 2nd editor is not updated because the two editors are using seperate CDO resources.
So I changed my code to listen to CDO resource commit event so that I could trigger an update when appropriate and it now works fine.

Many thanks,

Laurent
Re: Auto update not fully working ? [message #1385101 is a reply to message #1384731] Wed, 04 June 2014 10:55 Go to previous messageGo to next message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1931
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Hi Laurent,

hm, I'n not familiar with CDO.

In "standard Graphiti" you get a TransactionalEditingDomain/ResourceSet for
each editor, which means each editor has its own copy of the EMF model in
memory. Only after saving the other editing domains will know about changes.

If you want to see the same model state in several editors you might also
share the editing domain between editors. Override the method
createEditingDomain in DefaultUpdateBehavior and return your common domain
there instead of creating a new one. Note that this will also share the
command stack (undo/redo) between the editors.

Michael
Re: Auto update not fully working ? [message #1385336 is a reply to message #1385101] Thu, 05 June 2014 17:17 Go to previous message
Laurent Le Moux is currently offline Laurent Le MouxFriend
Messages: 184
Registered: September 2011
Senior Member
Hi Michael,

The problem with sharing the transactionnal editing domain (TED) and its associated command stack is indeed that the user will be able to perform undos/redos in an editor concerning modifications that took place in another editor...

Moreover, I'm not a specialist either but I don't think the behavior you described applies to CDO. That is : each editor having its own copy of the EMF model in
memory.

In my case, I have a dedicated TED per editor but they all share a single underlying CDO transaction.

Now, considering that it's possible to commit only a part of the transaction and that each editor works on a distinct EMF/CDO resource, when an editor is saved, only the modified elements in its resource are commited.

The other opened editor listen to commit events triggered by CDO and I ask for an update in case their resource has a "external" reference to an element that has been commited by a direct editing and whose display must be refreshed.

Regards,

Laurent
Previous Topic:Problem with EReference
Next Topic:Rotate GraphicsAlgorithm
Goto Forum:
  


Current Time: Fri Mar 29 09:41:58 GMT 2024

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

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

Back to the top