| 
| Undo / Redo limit operation on each Editor/View [message #336990] | Mon, 20 July 2009 05:21  |  | 
| Eclipse User  |  |  |  |  | Hello everyone, 
 I'm developing an application using the Eclipse plug-ins system. One of
 the client's desiderata is to have an undo/redo stack limited to the five
 latest operations for each Editors and Views of the application.
 To this end, I created an UndoContext in the createPartControl method of
 my Editors and Views.  Then I attach this context to the
 UndoRedoActionGroup :
 (with the required getViewSite(), getEditorSite() method according to the
 Part concerned)
 UndoRedoActionGroup undoRedoActions = new UndoRedoActionGroup(getSite(),
 undoContext, true);
 undoRedoActions.fillActionBars(getEditorSite().getActionBars ());
 Once this is done, I set the limit of operation in the OperationHistory :
 IOperationHistory operationHistory =
 OperationHistoryFactory.getOperationHistory();
 operationHistory.setLimit(undoContext, 5);
 
 And then I create an OperationHistoryListener for each part and had it to
 the operationHistory.
 When an edition operation is done in an Editor, I associate its
 undoContext to the operation. But, when I have 3 Editors opened and I
 perform an edition operation, the first operation doesn't update the undo
 label in the Edit menu... And when a second operation is performed on a
 second Editor, the undo label is updated for all the Editors. In other
 word I can "cancel" the edition operation on the second Editor from all
 the opened Editors.
 
 Any idea of something I'm doing wrong?
 Marc
 |  |  |  | 
| 
| Re: Undo / Redo limit operation on each Editor/View [message #468177 is a reply to message #336990] | Tue, 04 August 2009 09:08  |  | 
| Eclipse User  |  |  |  |  | Marc wrote: > Hello everyone,
 >
 > I'm developing an application using the Eclipse plug-ins system. One
 > of the client's desiderata is to have an undo/redo stack limited to
 > the five latest operations for each Editors and Views of the application.
 > To this end, I created an UndoContext in the createPartControl method
 > of my Editors and Views.  Then I attach this context to the
 > UndoRedoActionGroup :
 > (with the required getViewSite(), getEditorSite() method according to
 > the Part concerned)
 > UndoRedoActionGroup undoRedoActions = new
 > UndoRedoActionGroup(getSite(), undoContext, true);
 >  undoRedoActions.fillActionBars(getEditorSite().getActionBars ());
 > Once this is done, I set the limit of operation in the OperationHistory :
 > IOperationHistory operationHistory =
 > OperationHistoryFactory.getOperationHistory();
 > operationHistory.setLimit(undoContext, 5);
 >
 > And then I create an OperationHistoryListener for each part and had it
 > to the operationHistory. When an edition operation is done in an
 > Editor, I associate its undoContext to the operation. But, when I have
 > 3 Editors opened and I perform an edition operation, the first
 > operation doesn't update the undo label in the Edit menu... And when a
 > second operation is performed on a second Editor, the undo label is
 > updated for all the Editors. In other word I can "cancel" the edition
 > operation on the second Editor from all the opened Editors.
 >
 > Any idea of something I'm doing wrong?
 Make sure that you really use different undo contexts.
 
 Dani
 > Marc
 >
 |  |  |  | 
Powered by 
FUDForum. Page generated in 0.04560 seconds