From aea1e5d58918e1574c9dbc342c70797b5f33551e Mon Sep 17 00:00:00 2001 From: Vincent Fugnitto Date: Wed, 31 Oct 2018 13:07:55 -0400 Subject: [PATCH] Create terminal main-menu item Fixes #3356 - Created new `Terminal` main menu item which encompasses both terminal and task commands - Remove `Task` menu and instead placed the items under the new `Terminal` main-menu - Fixed the ordering of the main-menu items to align with `vscode` Signed-off-by: Vincent Fugnitto --- examples/browser/test/top-panel/top-panel.ts | 4 ++-- .../browser/common-frontend-contribution.ts | 5 +++-- ...debug-frontend-application-contribution.ts | 2 +- packages/editor/src/browser/editor-menu.ts | 2 +- .../src/browser/task-frontend-contribution.ts | 22 +++++-------------- .../browser/terminal-frontend-contribution.ts | 19 +++++++++++----- 6 files changed, 27 insertions(+), 27 deletions(-) diff --git a/examples/browser/test/top-panel/top-panel.ts b/examples/browser/test/top-panel/top-panel.ts index fed00b730edb6..5cd2bf26af8c8 100644 --- a/examples/browser/test/top-panel/top-panel.ts +++ b/examples/browser/test/top-panel/top-panel.ts @@ -25,8 +25,8 @@ export class TopPanel { } openNewTerminal() { - this.clickMenuTab('File'); - this.clickSubMenu('Open New Terminal'); + this.clickMenuTab('Terminal'); + this.clickSubMenu('New Terminal'); } toggleCallHierarchyView() { diff --git a/packages/core/src/browser/common-frontend-contribution.ts b/packages/core/src/browser/common-frontend-contribution.ts index 7406b052ec72f..56036c894f6fd 100644 --- a/packages/core/src/browser/common-frontend-contribution.ts +++ b/packages/core/src/browser/common-frontend-contribution.ts @@ -46,11 +46,12 @@ export namespace CommonMenus { export const EDIT_CLIPBOARD = [...EDIT, '2_clipboard']; export const EDIT_FIND = [...EDIT, '3_find']; - export const VIEW = [...MAIN_MENU_BAR, '3_view']; + export const VIEW = [...MAIN_MENU_BAR, '4_view']; export const VIEW_VIEWS = [...VIEW, '1_views']; export const VIEW_LAYOUT = [...VIEW, '2_layout']; - export const HELP = [...MAIN_MENU_BAR, '4_help']; + // last menu item + export const HELP = [...MAIN_MENU_BAR, '9_help']; } diff --git a/packages/debug/src/browser/debug-frontend-application-contribution.ts b/packages/debug/src/browser/debug-frontend-application-contribution.ts index 72efc62b45cb7..594a1d08b65d1 100644 --- a/packages/debug/src/browser/debug-frontend-application-contribution.ts +++ b/packages/debug/src/browser/debug-frontend-application-contribution.ts @@ -44,7 +44,7 @@ import { DebugEditorService } from './editor/debug-editor-service'; import { DebugConsoleContribution } from './console/debug-console-contribution'; export namespace DebugMenus { - export const DEBUG = [...MAIN_MENU_BAR, '4_debug']; + export const DEBUG = [...MAIN_MENU_BAR, '6_debug']; export const DEBUG_CONTROLS = [...DEBUG, 'a_controls']; export const DEBUG_CONFIGURATION = [...DEBUG, 'b_configuration']; export const DEBUG_THREADS = [...DEBUG, 'c_threads']; diff --git a/packages/editor/src/browser/editor-menu.ts b/packages/editor/src/browser/editor-menu.ts index a72fd1a6aadb7..53775f397a25d 100644 --- a/packages/editor/src/browser/editor-menu.ts +++ b/packages/editor/src/browser/editor-menu.ts @@ -32,7 +32,7 @@ export namespace EditorMainMenu { /** * The main `Go` menu item. */ - export const GO = [...MAIN_MENU_BAR, '4_go']; + export const GO = [...MAIN_MENU_BAR, '5_go']; /** * Navigation menu group in the `Go` menu. diff --git a/packages/task/src/browser/task-frontend-contribution.ts b/packages/task/src/browser/task-frontend-contribution.ts index 924304935304c..924994f11868e 100644 --- a/packages/task/src/browser/task-frontend-contribution.ts +++ b/packages/task/src/browser/task-frontend-contribution.ts @@ -17,31 +17,23 @@ import { inject, injectable, named } from 'inversify'; import { ILogger, ContributionProvider } from '@theia/core/lib/common'; import { QuickOpenTask } from './quick-open-task'; -import { MAIN_MENU_BAR, CommandContribution, Command, CommandRegistry, MenuContribution, MenuModelRegistry } from '@theia/core/lib/common'; +import { CommandContribution, Command, CommandRegistry, MenuContribution, MenuModelRegistry } from '@theia/core/lib/common'; import { FrontendApplication, FrontendApplicationContribution, QuickOpenContribution, QuickOpenHandlerRegistry } from '@theia/core/lib/browser'; import { WidgetManager } from '@theia/core/lib/browser/widget-manager'; import { TaskContribution, TaskResolverRegistry, TaskProviderRegistry } from './task-contribution'; import { TaskService } from './task-service'; +import { TerminalMenus } from '@theia/terminal/lib/browser/terminal-frontend-contribution'; export namespace TaskCommands { - // Task menu - export const TASK_MENU = [...MAIN_MENU_BAR, '3_task']; - export const TASK_MENU_RUN = [...TASK_MENU, '1_run']; - export const TASK_MENU_LABEL = 'Task'; - // run task group - export const TASK = [...MAIN_MENU_BAR, '3_task']; - export const RUN_GROUP = [...TASK, '1_run']; - - // run task command export const TASK_RUN: Command = { id: 'task:run', - label: 'Tasks: Run...' + label: 'Tasks: Run Task...' }; export const TASK_ATTACH: Command = { id: 'task:attach', - label: 'Tasks: Attach...' + label: 'Tasks: Attach Task...' }; } @@ -107,15 +99,13 @@ export class TaskFrontendContribution implements CommandContribution, MenuContri } registerMenus(menus: MenuModelRegistry): void { - // Explicitly register the Task Submenu - menus.registerSubmenu(TaskCommands.TASK_MENU, TaskCommands.TASK_MENU_LABEL); - menus.registerMenuAction(TaskCommands.RUN_GROUP, { + menus.registerMenuAction(TerminalMenus.TERMINAL_TASKS, { commandId: TaskCommands.TASK_RUN.id, label: TaskCommands.TASK_RUN.label ? TaskCommands.TASK_RUN.label.slice('Tasks: '.length) : TaskCommands.TASK_RUN.label, order: '0' }); - menus.registerMenuAction(TaskCommands.RUN_GROUP, { + menus.registerMenuAction(TerminalMenus.TERMINAL_TASKS, { commandId: TaskCommands.TASK_ATTACH.id, label: TaskCommands.TASK_ATTACH.label ? TaskCommands.TASK_ATTACH.label.slice('Tasks: '.length) : TaskCommands.TASK_ATTACH.label, order: '1' diff --git a/packages/terminal/src/browser/terminal-frontend-contribution.ts b/packages/terminal/src/browser/terminal-frontend-contribution.ts index 43471c5b3e219..34ca872b36e99 100644 --- a/packages/terminal/src/browser/terminal-frontend-contribution.ts +++ b/packages/terminal/src/browser/terminal-frontend-contribution.ts @@ -25,7 +25,7 @@ import { SelectionService } from '@theia/core/lib/common'; import { - CommonMenus, ApplicationShell, KeybindingContribution, KeyCode, Key, + ApplicationShell, KeybindingContribution, KeyCode, Key, KeyModifier, KeybindingRegistry } from '@theia/core/lib/browser'; import { WidgetManager } from '@theia/core/lib/browser'; @@ -36,8 +36,14 @@ import { TerminalWidgetOptions, TerminalWidget } from './base/terminal-widget'; import { UriAwareCommandHandler } from '@theia/core/lib/common/uri-command-handler'; import { FileSystem } from '@theia/filesystem/lib/common'; import URI from '@theia/core/lib/common/uri'; +import { MAIN_MENU_BAR } from '@theia/core'; -const NAVIGATOR_CONTEXT_MENU_NEW = ['navigator-context-menu', '4_new']; +export namespace TerminalMenus { + export const TERMINAL = [...MAIN_MENU_BAR, '7_terminal']; + export const TERMINAL_NEW = [...TERMINAL, '1_terminal']; + export const TERMINAL_TASKS = [...TERMINAL, '2_terminal']; + export const TERMINAL_NAVIGATOR_CONTEXT_MENU = ['navigator-context-menu', '4_new']; +} export namespace TerminalCommands { export const NEW: Command = { @@ -101,10 +107,13 @@ export class TerminalFrontendContribution implements TerminalService, CommandCon } registerMenus(menus: MenuModelRegistry): void { - menus.registerMenuAction(CommonMenus.FILE_NEW, { - commandId: TerminalCommands.NEW.id + menus.registerSubmenu(TerminalMenus.TERMINAL, 'Terminal'); + menus.registerMenuAction(TerminalMenus.TERMINAL_NEW, { + commandId: TerminalCommands.NEW.id, + label: 'New Terminal', + order: '0' }); - menus.registerMenuAction(NAVIGATOR_CONTEXT_MENU_NEW, { + menus.registerMenuAction(TerminalMenus.TERMINAL_NAVIGATOR_CONTEXT_MENU, { commandId: TerminalCommands.TERMINAL_CONTEXT.id }); }