Package net.jangaroo.exml.model

Examples of net.jangaroo.exml.model.ConfigClass


import java.util.Set;

public class ConfigClassBuilderTest {
  @Test
  public void testBuildConfigClass() throws Exception {
    ConfigClass configClass = buildConfigClass("/testNamespace/config/testComponent.as");
    Assert.assertEquals("testNamespace.config", configClass.getPackageName());
    Assert.assertEquals("testComponent", configClass.getName());
    Assert.assertEquals("testPackage.TestComponent", configClass.getComponentClassName());
    Assert.assertEquals("This is a TestComponent with panel as baseclass. <p>This class serves as a typed config object for the constructor of the class <code>testPackage.TestComponent</code>. It defines the EXML element <code>&lt;tc:testComponent></code> with <code>xmlns:tc=\"exml:testNamespace.config\"</code>.</p> <p>Using this config class also takes care of registering the target class under the xtype <code>\"testNamespace.config.testComponent\"</code> with Ext JS.</p> @see testPackage.TestComponent @see ext.Panel", configClass.getDescription());
    Set<String> attributeNames = new HashSet<String>();
    for (ConfigAttribute configAttribute : configClass.getCfgs()) {
      attributeNames.add(configAttribute.getName());
      if ("propertyOne".equals(configAttribute.getName())) {
        Assert.assertEquals("Boolean", configAttribute.getType());
        Assert.assertEquals("Some Boolean property @see Boolean", configAttribute.getDescription());
      }
View Full Code Here


    Assert.assertEquals(new HashSet<String>(Arrays.asList("propertyOne", "propertyTwo", "propertyThree", "propertyFour", "propertyFive")), attributeNames);
  }

  @Test
  public void testBuildNonConfigClass() throws Exception {
    ConfigClass configClass = buildConfigClass("/testNamespace/config/NonConfig.as");
    Assert.assertNull(configClass);
  }
View Full Code Here

  public ExmlModel parse(File file) throws IOException, SAXException {
    ExmlModel model = new ExmlModel();
    String qName = CompilerUtils.qNameFromFile(registry.getConfig().findSourceDir(file), file);
    String className = CompilerUtils.className(qName);
    model.setClassName(ExmlUtils.createComponentClassName(className));
    ConfigClass configClassByName = registry.getConfigClassByName(registry.getConfig().getConfigClassPackage() + "." + ConfigClass.createConfigClassName(className));
    model.setConfigClass(configClassByName);
    model.setPackageName(CompilerUtils.packageName(qName));

    BufferedInputStream inputStream = null;
    try {
View Full Code Here

    String superFullClassName = createFullConfigClassNameFromNode(componentNode);
    if (superFullClassName.equals(model.getConfigClass().getFullName())) {
      int lineNumber = getLineNumber(componentNode);
      throw  new ExmlcException("Cyclic inheritance error: super class and this component are the same!. There is something wrong!", lineNumber);
    }
    ConfigClass superConfigClass = getConfigClassByName(superFullClassName, componentNode);
    String superComponentClassName = superConfigClass.getComponentClassName();
    if (model.getSuperClassName() == null) {
      model.setSuperClassName(superComponentClassName);
    }
    //but we still need the import
    model.addImport(superComponentClassName);
View Full Code Here

      jsonObject.set(propertyName, childObjects.get(0));
    }
  }

  private ConfigClass getConfigClassByName(String className, Node errorNode) {
    ConfigClass configClass = registry.getConfigClassByName(className);
    if (configClass == null) {
      int lineNumber = getLineNumber(errorNode);
      throw new ExmlcException("unknown type '" + className + "'", lineNumber);
    }
    return configClass;
View Full Code Here

    }
    return result;
  }

