Integer tabPriority = null;
String tabLabel = null;
TabInfoFunctionDescription tabInfoFunctionDescription = null;
String tabNameToken = null;
if (proxyInterface.isAssignableTo(tabContentProxyClass)) {
TabInfo tabInfoAnnotation = proxyInterface.getAnnotation(TabInfo.class);
tabInfoFunctionDescription = findTabInfoFunction(
logger, presenterClass, presenterClassName, ginjectorClassName,
ginjectorClass);
// Ensure @TabInfo is there exactly once
if (tabInfoAnnotation != null && tabInfoFunctionDescription != null) {
logger.log(TreeLogger.ERROR, "Presenter " + presenterClassName
+ " contains both a proxy and a method annotated with @' +"
+ TabInfo.class.getSimpleName() + ". This is illegal.", null);
throw new UnableToCompleteException();
}
if (tabInfoFunctionDescription != null) {
tabInfoAnnotation = tabInfoFunctionDescription.annotation;
}
if (tabInfoAnnotation == null) {
logger.log(TreeLogger.ERROR, "The proxy for '" + presenterClassName
+ "' is a TabContentProxy, but is not annotated with @' +"
+ TabInfo.class.getSimpleName()
+ " and its presenter has no method annotated with it either.", null);
throw new UnableToCompleteException();
}
// Extract the label if its in TabInfo
if (tabInfoAnnotation.label().length() > 0) {
tabLabel = tabInfoAnnotation.label();
}
if (tabLabel != null && tabInfoFunctionDescription != null) {
logger.log(TreeLogger.ERROR, "The @" + TabInfo.class.getSimpleName()
+ " in " + presenterClassName + " defines the 'label' parameter and"
+ " annotates a method, this is not permitted.", null);
throw new UnableToCompleteException();
}
if (tabLabel == null && tabInfoFunctionDescription == null) {
logger.log(TreeLogger.ERROR, "The @" + TabInfo.class.getSimpleName()
+ " in " + presenterClassName + " does not define the 'label' parameter and"
+ " does not annotate a method, this is not permitted.", null);
throw new UnableToCompleteException();
}
// Extract the label if its in TabInfo (it is a negative integer if not set)
if (tabInfoAnnotation.priority() >= 0) {
tabPriority = tabInfoAnnotation.priority();
}
if (tabPriority != null &&
tabInfoFunctionDescription != null && !tabInfoFunctionDescription.returnString) {
logger.log(TreeLogger.ERROR, "The @" + TabInfo.class.getSimpleName()
+ " in " + presenterClassName + " defines the 'priority' parameter and"
+ " annotates a method returning TabData, this is not permitted.", null);
throw new UnableToCompleteException();
}
if (tabPriority == null &&
(tabInfoFunctionDescription == null || tabInfoFunctionDescription.returnString)) {
logger.log(TreeLogger.ERROR, "The @" + TabInfo.class.getSimpleName()
+ " in " + presenterClassName + " does not define the 'priority' parameter and"
+ " does not annotate a method returning TabData, this is not permitted.", null);
throw new UnableToCompleteException();
}
// Find the container
tabContainerClass = oracle.findType(tabInfoAnnotation.container().getCanonicalName());
if (tabContainerClass == null) {
logger.log(TreeLogger.ERROR, "The container '"
+ tabInfoAnnotation.container().getCanonicalName()
+ "' in the proxy annotation for '" + presenterClassName
+ "' was not found.", null);
throw new UnableToCompleteException();
}
tabContainerClassName = tabContainerClass.getParameterizedQualifiedSourceName();
// Find the name token to use when the tab is clicked
if (tabInfoAnnotation.nameToken().length() > 0) {
tabNameToken = tabInfoAnnotation.nameToken();
}
if (tabNameToken != null && nameToken != null) {
logger.log(TreeLogger.ERROR, "The @" + TabInfo.class.getSimpleName()
+ " in " + presenterClassName + " defines the 'nameToken' parameter but"
+ " its proxy is a place, this is not permitted.", null);