Source:
<code>private static void addMissingReferences(final IQ7Project project, final List<IQ7NamedElement> references) { Job job = new Job("Fix project references") { @Override protected IStatus run(IProgressMonitor monitor) { final IStatus[] status = { Status.OK_STATUS }; try { monitor.beginTask("Remove project context/verification references", references.size() * 2); IQ7ProjectMetadata metadata = project.getMetadata(); if (metadata == null || !metadata.exists()) { return status[0]; } String[] defaultContexts = metadata.getContexts(); String[] defaultVerifications = metadata.getVerifications(); if (defaultContexts.length == 0 && defaultVerifications.length == 0) { return status[0]; } final List<String> contextsToRemove = Arrays.asList(defaultContexts); final List<String> verificationsToRemove = Arrays.asList(defaultVerifications); ResourcesPlugin.getWorkspace().run( new IWorkspaceRunnable() { public void run(IProgressMonitor monitor) throws CoreException { <START> WriteAccessChecker writeAccessChecker = new WriteAccessChecker(); <END> if (!writeAccessChecker.makeResourceWritable(references)) { status[0] = Status.CANCEL_STATUS; return; } for (IQ7NamedElement e : references) { IQ7NamedElement copy = e.getWorkingCopy(new SubProgressMonitor( monitor, 1)); try { NamedElement ne = copy.getNamedElement(); if (ne instanceof Scenario) { ((Scenario) ne) .getContexts() .removeAll( contextsToRemove); ((Scenario) ne) .getVerifications() .removeAll( verificationsToRemove); } if (ne instanceof GroupContext) { ((GroupContext) ne) .getContextReferences() .removeAll( contextsToRemove); } copy.commitWorkingCopy(false, new SubProgressMonitor( monitor, 1)); } finally { copy.discardWorkingCopy(); } } } }, monitor); } catch (CoreException e) { return e.getStatus(); } return status[0]; } }; job.setUser(true); job.schedule(); }</code><technical_language>default shell. Dialog one</technical_language>

Target:
private static void addMissingReferences(final IQ7Project project, final List<IQ7NamedElement> references) { Job job = new Job("Fix project references") { @Override protected IStatus run(IProgressMonitor monitor) { final IStatus[] status = { Status.OK_STATUS }; try { monitor.beginTask("Remove project context/verification references", references.size() * 2); IQ7ProjectMetadata metadata = project.getMetadata(); if (metadata == null || !metadata.exists()) { return status[0]; } String[] defaultContexts = metadata.getContexts(); String[] defaultVerifications = metadata.getVerifications(); if (defaultContexts.length == 0 && defaultVerifications.length == 0) { return status[0]; } final List<String> contextsToRemove = Arrays.asList(defaultContexts); final List<String> verificationsToRemove = Arrays.asList(defaultVerifications); ResourcesPlugin.getWorkspace().run( new IWorkspaceRunnable() { public void run(IProgressMonitor monitor) throws CoreException { WriteAccessChecker writeAccessChecker = new WriteAccessChecker(instance.getShell()); if (!writeAccessChecker.makeResourceWritable(references .toArray(new IQ7NamedElement[0]))) { status[0] = Status.CANCEL_STATUS; return; } for (IQ7NamedElement e : references) { IQ7NamedElement copy = e.getWorkingCopy(new SubProgressMonitor( monitor, 1)); try { NamedElement ne = copy.getNamedElement(); if (ne instanceof Scenario) { ((Scenario) ne) .getContexts() .removeAll( contextsToRemove); ((Scenario) ne) .getVerifications() .removeAll( verificationsToRemove); } if (ne instanceof GroupContext) { ((GroupContext) ne) .getContextReferences() .removeAll( contextsToRemove); } copy.commitWorkingCopy(false, new SubProgressMonitor( monitor, 1)); } finally { copy.discardWorkingCopy(); } } } }, monitor); } catch (CoreException e) { return e.getStatus(); } return status[0]; } }; job.setUser(true); job.schedule(); }