* @param allowNoParameterCall
*/
public static boolean checkEvtCall(String eventValue, String eventName,String parameterClassName,
GeneratorContext context, View view, Device device, boolean allowNoParameterCall)
{
Event event = EventFactory.getEvent(eventName, eventValue);
if (event == null)
{
throw new CruxGeneratorException("Error parsing controller method declaration on view ["+view.getId()+"]. ["+eventValue+"] is not a valid method declaration.");
}
JClassType eventClassType = parameterClassName==null?null:context.getTypeOracle().findType(parameterClassName);
if (!view.useController(event.getController()))
{
throw new CruxGeneratorException("Controller ["+event.getController()+"] , used on view ["+view.getId()+"], was not declared on this view. Use the useController attribute to import the controller into this view.");
}
String controller = ClientControllers.getController(event.getController(), device);
if (controller == null)
{
throw new CruxGeneratorException("Controller ["+event.getController()+"] , declared on view ["+view.getId()+"], not found.");
}
boolean hasEventParameter = true;
JClassType controllerClass = context.getTypeOracle().findType(controller);
if (controllerClass == null)
{
String message = "Controller class ["+controller+"] , declared on view ["+view.getId()+"], could not be loaded. "
+ "\n Possible causes:"
+ "\n\t 1. Check if any type or subtype used by controller refers to another module and if this module is inherited in the .gwt.xml file."
+ "\n\t 2. Check if your controller or its members belongs to a client package."
+ "\n\t 3. Check the versions of all your modules."
;
throw new CruxGeneratorException(message);
}
JMethod exposedMethod = getControllerMethodWithEvent(event.getMethod(), eventClassType, controllerClass);
if (exposedMethod == null)
{
if (allowNoParameterCall)
{
exposedMethod = JClassUtils.getMethod(controllerClass, event.getMethod(), new JType[]{});
if (exposedMethod == null)
{
throw new CruxGeneratorException("View ["+view.getId()+"] tries to invoke the method ["+event.getMethod()+"] on controller ["+controller+"]. That method does not exist.");
}
hasEventParameter = false;
}
else
{
throw new CruxGeneratorException("View ["+view.getId()+"] tries to invoke the method ["+event.getMethod()+"] on controller ["+controller+"]. That method does not exist.");
}
}
checkExposedMethod(event, controller, exposedMethod, context);
return hasEventParameter;