提交 b297efad 编写于 作者: M Matt Bierner

Extract interface

上级 f8870d79
......@@ -10,7 +10,7 @@ import { TPromise } from 'vs/base/common/winjs.base';
import { localize } from 'vs/nls';
import { ILifecycleService } from 'vs/platform/lifecycle/common/lifecycle';
import { IOpenerService } from 'vs/platform/opener/common/opener';
import { ExtHostContext, ExtHostWebviewsShape, IExtHostContext, MainContext, MainThreadWebviewsShape, WebviewPanelHandle } from 'vs/workbench/api/node/extHost.protocol';
import { ExtHostContext, ExtHostWebviewsShape, IExtHostContext, MainContext, MainThreadWebviewsShape, WebviewPanelHandle, WebviewPanelShowOptions } from 'vs/workbench/api/node/extHost.protocol';
import { editorGroupToViewColumn, EditorViewColumn, viewColumnToEditorGroup } from 'vs/workbench/api/shared/editor';
import { WebviewEditor } from 'vs/workbench/parts/webview/electron-browser/webviewEditor';
import { WebviewEditorInput } from 'vs/workbench/parts/webview/electron-browser/webviewEditorInput';
......@@ -145,15 +145,15 @@ export class MainThreadWebviews implements MainThreadWebviewsShape, WebviewReviv
webview.setOptions(reviveWebviewOptions(options));
}
public $reveal(handle: WebviewPanelHandle, viewColumn: EditorViewColumn | null, preserveFocus: boolean): void {
public $reveal(handle: WebviewPanelHandle, showOptions: WebviewPanelShowOptions): void {
const webview = this.getWebview(handle);
if (webview.isDisposed()) {
return;
}
const targetGroup = this._editorGroupService.getGroup(viewColumnToEditorGroup(this._editorGroupService, viewColumn));
const targetGroup = this._editorGroupService.getGroup(viewColumnToEditorGroup(this._editorGroupService, showOptions.viewColumn));
this._webviewService.revealWebview(webview, targetGroup || this._editorGroupService.activeGroup, preserveFocus);
this._webviewService.revealWebview(webview, targetGroup || this._editorGroupService.activeGroup, showOptions.preserveFocus);
}
public $postMessage(handle: WebviewPanelHandle, message: any): TPromise<boolean> {
......
......@@ -425,10 +425,15 @@ export interface MainThreadTelemetryShape extends IDisposable {
export type WebviewPanelHandle = string;
export interface WebviewPanelShowOptions {
readonly viewColumn?: EditorViewColumn;
readonly preserveFocus?: boolean;
}
export interface MainThreadWebviewsShape extends IDisposable {
$createWebviewPanel(handle: WebviewPanelHandle, viewType: string, title: string, viewOptions: { viewColumn: EditorViewColumn, preserveFocus: boolean }, options: vscode.WebviewPanelOptions & vscode.WebviewOptions, extensionLocation: UriComponents): void;
$createWebviewPanel(handle: WebviewPanelHandle, viewType: string, title: string, showOptions: WebviewPanelShowOptions, options: vscode.WebviewPanelOptions & vscode.WebviewOptions, extensionLocation: UriComponents): void;
$disposeWebview(handle: WebviewPanelHandle): void;
$reveal(handle: WebviewPanelHandle, viewColumn: EditorViewColumn | null, preserveFocus: boolean): void;
$reveal(handle: WebviewPanelHandle, showOptions: WebviewPanelShowOptions): void;
$setTitle(handle: WebviewPanelHandle, value: string): void;
$setIconPath(handle: WebviewPanelHandle, value: { light: UriComponents, dark: UriComponents } | undefined): void;
$setHtml(handle: WebviewPanelHandle, value: string): void;
......
......@@ -208,9 +208,10 @@ export class ExtHostWebviewPanel implements vscode.WebviewPanel {
public reveal(viewColumn?: vscode.ViewColumn, preserveFocus?: boolean): void {
this.assertNotDisposed();
this._proxy.$reveal(this._handle,
viewColumn ? typeConverters.ViewColumn.from(viewColumn) : undefined,
!!preserveFocus);
this._proxy.$reveal(this._handle, {
viewColumn: viewColumn ? typeConverters.ViewColumn.from(viewColumn) : undefined,
preserveFocus: !!preserveFocus
});
}
private assertNotDisposed() {
......
......@@ -11,7 +11,7 @@ import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
export class WebviewFindWidget extends SimpleFindWidget {
constructor(
private webview: WebviewElement,
private _webview: WebviewElement,
@IContextViewService contextViewService: IContextViewService,
@IContextKeyService contextKeyService: IContextKeyService
) {
......@@ -19,45 +19,45 @@ export class WebviewFindWidget extends SimpleFindWidget {
}
dispose() {
this.webview = undefined;
this._webview = undefined;
super.dispose();
}
public find(previous: boolean) {
const val = this.inputValue;
if (val) {
this.webview.find(val, { findNext: true, forward: !previous });
this._webview.find(val, { findNext: true, forward: !previous });
}
}
public hide() {
super.hide();
this.webview.stopFind(true);
this.webview.focus();
this._webview.stopFind(true);
this._webview.focus();
}
public onInputChanged() {
const val = this.inputValue;
if (val) {
this.webview.startFind(val);
this._webview.startFind(val);
} else {
this.webview.stopFind(false);
this._webview.stopFind(false);
}
}
protected onFocusTrackerFocus() {
this.webview.notifyFindWidgetFocusChanged(true);
this._webview.notifyFindWidgetFocusChanged(true);
}
protected onFocusTrackerBlur() {
this.webview.notifyFindWidgetFocusChanged(false);
this._webview.notifyFindWidgetFocusChanged(false);
}
protected onFindInputFocusTrackerFocus() {
this.webview.notifyFindWidgetInputFocusChanged(true);
this._webview.notifyFindWidgetInputFocusChanged(true);
}
protected onFindInputFocusTrackerBlur() {
this.webview.notifyFindWidgetInputFocusChanged(false);
this._webview.notifyFindWidgetInputFocusChanged(false);
}
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册