Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » opening a new diagram editor after closing the current editor
opening a new diagram editor after closing the current editor [message #1710115] Sun, 04 October 2015 14:43 Go to next message
Jack Webber is currently offline Jack WebberFriend
Messages: 5
Registered: October 2015
Junior Member
I subclassed DiagramEditor and overrode init method..I import the xpdl onto the diagram when the user just opens the xpdl with graphiti diagram editor.

I reload the diagram again when the user opens the xpdl again by importing the xpdl in the code.but eclipse opens multiple tabs.I want only one tab to be opened.I use DiagramEditorMatchingStrategy in plugin.xml.It works when I click the .diagram file every time.I want it to work for .xpdl.

So I decided to use workBenchPart.getPage.findEditor(EditorInput) to close the existing editor and open a fresh one.It works but the action tool bar is disabled.No undo, copy, paste or zoom in , zoom out options.But when I click outside the diagram and click back on the diagram the action bar features are enabled.

I overrode selectionChanged method to see if that was the issue.I overrode the method and return nothing still it works the same way.

I tried option 2 .I delete the existing file by searching for the file in workspace and open a fresh diagram by importing the xpdl.Somehow the newly opened editor's hascode is the same as the deleted diagram's hashcode.The same issue of action bar disabled for option 2.

In other words, what i really want is close the current diagram editor and open new diagram editor when the user opens the xpdl.

[Updated on: Tue, 06 October 2015 06:28]

Report message to a moderator

Re: opening a new diagram editor after closing the current editor [message #1710422 is a reply to message #1710115] Tue, 06 October 2015 14:42 Go to previous messageGo to next message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1883
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Jack,

not sure if I git your point...

Do you also have a action bar contributor registered with your editor? It needs to be defined in the contributorClass attribute of your org.eclipse.ui.editors extension. The base class for Graphiti is DiagramEditorActionBarContributor. It is responsible for adding/enabling/disabling actions for tool bar entries.

HTH,
Michael
Re: opening a new diagram editor after closing the current editor [message #1710425 is a reply to message #1710422] Tue, 06 October 2015 15:00 Go to previous messageGo to next message
Jack Webber is currently offline Jack WebberFriend
Messages: 5
Registered: October 2015
Junior Member
yes it is defined in plugin.xml .
contributorClass="org.eclipse.graphiti.ui.editor.DiagramEditorActionBarContributor"
matchingStrategy="org.eclipse.graphiti.ui.editor.DiagramEditorMatchingStrategy"

it works when opening the editor the first time.What i want is when the user double clicks on xpdl ,i need the new values from the xpdl to be imported while opening the editor.So I close the current editor and create a new diagram and import the xpdl .But it seems everytime i close and open a new editor , it is actually opening the existing editor.Is there anything else i have to close? .

this is how i close the editor in the subclassed diagrameditor class .

customeditorInput = (IEditorInput)getDiagramBehavior().getDiagramContainer()
.getDiagramEditorInput();

customEditorInput.close();

I even tried deleting the file by searching for the .diagram file,still it looks like it is opening the same editor.the hashcode of the newly opened editor is same as the deleted editor.

The problem is the zoom,undo toolbar is not enabled in the newly opened editor until i click outside and click back on the editor.
Re: opening a new diagram editor after closing the current editor [message #1710702 is a reply to message #1710425] Thu, 08 October 2015 14:00 Go to previous message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1883
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Jack,

the coding you provided above works on an editor input only (just a lightweight maker that holds information on the editor not the editor itself), not sure what that close method does...

To close an Eclipse editor you need to call something like PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().closeEditor(...) and pass the editor to close (your diagram editor instance).

HTH,
Michael
Previous Topic:translations in babel package/site
Next Topic:How can I draw a cloud using graphiti?
Goto Forum:
  


Current Time: Wed Jan 24 03:47:12 GMT 2018

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

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