Search in sources :

Example 11 with MenuItem

use of com.google.gwt.user.client.ui.MenuItem in project gwt-test-utils by gwt-test-utils.

the class MenuBarTest method removeItem.

@Test
public void removeItem() {
    // Given
    MenuBar bar = new MenuBar();
    MenuItem item0 = bar.addItem("test0", cmd);
    MenuItem item1 = bar.addItem("test1", cmd);
    // When
    bar.removeItem(item0);
    // Then
    assertThat(bar.getItemIndex(item1)).isEqualTo(0);
}
Also used : MenuBar(com.google.gwt.user.client.ui.MenuBar) MenuItem(com.google.gwt.user.client.ui.MenuItem) Test(org.junit.Test)

Example 12 with MenuItem

use of com.google.gwt.user.client.ui.MenuItem in project gwt-test-utils by gwt-test-utils.

the class MenuBarTest method constructor_Complex.

@Test
public void constructor_Complex() {
    // Given
    MenuBar bar = new MenuBar();
    MenuBar subMenuBar = new MenuBar();
    MenuItem item = new MenuItem("item", false, subMenuBar);
    bar.addItem(item);
    item.setCommand(cmd);
    // Preconditions
    assertThat(called).isEqualTo(false);
    // When
    Browser.click(bar, item);
    // Then
    assertThat(called).isEqualTo(true);
}
Also used : MenuBar(com.google.gwt.user.client.ui.MenuBar) MenuItem(com.google.gwt.user.client.ui.MenuItem) Test(org.junit.Test)

Example 13 with MenuItem

use of com.google.gwt.user.client.ui.MenuItem in project gwt-test-utils by gwt-test-utils.

the class MenuBarTest method addItem.

@Test
public void addItem() {
    // Given
    MenuBar bar = new MenuBar();
    // When
    MenuItem item0 = bar.addItem("test0", cmd);
    MenuItem item1 = bar.addItem("test1", cmd);
    // Then
    assertThat(bar.getItemIndex(item0)).isEqualTo(0);
    assertThat(bar.getItemIndex(item1)).isEqualTo(1);
    assertThat(item0.getParentMenu()).isEqualTo(bar);
    assertThat(item1.getParentMenu()).isEqualTo(bar);
}
Also used : MenuBar(com.google.gwt.user.client.ui.MenuBar) MenuItem(com.google.gwt.user.client.ui.MenuItem) Test(org.junit.Test)

Example 14 with MenuItem

use of com.google.gwt.user.client.ui.MenuItem in project gwt-test-utils by gwt-test-utils.

the class MenuBarTest method click.

@Test
public void click() {
    // Given
    MenuBar bar = new MenuBar();
    MenuItem item = bar.addItem("item", cmd);
    // Preconditions
    assertThat(called).isEqualTo(false);
    // When
    Browser.click(bar, item);
    // Then
    assertThat(called).isEqualTo(true);
}
Also used : MenuBar(com.google.gwt.user.client.ui.MenuBar) MenuItem(com.google.gwt.user.client.ui.MenuItem) Test(org.junit.Test)

Example 15 with MenuItem

use of com.google.gwt.user.client.ui.MenuItem in project rstudio by rstudio.

the class BaseMenuBar method onLoad.

@Override
protected void onLoad() {
    if (vertical_ && glass++ == 0)
        eventBus_.fireEvent(new GlassVisibilityEvent(true));
    super.onLoad();
    for (MenuItem child : getItems()) {
        if (child instanceof AppMenuItem)
            ((AppMenuItem) child).onShow();
        else {
            // if this is a submenu that consists entirely of hidden commands, 
            // hide the submenu and its flyout icon 
            MenuBar submenu = child.getSubMenu();
            if (submenu != null && submenu instanceof AppMenuBar) {
                boolean visible = child.isVisible();
                boolean newVisible = !((AppMenuBar) submenu).allInvisibleCmds();
                if (visible != newVisible) {
                    child.setVisible(newVisible);
                    updateSubmenuIcon(child);
                }
            }
        }
    }
    if (autoHideRedundantSeparators_)
        manageSeparators();
}
Also used : GlassVisibilityEvent(org.rstudio.core.client.widget.events.GlassVisibilityEvent) MenuBar(com.google.gwt.user.client.ui.MenuBar) MenuItem(com.google.gwt.user.client.ui.MenuItem)

Aggregations

MenuItem (com.google.gwt.user.client.ui.MenuItem)24 Command (com.google.gwt.user.client.Command)8 SafeHtmlBuilder (com.google.gwt.safehtml.shared.SafeHtmlBuilder)7 AppCommand (org.rstudio.core.client.command.AppCommand)7 MenuBar (com.google.gwt.user.client.ui.MenuBar)5 ScheduledCommand (com.google.gwt.core.client.Scheduler.ScheduledCommand)4 Test (org.junit.Test)4 JsArrayString (com.google.gwt.core.client.JsArrayString)3 RepeatingCommand (com.google.gwt.core.client.Scheduler.RepeatingCommand)3 ToolbarPopupMenu (org.rstudio.core.client.widget.ToolbarPopupMenu)3 StatusBarPopupMenu (org.rstudio.studio.client.workbench.views.source.editors.text.status.StatusBarPopupMenu)3 Scheduler (com.google.gwt.core.client.Scheduler)2 SafeHtml (com.google.gwt.safehtml.shared.SafeHtml)2 Event (com.google.gwt.user.client.Event)2 PositionCallback (com.google.gwt.user.client.ui.PopupPanel.PositionCallback)2 SlideNavigationItem (org.rstudio.studio.client.common.presentation.model.SlideNavigationItem)2 StatusBarPopupRequest (org.rstudio.studio.client.workbench.views.source.editors.text.status.StatusBarPopupRequest)2 JsArray (com.google.gwt.core.client.JsArray)1 Label (com.google.gwt.user.client.ui.Label)1 UIObject (com.google.gwt.user.client.ui.UIObject)1