Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » Reload Editor from different EditorInput for Save As
Reload Editor from different EditorInput for Save As [message #1722714] Mon, 08 February 2016 14:07 Go to next message
Thomas Thonhofer is currently offline Thomas ThonhoferFriend
Messages: 25
Registered: July 2013
Junior Member
Hello

I am trying to implement a "save as" function for my Graphiti editor. It should save the current diagram to a new file and the editor should have the input from the new file as its editorInput. Saving to a new file is not a problem but I don't manage to have the new File open in the editor instead of the old one.

What I do at the moment is this: In the doSaveAs() method of my custom DiagramEditor I first save the diagram to a new file. Then I create a new DiagramEditorInput with the URI from the new file and the provider id from the old editorInput like this:
DiagramEditorInput newInput = new DiagramEditorInput(fileUri, input.getProviderId());

After that i want to reload the editor with the new input. What I tried is:
setInput(newInput); 

But this causes the NullpointerException attached below. Seems like a new ConfigurationProvider is created but the ContextButtonManager is not set.

My question now is: Am I simply doing it wrong, is this a bug or is it just not intended to set a new DiagramEditorInput?

Is there a better way for implementing my "save as" functionality? The workaround would of course be to completely close the editor and reopen it for the new file, but it seems to me that it would be nicer to simply reload the content.

Would be great if someone could point me in the right direction.
Thanks,
Thomas

java.lang.NullPointerException
at org.eclipse.graphiti.ui.internal.parts.ShapeEditPart.activate(ShapeEditPart.java:129)
at org.eclipse.gef.editparts.AbstractEditPart.activate(AbstractEditPart.java:160)
at org.eclipse.gef.editparts.AbstractGraphicalEditPart.activate(AbstractGraphicalEditPart.java:195)
at org.eclipse.graphiti.ui.internal.parts.ShapeEditPart.activate(ShapeEditPart.java:127)
at org.eclipse.gef.editparts.AbstractEditPart.addChild(AbstractEditPart.java:215)
at org.eclipse.gef.editparts.SimpleRootEditPart.setContents(SimpleRootEditPart.java:105)
at org.eclipse.gef.ui.parts.AbstractEditPartViewer.setContents(AbstractEditPartViewer.java:617)
at org.eclipse.gef.ui.parts.AbstractEditPartViewer.setContents(AbstractEditPartViewer.java:626)
at org.eclipse.graphiti.ui.editor.DiagramBehavior.initializeGraphicalViewer(DiagramBehavior.java:600)
at org.eclipse.graphiti.ui.editor.DiagramBehavior.initConfigurationProvider(DiagramBehavior.java:1420)
at org.eclipse.graphiti.ui.editor.DiagramBehavior.setInput(DiagramBehavior.java:385)
at org.eclipse.graphiti.ui.editor.DiagramEditor.setInput(DiagramEditor.java:307)
...



Re: Reload Editor from different EditorInput for Save As [message #1722846 is a reply to message #1722714] Tue, 09 February 2016 14: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
Thomas,

the method setInput() on the editor will only work for initializing newly created editors, it does not support exchanging the input when it was already set.

An option to achive this would maybe be to close the open editor and open a new one using the editor input your created.

HTH,
Michael
Re: Reload Editor from different EditorInput for Save As [message #1722849 is a reply to message #1722846] Tue, 09 February 2016 15:28 Go to previous message
Thomas Thonhofer is currently offline Thomas ThonhoferFriend
Messages: 25
Registered: July 2013
Junior Member
Thanks for your quick reply

I was afraid that this is the case. Would probably be nicer if there was a way to reload the editor, but I guess opening and closing it will do.

Thanks,
Thomas
Previous Topic:Integration of the KIELER Framework
Next Topic:how to re-select connection
Goto Forum:
  


Current Time: Thu Apr 25 23:42:40 GMT 2024

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

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

Back to the top