Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Delete action/button is dissabled
Delete action/button is dissabled [message #227270] Fri, 01 December 2006 11:20 Go to next message
Eclipse UserFriend
Originally posted by: vikas.khengare.unnat-e.com

Hi friends,

I have put following code in "MultiPageEditorContributor", This is showing
me undo & redo functionality clear.
But for delete action "Delete" button icon is always disabled and not
performing any thing.
It is not enabling even single time.

1) Do I need to handle some thing for delete in "Command" where I have
handled for Undo & Redo?
2) Am I missing something in coding? what?
3) Do I need to do something with ActionRegistry / getActionRegistry?

public void contributeToToolBar(IToolBarManager manager) {
manager.add(getActionRegistry().getAction(ActionFactory.UNDO .getId()));
manager.add(getActionRegistry().getAction(ActionFactory.REDO .getId()));
manager.add(new Separator());

manager.add(getActionRegistry().getAction(ActionFactory.DELE TE.getId()));
}

protected void buildActions() {
addRetargetAction(new UndoRetargetAction());
addRetargetAction(new RedoRetargetAction());
addRetargetAction(new DeleteRetargetAction());
}

--
With best regards

From
Vikas R. Khengare
Re: Delete action/button is dissabled [message #227339 is a reply to message #227270] Mon, 04 December 2006 02:15 Go to previous messageGo to next message
Alex Boyko is currently offline Alex BoykoFriend
Messages: 200
Registered: July 2009
Senior Member
Hi Vikas,

It seems to me that you're trying to add GEF's retarget actions to a
Multipage editor, which is not a GEF application. There is no need to add
GEF's actions to it... you can simply add to tool bar actions defined for
text editors already. GEF's actions won't work there correctly anyway.
I've tried to do the following in setActivePage(IEditorPart) method inside
if (actionBars != null) block:

actionBars.getToolBarManager().add(getAction(editor,ITextEdi torActionConstants.UNDO));
actionBars.getToolBarManager().add(getAction(editor,ITextEdi torActionConstants.REDO));
actionBars.getToolBarManager().add(getAction(editor,ITextEdi torActionConstants.DELETE));

This is merely an example, I'm not 100% sure that that is the right place
to put those 3 lines in. Try posting this question on Eclipse PDE
newsgroup.
Hope this helps.

Cheers,
Alex
Re: Delete action/button is dissabled [message #227367 is a reply to message #227339] Mon, 04 December 2006 09:10 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: vikas.khengare.unnat-e.com

Hi friends

Thanks alex for your reply.
I have enabled delete button on right click by following code

public void buildContextMenu(IMenuManager menu)
{
action = getActionRegistry().getAction(ActionFactory.DELETE.getId());
action.setEnabled(true);
if (null != action && action.isEnabled())
menu.appendToGroup(GEFActionConstants.GROUP_EDIT, action);
}

But still now also it is not performing any action. It is not creating
command.
It is not calling "getCommand()" even.

In Edit Part; I worte ...
protected void createEditPolicies() {
installEditPolicy(EditPolicy.COMPONENT_ROLE, new RectangleEditPolicy());
}

In "RectangleEditPolicy" class I wrote
class RectangleEditPolicy extends ComponentEditPolicy{

public Command getCommand(Request request) {
System.out.println(request.getType());
return super.getCommand(request);
}
}

But this is not calling getCommand() method.

Can Someone help me in this scenario?
Note : 1] This is MultiPageEditor
2] Where my main editor class extends GraphicalEditor
---
With best regards

From
Vikas R. Khengare

