Search in sources :

Example 6 with DefaultActionGroup

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

the class NodeJsExtension method prepareActions.

@Inject
private void prepareActions(ActionManager actionManager, NodeJsResources resources, IconRegistry iconRegistry, NewNodeJsFileAction newFileAction) {
    DefaultActionGroup newGroup = (DefaultActionGroup) actionManager.getAction(GROUP_FILE_NEW);
    actionManager.registerAction("newNodeJsFile", newFileAction);
    newGroup.add(newFileAction, Constraints.FIRST);
    iconRegistry.registerIcon(new Icon(NODE_JS_CATEGORY + ".samples.category.icon", resources.jsIcon()));
}
Also used : Icon(org.eclipse.che.ide.api.icon.Icon) DefaultActionGroup(org.eclipse.che.ide.api.action.DefaultActionGroup) Inject(com.google.inject.Inject)

Example 7 with DefaultActionGroup

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

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

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

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

the class SelectCommandComboBox method updateMachineActions.

private void updateMachineActions() {
    machinesActions.removeAll();
    final DefaultActionGroup actionList = (DefaultActionGroup) actionManager.getAction(GROUP_MACHINES_LIST);
    if (actionList != null) {
        machinesActions.addAll(actionList);
    }
    if (registeredMachineMap.isEmpty()) {
        return;
    }
    final List<Map.Entry<String, Machine>> machineEntryList = new LinkedList(registeredMachineMap.entrySet());
    // defined MachineDto Comparator here
    Collections.sort(machineEntryList, new MachineListEntryComparator());
    String machineCategory = null;
    for (Map.Entry<String, Machine> machineEntry : machineEntryList) {
        final Machine machine = machineEntry.getValue();
        final MachineConfig machineConfig = machine.getConfig();
        if (!this.getMachineCategory(machineConfig).equals(machineCategory)) {
            machineCategory = this.getMachineCategory(machineConfig);
            machinesActions.addSeparator(machineCategory);
        }
        machinesActions.add(machinesListWidget.createAction(machine.getId(), machineConfig.getName()));
    }
    machinesListWidget.updatePopup();
    if (machinesListWidget.getSelectedName() == null && machinesActions.getChildrenCount() > 0) {
        Machine firstMachine = machineEntryList.get(0).getValue();
        if (firstMachine == null) {
            return;
        }
        machinesListWidget.selectElement(firstMachine.getId(), firstMachine.getConfig().getName());
    }
}
Also used : MachineConfig(org.eclipse.che.api.core.model.machine.MachineConfig) DefaultActionGroup(org.eclipse.che.ide.api.action.DefaultActionGroup) HashMap(java.util.HashMap) Map(java.util.Map) LinkedList(java.util.LinkedList) Machine(org.eclipse.che.api.core.model.machine.Machine)

Aggregations

DefaultActionGroup (org.eclipse.che.ide.api.action.DefaultActionGroup)26 Inject (com.google.inject.Inject)14 Action (org.eclipse.che.ide.api.action.Action)8 Icon (org.eclipse.che.ide.api.icon.Icon)5 KeyBuilder (org.eclipse.che.ide.api.keybinding.KeyBuilder)4 Machine (org.eclipse.che.api.core.model.machine.Machine)2 Constraints (org.eclipse.che.ide.api.constraints.Constraints)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 LinkedList (java.util.LinkedList)1 Map (java.util.Map)1 MachineConfig (org.eclipse.che.api.core.model.machine.MachineConfig)1 CloseActiveEditorAction (org.eclipse.che.ide.actions.CloseActiveEditorAction)1 CollapseAllAction (org.eclipse.che.ide.actions.CollapseAllAction)1 CompleteAction (org.eclipse.che.ide.actions.CompleteAction)1 ConvertFolderToProjectAction (org.eclipse.che.ide.actions.ConvertFolderToProjectAction)1 CreateProjectAction (org.eclipse.che.ide.actions.CreateProjectAction)1 DeleteResourceAction (org.eclipse.che.ide.actions.DeleteResourceAction)1 DownloadProjectAction (org.eclipse.che.ide.actions.DownloadProjectAction)1 DownloadResourceAction (org.eclipse.che.ide.actions.DownloadResourceAction)1