Skip to content

Commit

Permalink
Merge branch 'sandy081/strictPropertyInit'
Browse files Browse the repository at this point in the history
  • Loading branch information
sandy081 committed Sep 4, 2019
2 parents e08ba90 + e878c3e commit 0e00b6d
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 58 deletions.
63 changes: 28 additions & 35 deletions src/vs/workbench/contrib/markers/browser/markersPanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,23 +69,21 @@ export class MarkersPanel extends Panel implements IMarkerFilterController {
private lastSelectedRelativeTop: number = 0;
private currentActiveResource: URI | null = null;

private tree: WorkbenchObjectTree<TreeElement, FilterData>;
private treeLabels: ResourceLabels;
private rangeHighlightDecorations: RangeHighlightDecorations;

private actions: IAction[];
private collapseAllAction: IAction;
private filterAction: MarkersFilterAction;
private filterInputActionViewItem: MarkersFilterActionViewItem;

private treeContainer: HTMLElement;
private messageBoxContainer: HTMLElement;
private ariaLabelElement: HTMLElement;
private readonly rangeHighlightDecorations: RangeHighlightDecorations;
private readonly filter: Filter;

private tree!: WorkbenchObjectTree<TreeElement, FilterData>;
private treeContainer!: HTMLElement;
private messageBoxContainer!: HTMLElement;
private ariaLabelElement!: HTMLElement;

private readonly collapseAllAction: IAction;
private readonly filterAction: MarkersFilterAction;
private filterInputActionViewItem: MarkersFilterActionViewItem | null = null;

private readonly panelState: MementoObject;
private panelFoucusContextKey: IContextKey<boolean>;

private filter: Filter;

private _onDidFilter = this._register(new Emitter<void>());
readonly onDidFilter: Event<void> = this._onDidFilter.event;
private cachedFilterStats: { total: number; filtered: number; } | undefined = undefined;
Expand Down Expand Up @@ -114,12 +112,18 @@ export class MarkersPanel extends Panel implements IMarkerFilterController {
this.markersViewModel = instantiationService.createInstance(MarkersViewModel, this.panelState['multiline']);
this.markersViewModel.onDidChange(this.onDidChangeViewState, this, this.disposables);
this.setCurrentActiveEditor();

this.filter = new Filter(new FilterOptions());
this.rangeHighlightDecorations = this._register(this.instantiationService.createInstance(RangeHighlightDecorations));

// actions
this.collapseAllAction = new Action('vs.tree.collapse', localize('collapseAll', "Collapse All"), 'monaco-tree-action collapse-all', true, async () => this.collapseAll());
this.filterAction = this.instantiationService.createInstance(MarkersFilterAction, { filterText: this.panelState['filter'] || '', filterHistory: this.panelState['filterHistory'] || [], useFilesExclude: !!this.panelState['useFilesExclude'] });
}

public create(parent: HTMLElement): void {
super.create(parent);

this.rangeHighlightDecorations = this._register(this.instantiationService.createInstance(RangeHighlightDecorations));

dom.addClass(parent, 'markers-panel');

Expand All @@ -128,7 +132,6 @@ export class MarkersPanel extends Panel implements IMarkerFilterController {
this.createArialLabelElement(container);
this.createMessageBox(container);
this.createTree(container);
this.createActions();
this.createListeners();

this.updateFilter();
Expand Down Expand Up @@ -178,10 +181,7 @@ export class MarkersPanel extends Panel implements IMarkerFilterController {
}

public getActions(): IAction[] {
if (!this.actions) {
this.createActions();
}
return this.actions;
return [this.filterAction, this.collapseAllAction];
}

public showQuickFixes(marker: Marker): void {
Expand Down Expand Up @@ -306,15 +306,14 @@ export class MarkersPanel extends Panel implements IMarkerFilterController {

const onDidChangeRenderNodeCount = new Relay<ITreeNode<any, any>>();

this.treeLabels = this._register(this.instantiationService.createInstance(ResourceLabels, this));
const treeLabels = this._register(this.instantiationService.createInstance(ResourceLabels, this));

const virtualDelegate = new VirtualDelegate(this.markersViewModel);
const renderers = [
this.instantiationService.createInstance(ResourceMarkersRenderer, this.treeLabels, onDidChangeRenderNodeCount.event),
this.instantiationService.createInstance(ResourceMarkersRenderer, treeLabels, onDidChangeRenderNodeCount.event),
this.instantiationService.createInstance(MarkerRenderer, this.markersViewModel),
this.instantiationService.createInstance(RelatedInformationRenderer)
];
this.filter = new Filter(new FilterOptions());
const accessibilityProvider = this.instantiationService.createInstance(MarkersTreeAccessibilityProvider);

const identityProvider = {
Expand Down Expand Up @@ -396,17 +395,12 @@ export class MarkersPanel extends Panel implements IMarkerFilterController {
}));
}

private createActions(): void {
this.collapseAllAction = new Action('vs.tree.collapse', localize('collapseAll', "Collapse All"), 'monaco-tree-action collapse-all', true, async () => {
this.tree.collapseAll();
this.tree.setSelection([]);
this.tree.setFocus([]);
this.tree.getHTMLElement().focus();
this.tree.focusFirst();
});

this.filterAction = this.instantiationService.createInstance(MarkersFilterAction, { filterText: this.panelState['filter'] || '', filterHistory: this.panelState['filterHistory'] || [], useFilesExclude: !!this.panelState['useFilesExclude'] });
this.actions = [this.filterAction, this.collapseAllAction];
private collapseAll(): void {
this.tree.collapseAll();
this.tree.setSelection([]);
this.tree.setFocus([]);
this.tree.getHTMLElement().focus();
this.tree.focusFirst();
}

private createListeners(): void {
Expand All @@ -423,7 +417,6 @@ export class MarkersPanel extends Panel implements IMarkerFilterController {
this.updateFilter();
}
}));
this.actions.forEach(a => this._register(a));
}

private onDidChangeModel(change: MarkerChangesEvent) {
Expand Down
45 changes: 24 additions & 21 deletions src/vs/workbench/contrib/markers/browser/markersPanelActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,9 @@ export interface IMarkerFilterController {
export class MarkersFilterActionViewItem extends BaseActionViewItem {

private delayedFilterUpdate: Delayer<void>;
private container: HTMLElement;
private filterInputBox: HistoryInputBox;
private controlsContainer: HTMLInputElement;
private filterBadge: HTMLInputElement;
private container: HTMLElement | null = null;
private filterInputBox: HistoryInputBox | null = null;
private filterBadge: HTMLElement | null = null;
private focusContextKey: IContextKey<boolean>;

constructor(
Expand Down Expand Up @@ -172,13 +171,13 @@ export class MarkersFilterActionViewItem extends BaseActionViewItem {
this.filterInputBox.inputElement.setAttribute('aria-labelledby', 'markers-panel-arialabel');
this._register(attachInputBoxStyler(this.filterInputBox, this.themeService));
this.filterInputBox.value = this.action.filterText;
this._register(this.filterInputBox.onDidChange(filter => this.delayedFilterUpdate.trigger(() => this.onDidInputChange(this.filterInputBox))));
this._register(this.filterInputBox.onDidChange(filter => this.delayedFilterUpdate.trigger(() => this.onDidInputChange(this.filterInputBox!))));
this._register(this.action.onDidChange((event: IMarkersFilterActionChangeEvent) => {
if (event.filterText) {
this.filterInputBox.value = this.action.filterText;
this.filterInputBox!.value = this.action.filterText;
}
}));
this._register(DOM.addStandardDisposableListener(this.filterInputBox.inputElement, DOM.EventType.KEY_DOWN, (e: any) => this.onInputKeyDown(e, this.filterInputBox)));
this._register(DOM.addStandardDisposableListener(this.filterInputBox.inputElement, DOM.EventType.KEY_DOWN, (e: any) => this.onInputKeyDown(e, this.filterInputBox!)));
this._register(DOM.addStandardDisposableListener(container, DOM.EventType.KEY_DOWN, this.handleKeyboardEvent));
this._register(DOM.addStandardDisposableListener(container, DOM.EventType.KEY_UP, this.handleKeyboardEvent));

Expand All @@ -189,24 +188,24 @@ export class MarkersFilterActionViewItem extends BaseActionViewItem {
}

private createControls(container: HTMLElement): void {
this.controlsContainer = DOM.append(container, DOM.$('.markers-panel-filter-controls'));
this.createBadge(this.controlsContainer);
this.createFilesExcludeCheckbox(this.controlsContainer);
const controlsContainer = DOM.append(container, DOM.$('.markers-panel-filter-controls'));
this.createBadge(controlsContainer);
this.createFilesExcludeCheckbox(controlsContainer);
}

private createBadge(container: HTMLElement): void {
this.filterBadge = DOM.append(container, DOM.$('.markers-panel-filter-badge'));
const filterBadge = this.filterBadge = DOM.append(container, DOM.$('.markers-panel-filter-badge'));
this._register(attachStylerCallback(this.themeService, { badgeBackground, badgeForeground, contrastBorder }, colors => {
const background = colors.badgeBackground ? colors.badgeBackground.toString() : null;
const foreground = colors.badgeForeground ? colors.badgeForeground.toString() : null;
const border = colors.contrastBorder ? colors.contrastBorder.toString() : null;

this.filterBadge.style.backgroundColor = background;
filterBadge.style.backgroundColor = background;

this.filterBadge.style.borderWidth = border ? '1px' : null;
this.filterBadge.style.borderStyle = border ? 'solid' : null;
this.filterBadge.style.borderColor = border;
this.filterBadge.style.color = foreground;
filterBadge.style.borderWidth = border ? '1px' : null;
filterBadge.style.borderStyle = border ? 'solid' : null;
filterBadge.style.borderColor = border;
filterBadge.style.color = foreground;
}));
this.updateBadge();
this._register(this.filterController.onDidFilter(() => this.updateBadge()));
Expand Down Expand Up @@ -241,14 +240,18 @@ export class MarkersFilterActionViewItem extends BaseActionViewItem {
}

private updateBadge(): void {
const { total, filtered } = this.filterController.getFilterStats();
DOM.toggleClass(this.filterBadge, 'hidden', total === filtered || filtered === 0);
this.filterBadge.textContent = localize('showing filtered problems', "Showing {0} of {1}", filtered, total);
this.adjustInputBox();
if (this.filterBadge) {
const { total, filtered } = this.filterController.getFilterStats();
DOM.toggleClass(this.filterBadge, 'hidden', total === filtered || filtered === 0);
this.filterBadge.textContent = localize('showing filtered problems', "Showing {0} of {1}", filtered, total);
this.adjustInputBox();
}
}

private adjustInputBox(): void {
this.filterInputBox.inputElement.style.paddingRight = DOM.hasClass(this.container, 'small') || DOM.hasClass(this.filterBadge, 'hidden') ? '25px' : '150px';
if (this.container && this.filterInputBox && this.filterBadge) {
this.filterInputBox.inputElement.style.paddingRight = DOM.hasClass(this.container, 'small') || DOM.hasClass(this.filterBadge, 'hidden') ? '25px' : '150px';
}
}

// Action toolbar is swallowing some keys for action items which should not be for an input box
Expand Down
4 changes: 2 additions & 2 deletions src/vs/workbench/contrib/markers/browser/markersTreeViewer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ export class MarkerViewModel extends Disposable {
}
}

private _quickFixAction: QuickFixAction;
private _quickFixAction: QuickFixAction | null = null;
get quickFixAction(): QuickFixAction {
if (!this._quickFixAction) {
this._quickFixAction = this._register(this.instantiationService.createInstance(QuickFixAction, this.marker));
Expand Down Expand Up @@ -616,7 +616,7 @@ export class MarkersViewModel extends Disposable {

private bulkUpdate: boolean = false;

private hoveredMarker: Marker | null;
private hoveredMarker: Marker | null = null;
private hoverDelayer: Delayer<void> = new Delayer<void>(300);

constructor(
Expand Down

0 comments on commit 0e00b6d

Please sign in to comment.