"Alex Boyko" <aboyko@ca.ibm.com> wrote in message
news:179dd5c5ce95617b1d2633657335bcc9$1@www.eclipse.org...
> Hi Vikas,
>
> It seems to me that you're trying to add GEF's retarget actions to a
> Multipage editor, which is not a GEF application. There is no need to add
> GEF's actions to it... you can simply add to tool bar actions defined for
> text editors already. GEF's actions won't work there correctly anyway.
> I've tried to do the following in setActivePage(IEditorPart) method inside
> if (actionBars != null) block:
>
>
actionBars.getToolBarManager().add(getAction(editor,ITextEdi torActionConstan
ts.UNDO));
>
actionBars.getToolBarManager().add(getAction(editor,ITextEdi torActionConstan
ts.REDO));
>
actionBars.getToolBarManager().add(getAction(editor,ITextEdi torActionConstan
ts.DELETE));
>
> This is merely an example, I'm not 100% sure that that is the right place
> to put those 3 lines in. Try posting this question on Eclipse PDE
> newsgroup.
> Hope this helps.
>
> Cheers,
> Alex
>
>
Re: Delete action/button is dissabled [message #227391 is a reply to message #227270] Tue, 05 December 2006 02:23 Go to previous messageGo to next message
Alex Boyko is currently offline Alex BoykoFriend
Messages: 200
Registered: July 2009
Senior Member
Hi Vikas,

Your retarget delete action does not have a handler - the actual
DeleteAction that will create and execute the command. So your retarget
delete action is not doing anything at the moment.

Try doing the following in your action bar contrubutor class, where you
contribute actions to tool bars and menus:

protected void declareGlobalActionKeys() {
addGlobalActionKey(ActionFactory.DELETE.getId())
}

You're adding Undo and Redo global key handlers somewhere right now,
either in the action bar contributor or the editor's class in init()
method. Insert the global key handler for delete in the same place. (This
is how it's done in the Logic example editor)
Hope this helps.

Cheers,
Alex
Re: Delete action/button is dissabled [message #227398 is a reply to message #227391] Tue, 05 December 2006 05:23 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: vikas.khengare.unnat-e.com

Hi Alex & other friends

I have done that already ... in class "MultiPageEditorContributor extends
ActionBarContributor"

public void contributeToToolBar(IToolBarManager manager)
{

manager.add(getActionRegistry().getAction(ActionFactory.DELE TE.getId()));
// same for Undo & Redo
}
protected void buildActions()
{
addRetargetAction(new DeleteRetargetAction());
// same for Undo & Redo
}
protected void declareGlobalActionKeys()
{
addGlobalActionKey(ActionFactory.DELETE.getId());
addGlobalActionKey(ActionFactory.UNDO.getId());
addGlobalActionKey(ActionFactory.REDO.getId());
}

As I told you I wrote ...... I wrote every thing ....... 1] Context menu 2]
Installed EditPolicy in edit Part 3] Actual EditPolicy class

public void buildContextMenu(IMenuManager menu)
{
action = getActionRegistry().getAction(ActionFactory.DELETE.getId());
action.setEnabled(true);
if (null != action && action.isEnabled())
menu.appendToGroup(GEFActionConstants.GROUP_EDIT, action);
}

But still now also it is not performing any action. It is not creating
command.
It is not calling "getCommand()" even.

In Edit Part; I worte ...
protected void createEditPolicies() {
installEditPolicy(EditPolicy.COMPONENT_ROLE, new RectangleEditPolicy());
}

In "RectangleEditPolicy" class I wrote
class RectangleEditPolicy extends ComponentEditPolicy
{ public Command getCommand(Request request) {
System.out.println(request.getType());
return super.getCommand(request);
}}

But this is not calling getCommand() method.

What's the wrong ?

--
With best regards

From
Vikas R. Khengare

