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

#10696 Complete createStatusBarItem in window namespace from VSCode API #10754

Merged
merged 1 commit into from
Feb 15, 2022
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
- [core] Removed method `attachGlobalShortcuts` from `ElectronMainApplication`. Attaching shortcuts in that way interfered with internal shortcuts. Use internal keybindings instead of global shortcuts. [#10704](https://github.com/eclipse-theia/theia/pull/10704)
- [plugin-ext] function `logMeasurement` of `PluginDeployerImpl` class and browser class `HostedPluginSupport` is replaced by `measure` using the new `Stopwatch` API [#10407](https://github.com/eclipse-theia/theia/pull/10407)
- [plugin-ext] the constructor of `BackendApplication` class no longer invokes the `initialize` method. Instead, the `@postConstruct configure` method now starts by calling `initialize` [#10407](https://github.com/eclipse-theia/theia/pull/10407)
- [plugin] Added support for `vscode.window.createStatusBarItem` [#10754](https://github.com/eclipse-theia/theia/pull/10754) - Contributed on behalf of STMicroelectronics

## v1.22.0 - 1/27/2022

Expand Down
18 changes: 16 additions & 2 deletions packages/plugin-ext/src/plugin/plugin-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -413,8 +413,22 @@ export function createAPIFactory(
showInputBox(options?: theia.InputBoxOptions, token?: theia.CancellationToken): PromiseLike<string | undefined> {
return quickOpenExt.showInput(options, token);
},
createStatusBarItem(alignment?: theia.StatusBarAlignment, priority?: number): theia.StatusBarItem {
return statusBarMessageRegistryExt.createStatusBarItem(alignment, priority);
createStatusBarItem(alignmentOrId?: theia.StatusBarAlignment | string, priorityOrAlignment?: number | theia.StatusBarAlignment,
priorityArg?: number): theia.StatusBarItem {
let id: string | undefined;
let alignment: number | undefined;
let priority: number | undefined;

if (typeof alignmentOrId === 'string') {
id = alignmentOrId;
alignment = priorityOrAlignment;
priority = priorityArg;
} else {
alignment = alignmentOrId;
priority = priorityOrAlignment;
}

return statusBarMessageRegistryExt.createStatusBarItem(alignment, priority, id);
},
createOutputChannel(name: string): theia.OutputChannel {
return outputChannelRegistryExt.createOutputChannel(name, pluginToPluginInfo(plugin));
Expand Down
5 changes: 3 additions & 2 deletions packages/plugin-ext/src/plugin/status-bar-message-registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,10 @@ export class StatusBarMessageRegistryExt {

}

createStatusBarItem(alignment?: StatusBarAlignment, priority?: number): StatusBarItem {
return new StatusBarItemImpl(this.proxy, alignment, priority);
createStatusBarItem(alignment?: StatusBarAlignment, priority?: number, id?: string): StatusBarItem {
return new StatusBarItemImpl(this.proxy, alignment, priority, id);
}

}

// copied from https://github.com/Microsoft/vscode/blob/6c8f02b41db9ae5c4d15df767d47755e5c73b9d5/src/vs/workbench/api/node/extHostStatusBar.ts#L122
Expand Down
10 changes: 8 additions & 2 deletions packages/plugin-ext/src/plugin/status-bar/status-bar-item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { UUID } from '@theia/core/shared/@phosphor/coreutils';

export class StatusBarItemImpl implements theia.StatusBarItem {

private readonly id = StatusBarItemImpl.nextId();
private _id: string;

private _alignment: StatusBarAlignment;
private _priority: number;
Expand All @@ -37,10 +37,16 @@ export class StatusBarItemImpl implements theia.StatusBarItem {

constructor(_proxy: StatusBarMessageRegistryMain,
alignment: StatusBarAlignment = StatusBarAlignment.Left,
priority: number = 0) {
priority: number = 0,
id = StatusBarItemImpl.nextId()) {
this._proxy = _proxy;
this._alignment = alignment;
this._priority = priority;
this._id = id;
}

public get id(): string {
return this._id;
}

public get alignment(): theia.StatusBarAlignment {
Expand Down
12 changes: 11 additions & 1 deletion packages/plugin/src/theia.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4553,14 +4553,24 @@ export module '@theia/plugin' {
export function setStatusBarMessage(text: string, hideWhenDone: PromiseLike<any>): Disposable;

/**
* Creates a status bar [item](#StatusBarItem).
* Creates a status bar {@link StatusBarItem item}.
*
* @param alignment The alignment of the item.
* @param priority The priority of the item. Higher values mean the item should be shown more to the left.
* @return A new status bar item.
*/
export function createStatusBarItem(alignment?: StatusBarAlignment, priority?: number): StatusBarItem;

/**
* Creates a status bar {@link StatusBarItem item}.
*
* @param id The unique identifier of the item.
* @param alignment The alignment of the item.
* @param priority The priority of the item. Higher values mean the item should be shown more to the left.
* @return A new status bar item.
*/
export function createStatusBarItem(id: string, alignment?: StatusBarAlignment, priority?: number): StatusBarItem;

/**
* Create a new [output channel](#OutputChannel) with the given name.
*
Expand Down