diff --git a/src/vs/platform/actions/common/actions.ts b/src/vs/platform/actions/common/actions.ts index 9300a276..1ff96592 100644 --- a/src/vs/platform/actions/common/actions.ts +++ b/src/vs/platform/actions/common/actions.ts @@ -78,6 +78,7 @@ export class MenuId { static readonly MenubarFileMenu = new MenuId('MenubarFileMenu'); static readonly MenubarGoMenu = new MenuId('MenubarGoMenu'); static readonly MenubarHelpMenu = new MenuId('MenubarHelpMenu'); + static readonly MenubarProjectMenu = new MenuId('MenubarProjectMenu'); static readonly MenubarLayoutMenu = new MenuId('MenubarLayoutMenu'); static readonly MenubarNewBreakpointMenu = new MenuId('MenubarNewBreakpointMenu'); static readonly MenubarPanelAlignmentMenu = new MenuId('MenubarPanelAlignmentMenu'); diff --git a/src/vs/platform/menubar/electron-main/menubar.ts b/src/vs/platform/menubar/electron-main/menubar.ts index 9fd8cca8..2d637109 100644 --- a/src/vs/platform/menubar/electron-main/menubar.ts +++ b/src/vs/platform/menubar/electron-main/menubar.ts @@ -296,7 +296,13 @@ export class Menubar { this.setMenuById(editMenu, 'Edit'); menubar.append(editMenuItem); } - + //Project + if (this.shouldDrawMenu('Project')) { + const projectMenu = new Menu(); + const projectMenuItem = new MenuItem({ label: this.mnemonicLabel(nls.localize({ key: 'mProject', comment: ['&& denotes a mnemonic'] }, "&&Project")), submenu: projectMenu, role: 'help' }); + this.setMenuById(projectMenu, 'Project'); + menubar.append(projectMenuItem); + } // Selection if (this.shouldDrawMenu('Selection')) { const selectionMenu = new Menu(); @@ -357,6 +363,8 @@ export class Menubar { menubar.append(helpMenuItem); } + + if (menubar.items && menubar.items.length > 0) { Menu.setApplicationMenu(menubar); } else { diff --git a/src/vs/workbench/browser/actions/projectActions.ts b/src/vs/workbench/browser/actions/projectActions.ts new file mode 100755 index 00000000..b6d3db52 --- /dev/null +++ b/src/vs/workbench/browser/actions/projectActions.ts @@ -0,0 +1,68 @@ +import { localize } from 'vs/nls'; +import { MenuId, MenuRegistry } from 'vs/platform/actions/common/actions'; + + +const commandCreateProject = "project.createProject"; +const commandConfigProject = "project.configProject"; +const commandPackageProject = "project.buildPackage"; +const commandDebugProject = "debug.openView"; +const commandRunProject = "workbench.action.tasks.runTask"; +const commandBuidProject = "workbench.action.tasks.build"; + + +MenuRegistry.appendMenuItem(MenuId.MenubarProjectMenu, { + group: '1_project', + command: { + id: commandCreateProject, + title: localize({ key: 'miDefault Template', comment: ['&& denotes a mnemonic'] }, "&&创建新的项目") + }, + order: 1 + //when: ContextKeyExpr.has('extension.helloWorld') +}); +MenuRegistry.appendMenuItem(MenuId.MenubarProjectMenu, { + group: '1_project', + command: { + id: commandConfigProject, + title: localize({ key: 'miDefault Template', comment: ['&& denotes a mnemonic'] }, "&&配置当前项目") + }, + order: 2 + //when: ContextKeyExpr.has('extension.helloWorld') +}); +MenuRegistry.appendMenuItem(MenuId.MenubarProjectMenu, { + group: '1_project', + command: { + id: commandBuidProject, + title: localize({ key: 'miDefault Template', comment: ['&& denotes a mnemonic'] }, "&&构建") + }, + order: 3 + //when: ContextKeyExpr.has('extension.helloWorld') +}); +MenuRegistry.appendMenuItem(MenuId.MenubarProjectMenu, { + group: '1_project', + command: { + id: commandDebugProject, + title: localize({ key: 'miDefault Template', comment: ['&& denotes a mnemonic'] }, "&&调试") + }, + order: 4 + //when: ContextKeyExpr.has('extension.helloWorld') +}); +MenuRegistry.appendMenuItem(MenuId.MenubarProjectMenu, { + group: '1_project', + command: { + id: commandRunProject, + title: localize({ key: 'miDefault Template', comment: ['&& denotes a mnemonic'] }, "&&运行") + }, + order: 5, + //when: ContextKeyExpr.has('extension.vscode-create-project') +}); +MenuRegistry.appendMenuItem(MenuId.MenubarProjectMenu, { + group: '1_project', + command: { + id: commandPackageProject, + title: localize({ key: 'miDefault Template', comment: ['&& denotes a mnemonic'] }, "&&打包") + }, + order: 6 + //when: ContextKeyExpr.has('extension.helloWorld') +}); + + diff --git a/src/vs/workbench/browser/parts/titlebar/menubarControl.ts b/src/vs/workbench/browser/parts/titlebar/menubarControl.ts index 88e69dc8..ae1cea59 100644 --- a/src/vs/workbench/browser/parts/titlebar/menubarControl.ts +++ b/src/vs/workbench/browser/parts/titlebar/menubarControl.ts @@ -114,6 +114,16 @@ MenuRegistry.appendMenuItem(MenuId.MenubarMainMenu, { order: 8 }); +MenuRegistry.appendMenuItem(MenuId.MenubarMainMenu, { + submenu: MenuId.MenubarProjectMenu, + title: { + value: 'Project', + original: 'Project', + mnemonicTitle: localize({ key: 'mProject', comment: ['&& denotes a mnemonic'] }, "&&Project") + }, + order: 10 +}); + MenuRegistry.appendMenuItem(MenuId.MenubarMainMenu, { submenu: MenuId.MenubarPreferencesMenu, title: { @@ -125,6 +135,7 @@ MenuRegistry.appendMenuItem(MenuId.MenubarMainMenu, { order: 9 }); + export abstract class MenubarControl extends Disposable { protected keys = [ diff --git a/src/vs/workbench/workbench.common.main.ts b/src/vs/workbench/workbench.common.main.ts index a9e13a7d..fc82d15f 100644 --- a/src/vs/workbench/workbench.common.main.ts +++ b/src/vs/workbench/workbench.common.main.ts @@ -346,4 +346,8 @@ import 'vs/workbench/contrib/list/browser/list.contribution'; // Audio Cues import 'vs/workbench/contrib/audioCues/browser/audioCues.contribution'; +//workspaces project +import 'vs/workbench/browser/actions/projectActions'; +//#endregion + //#endregion