Search in sources :

Example 6 with TabItemConfig

use of com.sencha.gxt.widget.core.client.TabItemConfig 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

TabItemConfig (com.sencha.gxt.widget.core.client.TabItemConfig)6 Point (com.sencha.gxt.core.client.util.Point)3 Element (com.google.gwt.dom.client.Element)2 XElement (com.sencha.gxt.core.client.dom.XElement)2 FxElement (com.sencha.gxt.fx.client.FxElement)2 HTML (com.google.gwt.user.client.ui.HTML)1 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 ContentPanel (com.sencha.gxt.widget.core.client.ContentPanel)1 PlainTabPanel (com.sencha.gxt.widget.core.client.PlainTabPanel)1 HideEvent (com.sencha.gxt.widget.core.client.event.HideEvent)1 HideHandler (com.sencha.gxt.widget.core.client.event.HideEvent.HideHandler)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 FormClass (org.activityinfo.model.form.FormClass)1 SubFormReferenceType (org.activityinfo.model.type.subform.SubFormReferenceType)1