Search in sources :

Example 1 with HideHandler

use of com.sencha.gxt.widget.core.client.event.HideEvent.HideHandler in project gwt-test-utils by gwt-test-utils.

the class WindowTest method hide.

@Test
public void hide() {
    // Given
    window.addHideHandler(new HideHandler() {

        public void onHide(HideEvent event) {
            assertThat(event.getSource()).isEqualTo(window);
            hide = true;
        }
    });
    window.show();
    // When
    window.hide();
    // Then
    assertThat(hide).isTrue();
}
Also used : HideHandler(com.sencha.gxt.widget.core.client.event.HideEvent.HideHandler) Test(org.junit.Test)

Example 2 with HideHandler

use of com.sencha.gxt.widget.core.client.event.HideEvent.HideHandler in project activityinfo by bedatadriven.

the class LogicalTabPanel method onItemContextMenu.

protected void onItemContextMenu(final M item, int x, int y) {
    if (closeMenu) {
        if (closeContextMenu == null) {
            closeContextMenu = new Menu();
            closeContextMenu.addHideHandler(new HideHandler() {

                @Override
                public void onHide(HideEvent event) {
                    contextMenuItem = null;
                }
            });
            closeContextMenu.add(new MenuItem(getMessages().closeTab(), new SelectionHandler<MenuItem>() {

                @Override
                public void onSelection(SelectionEvent<MenuItem> event) {
                    close(contextMenuItem);
                }
            }));
            closeContextMenu.add(new MenuItem(getMessages().closeOtherTabs(), new SelectionHandler<MenuItem>() {

                @Override
                public void onSelection(SelectionEvent<MenuItem> event) {
                    List<M> models = new ArrayList<M>();
                    for (int i = 0, len = getModelCount(); i < len; i++) {
                        models.add(getModel(i));
                    }
                    for (M w : models) {
                        TabItemConfig config = getConfig(w);
                        if (w != contextMenuItem && config.isClosable()) {
                            close(w);
                        }
                    }
                }
            }));
        }
        TabItemConfig c = configMap.get(item);
        MenuItem mi = (MenuItem) closeContextMenu.getWidget(0);
        mi.setEnabled(c.isClosable());
        contextMenuItem = item;
        boolean hasClosable = false;
        for (int i = 0, len = getModelCount(); i < len; i++) {
            Widget item2 = container.getWidget(i);
            TabItemConfig config = configMap.get(item2);
            if (config.isClosable() && item2 != item) {
                hasClosable = true;
                break;
            }
        }
        MenuItem m = (MenuItem) closeContextMenu.getWidget(1);
        m.setEnabled(hasClosable);
        closeContextMenu.showAt(x, y);
    }
}
Also used : ArrayList(java.util.ArrayList) IsWidget(com.google.gwt.user.client.ui.IsWidget) Widget(com.google.gwt.user.client.ui.Widget) HasOneWidget(com.google.gwt.user.client.ui.HasOneWidget) MenuItem(com.sencha.gxt.widget.core.client.menu.MenuItem) XDOM(com.sencha.gxt.core.client.dom.XDOM) Point(com.sencha.gxt.core.client.util.Point) HideHandler(com.sencha.gxt.widget.core.client.event.HideEvent.HideHandler) TabItemConfig(com.sencha.gxt.widget.core.client.TabItemConfig) Menu(com.sencha.gxt.widget.core.client.menu.Menu) HideEvent(com.sencha.gxt.widget.core.client.event.HideEvent)

Aggregations

HideHandler (com.sencha.gxt.widget.core.client.event.HideEvent.HideHandler)2 HasOneWidget (com.google.gwt.user.client.ui.HasOneWidget)1 IsWidget (com.google.gwt.user.client.ui.IsWidget)1 Widget (com.google.gwt.user.client.ui.Widget)1 XDOM (com.sencha.gxt.core.client.dom.XDOM)1 Point (com.sencha.gxt.core.client.util.Point)1 TabItemConfig (com.sencha.gxt.widget.core.client.TabItemConfig)1 HideEvent (com.sencha.gxt.widget.core.client.event.HideEvent)1 Menu (com.sencha.gxt.widget.core.client.menu.Menu)1 MenuItem (com.sencha.gxt.widget.core.client.menu.MenuItem)1 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1