public void test_operations() throws Exception {
   dontUseSharedGWTState();
   setFileContentSrc(
       "test/client/MyButton.java",
       getJavaSource(
           "import com.google.gwt.uibinder.client.UiConstructor;",
           "// filler filler filler filler filler",
           "// filler filler filler filler filler",
           "public class MyButton extends Button {",
           "  @UiConstructor",
           "  public MyButton(int foo) {",
           "  }",
           "}"));
   waitForAutoBuild();
   // parse
   parse(
       "// filler filler filler filler filler",
       "// filler filler filler filler filler",
       "<ui:UiBinder>",
       "  <g:FlowPanel>",
       "    <t:MyButton wbp:name='button' foo='1'/>",
       "  </g:FlowPanel>",
       "</ui:UiBinder>");
   refresh();
   WidgetInfo button = getObjectByName("button");
   // prepare property
   Property property = PropertyUtils.getByPath(button, "UiConstructor/foo");
   // initial value
   assertEquals(1, property.getValue());
   // set new value
   property.setValue(2);
   assertXML(
       "// filler filler filler filler filler",
       "// filler filler filler filler filler",
       "<ui:UiBinder>",
       "  <g:FlowPanel>",
       "    <t:MyButton wbp:name='button' foo='2'/>",
       "  </g:FlowPanel>",
       "</ui:UiBinder>");
   // no delete
   property.setValue(Property.UNKNOWN_VALUE);
   assertXML(
       "// filler filler filler filler filler",
       "// filler filler filler filler filler",
       "<ui:UiBinder>",
       "  <g:FlowPanel>",
       "    <t:MyButton wbp:name='button' foo='2'/>",
       "  </g:FlowPanel>",
       "</ui:UiBinder>");
 }
示例#2
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());
   }
 }
示例#3
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());
   }
 }
 /** Test for "Edge" property, contributed to child {@link WidgetInfo}. */
 public void test_propertyEdge() throws Exception {
   DockLayoutPanelInfo panel =
       parse(
           "// filler filler filler filler filler",
           "// filler filler filler filler filler",
           "<ui:UiBinder>",
           "  <g:DockLayoutPanel unit='CM'>",
           "    <g:west size='1.0'>",
           "      <g:Button wbp:name='button'/>",
           "    </g:west>",
           "  </g:DockLayoutPanel>",
           "</ui:UiBinder>");
   refresh();
   WidgetInfo button = getObjectByName("button");
   // prepare "Edge" property
   Property property = button.getPropertyByTitle("Edge");
   assertNotNull(property);
   assertEquals("WEST", getPropertyText(property));
   assertInstanceOf(StringListPropertyEditor.class, property.getEditor());
   // set value
   property.setValue("NORTH");
   assertXML(
       "// filler filler filler filler filler",
       "// filler filler filler filler filler",
       "<ui:UiBinder>",
       "  <g:DockLayoutPanel unit='CM'>",
       "    <g:north size='1.0'>",
       "      <g:Button wbp:name='button'/>",
       "    </g:north>",
       "  </g:DockLayoutPanel>",
       "</ui:UiBinder>");
   assertEquals("NORTH", panel.getEdge(button));
 }
 /** Opens editing dialog. */
 private void openDialog(Property property) throws Exception {
   // set initial color
   {
     Object value = property.getValue();
     if (value instanceof String) {
       RGB rgb = ColorDialog.getRGB((String) value);
       if (rgb != null) {
         m_colorDialog.setColorInfo(new ColorInfo(null, rgb));
       }
     }
   }
   // open dialog
   if (m_colorDialog.open() == Window.OK) {
     ColorInfo colorInfo = m_colorDialog.getColorInfo();
     String colorString = getColorString(colorInfo);
     property.setValue(colorString);
   }
 }
示例#6
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());
   }
 }