Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 7e870478dae0a577194ef537e28f18b4ca20519f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package org.eclipse.jst.jsf.common.internal.resource;

import org.eclipse.core.resources.IWorkspaceRunnable;
import org.eclipse.core.resources.WorkspaceJob;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;

/**
 * Mediates between a client and certain workspace interface.  This is allows
 * us to decouple from the IWorkspace interface, especially for testing.
 * 
 * @author cbateman
 *
 */
public class WorkspaceMediator
{
    /**
     * @param runnable
     * @param name
     */
    public void runInWorkspaceJob(final IWorkspaceRunnable runnable, final String name)
    {
        new WorkspaceJob(name)
        {
            @Override
            public IStatus runInWorkspace(IProgressMonitor monitor)
                    throws CoreException
            {
                runnable.run(monitor);
                return Status.OK_STATUS;
            }
            
        }.schedule();
    }
}

Back to the top