Package com.google.gdt.eclipse.designer.smart.model

Examples of com.google.gdt.eclipse.designer.smart.model.CanvasInfo


        "  }",
        "}");
  }

  public void test_BOUNDS_moveTo_setSize() throws Exception {
    CanvasInfo canvas =
        parseJavaInfo(
            "public class Test extends Canvas {",
            "  public Test() {",
            "    {",
            "      Button button = new Button('My Button');",
            "      addChild(button);",
            "      button.moveTo(1, 2);",
            "    }",
            "  }",
            "}");
    canvas.refresh();
    CanvasInfo button = getJavaInfoByName("button");
    //
    canvas.command_BOUNDS(button, null, new Dimension(100, 25));
    assertEditor(
        "public class Test extends Canvas {",
        "  public Test() {",
View Full Code Here


  ////////////////////////////////////////////////////////////////////////////
  /**
   * Test for {@link CanvasInfo#command_absolute_CREATE(WidgetInfo, WidgetInfo)}.
   */
  public void test_CREATE_noSibling() throws Exception {
    CanvasInfo canvas =
        parseJavaInfo(
            "// filler filler filler",
            "public class Test extends Canvas {",
            "  public Test() {",
            "  }",
            "}");
    canvas.refresh();
    assertThat(canvas.getWidgets()).isEmpty();
    //
    WidgetInfo newButton = createButton();
    canvas.command_absolute_CREATE(newButton, null);
    assertEditor(
        "// filler filler filler",
        "public class Test extends Canvas {",
        "  public Test() {",
        "    {",
        "      Button button = new Button();",
        "      addChild(button);",
        "    }",
        "  }",
        "}");
    assertThat(canvas.getWidgets()).containsExactly(newButton);
  }
View Full Code Here

  /**
   * Test for {@link CanvasInfo#command_absolute_CREATE(WidgetInfo, WidgetInfo)}.
   */
  public void test_CREATE_beforeSibling() throws Exception {
    CanvasInfo canvas =
        parseJavaInfo(
            "public class Test extends Canvas {",
            "  public Test() {",
            "    {",
            "      Button button_1 = new Button();",
            "      addChild(button_1);",
            "    }",
            "  }",
            "}");
    canvas.refresh();
    CanvasInfo button_1 = getJavaInfoByName("button_1");
    //
    WidgetInfo newButton = createButton();
    canvas.command_absolute_CREATE(newButton, button_1);
    assertEditor(
        "public class Test extends Canvas {",
View Full Code Here

  /**
   * Test for {@link CanvasInfo#command_absolute_CREATE(WidgetInfo, WidgetInfo)}.
   */
  public void test_CREATE_Widget() throws Exception {
    CanvasInfo canvas =
        parseJavaInfo(
            "// filler filler filler",
            "public class Test extends Canvas {",
            "  public Test() {",
            "  }",
            "}");
    canvas.refresh();
    assertThat(canvas.getWidgets()).isEmpty();
    // create GWT TextBox
    WidgetInfo newTextBox = createJavaInfo("com.google.gwt.user.client.ui.TextBox");
    canvas.command_absolute_CREATE(newTextBox, null);
    // check
    assertThat(canvas.getWidgets()).excludes(newTextBox);
    WidgetCanvasInfo widgetCanvas = canvas.getChildren(WidgetCanvasInfo.class).get(0);
    // check presentation
    {
      IObjectPresentation presentation = widgetCanvas.getPresentation();
      IObjectPresentation widgetPresentation = newTextBox.getPresentation();
      assertThat(presentation.getText().startsWith(widgetPresentation.getText())).isTrue();
View Full Code Here

  ////////////////////////////////////////////////////////////////////////////
  /**
   * Test for {@link CanvasInfo#command_absolute_MOVE(WidgetInfo, WidgetInfo)}.
   */
  public void test_MOVE() throws Exception {
    CanvasInfo canvas =
        parseJavaInfo(
            "public class Test extends Canvas {",
            "  public Test() {",
            "    {",
            "      Button button_1 = new Button();",
            "      addChild(button_1);",
            "    }",
            "    {",
            "      Button button_2 = new Button();",
            "      addChild(button_2);",
            "    }",
            "  }",
            "}");
    canvas.refresh();
    CanvasInfo button_1 = getJavaInfoByName("button_1");
    CanvasInfo button_2 = getJavaInfoByName("button_2");
    assertThat(canvas.getWidgets()).containsExactly(button_1, button_2);
    //
    canvas.command_absolute_MOVE(button_2, button_1);
    assertEditor(
        "public class Test extends Canvas {",
View Full Code Here

  /**
   * When we move {@link WidgetInfo} out of {@link CanvasInfo}, its location information should be
   * removed.
   */
  public void test_moveOut_removeLocation() throws Exception {
    CanvasInfo canvas =
        parseJavaInfo(
            "public class Test extends Canvas {",
            "  public Test() {",
            "    {",
            "      Button button = new Button();",
            "      button.setLeft(100);",
            "      button.setTop(50);",
            "      addChild(button);",
            "    }",
            "    {",
            "      VLayout vLayout = new VLayout();",
            "      addChild(vLayout);",
            "    }",
            "  }",
            "}");
    canvas.refresh();
    CanvasInfo button = getJavaInfoByName("button");
    LayoutInfo layout = getJavaInfoByName("vLayout");
    //
    FlowContainer flowContainer = new FlowContainerFactory(layout, true).get().get(0);
    flowContainer.command_MOVE(button, null);
    assertEditor(
View Full Code Here

  /**
   * When we move {@link WidgetInfo} out of {@link CanvasInfo}, its location information should be
   * removed.
   */
  public void test_moveOut_removeLocation_setRect() throws Exception {
    CanvasInfo canvas =
        parseJavaInfo(
            "public class Test extends Canvas {",
            "  public Test() {",
            "    {",
            "      Button button = new Button();",
            "      button.setRect(100, 50, 200, 40);",
            "      addChild(button);",
            "    }",
            "    {",
            "      VLayout vLayout = new VLayout();",
            "      addChild(vLayout);",
            "    }",
            "  }",
            "}");
    canvas.refresh();
    CanvasInfo button = getJavaInfoByName("button");
    LayoutInfo layout = getJavaInfoByName("vLayout");
    //
    FlowContainer flowContainer = new FlowContainerFactory(layout, true).get().get(0);
    flowContainer.command_MOVE(button, null);
    assertEditor(
View Full Code Here

  //
  // Property "Bounds"
  //
  ////////////////////////////////////////////////////////////////////////////
  public void test_boundsProperty() throws Exception {
    CanvasInfo canvas =
        parseJavaInfo(
            "public class Test extends Canvas {",
            "  public Test() {",
            "    {",
            "      Button button = new Button();",
            "      addChild(button);",
            "      button.setRect(1, 2, 3, 4);",
            "    }",
            "  }",
            "}");
    canvas.refresh();
    CanvasInfo button = getJavaInfoByName("button");
    //
    Property boundsProperty = button.getPropertyByTitle("Bounds");
    assertNotNull(boundsProperty);
    // x
    {
      Property xProperty = PropertyUtils.getByPath(button, "Bounds/x");
      assertNotNull(xProperty);
View Full Code Here

  /**
   * Root canvas must ignore any set location invocations.
   */
  public void test_root_noPosition() throws Exception {
    CanvasInfo canvas =
        parseJavaInfo(
            "public class Test implements EntryPoint {",
            "  public void onModuleLoad() {",
            "    Canvas canvas = new Canvas();",
            "    canvas.setLeft('30%');",
            "    canvas.draw();",
            "  }",
            "}");
    canvas.refresh();
    // check left position
    {
      Integer left = (Integer) ReflectionUtils.invokeMethod2(canvas.getObject(), "getLeft");
      assertThat(left).isEqualTo(0);
    }
    {
      Integer left = (Integer) ReflectionUtils.invokeMethod2(canvas.getObject(), "getAbsoluteLeft");
      assertThat(left).isEqualTo(0);
    }
    //
    assertThat(canvas.getAbsoluteBounds()).isEqualTo(new Rectangle(0, 0, 450, 300));
  }
View Full Code Here

        }
        placementsSupport.commit();
        for (IAbstractComponentInfo widget : models) {
          Rectangle bounds = widget.getModelBounds();
          WidgetInfo component = (WidgetInfo) widget;
          CanvasInfo boundsCanvas = getBoundsCanvas(component);
          if (boundsCanvas != null) {
            m_canvas.command_BOUNDS(boundsCanvas, bounds.getLocation(), null);
          }
        }
      }
View Full Code Here

TOP

Related Classes of com.google.gdt.eclipse.designer.smart.model.CanvasInfo

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.