Package org.cruxframework.crux.core.rebind

Examples of org.cruxframework.crux.core.rebind.CruxGeneratorException


    {
      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


   */
  private static void checkExposedMethod(Event event, String controller, JMethod exposedMethod, GeneratorContext context)
  {
    if (exposedMethod.getAnnotation(Expose.class) == null && exposedMethod.getAnnotation(Factory.class) == null)
      {
        throw new CruxGeneratorException(" Method ["+event.getMethod()+"] of Controller ["+controller+"] is not exposed, so it can not be called from crux.xml pages.");
      }

    JClassType runtimeExceptionType = context.getTypeOracle().findType(RuntimeException.class.getCanonicalName());

      JClassType[] methodThrows = exposedMethod.getThrows();
      if (methodThrows != null)
      {
        for (JClassType exception : methodThrows)
        {
          if (!exception.isAssignableTo(runtimeExceptionType))
          {
            throw new CruxGeneratorException("Method ["+event.getMethod()+"] of Controller ["+controller+"] can not be exposed. It can throw a checked exception.");
          }
      }
      }
  }
View Full Code Here

      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());
View Full Code Here

     */
    void processChild(SourcePrinter out, WidgetCreatorContext context, String childName)
    {
      if (!childrenProcessors.containsKey(childName))
      {
        throw new CruxGeneratorException("Can not find ChildProcessor for ["+childName+"].");
      }
      childrenProcessors.get(childName).processChild(out, context);
    }
View Full Code Here

  protected JClassType getDataObject(WidgetCreatorContext context)
    {
    String dataObject = context.readWidgetProperty("dataObject");
    if (StringUtils.isEmpty(dataObject))
    {
      throw new CruxGeneratorException("Widget ["+context.getWidgetId()+"] on view ["+getView().getId()+"] must inform the dataObject to bind into the declared DataProvider");
    }
   
    String dataObjectClass = DataObjects.getDataObject(dataObject);
    if (StringUtils.isEmpty(dataObjectClass))
    {
      throw new CruxGeneratorException("Widget ["+context.getWidgetId()+"] on view ["+getView().getId()+"] informed an invalid dataObject. Can not found the informed value");
    }
    JClassType dtoType = getContext().getTypeOracle().findType(dataObjectClass);
    return dtoType;
    }
View Full Code Here

        creatorHelpers.put(widgetType, creatorHelper);
          }
        }
        catch (Exception e)
        {
          throw new CruxGeneratorException("Error retrieveing widgetFactory for type ["+widgetType+"].",e);
        }
    return creators.get(widgetType);
  }
View Full Code Here

        throws CruxGeneratorException
  {
    WidgetCreator<?> widgetFactory = getWidgetCreator(widgetType);
    if (widgetFactory == null)
    {
      throw new CruxGeneratorException("Can not found widgetFactory for type: ["+widgetType+"].");
    }

    String widget;
    if (consumer != null && consumer instanceof LazyCompatibleWidgetConsumer && mustRenderLazily(widgetType, metaElem, widgetId))
    {
      String lazyPanelId = ViewFactoryUtils.getLazyPanelId(widgetId, LazyPanelWrappingType.wrapWholeWidget);
      lazyPanels.add(lazyPanelId);
      widget = lazyFactory.getLazyPanel(printer, metaElem, widgetId, LazyPanelWrappingType.wrapWholeWidget);
      consumer.consume(printer, lazyPanelId, widget, widgetType, metaElem);
      ((LazyCompatibleWidgetConsumer)consumer).handleLazyWholeWidgetCreation(printer, widgetId);
    }
    else
    {
      widget = widgetFactory.createWidget(printer, metaElem, widgetId, consumer);
    }
    if (widget == null)
    {
      throw new CruxGeneratorException("Can not create widget ["+widgetId+"]. Verify the widget type.");
    }

    if (allowWrapperForCreatedWidget)
    {
      // No wrappers
View Full Code Here

        String resourceProperty = resourceParts[1];
        String resourceClassName = Resources.getResource(resourceKey, Device.valueOf(device));
       
        if (!view.useResource(resourceKey))
        {
        throw new CruxGeneratorException("The resource ["+resourceKey+"] is not imported into view ["+view.getId()+"]. Use the useResource atribute of view tag to import it first.");
        }
        String resourceObject = "(("+resourceClassName+")getResource("+EscapeUtils.quote(resourceKey)+"))";
       
        StringBuilder out = new StringBuilder();
      JClassType resourceType = context.getTypeOracle().findType(resourceClassName);
      if (resourceType == null)
      {
        String message = "Resource ["+resourceKey+"] , declared on view ["+view.getId()+"], could not be loaded. "
           + "\n Possible causes:"
           + "\n\t 1. Check if any type or subtype used by resource refers to another module and if this module is inherited in the .gwt.xml file."
           + "\n\t 2. Check if your resource or its members belongs to a client package."
           + "\n\t 3. Check the versions of all your modules."
           ;
        throw new CruxGeneratorException(message);
      }
            try
            {
              JClassUtils.buildGetValueExpression(out, resourceType, resourceProperty, resourceObject, false);
            }
            catch (NoSuchFieldException e)
            {
        throw new CruxGeneratorException("Resource ["+resourceKey+"] , declared on view ["+view.getId()+"], has an invalid expression ["+resourceProperty+"]", e);
            }
      return out.toString();
      }
      else
      {
View Full Code Here

   */
  private void checkDeclaredMessage(String messageClassName, String messageKey, String messageMethod) throws CruxGeneratorException
  {
    if (StringUtils.isEmpty(messageClassName))
    {
      throw new CruxGeneratorException("Message ["+messageKey+"] , declared on view ["+view.getId()+"], not found.");
    }
    else
    {
      JClassType messageClass = context.getTypeOracle().findType(messageClassName);
      if (messageClass == null)
      {
        String message = "Message class ["+messageKey+"] , declared on view ["+view.getId()+"], could not be loaded. "
                 + "\n Possible causes:"
                 + "\n\t 1. Check if any type or subtype used by message refers to another module and if this module is inherited in the .gwt.xml file."
                 + "\n\t 2. Check if your message or its members belongs to a client package."
                 + "\n\t 3. Check the versions of all your modules."
                 ;
        throw new CruxGeneratorException(message);
      }
      else
      {
        if (!hasMethod(messageClass, messageMethod, new JType[]{}))
        {
          throw new CruxGeneratorException("Method ["+messageMethod+"] of message ["+messageKey+"], declared on view ["+view.getId()+"], does not exist in message class ["+messageClassName+"].");
        }
      }
    }
  }
View Full Code Here

   */
  private String createWidget(SourcePrinter printer, JSONObject metaElem, String widgetType)
  {
    if (!metaElem.has("id"))
    {
      throw new CruxGeneratorException("The id attribute is required for CRUX Widgets. " +
          "On page ["+view.getId()+"], there is an widget of type ["+widgetType+"] without id.");
    }
    String widget;

    String widgetId = metaElem.optString("id");
    if (widgetId == null || widgetId.length() == 0)
    {
      throw new CruxGeneratorException("The id attribute is required for CRUX Widgets. " +
          "On page ["+view.getId()+"], there is an widget of type ["+widgetType+"] without id.");
    }

    widget = newWidget(printer, metaElem, widgetId, widgetType);
    if (isAttachToDOM(widgetType))
View Full Code Here

TOP

Related Classes of org.cruxframework.crux.core.rebind.CruxGeneratorException

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.