MCPcopy Index your code
hub / github.com/alibaba/lowcode-engine / openEditorWindow

Method openEditorWindow

packages/workspace/src/workspace.ts:296–344  ·  view source on GitHub ↗
(name: string, title: string, options: Object, viewName?: string, sleep?: boolean)

Source from the content-addressed store, hash-verified

294 }
295
296 async openEditorWindow(name: string, title: string, options: Object, viewName?: string, sleep?: boolean) {
297 if (this.window && !this.window.sleep && !this.window?.initReady && !sleep) {
298 this.windowQueue.push({
299 name, title, options, viewName,
300 });
301 return;
302 }
303 const resourceType = this.resourceTypeMap.get(name);
304 if (!resourceType) {
305 console.error(`${name} resourceType is not available`);
306 return;
307 }
308 this.window?.updateState(WINDOW_STATE.inactive);
309 const filterWindows = this.windows.filter(d => (d.resource?.name === name && d.resource.title == title) || (d.resource.id == title));
310 if (filterWindows && filterWindows.length) {
311 this.window = filterWindows[0];
312 if (!sleep && this.window.sleep) {
313 await this.window.init();
314 } else {
315 this.checkWindowQueue();
316 }
317 this.emitChangeActiveWindow();
318 this.window?.updateState(WINDOW_STATE.active);
319 return;
320 }
321 const resource = new Resource({
322 resourceName: name,
323 title,
324 options,
325 id: title?.toString(),
326 }, resourceType, this);
327 const window = new EditorWindow(resource, this, {
328 title,
329 options,
330 viewName,
331 sleep,
332 });
333 this.windows = [...this.windows, window];
334 this.editorWindowMap.set(window.id, window);
335 if (sleep) {
336 this.emitChangeWindow();
337 return;
338 }
339 this.window = window;
340 await this.window.init();
341 this.emitChangeWindow();
342 this.emitChangeActiveWindow();
343 this.window?.updateState(WINDOW_STATE.active);
344 }
345
346 onChangeWindows(fn: () => void) {
347 this.emitter.on(EVENT.CHANGE_WINDOW, fn);

Callers 1

checkWindowQueueMethod · 0.95

Calls 11

checkWindowQueueMethod · 0.95
emitChangeWindowMethod · 0.95
pushMethod · 0.80
toStringMethod · 0.80
getMethod · 0.65
errorMethod · 0.65
updateStateMethod · 0.65
filterMethod · 0.65
initMethod · 0.65
setMethod · 0.65

Tested by

no test coverage detected