public void run() {
LapseView lapseView = LapsePlugin.getDefault().getLapseView();
if (lapseView != null) {
ViewMatch match = ((ViewMatch) ((IStructuredSelection) viewer.getSelection()).getFirstElement());
ASTNode astNode = match.getAST();
SlicingFromSinkJob job = lapseView.getSinkSlicingJob();
if(job != null) {
ASTNode arg = null;
if (astNode instanceof MethodInvocation) {
arg = (ASTNode) ((MethodInvocation) astNode).arguments().get(0);
} else if(astNode instanceof ClassInstanceCreation)
{
arg=(ASTNode)((ClassInstanceCreation) astNode).arguments().get(0);
}
else
{
logError("Unrecognized " + astNode);
return;
}
job.setSink(arg);
job.setUnit(match.getUnit());
job.setResource(match.getResource());
// switch to the provenance tracker view
lapseView.refresh();
lapseView.setFocus();
// run the job
job.schedule();
} else {
MessageDialog.openError(
viewer.getControl().getShell(),
"Error occurred",
"The provenance view is closed. Please open it and try again.");