Search in sources :

Example 1 with Presentation

use of org.eclipse.che.ide.api.action.Presentation 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 Presentation

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

the class MainMenuViewImpl method expandActionGroup.

private void expandActionGroup(List<Action> newVisibleActions, ActionManager actionManager, ActionGroup mainActionGroup) {
    final Action[] children = mainActionGroup.getChildren(null);
    for (final Action action : children) {
        final Presentation presentation = presentationFactory.getPresentation(action);
        final ActionEvent e = new ActionEvent(presentation, actionManager, managerProvider.get());
        action.update(e);
        if (presentation.isVisible()) {
            // add only visible items
            newVisibleActions.add(action);
        }
        if (action2barItem.containsKey(action)) {
            action2barItem.get(action).update();
        }
    }
}
Also used : CustomComponentAction(org.eclipse.che.ide.api.action.CustomComponentAction) Action(org.eclipse.che.ide.api.action.Action) ActionEvent(org.eclipse.che.ide.api.action.ActionEvent) Presentation(org.eclipse.che.ide.api.action.Presentation)

Example 3 with Presentation

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

the class EditorTabContextMenu method updateActions.

protected ActionGroup updateActions() {
    final ActionGroup mainActionGroup = (ActionGroup) actionManager.getAction(getGroupMenu());
    if (mainActionGroup == null) {
        return new DefaultActionGroup(actionManager);
    }
    final Action[] children = mainActionGroup.getChildren(null);
    for (final Action action : children) {
        final Presentation presentation = presentationFactory.getPresentation(action);
        //pass into action properties
        presentation.putClientProperty(CURRENT_FILE_PROP, editorTab.getFile());
        presentation.putClientProperty(CURRENT_TAB_PROP, editorTab);
        presentation.putClientProperty(CURRENT_PANE_PROP, editorPartStack);
    }
    return super.updateActions();
}
Also used : Action(org.eclipse.che.ide.api.action.Action) ActionGroup(org.eclipse.che.ide.api.action.ActionGroup) DefaultActionGroup(org.eclipse.che.ide.api.action.DefaultActionGroup) Presentation(org.eclipse.che.ide.api.action.Presentation) DefaultActionGroup(org.eclipse.che.ide.api.action.DefaultActionGroup)

Example 4 with Presentation

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

the class SuspendAction method updateInPerspective.

@Override
public void updateInPerspective(ActionEvent event) {
    final Presentation presentation = event.getPresentation();
    final Debugger debugger = debuggerManager.getActiveDebugger();
    if (debugger == null) {
        presentation.setEnabledAndVisible(false);
        return;
    }
    //Workaround: we don't support this action for another types of debugger
    presentation.setVisible("gdb".equals(debugger.getDebuggerType()));
    presentation.setEnabled(debugger.isConnected() && !debugger.isSuspended());
}
Also used : Debugger(org.eclipse.che.ide.debug.Debugger) Presentation(org.eclipse.che.ide.api.action.Presentation)

Example 5 with Presentation

use of org.eclipse.che.ide.api.action.Presentation 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

Presentation (org.eclipse.che.ide.api.action.Presentation)17 Action (org.eclipse.che.ide.api.action.Action)10 ActionEvent (org.eclipse.che.ide.api.action.ActionEvent)9 ActionGroup (org.eclipse.che.ide.api.action.ActionGroup)7 CustomComponentAction (org.eclipse.che.ide.api.action.CustomComponentAction)4 Separator (org.eclipse.che.ide.api.action.Separator)4 Test (org.junit.Test)3 Widget (com.google.gwt.user.client.ui.Widget)2 DefaultActionGroup (org.eclipse.che.ide.api.action.DefaultActionGroup)2 DivElement (com.google.gwt.dom.client.DivElement)1 Element (com.google.gwt.dom.client.Element)1 RegExp (com.google.gwt.regexp.shared.RegExp)1 FlowPanel (com.google.gwt.user.client.ui.FlowPanel)1 Image (com.google.gwt.user.client.ui.Image)1 Label (com.google.gwt.user.client.ui.Label)1 Element (elemental.dom.Element)1 Event (elemental.events.Event)1 EventListener (elemental.events.EventListener)1 LIElement (elemental.html.LIElement)1 SpanElement (elemental.html.SpanElement)1