"}");
frame.refresh();
DockPanelInfo panel = (DockPanelInfo) frame.getChildrenWidgets().get(0);
WidgetInfo button = panel.getChildrenWidgets().get(0);
// check that "Cell" property exists
Property cellProperty;
{
cellProperty = button.getPropertyByTitle("Cell");
assertNotNull(cellProperty);
// same instance each time
assertSame(cellProperty, button.getPropertyByTitle("Cell"));
// presentation
assertEquals("Cell", cellProperty.getTitle());
assertTrue(cellProperty.getCategory().isSystem());
assertFalse(cellProperty.isModified());
assertEquals("(cell properties)", getPropertyText(cellProperty));
}
// sub-properties
Property[] subProperties = getSubProperties(cellProperty);
// check "width"
{
Property widthProperty = getPropertyByTitle(subProperties, "width");
assertFalse(widthProperty.isModified());
assertEquals("", widthProperty.getValue());
// set new value
widthProperty.setValue("5cm");
assertEditor(
"public class Test implements EntryPoint {",
" public void onModuleLoad() {",
" RootPanel rootPanel = RootPanel.get();",
" DockPanel panel = new DockPanel();",
" rootPanel.add(panel);",
" {",
" Button button = new Button();",
" panel.add(button, DockPanel.WEST);",
" panel.setCellWidth(button, '5cm');",
" }",
" }",
"}");
assertTrue(widthProperty.isModified());
assertEquals("5cm", widthProperty.getValue());
// set different value
widthProperty.setValue("10cm");
assertEditor(
"public class Test implements EntryPoint {",
" public void onModuleLoad() {",
" RootPanel rootPanel = RootPanel.get();",
" DockPanel panel = new DockPanel();",
" rootPanel.add(panel);",
" {",
" Button button = new Button();",
" panel.add(button, DockPanel.WEST);",
" panel.setCellWidth(button, '10cm');",
" }",
" }",
"}");
assertTrue(widthProperty.isModified());
assertEquals("10cm", widthProperty.getValue());
// remove value
widthProperty.setValue(Property.UNKNOWN_VALUE);
assertEditor(
"public class Test implements EntryPoint {",
" public void onModuleLoad() {",
" RootPanel rootPanel = RootPanel.get();",
" DockPanel panel = new DockPanel();",
" rootPanel.add(panel);",
" {",
" Button button = new Button();",
" panel.add(button, DockPanel.WEST);",
" }",
" }",
"}");
assertFalse(widthProperty.isModified());
assertEquals("", widthProperty.getValue());
// remove again - no changes
{
String expectedSource = m_lastEditor.getSource();
widthProperty.setValue(Property.UNKNOWN_VALUE);
assertEditor(expectedSource, m_lastEditor);
assertFalse(widthProperty.isModified());
assertEquals("", widthProperty.getValue());
}
}
// check "height"
{
Property heightProperty = getPropertyByTitle(subProperties, "height");
assertFalse(heightProperty.isModified());
assertEquals("", heightProperty.getValue());
// set new value
heightProperty.setValue("5cm");
assertEditor(
"public class Test implements EntryPoint {",
" public void onModuleLoad() {",
" RootPanel rootPanel = RootPanel.get();",
" DockPanel panel = new DockPanel();",
" rootPanel.add(panel);",
" {",
" Button button = new Button();",
" panel.add(button, DockPanel.WEST);",
" panel.setCellHeight(button, '5cm');",
" }",
" }",
"}");
assertTrue(heightProperty.isModified());
assertEquals("5cm", heightProperty.getValue());
// remove value
heightProperty.setValue(Property.UNKNOWN_VALUE);
assertEditor(
"public class Test implements EntryPoint {",
" public void onModuleLoad() {",
" RootPanel rootPanel = RootPanel.get();",
" DockPanel panel = new DockPanel();",
" rootPanel.add(panel);",
" {",
" Button button = new Button();",
" panel.add(button, DockPanel.WEST);",
" }",
" }",
"}");
assertFalse(heightProperty.isModified());
assertEquals("", heightProperty.getValue());
}
// check "horizontalAlignment"
{
Class<?> hasAlignmentClass =
m_lastLoader.loadClass("com.google.gwt.user.client.ui.HasHorizontalAlignment");
Property alignmentProperty = getPropertyByTitle(subProperties, "horizontalAlignment");
assertFalse(alignmentProperty.isModified());
assertEquals("ALIGN_LEFT", getPropertyText(alignmentProperty));
// set new value
alignmentProperty.setValue(ReflectionUtils.getFieldObject(hasAlignmentClass, "ALIGN_RIGHT"));
assertEditor(
"public class Test implements EntryPoint {",
" public void onModuleLoad() {",
" RootPanel rootPanel = RootPanel.get();",
" DockPanel panel = new DockPanel();",
" rootPanel.add(panel);",
" {",
" Button button = new Button();",
" panel.add(button, DockPanel.WEST);",
" panel.setCellHorizontalAlignment(button, HasHorizontalAlignment.ALIGN_RIGHT);",
" }",
" }",
"}");
assertTrue(alignmentProperty.isModified());
assertEquals("ALIGN_RIGHT", getPropertyText(alignmentProperty));
// remove value
alignmentProperty.setValue(Property.UNKNOWN_VALUE);
assertEditor(
"public class Test implements EntryPoint {",
" public void onModuleLoad() {",
" RootPanel rootPanel = RootPanel.get();",
" DockPanel panel = new DockPanel();",
" rootPanel.add(panel);",
" {",
" Button button = new Button();",
" panel.add(button, DockPanel.WEST);",
" }",
" }",
"}");
assertFalse(alignmentProperty.isModified());
assertEquals("ALIGN_LEFT", getPropertyText(alignmentProperty));
}
// check "verticalAlignment"
{
Class<?> hasAlignmentClass =
m_lastLoader.loadClass("com.google.gwt.user.client.ui.HasVerticalAlignment");
Property alignmentProperty = getPropertyByTitle(subProperties, "verticalAlignment");
assertFalse(alignmentProperty.isModified());
assertEquals("ALIGN_TOP", getPropertyText(alignmentProperty));
// set new value
alignmentProperty.setValue(ReflectionUtils.getFieldObject(hasAlignmentClass, "ALIGN_BOTTOM"));
assertEditor(
"public class Test implements EntryPoint {",
" public void onModuleLoad() {",
" RootPanel rootPanel = RootPanel.get();",
" DockPanel panel = new DockPanel();",
" rootPanel.add(panel);",
" {",
" Button button = new Button();",
" panel.add(button, DockPanel.WEST);",
" panel.setCellVerticalAlignment(button, HasVerticalAlignment.ALIGN_BOTTOM);",
" }",
" }",
"}");
assertTrue(alignmentProperty.isModified());
assertEquals("ALIGN_BOTTOM", getPropertyText(alignmentProperty));
// remove value
alignmentProperty.setValue(Property.UNKNOWN_VALUE);
assertEditor(
"public class Test implements EntryPoint {",
" public void onModuleLoad() {",
" RootPanel rootPanel = RootPanel.get();",
" DockPanel panel = new DockPanel();",
" rootPanel.add(panel);",
" {",
" Button button = new Button();",
" panel.add(button, DockPanel.WEST);",
" }",
" }",
"}");
assertFalse(alignmentProperty.isModified());
assertEquals("ALIGN_TOP", getPropertyText(alignmentProperty));
}
}