Search in sources :

Example 1 with KeyBuilder

use of org.eclipse.che.ide.api.keybinding.KeyBuilder in project che by eclipse.

the class JavaExtension method prepareActions.

@Inject
private void prepareActions(NewPackageAction newPackageAction, KeyBindingAgent keyBinding, NewJavaSourceFileAction newJavaSourceFileAction, ActionManager actionManager, ProjectClasspathAction projectClasspathAction, MoveAction moveAction, CutJavaSourceAction cutAction, FileStructureAction fileStructureAction, MarkDirAsSourceAction markDirAsSourceAction, UnmarkDirAsSourceAction unmarkDirAsSourceAction, MarkDirectoryAsGroup markDirectoryAsGroup, OrganizeImportsAction organizeImportsAction, RenameRefactoringAction renameRefactoringAction, QuickDocumentationAction quickDocumentationAction, QuickFixAction quickFixAction, OpenDeclarationAction openDeclarationAction, OpenImplementationAction openImplementationAction, FindUsagesAction findUsagesAction, ParametersHintsAction parametersHintsAction) {
    DefaultActionGroup newGroup = (DefaultActionGroup) actionManager.getAction(GROUP_FILE_NEW);
    actionManager.registerAction("newJavaClass", newJavaSourceFileAction);
    newGroup.add(newJavaSourceFileAction, Constraints.FIRST);
    actionManager.registerAction("newJavaPackage", newPackageAction);
    newGroup.add(newPackageAction, new Constraints(Anchor.AFTER, "newJavaClass"));
    DefaultActionGroup refactorGroup = (DefaultActionGroup) actionManager.getAction(GROUP_ASSISTANT_REFACTORING);
    if (refactorGroup == null) {
        refactorGroup = new DefaultActionGroup("Refactoring", true, actionManager);
        actionManager.registerAction(GROUP_ASSISTANT_REFACTORING, refactorGroup);
    }
    DefaultActionGroup projectGroup = (DefaultActionGroup) actionManager.getAction(GROUP_PROJECT);
    actionManager.registerAction("projectProperties", projectClasspathAction);
    projectGroup.add(projectClasspathAction, new Constraints(Anchor.LAST, null));
    DefaultActionGroup assistantGroup = (DefaultActionGroup) actionManager.getAction(GROUP_ASSISTANT);
    refactorGroup.addSeparator();
    refactorGroup.add(moveAction);
    refactorGroup.add(renameRefactoringAction);
    assistantGroup.add(refactorGroup, new Constraints(Anchor.BEFORE, "updateDependency"));
    actionManager.registerAction(SHOW_QUICK_DOC, quickDocumentationAction);
    actionManager.registerAction(OPEN_JAVA_DECLARATION, openDeclarationAction);
    actionManager.registerAction(OPEN_IMPLEMENTATION, openImplementationAction);
    actionManager.registerAction(JAVA_RENAME_REFACTORING, renameRefactoringAction);
    actionManager.registerAction(JAVA_MOVE_REFACTORING, moveAction);
    actionManager.registerAction(JAVA_CUT_REFACTORING, cutAction);
    actionManager.registerAction(JAVA_FIND_USAGES, findUsagesAction);
    actionManager.registerAction(JAVA_CLASS_STRUCTURE, fileStructureAction);
    actionManager.registerAction(ORGANIZE_IMPORTS, organizeImportsAction);
    actionManager.registerAction(PARAMETERS_INFO, parametersHintsAction);
    actionManager.registerAction(QUICK_FIX, quickFixAction);
    assistantGroup.add(quickDocumentationAction, new Constraints(Anchor.BEFORE, GROUP_ASSISTANT_REFACTORING));
    assistantGroup.add(quickFixAction, new Constraints(Anchor.BEFORE, GROUP_ASSISTANT_REFACTORING));
    assistantGroup.add(openDeclarationAction, new Constraints(Anchor.BEFORE, GROUP_ASSISTANT_REFACTORING));
    assistantGroup.add(organizeImportsAction, new Constraints(Anchor.BEFORE, GROUP_ASSISTANT_REFACTORING));
    assistantGroup.add(openImplementationAction, new Constraints(Anchor.BEFORE, GROUP_ASSISTANT_REFACTORING));
    assistantGroup.add(fileStructureAction, new Constraints(Anchor.BEFORE, GROUP_ASSISTANT_REFACTORING));
    assistantGroup.add(findUsagesAction, new Constraints(Anchor.BEFORE, GROUP_ASSISTANT_REFACTORING));
    //Configure Build Path action group
    actionManager.registerAction("markDirectoryAsSourceGroup", markDirectoryAsGroup);
    actionManager.registerAction("markDirectoryAsSource", markDirAsSourceAction);
    actionManager.registerAction("unmarkDirectoryAsSource", unmarkDirAsSourceAction);
    markDirectoryAsGroup.add(markDirAsSourceAction);
    markDirectoryAsGroup.add(unmarkDirAsSourceAction);
    markDirectoryAsGroup.add(projectClasspathAction);
    DefaultActionGroup mainContextMenuGroup = (DefaultActionGroup) actionManager.getAction("resourceOperation");
    mainContextMenuGroup.addSeparator();
    mainContextMenuGroup.add(markDirectoryAsGroup);
    mainContextMenuGroup.addSeparator();
    DefaultActionGroup editorContextMenuGroup = (DefaultActionGroup) actionManager.getAction(IdeActions.GROUP_EDITOR_CONTEXT_MENU);
    editorContextMenuGroup.add(quickDocumentationAction, new Constraints(Anchor.AFTER, "format"));
    editorContextMenuGroup.add(quickFixAction, new Constraints(Anchor.AFTER, SHOW_QUICK_DOC));
    editorContextMenuGroup.add(openDeclarationAction, new Constraints(Anchor.AFTER, QUICK_FIX));
    editorContextMenuGroup.add(refactorGroup, new Constraints(Anchor.AFTER, OPEN_JAVA_DECLARATION));
    editorContextMenuGroup.add(fileStructureAction, new Constraints(Anchor.AFTER, GROUP_ASSISTANT_REFACTORING));
    if (UserAgent.isMac()) {
        keyBinding.getGlobal().addKey(new KeyBuilder().alt().control().charCode('b').build(), OPEN_IMPLEMENTATION);
        keyBinding.getGlobal().addKey(new KeyBuilder().control().charCode('j').build(), SHOW_QUICK_DOC);
        keyBinding.getGlobal().addKey(new KeyBuilder().control().charCode(KeyCodeMap.F12).build(), JAVA_CLASS_STRUCTURE);
        keyBinding.getGlobal().addKey(new KeyBuilder().alt().control().charCode('o').build(), ORGANIZE_IMPORTS);
        keyBinding.getGlobal().addKey(new KeyBuilder().control().charCode('p').build(), PARAMETERS_INFO);
        keyBinding.getGlobal().addKey(new KeyBuilder().action().charCode(KeyCodeMap.ENTER).build(), QUICK_FIX);
    } else {
        keyBinding.getGlobal().addKey(new KeyBuilder().alt().action().charCode('b').build(), OPEN_IMPLEMENTATION);
        keyBinding.getGlobal().addKey(new KeyBuilder().action().charCode('q').build(), SHOW_QUICK_DOC);
        keyBinding.getGlobal().addKey(new KeyBuilder().action().charCode(KeyCodeMap.F12).build(), JAVA_CLASS_STRUCTURE);
        keyBinding.getGlobal().addKey(new KeyBuilder().alt().action().charCode('o').build(), ORGANIZE_IMPORTS);
        keyBinding.getGlobal().addKey(new KeyBuilder().action().charCode('p').build(), PARAMETERS_INFO);
        keyBinding.getGlobal().addKey(new KeyBuilder().alt().charCode(KeyCodeMap.ENTER).build(), QUICK_FIX);
    }
    keyBinding.getGlobal().addKey(new KeyBuilder().none().charCode(KeyCodeMap.F4).build(), OPEN_JAVA_DECLARATION);
    keyBinding.getGlobal().addKey(new KeyBuilder().shift().charCode(KeyCodeMap.F6).build(), JAVA_RENAME_REFACTORING);
    keyBinding.getGlobal().addKey(new KeyBuilder().action().charCode('x').build(), JAVA_CUT_REFACTORING);
    keyBinding.getGlobal().addKey(new KeyBuilder().charCode(KeyCodeMap.F6).build(), JAVA_MOVE_REFACTORING);
    keyBinding.getGlobal().addKey(new KeyBuilder().alt().charCode(KeyCodeMap.F7).build(), JAVA_FIND_USAGES);
}
Also used : KeyBuilder(org.eclipse.che.ide.api.keybinding.KeyBuilder) Constraints(org.eclipse.che.ide.api.constraints.Constraints) DefaultActionGroup(org.eclipse.che.ide.api.action.DefaultActionGroup) Inject(com.google.inject.Inject)

