Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create terminal main-menu item #3359

Merged
merged 1 commit into from
Nov 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions examples/browser/test/top-panel/top-panel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ export class TopPanel {
}

openNewTerminal() {
this.clickMenuTab('File');
this.clickSubMenu('Open New Terminal');
this.clickMenuTab('Terminal');
this.clickSubMenu('New Terminal');
}

toggleCallHierarchyView() {
Expand Down
5 changes: 3 additions & 2 deletions packages/core/src/browser/common-frontend-contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'];

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
Expand Down
2 changes: 1 addition & 1 deletion packages/editor/src/browser/editor-menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
28 changes: 9 additions & 19 deletions packages/task/src/browser/task-frontend-contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,31 +17,25 @@
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
const TASK_CATEGORY = 'Task';
export const TASK_RUN: Command = {
id: 'task:run',
label: 'Tasks: Run...'
category: TASK_CATEGORY,
label: 'Run Task...'
};

export const TASK_ATTACH: Command = {
id: 'task:attach',
label: 'Tasks: Attach...'
category: TASK_CATEGORY,
label: 'Attach Task...'
};
}

Expand Down Expand Up @@ -107,17 +101,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'
});
}
Expand Down
19 changes: 14 additions & 5 deletions packages/terminal/src/browser/terminal-frontend-contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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 {
const TERMINAL_CATEGORY = 'Terminal';
Expand Down Expand Up @@ -105,10 +111,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
});
}
Expand Down