Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Update the model view after model changes
Update the model view after model changes [message #1731726] Mon, 09 May 2016 14:53 Go to next message
Fy Za is currently offline Fy ZaFriend
Messages: 245
Registered: March 2010
Senior Member
Hi,

I create my emf project with my ecore metamodel (Lets call it mylanguage.ecore) and It works correctly.
In addition, I add an eclipse plugin that contains events can be triggered by clicking on a mylanguage model element.
These events make changes on my models.
After executing each event, the xmi resource of the model is updated immediately. However, the model, opened with mylanguage model editor, takes a moment (several seconds) to be updated with the newest values.

Does exist a way to ameliorate the behavior of this in order to make the model updated immediately?

best regards

FiFi
Re: Update the model view after model changes [message #1731732 is a reply to message #1731726] Mon, 09 May 2016 15:52 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7670
Registered: July 2009
Senior Member
Hi

I suspect that you are doing a round-trip through the file system.

If you use an EditingDomain you should be able to share the ResourceSet
so that no reload is needed.

You should use IResource.refreshLocal to keep Eclipse and the file
system in sync (if you really need the file system to also track promptly).

Regards

Ed Willink

On 09/05/2016 15:53, Fi Fi wrote:
> Hi,
> I create my emf project with my ecore metamodel (Lets call it
> mylanguage.ecore) and It works correctly.
> In addition, I add an eclipse plugin that contains events can be
> triggered by clicking on a mylanguage model element. These events make
> changes on my models.
> After executing each event, the xmi resource of the model is updated
> immediately. However, the model, opened with mylanguage model editor,
> takes a moment (several seconds) to be updated with the newest values.
>
> Does exist a way to ameliorate the behavior of this in order to make
> the model updated immediately?
>
> best regards
>
> FiFi
Re: Update the model view after model changes [message #1733453 is a reply to message #1731732] Fri, 27 May 2016 16:16 Go to previous message
Fy Za is currently offline Fy ZaFriend
Messages: 245
Registered: March 2010
Senior Member
Hi Ed,
Thank you for ur reply.
I add the IResource.refreshLocal juste after saving my resource (see below).
However, the model is still updated after a moment (several seconds) and the issue isn't resolved.

any suggestions ?


	public static void saveResource(Resource resource) {
		try {
			resource.save(Collections.EMPTY_MAP);
		} catch (IOException e) {
			e.printStackTrace();
		}
		//Added code
		URI resolvedFile = CommonPlugin.resolve(resource.getURI());
		IResource dfile = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(resolvedFile.toFileString()));
		try {
			dfile.refreshLocal(IResource.DEPTH_INFINITE, null);
		} catch (CoreException e) {
			e.printStackTrace();
		}
	}
Previous Topic:How to retrieve State Machines from the Model object?
Next Topic:[CDO] CDOQuery returns very rarely no object although it exists
Goto Forum:
  


Current Time: Fri Sep 20 09:55:41 GMT 2024

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

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

Back to the top