Example 2 with KeyBuilder

use of org.eclipse.che.ide.api.keybinding.KeyBuilder in project che by eclipse.

the class LanguageServerExtension method registerAction.

@Inject
protected void registerAction(ActionManager actionManager, KeyBindingAgent keyBindingManager, GoToSymbolAction goToSymbolAction, FindSymbolAction findSymbolAction, FindDefinitionAction findDefinitionAction, FindReferencesAction findReferencesAction) {
    actionManager.registerAction("LSGoToSymbolAction", goToSymbolAction);
    actionManager.registerAction("LSFindSymbolAction", findSymbolAction);
    actionManager.registerAction("LSFindDefinitionAction", findDefinitionAction);
    actionManager.registerAction("LSFindReferencesAction", findReferencesAction);
    DefaultActionGroup assistantGroup = (DefaultActionGroup) actionManager.getAction(GROUP_ASSISTANT);
    assistantGroup.add(goToSymbolAction, new Constraints(Anchor.BEFORE, GROUP_ASSISTANT_REFACTORING));
    assistantGroup.add(findSymbolAction, new Constraints(Anchor.BEFORE, GROUP_ASSISTANT_REFACTORING));
    assistantGroup.add(findDefinitionAction, new Constraints(Anchor.BEFORE, GROUP_ASSISTANT_REFACTORING));
    assistantGroup.add(findReferencesAction, new Constraints(Anchor.BEFORE, GROUP_ASSISTANT_REFACTORING));
    if (UserAgent.isMac()) {
        keyBindingManager.getGlobal().addKey(new KeyBuilder().control().charCode(KeyCodeMap.F12).build(), "LSGoToSymbolAction");
    } else {
        keyBindingManager.getGlobal().addKey(new KeyBuilder().action().charCode(KeyCodeMap.F12).build(), "LSGoToSymbolAction");
    }
    keyBindingManager.getGlobal().addKey(new KeyBuilder().alt().charCode('n').build(), "LSFindSymbolAction");
    keyBindingManager.getGlobal().addKey(new KeyBuilder().alt().charCode(KeyCodeMap.F7).build(), "LSFindReferencesAction");
    keyBindingManager.getGlobal().addKey(new KeyBuilder().charCode(KeyCodeMap.F4).build(), "LSFindDefinitionAction");
}
Also used : KeyBuilder(org.eclipse.che.ide.api.keybinding.KeyBuilder) Constraints(org.eclipse.che.ide.api.constraints.Constraints) DefaultActionGroup(org.eclipse.che.ide.api.action.DefaultActionGroup) Inject(com.google.inject.Inject)

