import { ApplicationRef, Injector, EventEmitter } from "@angular/core"; import { MessagerService } from "@farris/ui-messager"; import { ContextService } from "../services/context.service"; import { IEventBus } from '../event-bus/lib/types'; import { EventBusHandler } from "../event-bus/handler"; import { TabsHandler } from "../interface/handler/tabs-handler"; import { EditorHandler } from "../interface/handler/editor-handler"; import { RootHandler } from "../interface/handler/root-handler"; import { NavTreeService } from '../services/nav-tree.service'; import { NotifyService } from "@farris/ui-notify"; import { Observable, Subject } from "rxjs"; import { CommonEvent } from "../interface/event"; import { SaveResult } from "../event-bus/lib/types"; import { IEditorController } from "./types"; /** * 代码编辑器中央控制器 * @remarks * 掌握标签页、中心编辑器等组件实例,对外封装打开文件、关闭文件等基本接口 */ export declare class EditorController implements IEditorController { private injector; private applicationRef; private context; private eventBusHandler; private navTreeService; private msgSrv; private notifySrv; private root; /** 标签页组件实例 */ private tabs; /** 中心编辑器组件实例 */ private editor; readonly eventBus: IEventBus; /** 保存当前页签的文件 - 节流版本 */ throttledSaveCurrentFile: () => void; /** 全局按键事件 */ keydownEmitter: Subject; /** * 通知表单设计器代码编辑器内容已修改 */ private detectFileDirty; localeData: { save: string; formDesigner: string; codeDesigner: string; saveCurrentTab: string; saveCurrentTabTip: string; find: string; collpaseOrExpandNavPanel: string; collpaseOrExpandNavPanelTip: string; openCommandPanel: string; formatDocument: string; formatDocumentTip: string; saveSuccess: string; saveFailed: string; saveSuccessAll: string; saveVailate: string; unsave: string; cancel: string; unsaveInfo: string; errorInfo: string; unsaveInfo2: string; saveAndJump: string; nosaveAndJump: string; close: string; closeOthers: string; closeRight: string; closeSaved: string; closeAll: string; expandAll: string; collapseAll: string; search: string; searchEmpty: string; }; constructor(injector: Injector, // 防止依赖变更导致需要重新打包 applicationRef: ApplicationRef, context: ContextService, eventBusHandler: EventBusHandler, navTreeService: NavTreeService, msgSrv: MessagerService, notifySrv: NotifyService); getContextService(): ContextService; /** * 初始化中央控制器 * @param root 代码编辑器根组件 * @param tabs 标签页组件 * @param editor 中心编辑器组件 */ init(root: RootHandler, tabs: TabsHandler, editor: EditorHandler, detectFileDirty?: EventEmitter): void; /** 监听快捷键 - 仅初始化时调用一次 */ private listenShortcut; private subscribeOuterEvent; private subscribeInnerEvent; openFile(path: string, appendInfo?: any): void; showFile(path: string): void; /** * 更新标签页的标题和图标 * @param path 文件路径 */ private updateTabTitle; closeFile(path: string, force?: boolean): void; closeAllSavedFile(): void; closeToTheRight(path: string): void; closeAllFile(): void; closeOtherFile(path: string): void; /** * 关闭指定的几个文件条目(对应的标签页) * @remarks 如果存在未保存的文件则先显示该文件并弹框提示用户是否保存 * @param items 文件条目 * @returns 返回Observable以便在执行完成后追加操作,别忘记订阅 */ private closeFiles; /** * 保存并关闭文件 * @param path 标签页路径 * @param ignoreSuccessTip 不弹出保存成功提示 */ private saveAndCloseFile; /** 直接关闭文件 */ private directCloseFile; /** * 保存当前文件 * @param path 指定一个标签页路径,保存该标签页的文件(而不是保存当前文件) * @remarks 无论当前文件是否有变更都重新执行其保存回调函数 * @returns 保存结果,如果为空则表示当前没有文件被打开 */ private saveCurrentFile; /** * 保存全部文件 * @remarks 将保存全部有变更的文件(标签页可能配置“未变更也保存”选项) * @returns 保存结果 */ private saveAllFile; doSaveCurrentFile(notifyResult?: boolean, path?: string, ignoreSuccessTip?: boolean): Promise; private notifyOneSaveResult; doSaveAllFile(notifyResult?: boolean, ignoreSuccessTip?: boolean): Promise; private notifyAllSaveResult; /** * 是否全部保存成功 * @param results 保存结果数组 * @param 是否全部成功 */ private isAllSavedSuccess; private resetFileChanged; /** * 处理标签页选中事件 * @param path 文件路径 */ private handleTabSelected; refreshNavTree(selectNodePath?: string, type?: string[]): void; switchView(force?: boolean): void; private directSwitchView; setGlobalContextParam(key: string, value: any): any; getGlobalContextParam(key: string): any; detectChangesFromRoot(): void; sendNotification(path: string, event: CommonEvent): Observable | null; /** * 直接关闭所有标签页 */ private closeAllFileDirectly; /** 销毁代码视图,释放资源 */ destroy(): void; /** * */ private notifyFormDirtyInfo; }