diff options
Diffstat (limited to 'src/background/operators/impls/CommandOperatorFactoryChain.ts')
-rw-r--r-- | src/background/operators/impls/CommandOperatorFactoryChain.ts | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/src/background/operators/impls/CommandOperatorFactoryChain.ts b/src/background/operators/impls/CommandOperatorFactoryChain.ts new file mode 100644 index 0000000..680a384 --- /dev/null +++ b/src/background/operators/impls/CommandOperatorFactoryChain.ts @@ -0,0 +1,63 @@ +import { inject, injectable } from "tsyringe"; +import Operator from "../Operator"; +import OperatorFactoryChain from "../OperatorFactoryChain"; +import ShowCommandOperator from "./ShowCommandOperator"; +import ShowOpenCommandOperator from "./ShowOpenCommandOperator"; +import ShowTabOpenCommandOperator from "./ShowTabOpenCommandOperator"; +import ShowWinOpenCommandOperator from "./ShowWinOpenCommandOperator"; +import ShowBufferCommandOperator from "./ShowBufferCommandOperator"; +import ShowAddBookmarkOperator from "./ShowAddBookmarkOperator"; +import TabPresenter from "../../presenters/TabPresenter"; +import ConsoleClient from "../../infrastructures/ConsoleClient"; +import * as operations from "../../../shared/operations"; +import StartFindOperator from "./StartFindOperator"; + +@injectable() +export default class CommandOperatorFactoryChain + implements OperatorFactoryChain { + constructor( + @inject("TabPresenter") + private readonly tabPresenter: TabPresenter, + @inject("ConsoleClient") + private readonly consoleClient: ConsoleClient + ) {} + + create(op: operations.Operation): Operator | null { + switch (op.type) { + case operations.COMMAND_SHOW: + return new ShowCommandOperator(this.tabPresenter, this.consoleClient); + case operations.COMMAND_SHOW_OPEN: + return new ShowOpenCommandOperator( + this.tabPresenter, + this.consoleClient, + op.alter + ); + case operations.COMMAND_SHOW_TABOPEN: + return new ShowTabOpenCommandOperator( + this.tabPresenter, + this.consoleClient, + op.alter + ); + case operations.COMMAND_SHOW_WINOPEN: + return new ShowWinOpenCommandOperator( + this.tabPresenter, + this.consoleClient, + op.alter + ); + case operations.COMMAND_SHOW_BUFFER: + return new ShowBufferCommandOperator( + this.tabPresenter, + this.consoleClient + ); + case operations.COMMAND_SHOW_ADDBOOKMARK: + return new ShowAddBookmarkOperator( + this.tabPresenter, + this.consoleClient, + op.alter + ); + case operations.FIND_START: + return new StartFindOperator(this.tabPresenter, this.consoleClient); + } + return null; + } +} |