示例#1
0
 /** We should remove enclosing "Cell" element if it has no attributes. */
 public void test_propertyCell_removeElement() throws Exception {
   XmlObjectInfo panel =
       parse(
           "// filler filler filler filler filler",
           "<ui:UiBinder>",
           "  <g:HorizontalPanel>",
           "    <g:Cell width='100px'>",
           "      <g:Button/>",
           "    </g:Cell>",
           "  </g:HorizontalPanel>",
           "</ui:UiBinder>");
   refresh();
   WidgetInfo button = (WidgetInfo) panel.getChildren().get(0);
   // "width"
   {
     Property property = PropertyUtils.getByPath(button, "Cell/width");
     // remove value
     property.setValue(Property.UNKNOWN_VALUE);
     assertXML(
         "// filler filler filler filler filler",
         "<ui:UiBinder>",
         "  <g:HorizontalPanel>",
         "    <g:Button/>",
         "  </g:HorizontalPanel>",
         "</ui:UiBinder>");
     // no value
     assertFalse(property.isModified());
     assertEquals(Property.UNKNOWN_VALUE, property.getValue());
   }
 }
 ////////////////////////////////////////////////////////////////////////////
 //
 // Constructor
 //
 ////////////////////////////////////////////////////////////////////////////
 public UiBinderTagResolver(XmlObjectInfo rootObject) {
   super(rootObject.getCreationSupport().getElement().getRoot());
   rootObject.addBroadcastListener(
       new XmlObjectResolveTag() {
         public void invoke(XmlObjectInfo object, Class<?> clazz, String[] namespace, String[] tag)
             throws Exception {
           resolveTag(object, clazz, namespace, tag);
         }
       });
 }
 /** @return <code>true</code> if given {@link XmlObjectInfo} is Android. */
 public static boolean isAndroid(XmlObjectInfo object) {
   EditorContext context = object.getContext();
   return isAndroid(context);
 }