forked from openkylin/kylin-code
增加判断项目插件是否存在来显示菜单栏按钮的功能
This commit is contained in:
parent
2862ab14fb
commit
5ec0c4200d
|
@ -40,6 +40,7 @@ import { IsMacNativeContext, IsWebContext } from 'vs/platform/contextkey/common/
|
|||
import { ICommandService } from 'vs/platform/commands/common/commands';
|
||||
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { OpenRecentAction } from 'vs/workbench/browser/actions/windowActions';
|
||||
import { IWorkbenchExtensionEnablementService } from 'vs/workbench/services/extensionManagement/common/extensionManagement';
|
||||
|
||||
export type IOpenRecentAction = IAction & { uri: URI; remoteAuthority?: string };
|
||||
|
||||
|
@ -158,6 +159,7 @@ export abstract class MenubarControl extends Disposable {
|
|||
protected recentlyOpened: IRecentlyOpened = { files: [], workspaces: [] };
|
||||
|
||||
protected menuUpdater: RunOnceScheduler;
|
||||
protected hasCreateProjectExternsion: boolean = false;
|
||||
|
||||
protected static readonly MAX_MENU_RECENT_ENTRIES = 10;
|
||||
|
||||
|
@ -175,7 +177,8 @@ export abstract class MenubarControl extends Disposable {
|
|||
protected readonly environmentService: IWorkbenchEnvironmentService,
|
||||
protected readonly accessibilityService: IAccessibilityService,
|
||||
protected readonly hostService: IHostService,
|
||||
protected readonly commandService: ICommandService
|
||||
protected readonly commandService: ICommandService,
|
||||
protected readonly extensionEnablementService: IWorkbenchExtensionEnablementService,
|
||||
) {
|
||||
|
||||
super();
|
||||
|
@ -210,6 +213,33 @@ export abstract class MenubarControl extends Disposable {
|
|||
|
||||
// Update recent menu items on formatter registration
|
||||
this._register(this.labelService.onDidChangeFormatters(() => { this.onDidChangeRecentlyOpened(); }));
|
||||
this._register(this.extensionEnablementService.onEnablementChanged((extensions) => {
|
||||
for (const extension of extensions) {
|
||||
let isenable: boolean;
|
||||
try {
|
||||
isenable = this.extensionEnablementService.isEnabled(extension);
|
||||
} catch (err) {
|
||||
isenable = false;
|
||||
}
|
||||
if (isenable) {
|
||||
if (extension.identifier.id = "kylin.vscode-create-project") {
|
||||
console.log("kylin.vscode-create-project is enable " + extension.identifier.id);
|
||||
this.hasCreateProjectExternsion = true;
|
||||
this.setupMainMenu();
|
||||
this.doUpdateMenubar(true);
|
||||
}
|
||||
} else {
|
||||
if (extension.identifier.id = "kylin.vscode-create-project") {
|
||||
console.log("kylin.vscode-create-project is disable " + extension.identifier.id);
|
||||
this.hasCreateProjectExternsion = false;
|
||||
this.setupMainMenu();
|
||||
this.doUpdateMenubar(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}));
|
||||
|
||||
// Listen for changes on the main menu
|
||||
this._register(this.mainMenu.onDidChange(() => { this.setupMainMenu(); this.doUpdateMenubar(true); }));
|
||||
|
@ -223,6 +253,11 @@ export abstract class MenubarControl extends Disposable {
|
|||
const [, mainMenuActions] = this.mainMenu.getActions()[0];
|
||||
for (const mainMenuAction of mainMenuActions) {
|
||||
if (mainMenuAction instanceof SubmenuItemAction && typeof mainMenuAction.item.title !== 'string') {
|
||||
if (mainMenuAction.item.title.original == "Project") {
|
||||
if (this.hasCreateProjectExternsion == false) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
this.menus[mainMenuAction.item.title.original] = this.mainMenuDisposables.add(this.menuService.createMenu(mainMenuAction.item.submenu, this.contextKeyService));
|
||||
this.topLevelTitles[mainMenuAction.item.title.original] = mainMenuAction.item.title.mnemonicTitle ?? mainMenuAction.item.title.value;
|
||||
}
|
||||
|
@ -410,9 +445,11 @@ export class CustomMenubarControl extends MenubarControl {
|
|||
@IWorkbenchLayoutService private readonly layoutService: IWorkbenchLayoutService,
|
||||
@ITelemetryService private readonly telemetryService: ITelemetryService,
|
||||
@IHostService hostService: IHostService,
|
||||
@ICommandService commandService: ICommandService
|
||||
@ICommandService commandService: ICommandService,
|
||||
@IWorkbenchExtensionEnablementService extensionEnablementService: IWorkbenchExtensionEnablementService,
|
||||
|
||||
) {
|
||||
super(menuService, workspacesService, contextKeyService, keybindingService, configurationService, labelService, updateService, storageService, notificationService, preferencesService, environmentService, accessibilityService, hostService, commandService);
|
||||
super(menuService, workspacesService, contextKeyService, keybindingService, configurationService, labelService, updateService, storageService, notificationService, preferencesService, environmentService, accessibilityService, hostService, commandService, extensionEnablementService);
|
||||
|
||||
this._onVisibilityChange = this._register(new Emitter<boolean>());
|
||||
this._onFocusStateChange = this._register(new Emitter<boolean>());
|
||||
|
|
|
@ -25,6 +25,7 @@ import { IHostService } from 'vs/workbench/services/host/browser/host';
|
|||
import { IPreferencesService } from 'vs/workbench/services/preferences/common/preferences';
|
||||
import { ICommandService } from 'vs/platform/commands/common/commands';
|
||||
import { OpenRecentAction } from 'vs/workbench/browser/actions/windowActions';
|
||||
import { IWorkbenchExtensionEnablementService } from 'vs/workbench/services/extensionManagement/common/extensionManagement';
|
||||
|
||||
export class NativeMenubarControl extends MenubarControl {
|
||||
|
||||
|
@ -45,8 +46,9 @@ export class NativeMenubarControl extends MenubarControl {
|
|||
@IHostService hostService: IHostService,
|
||||
@INativeHostService private readonly nativeHostService: INativeHostService,
|
||||
@ICommandService commandService: ICommandService,
|
||||
@IWorkbenchExtensionEnablementService extensionEnablementService: IWorkbenchExtensionEnablementService,
|
||||
) {
|
||||
super(menuService, workspacesService, contextKeyService, keybindingService, configurationService, labelService, updateService, storageService, notificationService, preferencesService, environmentService, accessibilityService, hostService, commandService);
|
||||
super(menuService, workspacesService, contextKeyService, keybindingService, configurationService, labelService, updateService, storageService, notificationService, preferencesService, environmentService, accessibilityService, hostService, commandService, extensionEnablementService);
|
||||
|
||||
(async () => {
|
||||
this.recentlyOpened = await this.workspacesService.getRecentlyOpened();
|
||||
|
|
Loading…
Reference in New Issue