Search in sources :

Example 6 with Action

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

the class CommandProducerActionManager method createActionsForMachine.

/**
     * Creates actions for that {@link CommandProducer}s
     * which are applicable for the given machine's type.
     */
private void createActionsForMachine(Machine machine) {
    for (CommandProducer commandProducer : commandProducers) {
        if (commandProducer.getMachineTypes().contains(machine.getConfig().getType())) {
            CommandProducerAction machineAction = commandProducerActionFactory.create(machine.getConfig().getName(), commandProducer, machine);
            List<Action> actionList = actionsByMachines.get(machine);
            if (actionList == null) {
                actionList = new ArrayList<>();
                actionsByMachines.put(machine, actionList);
            }
            actionList.add(machineAction);
            actionManager.registerAction(machine.getConfig().getName(), machineAction);
            DefaultActionGroup actionGroup = producersToActionGroups.get(commandProducer);
            if (actionGroup != null) {
                actionGroup.add(machineAction);
                actionsToActionGroups.put(machineAction, actionGroup);
            }
        }
    }
}
Also used : CommandProducer(org.eclipse.che.ide.api.command.CommandProducer) Action(org.eclipse.che.ide.api.action.Action) DefaultActionGroup(org.eclipse.che.ide.api.action.DefaultActionGroup)

Example 7 with Action

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

the class CommandProducerActionManager method createActionsForProducer.

/** Creates actions for the given {@link CommandProducer}. */
private void createActionsForProducer(CommandProducer producer) {
    Action action;
    if (producer.getMachineTypes().isEmpty()) {
        action = commandProducerActionFactory.create(producer.getName(), producer, appContext.getDevMachine().getDescriptor());
        actionManager.registerAction(producer.getName(), action);
    } else {
        action = new DefaultActionGroup(producer.getName(), true, actionManager);
        producersToActionGroups.put(producer, (DefaultActionGroup) action);
        actionManager.registerAction(producer.getName(), action);
        for (Machine machine : machines) {
            createActionsForMachine(machine);
        }
    }
    commandActionsPopUpGroup.add(action);
}
Also used : Action(org.eclipse.che.ide.api.action.Action) DefaultActionGroup(org.eclipse.che.ide.api.action.DefaultActionGroup) Machine(org.eclipse.che.api.core.model.machine.Machine)

Example 8 with Action

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

the class EditorPartStackPresenter method initializePaneMenu.

private void initializePaneMenu() {
    paneMenuTabItemHandler = new PaneMenuTabItemHandler();
    paneMenuActionItemHandler = new PaneMenuActionItemHandler();
    final EditorPaneMenuItem<Action> closePaneItemWidget = editorPaneMenuItemFactory.createMenuItem(closePaneAction);
    closePaneItemWidget.setDelegate(paneMenuActionItemHandler);
    editorPaneMenu.addItem(closePaneItemWidget);
    final EditorPaneMenuItem<Action> closeAllTabsItemWidget = editorPaneMenuItemFactory.createMenuItem(closeAllTabsPaneAction);
    closeAllTabsItemWidget.setDelegate(paneMenuActionItemHandler);
    editorPaneMenu.addItem(closeAllTabsItemWidget, true);
    final Action splitHorizontallyAction = actionManager.getAction(SPLIT_HORIZONTALLY);
    final EditorPaneMenuItem<Action> splitHorizontallyItemWidget = editorPaneMenuItemFactory.createMenuItem(splitHorizontallyAction);
    splitHorizontallyItemWidget.setDelegate(paneMenuActionItemHandler);
    editorPaneMenu.addItem(splitHorizontallyItemWidget);
    final Action splitVerticallyAction = actionManager.getAction(SPLIT_VERTICALLY);
    final EditorPaneMenuItem<Action> splitVerticallyItemWidget = editorPaneMenuItemFactory.createMenuItem(splitVerticallyAction);
    splitVerticallyItemWidget.setDelegate(paneMenuActionItemHandler);
    editorPaneMenu.addItem(splitVerticallyItemWidget);
}
Also used : CloseAllTabsPaneAction(org.eclipse.che.ide.part.editor.actions.CloseAllTabsPaneAction) ClosePaneAction(org.eclipse.che.ide.part.editor.actions.ClosePaneAction) Action(org.eclipse.che.ide.api.action.Action)

Example 9 with Action

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

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

the class EmptyEditorsPanel method render.

private void render(String title, Map<String, Action> actions) {
    this.title.setInnerText(title);
    container.removeAllChildren();
    Element listElement = Elements.createElement("ul", new String[] { style.list() });
    for (Map.Entry<String, Action> pair : actions.entrySet()) {
        LIElement liElement = Elements.createLiElement();
        liElement.appendChild(renderAction(pair.getKey(), pair.getValue()));
        listElement.appendChild(liElement);
    }
    container.appendChild((com.google.gwt.dom.client.Node) listElement);
}
Also used : CreateProjectAction(org.eclipse.che.ide.actions.CreateProjectAction) ImportProjectAction(org.eclipse.che.ide.actions.ImportProjectAction) Action(org.eclipse.che.ide.api.action.Action) NewFileAction(org.eclipse.che.ide.newresource.NewFileAction) Element(elemental.dom.Element) DivElement(com.google.gwt.dom.client.DivElement) LIElement(elemental.html.LIElement) SpanElement(elemental.html.SpanElement) HashMap(java.util.HashMap) Map(java.util.Map) LIElement(elemental.html.LIElement)

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