1 /*******************************************************************************
2  * Copyright (c) 2000, 2008 IBM Corporation and others.
3  *
4  * This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License 2.0
6  * which accompanies this distribution, and is available at
7  * https://www.eclipse.org/legal/epl-2.0/
8  *
9  * SPDX-License-Identifier: EPL-2.0
10  *
11  * Contributors:
12  *     IBM Corporation - initial API and implementation
13  *******************************************************************************/
14 package org.eclipse.core.filebuffers.manipulation;
15 
16 import org.eclipse.core.runtime.CoreException;
17 import org.eclipse.core.runtime.IProgressMonitor;
18 
19 import org.eclipse.core.resources.IWorkspace;
20 import org.eclipse.core.resources.IWorkspaceRunnable;
21 import org.eclipse.core.resources.ResourcesPlugin;
22 
23 import org.eclipse.core.filebuffers.IFileBuffer;
24 import org.eclipse.core.filebuffers.IFileBufferManager;
25 
26 
27 /**
28  * A <code>FileBufferOperationRunner</code> executes
29  * {@link org.eclipse.core.filebuffers.manipulation.IFileBufferOperation}.
30  * The runner takes care of all aspects that are not operation specific.
31  * <p>
32  * This class is not intended to be subclassed. Clients instantiate this class.
33  * </p>
34  *
35  * @see org.eclipse.core.filebuffers.manipulation.IFileBufferOperation
36  * @since 3.1
37  * @noextend This class is not intended to be subclassed by clients.
38  */
39 public class FileBufferOperationRunner extends GenericFileBufferOperationRunner {
40 
41 	/**
42 	 * Creates a new file buffer operation runner.
43 	 *
44 	 * @param fileBufferManager the file buffer manager
45 	 * @param validationContext the validationContext
46 	 */
FileBufferOperationRunner(IFileBufferManager fileBufferManager, Object validationContext)47 	public FileBufferOperationRunner(IFileBufferManager fileBufferManager, Object validationContext) {
48 		super(fileBufferManager, validationContext);
49 	}
50 
51 	@Override
commit(final IFileBuffer[] fileBuffers, final IProgressMonitor progressMonitor)52 	protected void commit(final IFileBuffer[] fileBuffers, final IProgressMonitor progressMonitor) throws CoreException {
53 		IWorkspaceRunnable runnable= monitor -> doCommit(fileBuffers, progressMonitor);
54 		ResourcesPlugin.getWorkspace().run(runnable, computeCommitRule(fileBuffers), IWorkspace.AVOID_UPDATE, progressMonitor);
55 	}
56 }
57