Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[gef-dev] Multipage editor support

> GraphicalEditor is designed to be an Editor, not a page of a multipage 
> editor.  Your actions are never enabled because selectionChanged() on 
> GraphicalEditor will never do anything.  It doesn't see itself as the 
> active editor.  Disabled actions don't get added to the context menu 
> generally.

I put a little time into looking for a workaround here (assuming that re-implementing GraphicalEditor is not an option).  If you are using MultiPageEditorPart and adding a GraphicalEditor to it, you can override selectionChanged like this:

public void selectionChanged(IWorkbenchPart part, ISelection selection) {
    IEditorPart activeEditor = getSite().getPage().getActiveEditor();
        
    //      If not the active editor, ignore selection changed.
    if (this.equals(activeEditor)
        || ((_parentEditor != null) && _parentEditor.equals(activeEditor) && _parentEditor.getActiveEditor()==this)
            )
        {
            updateActions(getSelectionActions());
        }
    }
}

This all turns on _parentEditor being a reference to your containing multipage editor.  It seems to work.  So far as I can tell, this won't cause any side-effects, someone correct me if I'm wrong.


Regards,

Cameron


Back to the top