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 <muhammad.shahid@ericsson.com>
  • Loading branch information
Anas Shahid committed Jun 12, 2020
1 parent 310ff52 commit bf14700
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 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,13 @@ export namespace ProblemsCommands {
export const COPY_MESSAGE: Command = {
id: 'problems.copy.message',
};
export const CLEAR_ALL: Command = {
id: 'problems.clear.all'
};
export const CLEAR_ALL_TOOLBAR: Command = {
id: 'problems.clear.all.toolbar',
iconClass: 'theia-remove-all-icon'
};
}

@injectable()
Expand Down Expand Up @@ -145,6 +152,14 @@ export class ProblemContribution extends AbstractViewContribution<ProblemWidget>
execute: selection => this.copyMessage(selection)
})
);
commands.registerCommand(ProblemsCommands.CLEAR_ALL, {
execute: () => this.clearAllMarkers()
});
commands.registerCommand(ProblemsCommands.CLEAR_ALL_TOOLBAR, {
isEnabled: widget => this.withWidget(widget, () => true),
isVisible: widget => this.withWidget(widget, () => true),
execute: () => this.clearAllMarkers()
});
}

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

protected async collapseAllProblems(): Promise<void> {
Expand All @@ -185,6 +206,13 @@ export class ProblemContribution extends AbstractViewContribution<ProblemWidget>
}
}

/**
* Clears all the markers in the problem channel.
*/
protected clearAllMarkers(): void {
this.problemManager.cleanAllMarkers();
}

protected addToClipboard(content: string): void {
const handleCopy = (e: ClipboardEvent) => {
document.removeEventListener('copy', handleCopy);
Expand Down

0 comments on commit bf14700

Please sign in to comment.