xapi.gwt.ui.autoui.client.UserInterfaceFactoryGwt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of xapi-gwt Show documentation
Show all versions of xapi-gwt Show documentation
This module exists solely to package all other gwt modules into a single
uber jar. This makes deploying to non-mavenized targets much easier.
Of course, you would be wise to inherit your dependencies individually;
the uber jar is intended for projects like collide,
which have complex configuration, and adding many jars would be a pain.
The newest version!
package xapi.gwt.ui.autoui.client;
import java.lang.reflect.AnnotatedElement;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
import xapi.annotation.inject.InstanceOverride;
import xapi.log.X_Log;
import xapi.log.api.LogLevel;
import xapi.platform.GwtPlatform;
import xapi.ui.autoui.api.BeanValueProvider;
import xapi.ui.autoui.api.DoNotIndex;
import xapi.ui.autoui.api.UiOptions;
import xapi.ui.autoui.api.UiRendererOptions;
import xapi.ui.autoui.api.UiRenderingContext;
import xapi.ui.autoui.api.UserInterfaceFactory;
import xapi.ui.autoui.impl.AbstractUserInterfaceFactory;
import xapi.util.X_Debug;
import xapi.util.api.ConvertsValue;
@GwtPlatform
@InstanceOverride(implFor=UserInterfaceFactory.class)
public class UserInterfaceFactoryGwt extends AbstractUserInterfaceFactory{
private static final int MAX_DEPTH = 10;
@Override
protected UiRenderingContext[] getOptions(Class> type) {
List options = new ArrayList();
BeanValueProvider values = getBeanProvider(type);
// Check the package for options
Package pkg = type.getPackage();
if (pkg != null && pkg.isAnnotationPresent(UiOptions.class)) {
options.addAll(extractRenderingContext(pkg.getAnnotation(UiOptions.class), values));
}
if (type.isAnnotationPresent(UiOptions.class)) {
UiOptions opts = type.getAnnotation(UiOptions.class);
if (opts.fields().length > 0) {
values.setChildKeys(opts.fields());
}
}
// check for enclosing types/methods?
Class> check = type;
while (check != null) {
// Check the type for options
addAllRendererContexts(options, check, values);
check = check.getEnclosingClass();
}
for (Method m : type.getMethods()) {
addAllRendererContexts(options, m, values);
}
return options.toArray(new UiRenderingContext[options.size()]);
}
protected void addAllRendererContexts(List options, AnnotatedElement element, BeanValueProvider values) {
if (element.isAnnotationPresent(UiOptions.class)) {
options.addAll(extractRenderingContext(element.getAnnotation(UiOptions.class), values));
}
if (element.isAnnotationPresent(UiRendererOptions.class)) {
options.addAll(extractRenderingContext(element.getAnnotation(UiRendererOptions.class), values,
element instanceof Method ? getNameFromMethod((Method)element) : null ));
}
}
@Override
protected void recursiveAddBeanValues(BeanValueProvider bean, Class> cls,
final ConvertsValue