MCPcopy
hub / github.com/alibaba/lowcode-engine / EditorWindow

Class EditorWindow

packages/workspace/src/window.ts:47–253  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

45}
46
47export class EditorWindow implements IEditorWindow {
48 id: string = uniqueId('window');
49 icon: React.ReactElement | undefined;
50
51 private emitter: IEventBus = createModuleEventBus('Project');
52
53 title: string | undefined;
54
55 url: string | undefined;
56
57 @obx.ref _editorView: Context;
58
59 @obx editorViews: Map<string, Context> = new Map<string, Context>();
60
61 @obx initReady = false;
62
63 sleep: boolean | undefined;
64
65 get editorView() {
66 if (!this._editorView) {
67 return this.editorViews.values().next().value;
68 }
69 return this._editorView;
70 }
71
72 constructor(readonly resource: IResource, readonly workspace: IWorkspace, private config: IWindowCOnfig) {
73 makeObservable(this);
74 this.title = config.title;
75 this.icon = resource.icon;
76 this.sleep = config.sleep;
77 if (config.sleep) {
78 this.updateState(WINDOW_STATE.sleep);
79 }
80 }
81
82 updateState(state: WINDOW_STATE): void {
83 switch (state) {
84 case WINDOW_STATE.active:
85 this._editorView?.setActivate(true);
86 break;
87 case WINDOW_STATE.inactive:
88 this._editorView?.setActivate(false);
89 break;
90 case WINDOW_STATE.destroyed:
91 break;
92 }
93 }
94
95 async importSchema(schema: any) {
96 const newSchema = await this.resource.import(schema);
97
98 if (!newSchema) {
99 return;
100 }
101
102 Object.keys(newSchema).forEach(key => {
103 const view = this.editorViews.get(key);
104 view?.project.importSchema(newSchema[key]);

Callers

nothing calls this directly

Calls 8

uniqueIdFunction · 0.85
createModuleEventBusFunction · 0.85
initMethod · 0.65
getMethod · 0.65
getEditorViewMethod · 0.65
setMethod · 0.65
emitMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…