Skip to content

Commit 84a090c

Browse files
hriday-panchasarabhufmann
authored andcommitted
Add select all and deselect all in marker menu
In markers menu add menu item to select/deselect all at once fixes #770 Signed-off-by: hriday-panchasara <hriday.panchasara@ericsson.com>
1 parent 28039a3 commit 84a090c

File tree

2 files changed

+37
-2
lines changed

2 files changed

+37
-2
lines changed

theia-extensions/viewer-prototype/src/browser/trace-viewer/trace-viewer-toolbar-contribution.tsx

+23-1
Original file line numberDiff line numberDiff line change
@@ -194,11 +194,17 @@ export class TraceViewerToolbarContribution implements TabBarToolbarContribution
194194
<div id="trace.viewer.toolbar.filter" className="fa fa-filter" title="Markers filter" onClick={async (event: React.MouseEvent) => {
195195
const toDisposeOnHide = new DisposableCollection();
196196
const menuPath = TraceViewerToolbarMenus.MARKER_CATEGORIES_MENU;
197-
let index = 0;
197+
let index = 1;
198198
const traceViewerWidget = widget as TraceViewerWidget;
199199
const markerCategories = traceViewerWidget.getMarkerCategories();
200+
let selectAll = true;
200201
markerCategories.forEach((categoryInfo, categoryName) => {
201202
const toggleInd = categoryInfo.toggleInd;
203+
204+
if (!toggleInd) {
205+
selectAll = false;
206+
}
207+
202208
index += 1;
203209
toDisposeOnHide.push(this.menus.registerMenuAction(menuPath, {
204210
label: categoryName,
@@ -216,6 +222,22 @@ export class TraceViewerToolbarContribution implements TabBarToolbarContribution
216222
}));
217223
});
218224

225+
toDisposeOnHide.push(this.menus.registerMenuAction(menuPath, {
226+
label: 'Select all',
227+
commandId: 'Select all' + index.toString(),
228+
order: '0',
229+
}));
230+
toDisposeOnHide.push(this.commands.registerCommand({
231+
id: 'Select all' + index.toString(),
232+
label: 'Select all'
233+
}, {
234+
execute: () => {
235+
traceViewerWidget.updateAllMarkerCategoryState(!selectAll);
236+
return;
237+
},
238+
isToggled: () => selectAll,
239+
}));
240+
219241
return this.contextMenuRenderer.render({
220242
menuPath,
221243
args: [],

theia-extensions/viewer-prototype/src/browser/trace-viewer/trace-viewer.tsx

+14-1
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ export class TraceViewerWidget extends ReactWidget implements StatefulWidget {
499499
return this.toolbarMarkerCategoriesMap;
500500
}
501501

502-
updateMarkerCategoryState(categoryName: string): void {
502+
updateMarkerCategoryState(categoryName: string, skipUpdate?: boolean): void {
503503
const toggledmarkerCategory = this.toolbarMarkerCategoriesMap.get(categoryName);
504504
if (toggledmarkerCategory) {
505505
const categoryCount = toggledmarkerCategory?.categoryCount;
@@ -513,6 +513,19 @@ export class TraceViewerWidget extends ReactWidget implements StatefulWidget {
513513
this.selectedMarkerCategoriesMap.set(outputId, selectedMarkerCategories);
514514
});
515515
}
516+
if (!skipUpdate) {
517+
this.update();
518+
}
519+
}
520+
521+
updateAllMarkerCategoryState(selectAll: boolean): void {
522+
const markerCategories = this.getMarkerCategories();
523+
for (const [key, value] of markerCategories) {
524+
if (value.toggleInd === selectAll) {
525+
continue;
526+
}
527+
this.updateMarkerCategoryState(key, true);
528+
}
516529
this.update();
517530
}
518531

0 commit comments

Comments
 (0)