Package net.jangaroo.exml.json

Examples of net.jangaroo.exml.json.JsonObject


  private void ifContainerDefaultsThenExtractXtype(JsonObject jsonObject, ConfigClass configClass, String elementName) {
    // special case: extract xtype from <defaults> as <defaultType>!
    if (EXT_CONTAINER_DEFAULTS_PROPERTY.equals(elementName) && isContainerConfig(configClass)) {
      Object value = jsonObject.get(elementName);
      if (value instanceof JsonObject) {
        JsonObject jsonObjectValue = (JsonObject) value;
        // there are two ways an xtype can be specified:
        // a) as an EXML config class wrapping the JSON object:
        String xtype = jsonObjectValue.getWrapperClass();
        if (xtype != null) {
          jsonObjectValue.settingWrapperClass(null);
        } else {
          // b) as an "xtype" attribute:
          xtype = (String) jsonObjectValue.remove(ConfigClassType.XTYPE.getType());
        }
        if (xtype != null) {
          jsonObject.set(EXT_CONTAINER_DEFAULT_TYPE_PROPERTY, xtype);
        }
      }
View Full Code Here


    }
    return configClass;
  }

  private void parseJavaScriptObjectProperty(JsonObject jsonObject, Element propertyElement) {
    JsonObject propertyObject = new JsonObject();

    setUntypedAttributes(propertyElement, propertyObject);
    for (Element child : getChildElements(propertyElement)) {
      parseJavaScriptObjectProperty(propertyObject, child);
    }
View Full Code Here

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

      return "{" + textContent.trim() + "}";
    } else {
      if (!exmlObjectNode.hasAttributes()) {
        return null;
      }
      JsonObject object = new JsonObject();
      setUntypedAttributes(exmlObjectNode, object);
      return object;
    }
  }
View Full Code Here

    ExmlModel model = exmlToModelParser.parse(getFile("/exmlparser/AllElements.exml"));
    Assert.assertEquals(new HashSet<String>(Arrays.asList("exmlparser.config.allElements", "ext.Panel", "ext.MessageBox")),
            model.getImports());
    Assert.assertEquals("ext.Panel", model.getSuperClassName());

    JsonObject expectedJsonObject = new JsonObject(
            "layout", "{config.myLayout}",
            "title", "I am a panel",
            "defaults", new JsonObject("layout","border"),
            "layoutConfig", new JsonObject(
                    "bla", "blub",
                    "anchor", new JsonObject("style", "test"),
                    "border", new JsonObject("type", "solid")
            ),
            "items", new JsonArray(
                    new JsonObject(
                            "xtype", "button",
                            "text", "Save"
                    ),
                    "{{xtype: \"editortreepanel\"}}"
            ),
            "menu", new JsonArray(
                    new JsonObject(
                            "xtype", "menuitem",
                            "text", "juhu1"
                    ),
                    new JsonObject(
                            "xtype", "menuitem",
                            "text", "juhu2"
                    ),
                    new JsonObject(
                            "xtype", "menuitem",
                            "text", "juhu3"
                    )
            ),
            "tools", new JsonArray(
                    new JsonObject(
                            "handler", "{function(x){return ''+x;}}",
                            "id", "gear"
                    )
            ),
            "plugins", new JsonArray(
                    new JsonObject(
                            "ptype", "aplugin"
                    ),
                    new JsonObject(
                            "ptype", "aplugin"
                    )
            ),
            "layout2", new JsonObject(
                    "type", "a"
            )
    );
    System.out.println(model.getJsonObject().toString(2));
    Assert.assertEquals(expectedJsonObject.toString(2), model.getJsonObject().toString(2));
  }
View Full Code Here

    ExmlToModelParser exmlToModelParser = new ExmlToModelParser(getConfigClassRegistry());

    ExmlModel model = exmlToModelParser.parse(getFile("/exmlparser/TestNumber.exml"));
    Assert.assertEquals("ext.Panel", model.getSuperClassName());

    JsonObject expectedJsonObject = new JsonObject(
            "items", new JsonArray(
                    new JsonObject(
                            "xtype", "panel",
                            "id", "foo",
                             "x", 100.0
                    ),
                    new JsonObject(
                            "xtype", "panel",
                            "id", "foo",
                            "x", 1.5
                    ),
                    new JsonObject(
                            "xtype", "panel",
                            "id", "foo",
                            "x", 1.0
                    ),
                    new JsonObject(
                            "xtype", "panel",
                            "id", "foo",
                            "x", -1.5
                    ),
                    new JsonObject(
                            "xtype", "panel",
                            "id", "foo",
                            "x", 3.0
                    )
            )
    );
    System.out.println(model.getJsonObject().toString(2));
    Assert.assertEquals(expectedJsonObject.toString(2), model.getJsonObject().toString(2));
  }
