import {Component, OnInit} from "@angular/core"; import {ConverterregistryService} from "./converterregistry.service"; import {Converter} from "./converter/converter"; import {InputcomponentmanagerService} from "./InputcomponentmanagerService"; @Component({ moduleId: module.id, selector: "den-inputarea", templateUrl: "inputarea.component.html", styleUrls: ["inputarea.component.css"] }) export class InputareaComponent extends OnInit { public converters:Converter[] = []; public content:string = ''; private selectedConverter:Converter; constructor(private converterregistryService:ConverterregistryService, private inputcomponentmanagerService:InputcomponentmanagerService) { super(); } public convert(e):void { this.selectedConverter = this.converterregistryService.getConverter(e.target.selectedOptions[0].id); this.update(); } public update():void { if (this.selectedConverter !== undefined) { let result:string = this.selectedConverter.convert(this.content); let nextComponent:InputareaComponent = this.inputcomponentmanagerService.getNext(this); if (nextComponent !== undefined) { nextComponent.setContent(result); } } } public setContent(content:string):void { this.content = content; this.update(); } ngOnInit():void { this.converters = this.converterregistryService.getAllConverters(); this.selectedConverter = undefined; this.inputcomponentmanagerService.register(this); } }