Implementing some actions for my own Navigator [message #233768] |
Tue, 16 June 2009 08:38 |
Javier Messages: 57 Registered: July 2009 |
Member |
|
|
Hello guys,
I have an application in which I need some extra functionality in my
Navigator view for the model resource. For example I can create model
elements through some actions in context menus (these model elements
will appear randomly located in the diagram). I also need this viewer to
access the undo/redo mechanism in the Edit menu.
To achieve this, I implemented my own CommonActionProvider and it is
being used from the Navigator. I followed the code I found for the
ProjectExplorer of Eclipse and I tried to modify it, telling the
UndoRedo actions to use the IUndoContext of my diagram. This is part of
the code:
public void init(ICommonActionExtensionSite anActionSite) {
IUndoContext context = ((DiagramEditor)PlatformUI.
getWorkbench().getActiveWorkbenchWindow().
getActivePage().getActiveEditor()).
getDiagramEditDomain().getDiagramCommandStack(). getUndoContext();
IWorkbenchPartSite site = ((DiagramEditor)PlatformUI.
getWorkbench().getActiveWorkbenchWindow().
getActivePage().getActiveEditor()).getSite();
undoRedoGroup = new UndoRedoActionGroup(site,
workspaceContext, true);
}
public void dispose() {
undoRedoGroup.dispose();
}
public void fillActionBars(IActionBars actionBars) {
actionBars.setGlobalActionHandler
(ActionFactory.UNDO.getId(), new
GlobalUndoAction(((DiagramEditor)PlatformUI.getWorkbench().g etActiveWorkbenchWindow().getActivePage().getActiveEditor()) ));
undoRedoGroup.fillActionBars(actionBars);
}
But this code is not working as I would like, since if I made changes in
the diagram and afterwards I put the focus on my navigator viewer, the
Undo/Redo shows nothing. Instead, if from the package explorer I move a
file from one folder to another, and then I go back and select one of
the elements that enables my ActionProvider, in the undo/redo I can undo
the moved element. But for example, doing this:
public void fillContextMenu(IMenuManager menu) {
menu.add(new
GlobalUndoAction(((DiagramEditor)PlatformUI.getWorkbench().g etActiveWorkbenchWindow().getActivePage().getActiveEditor()) ));
undoRedoGroup.fillContextMenu(menu);
}
I do get the UndoAction working properly in the context menu.
Any hint on how to get this behavior working in the ActionBars?
Thank u!
|
|
|
Powered by
FUDForum. Page generated in 0.02603 seconds