Package com.google.gdt.eclipse.designer.model.widgets.support

Examples of com.google.gdt.eclipse.designer.model.widgets.support.IDevModeBridge


  /**
   * Adds <code>JField</code> with given name and @UiField annotation into "form" <code>JType</code>
   * .
   */
  private void addFormJField(Class<?> componentClass, String name) throws Exception {
    IDevModeBridge bridge = m_context.getState().getDevModeBridge();
    ClassLoader devClassLoader = bridge.getDevClassLoader();
    // prepare "form" JType
    Object formType = bridge.findJType(m_context.getFormType().getFullyQualifiedName());
    // prepare @UiField annotation instance
    Class<?> uiFieldAnnotationClass =
        devClassLoader.loadClass("com.google.gwt.uibinder.client.UiField");
    java.lang.annotation.Annotation annotation =
        (java.lang.annotation.Annotation) Proxy.newProxyInstance(
            uiFieldAnnotationClass.getClassLoader(),
            new Class[]{uiFieldAnnotationClass},
            new InvocationHandler() {
              public Object invoke(Object proxy, Method method, Object[] args) {
                return Boolean.TRUE;
              }
            });
    // add new JField
    Object newField;
    {
      Constructor<?> fieldConstructor;
      Class<?> fieldClass;
      if (m_context.getState().getVersion().isHigherOrSame(Utils.GWT_2_2)) {
        fieldClass = devClassLoader.loadClass("com.google.gwt.dev.javac.typemodel.JField");
        fieldConstructor =
            ReflectionUtils.getConstructorBySignature(
                fieldClass,
                "<init>(com.google.gwt.dev.javac.typemodel.JClassType,java.lang.String,java.util.Map)");
      } else {
        fieldClass = devClassLoader.loadClass("com.google.gwt.core.ext.typeinfo.JField");
        fieldConstructor =
            ReflectionUtils.getConstructorBySignature(
                fieldClass,
                "<init>(com.google.gwt.core.ext.typeinfo.JClassType,java.lang.String,java.util.Map)");
      }
      newField =
          fieldConstructor.newInstance(
              formType,
              name,
              ImmutableMap.of(uiFieldAnnotationClass, annotation));
    }
    // set "widget" JType for JField
    Object widgetType = bridge.findJType(ReflectionUtils.getCanonicalName(componentClass));
    ReflectionUtils.invokeMethod(
        newField,
        "setType(com.google.gwt.core.ext.typeinfo.JType)",
        widgetType);
  }
View Full Code Here

TOP

Related Classes of com.google.gdt.eclipse.designer.model.widgets.support.IDevModeBridge

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.