[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[news.eclipse.tools.gef] Re: implementing cut/copy/paste

The registry should hold onto actions maintained by the Editor instance.
RetargetActions should only be created by the ActionBarContributor, not each
editor instance.

The purpose of retarget actions is to map a single ActionBarContributor to
multiple editor instances within a given WorkbenchWindow.  I think actionbar
contributors were designed as 1-per-window-per-editor-type to reduce flicker
and repainting when changing between multiple java CU editors.  It also
reduces the number of native widgets created.

"Jesper Eskilson" <jojo@xxxxxxxxxxxx> wrote in message
news:cohec2$bf8$1@xxxxxxxxxxxxxxxxxx
> Jesper Eskilson wrote:
> > "CL [dnoyeb] Gilbert" <Lamont_Gilbert@xxxxxxxxxxxxxxxxx> writes:
> >
> >
> >>getSelectedObjects should never return the empty list.
> >
> >
> > Well, it does.
> >
> > After some investigation, it appears that CopyAction's update() method
is
> > never called, and thus the selection field is never set. I wonder why.
> >
> > I'll keep investigating.
> >
>
> What seems to happen is this: when selectionChanged (in the
> GraphicalEditor class) calls updateAction() on all selection-actions,
> only the retarget-version of the action gets called -- they have the
> same ID, so the action-registry can only hold one of them:
>
> protected void updateActions(List actionIds)
> {
> ActionRegistry registry = getActionRegistry();
> Iterator iter = actionIds.iterator();
> while (iter.hasNext()) {
> IAction action = registry.getAction(iter.next());
> if (action instanceof UpdateAction)
> ((UpdateAction)action).update();
> }
> }
>
> The parameter actionIds is here [ 'delete', 'copy' ] when called from
> selectionChanged, and registry.getAction() returns a RetargetAction(),
> not my CopyAction.
>
> So, something is wrong in my action-registry. Pratik said that I should
> create both retarget-actions and "normal" actions with the same ID, but
> then they can't reside in the same action-registry. Or did I miss
something?
>
> /Jesper