if (activeMenuSelection instanceof IStructuredSelection) {
IStructuredSelection selection = (IStructuredSelection) activeMenuSelection;
p = Navigation.getProject(selection);
Object firstElement = selection.getFirstElement();
if (firstElement instanceof IMethod) {
IMethod m = (IMethod) firstElement;
ICompilationUnit unit = m.getCompilationUnit();
try {
IPackageDeclaration[] packs = unit.getPackageDeclarations();
if (packs.length < 1) {
info("This action can only apply to controllers.");
return null;
} else {
packageName = packs[0].getElementName();
if (!packageName.startsWith("controllers")) {
info("This action can only apply to controllers.");
return null;
}
}
IType type = unit.getTypes()[0];
controllerName = type.getElementName();
String superclassName = type.getSuperclassName();
if (superclassName.toLowerCase().contains("japid")) {
useJapid = true;
}
List<IJavaElement> path = getJavaElementsPath(m);
if (path.size() == 7) {
int flags = m.getFlags();
if (Flags.isPublic(flags) && Flags.isStatic(flags)) {
viewName = m.getElementName();
} else {
info("The selected method " + m.getElementName()
+ " is not public static of the top controller, thus not a valid action method.");
return null;
}
}
} catch (JavaModelException e) {