Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Delete EditPart/Figure
Delete EditPart/Figure [message #161102] Thu, 09 December 2004 14:50 Go to next message
Eclipse UserFriend
Originally posted by: seb01016.fh-hagenberg.at

Hi!

I have got following question: Which steps are needed to make it possible
to delete an EditPart by pressing the DEL button?

I have an Editor, that extends GraphicalEditorWithPalette. I implemented
following method:

protected KeyHandler getSharedKeyHandler(){
if (sharedKeyHandler == null){
sharedKeyHandler = new KeyHandler();
// configure common keys for all viewers
sharedKeyHandler.put(KeyStroke.getPressed(SWT.DEL, 127, 0),

getActionRegistry().getAction(ActionFactory.DELETE.getId())) ;
}
return sharedKeyHandler;
}

Afterwards I added following statement in the configureGraphicalViewer()
Method
....
viewer.setKeyHandler(this.getSharedKeyHandler());
....

Next I have my own ComponentEditPolicy where I implemented the protected
Command createDeleteCommand(GroupRequest deleteRequest) method.

But if I press the del button nothing happens. Could somebody please tell
me, what i have forgotten or what I did wrong!

thx in advance
Hannes
Re: Delete EditPart/Figure [message #161134 is a reply to message #161102] Thu, 09 December 2004 15:33 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

It sounds like the workbench's global delete action is stealing this
keybinding, causing the Canvas to not receive the keypressed event. This is
new behavior in 3.0 I believe.

"Schoenboeck" <seb01016@fh-hagenberg.at> wrote in message
news:cp9oob$d07$1@www.eclipse.org...
> Hi!
>
> I have got following question: Which steps are needed to make it possible
> to delete an EditPart by pressing the DEL button?
>
> I have an Editor, that extends GraphicalEditorWithPalette. I implemented
> following method:
>
> protected KeyHandler getSharedKeyHandler(){
> if (sharedKeyHandler == null){
> sharedKeyHandler = new KeyHandler();
> // configure common keys for all viewers
> sharedKeyHandler.put(KeyStroke.getPressed(SWT.DEL, 127, 0),
>
> getActionRegistry().getAction(ActionFactory.DELETE.getId())) ;
> }
> return sharedKeyHandler;
> }
>
> Afterwards I added following statement in the configureGraphicalViewer()
> Method
> ...
> viewer.setKeyHandler(this.getSharedKeyHandler());
> ...
>
> Next I have my own ComponentEditPolicy where I implemented the protected
> Command createDeleteCommand(GroupRequest deleteRequest) method.
>
> But if I press the del button nothing happens. Could somebody please tell
> me, what i have forgotten or what I did wrong!
>
> thx in advance
> Hannes
>
>
>
Re: Delete EditPart/Figure [message #161215 is a reply to message #161134] Fri, 10 December 2004 09:53 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: seb01016.fh-hagenberg.at

You are right, I am using Eclipse 3.0 but I have a sample application
where the "Delete Process" works fine, but I can not find a big difference
to my project.

I tried to implement the keyPressed method of my key handler. Within this
method I can catch the DEL event. Therefore I thought of deleting the
EditPart manually, but I dont know how? Is this a possibility to do this???

viewer.setKeyHandler(new GraphicalViewerKeyHandler(viewer){
public boolean keyPressed(KeyEvent ev){
if(ev.getKeyCode()==SWT.DEL){
System.out.println("del event occured");
//how can i delete edit part here???
}
return true;
}
});

Furthermore I tried to add the delete Action to my Context menue. But this
does not work too, although undo and redo actions work fine.

public void buildContextMenu(IMenuManager menuManager){
GEFActionConstants.addStandardActionGroups(menuManager);
appendActionToUndoGroup(menuManager, ActionFactory.UNDO.getId());
appendActionToUndoGroup(menuManager, ActionFactory.REDO.getId());
appendActionToEditGroup(menuManager, ActionFactory.DELETE.getId());
}

I'm a little bit confused now and I don't know how can a implement the
Delete stuff.

thanks Hannes



Randy Hudson wrote:

> It sounds like the workbench's global delete action is stealing this
> keybinding, causing the Canvas to not receive the keypressed event. This is
> new behavior in 3.0 I believe.

> "Schoenboeck" <seb01016@fh-hagenberg.at> wrote in message
> news:cp9oob$d07$1@www.eclipse.org...
>> Hi!
>>
>> I have got following question: Which steps are needed to make it possible
>> to delete an EditPart by pressing the DEL button?
>>
>> I have an Editor, that extends GraphicalEditorWithPalette. I implemented
>> following method:
>>
>> protected KeyHandler getSharedKeyHandler(){
>> if (sharedKeyHandler == null){
>> sharedKeyHandler = new KeyHandler();
>> // configure common keys for all viewers
>> sharedKeyHandler.put(KeyStroke.getPressed(SWT.DEL, 127, 0),
>>
>> getActionRegistry().getAction(ActionFactory.DELETE.getId())) ;
>> }
>> return sharedKeyHandler;
>> }
>>
>> Afterwards I added following statement in the configureGraphicalViewer()
>> Method
>> ...
>> viewer.setKeyHandler(this.getSharedKeyHandler());
>> ...
>>
>> Next I have my own ComponentEditPolicy where I implemented the protected
>> Command createDeleteCommand(GroupRequest deleteRequest) method.
>>
>> But if I press the del button nothing happens. Could somebody please tell
>> me, what i have forgotten or what I did wrong!
>>
>> thx in advance
>> Hannes
>>
>>
>>
Re: Delete EditPart/Figure [message #161339 is a reply to message #161215] Mon, 13 December 2004 15:08 Go to previous message
Eclipse UserFriend
Originally posted by: seb01016.fh-hagenberg.at

I solved the problem. I have forgotten to implement the selection
listener. Now everything works fine.

Thx
Hannes

Schoenboeck wrote:

> You are right, I am using Eclipse 3.0 but I have a sample application
> where the "Delete Process" works fine, but I can not find a big difference
> to my project.

> I tried to implement the keyPressed method of my key handler. Within this
> method I can catch the DEL event. Therefore I thought of deleting the
> EditPart manually, but I dont know how? Is this a possibility to do this???

> viewer.setKeyHandler(new GraphicalViewerKeyHandler(viewer){
> public boolean keyPressed(KeyEvent ev){
> if(ev.getKeyCode()==SWT.DEL){
> System.out.println("del event occured");
> //how can i delete edit part here???
> }
> return true;
> }
> });

> Furthermore I tried to add the delete Action to my Context menue. But this
> does not work too, although undo and redo actions work fine.

> public void buildContextMenu(IMenuManager menuManager){
> GEFActionConstants.addStandardActionGroups(menuManager);
> appendActionToUndoGroup(menuManager, ActionFactory.UNDO.getId());
> appendActionToUndoGroup(menuManager, ActionFactory.REDO.getId());
> appendActionToEditGroup(menuManager, ActionFactory.DELETE.getId());
> }

> I'm a little bit confused now and I don't know how can a implement the
> Delete stuff.

> thanks Hannes



> Randy Hudson wrote:

>> It sounds like the workbench's global delete action is stealing this
>> keybinding, causing the Canvas to not receive the keypressed event. This is
>> new behavior in 3.0 I believe.

>> "Schoenboeck" <seb01016@fh-hagenberg.at> wrote in message
>> news:cp9oob$d07$1@www.eclipse.org...
>>> Hi!
>>>
>>> I have got following question: Which steps are needed to make it possible
>>> to delete an EditPart by pressing the DEL button?
>>>
>>> I have an Editor, that extends GraphicalEditorWithPalette. I implemented
>>> following method:
>>>
>>> protected KeyHandler getSharedKeyHandler(){
>>> if (sharedKeyHandler == null){
>>> sharedKeyHandler = new KeyHandler();
>>> // configure common keys for all viewers
>>> sharedKeyHandler.put(KeyStroke.getPressed(SWT.DEL, 127, 0),
>>>
>>> getActionRegistry().getAction(ActionFactory.DELETE.getId())) ;
>>> }
>>> return sharedKeyHandler;
>>> }
>>>
>>> Afterwards I added following statement in the configureGraphicalViewer()
>>> Method
>>> ...
>>> viewer.setKeyHandler(this.getSharedKeyHandler());
>>> ...
>>>
>>> Next I have my own ComponentEditPolicy where I implemented the protected
>>> Command createDeleteCommand(GroupRequest deleteRequest) method.
>>>
>>> But if I press the del button nothing happens. Could somebody please tell
>>> me, what i have forgotten or what I did wrong!
>>>
>>> thx in advance
>>> Hannes
>>>
>>>
>>>
Previous Topic:Problem with picture using plugin
Next Topic:palette-model-figure
Goto Forum:
  


Current Time: Sun Sep 22 23:28:36 GMT 2024

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

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

Back to the top