* @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
*/
public Object execute(ExecutionEvent event) throws ExecutionException
{
ISelection sel = HandlerUtil.getCurrentSelection(event);
final ProjectSpace projectSpace = (ProjectSpace) ((StructuredSelection) sel).getFirstElement();
final Shell shell = HandlerUtil.getActiveWorkbenchWindow(event).getShell();
final RuleApplicationWizard wizard = new RuleApplicationWizard(projectSpace.getProject());
final WizardDialog dialog = new WizardDialog(shell, wizard);
new EMFStoreCommand() {
@Override
protected void doRun()
{
int ruleCnt = (Activator.getAccessLayer().getElements(projectSpace.getProject(), "Rule")).size();
if( ruleCnt == 0 )
{
MessageDialog.openError(shell, "Execution abborted", "The project does not contain any rule(s)");
return;
}
int modelCnt = (Activator.getAccessLayer().getElements(projectSpace.getProject(), "EObject")).size() - ruleCnt;
if( modelCnt == 0 )
{
MessageDialog.openError(shell, "Execution abborted", "The project does not contain any model(s)");
return;
}
Activator.getProjectCleaner().cleanUpProject(projectSpace.getProject());
dialog.open();
}
}.run();
if( wizard.finishedSuccessfully )
{
Activator.getAccessLayer().invalidateCache(projectSpace.getProject());
RuleApplicationOperation op = new RuleApplicationOperation(projectSpace.getProject(), projectSpace, wizard.selectedModels, wizard.selectedCatalog, wizard.selectedRules);
try
{
ProgressMonitorDialog progressDialog = new ProgressMonitorDialog(shell);
progressDialog.setCancelable(false);
progressDialog.run(true, true, op);