Source:
public static void addTracingNature(IProject project, IProgressMonitor monitor) { WorkspaceModifyOperation action = new WorkspaceModifyOperation() { @Override protected void execute(IProgressMonitor progressMonitor) throws CoreException, InvocationTargetException, InterruptedException { if (!project.isOpen()) { project.open(progressMonitor); } IProjectDescription description = project.getDescription(); boolean hasNature = description.hasNature(TmfProjectNature.ID); String[] natures = description.getNatureIds(); IWorkspace workspace = ResourcesPlugin.getWorkspace(); if (workspace == null) { return; } if (!hasNature && natures.length > 0) { String[] newNatures = new String[natures.length + 1]; System.arraycopy(natures, 0, newNatures, 0, natures.length); newNatures[natures.length] = TmfProjectNature.ID; IStatus status = workspace.validateNatureSet(newNatures); if (status.isOK()) { description.setNatureIds(newNatures); project.setDescription(description, null); } else { Activator.getDefault().getLog().log(status); } } description = project.getDescription(); hasNature = description.hasNature(TmfProjectNature.ID); natures = description.getNatureIds(); if (hasNature && natures.length > 1) { String shadowProjectName = TmfProjectModelHelper.getShadowProjectName(project.getName()); IProject shadowProject = workspace.getRoot().getProject(shadowProjectName); if (!shadowProject.isAccessible()) { shadowProject.delete(false, true, progressMonitor); } if (!shadowProject.exists()) { IFolder shadowProjectFolder = TmfProjectElement.createFolderStructure(project, null); shadowProject = createProject(shadowProjectName, shadowProjectFolder.getLocationURI(), progressMonitor); shadowProjectFolder.refreshLocal(IResource.DEPTH_INFINITE, progressMonitor); } if (!shadowProject.isOpen()) { shadowProject.open(progressMonitor); } TmfProjectElement.createFolderStructure(project, shadowProject); } } }; try { action.run(monitor); } catch (InvocationTargetException e) { Activator.getDefault().logError("Error adding tracing natue to project " + project.getName(), e); } catch (InterruptedException e) { } }

Target:
public static void addTracingNature(IProject project, IProgressMonitor monitor) { WorkspaceModifyOperation action = new WorkspaceModifyOperation() { @Override protected void execute(IProgressMonitor progressMonitor) throws CoreException, InvocationTargetException, InterruptedException { if (!project.isOpen()) { project.open(progressMonitor); } IProjectDescription description = project.getDescription(); boolean hasNature = description.hasNature(TmfProjectNature.ID); String[] natures = description.getNatureIds(); IWorkspace workspace = ResourcesPlugin.getWorkspace(); if (workspace == null) { return; } if (!hasNature && natures.length > 0) { String[] newNatures = new String[natures.length + 1]; System.arraycopy(natures, 0, newNatures, 0, natures.length); newNatures[natures.length] = TmfProjectNature.ID; IStatus status = workspace.validateNatureSet(newNatures); if (status.isOK()) { description.setNatureIds(newNatures); project.setDescription(description, null); } else { Activator.getDefault().getLog().log(status); } } description = project.getDescription(); hasNature = description.hasNature(TmfProjectNature.ID); natures = description.getNatureIds(); if (hasNature && natures.length > 1) { String shadowProjectName = TmfProjectModelHelper.getShadowProjectName(project.getName()); IProject shadowProject = workspace.getRoot().getProject(shadowProjectName); if (shadowProject.exists() && !shadowProject.isAccessible()) { shadowProject.delete(false, true, progressMonitor); } if (!shadowProject.exists()) { IFolder shadowProjectFolder = TmfProjectElement.createFolderStructure(project, null); shadowProject = createProject(shadowProjectName, shadowProjectFolder.getLocationURI(), progressMonitor); shadowProjectFolder.refreshLocal(IResource.DEPTH_INFINITE, progressMonitor); } if (!shadowProject.isOpen()) { shadowProject.open(progressMonitor); } TmfProjectElement.createFolderStructure(project, shadowProject); } } }; try { action.run(monitor); } catch (InvocationTargetException e) { Activator.getDefault().logError("Error adding tracing nature to project " + project.getName(), e); } catch (InterruptedException e) { } }