Example 3 with KeyBuilder

use of org.eclipse.che.ide.api.keybinding.KeyBuilder in project che by eclipse.

the class StandardComponentInitializer method initialize.

public void initialize() {
    messageLoaderResources.Css().ensureInjected();
    editorResources.editorCss().ensureInjected();
    popupResources.popupStyle().ensureInjected();
    fileTypeRegistry.registerFileType(xmlFile);
    fileTypeRegistry.registerFileType(txtFile);
    fileTypeRegistry.registerFileType(jsonFile);
    fileTypeRegistry.registerFileType(mdFile);
    fileTypeRegistry.registerFileType(pngFile);
    editorRegistry.registerDefaultEditor(pngFile, imageViewerProvider);
    fileTypeRegistry.registerFileType(bmpFile);
    editorRegistry.registerDefaultEditor(bmpFile, imageViewerProvider);
    fileTypeRegistry.registerFileType(gifFile);
    editorRegistry.registerDefaultEditor(gifFile, imageViewerProvider);
    fileTypeRegistry.registerFileType(iconFile);
    editorRegistry.registerDefaultEditor(iconFile, imageViewerProvider);
    fileTypeRegistry.registerFileType(svgFile);
    editorRegistry.registerDefaultEditor(svgFile, imageViewerProvider);
    fileTypeRegistry.registerFileType(jpeFile);
    editorRegistry.registerDefaultEditor(jpeFile, imageViewerProvider);
    fileTypeRegistry.registerFileType(jpegFile);
    editorRegistry.registerDefaultEditor(jpegFile, imageViewerProvider);
    fileTypeRegistry.registerFileType(jpgFile);
    editorRegistry.registerDefaultEditor(jpgFile, imageViewerProvider);
    // Workspace (New Menu)
    DefaultActionGroup workspaceGroup = (DefaultActionGroup) actionManager.getAction(GROUP_WORKSPACE);
    actionManager.registerAction(IMPORT_PROJECT, importProjectAction);
    workspaceGroup.add(importProjectAction);
    actionManager.registerAction(CREATE_PROJECT, createProjectAction);
    workspaceGroup.add(createProjectAction);
    actionManager.registerAction("downloadWsAsZipAction", downloadWsAction);
    workspaceGroup.add(downloadWsAction);
    workspaceGroup.addSeparator();
    // Project (New Menu)
    DefaultActionGroup projectGroup = (DefaultActionGroup) actionManager.getAction(GROUP_PROJECT);
    DefaultActionGroup newGroup = new DefaultActionGroup("New", true, actionManager);
    newGroup.getTemplatePresentation().setDescription("Create...");
    newGroup.getTemplatePresentation().setSVGResource(resources.newResource());
    actionManager.registerAction(GROUP_FILE_NEW, newGroup);
    projectGroup.add(newGroup);
    newGroup.addSeparator();
    actionManager.registerAction(NEW_FILE, newFileAction);
    newGroup.addAction(newFileAction);
    actionManager.registerAction("newFolder", newFolderAction);
    newGroup.addAction(newFolderAction);
    newGroup.addSeparator();
    actionManager.registerAction("newXmlFile", newXmlFileAction);
    newXmlFileAction.getTemplatePresentation().setSVGResource(xmlFile.getImage());
    newGroup.addAction(newXmlFileAction);
    actionManager.registerAction("uploadFile", uploadFileAction);
    projectGroup.add(uploadFileAction);
    actionManager.registerAction("uploadFolder", uploadFolderAction);
    projectGroup.add(uploadFolderAction);
    actionManager.registerAction("convertFolderToProject", convertFolderToProjectAction);
    projectGroup.add(convertFolderToProjectAction);
    actionManager.registerAction("downloadAsZipAction", downloadProjectAction);
    projectGroup.add(downloadProjectAction);
    actionManager.registerAction("showHideHiddenFiles", showHiddenFilesAction);
    projectGroup.add(showHiddenFilesAction);
    projectGroup.addSeparator();
    actionManager.registerAction("projectConfiguration", projectConfigurationAction);
    projectGroup.add(projectConfigurationAction);
    // Edit (New Menu)
    DefaultActionGroup editGroup = (DefaultActionGroup) actionManager.getAction(GROUP_EDIT);
    DefaultActionGroup recentGroup = new DefaultActionGroup(RECENT_GROUP_ID, true, actionManager);
    actionManager.registerAction(GROUP_RECENT_FILES, recentGroup);
    actionManager.registerAction("clearRecentList", clearRecentFilesAction);
    recentGroup.addSeparator();
    recentGroup.add(clearRecentFilesAction, LAST);
    editGroup.add(recentGroup);
    actionManager.registerAction(OPEN_RECENT_FILES, openRecentFilesAction);
    editGroup.add(openRecentFilesAction);
    editGroup.addSeparator();
    actionManager.registerAction(CLOSE_ACTIVE_EDITOR, closeActiveEditorAction);
    editGroup.add(closeActiveEditorAction);
    actionManager.registerAction(FORMAT, formatterAction);
    editGroup.add(formatterAction);
    actionManager.registerAction("undo", undoAction);
    editGroup.add(undoAction);
    actionManager.registerAction("redo", redoAction);
    editGroup.add(redoAction);
    actionManager.registerAction(CUT, cutResourceAction);
    editGroup.add(cutResourceAction);
    actionManager.registerAction(COPY, copyResourceAction);
    editGroup.add(copyResourceAction);
    actionManager.registerAction(PASTE, pasteResourceAction);
    editGroup.add(pasteResourceAction);
    actionManager.registerAction(RENAME, renameItemAction);
    editGroup.add(renameItemAction);
    actionManager.registerAction(DELETE_ITEM, deleteResourceAction);
    editGroup.add(deleteResourceAction);
    actionManager.registerAction(FULL_TEXT_SEARCH, fullTextSearchAction);
    editGroup.add(fullTextSearchAction);
    editGroup.addSeparator();
    editGroup.add(switchPreviousEditorAction);
    editGroup.add(switchNextEditorAction);
    editGroup.addSeparator();
    editGroup.add(revealResourceAction);
    // Assistant (New Menu)
    DefaultActionGroup assistantGroup = (DefaultActionGroup) actionManager.getAction(GROUP_ASSISTANT);
    actionManager.registerAction(FIND_ACTION, findActionAction);
    assistantGroup.add(findActionAction);
    actionManager.registerAction("hotKeysList", hotKeysListAction);
    assistantGroup.add(hotKeysListAction);
    assistantGroup.addSeparator();
    actionManager.registerAction("callCompletion", completeAction);
    assistantGroup.add(completeAction);
    actionManager.registerAction("downloadItemAction", downloadResourceAction);
    actionManager.registerAction(NAVIGATE_TO_FILE, navigateToFileAction);
    assistantGroup.add(navigateToFileAction);
    // Compose Save group
    DefaultActionGroup saveGroup = new DefaultActionGroup(actionManager);
    actionManager.registerAction("saveGroup", saveGroup);
    actionManager.registerAction("save", saveAction);
    actionManager.registerAction("saveAll", saveAllAction);
    saveGroup.addSeparator();
    saveGroup.add(saveAction);
    saveGroup.add(saveAllAction);
    //Compose Profile menu
    DefaultActionGroup profileGroup = (DefaultActionGroup) actionManager.getAction(GROUP_PROFILE);
    actionManager.registerAction("showPreferences", showPreferencesAction);
    profileGroup.add(showPreferencesAction);
    // Compose Help menu
    DefaultActionGroup helpGroup = (DefaultActionGroup) actionManager.getAction(GROUP_HELP);
    helpGroup.addSeparator();
    // Compose main context menu
    DefaultActionGroup resourceOperation = new DefaultActionGroup(actionManager);
    actionManager.registerAction("resourceOperation", resourceOperation);
    actionManager.registerAction("refreshPathAction", refreshPathAction);
    actionManager.registerAction("linkWithEditor", linkWithEditorAction);
    resourceOperation.addSeparator();
    resourceOperation.add(showReferenceAction);
    resourceOperation.add(goIntoAction);
    resourceOperation.add(editFileAction);
    resourceOperation.add(cutResourceAction);
    resourceOperation.add(copyResourceAction);
    resourceOperation.add(pasteResourceAction);
    resourceOperation.add(renameItemAction);
    resourceOperation.add(deleteResourceAction);
    resourceOperation.addSeparator();
    resourceOperation.add(downloadResourceAction);
    resourceOperation.add(refreshPathAction);
    resourceOperation.add(linkWithEditorAction);
    resourceOperation.addSeparator();
    resourceOperation.add(convertFolderToProjectAction);
    resourceOperation.addSeparator();
    DefaultActionGroup mainContextMenuGroup = (DefaultActionGroup) actionManager.getAction(GROUP_MAIN_CONTEXT_MENU);
    mainContextMenuGroup.add(newGroup, Constraints.FIRST);
    mainContextMenuGroup.addSeparator();
    mainContextMenuGroup.add(resourceOperation);
    DefaultActionGroup partMenuGroup = (DefaultActionGroup) actionManager.getAction(GROUP_PART_MENU);
    partMenuGroup.add(maximizePartAction);
    partMenuGroup.add(minimizePartAction);
    partMenuGroup.add(restorePartAction);
    actionManager.registerAction("expandEditor", expandEditorAction);
    DefaultActionGroup rightMenuGroup = (DefaultActionGroup) actionManager.getAction(GROUP_RIGHT_MAIN_MENU);
    rightMenuGroup.add(expandEditorAction, FIRST);
    // Compose main toolbar
    DefaultActionGroup changeResourceGroup = new DefaultActionGroup(actionManager);
    actionManager.registerAction("changeResourceGroup", changeResourceGroup);
    actionManager.registerAction("editFile", editFileAction);
    actionManager.registerAction("goInto", goIntoAction);
    actionManager.registerAction(SHOW_REFERENCE, showReferenceAction);
    actionManager.registerAction("collapseAll", collapseAllAction);
    actionManager.registerAction("openFile", openFileAction);
    actionManager.registerAction(SWITCH_LEFT_TAB, switchPreviousEditorAction);
    actionManager.registerAction(SWITCH_RIGHT_TAB, switchNextEditorAction);
    actionManager.registerAction("scrollFromSource", revealResourceAction);
    changeResourceGroup.add(cutResourceAction);
    changeResourceGroup.add(copyResourceAction);
    changeResourceGroup.add(pasteResourceAction);
    changeResourceGroup.add(deleteResourceAction);
    DefaultActionGroup mainToolbarGroup = (DefaultActionGroup) actionManager.getAction(GROUP_MAIN_TOOLBAR);
    mainToolbarGroup.add(newGroup);
    mainToolbarGroup.add(changeResourceGroup);
    toolbarPresenter.bindMainGroup(mainToolbarGroup);
    DefaultActionGroup centerToolbarGroup = (DefaultActionGroup) actionManager.getAction(GROUP_CENTER_TOOLBAR);
    toolbarPresenter.bindCenterGroup(centerToolbarGroup);
    DefaultActionGroup rightToolbarGroup = (DefaultActionGroup) actionManager.getAction(GROUP_RIGHT_TOOLBAR);
    toolbarPresenter.bindRightGroup(rightToolbarGroup);
    //Editor context menu group
    DefaultActionGroup editorTabContextMenu = (DefaultActionGroup) actionManager.getAction(GROUP_EDITOR_TAB_CONTEXT_MENU);
    editorTabContextMenu.add(closeAction);
    actionManager.registerAction(CLOSE, closeAction);
    editorTabContextMenu.add(closeAllAction);
    actionManager.registerAction(CLOSE_ALL, closeAllAction);
    editorTabContextMenu.add(closeOtherAction);
    actionManager.registerAction(CLOSE_OTHER, closeOtherAction);
    editorTabContextMenu.add(closeAllExceptPinnedAction);
    actionManager.registerAction(CLOSE_ALL_EXCEPT_PINNED, closeAllExceptPinnedAction);
    editorTabContextMenu.addSeparator();
    editorTabContextMenu.add(reopenClosedFileAction);
    actionManager.registerAction(REOPEN_CLOSED, reopenClosedFileAction);
    editorTabContextMenu.add(pinEditorTabAction);
    actionManager.registerAction(PIN_TAB, pinEditorTabAction);
    editorTabContextMenu.addSeparator();
    actionManager.registerAction(SPLIT_HORIZONTALLY, splitHorizontallyAction);
    editorTabContextMenu.add(splitHorizontallyAction);
    actionManager.registerAction(SPLIT_VERTICALLY, splitVerticallyAction);
    editorTabContextMenu.add(splitVerticallyAction);
    actionManager.registerAction(SIGNATURE_HELP, signatureHelpAction);
    DefaultActionGroup editorContextMenuGroup = new DefaultActionGroup(actionManager);
    actionManager.registerAction(GROUP_EDITOR_CONTEXT_MENU, editorContextMenuGroup);
    editorContextMenuGroup.add(undoAction);
    editorContextMenuGroup.add(redoAction);
    editorContextMenuGroup.addSeparator();
    editorContextMenuGroup.add(formatterAction);
    editorContextMenuGroup.addSeparator();
    editorContextMenuGroup.add(fullTextSearchAction);
    editorContextMenuGroup.add(closeActiveEditorAction);
    // Define hot-keys
    keyBinding.getGlobal().addKey(new KeyBuilder().action().alt().charCode('n').build(), NAVIGATE_TO_FILE);
    keyBinding.getGlobal().addKey(new KeyBuilder().action().charCode('F').build(), FULL_TEXT_SEARCH);
    keyBinding.getGlobal().addKey(new KeyBuilder().action().charCode('A').build(), FIND_ACTION);
    keyBinding.getGlobal().addKey(new KeyBuilder().alt().charCode('L').build(), FORMAT);
    keyBinding.getGlobal().addKey(new KeyBuilder().action().charCode('c').build(), COPY);
    keyBinding.getGlobal().addKey(new KeyBuilder().action().charCode('x').build(), CUT);
    keyBinding.getGlobal().addKey(new KeyBuilder().action().charCode('v').build(), PASTE);
    keyBinding.getGlobal().addKey(new KeyBuilder().shift().charCode(KeyCodeMap.F6).build(), RENAME);
    keyBinding.getGlobal().addKey(new KeyBuilder().shift().charCode(KeyCodeMap.F7).build(), SHOW_REFERENCE);
    keyBinding.getGlobal().addKey(new KeyBuilder().alt().charCode(KeyCodeMap.ARROW_LEFT).build(), SWITCH_LEFT_TAB);
    keyBinding.getGlobal().addKey(new KeyBuilder().alt().charCode(KeyCodeMap.ARROW_RIGHT).build(), SWITCH_RIGHT_TAB);
    keyBinding.getGlobal().addKey(new KeyBuilder().action().charCode('e').build(), OPEN_RECENT_FILES);
    keyBinding.getGlobal().addKey(new KeyBuilder().charCode(KeyCodeMap.DELETE).build(), DELETE_ITEM);
    keyBinding.getGlobal().addKey(new KeyBuilder().alt().charCode('N').build(), NEW_FILE);
    keyBinding.getGlobal().addKey(new KeyBuilder().alt().charCode('x').build(), CREATE_PROJECT);
    keyBinding.getGlobal().addKey(new KeyBuilder().alt().charCode('A').build(), IMPORT_PROJECT);
    if (UserAgent.isMac()) {
        keyBinding.getGlobal().addKey(new KeyBuilder().control().charCode('w').build(), CLOSE_ACTIVE_EDITOR);
        keyBinding.getGlobal().addKey(new KeyBuilder().control().charCode('p').build(), SIGNATURE_HELP);
    } else {
        keyBinding.getGlobal().addKey(new KeyBuilder().alt().charCode('w').build(), CLOSE_ACTIVE_EDITOR);
        keyBinding.getGlobal().addKey(new KeyBuilder().action().charCode('p').build(), SIGNATURE_HELP);
    }
    final Map<String, Perspective> perspectives = perspectiveManager.getPerspectives();
    if (perspectives.size() > 1) {
        //if registered perspectives will be more then 2 Main Menu -> Window
        // will appears and contains all of them as sub-menu
        final DefaultActionGroup windowMenu = new DefaultActionGroup("Window", true, actionManager);
        actionManager.registerAction("Window", windowMenu);
        final DefaultActionGroup mainMenu = (DefaultActionGroup) actionManager.getAction(GROUP_MAIN_MENU);
        mainMenu.add(windowMenu);
        for (Perspective perspective : perspectives.values()) {
            final Action action = new Action(perspective.getPerspectiveName()) {

                @Override
                public void actionPerformed(ActionEvent e) {
                    perspectiveManager.setPerspectiveId(perspective.getPerspectiveId());
                }
            };
            actionManager.registerAction(perspective.getPerspectiveId(), action);
            windowMenu.add(action);
        }
    }
}
Also used : KeyBuilder(org.eclipse.che.ide.api.keybinding.KeyBuilder) Perspective(org.eclipse.che.ide.api.parts.Perspective) FullTextSearchAction(org.eclipse.che.ide.actions.FullTextSearchAction) UndoAction(org.eclipse.che.ide.actions.UndoAction) LinkWithEditorAction(org.eclipse.che.ide.actions.LinkWithEditorAction) MinimizePartAction(org.eclipse.che.ide.actions.common.MinimizePartAction) ConvertFolderToProjectAction(org.eclipse.che.ide.actions.ConvertFolderToProjectAction) NavigateToFileAction(org.eclipse.che.ide.actions.NavigateToFileAction) UploadFolderAction(org.eclipse.che.ide.actions.UploadFolderAction) RestorePartAction(org.eclipse.che.ide.actions.common.RestorePartAction) CloseAllAction(org.eclipse.che.ide.part.editor.actions.CloseAllAction) RenameItemAction(org.eclipse.che.ide.actions.RenameItemAction) SaveAction(org.eclipse.che.ide.actions.SaveAction) ShowHiddenFilesAction(org.eclipse.che.ide.actions.ShowHiddenFilesAction) CutResourceAction(org.eclipse.che.ide.resources.action.CutResourceAction) SplitVerticallyAction(org.eclipse.che.ide.part.editor.actions.SplitVerticallyAction) DownloadWsAction(org.eclipse.che.ide.actions.DownloadWsAction) DownloadResourceAction(org.eclipse.che.ide.actions.DownloadResourceAction) PinEditorTabAction(org.eclipse.che.ide.part.editor.actions.PinEditorTabAction) RevealResourceAction(org.eclipse.che.ide.resources.action.RevealResourceAction) SwitchNextEditorAction(org.eclipse.che.ide.part.editor.actions.SwitchNextEditorAction) ImportProjectAction(org.eclipse.che.ide.actions.ImportProjectAction) NewXmlFileAction(org.eclipse.che.ide.xml.NewXmlFileAction) SaveAllAction(org.eclipse.che.ide.actions.SaveAllAction) CloseAction(org.eclipse.che.ide.part.editor.actions.CloseAction) CloseOtherAction(org.eclipse.che.ide.part.editor.actions.CloseOtherAction) GoIntoAction(org.eclipse.che.ide.actions.GoIntoAction) EditFileAction(org.eclipse.che.ide.actions.EditFileAction) HotKeysListAction(org.eclipse.che.ide.actions.HotKeysListAction) ProjectConfigurationAction(org.eclipse.che.ide.actions.ProjectConfigurationAction) RedoAction(org.eclipse.che.ide.actions.RedoAction) NewFileAction(org.eclipse.che.ide.newresource.NewFileAction) FormatterAction(org.eclipse.che.ide.actions.FormatterAction) OpenFileAction(org.eclipse.che.ide.actions.OpenFileAction) ReopenClosedFileAction(org.eclipse.che.ide.part.editor.actions.ReopenClosedFileAction) FindActionAction(org.eclipse.che.ide.actions.find.FindActionAction) ShowPreferencesAction(org.eclipse.che.ide.actions.ShowPreferencesAction) ClearRecentListAction(org.eclipse.che.ide.part.editor.recent.ClearRecentListAction) NewFolderAction(org.eclipse.che.ide.newresource.NewFolderAction) PasteResourceAction(org.eclipse.che.ide.resources.action.PasteResourceAction) CollapseAllAction(org.eclipse.che.ide.actions.CollapseAllAction) OpenRecentFilesAction(org.eclipse.che.ide.part.editor.recent.OpenRecentFilesAction) CreateProjectAction(org.eclipse.che.ide.actions.CreateProjectAction) CompleteAction(org.eclipse.che.ide.actions.CompleteAction) ExpandEditorAction(org.eclipse.che.ide.actions.ExpandEditorAction) DownloadProjectAction(org.eclipse.che.ide.actions.DownloadProjectAction) MaximizePartAction(org.eclipse.che.ide.actions.common.MaximizePartAction) ShowReferenceAction(org.eclipse.che.ide.actions.ShowReferenceAction) DeleteResourceAction(org.eclipse.che.ide.actions.DeleteResourceAction) CloseAllExceptPinnedAction(org.eclipse.che.ide.part.editor.actions.CloseAllExceptPinnedAction) SplitHorizontallyAction(org.eclipse.che.ide.part.editor.actions.SplitHorizontallyAction) CopyResourceAction(org.eclipse.che.ide.resources.action.CopyResourceAction) SwitchPreviousEditorAction(org.eclipse.che.ide.part.editor.actions.SwitchPreviousEditorAction) SignatureHelpAction(org.eclipse.che.ide.actions.SignatureHelpAction) Action(org.eclipse.che.ide.api.action.Action) UploadFileAction(org.eclipse.che.ide.actions.UploadFileAction) CloseActiveEditorAction(org.eclipse.che.ide.actions.CloseActiveEditorAction) RefreshPathAction(org.eclipse.che.ide.actions.RefreshPathAction) ActionEvent(org.eclipse.che.ide.api.action.ActionEvent) DefaultActionGroup(org.eclipse.che.ide.api.action.DefaultActionGroup)

