{
ISelection sel = HandlerUtil.getCurrentSelection(event);
final ProjectSpace projectSpace = (ProjectSpace) ((StructuredSelection) sel).getFirstElement();
final Shell shell = HandlerUtil.getActiveWorkbenchWindow(event).getShell();
final Project project = projectSpace.getProject();
final ProgressMonitorDialog progressDialog = new ProgressMonitorDialog(shell);
new EMFStoreCommand() {
@Override
protected void doRun()
{
progressDialog.open();
Activator.getAccessLayer().invalidateCache(project);
progressDialog.getProgressMonitor().beginTask("Cleaning up project...", 10);
Activator.getProjectCleaner().cleanUpRuleOrphans(project);
progressDialog.getProgressMonitor().worked(1);
Activator.getProjectCleaner().cleanUpLinkTypeOrphans(project);
progressDialog.getProgressMonitor().worked(1);
Activator.getProjectCleaner().cleanUpViolationTypeOrphans(project);
progressDialog.getProgressMonitor().worked(1);
Activator.getProjectCleaner().cleanUpChangeTypeOrphans(project);
progressDialog.getProgressMonitor().worked(1);
Activator.getProjectCleaner().updateLinkTypeCatalogs(project);
progressDialog.getProgressMonitor().worked(1);
Activator.getProjectCleaner().updateViolationTypeCatalogs(project);
progressDialog.getProgressMonitor().worked(1);
Activator.getProjectCleaner().updateRuleCatalogs(project);
progressDialog.getProgressMonitor().worked(1);
Activator.getProjectCleaner().updateChangeTypeCatalogs(project);
progressDialog.getProgressMonitor().worked(1);
Activator.getProjectCleaner().updateLinkContainer(project);
progressDialog.getProgressMonitor().worked(1);
Activator.getProjectCleaner().updateReportContainer(project);
progressDialog.getProgressMonitor().worked(1);
progressDialog.getProgressMonitor().done();
progressDialog.close();
MessageDialog.openInformation(shell, "Cleaning project finished", "");
}
}.run();