Skip to content
This repository has been archived by the owner on Apr 4, 2023. It is now read-only.

Commit

Permalink
chore: Adapt Che-Theia to upstream changes (Monaco)
Browse files Browse the repository at this point in the history
Signed-off-by: Roman Nikitenko <[email protected]>
  • Loading branch information
RomanNikitenko committed Aug 2, 2021
1 parent b3ace5c commit dfe7934
Show file tree
Hide file tree
Showing 14 changed files with 1,156 additions and 1,463 deletions.
2 changes: 1 addition & 1 deletion build.include
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ IMAGE_TAG="next"
THEIA_GITHUB_REPO="eclipse-theia/theia"
THEIA_VERSION="master"
THEIA_BRANCH="master"
THEIA_COMMIT_SHA="9648953cd6e8552b7e027558509ba77770bd8b6f"
THEIA_COMMIT_SHA=
THEIA_GIT_REFS="refs\\/heads\\/master"
THEIA_DOCKER_IMAGE_VERSION=

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import * as React from 'react';
import { AboutDialog, AboutDialogProps, ABOUT_CONTENT_CLASS } from '@theia/core/lib/browser/about-dialog';
import { injectable, inject, postConstruct } from 'inversify';
import { CheProductService, Product } from '@eclipse-che/theia-plugin-ext/lib/common/che-protocol';
import { ThemeService, Theme } from '@theia/core/lib/browser/theming';
import { ThemeService, Theme, ThemeChangeEvent } from '@theia/core/lib/browser/theming';
import { Logo } from '@eclipse-che/plugin';

