Package org.cruxframework.crux.core.rebind

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


    {
    JClassType resourceType = context.getTypeOracle().findType(resourceClass);
   
      if (resourceType == null)
      {
        throw new CruxGeneratorException("Resource ["+resourceKey+"], declared on View ["+view.getId()+"] could not be found.");
      }
     
      JMethod[] methods = resourceType.getOverridableMethods();
      if (methods != null)
      {
View Full Code Here


   */
  public JSONArray ensureChildren(JSONObject metaElem, boolean acceptsNoChild, String parentWidgetId) throws CruxGeneratorException
  {
    if (!acceptsNoChild && !metaElem.has("_children"))
    {
      throw new CruxGeneratorException("The widget ["+parentWidgetId+"], declared on View ["+getView().getId()+"], must contain at least one child.");
    }
   
    JSONArray children = metaElem.optJSONArray("_children");
    if (acceptsNoChild && children == null)
    {
      return null;
    }

    if (!acceptsNoChild && (children == null || children.length() == 0 || children.opt(0)==null))
    {
      throw new CruxGeneratorException("The widget ["+parentWidgetId+"], declared on View ["+getView().getId()+"], must contain at least one child.");
    }
    return children;
 
View Full Code Here

   */
  public JSONObject ensureFirstChild(JSONObject metaElem, boolean acceptsNoChild, String parentWidgetId) throws CruxGeneratorException
  {
    if (!acceptsNoChild && !metaElem.has("_children"))
    {
      throw new CruxGeneratorException("The widget ["+parentWidgetId+"], declared on View ["+getView().getId()+"], must contain at least one child.");
    }
    JSONArray children = metaElem.optJSONArray("_children");
    if (acceptsNoChild && children == null)
    {
      return null;
    }
    if (!acceptsNoChild && (children == null || children.length() == 0))
    {
      throw new CruxGeneratorException("The widget ["+parentWidgetId+"], declared on view ["+getView().getId()+"], must contain at least one child.");
    }
    JSONObject firstChild = children.optJSONObject(0);
    if (!acceptsNoChild && firstChild == null)
    {
      throw new CruxGeneratorException("The widget ["+parentWidgetId+"], declared on View ["+getView().getId()+"], must contain at least one child.");
    }
    return firstChild;
  }
View Full Code Here

  public String ensureHtmlChild(JSONObject metaElem, boolean acceptsNoChild, String parentWidgetId) throws CruxGeneratorException
  {
    String result = metaElem.optString("_html");
    if (!acceptsNoChild && (result == null || result.length() == 0))
    {
      throw new CruxGeneratorException("The widget ["+parentWidgetId+"], declared on View ["+getView().getId()+"], must contain an inner HTML.");
    }
    if (result != null)
    {
      result = EscapeUtils.quote(result).replace(ViewParser.CRUX_VIEW_PREFIX, "\"+"+getViewVariable()+".getPrefix()+\"");
    }
View Full Code Here

  public String ensureTextChild(JSONObject metaElem, boolean acceptsNoChild, String parentWidgetId, boolean addQuotes) throws CruxGeneratorException
  {
    String result = metaElem.optString("_text");
    if (!acceptsNoChild && (result == null || result.length() == 0))
    {
      throw new CruxGeneratorException("The widget ["+parentWidgetId+"], declared on View ["+getView().getId()+"], must contain a text node child.");
    }
    if (result != null && addQuotes)
    {
      result = EscapeUtils.quote(result);
    }
View Full Code Here

   */
  public String createChildWidget(SourcePrinter out, JSONObject metaElem, WidgetConsumer consumer, boolean allowWrapperForCreatedWidget, WidgetCreatorContext context) throws CruxGeneratorException
  {
    if (!metaElem.has("id"))
    {
      throw new CruxGeneratorException("The id attribute is required for CRUX Widgets. " +
          "On page ["+getView().getId()+"], there is an widget of type ["+viewFactory.getMetaElementType(metaElem)+"] without id.");
    }
    String widgetId = metaElem.optString("id");
    return createChildWidget(out, metaElem, widgetId, viewFactory.getMetaElementType(metaElem), consumer, allowWrapperForCreatedWidget, context);
  }   
View Full Code Here

   */
  public JSONObject ensureWidget(JSONObject metaElem, String parentWidgetId)
  {
    if (!isWidget(metaElem))
    {
      throw new CruxGeneratorException("The widget ["+parentWidgetId+"], declared on View ["+getView().getId()+"], must contain a valid widget as child.");
    }
    return metaElem;
  }
View Full Code Here

  public Class<?> getWidgetClass(String widgetDeclaration)
    {
    WidgetCreatorHelper widgetCreatorHelper = viewFactory.getWidgetCreatorHelper(widgetDeclaration);
    if (widgetCreatorHelper == null)
    {
      throw new CruxGeneratorException("No widget registered for declaration ["+widgetDeclaration+"].");
    }
    return widgetCreatorHelper.getWidgetType();
    }
View Full Code Here

    DeclarativeFactory declarativeFactory = getClass().getAnnotation(DeclarativeFactory.class);
    if (declarativeFactory != null)
    {
      return declarativeFactory.library()+"_"+declarativeFactory.id();
    }
    throw new CruxGeneratorException("Error reading viewFactory declaration.");
  }
View Full Code Here

                attributes.add(createAttributeProcessorWithParser(attr));
              }
            }
            else
            {
              throw new CruxGeneratorException("Error generating widget factory. Invalid attribute name: ["+attrName+"].");
            }
          }
        }
      }
          Class<?> superclass = factoryClass.getSuperclass();
          if (superclass!= null && !superclass.equals(Object.class))
          {
            scanAttributes(superclass, attributes, added);
          }
          Class<?>[] interfaces = factoryClass.getInterfaces();
          for (Class<?> interfaceClass : interfaces)
          {
            scanAttributes(interfaceClass, attributes, added);
          }
        }
        catch (Exception e)
        {
          throw new CruxGeneratorException(e.getMessage(), e);
        }
  } 
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.