Search in sources :

Example 1 with AbstractTreeMenuStrategy

use of org.geosdi.geoplatform.gui.impl.tree.menu.strategy.AbstractTreeMenuStrategy in project geo-platform by geosdi.

the class GPMenuActionBinder method bindMenuCheckAction.

@Override
public void bindMenuCheckAction(MenuCheckAction action, GPCheckMenuItem tool, final Menu menu) {
    checkArgument(tool != null, "The Parameter tool must not be null.");
    checkArgument(menu != null, "The Parameter menu must not be null.");
    final CheckMenuItem item = new CheckMenuItem(tool.getText());
    item.setItemId(tool.getId());
    menu.add(item);
    if (action != null) {
        action.setId(tool.getId());
        item.addSelectionListener(action);
        this.addMenuActionEnableHandler(action, item);
        action.addMenuActionChangeCheckHandler(new MenuActionChangeCheckHandler() {

            @Override
            public void onActionCheckChange(MenuActionChangeCheckEvent event) {
                item.setChecked(event.isCheck());
                item.fireEvent(Events.Select, new MenuEvent(menu, item));
            }
        });
        action.setChecked(tool.isChecked());
        action.setEnabled(tool.isEnabled());
        if ((action instanceof TreeMenuCompositeAction) && (this.menuCreator instanceof AbstractTreeMenuStrategy)) {
            ((TreeMenuCompositeAction) action).addTreeMenuSelectionHandler();
        }
    }
}
Also used : CheckMenuItem(com.extjs.gxt.ui.client.widget.menu.CheckMenuItem) AbstractTreeMenuStrategy(org.geosdi.geoplatform.gui.impl.tree.menu.strategy.AbstractTreeMenuStrategy) MenuActionChangeCheckHandler(org.geosdi.geoplatform.gui.action.menu.handler.MenuActionChangeCheckHandler) MenuActionChangeCheckEvent(org.geosdi.geoplatform.gui.action.menu.event.MenuActionChangeCheckEvent) MenuEvent(com.extjs.gxt.ui.client.event.MenuEvent) TreeMenuCompositeAction(org.geosdi.geoplatform.gui.action.menu.tree.TreeMenuCompositeAction)

Example 2 with AbstractTreeMenuStrategy

use of org.geosdi.geoplatform.gui.impl.tree.menu.strategy.AbstractTreeMenuStrategy in project geo-platform by geosdi.

the class GPMenuActionBinder method bindMenuBaseAction.

/**
 * @param action
 * @param tool
 * @param menu
 */
@Override
public void bindMenuBaseAction(MenuAction action, GPMenuItem tool, final 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());
    item.setItemId(tool.getId());
    if (action != null) {
        action.setId(tool.getId());
        if (action instanceof MenuBaseAction) {
            item.setIcon(((MenuBaseAction) action).getImage());
        }
        item.addSelectionListener(action);
        this.addMenuActionEnableHandler(action, item);
        action.setEnabled((action.isMustBeEnabled()) ? action.isMustBeEnabled() : tool.isEnabled());
        if ((action instanceof TreeMenuCompositeAction) && (this.menuCreator instanceof AbstractTreeMenuStrategy)) {
            ((TreeMenuCompositeAction) action).addTreeMenuSelectionHandler();
        }
    }
    menu.add(item);
}
Also used : MenuBaseAction(org.geosdi.geoplatform.gui.action.menu.MenuBaseAction) AbstractTreeMenuStrategy(org.geosdi.geoplatform.gui.impl.tree.menu.strategy.AbstractTreeMenuStrategy) MenuItem(com.extjs.gxt.ui.client.widget.menu.MenuItem) CheckMenuItem(com.extjs.gxt.ui.client.widget.menu.CheckMenuItem) TreeMenuCompositeAction(org.geosdi.geoplatform.gui.action.menu.tree.TreeMenuCompositeAction)

Example 3 with AbstractTreeMenuStrategy

use of org.geosdi.geoplatform.gui.impl.tree.menu.strategy.AbstractTreeMenuStrategy 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)

Example 4 with AbstractTreeMenuStrategy

use of org.geosdi.geoplatform.gui.impl.tree.menu.strategy.AbstractTreeMenuStrategy in project geo-platform by geosdi.

the class GPMenuActionBinder method addMenuActionEnableHandler.

/**
 * @param action
 * @param item
 */
@Override
public void addMenuActionEnableHandler(MenuAction action, final MenuItem item) {
    checkArgument(action != null, "The Parameter action must not be null.");
    checkArgument(item != null, "The Parameter item must not be null.");
    action.addActionEnableHandler(new ActionEnableHandler() {

        @Override
        public void onActionEnabled(ActionEnableEvent event) {
            item.setEnabled(event.isEnabled());
            if ((menuCreator instanceof AbstractTreeMenuStrategy) && (item.getParentMenu() != null) && (item.getParentMenu().getParentItem() != null) && (item.getParentMenu().getParentItem() instanceof MenuItem) && ((MenuItem) (item.getParentMenu().getParentItem())).getSubMenu() != null) {
                Menu menu = item.getParentMenu();
                GPMenuActionHandlerManager.fireEventFromSource(new GPTreeMenuGroupEnableEvent(), menu.getId());
            }
        }
    });
}
Also used : GPTreeMenuGroupEnableEvent(org.geosdi.geoplatform.gui.configuration.composite.menu.puregwt.event.GPTreeMenuGroupEnableEvent) ActionEnableEvent(org.geosdi.geoplatform.gui.configuration.action.event.ActionEnableEvent) AbstractTreeMenuStrategy(org.geosdi.geoplatform.gui.impl.tree.menu.strategy.AbstractTreeMenuStrategy) 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) ActionEnableHandler(org.geosdi.geoplatform.gui.configuration.action.event.ActionEnableHandler)

Aggregations

CheckMenuItem (com.extjs.gxt.ui.client.widget.menu.CheckMenuItem)4 AbstractTreeMenuStrategy (org.geosdi.geoplatform.gui.impl.tree.menu.strategy.AbstractTreeMenuStrategy)4 MenuItem (com.extjs.gxt.ui.client.widget.menu.MenuItem)3 Menu (com.extjs.gxt.ui.client.widget.menu.Menu)2 TreeMenuCompositeAction (org.geosdi.geoplatform.gui.action.menu.tree.TreeMenuCompositeAction)2 MenuEvent (com.extjs.gxt.ui.client.event.MenuEvent)1 Component (com.extjs.gxt.ui.client.widget.Component)1 MenuBaseAction (org.geosdi.geoplatform.gui.action.menu.MenuBaseAction)1 MenuActionChangeCheckEvent (org.geosdi.geoplatform.gui.action.menu.event.MenuActionChangeCheckEvent)1 MenuActionChangeCheckHandler (org.geosdi.geoplatform.gui.action.menu.handler.MenuActionChangeCheckHandler)1 ActionEnableEvent (org.geosdi.geoplatform.gui.configuration.action.event.ActionEnableEvent)1 ActionEnableHandler (org.geosdi.geoplatform.gui.configuration.action.event.ActionEnableHandler)1 GPTreeMenuGroupEnableEvent (org.geosdi.geoplatform.gui.configuration.composite.menu.puregwt.event.GPTreeMenuGroupEnableEvent)1 GPTreeMenuGroupEnableHander (org.geosdi.geoplatform.gui.configuration.composite.menu.puregwt.handler.GPTreeMenuGroupEnableHander)1 GPTreeMenuGroupItem (org.geosdi.geoplatform.gui.configuration.composite.menu.tools.GPTreeMenuGroupItem)1