Search in sources :

Example 1 with GPTreeMenuGroupItem

use of org.geosdi.geoplatform.gui.configuration.composite.menu.tools.GPTreeMenuGroupItem in project geo-platform by geosdi.

the class GPMenuActionBinder method bindGroupMenuItem.

/**
 * @param tool
 * @param menu
 */
@Override
public void bindGroupMenuItem(GPGroupMenuItem tool, Menu menu) {
    checkArgument(tool != null, "The Parameter tool must not be null.");
    checkArgument(menu != null, "The Parameter menu must not be null.");
    final MenuItem item = new MenuItem(tool.getText());
    menu.add(item);
    final Menu subMenu = new Menu();
    this.bindTools(subMenu, tool.getTools());
    item.setSubMenu(subMenu);
    if ((tool instanceof GPTreeMenuGroupItem) && (this.menuCreator instanceof AbstractTreeMenuStrategy)) {
        GPMenuActionHandlerManager.addHandlerToSource(TYPE, subMenu.getId(), new GPTreeMenuGroupEnableHander() {

            @Override
            public void onEnableTreeMenuGroupItem() {
                int menuItemsNoEnabled = 0;
                for (Component component : subMenu.getItems()) {
                    if (!component.isEnabled()) {
                        ++menuItemsNoEnabled;
                    }
                }
                item.setEnabled((menuItemsNoEnabled == subMenu.getItemCount()) ? FALSE : TRUE);
            }
        });
    }
}
Also used : GPTreeMenuGroupItem(org.geosdi.geoplatform.gui.configuration.composite.menu.tools.GPTreeMenuGroupItem) AbstractTreeMenuStrategy(org.geosdi.geoplatform.gui.impl.tree.menu.strategy.AbstractTreeMenuStrategy) GPTreeMenuGroupEnableHander(org.geosdi.geoplatform.gui.configuration.composite.menu.puregwt.handler.GPTreeMenuGroupEnableHander) MenuItem(com.extjs.gxt.ui.client.widget.menu.MenuItem) CheckMenuItem(com.extjs.gxt.ui.client.widget.menu.CheckMenuItem) Menu(com.extjs.gxt.ui.client.widget.menu.Menu) Component(com.extjs.gxt.ui.client.widget.Component)

Aggregations

Component (com.extjs.gxt.ui.client.widget.Component)1 CheckMenuItem (com.extjs.gxt.ui.client.widget.menu.CheckMenuItem)1 Menu (com.extjs.gxt.ui.client.widget.menu.Menu)1 MenuItem (com.extjs.gxt.ui.client.widget.menu.MenuItem)1 GPTreeMenuGroupEnableHander (org.geosdi.geoplatform.gui.configuration.composite.menu.puregwt.handler.GPTreeMenuGroupEnableHander)1 GPTreeMenuGroupItem (org.geosdi.geoplatform.gui.configuration.composite.menu.tools.GPTreeMenuGroupItem)1 AbstractTreeMenuStrategy (org.geosdi.geoplatform.gui.impl.tree.menu.strategy.AbstractTreeMenuStrategy)1