import {RcsbFvTrackDataElementInterface} from "@rcsb/rcsb-saguaro"; import { ViewerCallbackManagerInterface, ViewerActionManagerInterface } from "../../../RcsbFvStructure/StructureViewerInterface"; import {DataContainer} from "../../../Utils/DataContainer"; import { RcsbFvModulePublicInterface } from "@rcsb/rcsb-saguaro-app/build/dist/RcsbFvWeb/RcsbFvModule/RcsbFvModuleInterface"; import {PfvManagerInterface} from "./PfvManagerFactoryInterface"; import {RcsbFvStateInterface} from "../../../RcsbFvState/RcsbFvStateInterface"; export interface CallbackManagerInterface { structureViewerSelectionCallback(mode:'select'|'hover'): Promise; featureClickCallback(e:RcsbFvTrackDataElementInterface): void; highlightHoverCallback(selection: RcsbFvTrackDataElementInterface[]): void; pfvSelectionChangeCallback(selection: Array): void; modelChangeCallback(defaultAuthId?: string, defaultOperatorName?:string): Promise; pfvChangeCallback(args:U): Promise; } export interface CallbackManagerFactoryInterface { getCallbackManager(config: CallbackConfigInterface): CallbackManagerInterface; } export interface CallbackConfigInterface { rcsbFvContainer: DataContainer; stateManager: RcsbFvStateInterface; pfvFactory: PfvManagerInterface; } export abstract class AbstractCallbackManager implements CallbackManagerInterface { protected readonly rcsbFvContainer: DataContainer; protected readonly stateManager: RcsbFvStateInterface; protected pfvFactory: PfvManagerInterface; private readonly isInnerSelection: DataContainer = new DataContainer(); constructor(config: CallbackConfigInterface) { this.rcsbFvContainer = config.rcsbFvContainer; this.stateManager = config.stateManager; this.pfvFactory = config.pfvFactory; } public async structureViewerSelectionCallback(mode:'select'|'hover'): Promise { if(this.rcsbFvContainer.get() == null) return; this.isInnerSelection.set(true); await this.innerStructureViewerSelectionChange(mode); this.isInnerSelection.set(false); } public pfvSelectionChangeCallback(selection: Array): void { if(this.isInnerSelection.get()) return; this.innerPfvSelectionChange(selection); } public abstract featureClickCallback(e:RcsbFvTrackDataElementInterface): void; public abstract highlightHoverCallback(selection: RcsbFvTrackDataElementInterface[]): void; public abstract modelChangeCallback(defaultAuthId?: string, defaultOperatorName?:string): Promise; public abstract pfvChangeCallback(args: U): Promise; protected abstract innerStructureViewerSelectionChange(mode: "select" | "hover"): Promise ; protected abstract innerPfvSelectionChange(selection: Array): void; }