Search in sources :

Example 1 with CustomComponentAction

use of org.eclipse.che.ide.api.action.CustomComponentAction in project che by eclipse.

the class MainMenuViewImpl method add.

/**
     * 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);
    }
}
Also used : CustomComponentAction(org.eclipse.che.ide.api.action.CustomComponentAction) ActionGroup(org.eclipse.che.ide.api.action.ActionGroup) Element(com.google.gwt.dom.client.Element) Widget(com.google.gwt.user.client.ui.Widget) Presentation(org.eclipse.che.ide.api.action.Presentation)

Example 2 with CustomComponentAction

use of org.eclipse.che.ide.api.action.CustomComponentAction in project che by eclipse.

the class ToolbarViewImpl method createToolbarPart.

/**
     * Creates a toolbar part widget.
     *
     * @return widget
     */
private Widget createToolbarPart(List<Utils.VisibleActionGroup> visibleActionGroupList) {
    FlowPanel toolbarPart = new FlowPanel();
    if (addSeparatorFirst) {
        final Widget firstDelimiter = createDelimiter();
        toolbarPart.add(firstDelimiter);
    }
    for (Utils.VisibleActionGroup visibleActionGroup : visibleActionGroupList) {
        List<Action> actions = visibleActionGroup.getActionList();
        if (actions == null || actions.size() == 0) {
            continue;
        }
        FlowPanel actionGroupPanel = new FlowPanel();
        actionGroupPanel.setStyleName(toolbarResources.toolbar().toolbarActionGroupPanel());
        toolbarPart.add(actionGroupPanel);
        for (Action action : actions) {
            if (action instanceof Separator) {
                int actionIndex = actions.indexOf(action);
                if (actionIndex > 0 && actionIndex < actions.size() - 1) {
                    final Widget delimiter = createDelimiter();
                    actionGroupPanel.add(delimiter);
                }
            } else if (action instanceof CustomComponentAction) {
                Presentation presentation = presentationFactory.getPresentation(action);
                Widget customComponent = ((CustomComponentAction) action).createCustomComponent(presentation);
                actionGroupPanel.add(customComponent);
            } else if (action instanceof ActionGroup && ((ActionGroup) action).isPopup()) {
                ActionPopupButton button = new ActionPopupButton((ActionGroup) action, actionManager, keyBindingAgent, presentationFactory, managerProvider, toolbarResources);
                actionGroupPanel.add(button);
            } else {
                final ActionButton button = createToolbarButton(action);
                actionGroupPanel.add(button);
            }
        }
    }
    return toolbarPart;
}
Also used : Action(org.eclipse.che.ide.api.action.Action) CustomComponentAction(org.eclipse.che.ide.api.action.CustomComponentAction) CustomComponentAction(org.eclipse.che.ide.api.action.CustomComponentAction) Widget(com.google.gwt.user.client.ui.Widget) Presentation(org.eclipse.che.ide.api.action.Presentation) ActionGroup(org.eclipse.che.ide.api.action.ActionGroup) FlowPanel(com.google.gwt.user.client.ui.FlowPanel) Separator(org.eclipse.che.ide.api.action.Separator)

Aggregations

Widget (com.google.gwt.user.client.ui.Widget)2 ActionGroup (org.eclipse.che.ide.api.action.ActionGroup)2 CustomComponentAction (org.eclipse.che.ide.api.action.CustomComponentAction)2 Presentation (org.eclipse.che.ide.api.action.Presentation)2 Element (com.google.gwt.dom.client.Element)1 FlowPanel (com.google.gwt.user.client.ui.FlowPanel)1 Action (org.eclipse.che.ide.api.action.Action)1 Separator (org.eclipse.che.ide.api.action.Separator)1