Home » Eclipse Projects » GEF » how to delete an edit part
how to delete an edit part [message #140022] |
Fri, 25 June 2004 08:46  |
Eclipse User |
|
|
|
Originally posted by: jerome.lafon.bull.net
Hi,
I want to know if Somedody can explain me how to catch a keyboard
event, like del key pressed and assign a method to his event ?
Actually I have:
a GraphicalEditorWithPalette, with a KeyHandler, a method with
sharedKeyHandler.put( KeyStroke.getPressed(SWT.DEL, 127, 0),
getActionRegistry().getAction(ActionFactory.DELETE.getId())) ;
and a method createActions((IWorkbenchPart)this) {
action = new DeleteAction((IWorkbenchPart)this);
registry.registerAction(action);
getSelectionActions().add(action.getId());
}
The topEditPart with a LAYOUT_ROLE and a CONTAINER_ROLE
I have an editpart with a COMPONENT_ROLE edit policy, this policy
implements createDeleteCommand(GroupRequest deleteRequest).
With this state, I can't delete an editpart.
I am not sure to understand how it should work. When I register the
DeleteAction in the ActionRegistry, GEF automatically call
createDeleteCommand() ?
Thanks
Jerome Lafon
|
|
|
Re: how to delete an edit part [message #140043 is a reply to message #140022] |
Fri, 25 June 2004 09:59   |
Eclipse User |
|
|
|
Originally posted by: rlemaigr.ulb.ac.be
hello,
I don't precisely know the answer to your question but I will try to hel=
p.
First, you don't have to worry about adding the delete action to the =
action registry in the createAction method because the =
GEFActionConstants.DELETE is already added by default (undo and redo =
actions as well) to the action registry in the GraphicalEditor super =
class. You can get this action by calling =
getActionRegistry().getAction(GEFActionConstants.DELETE).
Maybe that was the problem ?
Then your configureGraphicalViewer method should look like that:
protected void configureGraphicalViewer()
{
...
//keyhandler:
KeyHandler keyHandler =3D new KeyHandler();
keyHandler.put(KeyStroke.getPressed(SWT.DEL, 127, 0), =
getActionRegistry().getAction(GEFActionConstants.DELETE));
getGraphicalViewer().setKeyHandler(new =
GraphicalViewerKeyHandler(getGraphicalViewer()).setParent(ke yHandler));/=
/I =
am not sure
//about this line...I have written this a month ago...but I am sure it=
=
worked.
}
Does it solve your problem ?
If it has not, instead of catching key strokes to do the delete, you cou=
ld =
first try to contribute to the delete retargetable action of the workben=
ch =
(the one that gets executed when you select delete in the global menu ; =
if =
you don't know what retargetable actions are, the eclipse help explains =
=
that very well). If it works that way, then you will be sure the problem=
=
comes from the way you handle key events.
You just have to redefine the createPartControl method in the editor par=
t =
like that:
public void createPartControl(Composite parent)
{
super.createPartControl(parent);
getEditorSite().getActionBars().setGlobalActionHandler(
IWorkbenchActionConstants.DELETE,
getActionRegistry().getAction(GEFActionConstants.DELETE));
}
and now, when you select delete in the eclipse global menu when your =
editor is active, the method getCommand(Request) will be called on the =
selected EditParts of your Editor with a req_delete GroupRequest as =
parameter. This call will be forwarded to the EditPolicies and to your =
ComponentEditPolicy which should return the delete command.
hope this will help,
r=E9gis
On Fri, 25 Jun 2004 14:46:42 +0200, jerome lafon <jerome.lafon@bull.net>=
=
wrote:
> Hi,
> I want to know if Somedody can explain me how to catch a keyboard
> event, like del key pressed and assign a method to his event ?
> Actually I have:
>
> a GraphicalEditorWithPalette, with a KeyHandler, a method with
> sharedKeyHandler.put( KeyStroke.getPressed(SWT.DEL, 127, 0),
> getActionRegistry().getAction(ActionFactory.DELETE.getId())) ;
>
> and a method createActions((IWorkbenchPart)this) {
> action =3D new DeleteAction((IWorkbenchPart)this);
> registry.registerAction(action);
> getSelectionActions().add(action.getId());
> }
>
> The topEditPart with a LAYOUT_ROLE and a CONTAINER_ROLE
>
> I have an editpart with a COMPONENT_ROLE edit policy, this policy
> implements createDeleteCommand(GroupRequest deleteRequest).
>
> With this state, I can't delete an editpart.
> I am not sure to understand how it should work. When I register the
> DeleteAction in the ActionRegistry, GEF automatically call
> createDeleteCommand() ?
>
> Thanks
> Jerome Lafon
>
>
-- =
Using Opera's revolutionary e-mail client: http://www.opera.com/m2/
|
|
|
Re: how to delete an edit part [message #140095 is a reply to message #140022] |
Fri, 25 June 2004 10:27   |
Eclipse User |
|
|
|
Originally posted by: none.us.ibm.com
Delete is a global action defined by the workbench. You might need to
register a global action handler. Delete is working in the Logic example so
maybe you can check out that code. Some things have changed a little in the
Eclipse platform regarding Delete.
"jerome lafon" <jerome.lafon@bull.net> wrote in message
news:40DC1EB2.4CB193BF@bull.net...
> Hi,
> I want to know if Somedody can explain me how to catch a keyboard
> event, like del key pressed and assign a method to his event ?
> Actually I have:
>
> a GraphicalEditorWithPalette, with a KeyHandler, a method with
> sharedKeyHandler.put( KeyStroke.getPressed(SWT.DEL, 127, 0),
> getActionRegistry().getAction(ActionFactory.DELETE.getId())) ;
>
> and a method createActions((IWorkbenchPart)this) {
> action = new DeleteAction((IWorkbenchPart)this);
> registry.registerAction(action);
> getSelectionActions().add(action.getId());
> }
>
> The topEditPart with a LAYOUT_ROLE and a CONTAINER_ROLE
>
> I have an editpart with a COMPONENT_ROLE edit policy, this policy
> implements createDeleteCommand(GroupRequest deleteRequest).
>
> With this state, I can't delete an editpart.
> I am not sure to understand how it should work. When I register the
> DeleteAction in the ActionRegistry, GEF automatically call
> createDeleteCommand() ?
>
> Thanks
> Jerome Lafon
>
>
|
|
|
Re: how to delete an edit part [message #140105 is a reply to message #140095] |
Fri, 25 June 2004 10:35   |
Eclipse User |
|
|
|
Originally posted by: rlemaigr.ulb.ac.be
Is there now also a key assigned to the delete global action ?
Like ctrl+z for undo ?
Last time I had this problem, such a key assignement for delete seemed n=
ot =
exist so I had to use a key handler...
r=E9gis
On Fri, 25 Jun 2004 10:27:31 -0400, Randy Hudson <none@us.ibm.com> wrote=
:
> Delete is a global action defined by the workbench. You might need to=
> register a global action handler. Delete is working in the Logic =
> example so
> maybe you can check out that code. Some things have changed a little =
in =
> the
> Eclipse platform regarding Delete.
>
> "jerome lafon" <jerome.lafon@bull.net> wrote in message
> news:40DC1EB2.4CB193BF@bull.net...
>> Hi,
>> I want to know if Somedody can explain me how to catch a keyboard
>> event, like del key pressed and assign a method to his event ?
>> Actually I have:
>>
>> a GraphicalEditorWithPalette, with a KeyHandler, a method with
>> sharedKeyHandler.put( KeyStroke.getPressed(SWT.DEL, 127, 0),
>> getActionRegistry().getAction(ActionFactory.DELETE.getId())) ;
>>
>> and a method createActions((IWorkbenchPart)this) {
>> action =3D new DeleteAction((IWorkbenchPart)this);
>> registry.registerAction(action);
>> getSelectionActions().add(action.getId());
>> }
>>
>> The topEditPart with a LAYOUT_ROLE and a CONTAINER_ROLE
>>
>> I have an editpart with a COMPONENT_ROLE edit policy, this policy
>> implements createDeleteCommand(GroupRequest deleteRequest).
>>
>> With this state, I can't delete an editpart.
>> I am not sure to understand how it should work. When I register the
>> DeleteAction in the ActionRegistry, GEF automatically call
>> createDeleteCommand() ?
>>
>> Thanks
>> Jerome Lafon
>>
>>
>
>
-- =
Using Opera's revolutionary e-mail client: http://www.opera.com/m2/
|
|
| |
Re: how to delete an edit part [message #140291 is a reply to message #140241] |
Fri, 25 June 2004 18:02  |
Eclipse User |
|
|
|
Originally posted by: rlemaigr.ulb.ac.be
Ok, thx for your explanations.
r=E9gis
On Fri, 25 Jun 2004 13:33:47 -0400, Randy Hudson <none@us.ibm.com> wrote=
:
> Yes, that's the change in 3.0. The key assignment was always there bu=
t =
> it
> was special-cased to be ignore by the workbench. In 3.0, supposedly t=
he
> control still received DEL first, then if it does not set doit =3D fal=
se, =
> the
> keybinding system will also process the key.
>
> But, you must be doing something else incorrectly. Put a breakpoint i=
n
> DeleteAction#run() and you will see that this works fine in the
> LogicExample. Stack trace:
>
> DeleteAction.run() line: 127
> KeyHandler.performStroke(KeyStroke) line: 76
> KeyHandler.keyPressed(KeyEvent) line: 50
> GraphicalViewerKeyHandler(KeyHandler).keyPressed(KeyEvent) line: 54
> GraphicalViewerKeyHandler.keyPressed(KeyEvent) line: 292
> PanningSelectionTool(SelectionTool).handleKeyDown(KeyEvent) line: 309
> PanningSelectionTool.handleKeyDown(KeyEvent) line: 163
> PanningSelectionTool(AbstractTool).keyDown(KeyEvent, EditPartViewer) =
> line:
> 887
> PanningSelectionTool(SelectionTool).keyDown(KeyEvent, EditPartViewer) =
=
> line:
> 459
> DefaultEditDomain(EditDomain).keyDown(KeyEvent, EditPartViewer) line: =
147
> DomainEventDispatcher.dispatchKeyPressed(KeyEvent) line: 229
>
>
> <rlemaigr@ulb.ac.be> wrote in message
> news:opr95mt0daxn9g2u@xn--pcrgis-dva.mshome.net...
> Is there now also a key assigned to the delete global action ?
>
>
-- =
Using Opera's revolutionary e-mail client: http://www.opera.com/m2/
|
|
|
Goto Forum:
Current Time: Thu Jul 24 15:43:30 EDT 2025
Powered by FUDForum. Page generated in 0.03263 seconds
|