Package org.cruxframework.crux.core.rebind.screen

Examples of org.cruxframework.crux.core.rebind.screen.Event


     
      out.print(AbstractDataProvider.class.getCanonicalName()+"<"+context.rowDataObject+"> " + context.dataProvider + " = ");
      EvtProcessor.printEvtCall(out, dataProviderFactoryMethod, "loadDataProvider", (String)null, null, this);
      out.println(context.dataProvider+".addDataDisplay("+context.getWidget()+");");

      Event event = EventFactory.getEvent("loadDataProvider", dataProviderFactoryMethod);
      String controller = ClientControllers.getController(event.getController(), getDevice());
      JClassType controllerClass = getContext().getTypeOracle().findType(controller);
      JMethod loadDataProviderMethod = JClassUtils.getMethod(controllerClass, event.getMethod(), new JType[]{});
      if (loadDataProviderMethod == null)
      {
        throw new CruxGeneratorException("DataProvider factory method not found: Controller["+event.getController()+"], Method["+event.getMethod()+"].");
      }
      JType returnType = loadDataProviderMethod.getReturnType();
      if (returnType instanceof JClassType)
      {
        context.asyncDataProvider =
View Full Code Here


     */
    public static void printEvtCall(SourcePrinter out, String eventValue, String eventName,String parameterClassName,
                                String cruxEvent, GeneratorContext context, View view, ControllerAccessHandler controllerAccessHandler,
                                Device device, boolean allowNoParameterCall)
    {
      Event event = EventFactory.getEvent(eventName, eventValue);
      boolean hasEventParameter = checkEvtCall(eventValue, eventName, parameterClassName, context, view, device, allowNoParameterCall);
      out.print(controllerAccessHandler.getControllerExpression(event.getController(), device)+"."+event.getMethod()+ControllerProxyCreator.EXPOSED_METHOD_SUFFIX+"(");
     
      if (hasEventParameter)
      {
        out.print(cruxEvent);
      }
View Full Code Here

     * @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;
View Full Code Here

     * @param cruxEvent
     * @param creator
     */
    public static void printPostProcessingEvtCall(String eventValue, String eventName, Class<?> eventClass, String cruxEvent, WidgetCreator<?> creator)
    {
      Event event = EventFactory.getEvent(eventName, eventValue);

      JClassType eventClassType = creator.getContext().getTypeOracle().findType(eventClass.getCanonicalName());

      if (!creator.getView().useController(event.getController()))
      {
        throw new CruxGeneratorException("Controller ["+event.getController()+"] , used on view ["+creator.getView().getId()+"], was not declared on this view. Use the useController attribute to import the controller into this view.");
      }
      String controller = ClientControllers.getController(event.getController(), creator.getDevice());
      if (controller == null)
      {
        throw new CruxGeneratorException("Controller ["+event.getController()+"] , declared on view ["+creator.getView().getId()+"], not found.");
      }

      boolean hasEventParameter = true;
      JClassType controllerClass = creator.getContext().getTypeOracle().findType(controller);
      if (controllerClass == null)
      {
      String message = "Controller class ["+controller+"] , declared on view ["+creator.getView().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)
      {
      exposedMethod = JClassUtils.getMethod(controllerClass, event.getMethod(), new JType[]{});
        if (exposedMethod == null)
        {
            throw new CruxGeneratorException("View ["+creator.getView().getId()+"] tries to invoke the method ["+event.getMethod()+"] on controller ["+controller+"]. That method does not exist.");
        }
        hasEventParameter = false;
      }

      checkExposedMethod(event, controller, exposedMethod, creator.getContext());

        creator.printlnPostProcessing(creator.getControllerAccessorHandler().getControllerExpression(event.getController(), creator.getDevice())+"."+event.getMethod()+ControllerProxyCreator.EXPOSED_METHOD_SUFFIX+"(");

      if (hasEventParameter)
      {
        creator.printlnPostProcessing(cruxEvent);
      }
View Full Code Here

   *
   * @param printer
   */
  private void processCloseEvt(SourcePrinter printer)
    {
      Event onClose = view.getEvent("onClose");
    if (onClose != null)
    {
      printer.println(viewVariable+".addWindowCloseHandler(new "+CloseHandler.class.getCanonicalName()+"<Window>(){");
      printer.println("public void onClose("+CloseEvent.class.getCanonicalName()+"<Window> event){");

      EvtProcessor.printEvtCall(printer, onClose.getController()+"."+onClose.getMethod(), "onClose",
          CloseEvent.class, "event", context, view, getControllerAccessHandler(), Device.valueOf(device));

      printer.println("}");
      printer.println("});");
    }
View Full Code Here

   *
   * @param printer
   */
  private void processClosingEvt(SourcePrinter printer)
    {
      Event onClosing = view.getEvent("onClosing");
    if (onClosing != null)
    {
      printer.println(viewVariable+".addWindowClosingHandler(new Window.ClosingHandler(){");
      printer.println("public void onWindowClosing("+ClosingEvent.class.getCanonicalName()+" event){");

      EvtProcessor.printEvtCall(printer, onClosing.getController()+"."+onClosing.getMethod(), "onClosing",
            ClosingEvent.class, "event", context, view, getControllerAccessHandler(), Device.valueOf(device));

      printer.println("}");
      printer.println("});");
    }
View Full Code Here

   *
   * @param printer
   */
  private void processHistoryChangedEvt(SourcePrinter printer)
    {
      Event onHistoryChanged = view.getEvent("onHistoryChanged");
    if (onHistoryChanged != null)
    {
      printer.println(viewVariable+".addWindowHistoryChangedHandler(new "+ValueChangeHandler.class.getCanonicalName()+"<String>(){");
      printer.println("public void onValueChange("+ValueChangeEvent.class.getCanonicalName()+"<String> event){");

      EvtProcessor.printEvtCall(printer, onHistoryChanged.getController()+"."+onHistoryChanged.getMethod(),
          "onHistoryChanged", ValueChangeEvent.class, "event", context, view, getControllerAccessHandler(), Device.valueOf(device));

      printer.println("}");
      printer.println("});");
    }
View Full Code Here

   *
   * @param printer
   */
  private void processLoadEvt(SourcePrinter printer)
  {
      Event onLoad = view.getEvent("onLoad");
    if (onLoad != null)
    {
      printer.println(viewVariable+".addViewLoadHandler(new "+ViewLoadHandler.class.getCanonicalName()+"(){");
      printer.println("public void onLoad("+ViewLoadEvent.class.getCanonicalName()+" event){");

      EvtProcessor.printEvtCall(printer, onLoad.getController()+"."+onLoad.getMethod(),
          "onLoad", ViewLoadEvent.class, "event", context, view, getControllerAccessHandler(), Device.valueOf(device));

      printer.println("}");
      printer.println("});");
    }
View Full Code Here

   *
   * @param printer
   */
  private void processUnloadEvt(SourcePrinter printer)
  {
      Event onUnload = view.getEvent("onUnload");
    if (onUnload != null)
    {
      printer.println(viewVariable+".addViewUnloadHandler(new "+ViewUnloadHandler.class.getCanonicalName()+"(){");
      printer.println("public void onUnload("+ViewUnloadEvent.class.getCanonicalName()+" event){");

      EvtProcessor.printEvtCall(printer, onUnload.getController()+"."+onUnload.getMethod(),
          "onUnload", ViewUnloadEvent.class, "event", context, view, getControllerAccessHandler(), Device.valueOf(device));

      printer.println("}");
      printer.println("});");
    }
View Full Code Here

   *
   * @param printer
   */
  private void processActivateEvt(SourcePrinter printer)
  {
      Event onActivate = view.getEvent("onActivate");
    if (onActivate != null)
    {
      printer.println(viewVariable+".addViewActivateHandler(new "+ViewActivateHandler.class.getCanonicalName()+"(){");
      printer.println("public void onActivate("+ViewActivateEvent.class.getCanonicalName()+" event){");

      EvtProcessor.printEvtCall(printer, onActivate.getController()+"."+onActivate.getMethod(),
          "onActivate", ViewActivateEvent.class, "event", context, view, getControllerAccessHandler(), Device.valueOf(device));

      printer.println("}");
      printer.println("});");
    }
View Full Code Here

TOP

Related Classes of org.cruxframework.crux.core.rebind.screen.Event

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.