提交 5eff1e2e 编写于 作者: B Benjamin Pasero

views - adopt new visibility event (part of #65475)

上级 cdb8a86f
......@@ -62,14 +62,18 @@ export class CommentsPanel extends Panel {
this.createTree();
this.createMessageBox(container);
this.commentService.onDidSetAllCommentThreads(this.onAllCommentsChanged, this);
this.commentService.onDidUpdateCommentThreads(this.onCommentsUpdated, this);
this._register(this.commentService.onDidSetAllCommentThreads(this.onAllCommentsChanged, this));
this._register(this.commentService.onDidUpdateCommentThreads(this.onCommentsUpdated, this));
const styleElement = dom.createStyleSheet(parent);
this.applyStyles(styleElement);
this.themeService.onThemeChange(_ => {
this.applyStyles(styleElement);
});
this._register(this.themeService.onThemeChange(_ => this.applyStyles(styleElement)));
this._register(this.onDidChangeVisibility(visible => {
if (visible) {
this.refresh();
}
}));
this.render();
}
......@@ -232,16 +236,6 @@ export class CommentsPanel extends Panel {
return true;
}
public setVisible(visible: boolean): void {
const wasVisible = this.isVisible();
super.setVisible(visible);
if (this.isVisible()) {
if (!wasVisible) {
this.refresh();
}
}
}
private refresh(): void {
if (this.isVisible()) {
this.collapseAllAction.enabled = this.commentsModel.hasCommentThreads();
......
......@@ -119,6 +119,12 @@ export class BreakpointsView extends ViewletPanel {
}));
this.list.splice(0, this.list.length, this.elements);
this.disposables.push(this.onDidChangeBodyVisibility(visible => {
if (visible && this.needsRefresh) {
this.onBreakpointsChange();
}
}));
}
public focus(): void {
......@@ -191,22 +197,6 @@ export class BreakpointsView extends ViewletPanel {
];
}
public setExpanded(expanded: boolean): boolean {
const changed = super.setExpanded(expanded);
if (expanded && this.needsRefresh) {
this.onBreakpointsChange();
}
return changed;
}
public setVisible(visible: boolean): void {
super.setVisible(visible);
if (visible && this.needsRefresh) {
this.onBreakpointsChange();
}
}
private onBreakpointsChange(): void {
if (this.isExpanded() && this.isVisible()) {
this.minimumBodySize = this.getExpandedBodySize();
......
......@@ -492,36 +492,18 @@ export class LoadedScriptsView extends ViewletPanel {
}));
this.changeScheduler.schedule(0);
this.disposables.push(this.onDidChangeBodyVisibility(visible => {
if (visible && this.treeNeedsRefreshOnVisible) {
this.changeScheduler.schedule();
}
}));
}
layoutBody(size: number): void {
this.tree.layout(size);
}
setExpanded(expanded: boolean): boolean {
const changed = super.setExpanded(expanded);
if (expanded && this.treeNeedsRefreshOnVisible) {
this.changeScheduler.schedule();
}
return changed;
}
setVisible(visible: boolean): void {
super.setVisible(visible);
if (visible && this.treeNeedsRefreshOnVisible) {
this.changeScheduler.schedule();
}
}
/*
private tryToExpand(element: LoadedScriptsItem): void {
try {
this.tree.expand(element);
} catch (e) { }
}
*/
dispose(): void {
this.tree = dispose(this.tree);
this.treeLabels = dispose(this.treeLabels);
......
......@@ -215,6 +215,12 @@ export class CallStackView extends ViewletPanel {
if (this.debugService.state === State.Stopped) {
this.onCallStackChangeScheduler.schedule(0);
}
this.disposables.push(this.onDidChangeBodyVisibility(visible => {
if (visible && this.needsRefresh) {
this.onCallStackChangeScheduler.schedule();
}
}));
}
layoutBody(size: number): void {
......@@ -256,13 +262,6 @@ export class CallStackView extends ViewletPanel {
}
}
setVisible(visible: boolean): void {
super.setVisible(visible);
if (visible && this.needsRefresh) {
this.onCallStackChangeScheduler.schedule();
}
}
private onContextMenu(e: ITreeContextMenuEvent<CallStackItem>): void {
const actions: IAction[] = [];
const element = e.element;
......
......@@ -149,18 +149,16 @@ export class Repl extends Panel implements IPrivateReplService, IHistoryNavigati
this.updateInputDecoration();
}
}));
}
setVisible(visible: boolean): void {
super.setVisible(visible);
if (!visible) {
dispose(this.model);
} else {
this.model = this.modelService.createModel('', null, uri.parse(`${DEBUG_SCHEME}:replinput`), true);
this.replInput.setModel(this.model);
this.updateInputDecoration();
this.refreshReplElements(true);
}
this._register(this.onDidChangeVisibility(visible => {
if (!visible) {
dispose(this.model);
} else {
this.model = this.modelService.createModel('', null, uri.parse(`${DEBUG_SCHEME}:replinput`), true);
this.replInput.setModel(this.model);
this.updateInputDecoration();
this.refreshReplElements(true);
}
}));
}
get isReadonly(): boolean {
......
......@@ -105,28 +105,18 @@ export class VariablesView extends ViewletPanel {
this.disposables.push(variableSetEmitter.event(() => this.tree.refresh()));
this.disposables.push(this.tree.onMouseDblClick(e => this.onMouseDblClick(e)));
this.disposables.push(this.tree.onContextMenu(e => this.onContextMenu(e)));
this.disposables.push(this.onDidChangeBodyVisibility(visible => {
if (visible && this.needsRefresh) {
this.onFocusStackFrameScheduler.schedule();
}
}));
}
layoutBody(size: number): void {
this.tree.layout(size);
}
setExpanded(expanded: boolean): boolean {
const changed = super.setExpanded(expanded);
if (expanded && this.needsRefresh) {
this.onFocusStackFrameScheduler.schedule();
}
return changed;
}
setVisible(visible: boolean): void {
super.setVisible(visible);
if (visible && this.needsRefresh) {
this.onFocusStackFrameScheduler.schedule();
}
}
private onMouseDblClick(e: ITreeMouseEvent<IExpression | IScope>): void {
const session = this.debugService.getViewModel().focusedSession;
if (e.element instanceof Variable && session.capabilities.supportsSetVariable) {
......
......@@ -98,28 +98,18 @@ export class WatchExpressionsView extends ViewletPanel {
}
}));
this.disposables.push(variableSetEmitter.event(() => this.tree.refresh()));
this.disposables.push(this.onDidChangeBodyVisibility(visible => {
if (visible && this.needsRefresh) {
this.onWatchExpressionsUpdatedScheduler.schedule();
}
}));
}
layoutBody(size: number): void {
this.tree.layout(size);
}
setExpanded(expanded: boolean): boolean {
const changed = super.setExpanded(expanded);
if (expanded && this.needsRefresh) {
this.onWatchExpressionsUpdatedScheduler.schedule();
}
return changed;
}
setVisible(visible: boolean): void {
super.setVisible(visible);
if (visible && this.needsRefresh) {
this.onWatchExpressionsUpdatedScheduler.schedule();
}
}
private onMouseDblClick(e: ITreeMouseEvent<IExpression>): void {
if ((e.browserEvent.target as HTMLElement).className.indexOf('twistie') >= 0) {
// Ignore double click events on twistie
......
......@@ -370,18 +370,14 @@ export class ExtensionsViewlet extends ViewContainerViewlet implements IExtensio
this.searchBox.onShouldFocusResults(() => this.focusListView(), this, this.disposables);
this.extensionsBox = append(this.root, $('.extensions'));
super.create(this.extensionsBox);
}
setVisible(visible: boolean): void {
const isVisibilityChanged = this.isVisible() !== visible;
super.setVisible(visible);
if (isVisibilityChanged) {
this._register(this.onDidChangeVisibility(visible => {
if (visible) {
this.searchBox.focus();
}
}
}));
this.extensionsBox = append(this.root, $('.extensions'));
super.create(this.extensionsBox);
}
focus(): void {
......
......@@ -9,7 +9,6 @@ import * as env from 'vs/base/common/platform';
import * as DOM from 'vs/base/browser/dom';
import { IAction } from 'vs/base/common/actions';
import { Button } from 'vs/base/browser/ui/button/button';
import { IActionItem } from 'vs/base/browser/ui/actionbar/actionbar';
import { IViewletViewOptions } from 'vs/workbench/browser/parts/views/viewsViewlet';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { OpenFolderAction, OpenFileFolderAction, AddRootFolderAction } from 'vs/workbench/browser/actions/workspaceActions';
......@@ -26,8 +25,8 @@ import { SIDE_BAR_BACKGROUND } from 'vs/workbench/common/theme';
export class EmptyView extends ViewletPanel {
public static readonly ID: string = 'workbench.explorer.emptyView';
public static readonly NAME = nls.localize('noWorkspace', "No Folder Opened");
static readonly ID: string = 'workbench.explorer.emptyView';
static readonly NAME = nls.localize('noWorkspace', "No Folder Opened");
private button: Button;
private messageElement: HTMLElement;
......@@ -46,7 +45,7 @@ export class EmptyView extends ViewletPanel {
this.contextService.onDidChangeWorkbenchState(() => this.setLabels());
}
public renderHeader(container: HTMLElement): void {
renderHeader(container: HTMLElement): void {
const titleContainer = document.createElement('div');
DOM.addClass(titleContainer, 'title');
container.appendChild(titleContainer);
......@@ -123,29 +122,9 @@ export class EmptyView extends ViewletPanel {
// no-op
}
public setVisible(visible: boolean): Promise<void> {
return Promise.resolve(void 0);
}
public focusBody(): void {
focusBody(): void {
if (this.button) {
this.button.element.focus();
}
}
protected reveal(element: any, relativeTop?: number): Promise<void> {
return Promise.resolve(void 0);
}
public getActions(): IAction[] {
return [];
}
public getSecondaryActions(): IAction[] {
return [];
}
public getActionItem(action: IAction): IActionItem {
return null;
}
}
......@@ -284,6 +284,13 @@ export class OpenEditorsView extends ViewletPanel {
}));
this.listRefreshScheduler.schedule(0);
this.disposables.push(this.onDidChangeBodyVisibility(visible => {
this.updateListVisibility(visible);
if (visible && this.needsRefresh) {
this.listRefreshScheduler.schedule(0);
}
}));
}
public getActions(): IAction[] {
......@@ -294,24 +301,6 @@ export class OpenEditorsView extends ViewletPanel {
];
}
public setExpanded(expanded: boolean): boolean {
const changed = super.setExpanded(expanded);
this.updateListVisibility(expanded);
if (expanded && this.needsRefresh) {
this.listRefreshScheduler.schedule(0);
}
return changed;
}
public setVisible(visible: boolean): void {
super.setVisible(visible);
this.updateListVisibility(visible && this.isExpanded());
if (visible && this.needsRefresh) {
this.listRefreshScheduler.schedule(0);
}
}
public focus(): void {
super.focus();
this.list.domFocus();
......
......@@ -130,8 +130,16 @@ export class MarkersPanel extends Panel implements IMarkerFilterController {
this.updateFilter();
this.onDidFocus(() => this.panelFoucusContextKey.set(true));
this.onDidBlur(() => this.panelFoucusContextKey.set(false));
this._register(this.onDidFocus(() => this.panelFoucusContextKey.set(true)));
this._register(this.onDidBlur(() => this.panelFoucusContextKey.set(false)));
this._register(this.onDidChangeVisibility(visible => {
if (visible) {
this.refreshPanel();
} else {
this.rangeHighlightDecorations.removeHighlightRange();
}
}));
this.render();
}
......@@ -162,18 +170,6 @@ export class MarkersPanel extends Panel implements IMarkerFilterController {
}
}
public setVisible(visible: boolean): void {
const wasVisible = this.isVisible();
super.setVisible(visible);
if (this.isVisible()) {
if (!wasVisible) {
this.refreshPanel();
}
} else {
this.rangeHighlightDecorations.removeHighlightRange();
}
}
public getActions(): IAction[] {
if (!this.actions) {
this.createActions();
......
......@@ -337,6 +337,32 @@ export class SearchView extends Viewlet implements IViewlet, IPanel {
this._register(this.onDidFocus(() => this.viewletFocused.set(true)));
this._register(this.onDidBlur(() => this.viewletFocused.set(false)));
this._register(this.onDidChangeVisibility(visible => this.onVisibilityChanged(visible)));
}
private onVisibilityChanged(visible: boolean): void {
this.viewletVisible.set(visible);
if (visible) {
if (this.changedWhileHidden) {
// Render if results changed while viewlet was hidden - #37818
this.refreshAndUpdateCount();
this.changedWhileHidden = false;
}
}
// Enable highlights if there are searchresults
if (this.viewModel) {
this.viewModel.searchResult.toggleHighlights(visible);
}
// Open focused element from results in case the editor area is otherwise empty
if (visible && !this.editorService.activeEditor) {
let focus = this.tree.getFocus();
if (focus) {
this.onFocus(focus, true);
}
}
}
public get searchAndReplaceWidget(): SearchWidget {
......@@ -745,32 +771,6 @@ export class SearchView extends Viewlet implements IViewlet, IPanel {
}
}
public setVisible(visible: boolean): void {
this.viewletVisible.set(visible);
if (visible) {
if (this.changedWhileHidden) {
// Render if results changed while viewlet was hidden - #37818
this.refreshAndUpdateCount();
this.changedWhileHidden = false;
}
}
super.setVisible(visible);
// Enable highlights if there are searchresults
if (this.viewModel) {
this.viewModel.searchResult.toggleHighlights(visible);
}
// Open focused element from results in case the editor area is otherwise empty
if (visible && !this.editorService.activeEditor) {
let focus = this.tree.getFocus();
if (focus) {
this.onFocus(focus, true);
}
}
}
public moveFocusToResults(): void {
this.tree.domFocus();
}
......
......@@ -96,6 +96,24 @@ export class TerminalPanel extends Panel {
this._updateFont();
this._updateTheme();
this._register(this.onDidChangeVisibility(visible => {
if (visible) {
if (this._terminalService.terminalInstances.length > 0) {
this._updateFont();
this._updateTheme();
} else {
// Check if instances were already restored as part of workbench restore
if (this._terminalService.terminalInstances.length === 0) {
this._terminalService.createTerminal();
}
if (this._terminalService.terminalInstances.length > 0) {
this._updateFont();
this._updateTheme();
}
}
}
}));
// Force another layout (first is setContainers) since config has changed
this.layout(new dom.Dimension(this._terminalContainer.offsetWidth, this._terminalContainer.offsetHeight));
}
......@@ -107,28 +125,6 @@ export class TerminalPanel extends Panel {
this._terminalService.terminalTabs.forEach(t => t.layout(dimension.width, dimension.height));
}
public setVisible(visible: boolean): void {
if (visible) {
if (this._terminalService.terminalInstances.length > 0) {
this._updateFont();
this._updateTheme();
} else {
super.setVisible(visible);
// Check if instances were already restored as part of workbench restore
if (this._terminalService.terminalInstances.length === 0) {
this._terminalService.createTerminal();
}
if (this._terminalService.terminalInstances.length > 0) {
this._updateFont();
this._updateTheme();
}
return;
}
}
super.setVisible(visible);
}
public getActions(): IAction[] {
if (!this._actions) {
this._actions = [
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册