Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Editor having a child editor(How to manage the lifecycle of an editor spawned by another editor ?)
Editor having a child editor [message #491580] Thu, 15 October 2009 07:29 Go to next message
Cedric Moonen is currently offline Cedric MoonenFriend
Messages: 274
Registered: August 2009
Senior Member
Hello,

I have an editor, which is a multipage editor for which one page is a form. On this form, there's a button to edit a specific part of the data the editor is displaying. When pressing that button, the data to be edited is opened in a separate editor (for convenience). Thus, this second editor is in fact linked to the first editor and its lifecycle should be partially managed by the parent editor. The child editor is in fact a graphical editor.

What I want is that:
- When the parent editor is closed, the child editor is closed too.
- When that happens, if there are unsaved modifications in the child editor, a message should be displayed to the user asking to save the data BEFORE the parent editor is closed
- The child editor can be closed independently of the parent editor without afecting it.
- When the child editor is saved, the parent editor should be warned and adapt itself (the data from the graphical editor is converted to a string and displayed on the main editor).

I partially managed to reach that solution but it is not fully satisfactory. Waht I did was this:
When I click on the button, I create my own editor input which contains information about the data to open (the file) and a listener for changes (which is in fact the parent editor). Whenever the child editor is saved, it calls the listener changed method and passes the data to it.
I then add a PartListener on my editor and implement the partClosed method to be notified when my parent editor is called and then forwarding it to the part responsible for closing the child editor.

The biggest problem is when closing the parent editor: I should be warned before the editor is closed instead of after because I would like for instance to veto the close of the editor when there are changes in the child editor and userr select cancel when being asked about to save or not the unsaved changes.

I was wondering if there's some kind of built-in mechanism that allows to link an editor to another one. This looks like a quite useful feature.
Could somebody help me here ?

Thanks
Cédric
Re: Editor having a child editor [message #491718 is a reply to message #491580] Thu, 15 October 2009 14:47 Go to previous message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

The short answer is no ... at one time we had hoped to change the paradigm for MultiPageEditorPart to be a "working together" paradigm instead of containment (Eclipse 3.x doesn't support nested parts very well).

One option in 3.5 is to open the editor in your already open MultiPageEditorPart ... simply call org.eclipse.ui.part.MultiPageEditorPart.addPage(IEditorPart, IEditorInput)

PW


Previous Topic:How to set icon for progress job's group?
Next Topic:Force Toolbar of a view to 2nd row
Goto Forum:
  


Current Time: Tue Apr 23 08:05:33 GMT 2024

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

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

Back to the top