From b039076c8e3f602324b956388e0a0860aed75fdb Mon Sep 17 00:00:00 2001 From: Akos Kitta Date: Fri, 1 Sep 2017 12:18:18 +0200 Subject: [PATCH] GH-210: Fixed issues after the messed-up rebase attempt. Signed-off-by: Akos Kitta --- .../browser/common-frontend-contribution.ts | 57 ++++++++++++++++--- .../menu/core-menu-contribution.ts | 3 +- packages/monaco/src/browser/monaco-command.ts | 9 +-- packages/monaco/src/browser/monaco-menu.ts | 8 +-- 4 files changed, 54 insertions(+), 23 deletions(-) diff --git a/packages/core/src/browser/common-frontend-contribution.ts b/packages/core/src/browser/common-frontend-contribution.ts index e8ed2966ce632..97e86c2ea172d 100644 --- a/packages/core/src/browser/common-frontend-contribution.ts +++ b/packages/core/src/browser/common-frontend-contribution.ts @@ -13,17 +13,22 @@ import { FrontendApplication } from '../browser/frontend-application'; import { injectable, inject } from "inversify"; export namespace CommonCommands { + export const EDIT_MENU = "2_edit"; export const EDIT_MENU_UNDO_GROUP = "1_undo/redo"; - export const EDIT_MENU_COPYPASTE_GROUP = "2_copy"; + export const EDIT_MENU_CUT_COPY_PASTE_GROUP = "2_cut/copy/paste"; + export const EDIT_MENU_FIND_REPLACE_GROUP = "3_find/replace"; - export const EDIT_CUT = 'edit_cut'; - export const EDIT_COPY = 'edit_copy'; - export const EDIT_PASTE = 'edit_paste'; + export const EDIT_CUT = 'editor.action.clipboardCutAction'; + export const EDIT_COPY = 'editor.action.clipboardCopyAction'; + export const EDIT_PASTE = 'editor.action.clipboardPasteAction'; export const EDIT_UNDO = 'undo'; export const EDIT_REDO = 'redo'; + export const EDIT_FIND = 'actions.find'; + export const EDIT_REPLACE = 'editor.action.startFindReplaceAction'; + export const TAB_NEXT: Command = { id: 'tab:next', label: 'Switch to next tab' @@ -44,18 +49,42 @@ export class CommonFrontendContribution implements MenuContribution, CommandCont registerMenus(registry: MenuModelRegistry): void { // Explicitly register the Edit Submenu registry.registerSubmenu([MAIN_MENU_BAR], CommonCommands.EDIT_MENU, "Edit"); - registry.registerMenuAction([MAIN_MENU_BAR, CommonCommands.EDIT_MENU, CommonCommands.EDIT_MENU_UNDO_GROUP], { - commandId: CommonCommands.EDIT_UNDO - }); + + // Undo/Redo + registry.registerMenuAction([ + MAIN_MENU_BAR, + CommonCommands.EDIT_MENU, + CommonCommands.EDIT_MENU_UNDO_GROUP], { + commandId: CommonCommands.EDIT_UNDO, + order: '0' + }); registry.registerMenuAction([ MAIN_MENU_BAR, CommonCommands.EDIT_MENU, CommonCommands.EDIT_MENU_UNDO_GROUP], { - commandId: CommonCommands.EDIT_REDO + commandId: CommonCommands.EDIT_REDO, + order: '1' + }); + + // Find/Replace + registry.registerMenuAction([ + MAIN_MENU_BAR, + CommonCommands.EDIT_MENU, + CommonCommands.EDIT_MENU_FIND_REPLACE_GROUP], { + commandId: CommonCommands.EDIT_FIND, + order: '0' + }); + registry.registerMenuAction([ + MAIN_MENU_BAR, + CommonCommands.EDIT_MENU, + CommonCommands.EDIT_MENU_FIND_REPLACE_GROUP], { + commandId: CommonCommands.EDIT_REPLACE, + order: '1' }); } registerCommands(commandRegistry: CommandRegistry): void { + commandRegistry.registerCommand({ id: CommonCommands.EDIT_CUT, label: 'Cut' @@ -68,6 +97,7 @@ export class CommonFrontendContribution implements MenuContribution, CommandCont id: CommonCommands.EDIT_PASTE, label: 'Paste' }); + commandRegistry.registerCommand({ id: CommonCommands.EDIT_UNDO, label: 'Undo' @@ -76,11 +106,20 @@ export class CommonFrontendContribution implements MenuContribution, CommandCont id: CommonCommands.EDIT_REDO, label: 'Redo' }); + + commandRegistry.registerCommand({ + id: CommonCommands.EDIT_FIND, + label: 'Find' + }); + commandRegistry.registerCommand({ + id: CommonCommands.EDIT_REPLACE, + label: 'Replace' + }); + commandRegistry.registerCommand(CommonCommands.TAB_NEXT, { isEnabled: () => this.app.shell.hasSelectedTab(), execute: () => this.app.shell.activateNextTab() }); - commandRegistry.registerCommand(CommonCommands.TAB_PREVIOUS, { isEnabled: () => this.app.shell.hasSelectedTab(), execute: () => this.app.shell.activatePreviousTab() diff --git a/packages/core/src/electron-browser/menu/core-menu-contribution.ts b/packages/core/src/electron-browser/menu/core-menu-contribution.ts index ee8daad72c14a..17942e780c6a8 100644 --- a/packages/core/src/electron-browser/menu/core-menu-contribution.ts +++ b/packages/core/src/electron-browser/menu/core-menu-contribution.ts @@ -6,7 +6,8 @@ */ import { injectable } from "inversify"; -import { MenuContribution, MenuModelRegistry, MAIN_MENU_BAR, CommonCommands } from "../../common"; +import { CommonCommands } from "../../browser"; +import { MenuContribution, MenuModelRegistry, MAIN_MENU_BAR } from "../../common"; export namespace ElectronMenus { export const HELP = [MAIN_MENU_BAR, "4_help"]; diff --git a/packages/monaco/src/browser/monaco-command.ts b/packages/monaco/src/browser/monaco-command.ts index 9e75f1b00f2e6..17a550e7c8273 100644 --- a/packages/monaco/src/browser/monaco-command.ts +++ b/packages/monaco/src/browser/monaco-command.ts @@ -7,15 +7,10 @@ import { injectable, inject } from "inversify"; import { ProtocolToMonacoConverter } from "monaco-languageclient/lib"; -<<<<<<< HEAD -import { CommandHandler, CommandContribution, CommandRegistry, SelectionService } from '@theia/core/lib/common'; -import { CommonCommands } from '@theia/core/lib/browser'; -import { EditorManager, TextEditorSelection, SHOW_REFERENCES } from '@theia/editor/lib/browser'; -======= ->>>>>>> 9748b0e... GH-210: Registered `selection` commands, handlers and menu items. import { Position, Location } from "@theia/languages/lib/common"; +import { CommonCommands } from '@theia/core/lib/browser'; import { EditorManager, TextEditorSelection, SHOW_REFERENCES } from '@theia/editor/lib/browser'; -import { CommandHandler, CommandContribution, CommandRegistry, CommonCommands, SelectionService } from '@theia/core/lib/common'; +import { CommandHandler, CommandContribution, CommandRegistry, SelectionService } from '@theia/core/lib/common'; import { getCurrent, MonacoEditor } from './monaco-editor'; import MenuRegistry = monaco.actions.MenuRegistry; import MenuId = monaco.actions.MenuId; diff --git a/packages/monaco/src/browser/monaco-menu.ts b/packages/monaco/src/browser/monaco-menu.ts index a165651325ac0..d05f0b53d5967 100644 --- a/packages/monaco/src/browser/monaco-menu.ts +++ b/packages/monaco/src/browser/monaco-menu.ts @@ -6,12 +6,8 @@ */ import { injectable } from "inversify"; -<<<<<<< HEAD -import { MenuContribution, MenuModelRegistry } from "@theia/core/lib/common"; -import { CommonCommands } from '@theia/core/lib/browser'; -======= -import { MenuContribution, MenuModelRegistry, CommonCommands, MAIN_MENU_BAR } from "@theia/core/lib/common"; ->>>>>>> 9748b0e... GH-210: Registered `selection` commands, handlers and menu items. +import { MenuContribution, MenuModelRegistry, MAIN_MENU_BAR } from "@theia/core/lib/common"; +import { CommonCommands } from "@theia/core/lib/browser"; import { EDITOR_CONTEXT_MENU_ID } from "@theia/editor/lib/browser"; import { MonacoSelectionCommands } from "./monaco-command"; import MenuRegistry = monaco.actions.MenuRegistry;