Package com.google.gdt.eclipse.designer.gxt.model.widgets.menu

Examples of com.google.gdt.eclipse.designer.gxt.model.widgets.menu.MenuInfo


  //
  // Menu: IMenuPolicy
  //
  ////////////////////////////////////////////////////////////////////////////
  public void test_Menu_IMenuPolicy_CREATE_MenuItem() throws Exception {
    MenuInfo menu =
        parseJavaInfo(
            "// filler filler filler",
            "public class Test extends Menu {",
            "  public Test() {",
            "  }",
            "}");
    menu.refresh();
    IMenuPolicy policy = MenuObjectInfoUtils.getMenuInfo(menu).getPolicy();
    // don't accept anything other than Component
    assertFalse(policy.validateCreate(new Object()));
    // create new MenuItem
    MenuItemInfo newItem = createJavaInfo("com.extjs.gxt.ui.client.widget.menu.MenuItem");
View Full Code Here


        "  }",
        "}");
  }

  public void test_Menu_IMenuPolicy_CREATE_Menu() throws Exception {
    MenuInfo menu =
        parseJavaInfo(
            "// filler filler filler",
            "public class Test extends Menu {",
            "  public Test() {",
            "  }",
            "}");
    menu.refresh();
    IMenuPolicy policy = MenuObjectInfoUtils.getMenuInfo(menu).getPolicy();
    // don't accept anything other than Component
    assertFalse(policy.validateCreate(new Object()));
    // create new Menu
    MenuInfo newMenu = createJavaInfo("com.extjs.gxt.ui.client.widget.menu.Menu");
    assertTrue(policy.validateCreate(newMenu));
    policy.commandCreate(newMenu, null);
    assertEditor(
        "// filler filler filler",
        "public class Test extends Menu {",
View Full Code Here

            "    }",
            "    add(new com.google.gwt.user.client.ui.Button());",
            "  }",
            "}");
    container.refresh();
    MenuInfo menu = (MenuInfo) container.getWidgets().get(0);
    IMenuPolicy policy = MenuObjectInfoUtils.getMenuInfo(menu).getPolicy();
    // Object can not be pasted (not list of memento at all)
    assertFalse(policy.validatePaste(new Object()));
    // GWT Button can not be pasted (even if it has memento)
    {
View Full Code Here

      assertFalse(policy.validatePaste(mementos));
    }
  }

  public void test_Menu_IMenuPolicy_PASTE() throws Exception {
    MenuInfo menu =
        parseJavaInfo(
            "public class Test extends Menu {",
            "  public Test() {",
            "    {",
            "      MenuItem item = new MenuItem('A');",
            "      add(item);",
            "    }",
            "  }",
            "}");
    menu.refresh();
    IMenuPolicy policy = MenuObjectInfoUtils.getMenuInfo(menu).getPolicy();
    // prepare mementos
    List<JavaInfoMemento> mementos;
    {
      ComponentInfo existingItem = menu.getItems().get(0);
      JavaInfoMemento memento = JavaInfoMemento.createMemento(existingItem);
      mementos = ImmutableList.of(memento);
    }
    // paste
    {
View Full Code Here

        "  }",
        "}");
  }

  public void test_Menu_IMenuPolicy_MOVE() throws Exception {
    MenuInfo menu =
        parseJavaInfo(
            "public class Test extends Menu {",
            "  public Test() {",
            "    {",
            "      MenuItem item_1 = new MenuItem('A');",
            "      add(item_1);",
            "    }",
            "    {",
            "      MenuItem item_2 = new MenuItem('B');",
            "      add(item_2);",
            "    }",
            "  }",
            "}");
    menu.refresh();
    IMenuPolicy policy = MenuObjectInfoUtils.getMenuInfo(menu).getPolicy();
    ComponentInfo item_1 = menu.getItems().get(0);
    ComponentInfo item_2 = menu.getItems().get(1);
    // invalid move
    assertFalse(policy.validateMove(new Object()));
    // move "item_2" before "item_1"
    {
      // validate
View Full Code Here

            "  public Test() {",
            "  }",
            "}");
    container.refresh();
    //
    MenuInfo newMenu = createJavaInfo("com.extjs.gxt.ui.client.widget.menu.Menu");
    for (SimpleContainer simpleContainer : new SimpleContainerFactory(container, true).get()) {
      if (simpleContainer.validateComponent(newMenu)) {
        simpleContainer.command_CREATE(newMenu);
        break;
      }
View Full Code Here

  //
  // MenuItem
  //
  ////////////////////////////////////////////////////////////////////////////
  public void test_SeparatorMenuItem_parse() throws Exception {
    MenuInfo menu =
        parseJavaInfo(
            "public class Test extends Menu {",
            "  public Test() {",
            "    {",
            "      SeparatorMenuItem item = new SeparatorMenuItem();",
            "      add(item);",
            "    }",
            "  }",
            "}");
    assertHierarchy(
        "{this: com.extjs.gxt.ui.client.widget.menu.Menu} {this} {/add(item)/}",
        "  {new: com.extjs.gxt.ui.client.widget.menu.SeparatorMenuItem} {local-unique: item} {/new SeparatorMenuItem()/ /add(item)/}");
    menu.refresh();
    ItemInfo item = (ItemInfo) menu.getItems().get(0);
    //
    IMenuItemInfo itemObject = MenuObjectInfoUtils.getMenuItemInfo(item);
    assertNotNull(itemObject);
    assertSame(item, itemObject.getModel());
    // presentation
View Full Code Here

        "  {implicit-layout: default} {implicit-layout} {}",
        "  {new: com.extjs.gxt.ui.client.widget.menu.Menu} {local-unique: menu} {/new Menu()/ /add(menu)/ /menu.add(item)/}",
        "    {new: com.extjs.gxt.ui.client.widget.menu.MenuItem} {local-unique: item} {/new MenuItem()/ /menu.add(item)/ /item.setSubMenu(subMenu)/}",
        "      {new: com.extjs.gxt.ui.client.widget.menu.Menu} {local-unique: subMenu} {/new Menu()/ /item.setSubMenu(subMenu)/}");
    container.refresh();
    MenuInfo menu = (MenuInfo) container.getWidgets().get(0);
    MenuItemInfo item = (MenuItemInfo) menu.getItems().get(0);
    // prepare "subMenu"
    MenuInfo subMenu = item.getSubMenu();
    assertNotNull(subMenu);
    // prepare object for "subMenu"
    IMenuInfo subMenuObject;
    {
      IMenuInfo menuObject = MenuObjectInfoUtils.getMenuInfo(menu);
      IMenuItemInfo itemObject = menuObject.getItems().get(0);
      subMenuObject = itemObject.getMenu();
    }
    // check
    assertNotNull(subMenuObject);
    assertSame(subMenu, subMenuObject.getModel());
    {
      Image image = subMenu.getImage();
      assertNotNull(image);
    }
    {
      Rectangle bounds = subMenu.getBounds();
      assertEquals(120, bounds.width);
      assertEquals(30, bounds.height);
    }
  }
View Full Code Here

TOP

Related Classes of com.google.gdt.eclipse.designer.gxt.model.widgets.menu.MenuInfo

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.