Package org.eclipse.wb.internal.core.model.menu

Examples of org.eclipse.wb.internal.core.model.menu.IMenuPolicy


            "    add(bar);",
            "  }",
            "}");
    container.refresh();
    MenuBarInfo bar = (MenuBarInfo) container.getWidgets().get(0);
    IMenuPolicy policy = MenuObjectInfoUtils.getMenuInfo(bar).getPolicy();
    // don't accept anything other than MenuBarItem
    assertFalse(policy.validateCreate(new Object()));
    // create new MenuBarItem
    MenuBarItemInfo newItem = createJavaInfo("com.extjs.gxt.ui.client.widget.menu.MenuBarItem");
    assertTrue(policy.validateCreate(newItem));
    policy.commandCreate(newItem, null);
    assertEditor(
        "public class Test extends LayoutContainer {",
        "  public Test() {",
        "    MenuBar bar = new MenuBar();",
        "    {",
View Full Code Here


            "    add(bar);",
            "  }",
            "}");
    container.refresh();
    MenuBarInfo bar = (MenuBarInfo) container.getWidgets().get(0);
    IMenuPolicy policy = MenuObjectInfoUtils.getMenuInfo(bar).getPolicy();
    // Object can not be pasted (not list of memento at all)
    assertFalse(policy.validatePaste(new Object()));
    // MenuBar can not be pasted (even if it has memento)
    {
      JavaInfoMemento memento = JavaInfoMemento.createMemento(bar);
      List<JavaInfoMemento> mementos = ImmutableList.of(memento);
      assertFalse(policy.validatePaste(mementos));
    }
  }
View Full Code Here

      JavaInfoMemento memento = JavaInfoMemento.createMemento(existingItem);
      mementos = ImmutableList.of(memento);
    }
    // paste
    {
      IMenuPolicy policy = MenuObjectInfoUtils.getMenuInfo(bar).getPolicy();
      // validate
      assertTrue(policy.validatePaste(mementos));
      // do paste
      List<?> pastedObjects = policy.commandPaste(mementos, null);
      assertThat(pastedObjects).hasSize(1);
      assertThat(pastedObjects.get(0)).isInstanceOf(MenuBarItemInfo.class);
    }
    assertEditor(
        "public class Test extends LayoutContainer {",
View Full Code Here

            "    add(bar);",
            "  }",
            "}");
    container.refresh();
    MenuBarInfo bar = (MenuBarInfo) container.getWidgets().get(0);
    IMenuPolicy policy = MenuObjectInfoUtils.getMenuInfo(bar).getPolicy();
    MenuBarItemInfo item_1 = bar.getItems().get(0);
    MenuBarItemInfo item_2 = bar.getItems().get(1);
    // invalid move
    assertFalse(policy.validateMove(new Object()));
    // move "item_2" before "item_1"
    {
      // validate
      assertTrue(policy.validateMove(item_2));
      // do move
      policy.commandMove(item_2, item_1);
    }
    assertEditor(
        "public class Test extends LayoutContainer {",
        "  public Test() {",
        "    MenuBar bar = new MenuBar();",
View Full Code Here

            "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");
    assertTrue(policy.validateCreate(newItem));
    policy.commandCreate(newItem, null);
    assertEditor(
        "// filler filler filler",
        "public class Test extends Menu {",
        "  public Test() {",
        "    {",
View Full Code Here

            "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 {",
        "  public Test() {",
        "    {",
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)
    {
      WidgetInfo button = container.getWidgets().get(1);
      JavaInfoMemento memento = JavaInfoMemento.createMemento(button);
      List<JavaInfoMemento> mementos = ImmutableList.of(memento);
      assertFalse(policy.validatePaste(mementos));
    }
  }
View Full Code Here

            "      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
    {
      // validate
      assertTrue(policy.validatePaste(mementos));
      // do paste
      List<?> pastedObjects = policy.commandPaste(mementos, null);
      assertThat(pastedObjects).hasSize(1);
      assertThat(pastedObjects.get(0)).isInstanceOf(ComponentInfo.class);
    }
    assertEditor(
        "public class Test extends Menu {",
View Full Code Here

            "      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
      assertTrue(policy.validateMove(item_2));
      // do move
      policy.commandMove(item_2, item_1);
    }
    assertEditor(
        "public class Test extends Menu {",
        "  public Test() {",
        "    {",
View Full Code Here

        "    rootPanel.add(bar);",
        "  }",
        "}");
    MenuBarInfo bar = getJavaInfoByName("bar");
    IMenuInfo barObject = MenuObjectInfoUtils.getMenuInfo(bar);
    IMenuPolicy barPolicy = barObject.getPolicy();
    // don't accept something other than MenuItem or MenuItemSeparator
    assertFalse(barPolicy.validateCreate(new Object()));
    // create new MenuItemSeparator
    MenuItemSeparatorInfo newSeparator =
        createJavaInfo("com.google.gwt.user.client.ui.MenuItemSeparator");
    assertTrue(barPolicy.validateCreate(newSeparator));
    barPolicy.commandCreate(newSeparator, null);
    assertEditor(
        "public class Test implements EntryPoint {",
        "  public void onModuleLoad() {",
        "    RootPanel rootPanel = RootPanel.get();",
        "    MenuBar bar = new MenuBar();",
View Full Code Here

TOP

Related Classes of org.eclipse.wb.internal.core.model.menu.IMenuPolicy

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.