import '../../src/browser/style/che-theia-about.css';
Expand Down Expand Up @@ -67,7 +67,7 @@ export class AboutCheTheiaDialog extends AboutDialog {
const productLogo: Logo = productInfo.logo;
src = this.isDark(this.themeService.getCurrentTheme()) ? productLogo.dark : productLogo.light;

this.themeService.onThemeChange(e => {
this.themeService.onDidColorThemeChange((e: ThemeChangeEvent) => {
src = this.isDark(e.newTheme) ? productLogo.dark : productLogo.light;
});
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,21 @@
***********************************************************************/

import { DevfileComponentStatus, DevfileService } from '@eclipse-che/theia-remote-api/lib/common/devfile-service';
import {
QuickOpenGroupItem,
QuickOpenItem,
QuickOpenMode,
QuickOpenModel,
} from '@theia/core/lib/common/quick-open-model';
import { QuickOpenOptions, QuickOpenService } from '@theia/core/lib/browser/quick-open/quick-open-service';
import { QuickInputService, QuickPickItem } from '@theia/core/lib/browser';
import { inject, injectable } from 'inversify';

import { QuickOpenHandler } from '@theia/core/lib/browser/quick-open';

const CONTAINERS_PLACE_HOLDER = 'Pick a container to run the task';

@injectable()
export class ContainerPicker implements QuickOpenHandler, QuickOpenModel {
prefix: string = 'container ';
description: string = 'Pick a container name.';

export class ContainerPicker {
@inject(DevfileService)
protected readonly devfileService: DevfileService;

@inject(QuickOpenService)
protected readonly quickOpenService: QuickOpenService;
@inject(QuickInputService)
private readonly quickInputService: QuickInputService;

private componentStatuses: DevfileComponentStatus[];
protected items: QuickOpenGroupItem[];
protected items: QuickPickItem[];

/**
* Returns a container name if there's just one container in the current workspace.
Expand All @@ -58,21 +47,17 @@ export class ContainerPicker implements QuickOpenHandler, QuickOpenModel {
this.items.push(
...containerNames.map(
containerName =>
new QuickOpenGroupItem({
({
label: containerName,
showBorder: false,
run(mode: QuickOpenMode): boolean {
if (mode !== QuickOpenMode.OPEN) {
return false;
}
execute: (item: QuickPickItem) => {
resolve(containerName);
return true;
},
})
} as QuickPickItem)
)
);

this.quickOpenService.open(this, this.getOptions());
this.quickInputService.showQuickPick(this.items, { placeholder: CONTAINERS_PLACE_HOLDER });
});
}

Expand All @@ -89,77 +74,50 @@ export class ContainerPicker implements QuickOpenHandler, QuickOpenModel {
this.items = this.toQuickPickItems(container => {
resolve(container);
});
this.quickOpenService.open(this, this.getOptions());
this.quickInputService.showQuickPick(this.items, { placeholder: CONTAINERS_PLACE_HOLDER });
});
}

private toQuickPickItems(handler: { (containerName: string): void }): QuickOpenGroupItem[] {
const items: QuickOpenGroupItem[] = [];
private toQuickPickItems(handler: { (containerName: string): void }): QuickPickItem[] {
const items: QuickPickItem[] = [];

const devContainers = this.componentStatuses.filter(component => component.isUser);
const toolingContainers = this.componentStatuses.filter(component => !component.isUser);

items.push(
...devContainers.map(
(container, index) =>
new QuickOpenGroupItem({
label: container.name,
groupLabel:
index === 0 ? (devContainers.length === 1 ? 'Developer Container' : 'Developer Containers') : '',
showBorder: false,
run(mode: QuickOpenMode): boolean {
if (mode !== QuickOpenMode.OPEN) {
return false;
}
handler(container.name);
return true;
},
})
)
const devContainerItems = devContainers.map(
container =>
({
label: container.name,
execute: (item: QuickPickItem) => {
handler(container.name);
return true;
},
} as QuickPickItem)
);

items.push(
...toolingContainers.map(
(container, index) =>
new QuickOpenGroupItem({
label: container.name,
groupLabel:
devContainers.length <= 0
? ''
: index === 0
? toolingContainers.length === 1
? 'Tooling Container'
: 'Tooling Containers'
: '',
showBorder: devContainers.length <= 0 ? false : index === 0 ? true : false,
run(mode: QuickOpenMode): boolean {
if (mode !== QuickOpenMode.OPEN) {
return false;
}
handler(container.name);
return true;
},
})
)
);
if (devContainerItems.length > 0) {
const groupLabel = devContainers.length === 1 ? 'Developer Container' : 'Developer Containers';
devContainerItems.unshift({ type: 'separator', label: groupLabel });
}

return items;
}
const toolingContainerItems = toolingContainers.map(
container =>
({
label: container.name,
execute: (item: QuickPickItem) => {
handler(container.name);
return true;
},
} as QuickPickItem)
);

getOptions(): QuickOpenOptions {
return {
placeholder: CONTAINERS_PLACE_HOLDER,
fuzzyMatchLabel: true,
fuzzyMatchDescription: true,
fuzzySort: false,
};
}
if (toolingContainerItems.length > 0) {
const groupLabel = toolingContainers.length === 1 ? 'Tooling Container' : 'Tooling Containers';
toolingContainerItems.unshift({ type: 'separator', label: groupLabel });
}

onType(lookFor: string, acceptor: (items: QuickOpenItem[]) => void): void {
acceptor(this.items);
}
items.push(...devContainerItems, ...toolingContainerItems);

getModel(): QuickOpenModel {
return this;
return items;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import { inject, injectable } from 'inversify';

import { ChePluginManager } from './che-plugin-manager';
import { ChePluginRegistry } from '../../common/che-plugin-protocol';
import { MonacoQuickOpenService } from '@theia/monaco/lib/browser/monaco-quick-open-service';
import { QuickInputService } from '@theia/core/lib/browser';

function cmd(id: string, label: string): Command {
Expand Down Expand Up @@ -45,9 +44,6 @@ export class ChePluginCommandContribution implements CommandContribution {
@inject(QuickInputService)
protected readonly quickInputService: QuickInputService;

@inject(MonacoQuickOpenService)
protected readonly monacoQuickOpenService: MonacoQuickOpenService;

@inject(ChePluginManager)
protected readonly chePluginManager: ChePluginManager;

Expand All @@ -62,15 +58,15 @@ export class ChePluginCommandContribution implements CommandContribution {
* Makes new plugin registry active and displays a list of plugins from this registry.
*/
async addPluginRegistry(): Promise<void> {
const name = await this.quickInputService.open({
const name = await this.quickInputService.input({
prompt: 'Name of your registry',
});

if (!name) {
return;
}

const uri = await this.quickInputService.open({
const uri = await this.quickInputService.input({
prompt: 'Registry URI',
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,7 @@
* SPDX-License-Identifier: EPL-2.0
***********************************************************************/

import {
ApplicationShell,
Key,
KeyCode,
KeyModifier,
KeybindingRegistry,
QuickOpenContribution,
QuickOpenHandlerRegistry,
} from '@theia/core/lib/browser';
import { ApplicationShell, Key, KeyCode, KeyModifier, KeybindingRegistry } from '@theia/core/lib/browser';
import { Command, CommandRegistry, MenuModelRegistry } from '@theia/core/lib/common';
import {
REMOTE_TERMINAL_WIDGET_FACTORY_ID,
Expand Down Expand Up @@ -53,7 +45,7 @@ export interface OpenTerminalHandler {
}

@injectable()
export class ExecTerminalFrontendContribution extends TerminalFrontendContribution implements QuickOpenContribution {
export class ExecTerminalFrontendContribution extends TerminalFrontendContribution {
@inject(TerminalQuickOpenService)
private readonly terminalQuickOpen: TerminalQuickOpenService;

Expand Down Expand Up @@ -392,8 +384,4 @@ export class ExecTerminalFrontendContribution extends TerminalFrontendContributi
context: TerminalKeybindingContexts.terminalActive,
});
}

registerQuickOpenHandlers(handlers: QuickOpenHandlerRegistry): void {
handlers.registerHandler(this.terminalQuickOpen, false);
}
}
Loading

0 comments on commit dfe7934

Please sign in to comment.