Search in sources :

Example 11 with Action

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

the class PopupMenu method isRowEnabled.

private boolean isRowEnabled(Element tr) {
    if (tr == null) {
        return false;
    }
    String index = tr.getAttribute("item-index");
    if (index == null || "".equals(index)) {
        return false;
    }
    String enabled = tr.getAttribute("item-enabled");
    if (enabled == null || "".equals(enabled) || "false".equals(enabled)) {
        return false;
    }
    int itemIndex = Integer.parseInt(index);
    Action menuItem = list.get(itemIndex);
    return presentationFactory.getPresentation(menuItem).isEnabled();
}
Also used : ToggleAction(org.eclipse.che.ide.api.action.ToggleAction) Action(org.eclipse.che.ide.api.action.Action)

Example 12 with Action

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

the class PopupMenu method onRowHovered.

/**
     * Handling MouseOver event.
     *
     * @param tr
     *         - element to be processed.
     */
protected void onRowHovered(Element tr) {
    if (tr == hoveredTR) {
        return;
    }
    setStyleNormal(hoveredTR);
    if (subPopupAnchor != null) {
        setStyleHovered(subPopupAnchor);
    }
    if (!isRowEnabled(tr)) {
        hoveredTR = null;
        return;
    }
    hoveredTR = tr;
    setStyleHovered(tr);
    int itemIndex = Integer.parseInt(tr.getAttribute("item-index"));
    Action menuItem = list.get(itemIndex);
    openSubPopupTimer.cancel();
    if (menuItem instanceof ActionGroup && !(((ActionGroup) menuItem).canBePerformed() && !Utils.hasVisibleChildren((ActionGroup) menuItem, presentationFactory, actionManager, managerProvider.get()))) {
        openSubPopupTimer.schedule(300);
    } else {
        closeSubPopupTimer.cancel();
        closeSubPopupTimer.schedule(200);
    }
}
Also used : ToggleAction(org.eclipse.che.ide.api.action.ToggleAction) Action(org.eclipse.che.ide.api.action.Action) ActionGroup(org.eclipse.che.ide.api.action.ActionGroup)

Example 13 with Action

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

Example 14 with Action

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

the class ActionManagerImpl method getParentGroup.

public Action getParentGroup(final String groupId, final String actionName, final String pluginId) {
    if (groupId == null || groupId.length() == 0) {
        reportActionError(pluginId, actionName + ": attribute \"group-id\" should be defined");
        return null;
    }
    Action parentGroup = getActionImpl(groupId, true);
    if (parentGroup == null) {
        reportActionError(pluginId, actionName + ": group with id \"" + groupId + "\" isn't registered; action will be added to the \"Other\" group");
        parentGroup = getActionImpl(IdeActions.GROUP_OTHER_MENU, true);
    }
    if (!(parentGroup instanceof DefaultActionGroup)) {
        reportActionError(pluginId, actionName + ": group with id \"" + groupId + "\" should be instance of " + DefaultActionGroup.class.getName() + " but was " + parentGroup.getClass());
        return null;
    }
    return parentGroup;
}
Also used : PromisableAction(org.eclipse.che.ide.api.action.PromisableAction) Action(org.eclipse.che.ide.api.action.Action) DefaultActionGroup(org.eclipse.che.ide.api.action.DefaultActionGroup)

Example 15 with Action

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

the class ActionManagerImpl method unregisterAction.

@Override
public void unregisterAction(String actionId) {
    if (!myId2Action.containsKey(actionId)) {
        Log.debug(getClass(), "action with ID " + actionId + " wasn't registered");
        return;
    }
    Action oldValue = (Action) myId2Action.remove(actionId);
    myAction2Id.remove(oldValue);
    myId2Index.remove(actionId);
    for (Entry<String, Set<String>> entry : myPlugin2Id.entrySet()) {
        final Set<String> pluginActions = entry.getValue();
        if (pluginActions != null) {
            pluginActions.remove(actionId);
        }
    }
}
Also used : PromisableAction(org.eclipse.che.ide.api.action.PromisableAction) Action(org.eclipse.che.ide.api.action.Action) HashSet(java.util.HashSet) Set(java.util.Set)

Aggregations

Action (org.eclipse.che.ide.api.action.Action)32 ActionEvent (org.eclipse.che.ide.api.action.ActionEvent)10 ActionGroup (org.eclipse.che.ide.api.action.ActionGroup)10 DefaultActionGroup (org.eclipse.che.ide.api.action.DefaultActionGroup)10 Presentation (org.eclipse.che.ide.api.action.Presentation)10 Separator (org.eclipse.che.ide.api.action.Separator)5 ToggleAction (org.eclipse.che.ide.api.action.ToggleAction)5 ArrayList (java.util.ArrayList)4 CustomComponentAction (org.eclipse.che.ide.api.action.CustomComponentAction)4 CreateProjectAction (org.eclipse.che.ide.actions.CreateProjectAction)2 ImportProjectAction (org.eclipse.che.ide.actions.ImportProjectAction)2 PromisableAction (org.eclipse.che.ide.api.action.PromisableAction)2 SplitHorizontallyAction (org.eclipse.che.ide.part.editor.actions.SplitHorizontallyAction)2 SplitVerticallyAction (org.eclipse.che.ide.part.editor.actions.SplitVerticallyAction)2 Test (org.junit.Test)2 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)1 ScheduledCommand (com.google.gwt.core.client.Scheduler.ScheduledCommand)1 DivElement (com.google.gwt.dom.client.DivElement)1 Element (com.google.gwt.dom.client.Element)1 RegExp (com.google.gwt.regexp.shared.RegExp)1