  private ConfigAttribute getCfgByName(ConfigClass configClass, String attributeName) {
    ConfigClass current = configClass;
    while (current != null) {
      ConfigAttribute configAttribute = current.getCfgByName(attributeName);
      if (configAttribute != null) {
        return configAttribute;
      }
      String superClassName = current.getSuperClassName();
      if (superClassName == null || superClassName.equals("Object")) {
        break;
      }
      current = registry.getConfigClassByName(superClassName);
    }
View Full Code Here

      Object value;
      if (ExmlUtils.isExmlNamespace(arrayItemNode.getNamespaceURI()) && Exmlc.EXML_OBJECT_NODE_NAME.equals(arrayItemNode.getLocalName())) {
        value = parseExmlObjectNode(arrayItemNode);
      } else {
        String arrayItemClassName = createFullConfigClassNameFromNode(arrayItemNode);
        ConfigClass configClass = getConfigClassByName(arrayItemClassName, arrayItemNode);

        JsonObject arrayItemJsonObject = new JsonObject();
        if (configClass.getType() == null) {
          // Everything not a component, plugin or layout must be created immediately
          // by using net.jangaroo.ext.create() with its configClass and the config:
          arrayItemJsonObject.settingConfigClass(configClass.getFullName());
          model.addImport(configClass.getFullName());
          model.addImport(configClass.getComponentClassName());
          model.addImport(JsonObject.NET_JANGAROO_EXT_CREATE);
        } else {
          if (arrayItemClassName.startsWith(EXT_CONFIG_PREFIX)) {
            // Ext classes are always loaded. We can use the type string directly.
            arrayItemJsonObject.set(configClass.getType().getExtTypeAttribute(), configClass.getTypeValue());
          } else {
            arrayItemJsonObject.settingWrapperClass(configClass.getFullName());
            model.addImport(configClass.getFullName());
            model.addImport(configClass.getComponentClassName());
          }
        }

        fillModelAttributes(model, arrayItemJsonObject, arrayItemNode, configClass);
        value = arrayItemJsonObject;
View Full Code Here

    return configClass.getComponentClassName() == null ? null : configClass;
  }

  @Override
  public void visitCompilationUnit(CompilationUnit compilationUnit) throws IOException {
    configClass = new ConfigClass();
    compilationUnit.getPackageDeclaration().visit(this);
    for (AstNode node : compilationUnit.getDirectives()) {
      node.visit(new ClassAnnotationsVisitor());
    }
    compilationUnit.getPrimaryDeclaration().visit(this);
View Full Code Here

public class ConfigClassRegistryTest extends AbstractExmlTest {
  @Test
  public void testScanInitially() throws Exception {
    setUp("testNamespace.config");

    ConfigClass configClass = getConfigClassRegistry().getConfigClassByName("testNamespace.config.testLabel");
    Assert.assertNotNull(configClass);
    Assert.assertEquals("testNamespace.config", configClass.getPackageName());
    Assert.assertEquals("testPackage.TestLabel", configClass.getComponentClassName());
    ConfigClass labelConfigClass = getConfigClassRegistry().getConfigClassByName("ext.config.label");
    Assert.assertNotNull(labelConfigClass);
    Assert.assertEquals("ext.config.label", labelConfigClass.getFullName());
    Assert.assertEquals(labelConfigClass, configClass.getSuperClass());
    Assert.assertEquals(1, configClass.getCfgs().size());
  }
View Full Code Here

  @Test
  public void testGenerateFromExml() throws Exception {
    setUp("testNamespace.config");

    ConfigClass configClass = getConfigClassRegistry().getConfigClassByName("testNamespace.config.testLabel");
    Assert.assertNotNull(configClass);
    Assert.assertEquals("testNamespace.config", configClass.getPackageName());
    Assert.assertEquals("testPackage.TestLabel", configClass.getComponentClassName());
    Assert.assertEquals(1, configClass.getCfgs().size());

    // 2nd try should return the same object
    Assert.assertEquals(configClass, getConfigClassRegistry().getConfigClassByName("testNamespace.config.testLabel"));
  }
View Full Code Here

TOP

Related Classes of net.jangaroo.exml.model.ConfigClass

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.