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

8969 upgrade monaco #1

Closed
wants to merge 2 commits into from
Closed
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
8 changes: 4 additions & 4 deletions packages/bulk-edit/src/browser/bulk-edit-contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,23 @@
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/

import { injectable, inject } from '@theia/core/shared/inversify';
import { injectable, inject, optional } from '@theia/core/shared/inversify';
import { Widget } from '@theia/core/lib/browser/widgets/widget';
import { CommandRegistry } from '@theia/core/lib/common';
import { AbstractViewContribution } from '@theia/core/lib/browser/shell/view-contribution';
import { BulkEditCommands } from './bulk-edit-commands';
import { MonacoBulkEditService } from '@theia/monaco/lib/browser/monaco-bulk-edit-service';
import { TabBarToolbarContribution, TabBarToolbarRegistry } from '@theia/core/lib/browser/shell/tab-bar-toolbar';
import { BulkEditTreeWidget, BULK_EDIT_TREE_WIDGET_ID } from './bulk-edit-tree';
import { QuickViewService } from '@theia/core/lib/browser/quick-view-service';
import { QuickViewService } from '@theia/core/lib/browser';

export const BULK_EDIT_WIDGET_NAME = 'Refactor Preview';

@injectable()
export class BulkEditContribution extends AbstractViewContribution<BulkEditTreeWidget> implements TabBarToolbarContribution {
private workspaceEdit: monaco.languages.WorkspaceEdit;

@inject(QuickViewService)
@inject(QuickViewService) @optional()
protected readonly quickView: QuickViewService;

constructor(private readonly bulkEditService: MonacoBulkEditService) {
Expand All @@ -46,7 +46,7 @@ export class BulkEditContribution extends AbstractViewContribution<BulkEditTreeW

registerCommands(registry: CommandRegistry): void {
super.registerCommands(registry);
this.quickView.hideItem(BULK_EDIT_WIDGET_NAME);
this.quickView?.hideItem(BULK_EDIT_WIDGET_NAME);

registry.registerCommand(BulkEditCommands.APPLY, {
isEnabled: widget => this.withWidget(widget, () => true),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/

import { injectable, inject } from '@theia/core/shared/inversify';
import { injectable, inject, optional } from '@theia/core/shared/inversify';
import {
TreeWidget, TreeProps, ContextMenuRenderer, TreeNode, TreeModel,
CompositeTreeNode, NodeProps
CompositeTreeNode, NodeProps, QuickViewService
} from '@theia/core/lib/browser';
import * as React from '@theia/core/shared/react';
import { BulkEditInfoNode, BulkEditNode } from './bulk-edit-tree';
Expand All @@ -28,7 +28,6 @@ import { EditorWidget, EditorManager, EditorOpenerOptions } from '@theia/editor/
import { DiffUris } from '@theia/core/lib/browser';
import { MEMORY_TEXT } from './in-memory-text-resource';
import { Disposable } from '@theia/core/lib/common/disposable';
import { QuickViewService } from '@theia/core/lib/browser/quick-view-service';

export const BULK_EDIT_TREE_WIDGET_ID = 'bulkedit';
export const BULK_EDIT_WIDGET_NAME = 'Refactor Preview';
Expand All @@ -43,7 +42,7 @@ export class BulkEditTreeWidget extends TreeWidget {
@inject(EditorManager)
protected readonly editorManager: EditorManager;

@inject(QuickViewService)
@inject(QuickViewService) @optional()
protected readonly quickView: QuickViewService;

constructor(
Expand All @@ -66,7 +65,7 @@ export class BulkEditTreeWidget extends TreeWidget {

async initModel(workspaceEdit: monaco.languages.WorkspaceEdit): Promise<void> {
await this.model.initModel(workspaceEdit, await this.getFileContentsMap(workspaceEdit));
this.quickView.showItem(BULK_EDIT_WIDGET_NAME);
this.quickView?.showItem(BULK_EDIT_WIDGET_NAME);
}

protected handleClickEvent(node: TreeNode | undefined, event: React.MouseEvent<HTMLElement>): void {
Expand Down Expand Up @@ -225,6 +224,6 @@ export class BulkEditTreeWidget extends TreeWidget {

private disposeEditors(): void {
this.editorWidgets.forEach(w => w.dispose());
this.quickView.hideItem(BULK_EDIT_WIDGET_NAME);
this.quickView?.hideItem(BULK_EDIT_WIDGET_NAME);
}
}
4 changes: 2 additions & 2 deletions packages/core/src/browser/color-application-contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ export class ColorApplicationContribution implements FrontendApplicationContribu
}

this.updateThemeBackground();
ThemeService.get().onThemeChange(() => this.updateThemeBackground());
ThemeService.get().onDidColorThemeChange(() => this.updateThemeBackground());

this.update();
ThemeService.get().onThemeChange(() => this.update());
ThemeService.get().onDidColorThemeChange(() => this.update());
this.colors.onDidChange(() => this.update());
}

Expand Down
125 changes: 58 additions & 67 deletions packages/core/src/browser/common-frontend-contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
/* eslint-disable max-len, @typescript-eslint/indent */

import debounce = require('lodash.debounce');
import { injectable, inject } from 'inversify';
import { injectable, inject, optional } from 'inversify';
import { TabBar, Widget } from '@phosphor/widgets';
import { MAIN_MENU_BAR, SETTINGS_MENU, MenuContribution, MenuModelRegistry, ACCOUNTS_MENU } from '../common/menu';
import { KeybindingContribution, KeybindingRegistry } from './keybinding';
Expand All @@ -38,8 +38,7 @@ import { ResourceContextKey } from './resource-context-key';
import { UriSelection } from '../common/selection';
import { StorageService } from './storage-service';
import { Navigatable } from './navigatable';
import { QuickViewService } from './quick-view-service';
import { PrefixQuickOpenService, QuickOpenItem, QuickOpenMode, QuickOpenService, QuickOpenGroupItem } from './quick-open';
import { QuickViewService } from './quick-input/quick-view-service';
import { environment } from '@theia/application-package/lib/environment';
import { IconThemeService } from './icon-theme-service';
import { ColorContribution } from './color-application-contribution';
Expand All @@ -53,6 +52,7 @@ import { UTF8 } from '../common/encodings';
import { EnvVariablesServer } from '../common/env-variables';
import { AuthenticationService } from './authentication-service';
import { FormatType } from './saveable';
import { QuickInputService, QuickPick, QuickPickItem } from './quick-input';

export namespace CommonMenus {

Expand Down Expand Up @@ -304,21 +304,15 @@ export class CommonFrontendContribution implements FrontendApplicationContributi
@inject(StorageService)
protected readonly storageService: StorageService;

@inject(QuickViewService)
protected readonly quickView: QuickViewService;

@inject(PrefixQuickOpenService)
protected readonly quickOpen: PrefixQuickOpenService;
@inject(QuickInputService) @optional()
protected readonly quickInputService: QuickInputService;

@inject(IconThemeService)
protected readonly iconThemes: IconThemeService;

@inject(ThemeService)
protected readonly themeService: ThemeService;

@inject(QuickOpenService)
protected readonly quickOpenService: QuickOpenService;

@inject(CorePreferences)
protected readonly preferences: CorePreferences;

Expand Down Expand Up @@ -363,7 +357,7 @@ export class CommonFrontendContribution implements FrontendApplicationContributi
this.updateThemeFromPreference(e.preferenceName);
}
});
this.themeService.onThemeChange(() => this.updateThemePreference('workbench.colorTheme'));
this.themeService.onDidColorThemeChange(() => this.updateThemePreference('workbench.colorTheme'));
this.iconThemes.onDidChangeCurrent(() => this.updateThemePreference('workbench.iconTheme'));

app.shell.leftPanelHandler.addMenu({
Expand Down Expand Up @@ -765,7 +759,7 @@ export class CommonFrontendContribution implements FrontendApplicationContributi
});

commandRegistry.registerCommand(CommonCommands.OPEN_VIEW, {
execute: () => this.quickOpen.open(this.quickView.prefix)
execute: () => this.quickInputService?.open(QuickViewService.PREFIX)
});

commandRegistry.registerCommand(CommonCommands.SELECT_COLOR_THEME, {
Expand Down Expand Up @@ -991,82 +985,79 @@ export class CommonFrontendContribution implements FrontendApplicationContributi
let resetTo: string | undefined = this.iconThemes.current;
const previewTheme = debounce((id: string) => this.iconThemes.current = id, 200);

let items: (QuickOpenItem & { id: string })[] = [];
let items: Array<QuickPickItem> = [];
for (const iconTheme of this.iconThemes.definitions) {
const item = Object.assign(new QuickOpenItem({
items.push({
id: iconTheme.id,
label: iconTheme.label,
description: iconTheme.description,
run: (mode: QuickOpenMode) => {
if (mode === QuickOpenMode.OPEN) {
resetTo = undefined;
}
previewTheme(iconTheme.id);
return true;
}
}), { id: iconTheme.id });
items.push(item);
});
}
items = items.sort((a, b) => {
if (a.id === 'none') {
return -1;
}
return a.getLabel()!.localeCompare(b.getLabel()!);
});
this.quickOpenService.open({
onType: (_, accept) => accept(items)
}, {
placeholder: 'Select File Icon Theme',
fuzzyMatchLabel: true,
selectIndex: () => items.findIndex(item => item.id === this.iconThemes.current),
onClose: () => {
if (resetTo) {
previewTheme.cancel();
this.iconThemes.current = resetTo;
}
}
return a.label!.localeCompare(b.label!);
});

this.quickInputService?.showQuickPick(items,
{
placeholder: 'Select File Icon Theme',
activeItem: items.find(item => item.id === resetTo),
onDidChangeSelection: (quickPick: QuickPick<QuickPickItem>, selectedItems: Array<QuickPickItem>) => {
resetTo = undefined;
previewTheme(selectedItems[0].id!);
},
onDidChangeActive: (quickPick: QuickPick<QuickPickItem>, activeItems: Array<QuickPickItem>) => {
previewTheme(activeItems[0].id!);
},
onDidHide: () => {
if (resetTo) {
this.iconThemes.current = resetTo;
}
}
});
}

protected selectColorTheme(): void {
let resetTo: string | undefined = this.themeService.getCurrentTheme().id;
const previewTheme = debounce((id: string) => this.themeService.setCurrentTheme(id), 200);

type ThemeQuickOpenItem = QuickOpenItem & { id: string };
const itemsByTheme: { light: ThemeQuickOpenItem[], dark: ThemeQuickOpenItem[], hc: ThemeQuickOpenItem[] } = { light: [], dark: [], hc: [] };
const itemsByTheme: { light: Array<QuickPickItem>, dark: Array<QuickPickItem>, hc: Array<QuickPickItem> } = { light: [], dark: [], hc: [] };
for (const theme of this.themeService.getThemes().sort((a, b) => a.label.localeCompare(b.label))) {
const themeItems = itemsByTheme[theme.type];
const groupLabel = themeItems.length === 0 ? (theme.type === 'hc' ? 'high contrast' : theme.type) + ' themes' : undefined;
themeItems.push(Object.assign(new QuickOpenGroupItem({
if (themeItems.length === 0) {
themeItems.push({
type: 'separator',
label: (theme.type === 'hc' ? 'high contrast' : theme.type) + ' themes'
});
}
themeItems.push({
id: theme.id,
label: theme.label,
description: theme.description,
run: (mode: QuickOpenMode) => {
if (mode === QuickOpenMode.OPEN) {
resetTo = undefined;
}
previewTheme(theme.id);
return true;
},
groupLabel,
showBorder: !!groupLabel && theme.type !== 'light'
}), { id: theme.id }));
});
}
const items = [...itemsByTheme.light, ...itemsByTheme.dark, ...itemsByTheme.hc];
this.quickOpenService.open({
onType: (_, accept) => accept(items)
}, {
placeholder: 'Select Color Theme (Up/Down Keys to Preview)',
fuzzyMatchLabel: true,
selectIndex: () => {
const current = this.themeService.getCurrentTheme().id;
return items.findIndex(item => item.id === current);
},
onClose: () => {
if (resetTo) {
previewTheme.cancel();
this.themeService.setCurrentTheme(resetTo);
this.quickInputService?.showQuickPick(items,
{
placeholder: 'Select Color Theme (Up/Down Keys to Preview)',
activeItem: items.find((item: QuickPickItem) => item.id === resetTo),
// eslint-disable-next-line @typescript-eslint/no-explicit-any
onDidChangeSelection: (quickPick: any, selectedItems: Array<QuickPickItem>) => {
resetTo = undefined;
previewTheme(selectedItems[0].id!);
},
// eslint-disable-next-line @typescript-eslint/no-explicit-any
onDidChangeActive: (quickPick: any, activeItems: Array<QuickPickItem>) => {
previewTheme(activeItems[0].id!);
},
onDidHide: () => {
if (resetTo) {
this.themeService.setCurrentTheme(resetTo);
}
}
}
});
});
}

registerColors(colors: ColorRegistry): void {
Expand Down
42 changes: 19 additions & 23 deletions packages/core/src/browser/frontend-application-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,6 @@ import { FrontendApplication, FrontendApplicationContribution, DefaultFrontendAp
import { DefaultOpenerService, OpenerService, OpenHandler } from './opener-service';
import { HttpOpenHandler } from './http-open-handler';
import { CommonFrontendContribution } from './common-frontend-contribution';
import {
QuickOpenService, QuickCommandService, QuickCommandFrontendContribution, QuickOpenContribution,
QuickOpenHandlerRegistry, CommandQuickOpenContribution, HelpQuickOpenHandler,
QuickOpenFrontendContribution, PrefixQuickOpenService, QuickInputService
} from './quick-open';
import { LocalStorageService, StorageService } from './storage-service';
import { WidgetFactory, WidgetManager } from './widget-manager';
import {
Expand All @@ -65,16 +60,13 @@ import { FrontendApplicationStateService } from './frontend-application-state';
import { JsonSchemaStore, JsonSchemaContribution, DefaultJsonSchemaContribution } from './json-schema-store';
import { TabBarToolbarRegistry, TabBarToolbarContribution, TabBarToolbarFactory, TabBarToolbar } from './shell/tab-bar-toolbar';
import { bindCorePreferences } from './core-preferences';
import { QuickPickServiceImpl } from './quick-open/quick-pick-service-impl';
import { QuickPickService, quickPickServicePath } from '../common/quick-pick-service';
import { ContextKeyService } from './context-key-service';
import { ResourceContextKey } from './resource-context-key';
import { KeyboardLayoutService } from './keyboard/keyboard-layout-service';
import { MimeService } from './mime-service';
import { ApplicationShellMouseTracker } from './shell/application-shell-mouse-tracker';
import { ViewContainer, ViewContainerIdentifier } from './view-container';
import { QuickViewService } from './quick-view-service';
import { QuickTitleBar } from './quick-open/quick-title-bar';
import { QuickViewService } from './quick-input/quick-view-service';
import { DialogOverlayService } from './dialogs';
import { ProgressLocationService } from './progress-location-service';
import { ProgressClient } from '../common/progress-service-protocol';
Expand All @@ -98,6 +90,15 @@ import { EncodingRegistry } from './encoding-registry';
import { EncodingService } from '../common/encoding-service';
import { AuthenticationService, AuthenticationServiceImpl } from '../browser/authentication-service';
import { DecorationsService, DecorationsServiceImpl } from './decorations-service';
import { QuickCommandFrontendContribution } from './quick-input/quick-command-frontend-contribution';
import { QuickHelpService } from './quick-input/quick-help-service';
import { QuickPickService, quickPickServicePath } from '../common/quick-pick-service';
import {
QuickPickServiceImpl,
QuickInputFrontendContribution
} from './quick-input';
import { QuickAccessContribution } from './quick-input/quick-access';
import { QuickCommandService } from './quick-input/quick-command-service';

export { bindResourceProvider, bindMessageService, bindPreferenceService };

Expand Down Expand Up @@ -196,7 +197,6 @@ export const frontendApplicationModule = new ContainerModule((bind, unbind, isBo
});
bind(CommandService).toService(CommandRegistry);
bindContributionProvider(bind, CommandContribution);
bind(QuickOpenContribution).to(CommandQuickOpenContribution);

bind(ContextKeyService).toSelf().inSingletonScope();

Expand Down Expand Up @@ -225,28 +225,24 @@ export const frontendApplicationModule = new ContainerModule((bind, unbind, isBo
bind(serviceIdentifier).toService(CommonFrontendContribution)
);

bind(QuickOpenService).toSelf().inSingletonScope();
bind(QuickInputService).toSelf().inSingletonScope();
bind(QuickTitleBar).toSelf().inSingletonScope();
bind(QuickCommandService).toSelf().inSingletonScope();
bind(QuickCommandFrontendContribution).toSelf().inSingletonScope();
[CommandContribution, KeybindingContribution, MenuContribution].forEach(serviceIdentifier =>
bind(serviceIdentifier).toService(QuickCommandFrontendContribution)
);
bind(QuickCommandService).toSelf().inSingletonScope();
bind(QuickAccessContribution).toService(QuickCommandService);

bind(QuickHelpService).toSelf().inSingletonScope();
bind(QuickAccessContribution).toService(QuickHelpService);

bind(QuickPickService).to(QuickPickServiceImpl).inSingletonScope().onActivation(({ container }, quickPickService: QuickPickService) => {
WebSocketConnectionProvider.createProxy(container, quickPickServicePath, quickPickService);
return quickPickService;
});

bind(PrefixQuickOpenService).toSelf().inSingletonScope();
bindContributionProvider(bind, QuickOpenContribution);
bind(QuickOpenHandlerRegistry).toSelf().inSingletonScope();
bind(QuickOpenFrontendContribution).toSelf().inSingletonScope();
bind(FrontendApplicationContribution).toService(QuickOpenFrontendContribution);

bind(HelpQuickOpenHandler).toSelf().inSingletonScope();
bind(QuickOpenContribution).toService(HelpQuickOpenHandler);
bindContributionProvider(bind, QuickAccessContribution);
bind(QuickInputFrontendContribution).toSelf().inSingletonScope();
bind(FrontendApplicationContribution).toService(QuickInputFrontendContribution);

bind(LocalStorageService).toSelf().inSingletonScope();
bind(StorageService).toService(LocalStorageService);
Expand Down Expand Up @@ -319,7 +315,7 @@ export const frontendApplicationModule = new ContainerModule((bind, unbind, isBo
});

bind(QuickViewService).toSelf().inSingletonScope();
bind(QuickOpenContribution).toService(QuickViewService);
bind(QuickAccessContribution).toService(QuickViewService);

bind(DialogOverlayService).toSelf().inSingletonScope();
bind(FrontendApplicationContribution).toService(DialogOverlayService);
Expand Down
Loading