@@ -44,7 +44,6 @@ import {
44
44
import { AutoModeler } from "./auto-modeler" ;
45
45
import { telemetryListener } from "../common/vscode/telemetry" ;
46
46
import { ModelingStore } from "./modeling-store" ;
47
- import { ModelEditorViewTracker } from "./model-editor-view-tracker" ;
48
47
import { ModelingEvents } from "./modeling-events" ;
49
48
import { getModelsAsDataLanguage , ModelsAsDataLanguage } from "./languages" ;
50
49
import { runGenerateQueries } from "./generate" ;
@@ -60,7 +59,6 @@ export class ModelEditorView extends AbstractWebview<
60
59
protected readonly app : App ,
61
60
private readonly modelingStore : ModelingStore ,
62
61
private readonly modelingEvents : ModelingEvents ,
63
- private readonly viewTracker : ModelEditorViewTracker < ModelEditorView > ,
64
62
private readonly modelConfig : ModelConfigListener ,
65
63
private readonly databaseManager : DatabaseManager ,
66
64
private readonly cliServer : CodeQLCliServer ,
@@ -79,8 +77,6 @@ export class ModelEditorView extends AbstractWebview<
79
77
this . registerToModelingEvents ( ) ;
80
78
this . registerToModelConfigEvents ( ) ;
81
79
82
- this . viewTracker . registerView ( this ) ;
83
-
84
80
this . autoModeler = new AutoModeler (
85
81
app ,
86
82
cliServer ,
@@ -166,7 +162,7 @@ export class ModelEditorView extends AbstractWebview<
166
162
}
167
163
168
164
protected onPanelDispose ( ) : void {
169
- this . viewTracker . unregisterView ( this ) ;
165
+ // Nothing to do
170
166
}
171
167
172
168
protected async onMessage ( msg : FromModelEditorMessage ) : Promise < void > {
@@ -573,12 +569,9 @@ export class ModelEditorView extends AbstractWebview<
573
569
return ;
574
570
}
575
571
576
- let existingView = this . viewTracker . getView (
577
- addedDatabase . databaseUri . toString ( ) ,
578
- ) ;
579
- if ( existingView ) {
580
- await existingView . focusView ( ) ;
581
-
572
+ const addedDbUri = addedDatabase . databaseUri . toString ( ) ;
573
+ if ( this . modelingStore . isDbOpen ( addedDbUri ) ) {
574
+ this . modelingEvents . fireFocusModelEditorEvent ( addedDbUri ) ;
582
575
return ;
583
576
}
584
577
@@ -596,20 +589,15 @@ export class ModelEditorView extends AbstractWebview<
596
589
597
590
// Check again just before opening the editor to ensure no model editor has been opened between
598
591
// our first check and now.
599
- existingView = this . viewTracker . getView (
600
- addedDatabase . databaseUri . toString ( ) ,
601
- ) ;
602
- if ( existingView ) {
603
- await existingView . focusView ( ) ;
604
-
592
+ if ( this . modelingStore . isDbOpen ( addedDbUri ) ) {
593
+ this . modelingEvents . fireFocusModelEditorEvent ( addedDbUri ) ;
605
594
return ;
606
595
}
607
596
608
597
const view = new ModelEditorView (
609
598
this . app ,
610
599
this . modelingStore ,
611
600
this . modelingEvents ,
612
- this . viewTracker ,
613
601
this . modelConfig ,
614
602
this . databaseManager ,
615
603
this . cliServer ,
@@ -742,6 +730,22 @@ export class ModelEditorView extends AbstractWebview<
742
730
}
743
731
} ) ,
744
732
) ;
733
+
734
+ this . push (
735
+ this . modelingEvents . onRevealInModelEditor ( async ( event ) => {
736
+ if ( event . dbUri === this . databaseItem . databaseUri . toString ( ) ) {
737
+ await this . revealMethod ( event . method ) ;
738
+ }
739
+ } ) ,
740
+ ) ;
741
+
742
+ this . push (
743
+ this . modelingEvents . onFocusModelEditor ( async ( event ) => {
744
+ if ( event . dbUri === this . databaseItem . databaseUri . toString ( ) ) {
745
+ await this . focusView ( ) ;
746
+ }
747
+ } ) ,
748
+ ) ;
745
749
}
746
750
747
751
private registerToModelConfigEvents ( ) {
0 commit comments