use of org.eclipse.che.ide.api.editor.texteditor.HandlesUndoRedo in project che by eclipse.
the class LanguageServerFormatter method applyEdits.
private void applyEdits(List<TextEditDTO> edits, Document document) {
HandlesUndoRedo undoRedo = null;
if (editor instanceof UndoableEditor) {
undoRedo = ((UndoableEditor) editor).getUndoRedo();
}
try {
if (undoRedo != null) {
undoRedo.beginCompoundChange();
}
// #2437: apply the text edits from last to first to avoid messing up the document
Collections.reverse(edits);
for (TextEditDTO change : edits) {
RangeDTO range = change.getRange();
document.replace(range.getStart().getLine(), range.getStart().getCharacter(), range.getEnd().getLine(), range.getEnd().getCharacter(), change.getNewText());
}
} catch (final Exception e) {
Log.error(getClass(), e);
} finally {
if (undoRedo != null) {
undoRedo.endCompoundChange();
}
}
}
use of org.eclipse.che.ide.api.editor.texteditor.HandlesUndoRedo in project che by eclipse.
the class RecipeEditorPanel method onCancelButtonClicked.
/** {@inheritDoc} */
@Override
public void onCancelButtonClicked() {
setEnableSaveAndCancelButtons(false);
view.setTags(recipeDescriptor.getTags());
view.setName(recipeDescriptor.getName());
if (editor instanceof UndoableEditor) {
HandlesUndoRedo undoRedo = ((UndoableEditor) editor).getUndoRedo();
while (editor.isDirty() && undoRedo.undoable()) {
undoOperations++;
undoRedo.undo();
}
}
}
Aggregations