Opening a MultiPageEditorPart on a specific page [message #689456] |
Mon, 27 June 2011 12:49  |
Eclipse User |
|
|
|
Hello,
I am trying to open a multi page editor part on a specific page depending on a IEditorInput.
Actually, I think this is the exact same thing which is done by the PDE editor, when opening a build.properties file opens the PDE editor on the build page and opening a MANIFEST.MF opens the exact same editor and focuses on the overview page.
In my situation, I have several elements from a navigator (a custom navigator, not resource-based). These elements need to be opened in the exact same editor but corresponds to different page of this editor.
I would like the following behaviour :
* Opening element A opens the editor my.editor.id on element A page 1
* Opening element B, child of A, opens the editor my.editor.id on on element A page 2. If editor is already open on element A, it simply focus on page 2
Do I need to implement everything manually ? That is to say opening the editor, checking whether it is a MultiPageEditorPart, if so I could cast and find the corresponding editor manually.
Thank you for your help & time,
Christophe
http://www.nextep-softwares.com
|
|
|
Re: Opening a MultiPageEditorPart on a specific page [message #693749 is a reply to message #689456] |
Thu, 07 July 2011 02:54  |
Eclipse User |
|
|
|
For anyone interested, I managed to implement this properly using features provided by the FormEditor (rather than MultiPageEditor aspect) :
try {
final IEditorPart editor = activePage.openEditor(getEditorInput(model), getEditorId());
if (editor instanceof FormEditor) {
final FormEditor formEditor = (FormEditor) editor;
formEditor.setActivePage(IUIService.PAGE_ID_PREFIX + model.getType().getId(), model);
}
} catch (PartInitException e) {
throw new ErrorException(e);
}
The idea here is to be able to build the page identifier of the editor from the input you have (here, the model object) and to invoke the setActivePage(pageId, formInput) method. Then, your IFormPart need to be responsive to the setFormInput to implement viewer selection of the given input.
The result is that the editor will open, appropriate page will be focused and selection will be made in the page's viewer (for example a master / details block).
Hope this could help anyone,
Christophe
http://www.nextep-softwares.com
|
|
|
Powered by
FUDForum. Page generated in 0.03839 seconds