This example demonstrates one way that a window could open new windows, provide details as to which table to open, and allow linking of the tables between those windows.
"Linking" consists of specifying two tables and building a filter that compares values in one or more columns of each, with one as the source, and one as the target. When a user selects a row in the source, the value of the specified column is used to apply a filter to the target table, so that only matching rows are displayed there.
Each browser window in this example opens a new connection to the server. This window only opens the connection so that it can get the list of persistent query configs and their respective tables, but then each other window will also open a connection to the query worker which is running the table in question.
As presently implemented, the individual table windows do not know about each other until a link has been established, so this window must remain open (and cannot be refreshed or navigated away from this page) if more links are to be made. This is a design choice made for this example application, but could easily be done a different way as needed.
Once two windows are open, a column header from one table can be dragged to another window and dropped on a column header there to link them. The link will be listed on the "source" window at a list at the bottom.
When the drop occurs, the "target" window where the header was dropped will create a MessagePort and send it in a message to this window (the opener for both windows), and ask it to forward the message and port to the "source" window. Once there, the "source" window will track that MessagePort and when any row is selected, will notify the "target" window through the MessagePort. The "target" window, listening for incoming messages from that MessagePort, will respond by taking the selected value and replacing its current filter to match the selected row in the "source" window.
Selecting a table will attempt to open it in a new window - to make this demo easier to use, resize the windows so that more than one table is visible at once.