@@ -35,11 +35,26 @@ export type MPQSelectionCmdOpenArgs = {
35
35
panel : vscode . WebviewPanel ;
36
36
} ;
37
37
38
+ export type MPQSelectionCmdCloseArgs = {
39
+ modelPath : string ;
40
+ document : vscode . TextDocument ;
41
+ } ;
42
+
43
+ export type MPQSelectionCmdLayersChangedArgs = {
44
+ modelPath : string ;
45
+ document : vscode . TextDocument ;
46
+ names : any ;
47
+ } ;
48
+
38
49
export class MPQSelectionPanel
39
50
extends CircleGraphCtrl
40
51
implements CircleGraphEvent
41
52
{
42
53
public static readonly viewType = "one.viewer.mpq" ;
54
+ public static readonly cmdOpen = "one.viewer.mpq.openGraphSelector" ;
55
+ public static readonly cmdClose = "one.viewer.mpq.closeGraphSelector" ;
56
+ public static readonly cmdChanged = "one.viewer.mpq.layersChangedByOwner" ;
57
+
43
58
public static panels : MPQSelectionPanel [ ] = [ ] ;
44
59
45
60
private _panel : vscode . WebviewPanel ;
@@ -52,7 +67,33 @@ export class MPQSelectionPanel
52
67
private _lastSelected : string [ ] ;
53
68
private _closedByOwner : boolean = false ;
54
69
55
- public static register ( _context : vscode . ExtensionContext ) : void { }
70
+ public static register ( context : vscode . ExtensionContext ) : void {
71
+ const registrations = [
72
+ vscode . commands . registerCommand (
73
+ MPQSelectionPanel . cmdOpen ,
74
+ ( args : MPQSelectionCmdOpenArgs , handler : MPQSelectionEvent ) => {
75
+ MPQSelectionPanel . createOrShow ( context . extensionUri , args , handler ) ;
76
+ }
77
+ ) ,
78
+ vscode . commands . registerCommand (
79
+ MPQSelectionPanel . cmdClose ,
80
+ ( args : MPQSelectionCmdCloseArgs ) => {
81
+ MPQSelectionPanel . closeByOwner ( context . extensionUri , args ) ;
82
+ }
83
+ ) ,
84
+ vscode . commands . registerCommand (
85
+ MPQSelectionPanel . cmdChanged ,
86
+ ( args : MPQSelectionCmdLayersChangedArgs ) => {
87
+ MPQSelectionPanel . forwardSelectionByOwner ( context . extensionUri , args ) ;
88
+ }
89
+ ) ,
90
+ // TODO add more commands
91
+ ] ;
92
+
93
+ registrations . forEach ( ( disposable ) =>
94
+ context . subscriptions . push ( disposable )
95
+ ) ;
96
+ }
56
97
57
98
public static createOrShow (
58
99
extensionUri : vscode . Uri ,
@@ -111,6 +152,39 @@ export class MPQSelectionPanel
111
152
return result ;
112
153
}
113
154
155
+ /**
156
+ * @brief called when owner is closing
157
+ */
158
+ public static closeByOwner (
159
+ extensionUri : vscode . Uri ,
160
+ args : MPQSelectionCmdCloseArgs
161
+ ) {
162
+ let selPanel = MPQSelectionPanel . findSelPanel (
163
+ args . modelPath ,
164
+ args . document . uri . toString ( )
165
+ ) ;
166
+ if ( selPanel ) {
167
+ selPanel . _closedByOwner = true ;
168
+ selPanel . dispose ( ) ;
169
+ }
170
+ }
171
+
172
+ /**
173
+ * @brief called when owner selection state of nodes has changed
174
+ */
175
+ public static forwardSelectionByOwner (
176
+ extensionUri : vscode . Uri ,
177
+ args : MPQSelectionCmdLayersChangedArgs
178
+ ) {
179
+ let selPanel = MPQSelectionPanel . findSelPanel (
180
+ args . modelPath ,
181
+ args . document . uri . toString ( )
182
+ ) ;
183
+ if ( selPanel ) {
184
+ selPanel . onForwardSelection ( args . names ) ;
185
+ }
186
+ }
187
+
114
188
private constructor (
115
189
panel : vscode . WebviewPanel ,
116
190
extensionUri : vscode . Uri ,
0 commit comments