/** Create and add new item in menu. */ private void add(Action action, PresentationFactory presentationFactory) { Presentation presentation = presentationFactory.getPresentation(action); if (action instanceof ActionGroup) { ActionGroup group = (ActionGroup) action; table.setText(0, menuBarItems.size(), presentation.getText()); Element element = table.getCellFormatter().getElement(0, menuBarItems.size()); MenuBarItem item = new MenuBarItem( group, actionManager, managerProvider, presentationFactory, element, this, keyBindingAgent, resources.menuCss()); item.onMouseOut(); menuBarItems.put(element, item); action2barItem.put(group, item); } else if (action instanceof CustomComponentAction) { Widget widget = ((CustomComponentAction) action).createCustomComponent(presentation); table.setWidget(0, menuBarItems.size(), widget); Element element = table.getCellFormatter().getElement(0, menuBarItems.size()); menuBarItems.put(element, null); } }
/** Create a new widget and add it to panel menu. */ private void addToPanel(FlowPanel panel, Action action, PresentationFactory presentationFactory) { Presentation presentation = presentationFactory.getPresentation(action); if (action instanceof Separator) { panel.add(new SeparatorItem(resources.menuCss().panelSeparator())); // todo find way to render non custom actions } else if (action instanceof CustomComponentAction) { CustomComponentAction customComponentAction = (CustomComponentAction) action; Widget component = customComponentAction.createCustomComponent(presentation); component.addStyleName(resources.menuCss().customComponent()); panel.add(component); } }
/** Create a new widget and add it to panel menu. */ private void addToPanel(FlowPanel panel, Action action, PresentationFactory presentationFactory) { Presentation presentation = presentationFactory.getPresentation(action); if (action instanceof Separator) { panel.add(new SeparatorItem(resources.menuCss().panelSeparator())); // todo find way to render non custom actions } else if (action instanceof CustomComponentAction) { CustomComponentAction customComponentAction = (CustomComponentAction) action; Widget component = customComponentAction.createCustomComponent(presentation); component.addStyleName(resources.menuCss().customComponent()); panel.add(component); } }
Presentation presentation = presentationFactory.getPresentation(action); Widget customComponent = ((CustomComponentAction) action).createCustomComponent(presentation); actionGroupPanel.add(customComponent); } else if (action instanceof ActionGroup && ((ActionGroup) action).isPopup()) {