"Alex Boyko" <aboyko@ca.ibm.com> wrote in message
news:2deda39a1ce6b9e0fb084e79e9eff68f$1@www.eclipse.org...
> Hi Vikas,
>
> Your retarget delete action does not have a handler - the actual
> DeleteAction that will create and execute the command. So your retarget
> delete action is not doing anything at the moment.
>
> Try doing the following in your action bar contrubutor class, where you
> contribute actions to tool bars and menus:
>
> protected void declareGlobalActionKeys() {
> addGlobalActionKey(ActionFactory.DELETE.getId())
> }
>
> You're adding Undo and Redo global key handlers somewhere right now,
> either in the action bar contributor or the editor's class in init()
> method. Insert the global key handler for delete in the same place. (This
> is how it's done in the Logic example editor)
> Hope this helps.
>
> Cheers,
> Alex
>
Re: Delete action/button is dissabled [message #227428 is a reply to message #227398] Tue, 05 December 2006 09:34 Go to previous message
Eclipse UserFriend
Originally posted by: vikas.khengare.unnat-e.com

hi alex / other friends,

I got the solution ....... I haven't override init() methods of
GraphicalEditor class.

Hope so this was missing ....... right alex?

--
With best regards

From
Vikas R. Khengare

"Vikas" <vikas.khengare@unnat-e.com> wrote in message
news:el2vob$m41$1@utils.eclipse.org...
> Hi Alex & other friends
>
> I have done that already ... in class "MultiPageEditorContributor extends
> ActionBarContributor"
>
> public void contributeToToolBar(IToolBarManager manager)
> {
>
> manager.add(getActionRegistry().getAction(ActionFactory.DELE TE.getId()));
> // same for Undo & Redo
> }
> protected void buildActions()
> {
> addRetargetAction(new DeleteRetargetAction());
> // same for Undo & Redo
> }
> protected void declareGlobalActionKeys()
> {
> addGlobalActionKey(ActionFactory.DELETE.getId());
> addGlobalActionKey(ActionFactory.UNDO.getId());
> addGlobalActionKey(ActionFactory.REDO.getId());
> }
>
> As I told you I wrote ...... I wrote every thing ....... 1] Context menu
2]
> Installed EditPolicy in edit Part 3] Actual EditPolicy class
>
> public void buildContextMenu(IMenuManager menu)
> {
> action = getActionRegistry().getAction(ActionFactory.DELETE.getId());
> action.setEnabled(true);
> if (null != action && action.isEnabled())
> menu.appendToGroup(GEFActionConstants.GROUP_EDIT, action);
> }
>
> But still now also it is not performing any action. It is not creating
> command.
> It is not calling "getCommand()" even.
>
> In Edit Part; I worte ...
> protected void createEditPolicies() {
> installEditPolicy(EditPolicy.COMPONENT_ROLE, new RectangleEditPolicy());
> }
>
> In "RectangleEditPolicy" class I wrote
> class RectangleEditPolicy extends ComponentEditPolicy
> { public Command getCommand(Request request) {
> System.out.println(request.getType());
> return super.getCommand(request);
> }}
>
> But this is not calling getCommand() method.
>
> What's the wrong ?
>
> --
> With best regards
>
> From
> Vikas R. Khengare
>
> "Alex Boyko" <aboyko@ca.ibm.com> wrote in message
> news:2deda39a1ce6b9e0fb084e79e9eff68f$1@www.eclipse.org...
> > Hi Vikas,
> >
> > Your retarget delete action does not have a handler - the actual
> > DeleteAction that will create and execute the command. So your retarget
> > delete action is not doing anything at the moment.
> >
> > Try doing the following in your action bar contrubutor class, where you
> > contribute actions to tool bars and menus:
> >
> > protected void declareGlobalActionKeys() {
> > addGlobalActionKey(ActionFactory.DELETE.getId())
> > }
> >
> > You're adding Undo and Redo global key handlers somewhere right now,
> > either in the action bar contributor or the editor's class in init()
> > method. Insert the global key handler for delete in the same place.
(This
> > is how it's done in the Logic example editor)
> > Hope this helps.
> >
> > Cheers,
> > Alex
> >
>
>
Previous Topic:Where to persist a model's graphical information?
Next Topic:Problem in Shapes example
Goto Forum:
  


Current Time: Sun Dec 22 05:46:48 GMT 2024

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

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

Back to the top