throw new UnableToCompleteException();
}
}
// Start composing the class
ClassSourceFileComposerFactory composerFactory = new ClassSourceFileComposerFactory(
packageName, implClassName);
// Setup required imports
// TODO cleanup imports
composerFactory.addImport(GWT.class.getCanonicalName());
composerFactory.addImport(Inject.class.getCanonicalName()); // Obsolete?
composerFactory.addImport(Provider.class.getCanonicalName());
composerFactory.addImport(AsyncProvider.class.getCanonicalName());
composerFactory.addImport(EventBus.class.getCanonicalName());
composerFactory.addImport(StandardProvider.class.getCanonicalName());
composerFactory.addImport(CodeSplitProvider.class.getCanonicalName());
composerFactory.addImport(CodeSplitBundleProvider.class.getCanonicalName());
composerFactory.addImport(ProxyFailureHandler.class.getCanonicalName());
composerFactory.addImport(proxyImplClassName);
composerFactory.addImport(proxyPlaceImplClassName);
composerFactory.addImport(RevealContentHandler.class.getCanonicalName());
composerFactory.addImport(delayedBindClassName);
composerFactory.addImport(tabContentProxyPlaceImplClassName);
composerFactory.addImport(DelayedBindRegistry.class.getCanonicalName());
composerFactory.addImport(Ginjector.class.getCanonicalName());
composerFactory.addImport(RevealContentEvent.class.getCanonicalName()); // Obsolete?
composerFactory.addImport(Scheduler.class.getCanonicalName());
composerFactory.addImport(Command.class.getCanonicalName());
composerFactory.addImport(AsyncCallback.class.getCanonicalName());
composerFactory.addImport(TabData.class.getCanonicalName());
composerFactory.addImport(TabDataBasic.class.getCanonicalName());
if (title != null || titleFunctionDescription != null) {
composerFactory.addImport(GetPlaceTitleEvent.class.getCanonicalName());
composerFactory.addImport(AsyncCallback.class.getCanonicalName());
composerFactory.addImport(Throwable.class.getCanonicalName());
}
// Sets interfaces and superclass
composerFactory.addImplementedInterface(proxyInterface.getParameterizedQualifiedSourceName());
composerFactory.addImplementedInterface(delayedBindClassName);
if (nameToken == null) {
// Not a place
if (tabContainerClass == null) {
// Standard proxy (not a Place, not a TabContentProxy)
composerFactory.setSuperclass(proxyImplClassName + "<"
+ presenterClassName + ">");
} else {
if (tabNameToken == null) {
logger.log(TreeLogger.ERROR, "Class '" + presenterClassName
+ "' is not a Place, its @TabInfo needs to define nameToken.",
null);
throw new UnableToCompleteException();
}
// TabContentProxy (not a Place, but a TabContentProxy)
composerFactory.setSuperclass(tabContentProxyImplClassName + "<"
+ presenterClassName + ">");
}
} else {
// A place
if (tabContainerClass == null) {
// Place (but not a TabContentProxy)
composerFactory.setSuperclass(proxyPlaceImplClassName + "<"
+ presenterClassName + ">");
} else {
if (tabNameToken != null) {
logger.log(
TreeLogger.ERROR,
"Class '"
+ presenterClassName
+ "' has a @NameToken and its @TabInfo has a nameToken, unsupported.",
null);
throw new UnableToCompleteException();
}
// Place and TabContentProxy
composerFactory.setSuperclass(tabContentProxyPlaceImplClassName + "<"
+ presenterClassName + ">");
}
}
// Add all implemented handlers
for (ProxyEventDescription desc : proxyEvents) {
composerFactory.addImplementedInterface(desc.handlerFullName);
}
// Get a source writer
SourceWriter writer = composerFactory.createSourceWriter(ctx, printWriter);
// Private variable to store the gingector
writer.println();
writer.println("private " + ginjectorClassName + " ginjector;");