Skip to content

Commit 592ef97

Browse files
committed
[MPQEditor] Implement open and other commands
Implement open and other commands for MPQSelectionPanel. ONE-vscode-DCO-1.0-Signed-off-by: s.malakhov <[email protected]>
1 parent 9c1f33b commit 592ef97

File tree

1 file changed

+75
-1
lines changed

1 file changed

+75
-1
lines changed

src/MPQEditor/MPQCircleSelector.ts

+75-1
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,26 @@ export type MPQSelectionCmdOpenArgs = {
3535
panel: vscode.WebviewPanel;
3636
};
3737

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+
3849
export class MPQSelectionPanel
3950
extends CircleGraphCtrl
4051
implements CircleGraphEvent
4152
{
4253
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+
4358
public static panels: MPQSelectionPanel[] = [];
4459

4560
private _panel: vscode.WebviewPanel;
@@ -52,7 +67,33 @@ export class MPQSelectionPanel
5267
private _lastSelected: string[];
5368
private _closedByOwner: boolean = false;
5469

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+
}
5697

5798
public static createOrShow(
5899
extensionUri: vscode.Uri,
@@ -111,6 +152,39 @@ export class MPQSelectionPanel
111152
return result;
112153
}
113154

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+
114188
private constructor(
115189
panel: vscode.WebviewPanel,
116190
extensionUri: vscode.Uri,

0 commit comments

Comments
 (0)