Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Papyrus » How to reload a Papyrus model?
How to reload a Papyrus model? [message #1220046] Mon, 09 December 2013 10:56 Go to next message
Maria Schneider is currently offline Maria SchneiderFriend
Messages: 3
Registered: December 2013
Junior Member
Hi,

I modify the files ".notation", ".uml" and ".di" of an open Papyrus model with an EOL-script (Epsilon Object Language) which is executed by a command in the context menu. The script creates a new diagram and adds it to the available pages and current selection in the di-file.

If I close and open the model again, everything is fine. But I want to reload the model/resources programmatically while the model stays open. Is there any way to do this?
Re: How to reload a Papyrus model? [message #1220366 is a reply to message #1220046] Wed, 11 December 2013 10:47 Go to previous messageGo to next message
Ansgar Radermacher is currently offline Ansgar RadermacherFriend
Messages: 266
Registered: March 2011
Location: Paris Saclay, France
Senior Member
Hi Maria,

if you modify the .di/.notation/.uml files, the editor will detect the resource change and re-open the file (in older versions of Papyrus, this detection is only done if you change from another editor to the one with the modified diagram). There is currently no way to see changes made on the files without re-opening the editor.

An alternative is to create a diagram programmatically by directly modifying the loaded Papyrus model. In this case, changes are immediately visible. You can find an example here
http://wiki.eclipse.org/Papyrus_Developer_Guide/CreateProgrammatically

[Updated on: Wed, 11 December 2013 10:54]

Report message to a moderator

Re: How to reload a Papyrus model? [message #1220383 is a reply to message #1220366] Wed, 11 December 2013 12:06 Go to previous messageGo to next message
Maria Schneider is currently offline Maria SchneiderFriend
Messages: 3
Registered: December 2013
Junior Member
Hi Ansgar,

thanks for your answer Smile Unfortunately the editor doesn't detect the change (even if I change from another editor back to the modified). Is it possible to initiate this mechanism (re-opening the file/editor) from source code? If there is no way of reloading the editor without reopening it then it would be at least nice to re-open it automatically Wink
Re: How to reload a Papyrus model? [message #1220915 is a reply to message #1220383] Mon, 16 December 2013 07:24 Go to previous message
Maria Schneider is currently offline Maria SchneiderFriend
Messages: 3
Registered: December 2013
Junior Member
So, I found the position in the source code where the editor is reopened Smile For those who are interested:

final IMultiDiagramEditor editor = EditorUtils.getMultiDiagramEditor(); 
Display.getCurrent().asyncExec(new Runnable() {
	public void run() {
		IWorkbench wb = PlatformUI.getWorkbench();
		IWorkbenchPage page = wb.getActiveWorkbenchWindow().getActivePage();
		IEditorInput input = editor.getEditorInput();
		page.closeEditor(editor, false);
		try {
			IEditorDescriptor desc = wb.getEditorRegistry().getDefaultEditor(input.getName());
			page.openEditor(input, desc.getId(), false);
		} catch (PartInitException e) {
			e.printStackTrace();
		}
	}
});


Copied from the PartActivationListener.java (org.eclipse.papyrus.uml.diagram.common.resourceupdate)
Previous Topic:[Solved:] How to apply Papyrus-Preferences to existing Diagram?
Next Topic:Create UML diagram programmatically without any UI
Goto Forum:
  


Current Time: Sat Dec 05 00:25:21 GMT 2020

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

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

Back to the top