View Full Code Here

    ExmlToModelParser exmlToModelParser = new ExmlToModelParser(getConfigClassRegistry());

    ExmlModel model = exmlToModelParser.parse(getFile("/exmlparser/TestTrueFalse.exml"));
    Assert.assertEquals("ext.Panel", model.getSuperClassName());

    JsonObject expectedJsonObject = new JsonObject(
            "items", new JsonArray(
                    new JsonObject(
                            "xtype", "panel",
                            "id", "foo",
                             "visible", true
                    ),
                    new JsonObject(
                            "xtype", "panel",
                            "id", "foo",
                            "visible", false
                    ),
                    new JsonObject(
                            "xtype", "panel",
                            "id", "foo",
                            "visible", true
                    ),
                    new JsonObject(
                            "xtype", "panel",
                            "id", "foo",
                            "visible", false
                    )
            )
    );
    System.out.println(model.getJsonObject().toString(2));
    Assert.assertEquals(expectedJsonObject.toString(2), model.getJsonObject().toString(2));
  }
View Full Code Here

    ExmlToModelParser exmlToModelParser = new ExmlToModelParser(getConfigClassRegistry());

    ExmlModel model = exmlToModelParser.parse(getFile("/exmlparser/TestArrayAttribute.exml"));
    Assert.assertEquals("ext.Panel", model.getSuperClassName());

    JsonObject expectedJsonObject = new JsonObject(
            "items", "{config.myItems}",
            "tools", new JsonArray("tools")
    );
    System.out.println(model.getJsonObject().toString(2));
    Assert.assertEquals(expectedJsonObject.toString(2), model.getJsonObject().toString(2));
  }
View Full Code Here

    ExmlToModelParser exmlToModelParser = new ExmlToModelParser(getConfigClassRegistry());

    ExmlModel model = exmlToModelParser.parse(getFile("/exmlparser/TestActions.exml"));
    Assert.assertEquals("ext.Panel", model.getSuperClassName());

    JsonObject expectedJsonObject = new JsonObject(
            "baseAction", "{net.jangaroo.ext.create(ext.config.action,{disabled: false})}"
    );
    System.out.println(model.getJsonObject().toString(2));
    Assert.assertEquals(expectedJsonObject.toString(2), model.getJsonObject().toString(2));
  }
View Full Code Here

    ExmlToModelParser exmlToModelParser = new ExmlToModelParser(getConfigClassRegistry());

    ExmlModel model = exmlToModelParser.parse(getFile("/exmlparser/TestUntyped.exml"));
    Assert.assertEquals("ext.Panel", model.getSuperClassName());

    JsonObject expectedJsonObject = new JsonObject(
            "items", new JsonArray(
                    new JsonObject(
                            "xtype", "panel",
                             "untyped", "text"
                    ),
                    new JsonObject(
                            "xtype", "panel",
                            "untyped", true
                    ),
                    new JsonObject(
                            "xtype", "panel",
                            "untyped", false
                    ),
                    new JsonObject(
                            "xtype", "panel",
                            "untyped", 1.0
                    ),
                    new JsonObject(
                            "xtype", "panel",
                            "untyped", -1.5
                    ),
                    new JsonObject(
                            "xtype", "panel",
                            "untyped", 3.0
                    ),
                    new JsonObject(
                            "xtype", "panel",
                            "untyped", "3L"
                    ),
                    new JsonObject(
                            "xtype", "panel",
                            "untyped", "42x"
                    )

            )
    );
    System.out.println(model.getJsonObject().toString(2));
    Assert.assertEquals(expectedJsonObject.toString(2), model.getJsonObject().toString(2));
  }
View Full Code Here

TOP

Related Classes of net.jangaroo.exml.json.JsonObject

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.