Skip to content

Commit

Permalink
[problems] Implemented clear-all in problems view.
Browse files Browse the repository at this point in the history
Fixes: #7979

Added a `Clear-All` toolbar item, which clears all the existing problem
markers

Signed-off-by: Anas Shahid <[email protected]>
  • Loading branch information
Anas Shahid committed Jun 15, 2020
1 parent 310ff52 commit 4b75418
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions packages/markers/src/browser/problem/problem-contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ export namespace ProblemsCommands {
export const COPY_MESSAGE: Command = {
id: 'problems.copy.message',
};
export const CLEAR_ALL: Command = {
id: 'problems.clear.all',
category: 'Problems',
label: 'Clear All',
iconClass: 'clear-all'
};
}

@injectable()
Expand Down Expand Up @@ -145,6 +151,14 @@ export class ProblemContribution extends AbstractViewContribution<ProblemWidget>
execute: selection => this.copyMessage(selection)
})
);
commands.registerCommand(ProblemsCommands.CLEAR_ALL, {
isEnabled: widget => this.withWidget(widget, w => {
const root = w.model.root as CompositeTreeNode;
return !!root.children.length;
}),
isVisible: widget => this.withWidget(widget, () => true),
execute: widget => this.withWidget(widget, () => this.problemManager.cleanAllMarkers())
});
}

registerMenus(menus: MenuModelRegistry): void {
Expand Down Expand Up @@ -173,6 +187,12 @@ export class ProblemContribution extends AbstractViewContribution<ProblemWidget>
tooltip: 'Collapse All',
priority: 0,
});
toolbarRegistry.registerItem({
id: ProblemsCommands.CLEAR_ALL.id,
command: ProblemsCommands.CLEAR_ALL.id,
tooltip: 'Clear All',
priority: 1,
});
}

protected async collapseAllProblems(): Promise<void> {
Expand Down

0 comments on commit 4b75418

Please sign in to comment.