class SourceCodeEditor implements IsWidget {

    public void init(SourceCodeType type, String code, Map<String,String> varMap, Command onSourceCodeChanged) {
        this.type = type;
        this.code = code;
        this.varMap = varMap == null ? new HashMap<>() : varMap;
        this.hasErrors = false;
        this.onSourceCodeChanged = onSourceCodeChanged;

        view.clearAll();
        view.edit(type, code);
        view.focus();

        for (String var : varMap.keySet()) {
            view.declareVariable(var, varMap.get(var));
        }

        String error = validateSourceCode(code);
        if (error != null) {
            hasErrors = true;
            view.error(error);
        }
    }

    @Inject public  SourceCodeEditor(View view, HtmlValidator htmlValidator, JsValidator jsValidator);

}