@@ -104,6 +104,8 @@ export class TimegraphOutputComponent extends AbstractTreeOutputComponent<Timegr
104
104
this . chartLayer . updateChart ( ) ;
105
105
} , 500 ) ;
106
106
107
+ private additonalParameters : { [ key : string ] : unknown } | undefined ;
108
+
107
109
constructor ( props : TimegraphOutputProps ) {
108
110
super ( props ) ;
109
111
this . state = {
@@ -260,6 +262,12 @@ export class TimegraphOutputComponent extends AbstractTreeOutputComponent<Timegr
260
262
} ) ;
261
263
this . waitAnalysisCompletion ( ) ;
262
264
this . subscribeToEvents ( ) ;
265
+
266
+ /* Server-side context menus */
267
+ if ( this . props . outputDescriptor ) {
268
+ console . log ( 'this.props.outputDescriptor' ) ;
269
+ this . registerServerSideMenus ( ) ;
270
+ }
263
271
}
264
272
265
273
componentWillUnmount ( ) : void {
@@ -273,13 +281,17 @@ export class TimegraphOutputComponent extends AbstractTreeOutputComponent<Timegr
273
281
signalManager ( ) . on ( Signals . OUTPUT_DATA_CHANGED , this . onOutputDataChanged ) ;
274
282
signalManager ( ) . on ( Signals . THEME_CHANGED , this . onThemeChange ) ;
275
283
signalManager ( ) . on ( Signals . SELECTION_CHANGED , this . onSelectionChanged ) ;
284
+ signalManager ( ) . on ( Signals . CONTEXT_MENU_ITEM_CLICKED , this . _onContextMenuItemClicked ) ;
285
+ signalManager ( ) . on ( Signals . TRACE_MODEL_UPDATED , this . onModelUpdated ) ;
276
286
}
277
287
278
288
protected unsubscribeToEvents ( ) : void {
279
289
signalManager ( ) . off ( Signals . CONTRIBUTE_CONTEXT_MENU , this . onContextMenuContributed ) ;
280
290
signalManager ( ) . off ( Signals . OUTPUT_DATA_CHANGED , this . onOutputDataChanged ) ;
281
291
signalManager ( ) . off ( Signals . THEME_CHANGED , this . onThemeChange ) ;
282
292
signalManager ( ) . off ( Signals . SELECTION_CHANGED , this . onSelectionChanged ) ;
293
+ signalManager ( ) . off ( Signals . CONTEXT_MENU_ITEM_CLICKED , this . _onContextMenuItemClicked ) ;
294
+ signalManager ( ) . off ( Signals . TRACE_MODEL_UPDATED , this . onModelUpdated ) ;
283
295
}
284
296
285
297
async fetchTree ( ) : Promise < ResponseStatus > {
@@ -1482,4 +1494,44 @@ export class TimegraphOutputComponent extends AbstractTreeOutputComponent<Timegr
1482
1494
) ;
1483
1495
this . chartLayer . selectAndReveal ( rowIndex ) ;
1484
1496
}
1497
+
1498
+ protected registerServerSideMenus ( ) : void {
1499
+ // TODO: create generic API to register server driven menus
1500
+ const ctxMenu : ContextMenuItems = {
1501
+ submenus : [ ] ,
1502
+ items : [ { id : 'org.eclipse.tracecompass.follow.thread.id' , label : 'Follow thread' } ]
1503
+ } ;
1504
+ const pld : ContextMenuContributedSignalPayload = new ContextMenuContributedSignalPayload (
1505
+ this . props . outputDescriptor . id ,
1506
+ ctxMenu
1507
+ ) ;
1508
+ signalManager ( ) . fireContributeContextMenu ( pld ) ;
1509
+ }
1510
+
1511
+ private _onContextMenuItemClicked = async ( payload : ContextMenuItemClickedSignalPayload ) : Promise < void > => {
1512
+ // handle item clicked payload and perform whatever function you need to based on the selection
1513
+ // TODO: create generic API to execute command-handler for server driven actions
1514
+ // For example, a pre-defined way to query additional query parameters that are passed to back-end calls (global filter)
1515
+
1516
+ if ( payload ?. getItemId ( ) === 'org.eclipse.tracecompass.follow.thread.id' ) {
1517
+ const items : { id : number ; parentId ?: number ; metadata ?: { [ key : string ] : unknown } } [ ] =
1518
+ payload . getProps ( ) [ 'selectedRows' ] ;
1519
+ const item = items [ 0 ] . id ;
1520
+ const parameters = QueryHelper . selectionQuery ( [ item ] ) ;
1521
+ const tspClientResponse = await this . props . tspClient . fetchTimeGraphTreeContext (
1522
+ this . props . traceId ,
1523
+ this . props . outputDescriptor . id ,
1524
+ parameters
1525
+ ) ;
1526
+ const model : { [ key : string ] : unknown } | undefined = tspClientResponse . getModel ( ) ?. model ;
1527
+ if ( model ) {
1528
+ signalManager ( ) . fireTraceContexModelUpdated ( model ) ;
1529
+ }
1530
+ }
1531
+ } ;
1532
+
1533
+ onModelUpdated = ( model : { [ key : string ] : unknown } ) : void => {
1534
+ // TODO add model as addtional parameters to back-end queries
1535
+ this . additonalParameters = model ;
1536
+ } ;
1485
1537
}
0 commit comments