@@ -0,0 +1,2515 @@
+package org.lamport.tla.toolbox.job;%0D%0A%0D%0Aimport java.io.File;%0D%0Aimport java.io.FileOutputStream;%0D%0Aimport java.io.IOException;%0D%0A%0D%0Aimport org.eclipse.core.resources.IWorkspaceRunnable;%0D%0Aimport org.eclipse.core.resources.WorkspaceJob;%0D%0Aimport org.eclipse.core.runtime.CoreException;%0D%0Aimport org.eclipse.core.runtime.IPath;%0D%0Aimport org.eclipse.core.runtime.IProgressMonitor;%0D%0Aimport org.eclipse.core.runtime.IStatus;%0D%0Aimport org.eclipse.core.runtime.Status;%0D%0Aimport org.lamport.tla.toolbox.Activator;%0D%0Aimport org.lamport.tla.toolbox.util.ResourceHelper;%0D%0A%0D%0A/**%0D%0A * Creates a new TLA+ module%0D%0A * @author Simon Zambrovski%0D%0A * @version $Id$%0D%0A */%0D%0Apublic class NewTLAModuleCreationOperation implements IWorkspaceRunnable%0D%0A%7B%0D%0A    private IPath modulePath;%0D%0A%0D%0A    /**%0D%0A     * @param name%0D%0A     */%0D%0A    public NewTLAModuleCreationOperation(IPath module)%0D%0A    %7B%0D%0A        // super(%22Create new TLA+ File %22 + module.toOSString());%0D%0A        this.modulePath = module;%0D%0A    %7D%0D%0A%0D%0A    /* (non-Javadoc)%0D%0A     * @see org.eclipse.core.resources.IWorkspaceRunnable#run(org.eclipse.core.runtime.IProgressMonitor)%0D%0A     */%0D%0A    public void run(IProgressMonitor monitor) throws CoreException%0D%0A    %7B%0D%0A        String moduleFileName = modulePath.lastSegment();%0D%0A%0D%0A        byte%5B%5D content = ResourceHelper.getEmptyModuleContent(moduleFileName);%0D%0A        try%0D%0A        %7B%0D%0A            // create file%0D%0A            File file = new File(modulePath.toOSString());%0D%0A            if (file.createNewFile())%0D%0A            %7B%0D%0A                // successfully created%0D%0A                FileOutputStream fos = new FileOutputStream(file);%0D%0A                fos.write(content);%0D%0A                fos.flush();%0D%0A                fos.close();%0D%0A            %7D else%0D%0A            %7B%0D%0A                throw new RuntimeException(%22Error creating a file%22);%0D%0A            %7D%0D%0A        %7D catch (IOException e)%0D%0A        %7B%0D%0A            throw new CoreException( new Status(Status.ERROR, Activator.PLUGIN_ID, %22Error creating TLA+ file%22, e));%0D%0A        %7D%0D%0A    %7D%0D%0A%0D%0A    /**%0D%0A     * Job factory%0D%0A     * @param module%0D%0A     * @return%0D%0A     */%0D%0A    public static WorkspaceJob NEW_JOB(final IPath module)%0D%0A    %7B%0D%0A        return new WorkspaceJob(%22Creating TLA+ file%22)%0D%0A        %7B%0D%0A            NewTLAModuleCreationOperation op = new NewTLAModuleCreationOperation(module);%0D%0A%0D%0A            public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException%0D%0A            %7B%0D%0A                op.run(monitor);%0D%0A                return Status.OK_STATUS;%0D%0A            %7D%0D%0A        %7D;%0D%0A        %0D%0A    %7D%0D%0A%7D%0D%0A

separated in a job