status - push proposed API for statusbar id/name and adopt
This commit is contained in:
parent
96913ae480
commit
c6d9e8ea64
|
@ -83,7 +83,12 @@ export function activate(context: ExtensionContext) {
|
|||
|
||||
let documentSelector = ['json', 'jsonc'];
|
||||
|
||||
let schemaResolutionErrorStatusBarItem = window.createStatusBarItem(StatusBarAlignment.Right, 0);
|
||||
let schemaResolutionErrorStatusBarItem = window.createStatusBarItem({
|
||||
id: 'status.json.resolveError',
|
||||
name: localize('json.resolveError', "JSON: Schema Resolution Error"),
|
||||
alignment: StatusBarAlignment.Right,
|
||||
priority: 0
|
||||
});
|
||||
schemaResolutionErrorStatusBarItem.command = '_json.retryResolveSchema';
|
||||
schemaResolutionErrorStatusBarItem.tooltip = localize('json.schemaResolutionErrorMessage', 'Unable to resolve schema.') + ' ' + localize('json.clickToRetry', 'Click to retry.');
|
||||
schemaResolutionErrorStatusBarItem.text = '$(alert)';
|
||||
|
|
|
@ -23,7 +23,12 @@ class ExcludeHintItem {
|
|||
constructor(
|
||||
private readonly telemetryReporter: TelemetryReporter
|
||||
) {
|
||||
this._item = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Right, 98 /* to the right of typescript version status (99) */);
|
||||
this._item = vscode.window.createStatusBarItem({
|
||||
id: 'status.typescript.exclude',
|
||||
name: localize('statusExclude', "TypeScript: Configure Excludes"),
|
||||
alignment: vscode.StatusBarAlignment.Right,
|
||||
priority: 98 /* to the right of typescript version status (99) */
|
||||
});
|
||||
this._item.command = 'js.projectStatus.command';
|
||||
}
|
||||
|
||||
|
|
|
@ -7,6 +7,9 @@ import * as vscode from 'vscode';
|
|||
import * as languageModeIds from './languageModeIds';
|
||||
import { TypeScriptVersion } from './versionProvider';
|
||||
import { Disposable } from './dispose';
|
||||
import * as nls from 'vscode-nls';
|
||||
|
||||
const localize = nls.loadMessageBundle();
|
||||
|
||||
export default class VersionStatus extends Disposable {
|
||||
private readonly _versionBarEntry: vscode.StatusBarItem;
|
||||
|
@ -15,7 +18,12 @@ export default class VersionStatus extends Disposable {
|
|||
private readonly _normalizePath: (resource: vscode.Uri) => string | undefined
|
||||
) {
|
||||
super();
|
||||
this._versionBarEntry = this._register(vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Right, 99 /* to the right of editor status (100) */));
|
||||
this._versionBarEntry = this._register(vscode.window.createStatusBarItem({
|
||||
id: 'status.typescript.version',
|
||||
name: localize('typescriptVersion', "TypeScript: Version"),
|
||||
alignment: vscode.StatusBarAlignment.Right,
|
||||
priority: 99 /* to the right of editor status (100) */
|
||||
}));
|
||||
vscode.window.onDidChangeActiveTextEditor(this.showHideStatus, this, this._disposables);
|
||||
}
|
||||
|
||||
|
|
49
src/vs/vscode.proposed.d.ts
vendored
49
src/vs/vscode.proposed.d.ts
vendored
|
@ -1436,4 +1436,53 @@ declare module 'vscode' {
|
|||
}
|
||||
|
||||
// #endregion
|
||||
|
||||
|
||||
// #region Ben - status bar item with ID and Name
|
||||
|
||||
export namespace window {
|
||||
|
||||
/**
|
||||
* Options to configure the status bar item.
|
||||
*/
|
||||
export interface StatusBarItemOptions {
|
||||
|
||||
/**
|
||||
* A unique identifier of the status bar item. The identifier
|
||||
* is for example used to allow a user to show or hide the
|
||||
* status bar item in the UI.
|
||||
*/
|
||||
id: string;
|
||||
|
||||
/**
|
||||
* A human readable name of the status bar item. The name is
|
||||
* for example used as a label in the UI to show or hide the
|
||||
* status bar item.
|
||||
*/
|
||||
name: string;
|
||||
|
||||
/**
|
||||
* The alignment of the status bar item.
|
||||
*/
|
||||
alignment?: StatusBarAlignment;
|
||||
|
||||
/**
|
||||
* The priority of the status bar item. Higher value means the item should
|
||||
* be shown more to the left.
|
||||
*/
|
||||
priority?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a status bar [item](#StatusBarItem).
|
||||
*
|
||||
* @param options The options of the item. If not provided, some default values
|
||||
* will be assumed. For example, the `StatusBarItemOptions.id` will be the id
|
||||
* of the extension and the `StatusBarItemOptions.name` will be the extension name.
|
||||
* @return A new status bar item.
|
||||
*/
|
||||
export function createStatusBarItem(options?: StatusBarItemOptions): StatusBarItem;
|
||||
}
|
||||
|
||||
//#endregion
|
||||
}
|
||||
|
|
|
@ -465,11 +465,24 @@ export function createApiFactory(
|
|||
showSaveDialog(options) {
|
||||
return extHostDialogs.showSaveDialog(options);
|
||||
},
|
||||
createStatusBarItem(position?: vscode.StatusBarAlignment, priority?: number): vscode.StatusBarItem {
|
||||
const id = extension.identifier.value;
|
||||
const name = nls.localize('extensionLabel', "{0} (Extension)", extension.displayName || extension.name);
|
||||
createStatusBarItem(alignmentOrOptions?: vscode.StatusBarAlignment | vscode.window.StatusBarItemOptions, priority?: number): vscode.StatusBarItem {
|
||||
let id: string;
|
||||
let name: string;
|
||||
let alignment: number | undefined;
|
||||
|
||||
return extHostStatusBar.createStatusBarEntry(id, name, <number>position, priority);
|
||||
if (alignmentOrOptions && typeof alignmentOrOptions !== 'number') {
|
||||
id = alignmentOrOptions.id;
|
||||
name = alignmentOrOptions.name;
|
||||
alignment = alignmentOrOptions.alignment;
|
||||
priority = alignmentOrOptions.priority;
|
||||
} else {
|
||||
id = extension.identifier.value;
|
||||
name = nls.localize('extensionLabel', "{0} (Extension)", extension.displayName || extension.name);
|
||||
alignment = alignmentOrOptions;
|
||||
priority = priority;
|
||||
}
|
||||
|
||||
return extHostStatusBar.createStatusBarEntry(id, name, alignment, priority);
|
||||
},
|
||||
setStatusBarMessage(text: string, timeoutOrThenable?: number | Thenable<any>): vscode.Disposable {
|
||||
return extHostStatusBar.setStatusBarMessage(text, timeoutOrThenable);
|
||||
|
|
Loading…
Reference in a new issue