(name: string, title: string, options: Object, viewName?: string, sleep?: boolean)
| 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); |
no test coverage detected