Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » delete an editPart
delete an editPart [message #139679] Wed, 23 June 2004 14:56 Go to next message
Eclipse UserFriend
Originally posted by: jerome.lafon.bull.net

Hi,
is somebody knows how to delete an editpart in a graphicalViewer?
I have write:

viewer.setKeyHandler(new GraphicalViewerKeyHandler(viewer)
.setParent(getCommonKeyHandler()));

protected KeyHandler getCommonKeyHandler() {
if (sharedKeyHandler == null) {
sharedKeyHandler = new KeyHandler();
sharedKeyHandler.put(
KeyStroke.getPressed(SWT.DEL, 127, 0),
getActionRegistry().getAction(GEFActionConstants.DELETE));
}
return sharedKeyHandler;
}

but it doesn't work!
thanks
Re: delete an editPart [message #139701 is a reply to message #139679] Wed, 23 June 2004 16:26 Go to previous messageGo to next message
Pratik Shah is currently offline Pratik ShahFriend
Messages: 1077
Registered: July 2009
Senior Member
I am not sure why it doesn't work. You should be able to figure it out
relatively easily by setting a breakpoint in performStroke() method (or
keyPressed() if it never makes it to performStroke()). Have you verified
that a proper action is registered in the ActionRegistry?

Another way you could work this is by doing something like this:

viewer.setKeyHandler(new GraphicalViewerKeyHandler(viewer) {
public boolean keyPressed(KeyEvent event) {
if (event.keyCode == SWT.DEL) {
// do delete
}
}
});

However, I am interested to know why your current implementation doesn't
work.


"jerome lafon" <jerome.lafon@bull.net> wrote in message
news:40D99A08.A2085FA3@bull.net...
> Hi,
> is somebody knows how to delete an editpart in a graphicalViewer?
> I have write:
>
> viewer.setKeyHandler(new GraphicalViewerKeyHandler(viewer)
> .setParent(getCommonKeyHandler()));
>
> protected KeyHandler getCommonKeyHandler() {
> if (sharedKeyHandler == null) {
> sharedKeyHandler = new KeyHandler();
> sharedKeyHandler.put(
> KeyStroke.getPressed(SWT.DEL, 127, 0),
> getActionRegistry().getAction(GEFActionConstants.DELETE));
> }
> return sharedKeyHandler;
> }
>
> but it doesn't work!
> thanks
>
Re: delete an editPart [message #139896 is a reply to message #139679] Thu, 24 June 2004 19:46 Go to previous message
Eclipse UserFriend
Originally posted by: rlemaigr.ulb.ac.be

Hello,

The result of the execution of the GEFActionConstants.DELETE action is =

only to send a req_delete to the selected EditParts, nothing more.

So to get it working, you have to install on the EditParts EditPolicies =
=

able to understand the req_delete requests and to return delete Commands=
=

which will delete the model objects of the selected EditParts. And if th=
e =

parent EditParts of the "almost deleted EditParts" listen correctly to =

their model, they will catch the event signaling the deletion, and they =
=

will call refreshChildren on themselves and the EditParts and their =

figures will be deleted.

If you already knew that and if you find my answer to be obvious, then I=
=

am sorry.

I hope it will help you !

r=E9gis


On Wed, 23 Jun 2004 16:56:09 +0200, jerome lafon <jerome.lafon@bull.net>=
=

wrote:

> Hi,
> is somebody knows how to delete an editpart in a graphicalViewer?
> I have write:
>
> viewer.setKeyHandler(new GraphicalViewerKeyHandler(viewer)
> .setParent(getCommonKeyHandler()));
>
> protected KeyHandler getCommonKeyHandler() {
> if (sharedKeyHandler =3D=3D null) {
> sharedKeyHandler =3D new KeyHandler();
> sharedKeyHandler.put(
> KeyStroke.getPressed(SWT.DEL, 127, 0),
> getActionRegistry().getAction(GEFActionConstants.DELETE));
> }
> return sharedKeyHandler;
> }
>
> but it doesn't work!
> thanks
>



-- =

Using Opera's revolutionary e-mail client: http://www.opera.com/m2/
Previous Topic:plugin Absoulate path
Next Topic:rededifing key function in eclipse
Goto Forum:
  


Current Time: Mon May 13 16:42:48 GMT 2024

Powered by FUDForum. Page generated in 0.07130 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top