Update modeling panel when clicking 'view' on model editor (#2874)
This commit is contained in:
@@ -58,6 +58,7 @@ export class MethodModelingViewProvider
|
||||
|
||||
this.webviewView = webviewView;
|
||||
|
||||
this.setInitialState(webviewView);
|
||||
this.registerToModelingStoreEvents();
|
||||
}
|
||||
|
||||
@@ -72,6 +73,18 @@ export class MethodModelingViewProvider
|
||||
}
|
||||
}
|
||||
|
||||
private setInitialState(webviewView: vscode.WebviewView): void {
|
||||
const selectedMethod = this.modelingStore.getSelectedMethodDetails();
|
||||
if (selectedMethod) {
|
||||
void webviewView.webview.postMessage({
|
||||
t: "setSelectedMethod",
|
||||
method: selectedMethod.method,
|
||||
modeledMethod: selectedMethod.modeledMethod,
|
||||
isModified: selectedMethod.isModified,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private async onMessage(msg: FromMethodModelingMessage): Promise<void> {
|
||||
switch (msg.t) {
|
||||
case "setModeledMethod": {
|
||||
|
||||
@@ -264,6 +264,27 @@ export class ModelingStore extends DisposableObject {
|
||||
});
|
||||
}
|
||||
|
||||
public getSelectedMethodDetails() {
|
||||
const dbState = this.getStateForActiveDb();
|
||||
if (!dbState) {
|
||||
throw new Error("No active state found in modeling store");
|
||||
}
|
||||
|
||||
const selectedMethod = dbState.selectedMethod;
|
||||
if (!selectedMethod) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return {
|
||||
method: selectedMethod,
|
||||
usage: dbState.selectedUsage,
|
||||
modeledMethod: dbState.modeledMethods[selectedMethod.signature],
|
||||
isModified: dbState.modifiedMethodSignatures.has(
|
||||
selectedMethod.signature,
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
private getState(databaseItem: DatabaseItem): DbModelingState {
|
||||
if (!this.state.has(databaseItem.databaseUri.toString())) {
|
||||
throw Error(
|
||||
|
||||
Reference in New Issue
Block a user