Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc) » How to detect Ctrl-Z in eclipse for the EcoreDiagramEditor
How to detect Ctrl-Z in eclipse for the EcoreDiagramEditor [message #1413498] |
Thu, 28 August 2014 17:27 |
ping cin Messages: 13 Registered: February 2014 |
Junior Member |
|
|
Hello everyone,
I would like to be able to detect a Ctrl-Z event in the EcoreDiagramEditor while modeling with ecore tool (.ecorediag).
While the user is modeling an ecore metamodel in eclipse, I have a plugin, in which I am constructing in parallel another representation of the (on going) metamodel. Thus, I need to detect Ctrl-Z, to also apply it on my other parallel representation.
For example, if I delete an attribute, and then I cancel its effect with a Ctrl-Z, I would also like to cancel it in my other parallel representation.
I tried to add a filter to my plugin container (like below), but it does not work well (at least not for Ctrl-Z).
container.getDisplay().addFilter(SWT.KeyDown, new Listener(){
public void handleEvent(Event e){
System.out.println("3333");
System.out.println("Filter-ctrl: " + SWT.CTRL);
System.out.println("Filter-mask: " + e.stateMask);
System.out.println("Filter-char: " + e.character);
System.out.println("Filter-char: " + e.keyCode);
}
});
For example, I can detect Ctrl-f, but not Ctrl-Z. Could anyone help me out here?
Thank you in advance for your time and answer.
Best Regads.
|
|
|
Re: How to detect Ctrl-Z in eclipse for the EcoreDiagramEditor [message #1413531 is a reply to message #1413498] |
Thu, 28 August 2014 19:38 |
|
Hi,
If your plug-in is listening to changes in the Ecore diagram editor
using Adapters of some kind, responding to Notifications by updating
your parallel representation, then it doesn't matter whether changes
are occurring because the user undid some action via Ctrl+Z. Your
plug-in will simply see Notifications indicating the inverse changes
and can update the parallel representation accordingly.
In any, you really don't want to intercept Ctrl+Z literally in this way
because the user's Eclipse instance may map some other keystroke to the
Undo command. Besides that on Mac platform the default binding is
different anyways, being Cmd+Z, not Ctrl+Z.
So, I think the real question is how is your plug-in observing changes
in the Ecore model and why should it make any difference whether they
occur because of some command executing versus being undone?
Cheers,
Christian
On 2014-08-28 17:27:06 +0000, ping cin said:
> Hello everyone,
>
> I would like to be able to detect a Ctrl-Z event in the
> EcoreDiagramEditor while modeling with ecore tool (.ecorediag).
>
> While the user is modeling an ecore metamodel in eclipse, I have a
> plugin, in which I am constructing in parallel another representation
> of the (on going) metamodel. Thus, I need to detect Ctrl-Z, to also
> apply it on my other parallel representation.
>
> For example, if I delete an attribute, and then I cancel its effect
> with a Ctrl-Z, I would also like to cancel it in my other parallel
> representation.
>
> I tried to add a filter to my plugin container (like below), but it
> does not work well (at least not for Ctrl-Z).
>
> container.getDisplay().addFilter(SWT.KeyDown, new Listener(){
> public void handleEvent(Event e){
> System.out.println("3333");
> System.out.println("Filter-ctrl: " + SWT.CTRL);
> System.out.println("Filter-mask: " + e.stateMask);
> System.out.println("Filter-char: " + e.character);
> System.out.println("Filter-char: " + e.keyCode);
> }
> });
>
> For example, I can detect Ctrl-f, but not Ctrl-Z. Could anyone help me
> out here?
>
> Thank you in advance for your time and answer.
>
> Best Regads.
|
|
| |
Goto Forum:
Current Time: Thu Apr 25 12:04:30 GMT 2024
Powered by FUDForum. Page generated in 0.02801 seconds
|