[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.tools.emf] Re: Limit Copy, Paste, Cut keyboard shortcuts to EMF tree only (not the entire editor)

Tom,

All that command stuff came long after we'd already done the EMF.Edit support. It's impossible to keep up with the Jone's when there are dozens of them and only two or three of us. Maybe an Eclipse 4.0 effort would allow us to throw away some of the cruft and focus on supporting only the latests and greatest patterns.

I'd be happy to provide hooks for whatever solution works well for this type of scenario. I hope we can find at least a bit of time this release to look at how to support forms and exploit data binding. I'm kind of sick and tired of the limitations of the crummy properties view (which doesn't even work for RAP).


Tom Schindl wrote:
Ed Merks schrieb:
Mircea,

Gosh, I don't have a lot of experience with this type of thing. I hope someone else has some clue, because I won't even know where to begin. Maybe Tom will read this and have an idea...



Tom has read it :-) I'm not really skilled when it comes to all those key-binding thingies.


But the following could work. If your TextWidget receives focus I'd try to reset the copy/cut/paste actions to their original counter parts:

widget.addFocusListener( new FocusListener() {
IAction emfcutaction = actionBars.getGlobalActionHandler(ActionFactory.CUT.getId());
IAction emfcopyaction = actionBars.getGlobalActionHandler(ActionFactory.COPY.getId());
IAction emfpasteaction = actionBars.getGlobalActionHandler(ActionFactory.PASTE.getId());


    IAction standardCut = ActionFactory.CUT.create(....);
    IAction standardCopy = ActionFactory.COPY.create(....);
    IAction standardPaste = ActionFactory.PASTE.create(....);

    public void focusLost(FocusEvent e) {

actionbars.setGlobalActionHandler(ActionFactory.CUT.getId(),emfcutaction);

actionbars.setGlobalActionHandler(ActionFactory.COPY.getId(),emfcopyaction);

actionbars.setGlobalActionHandler(ActionFactory.PASTE.getId(),emfpasteaction);

actionbars.updateActionBars();
    }

public void focusGained(FocusEvent e) {
actionbars.setGlobalActionHandler(ActionFactory.CUT.getId(),standardCut);
actionbars.setGlobalActionHandler(ActionFactory.COPY.getId(),standardCopy);


actionbars.setGlobalActionHandler(ActionFactory.PASTE.getId(),standardPaste);

actionbars.updateActionBars();
    }
});

If this works it would be great if the EditingDomainActionBarContributor would provide a possibility to restore the actions.

Another possible solution that comes to my mind is usage of the commands framework. I don't know if COPY/CUT/PASTE are handled by commands (but Paul knows so I've added eclipse.platform to the CC list :-).

Tom

M. Luchian wrote:
Hello,

The EditingDomainActionBarContributor.java class defined in the EMF plugins overrides the Windows CUT/COPY/PASTE actions' keyboard shortcuts (CTRL-X, CTRL-C, CTRL-V) with EMF's own.

This is correct as long as the actions are performed on the tree. However, I implemented an editor based on eclipse forms, with text widgets (Windows native) handling the COPY CUT PASTE actions with a right click of a mouse. As the mouse actions work fine and interact with the windows' clipboard, pressing the keyboard shortcuts for the same actions in the text widgets will call the actions reserved by EMF .. This is problematic as the CTRL-X, CTRL-C, CTRL-V shortcuts are overridden with the EMF copy, cut, paste actions for the entire editor.

Is there a possible way to register the actions for the editor's tree only? (See picture)



I have a CustomEditingDomainActionBarContributor.java replacing a few small things from the original EditingDomainActionBarContributor.java class, but I don't want to manage the registering / unregistering the copy, cut and paste actions when the tree is in focus or not.

Any help appreciated

Thanks,

Mircea