/** Create new {@link MainMenuViewImpl} */ @Inject public StatusPanelGroupViewImpl(MenuResources resources, ActionManager actionManager) { this.resources = resources; this.actionManager = actionManager; initWidget(rootPanel); rootPanel.setStyleName(resources.menuCss().menuBar()); rootPanel.addStyleName(resources.menuCss().statusPanel()); leftPanel.addStyleName(resources.menuCss().leftPanel()); leftPanel.getElement().getStyle().setPropertyPx("marginLeft", 1); rootPanel.add(leftPanel); centerPanel.setStyleName(resources.menuCss().leftPanel()); rootPanel.add(centerPanel); rightPanel.addStyleName(resources.menuCss().rightPanel()); rightPanel.getElement().getStyle().setPropertyPx("marginRight", 1); rootPanel.add(rightPanel); }
/** 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); } }
/** 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 new {@link MainMenuViewImpl} */ @Inject public MainMenuViewImpl( MenuResources resources, ActionManager actionManager, KeyBindingAgent keyBindingAgent, Provider<PerspectiveManager> managerProvider, CommandToolbarPresenter toolbarPresenter) { this.resources = resources; this.actionManager = actionManager; this.keyBindingAgent = keyBindingAgent; this.managerProvider = managerProvider; initWidget(rootPanel); disableTextSelection(rootPanel.getElement(), true); rootPanel.setStyleName(resources.menuCss().menuBar()); leftPanel.addStyleName(resources.menuCss().leftPanel()); table.setStyleName(resources.menuCss().menuBarTable()); table.setCellPadding(0); table.setCellSpacing(0); final DivElement triangleSeparator = Elements.createDivElement(resources.menuCss().triangleSeparator()); rightPanel.addStyleName(resources.menuCss().rightPanel()); rightPanel.addStyleName(resources.menuCss().commandToolbar()); rootPanel.add(leftPanel); rootPanel.add(table); rootPanel.getElement().appendChild((Element) triangleSeparator); rootPanel.add(rightPanel); toolbarPresenter.go(rightPanel::add); }