Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » selectionProvider in MultiPageEditor
selectionProvider in MultiPageEditor [message #194394] Thu, 01 September 2005 17:07 Go to next message
Eclipse UserFriend
Originally posted by: gef.oppacher.ca

Hi,

I was having problems with the MultiPageEditorPart and the Gef editors
that I embedded into the MultiPageEditorPart, specifically getting
selection changes. To fix this whenever I
MulitPageEditorPart#setActivePage() is called I set the selection provider
of the MultiPageEditor to be the GraphicalViewer of the newly selected
EditorPart. This all seems to work fine. So I was wondering if I'm
causing, or will cause problems by setting the selectionProvider? The
selectionProvider seems to be null before I set it and runs fine
afterwards. Any comments would be great.

Yandu
Re: selectionProvider in MultiPageEditor [message #194601 is a reply to message #194394] Fri, 02 September 2005 09:15 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: zhaojiangbin.163.com

i think you'd better to install a MultiPageSelectionProvider for a
MultiPageEditorPart in init() method.
consule the sample code bellow:

site.setSelectionProvider(new EditorMultiPageSelectionProvider(this));

and calss definition is:
EditorMultiPage is the MultiPageEditorPart name in my application

private static class EditorMultiPageSelectionProvider extends
MultiPageSelectionProvider {
private ISelection globalSelection;

/**
* @param multiPageEditor
*/
public EditorMultiPageSelectionProvider(EditorMultiPage editorMultiPage)
{
super(editorMultiPage);
}

public ISelection getSelection() {
IEditorPart activeEditor = ((EditorMultiPage) getMultiPageEditor())
.getActiveEditor();
if (activeEditor != null) {
ISelectionProvider selectionProvider = activeEditor.getSite()
.getSelectionProvider();
if (selectionProvider != null)
return selectionProvider.getSelection();
}
return globalSelection;
}

/*
* (non-Javadoc) Method declared on <code> ISelectionProvider </code> .
*/
public void setSelection(ISelection selection) {
IEditorPart activeEditor = ((EditorMultiPage) getMultiPageEditor())
.getActiveEditor();
if (activeEditor != null) {
ISelectionProvider selectionProvider = activeEditor.getSite()
.getSelectionProvider();
if (selectionProvider != null)
selectionProvider.setSelection(selection);
} else {
this.globalSelection = selection;
fireSelectionChanged(new SelectionChangedEvent(this,
globalSelection));
}
}
}




"Yandu" <gef@oppacher.ca> д
Re: selectionProvider in MultiPageEditor [message #194624 is a reply to message #194601] Fri, 02 September 2005 12:12 Go to previous message
Eclipse UserFriend
Originally posted by: mvsteenbergen.eljakim.scratch-this.nl

There already is a org.eclipse.ui.part.MultiPageSelectionProvider which
does this for you. If your multi-page editor extends MultiPageEditorPart
and you call the appropriate methods when adding new GraphicalEditors,
your problem should automagically be taken care of.

M.

zhaojiangbin wrote:
> i think you'd better to install a MultiPageSelectionProvider for a
> MultiPageEditorPart in init() method.
> consule the sample code bellow:
>
> site.setSelectionProvider(new EditorMultiPageSelectionProvider(this));
>
> and calss definition is:
> EditorMultiPage is the MultiPageEditorPart name in my application
>
> private static class EditorMultiPageSelectionProvider extends
> MultiPageSelectionProvider {
> private ISelection globalSelection;
>
> /**
> * @param multiPageEditor
> */
> public EditorMultiPageSelectionProvider(EditorMultiPage editorMultiPage)
> {
> super(editorMultiPage);
> }
>
> public ISelection getSelection() {
> IEditorPart activeEditor = ((EditorMultiPage) getMultiPageEditor())
> .getActiveEditor();
> if (activeEditor != null) {
> ISelectionProvider selectionProvider = activeEditor.getSite()
> .getSelectionProvider();
> if (selectionProvider != null)
> return selectionProvider.getSelection();
> }
> return globalSelection;
> }
>
> /*
> * (non-Javadoc) Method declared on <code> ISelectionProvider </code> .
> */
> public void setSelection(ISelection selection) {
> IEditorPart activeEditor = ((EditorMultiPage) getMultiPageEditor())
> .getActiveEditor();
> if (activeEditor != null) {
> ISelectionProvider selectionProvider = activeEditor.getSite()
> .getSelectionProvider();
> if (selectionProvider != null)
> selectionProvider.setSelection(selection);
> } else {
> this.globalSelection = selection;
> fireSelectionChanged(new SelectionChangedEvent(this,
> globalSelection));
> }
> }
> }
>
>
>
>
> "Yandu" <gef@oppacher.ca> дÈëÏûÏ¢ÐÂÎÅ:d434fd29286e7e94745b887a5148ef04$1@www.eclipse.org...
>
>>Hi,
>>
>>I was having problems with the MultiPageEditorPart and the Gef editors
>>that I embedded into the MultiPageEditorPart, specifically getting
>>selection changes. To fix this whenever I
>>MulitPageEditorPart#setActivePage() is called I set the selection provider
>>of the MultiPageEditor to be the GraphicalViewer of the newly selected
>>EditorPart. This all seems to work fine. So I was wondering if I'm
>>causing, or will cause problems by setting the selectionProvider? The
>>selectionProvider seems to be null before I set it and runs fine
>>afterwards. Any comments would be great.
>>
>>Yandu
>>
>
>
>
Previous Topic:IBM GEF/EMF Redbook
Next Topic:Help with GEF and layouts
Goto Forum:
  


Current Time: Mon Jan 13 11:28:14 GMT 2025

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

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

Back to the top