Hello Tom,
Thank you for the focus listener solution. I added the listeners on
every text widget that accepts a copy, paste, cut command set. The EMF
actions are disabled successfully while the focus is in the text
widgets and enabled when the focus goes out. However, the keyboard
shortcuts for the normal cut, paste, copy actions are not properly
initialized. Pressing CTRL-X, CTRL-C or CTRL-V does nothing while the
focus is in one of these widgets.
Would it be possible that I pass the wrong workbench window to these
three actions? Here is how I initialized them below:
IAction standardCut =
ActionFactory.CUT.create(editor.getEditorSite().getWorkbenchWindow());
IAction standardCopy =
ActionFactory.COPY.create(editor.getEditorSite().getWorkbenchWindow());
IAction standardPaste =
ActionFactory.PASTE.create(editor.getEditorSite().getWorkbenchWindow());
Thanks,
Mircea
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
|