Skip to main content



      Home
Home » Eclipse Projects » GEF » Delete action remains disabled unless I have the editor add a second copy
Delete action remains disabled unless I have the editor add a second copy [message #211309] Thu, 09 March 2006 09:14 Go to next message
Eclipse UserFriend
Originally posted by: lesliesoftware.yahoo.com

I have followed the shape example except that I create my menus and tool
bar in the main application including undo, redo and delete. Below is my
editor's action bar contributor. I realized that I did not need two
copies of these buttons so I actually removed the ActionBarContributor
totally but then they were no longer enabled - doh! So I added it back
but just did nothing in contributeToToolBar. That almost worked: undo and
redo worked as expected but delete did not. The delete button and menu
item remained disabled. If I do contribute to the editor tool bar then I
get a second copy of the delete button but they both work. However even
in this case the edit menu's delete command does not work.

What do I need to do to get the delete command to work? Do I really need
an ActionBarContributor to get these actions hooked up to the GEF drawing
(i.e. can I move this code to the editor)?

Any help or tips would be appreciated.

Thanks,

Ian

----8<----

public class DeckEditorActionBarContributor extends ActionBarContributor {

public DeckEditorActionBarContributor () {
super ();
}


@Override
public void contributeToToolBar (IToolBarManager toolBarManager) {
super.contributeToToolBar (toolBarManager);
// With the line below commented out the delete button / menu
// are never enabled.
// Uncommenting the line adds an additional copy of the delette
// button to the tool bar but both tool bar buttons are enabled
// and work however the menu is still disabled.
// toolBarManager.add (getAction (ActionFactory.DELETE.getId ()));
}


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


@Override
protected void declareGlobalActionKeys () {
// None to declare
}
}


In my ActionBarAdvisor I have code like this to create the actions:
myUndoAction = ActionFactory.UNDO.create (window);
register (myUndoAction);

myRedoAction = ActionFactory.REDO.create (window);
register (myRedoAction);

myDeleteAction = ActionFactory.DELETE.create (window);
register (myDeleteAction);

Which I use to create entries in the menu and tool bar like this:
menu:
MenuManager editMenu = new MenuManager (
Messages.getString
("ApplicationActionBarAdvisor.Menu.Edit"),
IWorkbenchActionConstants.M_EDIT);

// Populate the edit menu
// Undo / redo section
editMenu.add (myUndoAction);
editMenu.add (myRedoAction);
editMenu.add (new Separator ());

editMenu.add (myDeleteAction);

toolbar:
ToolBarManager editToolBar = new ToolBarManager (SWT.FLAT |
SWT.CENTER);

// Undo redo actions
editToolBar.add (myUndoAction);
editToolBar.add (myRedoAction);

editToolBar.add (new Separator ());

editToolBar.add (myDeleteAction);
SOLVED (was Re: Delete action remains disabled unless I have the editor add ...) [message #212277 is a reply to message #211309] Mon, 20 March 2006 16:12 Go to previous message
Eclipse UserFriend
Originally posted by: lesliesoftware.yahoo.com

Ian Leslie wrote:

> I have followed the shape example except that I create my menus and tool
> bar in the main application including undo, redo and delete. Below is my
> editor's action bar contributor. I realized that I did not need two
> copies of these buttons so I actually removed the ActionBarContributor
> totally but then they were no longer enabled - doh! So I added it back
> but just did nothing in contributeToToolBar. That almost worked: undo and
> redo worked as expected but delete did not. The delete button and menu
> item remained disabled.
<snip>

It turns out the problem was that my delete ComponentEditPolicy only
allowed for deletion of one type of child object not both. After
correcting the policy to allow for deletion correctly all was well.

Ian
Previous Topic:Is it possible to build stand alone application with GEF?
Next Topic:When should i create an edit part?
Goto Forum:
  


Current Time: Tue Jul 22 12:09:46 EDT 2025

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

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

Back to the top