@Override public void endCompoundChange() { if (isConnected()) { fFoldingIntoCompoundChange= false; commit(); } }
@Override public void setMaximalUndoLevel(int undoLevel) { fUndoLevel= Math.max(0, undoLevel); if (isConnected()) { fHistory.setLimit(fUndoContext, fUndoLevel); } }
@Override public void beginCompoundChange() { if (isConnected()) { fFoldingIntoCompoundChange= true; commit(); } }
@Override public void endCompoundChange() { if (isConnected()) { fFoldingIntoCompoundChange= false; commit(); } }
@Override public void setMaximalUndoLevel(int undoLevel) { fUndoLevel= Math.max(0, undoLevel); if (isConnected()) { fHistory.setLimit(fUndoContext, fUndoLevel); } }
@Override public void beginCompoundChange() { if (isConnected()) { fFoldingIntoCompoundChange= true; commit(); } }
@Override public void reset() { if (isConnected()) { initializeCommandStack(); fCurrent= new TextCommand(fUndoContext); fFoldingIntoCompoundChange= false; fInserting= false; fOverwriting= false; fTextBuffer.setLength(0); fPreservedTextBuffer.setLength(0); fPreservedUndoModificationStamp= IDocumentExtension4.UNKNOWN_MODIFICATION_STAMP; fPreservedRedoModificationStamp= IDocumentExtension4.UNKNOWN_MODIFICATION_STAMP; } }
@Override public void reset() { if (isConnected()) { initializeCommandStack(); fCurrent= new TextCommand(fUndoContext); fFoldingIntoCompoundChange= false; fInserting= false; fOverwriting= false; fTextBuffer.setLength(0); fPreservedTextBuffer.setLength(0); fPreservedUndoModificationStamp= IDocumentExtension4.UNKNOWN_MODIFICATION_STAMP; fPreservedRedoModificationStamp= IDocumentExtension4.UNKNOWN_MODIFICATION_STAMP; } }
@Override public void disconnect() { if (isConnected()) { removeListeners(); fCurrent= null; fTextViewer= null; disposeCommandStack(); fTextBuffer= null; fPreservedTextBuffer= null; fUndoContext= null; } }
@Override public void disconnect() { if (isConnected()) { removeListeners(); fCurrent= null; fTextViewer= null; disposeCommandStack(); fTextBuffer= null; fPreservedTextBuffer= null; fUndoContext= null; } }
@Override public void redo() { if (isConnected() && redoable()) { try { fHistory.redo(fUndoContext, null, null); } catch (ExecutionException ex) { openErrorDialog(JFaceTextMessages.getString("DefaultUndoManager.error.redoFailed.title"), ex); //$NON-NLS-1$ } } }
@Override public void undo() { if (isConnected() && undoable()) { try { fHistory.undo(fUndoContext, null, null); } catch (ExecutionException ex) { openErrorDialog(JFaceTextMessages.getString("DefaultUndoManager.error.undoFailed.title"), ex); //$NON-NLS-1$ } } }
@Override public void connect(ITextViewer textViewer) { if (!isConnected() && textViewer != null) { fTextViewer= textViewer; fTextBuffer= new StringBuilder(); fPreservedTextBuffer= new StringBuilder(); if (fUndoContext == null) fUndoContext= new ObjectUndoContext(this); fHistory.setLimit(fUndoContext, fUndoLevel); initializeCommandStack(); // open up the current command fCurrent= new TextCommand(fUndoContext); fPreviousDelete= new TextCommand(fUndoContext); addListeners(); } }
@Override public void redo() { if (isConnected() && redoable()) { try { fHistory.redo(fUndoContext, null, null); } catch (ExecutionException ex) { openErrorDialog(JFaceTextMessages.getString("DefaultUndoManager.error.redoFailed.title"), ex); //$NON-NLS-1$ } } }
@Override public void undo() { if (isConnected() && undoable()) { try { fHistory.undo(fUndoContext, null, null); } catch (ExecutionException ex) { openErrorDialog(JFaceTextMessages.getString("DefaultUndoManager.error.undoFailed.title"), ex); //$NON-NLS-1$ } } }
@Override public void connect(ITextViewer textViewer) { if (!isConnected() && textViewer != null) { fTextViewer= textViewer; fTextBuffer= new StringBuffer(); fPreservedTextBuffer= new StringBuffer(); if (fUndoContext == null) fUndoContext= new ObjectUndoContext(this); fHistory.setLimit(fUndoContext, fUndoLevel); initializeCommandStack(); // open up the current command fCurrent= new TextCommand(fUndoContext); fPreviousDelete= new TextCommand(fUndoContext); addListeners(); } }
/** * Shows the given exception in an error dialog. * * @param title the dialog title * @param ex the exception * @since 3.1 */ private void openErrorDialog(final String title, final Exception ex) { Shell shell= null; if (isConnected()) { StyledText st= fTextViewer.getTextWidget(); if (st != null && !st.isDisposed()) shell= st.getShell(); } if (Display.getCurrent() != null) MessageDialog.openError(shell, title, ex.getLocalizedMessage()); else { Display display; final Shell finalShell= shell; if (finalShell != null) display= finalShell.getDisplay(); else display= Display.getDefault(); display.syncExec(() -> MessageDialog.openError(finalShell, title, ex.getLocalizedMessage())); } }
if (isConnected()) { StyledText st= fTextViewer.getTextWidget(); if (st != null && !st.isDisposed())