use of org.openide.awt.UndoRedo in project netbeans-rcp-lite by outersky.
the class NbDocument method getEditToBeUndoneRedoneOfType.
private static <T extends UndoableEdit> T getEditToBeUndoneRedoneOfType(EditorCookie ec, Class<T> type, boolean redone) {
UndoRedo ur;
if (ec instanceof CloneableEditorSupport && ((ur = ((CloneableEditorSupport) ec).getUndoRedo()) instanceof UndoRedoManager)) {
UndoRedoManager urManager = (UndoRedoManager) ur;
UndoableEdit edit = urManager.editToBeUndoneRedone(redone);
if (type.isInstance(edit)) {
return type.cast(edit);
} else if (edit instanceof List) {
@SuppressWarnings("unchecked") List<UndoableEdit> listEdit = (List<UndoableEdit>) edit;
for (int i = listEdit.size() - 1; i >= 0; i--) {
// Go from most wrapped back
edit = listEdit.get(i);
if (type.isInstance(edit)) {
@SuppressWarnings("unchecked") T inst = (T) edit;
return inst;
}
}
}
}
return null;
}
Aggregations