Example 4 with KeyBuilder

use of org.eclipse.che.ide.api.keybinding.KeyBuilder in project che by eclipse.

the class MachineExtension method prepareActions.

@Inject
private void prepareActions(MachineLocalizationConstant localizationConstant, ActionManager actionManager, KeyBindingAgent keyBinding, ExecuteSelectedCommandAction executeSelectedCommandAction, SelectCommandComboBox selectCommandAction, EditCommandsAction editCommandsAction, StopWorkspaceAction stopWorkspaceAction, SwitchPerspectiveAction switchPerspectiveAction, RunCommandAction runCommandAction, NewTerminalAction newTerminalAction, EditTargetsAction editTargetsAction, IconRegistry iconRegistry, MachineResources machineResources, ReRunProcessAction reRunProcessAction, StopProcessAction stopProcessAction, CloseConsoleAction closeConsoleAction, ShowConsoleTreeAction showConsoleTreeAction) {
    final DefaultActionGroup workspaceMenu = (DefaultActionGroup) actionManager.getAction(GROUP_WORKSPACE);
    final DefaultActionGroup runMenu = (DefaultActionGroup) actionManager.getAction(GROUP_RUN);
    // register actions
    actionManager.registerAction("editCommands", editCommandsAction);
    actionManager.registerAction("selectCommandAction", selectCommandAction);
    actionManager.registerAction("executeSelectedCommand", executeSelectedCommandAction);
    actionManager.registerAction("editTargets", editTargetsAction);
    actionManager.registerAction("stopWorkspace", stopWorkspaceAction);
    actionManager.registerAction("runCommand", runCommandAction);
    actionManager.registerAction("newTerminal", newTerminalAction);
    // add actions in main menu
    runMenu.add(newTerminalAction, FIRST);
    runMenu.addSeparator();
    runMenu.add(editCommandsAction);
    runMenu.add(editTargetsAction);
    workspaceMenu.add(stopWorkspaceAction);
    if (centralToolbarVisible) {
        // add actions on center part of toolbar
        final DefaultActionGroup centerToolbarGroup = (DefaultActionGroup) actionManager.getAction(GROUP_CENTER_TOOLBAR);
        final DefaultActionGroup machineToolbarGroup = new DefaultActionGroup(GROUP_MACHINE_TOOLBAR, false, actionManager);
        actionManager.registerAction(GROUP_MACHINE_TOOLBAR, machineToolbarGroup);
        centerToolbarGroup.add(machineToolbarGroup, FIRST);
        machineToolbarGroup.add(selectCommandAction);
        final DefaultActionGroup executeToolbarGroup = new DefaultActionGroup(actionManager);
        executeToolbarGroup.add(executeSelectedCommandAction);
        machineToolbarGroup.add(executeToolbarGroup);
    }
    // add group for list of machines
    final DefaultActionGroup machinesList = new DefaultActionGroup(GROUP_MACHINES_DROPDOWN, true, actionManager);
    actionManager.registerAction(GROUP_MACHINES_LIST, machinesList);
    machinesList.add(editTargetsAction, FIRST);
    // add group for list of commands
    final DefaultActionGroup commandList = new DefaultActionGroup(GROUP_COMMANDS_DROPDOWN, true, actionManager);
    actionManager.registerAction(GROUP_COMMANDS_LIST, commandList);
    commandList.add(editCommandsAction, FIRST);
    // Consoles tree context menu group
    DefaultActionGroup consolesTreeContextMenu = (DefaultActionGroup) actionManager.getAction(GROUP_CONSOLES_TREE_CONTEXT_MENU);
    consolesTreeContextMenu.add(reRunProcessAction);
    consolesTreeContextMenu.add(stopProcessAction);
    consolesTreeContextMenu.add(closeConsoleAction);
    DefaultActionGroup partMenuGroup = (DefaultActionGroup) actionManager.getAction(IdeActions.GROUP_PART_MENU);
    partMenuGroup.add(showConsoleTreeAction);
    // Define hot-keys
    keyBinding.getGlobal().addKey(new KeyBuilder().alt().charCode(KeyCodeMap.F12).build(), "newTerminal");
    iconRegistry.registerIcon(new Icon("che.machine.icon", machineResources.devMachine()));
}
Also used : KeyBuilder(org.eclipse.che.ide.api.keybinding.KeyBuilder) 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)4 KeyBuilder (org.eclipse.che.ide.api.keybinding.KeyBuilder)4 Inject (com.google.inject.Inject)3 Constraints (org.eclipse.che.ide.api.constraints.Constraints)2 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 DownloadWsAction (org.eclipse.che.ide.actions.DownloadWsAction)1 EditFileAction (org.eclipse.che.ide.actions.EditFileAction)1 ExpandEditorAction (org.eclipse.che.ide.actions.ExpandEditorAction)1 FormatterAction (org.eclipse.che.ide.actions.FormatterAction)1 FullTextSearchAction (org.eclipse.che.ide.actions.FullTextSearchAction)1 GoIntoAction (org.eclipse.che.ide.actions.GoIntoAction)1 HotKeysListAction (org.eclipse.che.ide.actions.HotKeysListAction)1 ImportProjectAction (org.eclipse.che.ide.actions.ImportProjectAction)1