diff --git a/src/vs/workbench/parts/comments/electron-browser/commentsPanel.ts b/src/vs/workbench/parts/comments/electron-browser/commentsPanel.ts index 3a02e25eb500789d102b85318e387cf4d801193d..c1b0f53f8773dda4f5fcb76ab0e5f428a6b0ae72 100644 --- a/src/vs/workbench/parts/comments/electron-browser/commentsPanel.ts +++ b/src/vs/workbench/parts/comments/electron-browser/commentsPanel.ts @@ -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(); diff --git a/src/vs/workbench/parts/debug/browser/breakpointsView.ts b/src/vs/workbench/parts/debug/browser/breakpointsView.ts index 93c7b6659a687e59e8a6b66943a6c7b53ce02775..a63c75c94c90e352f4e28c4dda19aa4da6babf5c 100644 --- a/src/vs/workbench/parts/debug/browser/breakpointsView.ts +++ b/src/vs/workbench/parts/debug/browser/breakpointsView.ts @@ -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(); diff --git a/src/vs/workbench/parts/debug/browser/loadedScriptsView.ts b/src/vs/workbench/parts/debug/browser/loadedScriptsView.ts index 56aafac3539f389e5aa380e316f03808d901d609..468b6de76e4f226e73225d2081cbe4ace8073506 100644 --- a/src/vs/workbench/parts/debug/browser/loadedScriptsView.ts +++ b/src/vs/workbench/parts/debug/browser/loadedScriptsView.ts @@ -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); diff --git a/src/vs/workbench/parts/debug/electron-browser/callStackView.ts b/src/vs/workbench/parts/debug/electron-browser/callStackView.ts index 2f706cc94703dd81a823811c2a975c5b73a441ae..9bf6031da6da662de47034406d68d55e557c2841 100644 --- a/src/vs/workbench/parts/debug/electron-browser/callStackView.ts +++ b/src/vs/workbench/parts/debug/electron-browser/callStackView.ts @@ -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): void { const actions: IAction[] = []; const element = e.element; diff --git a/src/vs/workbench/parts/debug/electron-browser/repl.ts b/src/vs/workbench/parts/debug/electron-browser/repl.ts index 2d84efb65815c5742eb6d3cf245b7cd988225026..da6c7fd507c4765e3df10eacb4f44449eb3f96f6 100644 --- a/src/vs/workbench/parts/debug/electron-browser/repl.ts +++ b/src/vs/workbench/parts/debug/electron-browser/repl.ts @@ -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 { diff --git a/src/vs/workbench/parts/debug/electron-browser/variablesView.ts b/src/vs/workbench/parts/debug/electron-browser/variablesView.ts index d1a2ec8b20c7d787666a733348bb72f52379892e..d6511177d76c5f8940056b63e36fe92520f79e63 100644 --- a/src/vs/workbench/parts/debug/electron-browser/variablesView.ts +++ b/src/vs/workbench/parts/debug/electron-browser/variablesView.ts @@ -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): void { const session = this.debugService.getViewModel().focusedSession; if (e.element instanceof Variable && session.capabilities.supportsSetVariable) { diff --git a/src/vs/workbench/parts/debug/electron-browser/watchExpressionsView.ts b/src/vs/workbench/parts/debug/electron-browser/watchExpressionsView.ts index 1cb1d3369745abc3d3f69cc656b37db20fbf0cf9..b0075bc4fc967e34ee4c0c5fe3f90753e9eaba20 100644 --- a/src/vs/workbench/parts/debug/electron-browser/watchExpressionsView.ts +++ b/src/vs/workbench/parts/debug/electron-browser/watchExpressionsView.ts @@ -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): void { if ((e.browserEvent.target as HTMLElement).className.indexOf('twistie') >= 0) { // Ignore double click events on twistie diff --git a/src/vs/workbench/parts/extensions/electron-browser/extensionsViewlet.ts b/src/vs/workbench/parts/extensions/electron-browser/extensionsViewlet.ts index 024c14b98b7c5d0b01b00457fdd7729ef7262300..99492408d996f5fc7b59319d19b4c5fcccd734e6 100644 --- a/src/vs/workbench/parts/extensions/electron-browser/extensionsViewlet.ts +++ b/src/vs/workbench/parts/extensions/electron-browser/extensionsViewlet.ts @@ -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 { diff --git a/src/vs/workbench/parts/files/electron-browser/views/emptyView.ts b/src/vs/workbench/parts/files/electron-browser/views/emptyView.ts index 410c9c9a1fe9aed2f0b93dddeb65ddd6fdfa06f1..990332f091f6e9c983d8181712d83b2fc6fba21f 100644 --- a/src/vs/workbench/parts/files/electron-browser/views/emptyView.ts +++ b/src/vs/workbench/parts/files/electron-browser/views/emptyView.ts @@ -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 { - return Promise.resolve(void 0); - } - - public focusBody(): void { + focusBody(): void { if (this.button) { this.button.element.focus(); } } - - protected reveal(element: any, relativeTop?: number): Promise { - return Promise.resolve(void 0); - } - - public getActions(): IAction[] { - return []; - } - - public getSecondaryActions(): IAction[] { - return []; - } - - public getActionItem(action: IAction): IActionItem { - return null; - } } diff --git a/src/vs/workbench/parts/files/electron-browser/views/openEditorsView.ts b/src/vs/workbench/parts/files/electron-browser/views/openEditorsView.ts index d9e7f632eb31711d8d9472af1ac678f4d0736d1a..d77aff3324df6098aa5d44dd37450bfd27d80a2e 100644 --- a/src/vs/workbench/parts/files/electron-browser/views/openEditorsView.ts +++ b/src/vs/workbench/parts/files/electron-browser/views/openEditorsView.ts @@ -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(); diff --git a/src/vs/workbench/parts/markers/electron-browser/markersPanel.ts b/src/vs/workbench/parts/markers/electron-browser/markersPanel.ts index 60aeb8467879f6e0cdff7d872714b641fa795cef..00e58fa9e517c73678b973d1ffb4fbaa34a8c31b 100644 --- a/src/vs/workbench/parts/markers/electron-browser/markersPanel.ts +++ b/src/vs/workbench/parts/markers/electron-browser/markersPanel.ts @@ -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(); diff --git a/src/vs/workbench/parts/search/browser/searchView.ts b/src/vs/workbench/parts/search/browser/searchView.ts index ea603068f135a51193ad90d8925b2332fd57b466..58858befdc9056c3056bbf262dbe963961e3931e 100644 --- a/src/vs/workbench/parts/search/browser/searchView.ts +++ b/src/vs/workbench/parts/search/browser/searchView.ts @@ -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(); } diff --git a/src/vs/workbench/parts/terminal/electron-browser/terminalPanel.ts b/src/vs/workbench/parts/terminal/electron-browser/terminalPanel.ts index 89eca9e2f9101c988a268f0d00775c130ce64406..bbbd8e6fbc60b99bb94199a4380c8dd79ec7526f 100644 --- a/src/vs/workbench/parts/terminal/electron-browser/terminalPanel.ts +++ b/src/vs/workbench/parts/terminal/electron-browser/terminalPanel.ts @@ -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 = [