Search in sources :

Example 1 with MultiStateUndoChange

use of org.eclipse.ltk.internal.core.refactoring.MultiStateUndoChange in project che by eclipse.

the class MultiStateTextFileChange method perform.

/*
	 * @see org.eclipse.ltk.core.refactoring.Change#perform(org.eclipse.core.runtime.IProgressMonitor)
	 */
public final Change perform(final IProgressMonitor monitor) throws CoreException {
    //$NON-NLS-1$
    monitor.beginTask("", 3);
    IDocument document = null;
    try {
        document = acquireDocument(new SubProgressMonitor(monitor, 1));
        final LinkedList undoList = new LinkedList();
        performChanges(document, undoList, false);
        if (needsSaving())
            fBuffer.commit(new SubProgressMonitor(monitor, 1), false);
        return new MultiStateUndoChange(getName(), fFile, (UndoEdit[]) undoList.toArray(new UndoEdit[undoList.size()]), fContentStamp, fSaveMode);
    } catch (BadLocationException exception) {
        throw Changes.asCoreException(exception);
    } finally {
        if (document != null) {
            releaseDocument(document, new SubProgressMonitor(monitor, 1));
        }
        monitor.done();
    }
}
Also used : MultiStateUndoChange(org.eclipse.ltk.internal.core.refactoring.MultiStateUndoChange) UndoEdit(org.eclipse.text.edits.UndoEdit) IDocument(org.eclipse.jface.text.IDocument) SubProgressMonitor(org.eclipse.core.runtime.SubProgressMonitor) LinkedList(java.util.LinkedList) BadLocationException(org.eclipse.jface.text.BadLocationException)

Aggregations

LinkedList (java.util.LinkedList)1 SubProgressMonitor (org.eclipse.core.runtime.SubProgressMonitor)1 BadLocationException (org.eclipse.jface.text.BadLocationException)1 IDocument (org.eclipse.jface.text.IDocument)1 MultiStateUndoChange (org.eclipse.ltk.internal.core.refactoring.MultiStateUndoChange)1 UndoEdit (org.eclipse.text.edits.UndoEdit)1