Processes a newly created Activity.
try {
String methodContent =
" @Override\n" +
" public void onReceive(Context context, Intent intent) {\n" +
" // TODO Auto-generated method stub\n" +
" }";
newType.createMethod(methodContent, null /* sibling*/, false /* force */,
new NullProgressMonitor());
// we need to add the import for Bundle, so we need the compilation unit.
// Since the type could be enclosed in other types, we loop till we find it.
ICompilationUnit compilationUnit = null;
IJavaElement element = newType;
do {
IJavaElement parentElement = element.getParent();
if (parentElement != null) {
if (parentElement.getElementType() == IJavaElement.COMPILATION_UNIT) {
compilationUnit = (ICompilationUnit)parentElement;
}
element = parentElement;
} else {
break;
}
} while (compilationUnit == null);
if (compilationUnit != null) {
compilationUnit.createImport(AndroidConstants.CLASS_CONTEXT,
null /* sibling */, new NullProgressMonitor());
compilationUnit.createImport(AndroidConstants.CLASS_INTENT,
null /* sibling */, new NullProgressMonitor());
}
} catch (JavaModelException e) {
// looks like the class already existed (this happens when the user check to create
// inherited abstract methods).
}