Processes a newly created Activity.
try {
String methodContent =
" /** Called when the activity is first created. */\n" +
" @Override\n" +
" public void onCreate(Bundle savedInstanceState) {\n" +
" super.onCreate(savedInstanceState);\n" +
"\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_BUNDLE,
null /* sibling */, new NullProgressMonitor());
}
} catch (JavaModelException e) {
}