Example #1
0
 public void test_propertyCell_noElement() throws Exception {
   parse(
       "// filler filler filler filler filler",
       "<ui:UiBinder>",
       "  <g:HorizontalPanel>",
       "    <g:Button wbp:name='button'/>",
       "  </g:HorizontalPanel>",
       "</ui:UiBinder>");
   refresh();
   WidgetInfo button = getObjectByName("button");
   // "width"
   {
     Property property = PropertyUtils.getByPath(button, "Cell/width");
     // no value
     assertFalse(property.isModified());
     assertEquals(Property.UNKNOWN_VALUE, property.getValue());
     // set value, materialize "Cell"
     property.setValue("100px");
     assertXML(
         "// filler filler filler filler filler",
         "<ui:UiBinder>",
         "  <g:HorizontalPanel>",
         "    <g:Cell width='100px'>",
         "      <g:Button wbp:name='button'/>",
         "    </g:Cell>",
         "  </g:HorizontalPanel>",
         "</ui:UiBinder>");
     // has value
     assertTrue(property.isModified());
     assertEquals("100px", property.getValue());
   }
 }
 ////////////////////////////////////////////////////////////////////////////
 //
 // Change "Unit" property
 //
 ////////////////////////////////////////////////////////////////////////////
 public void test_propertyUnit() throws Exception {
   DockLayoutPanelInfo panel =
       parse(
           "// filler filler filler filler filler",
           "// filler filler filler filler filler",
           "<ui:UiBinder>",
           "  <g:DockLayoutPanel/>",
           "</ui:UiBinder>");
   refresh();
   // Unit property
   Property unitProperty = panel.getPropertyByTitle("Unit");
   assertNotNull(unitProperty);
   assertTrue(unitProperty.getCategory().isSystem());
   // default value
   assertFalse(unitProperty.isModified());
   assertEquals("PX", getPropertyText(unitProperty));
   // set value
   setPropertyText(unitProperty, "MM");
   assertXML(
       "// filler filler filler filler filler",
       "// filler filler filler filler filler",
       "<ui:UiBinder>",
       "  <g:DockLayoutPanel unit='MM'/>",
       "</ui:UiBinder>");
   assertTrue(unitProperty.isModified());
   assertEquals("MM", getPropertyText(unitProperty));
 }
Example #3
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());
   }
 }
Example #4
0
 public void test_propertyCell_existingElement_horizontalAlignment() throws Exception {
   parse(
       "// filler filler filler filler filler",
       "<ui:UiBinder>",
       "  <g:HorizontalPanel>",
       "    <g:Cell>",
       "      <g:Button wbp:name='button'/>",
       "    </g:Cell>",
       "  </g:HorizontalPanel>",
       "</ui:UiBinder>");
   refresh();
   WidgetInfo button = getObjectByName("button");
   // "horizontalAlignment"
   {
     Property property = PropertyUtils.getByPath(button, "Cell/horizontalAlignment");
     // no value initially
     assertFalse(property.isModified());
     assertEquals("ALIGN_LEFT", getPropertyText(property));
     // check items
     {
       addComboPropertyItems(property);
       List<String> items = getComboPropertyItems();
       assertThat(items).containsExactly("ALIGN_LEFT", "ALIGN_CENTER", "ALIGN_RIGHT");
     }
     // set value
     setComboPropertyValue(property, 1);
     assertXML(
         "// filler filler filler filler filler",
         "<ui:UiBinder>",
         "  <g:HorizontalPanel>",
         "    <g:Cell horizontalAlignment='ALIGN_CENTER'>",
         "      <g:Button wbp:name='button'/>",
         "    </g:Cell>",
         "  </g:HorizontalPanel>",
         "</ui:UiBinder>");
     // has value
     assertTrue(property.isModified());
     assertEquals("ALIGN_CENTER", getPropertyText(property));
   }
 }
Example #5
0
 ////////////////////////////////////////////////////////////////////////////
 //
 // Cell property
 //
 ////////////////////////////////////////////////////////////////////////////
 public void test_propertyCell_existingElement() throws Exception {
   parse(
       "// filler filler filler filler filler",
       "<ui:UiBinder>",
       "  <g:HorizontalPanel>",
       "    <g:Cell>",
       "      <g:Button wbp:name='button'/>",
       "    </g:Cell>",
       "  </g:HorizontalPanel>",
       "</ui:UiBinder>");
   refresh();
   WidgetInfo button = getObjectByName("button");
   // get "Cell" property
   {
     Property cellProperty = button.getPropertyByTitle("Cell");
     assertNotNull(cellProperty);
     assertTrue(cellProperty.getCategory().isSystem());
   }
   // "width"
   {
     Property property = PropertyUtils.getByPath(button, "Cell/width");
     // no value initially
     assertFalse(property.isModified());
     assertEquals(Property.UNKNOWN_VALUE, property.getValue());
     // set value
     property.setValue("100px");
     assertXML(
         "// filler filler filler filler filler",
         "<ui:UiBinder>",
         "  <g:HorizontalPanel>",
         "    <g:Cell width='100px'>",
         "      <g:Button wbp:name='button'/>",
         "    </g:Cell>",
         "  </g:HorizontalPanel>",
         "</ui:UiBinder>");
     // has value
     assertTrue(property.isModified());
     assertEquals("100px", property.getValue());
   }
 }