Search in sources :

Example 11 with DefaultActionGroup

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

the class SelectCommandComboBox method setCommands.

/**
     * Sets commands to the widget.
     *
     * @param commands
     *         commands to set
     * @param commandToSelect
     *         command that should be selected or {@code null} if none
     */
private void setCommands(List<CommandImpl> commands, @Nullable CommandImpl commandToSelect) {
    this.commands.clear();
    commandActions.removeAll();
    final DefaultActionGroup commandsList = (DefaultActionGroup) actionManager.getAction(GROUP_COMMANDS_LIST);
    if (commandsList != null) {
        commandActions.addAll(commandsList);
    }
    Collections.sort(commands, new Comparator<CommandImpl>() {

        @Override
        public int compare(CommandImpl o1, CommandImpl o2) {
            return o1.getType().compareTo(o2.getType());
        }
    });
    CommandImpl prevCommand = null;
    for (CommandImpl command : commands) {
        if (prevCommand == null || !command.getType().equals(prevCommand.getType())) {
            CommandType commandType = commandTypeRegistry.getCommandTypeById(command.getType());
            commandActions.addSeparator(commandType.getDisplayName());
        }
        commandActions.add(commandsListWidget.createAction(command.getName(), command.getName()));
        prevCommand = command;
    }
    this.commands.addAll(commands);
    if (commandToSelect != null) {
        setSelectedCommand(commandToSelect);
    } else {
        selectLastUsedCommand();
    }
}
Also used : CommandImpl(org.eclipse.che.ide.api.command.CommandImpl) CommandType(org.eclipse.che.ide.api.command.CommandType) DefaultActionGroup(org.eclipse.che.ide.api.action.DefaultActionGroup)

Example 12 with DefaultActionGroup

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

the class WebExtension method prepareActions.

@Inject
private void prepareActions(WebExtensionResource resources, ActionManager actionManager, NewCssFileAction newCssFileAction, NewLessFileAction newLessFileAction, NewHtmlFileAction newHtmlFileAction, NewJavaScriptFileAction newJavaScriptFileAction, PreviewAction previewAction) {
    // register actions
    actionManager.registerAction("newCssFile", newCssFileAction);
    actionManager.registerAction("newLessFile", newLessFileAction);
    actionManager.registerAction("newHtmlFile", newHtmlFileAction);
    actionManager.registerAction("newJavaScriptFile", newJavaScriptFileAction);
    actionManager.registerAction("previewHTML", previewAction);
    // set icons
    newCssFileAction.getTemplatePresentation().setSVGResource(resources.cssFile());
    newLessFileAction.getTemplatePresentation().setSVGResource(resources.lessFile());
    newHtmlFileAction.getTemplatePresentation().setSVGResource(resources.htmlFile());
    newJavaScriptFileAction.getTemplatePresentation().setSVGResource(resources.jsFile());
    // add actions in main menu
    DefaultActionGroup newGroup = (DefaultActionGroup) actionManager.getAction(GROUP_FILE_NEW);
    newGroup.add(newCssFileAction);
    newGroup.add(newLessFileAction);
    newGroup.add(newHtmlFileAction);
    newGroup.add(newJavaScriptFileAction);
    // add actions in context menu
    DefaultActionGroup mainContextMenuGroup = (DefaultActionGroup) actionManager.getAction(GROUP_MAIN_CONTEXT_MENU);
    mainContextMenuGroup.add(previewAction);
    // add actions in Assistant main menu
    DefaultActionGroup assistantMainMenuGroup = (DefaultActionGroup) actionManager.getAction(GROUP_ASSISTANT);
    assistantMainMenuGroup.add(previewAction);
}
Also used : DefaultActionGroup(org.eclipse.che.ide.api.action.DefaultActionGroup) Inject(com.google.inject.Inject)

Example 13 with DefaultActionGroup

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

the class MyFileTypeExtension method MyFileTypeExtension.

@Inject
public void MyFileTypeExtension(final ActionManager actionManager, final CreateMyFileAction createMyFileAction, final FileTypeRegistry fileTypeRegistry, @Named("MyFileType") final FileType myFileType) {
    actionManager.registerAction("createMyFileAction", createMyFileAction);
    DefaultActionGroup mainContextMenu = (DefaultActionGroup) actionManager.getAction(GROUP_MAIN_CONTEXT_MENU);
    mainContextMenu.add(createMyFileAction);
    fileTypeRegistry.registerFileType(myFileType);
}
Also used : DefaultActionGroup(org.eclipse.che.ide.api.action.DefaultActionGroup) Inject(com.google.inject.Inject)

Example 14 with DefaultActionGroup

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

the class ActionManagerTest method shouldUnregister.

@Test
public void shouldUnregister() {
    DefaultActionGroup defaultActionGroup = new DefaultActionGroup(actionManager);
    actionManager.registerAction(IdeActions.GROUP_MAIN_MENU, defaultActionGroup);
    actionManager.unregisterAction(IdeActions.GROUP_MAIN_MENU);
    Action action = actionManager.getAction(IdeActions.GROUP_MAIN_MENU);
    assertNull(action);
}
Also used : Action(org.eclipse.che.ide.api.action.Action) DefaultActionGroup(org.eclipse.che.ide.api.action.DefaultActionGroup) Test(org.junit.Test)

Example 15 with DefaultActionGroup

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

the class CppExtension method prepareActions.

@Inject
private void prepareActions(CreateCSourceFileAction newCSourceFileAction, CreateCppSourceFileAction newCppSourceFileAction, CreateHeaderSourceFileAction newHeadSourceFileAction, ActionManager actionManager, CppResources resources, IconRegistry iconRegistry) {
    DefaultActionGroup newGroup = (DefaultActionGroup) actionManager.getAction(GROUP_FILE_NEW);
    actionManager.registerAction("newCFile", newCSourceFileAction);
    actionManager.registerAction("newCppFile", newCppSourceFileAction);
    actionManager.registerAction("newHFile", newHeadSourceFileAction);
    newGroup.add(newCSourceFileAction, Constraints.FIRST);
    newGroup.add(newHeadSourceFileAction, Constraints.FIRST);
    newGroup.add(newCppSourceFileAction, Constraints.FIRST);
    iconRegistry.registerIcon(new Icon(C_CATEGORY + ".samples.category.icon", resources.category()));
}
Also used : Icon(org.eclipse.che.ide.api.icon.Icon) DefaultActionGroup(org.eclipse.che.ide.api.action.DefaultActionGroup) Inject(com.google.inject.Inject)

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