mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-03-05 17:57:13 +00:00
70 lines
2.1 KiB
TypeScript
70 lines
2.1 KiB
TypeScript
import { IPublicApiWorkspace, IPublicResourceList, IPublicTypeResourceType } from '@alilc/lowcode-types';
|
|
import { Workspace as InnerWorkSpace } from '@alilc/lowcode-workspace';
|
|
import { Plugins } from '@alilc/lowcode-shell';
|
|
import { workspaceSymbol } from '../symbols';
|
|
import { Resource as ShellResource, Window as ShellWindow } from '../model';
|
|
|
|
export class Workspace implements IPublicApiWorkspace {
|
|
readonly [workspaceSymbol]: InnerWorkSpace;
|
|
|
|
constructor(innerWorkspace: InnerWorkSpace) {
|
|
this[workspaceSymbol] = innerWorkspace;
|
|
}
|
|
|
|
get resourceList() {
|
|
return this[workspaceSymbol].getResourceList().map((d) => new ShellResource(d));
|
|
}
|
|
|
|
setResourceList(resourceList: IPublicResourceList) {
|
|
this[workspaceSymbol].setResourceList(resourceList);
|
|
}
|
|
|
|
onResourceListChange(fn: (resourceList: IPublicResourceList) => void): () => void {
|
|
return this[workspaceSymbol].onResourceListChange(fn);
|
|
}
|
|
|
|
get isActive() {
|
|
return this[workspaceSymbol].isActive;
|
|
}
|
|
|
|
get window() {
|
|
return new ShellWindow(this[workspaceSymbol].window);
|
|
}
|
|
|
|
registerResourceType(resourceTypeModel: IPublicTypeResourceType): void {
|
|
this[workspaceSymbol].registerResourceType(resourceTypeModel);
|
|
}
|
|
|
|
openEditorWindow(resourceName: string, title: string, extra: object, viewName?: string) {
|
|
this[workspaceSymbol].openEditorWindow(resourceName, title, extra, viewName);
|
|
}
|
|
|
|
openEditorWindowById(id: string) {
|
|
this[workspaceSymbol].openEditorWindowById(id);
|
|
}
|
|
|
|
removeEditorWindow(resourceName: string, title: string) {
|
|
this[workspaceSymbol].removeEditorWindow(resourceName, title);
|
|
}
|
|
|
|
removeEditorWindowById(id: string) {
|
|
this[workspaceSymbol].removeEditorWindowById(id);
|
|
}
|
|
|
|
get plugins() {
|
|
return new Plugins(this[workspaceSymbol].plugins, true);
|
|
}
|
|
|
|
get windows() {
|
|
return this[workspaceSymbol].windows.map((d) => new ShellWindow(d));
|
|
}
|
|
|
|
onChangeWindows(fn: () => void) {
|
|
return this[workspaceSymbol].onChangeWindows(fn);
|
|
}
|
|
|
|
onChangeActiveWindow(fn: () => void) {
|
|
return this[workspaceSymbol].onChangeActiveWindow(fn);
|
|
}
|
|
}
|