RCP add Undo/Redo in the FormEditor [message #1800433] |
Fri, 28 December 2018 06:31 |
Zhang Mengfan Messages: 1 Registered: December 2018 |
Junior Member |
|
|
hi
I want to use undo/redo in my FormEditor,so i create an undoContext within my FormPage,at the first time i binding the undo/redo actions with handler when i connect my undomanager.the code like this:
--
public void connect(TableApprover natTable) {
if (!isConnected() && natTable != null) {
this.natTable = natTable;
if (undoContext == null) {
undoContext = new ObjectUndoContext(this);
}
if (actionBars != null && site != null) {
//TODO binding the undo/redo actions
undoRedoGroup = new UndoRedoActionGroup(site, undoContext, true);
undoRedoGroup.fillActionBars(actionBars);
}
opHistory.setLimit(undoContext, undoLevel);
opHistory.dispose(undoContext, true, true, false);
}
}
--
it looks like well,however,when i create two FormPage with the same FormEditor,the first FormPage 's undo/redo couldn't worked,i guess the problem is those code:
--
undoRedoGroup.fillActionBars(actionBars);
@Override
public void fillActionBars(IActionBars actionBars) {
super.fillActionBars(actionBars);
if (undoActionHandler != null) {
actionBars.setGlobalActionHandler(ActionFactory.UNDO.getId(),
undoActionHandler);
actionBars.setGlobalActionHandler(ActionFactory.REDO.getId(),
redoActionHandler);
}
}
--
the actionBars' create :actionBars = getEditorSite().getActionBars();
when a FormPage opens,EditorReference will create a ActionBars for the new FormPage,but the rule is the FormEditor can just use the same actionBars,so i guess that
undoRedoGroup.fillActionBars(actionBars) can cover teh first's handler when the second FormPage connect.
so how can i use undo/redo in my FormEditor when there is more than one FormPages as the same type(FormEditor),can anyone help me,thank very much!
|
|
|
Powered by
FUDForum. Page generated in 0.03379 seconds