AdfRichUIPeer.createPeerClass(AdfDhtmlInputBasePeer, "AdfDhtmlCodeEditorPeer", false);
AdfDhtmlCodeEditorPeer.InitSubclass = function() {
  AdfObject.ensureClassInitialization(AdfRichCodeEditor);
  AdfRichUIPeer.addComponentEventHandlers(this, AdfUIInputEvent.BLUR_EVENT_TYPE, AdfActionEvent.ACTION_EVENT_TYPE, AdfUIInputEvent.KEY_DOWN_EVENT_TYPE, AdfUIInputEvent.FOCUS_EVENT_TYPE);
  this.InitConstants();
};
AdfDhtmlCodeEditorPeer.InitConstants = function() {
  this._CODEEDITOR_MARKER_PROPERTY_KEY = "AdfCodeEditorMarkers";
  this._CODE_MIRROR_CSS_PATH_PREFIX = "/afr/codemirror/";
  this._CODE_MIRROR_CSS = this._CODE_MIRROR_CSS_PATH_PREFIX + "codemirror.css";
  this._CODE_MIRROR_THEME_DEFAULT_CSS = this._CODE_MIRROR_CSS_PATH_PREFIX + "default.css";
  this._LANGUAGE_XML = "xml";
  this._LANGUAGE_JAVASCRIPT = "javascript";
  this._LANGUAGE_GROOVY = "groovy";
  this.COMMAND_UNDO = "cmd_undo";
  this.COMMAND_REDO = "cmd_redo";
  this.COMMAND_SEARCH_NEXT = "cmd_search_next";
  this.COMMAND_SEARCH_PREVIOUS = "cmd_search_previous";
  this.COMMAND_REPLACE_ALL = "cmd_replace_all";
  this.COMMAND_REPLACE_NEXT = "cmd_replace_next";
  this.COMMAND_JUMP = "cmd_jump";
  this._CODE_EDITOR_CONTENT_INPUT_CONTAINER_ID = "cc";
  this._CODE_EDITOR_CONTENT_INPUT_ID = "ci";
  this._CODE_EDITOR_HIDDEN_SCROLLPOS_ID = "hsp";
  this._CODE_EDITOR_LAZY_LOADING_IFRAME_ID = "ll";
  this._CODE_EDITOR_LAZY_LOADING_VALUE_ID = "llv";
  this._CODE_EDITOR_SEARCH_POPUP_ID = "_afrSearchPopup";
  this._CODE_EDITOR_TOOLBAR_ID = "tb";
  this._COMMAND_UNDO_BUTTON_ID = "_afrUndo";
  this._COMMAND_REDO_BUTTON_ID = "_afrRedo";
  this._COMMAND_SEARCH_NEXT_BUTTON_ID = "_afrSearchNext";
  this._COMMAND_SEARCH_PREVIOUS_BUTTON_ID = "_afrSearchPrevious";
  this._COMMAND_JUMP_BUTTON_ID = "_afrJump";
  this._COMMAND_SEARCH_SHOW_BUTTON_ID = "_afrSearchPopupShow";
  this._COMMAND_SEARCH_NEXT_POPUP_BUTTON_ID = "_afrSearchNextPopup";
  this._COMMAND_SEARCH_PREVIOUS_POPUP_BUTTON_ID = "_afrSearchPreviousPopup";
  this._COMMAND_REPLACE_ALL_POPUP_BUTTON_ID = "_afrReplaceAllPopup";
  this._COMMAND_REPLACE_NEXT_POPUP_BUTTON_ID = "_afrReplaceNextPopup";
  this._COMMAND_SEARCH_POPUP_FIELD_ID = "_afrSearchPopupField";
  this._COMMAND_REPLACE_POPUP_FIELD_ID = "_afrReplacePopupField";
  this._COMMAND_CASE_SENSITIVE_POPUP_CHECKBOX_ID = "_afrCaseSensitivePopupField";
  this._COMMAND_WHOLE_WORDS_POPUP_CHECKBOX_ID = "_afrWholeWordsPopupField";
  this._COMMAND_WRAP_POPUP_CHECKBOX_ID = "_afrWrapPopupField";
  this._COMMAND_SEARCH_TOOLBAR_FIELD_ID = "_afrSearchToolbarField";
  this._COMMAND_JUMP_FIELD_ID = "_afrJumpField";
  this._CODEEDITOR_MESSAGE_SEPARATOR = ", ";
  this._CODE_EDITOR_MARKERS_CONTENT_CONTAINER_CLASS = "af|codeEditor::markers-content-container";
  this._CODE_EDITOR_MARKERS_CONTENT_CLASS = "af|codeEditor::markers-content";
  this._CODE_EDITOR_MARKERS_LABEL_CLASS = "af|codeEditor::markers-label";
  this._CODE_EDITOR_MARKERS_TEXT_CLASS = "af|codeEditor::markers-text";
  this._CODE_EDITOR_EDITOR_LINES_CLASS = "af|codeEditor::editor-lines";
  this._CODE_EDITOR_EDITOR_SCROLL_CLASS = "af|codeEditor::editor-scroll";
  this._CODE_EDITOR_EDITOR_GUTTER_CLASS = "af|codeEditor::editor-gutter";
  this._CODE_EDITOR_EDITOR_GUTTER_LINENUMBERS_CLASS = "af|codeEditor::editor-gutter-linenumbers";
  this._CODE_EDITOR_EDITOR_MARKER_SEARCH_CLASS = "af|codeEditor::editor-search-highlight";
  this._CODE_EDITOR_EDITOR_MARKER_LINE_CLASS = "af|codeEditor::editor-jump-highlight";
  this._CODE_EDITOR_EDITOR_MARKER_ERROR_CLASS = "af|codeEditor::editor-marker-error";
  this._CODE_EDITOR_EDITOR_MARKER_FATAL_CLASS = "af|codeEditor::editor-marker-fatal";
  this._CODE_EDITOR_EDITOR_MARKER_WARNING_CLASS = "af|codeEditor::editor-marker-warning";
  this._CODE_EDITOR_EDITOR_MARKER_INFO_CLASS = "af|codeEditor::editor-marker-info";
  this._CODE_EDITOR_EDITOR_TEXT_CLASS = "af|codeEditor::editor-text";
  this._CODE_EDITOR_EDITOR_DISABLED_TEXT_CLASS = "af|codeEditor::editor-disabled-text";
  this._CODE_EDITOR_SMALL_FATAL_ICON_CLASS = "af|codeEditor::small-fatal-icon";
  this._CODE_EDITOR_SMALL_ERROR_ICON_CLASS = "af|codeEditor::small-error-icon";
  this._CODE_EDITOR_SMALL_WARNING_ICON_CLASS = "af|codeEditor::small-warning-icon";
  this._CODE_EDITOR_SMALL_INFO_ICON_CLASS = "af|codeEditor::small-info-icon";
  this._CODE_EDITOR_MESSAGE_SUMMARY_TEXT_CLASS = "af|codeEditor::message-summary-text";
  this._CODE_EDITOR_MESSAGE_ICON_STYLE_CLASS = "af|codeEditor::message-icon-style";
  this._CODE_EDITOR_EDITOR_FOLD_MARKER_CLASS = "af|codeEditor::editor-fold-marker";
  this._CODE_EDITOR_EDITOR_FOLD_GUTTER_CLASS = "af|codeEditor::editor-fold-gutter";
  this._CODE_EDITOR_EDITOR_FOLD_GUTTER_OPEN_CLASS = "af|codeEditor::editor-fold-gutter-open";
  this._CODE_EDITOR_EDITOR_FOLD_GUTTER_FOLDED_CLASS = "af|codeEditor::editor-fold-gutter-folded";
  this._CODE_EDITOR_EDITOR_FOLD_GUTTER_OPEN_AFTER_CLASS = "af|codeEditor::editor-fold-gutter-open-after";
  this._CODE_EDITOR_EDITOR_FOLD_GUTTER_FOLDED_AFTER_CLASS = "af|codeEditor::editor-fold-gutter-folded-after";
  this._CODE_EDITOR_EDITOR_BREAKPOINTS_CLASS = "af|codeEditor::editor-breakpoints";
  this._CODE_EDITOR_EDITOR_CODEMIRROR_CLASS = "af|codeEditor::editor-codemirror";
  this._CODE_EDITOR_EDITOR_CODE_COMPLETIONS_CLASS = "af|codeEditor::editor-code-completions";
  this._CODE_EDITOR_EDITOR_HINT_CLASS = "af|codeEditor::editor-code-hint";
  this._CODE_EDITOR_EDITOR_HINT_ACTIVE_CLASS = "af|codeEditor::editor-code-hint-active";
  this._CSS_MAP = new Array;
  this._CSS_MAP[AdfDhtmlCodeEditorPeer._CODE_EDITOR_EDITOR_LINES_CLASS] = ".CodeMirror-lines";
  this._CSS_MAP[AdfDhtmlCodeEditorPeer._CODE_EDITOR_EDITOR_SCROLL_CLASS] = ".CodeMirror-scroll";
  this._CSS_MAP[AdfDhtmlCodeEditorPeer._CODE_EDITOR_EDITOR_GUTTER_CLASS] = ".CodeMirror-gutter";
  this._CSS_MAP[AdfDhtmlCodeEditorPeer._CODE_EDITOR_EDITOR_GUTTER_LINENUMBERS_CLASS] = ".CodeMirror-gutter-text";
  this._CSS_MAP[AdfDhtmlCodeEditorPeer._CODE_EDITOR_EDITOR_TEXT_CLASS] = ".CodeMirror pre";
  this._CSS_MAP[AdfDhtmlCodeEditorPeer._CODE_EDITOR_EDITOR_FOLD_MARKER_CLASS] = ".CodeMirror-foldmarker";
  this._CSS_MAP[AdfDhtmlCodeEditorPeer._CODE_EDITOR_EDITOR_FOLD_GUTTER_CLASS] = ".CodeMirror-foldgutter";
  this._CSS_MAP[AdfDhtmlCodeEditorPeer._CODE_EDITOR_EDITOR_FOLD_GUTTER_OPEN_CLASS] = ".CodeMirror-foldgutter-open";
  this._CSS_MAP[AdfDhtmlCodeEditorPeer._CODE_EDITOR_EDITOR_FOLD_GUTTER_FOLDED_CLASS] = ".CodeMirror-foldgutter-folded";
  this._CSS_MAP[AdfDhtmlCodeEditorPeer._CODE_EDITOR_EDITOR_FOLD_GUTTER_OPEN_AFTER_CLASS] = ".CodeMirror-foldgutter-open:after";
  this._CSS_MAP[AdfDhtmlCodeEditorPeer._CODE_EDITOR_EDITOR_FOLD_GUTTER_FOLDED_AFTER_CLASS] = ".CodeMirror-foldgutter-folded:after";
  this._CSS_MAP[AdfDhtmlCodeEditorPeer._CODE_EDITOR_EDITOR_BREAKPOINTS_CLASS] = ".breakpoints";
  this._CSS_MAP[AdfDhtmlCodeEditorPeer._CODE_EDITOR_EDITOR_CODEMIRROR_CLASS] = ".CodeMirror";
  this._CSS_MAP[AdfDhtmlCodeEditorPeer._CODE_EDITOR_EDITOR_CODE_COMPLETIONS_CLASS] = ".CodeMirror-hints";
  this._CSS_MAP[AdfDhtmlCodeEditorPeer._CODE_EDITOR_EDITOR_HINT_CLASS] = ".CodeMirror-hint";
  this._CSS_MAP[AdfDhtmlCodeEditorPeer._CODE_EDITOR_EDITOR_HINT_ACTIVE_CLASS] = "li.CodeMirror-hint-active";
};
AdfDhtmlCodeEditorPeer.prototype.getEditorInstance = function(component) {
  return this._editor;
};
AdfDhtmlCodeEditorPeer.prototype.InitDomElement = function(component, domElement) {
  AdfDhtmlCodeEditorPeer.superclass.InitDomElement.call(this, component, domElement);
  if (!component) {
    return;
  }
  var componentId = component.getId();
  this._loaded = false;
  AdfPage.PAGE.unregisterLoadingComponent(component);
  AdfPage.PAGE.registerLoadingComponent(component);
  this._addCSSResource(AdfPage.PAGE.getResourceURL(AdfDhtmlCodeEditorPeer._CODE_MIRROR_CSS), false);
  this._markerInfoArray = new Array;
  if (component.getContentDelivery() == "lazy") {
    this._createIframe(component);
  }
  if (!component.getSimple()) {
    if (domElement.style.height == "auto") {
      domElement.style.height = "";
    }
    if (domElement.style.width == "auto") {
      domElement.style.width = "";
    }
  }
  this.addBinding(componentId + AdfDhtmlCodeEditorPeer._COMMAND_UNDO_BUTTON_ID, AdfDhtmlCodeEditorPeer.COMMAND_UNDO, null);
  this.addBinding(componentId + AdfDhtmlCodeEditorPeer._COMMAND_REDO_BUTTON_ID, AdfDhtmlCodeEditorPeer.COMMAND_REDO, null);
  this.addBinding(componentId + AdfDhtmlCodeEditorPeer._COMMAND_SEARCH_NEXT_BUTTON_ID, AdfDhtmlCodeEditorPeer.COMMAND_SEARCH_NEXT, new Array(componentId + AdfDhtmlCodeEditorPeer._COMMAND_SEARCH_TOOLBAR_FIELD_ID, null, null, null));
  this.addBinding(componentId + AdfDhtmlCodeEditorPeer._COMMAND_SEARCH_PREVIOUS_BUTTON_ID, AdfDhtmlCodeEditorPeer.COMMAND_SEARCH_PREVIOUS, new Array(componentId + AdfDhtmlCodeEditorPeer._COMMAND_SEARCH_TOOLBAR_FIELD_ID, null, null, null));
  this.addBinding(componentId + AdfDhtmlCodeEditorPeer._COMMAND_REPLACE_ALL_POPUP_BUTTON_ID, AdfDhtmlCodeEditorPeer.COMMAND_REPLACE_ALL, new Array(componentId + AdfDhtmlCodeEditorPeer._COMMAND_SEARCH_POPUP_FIELD_ID, componentId + AdfDhtmlCodeEditorPeer._COMMAND_REPLACE_POPUP_FIELD_ID, componentId + AdfDhtmlCodeEditorPeer._COMMAND_CASE_SENSITIVE_POPUP_CHECKBOX_ID, componentId + AdfDhtmlCodeEditorPeer._COMMAND_WHOLE_WORDS_POPUP_CHECKBOX_ID));
  this.addBinding(componentId + AdfDhtmlCodeEditorPeer._COMMAND_REPLACE_NEXT_POPUP_BUTTON_ID, AdfDhtmlCodeEditorPeer.COMMAND_REPLACE_NEXT, new Array(componentId + AdfDhtmlCodeEditorPeer._COMMAND_SEARCH_POPUP_FIELD_ID, componentId + AdfDhtmlCodeEditorPeer._COMMAND_REPLACE_POPUP_FIELD_ID, componentId + AdfDhtmlCodeEditorPeer._COMMAND_CASE_SENSITIVE_POPUP_CHECKBOX_ID, componentId + AdfDhtmlCodeEditorPeer._COMMAND_WHOLE_WORDS_POPUP_CHECKBOX_ID, componentId + AdfDhtmlCodeEditorPeer._COMMAND_WRAP_POPUP_CHECKBOX_ID));
  this.addBinding(componentId + AdfDhtmlCodeEditorPeer._COMMAND_SEARCH_NEXT_POPUP_BUTTON_ID, AdfDhtmlCodeEditorPeer.COMMAND_SEARCH_NEXT, new Array(componentId + AdfDhtmlCodeEditorPeer._COMMAND_SEARCH_POPUP_FIELD_ID, componentId + AdfDhtmlCodeEditorPeer._COMMAND_CASE_SENSITIVE_POPUP_CHECKBOX_ID, componentId + AdfDhtmlCodeEditorPeer._COMMAND_WHOLE_WORDS_POPUP_CHECKBOX_ID, componentId + AdfDhtmlCodeEditorPeer._COMMAND_WRAP_POPUP_CHECKBOX_ID));
  this.addBinding(componentId + AdfDhtmlCodeEditorPeer._COMMAND_SEARCH_PREVIOUS_POPUP_BUTTON_ID, AdfDhtmlCodeEditorPeer.COMMAND_SEARCH_PREVIOUS, new Array(componentId + AdfDhtmlCodeEditorPeer._COMMAND_SEARCH_POPUP_FIELD_ID, componentId + AdfDhtmlCodeEditorPeer._COMMAND_CASE_SENSITIVE_POPUP_CHECKBOX_ID, componentId + AdfDhtmlCodeEditorPeer._COMMAND_WHOLE_WORDS_POPUP_CHECKBOX_ID, componentId + AdfDhtmlCodeEditorPeer._COMMAND_WRAP_POPUP_CHECKBOX_ID));
  this.addBinding(componentId + AdfDhtmlCodeEditorPeer._COMMAND_JUMP_BUTTON_ID, AdfDhtmlCodeEditorPeer.COMMAND_JUMP, componentId + AdfDhtmlCodeEditorPeer._COMMAND_JUMP_FIELD_ID);
  this._addContextChangeListeners(component);
  AdfDhtmlCodeEditorPeer._waitForCSSResourcesLoad(component, domElement);
};
AdfDhtmlCodeEditorPeer.prototype.addBinding = function(componentId, command, commandParameter) {
  AdfAssert.assertString(componentId);
  AdfAssert.assertString(command);
  if (command.substring(0, 3) == "cmd") {
    this._addCommandBinding(componentId, command, commandParameter);
  } else {
    AdfLogger.LOGGER.severe("Unable to add binding [", command, "] for ", componentId, " to ", this.getComponent().getClientId());
  }
};
AdfDhtmlCodeEditorPeer.prototype.executeBinding = function(command, componentClientId) {
  var observers = this._commandObservers;
  var length = observers.length;
  for (var i = 0;i < length;i++) {
    var observer = observers[i];
    if (observer.command == command) {
      if (componentClientId) {
        if (componentClientId != observer.componentId) {
          continue;
        }
      }
      if (observer.command == AdfDhtmlCodeEditorPeer.COMMAND_SEARCH_ALL || observer.command == AdfDhtmlCodeEditorPeer.COMMAND_SEARCH_NEXT || observer.command == AdfDhtmlCodeEditorPeer.COMMAND_SEARCH_PREVIOUS || observer.command == AdfDhtmlCodeEditorPeer.COMMAND_REPLACE_ALL || observer.command == AdfDhtmlCodeEditorPeer.COMMAND_REPLACE_NEXT || observer.command == AdfDhtmlCodeEditorPeer.COMMAND_JUMP) {
        var parameterValue = null;
        if (observer.command == AdfDhtmlCodeEditorPeer.COMMAND_SEARCH_ALL || observer.command == AdfDhtmlCodeEditorPeer.COMMAND_SEARCH_NEXT || observer.command == AdfDhtmlCodeEditorPeer.COMMAND_SEARCH_PREVIOUS) {
          var searchField = AdfPage.PAGE.findComponent(observer.commandParameter[0]);
          var searchFieldContent = AdfDhtmlEditableValuePeer.getContentNode(searchField, searchField.getPeer().getDomElement());
          var caseSensitiveCheckBoxValue = false;
          var wholeWordsCheckBoxValue = false;
          var wrapCheckBoxValue = false;
          if (observer.commandParameter[1] != null) {
            var caseSensitiveCheckBox = AdfPage.PAGE.findComponent(observer.commandParameter[1]);
            if (caseSensitiveCheckBox) {
              caseSensitiveCheckBoxValue = caseSensitiveCheckBox.getValue();
            }
          }
          if (observer.commandParameter[2] != null) {
            var wholeWordsCheckBox = AdfPage.PAGE.findComponent(observer.commandParameter[2]);
            if (wholeWordsCheckBox) {
              wholeWordsCheckBoxValue = wholeWordsCheckBox.getValue();
            }
          }
          if (observer.commandParameter[3] != null) {
            var wrapCheckBox = AdfPage.PAGE.findComponent(observer.commandParameter[3]);
            if (wrapCheckBox) {
              wrapCheckBoxValue = wrapCheckBox.getValue();
            }
          }
          var searchFieldContentVal = searchFieldContent.value;
          if (searchFieldContent.value == null || searchFieldContent.value.length == 0) {
            searchFieldContentVal = searchField.getValue();
          }
          parameterValue = new Array(searchFieldContentVal, caseSensitiveCheckBoxValue, wholeWordsCheckBoxValue, wrapCheckBoxValue);
        } else {
          if (observer.command == AdfDhtmlCodeEditorPeer.COMMAND_REPLACE_ALL || observer.command == AdfDhtmlCodeEditorPeer.COMMAND_REPLACE_NEXT) {
            searchField = AdfPage.PAGE.findComponent(observer.commandParameter[0]);
            var replaceField = AdfPage.PAGE.findComponent(observer.commandParameter[1]);
            var caseSensitiveCheckBoxValue = false;
            var wholeWordsCheckBoxValue = false;
            var wrapCheckBoxValue = false;
            if (observer.commandParameter[2] != null) {
              var caseSensitiveCheckBox = AdfPage.PAGE.findComponent(observer.commandParameter[2]);
              if (caseSensitiveCheckBox) {
                caseSensitiveCheckBoxValue = caseSensitiveCheckBox.getValue();
              }
            }
            if (observer.commandParameter[3] != null) {
              var wholeWordsCheckBox = AdfPage.PAGE.findComponent(observer.commandParameter[3]);
              if (wholeWordsCheckBox) {
                wholeWordsCheckBoxValue = wholeWordsCheckBox.getValue();
              }
            }
            if (observer.commandParameter[4] != null) {
              var wrapCheckBox = AdfPage.PAGE.findComponent(observer.commandParameter[4]);
              if (wrapCheckBox) {
                wrapCheckBoxValue = wrapCheckBox.getValue();
              }
            }
            parameterValue = new Array(searchField.getValue(), replaceField.getValue(), caseSensitiveCheckBoxValue, wholeWordsCheckBoxValue, wrapCheckBoxValue);
          } else {
            if (observer.command == AdfDhtmlCodeEditorPeer.COMMAND_JUMP) {
              var jumpField = AdfPage.PAGE.findComponent(observer.commandParameter);
              var jumpFieldContent = AdfDhtmlEditableValuePeer.getContentNode(jumpField, jumpField.getPeer().getDomElement());
              parameterValue = jumpFieldContent.value;
            }
          }
        }
        return this._execCommand(observer.command, parameterValue);
      } else {
        return this._execCommand(observer.command, observer.commandParameter);
      }
      break;
    }
  }
  return null;
};
AdfDhtmlCodeEditorPeer.prototype.getReadyState = function() {
  if (!this._loaded) {
    return AdfUIComponent.STATE_LOADING;
  } else {
    return AdfUIComponent.STATE_COMPLETE;
  }
};
AdfDhtmlCodeEditorPeer.prototype.HandleComponentBlur = function(componentEvent) {
  if (componentEvent.getEventPhase() == AdfBaseEvent.AT_TARGET_PHASE) {
    var component = this.getComponent();
    if (this._editorUpdated) {
      AdfPage.PAGE.clearMessages(component.getClientId());
    }
    var state = {componentId:component.getClientId(), targetNode:componentEvent.getNativeEventTarget()};
    this._blurTimeout = page.scheduleTimer(this, this._onBlurTimeout, state, 10);
  } else {
    AdfDhtmlCodeEditorPeer.superclass.HandleComponentBlur.call(this, componentEvent);
  }
};
AdfDhtmlCodeEditorPeer.prototype.HandleComponentAction = function(componentEvent) {
  if (this._commandObservers == undefined) {
    return;
  }
  componentEvent.setPartial(true);
  var eventComponentId = componentEvent.getSource().getClientId();
  var componentId = this.getComponent().getId();
  if (eventComponentId == componentId + AdfDhtmlCodeEditorPeer._COMMAND_SEARCH_SHOW_BUTTON_ID) {
    AdfDhtmlCodeEditorPeer._showPopup(this.getComponent(), componentId + AdfDhtmlCodeEditorPeer._CODE_EDITOR_SEARCH_POPUP_ID);
    componentEvent.cancel();
  }
  var observers = this._commandObservers;
  var length = observers.length;
  for (var i = 0;i < length;i++) {
    var observer = observers[i];
    if (observer.componentId == eventComponentId) {
      var result = this.executeBinding(observer.command, observer.componentId);
      this._handleContextChanged();
      if (observer.componentId == componentId + AdfDhtmlCodeEditorPeer._COMMAND_SEARCH_NEXT_BUTTON_ID || observer.componentId == componentId + AdfDhtmlCodeEditorPeer._COMMAND_SEARCH_PREVIOUS_BUTTON_ID) {
        if (!result) {
          var listenerComponent = AdfPage.PAGE.findComponent(observer.componentId);
          listenerComponent.setProperty("disabled", true, false, false);
          this._oldCommandValues = null;
        }
      }
      componentEvent.cancel();
      break;
    }
  }
};
AdfDhtmlCodeEditorPeer.prototype.HandleComponentFocus = function(componentEvent) {
  AdfDhtmlCodeEditorPeer.superclass.HandleComponentFocus.call(this, componentEvent);
  var component = this.getComponent();
  if (!component.getReadOnly()) {
    if (AdfDhtmlCodeEditorPeer._isInCodeContainer(component, componentEvent)) {
      var contentNode = AdfDhtmlCodeEditorPeer._getCodeEditorContentNode(component);
      AdfDhtmlInputBasePeer.setLastValue(contentNode);
      AdfDhtmlCodeEditorPeer._saveHiddenCursorPosition(component, this.getEditorInstance());
    }
  }
};
AdfDhtmlCodeEditorPeer.prototype.HandleComponentKeyDown = function(componentEvent) {
  var component = this.getComponent();
  var keyCode = componentEvent.getKeyCode();
  var evt = componentEvent.getNativeEvent();
  var isInCodeContainer = AdfDhtmlCodeEditorPeer._isInCodeContainer(component, componentEvent);
  if (isInCodeContainer) {
    var editor = this.getEditorInstance();
    if (AdfKeyStroke.F2_KEY == keyCode) {
      this._inEditngMode = true;
      componentEvent.cancel();
    }
    if (this._inEditngMode) {
      if (AdfKeyStroke.ESC_KEY == keyCode) {
        this._inEditngMode = false;
      } else {
        if (AdfKeyStroke.TAB_KEY == keyCode) {
          if (evt.shiftKey) {
            editor.indentLine(editor.getCursor(true)["line"], "subtract");
          } else {
            CodeMirror.commands[editor.getCursor(true)["line"] != editor.getCursor()["line"] ? "indentMore" : "insertTab"](editor);
          }
        }
      }
    } else {
      if (AdfKeyStroke.TAB_KEY == componentEvent.getKeyCode()) {
        this._undo();
        if (evt.shiftKey) {
          AdfFocusUtils.focusPreviousTabStop(AdfPage.PAGE.getActiveDomElement());
        } else {
          AdfFocusUtils.focusNextTabStop(AdfPage.PAGE.getActiveDomElement());
        }
      }
    }
  } else {
    var componentId = component.getId();
    if (AdfKeyStroke.ENTER_KEY == componentEvent.getKeyCode()) {
      var focusElement = AdfPage.PAGE.getActiveDomElement();
      if (focusElement.id.indexOf(componentId + AdfDhtmlCodeEditorPeer._COMMAND_JUMP_FIELD_ID) != -1) {
        this.executeBinding(AdfDhtmlCodeEditorPeer.COMMAND_JUMP, componentId + AdfDhtmlCodeEditorPeer._COMMAND_JUMP_BUTTON_ID);
      } else {
        if (focusElement.id.indexOf(component.getId() + AdfDhtmlCodeEditorPeer._COMMAND_SEARCH_TOOLBAR_FIELD_ID) != -1) {
          this.executeBinding(AdfDhtmlCodeEditorPeer.COMMAND_SEARCH_NEXT, componentId + AdfDhtmlCodeEditorPeer._COMMAND_SEARCH_NEXT_BUTTON_ID);
        }
      }
    }
  }
};
AdfDhtmlCodeEditorPeer.prototype.RunValidation = function(component, targetNode, isChangeRequired) {
  var agent = AdfAgent.AGENT;
  var clientId = component.getClientId();
  this.getEditorInstance().save();
  var inCodeMirrorDom = AdfDomUtils.isAncestorOrSelf(this.getEditorInstance().getWrapperElement(), targetNode);
  if (inCodeMirrorDom) {
    var codeEditorContentNode = AdfDhtmlCodeEditorPeer._getCodeEditorContentNode(component);
    var hiddenCursorPosition = AdfDhtmlCodeEditorPeer._getHiddenCursorPosition(component);
    if (this.WasSubmitted(component)) {
      var lastValue = AdfDhtmlInputBasePeer.getLastValue(codeEditorContentNode);
      var value = codeEditorContentNode.value;
      if (!isChangeRequired || value != lastValue) {
        AdfDhtmlInputBasePeer.setLastValue(codeEditorContentNode, value);
        this.Validate(component, value);
      }
    }
    if (hiddenCursorPosition != null) {
      AdfDhtmlCodeEditorPeer._restoreCursorPosition(component, hiddenCursorPosition);
      this._editor.getScrollerElement().scrollTop = hiddenCursorPosition.scrollTop;
      AdfDhtmlCodeEditorPeer._saveHiddenCursorPosition(component, this.getEditorInstance());
    }
  }
};
AdfDhtmlCodeEditorPeer.prototype.SetDisplayValue = function(component, domElement, newValue) {
  AdfAssert.assertString(newValue);
  if (this.getEditorInstance().getValue() != newValue) {
    this.getEditorInstance().setValue(newValue);
    this.getEditorInstance().save();
  }
};
AdfDhtmlCodeEditorPeer.prototype.GetSubmittedValue = function(component, domElement) {
  if (this.getEditorInstance() != null) {
    this.getEditorInstance().save();
    this._editorUpdated = false;
  }
  var codeEditorContentNode = AdfDhtmlCodeEditorPeer._getCodeEditorContentNode(component);
  var value = codeEditorContentNode.value;
  if (value != null && value.length == 0) {
    return null;
  }
  return value;
};
AdfDhtmlCodeEditorPeer.prototype.getHintsWrapper = function(editor, peer) {
  var currentCursor = editor.getCursor();
  var cursorRow = currentCursor["line"];
  var cursorColumn = currentCursor.ch;
  var hintsObj = peer._getHints(cursorRow, cursorColumn);
  AdfAssert.assert(hintsObj != null);
  AdfAssert.assertArray(hintsObj.hints);
  AdfAssert.assertNumber(hintsObj.from.row);
  AdfAssert.assertNumber(hintsObj.to.row);
  AdfAssert.assertNumber(hintsObj.from.column);
  AdfAssert.assertNumber(hintsObj.to.column);
  return {"list":hintsObj["hints"], "from":{line:hintsObj["from"]["row"], ch:hintsObj["from"]["column"]}, "to":{line:hintsObj["to"]["row"], ch:hintsObj["to"]["column"]}};
};
AdfDhtmlCodeEditorPeer.prototype.SetHintsFunction = function(component, getHints) {
  var peer = component.getPeer();
  peer._getHints = getHints;
};
AdfDhtmlCodeEditorPeer.prototype.MessageNotify = function(maxType, messages) {
  AdfDhtmlCodeEditorPeer.superclass.MessageNotify.call(this, maxType, messages);
  var agent = AdfAgent.AGENT;
  var laf = AdfPage.PAGE.getLookAndFeel();
  var markersMessagesCountText = "";
  var markersErrorParentNode;
  var component = this.getComponent();
  var messageCountObj = new Object;
  messageCountObj.errorCount = 0;
  messageCountObj.warningCount = 0;
  messageCountObj.infoCount = 0;
  messageCountObj.fatalCount = 0;
  if (messages != null) {
    var jumpToMarker = true;
    var addedMarkers = false;
    var domDocument = AdfPage.PAGE.getDomDocument();
    var markersTableNode = null;
    for (var m = 0;m < messages.length;m++) {
      var message = messages[m];
      var markers = message.getProperty(AdfDhtmlCodeEditorPeer._CODEEDITOR_MARKER_PROPERTY_KEY);
      if (markers != null && markers.length > 0) {
        markersTableNode = domDocument.createElement("table");
        for (var i = 0;i < markers.length;i++) {
          var marker = markers[i];
          var startLine = marker.getStartLine();
          var startColumn = marker.getStartColumn();
          if (startLine != null && startColumn != null) {
            var markerInfo = this._addMarker(marker, jumpToMarker);
            this._addMessageIconOnGutter(marker, component, markerInfo);
            messageCountObj = this._incrementMessageCountObj(marker, messageCountObj);
            jumpToMarker = false;
            var styleClass = this._getMessageStyleClass(marker);
            var markerRowNode = domDocument.createElement("tr");
            markersTableNode.appendChild(markerRowNode);
            var markerImgCellNode = domDocument.createElement("td");
            AdfDomUtils.addCSSClassName(markerImgCellNode, laf.getStyleClass(AdfDhtmlCodeEditorPeer._CODE_EDITOR_MESSAGE_ICON_STYLE_CLASS));
            agent.setAttribute(markerImgCellNode, "valign", "top");
            markerRowNode.appendChild(markerImgCellNode);
            markerImgCellNode.appendChild(this._getMarkerImgDom(styleClass));
            var markerLinkCellNode = domDocument.createElement("td");
            markerRowNode.appendChild(markerLinkCellNode);
            markerLinkCellNode.appendChild(this._getMarkerDom(markerInfo));
            addedMarkers = true;
          }
        }
      }
    }
    if (addedMarkers) {
      var markerSubId = this._getMarkersSubId();
      var markerLabelSubId = this._getMarkersLabelSubId();
      var markersContainerNode = agent.getElementById(markerSubId);
      var markersLabelNode = agent.getElementById(markerLabelSubId);
      var contentNode = AdfDhtmlEditableValuePeer.getContentNode(component);
      if (!markersLabelNode) {
        markersLabelNode = domDocument.createElement("div");
        markersLabelNode.id = markerLabelSubId;
        AdfDomUtils.addCSSClassName(markersLabelNode, laf.getStyleClass(AdfDhtmlCodeEditorPeer._CODE_EDITOR_MARKERS_LABEL_CLASS));
        contentNode.appendChild(markersLabelNode);
        var markersLabel = AdfPage.PAGE.getLookAndFeel().getTranslatedString("af_codeEditor.LABEL_MARKERS");
        markersLabelTextNode = domDocument.createTextNode(markersLabel);
        markersErrorParentNode = domDocument.createElement("label");
        AdfDomUtils.addCSSClassName(markersErrorParentNode, laf.getStyleClass(AdfDhtmlCodeEditorPeer._CODE_EDITOR_MESSAGE_SUMMARY_TEXT_CLASS));
        var messageSeparator = "";
        var severityString = "";
        if (messageCountObj.errorCount > 0) {
          severityString = AdfMessageUtils.getString(AdfFacesMessage.TYPE_ERROR, false);
          var errorCount = severityString + ": " + messageCountObj.errorCount;
          markersMessagesCountText = markersMessagesCountText + errorCount;
        }
        if (messageCountObj.warningCount > 0) {
          severityString = AdfMessageUtils.getString(AdfFacesMessage.TYPE_WARNING, false);
          if (markersMessagesCountText.length > 0) {
            messageSeparator = AdfDhtmlCodeEditorPeer._CODEEDITOR_MESSAGE_SEPARATOR;
          }
          var warningCount = messageSeparator + severityString + ": " + messageCountObj.warningCount;
          markersMessagesCountText = markersMessagesCountText + warningCount;
        }
        if (messageCountObj.fatalCount > 0) {
          severityString = AdfMessageUtils.getString(AdfFacesMessage.TYPE_FATAL, false);
          if (markersMessagesCountText.length > 0) {
            messageSeparator = AdfDhtmlCodeEditorPeer._CODEEDITOR_MESSAGE_SEPARATOR;
          }
          var fatalCount = messageSeparator + severityString + ": " + messageCountObj.fatalCount;
          markersMessagesCountText = markersMessagesCountText + fatalCount;
        }
        if (messageCountObj.infoCount > 0) {
          severityString = AdfMessageUtils.getString(AdfFacesMessage.TYPE_INFO, false);
          if (markersMessagesCountText.length > 0) {
            messageSeparator = AdfDhtmlCodeEditorPeer._CODEEDITOR_MESSAGE_SEPARATOR;
          }
          var infoCount = messageSeparator + severityString + ": " + messageCountObj.infoCount;
          markersMessagesCountText = markersMessagesCountText + infoCount;
        }
        var markerErrorTextNode = domDocument.createTextNode(markersMessagesCountText);
        markersErrorParentNode.appendChild(markerErrorTextNode);
        markersLabelNode.appendChild(markersLabelTextNode);
        markersLabelNode.appendChild(markersErrorParentNode);
        agent.elementsAdded(markersLabelNode);
      }
      if (!markersContainerNode) {
        markersContainerNode = domDocument.createElement("div");
        markersContainerNode.id = markerSubId;
        AdfDomUtils.addCSSClassName(markersContainerNode, laf.getStyleClass(AdfDhtmlCodeEditorPeer._CODE_EDITOR_MARKERS_CONTENT_CONTAINER_CLASS));
        contentNode.appendChild(markersContainerNode);
        var markersContentNode = domDocument.createElement("div");
        AdfDomUtils.addCSSClassName(markersContentNode, laf.getStyleClass(AdfDhtmlCodeEditorPeer._CODE_EDITOR_MARKERS_CONTENT_CLASS));
        markersContainerNode.appendChild(markersContentNode);
        var markersContentNodeSized = domDocument.createElement("div");
        markersContentNode.appendChild(markersContentNodeSized);
        agent.elementsAdded(markersContainerNode);
      }
      var markersContentNode = markersContainerNode.children[0];
      markersContentNode.appendChild(markersTableNode);
      this._resizeEditor(component);
    }
  } else {
  }
};
AdfDhtmlCodeEditorPeer.prototype.needsResizeNotify = function(component) {
  return true;
};
AdfDhtmlCodeEditorPeer.prototype.resizeNotify = function(component, oldWidth, oldHeight, newWidth, newHeight) {
  this._resizeEditor(component, newHeight);
};
AdfDhtmlCodeEditorPeer.prototype.VetoShowNoteWindow = function(component) {
  if (this._editorUpdated) {
    return true;
  }
  var componentId = component.getClientId();
  var hasMessagePopupContent = AdfMessageUtils.hasMessagePopupContent(componentId);
  if (hasMessagePopupContent) {
    var messages = AdfPage.PAGE.getMessages(componentId);
    for (var m = 0;m < messages.length;m++) {
      var message = messages[m];
      if (message.getProperty != null && typeof message.getProperty == "function") {
        var markers = message.getProperty(AdfDhtmlCodeEditorPeer._CODEEDITOR_MARKER_PROPERTY_KEY);
        if (markers != null && markers.length > 0 && message.getSummary() == null && message.getDetail() == null) {
          return true;
        }
      }
    }
  }
  return AdfDhtmlCodeEditorPeer.superclass.VetoShowNoteWindow.call(this);
};
AdfDhtmlCodeEditorPeer.prototype._createIframe = function(component) {
  var agent = AdfAgent.AGENT;
  var page = AdfPage.PAGE;
  var clientId = component.getClientId();
  var lazyloadingId = AdfRichUIPeer.CreateSubId(clientId, AdfDhtmlCodeEditorPeer._CODE_EDITOR_LAZY_LOADING_IFRAME_ID);
  var lazyloadingElement = agent.getElementById(lazyloadingId);
  var iframe = this.getDomDocument().createElement("IFRAME");
  agent.setAttribute(iframe, "frameBorder", "0");
  agent.setAttribute(iframe, "id", lazyloadingElement.id);
  agent.setAttribute(iframe, "src", page.getLazyFetchURI(component.getClientId()));
  agent.setAttribute(iframe, "style", "width: 0px; height: 0px; visibility:hidden;");
  var loadCallback = this.createCallback(this._handleLoad);
  agent.addBubbleEventListener(iframe, "load", loadCallback);
  lazyloadingElement.parentNode.replaceChild(iframe, lazyloadingElement);
  agent.elementsRemoved(lazyloadingElement);
  agent.elementsAdded(iframe);
};
AdfDhtmlCodeEditorPeer.prototype._handleLoad = function(nativeEvent) {
  var component = this.getComponent();
  AdfDhtmlCodeEditorPeer._handleLoad(component);
};
AdfDhtmlCodeEditorPeer.prototype._addMarker = function(marker, moveCursor) {
  var startLine = marker.getStartLine();
  var startColumn = marker.getStartColumn();
  if (startColumn == null) {
    startColumn = 1;
  }
  if (moveCursor) {
    this._setCursor(startLine, startColumn);
  }
  var markerInfo = new Object;
  markerInfo.marker = marker;
  markerInfo.id = this._markerInfoArray.push(markerInfo) - 1;
  AdfDhtmlCodeEditorPeer._markText(this.getComponent(), marker, markerInfo);
  return markerInfo;
};
AdfDhtmlCodeEditorPeer.prototype._addMessageIconOnGutter = function(marker, component, markerInfo) {
  var laf = AdfPage.PAGE.getLookAndFeel();
  var startLine = marker.getStartLine();
  var styleClass = this._getMessageStyleClass(marker);
  var icon = this._getMarkerImgDom(styleClass);
  var domElement = document.createElement("div");
  var span = document.createElement("span");
  span.appendChild(icon);
  domElement.appendChild(span);
  this.getEditorInstance().setGutterMarker(startLine - 1, "breakpoints", domElement);
};
AdfDhtmlCodeEditorPeer.prototype._getMessageStyleClass = function(marker) {
  var styleClass = "";
  var type = AdfFacesMessage.getType(marker.getSeverity());
  if (type == AdfFacesMessage.TYPE_ERROR) {
    styleClass = AdfDhtmlCodeEditorPeer._CODE_EDITOR_SMALL_ERROR_ICON_CLASS;
  } else {
    if (type == AdfFacesMessage.TYPE_FATAL) {
      styleClass = AdfDhtmlCodeEditorPeer._CODE_EDITOR_SMALL_FATAL_ICON_CLASS;
    } else {
      if (type == AdfFacesMessage.TYPE_WARNING) {
        styleClass = AdfDhtmlCodeEditorPeer._CODE_EDITOR_SMALL_WARNING_ICON_CLASS;
      } else {
        if (type == AdfFacesMessage.TYPE_INFO) {
          styleClass = AdfDhtmlCodeEditorPeer._CODE_EDITOR_SMALL_INFO_ICON_CLASS;
        }
      }
    }
  }
  return styleClass;
};
AdfDhtmlCodeEditorPeer.prototype._incrementMessageCountObj = function(marker, messageCountObj) {
  var type = AdfFacesMessage.getType(marker.getSeverity());
  if (type == AdfFacesMessage.TYPE_ERROR) {
    messageCountObj.errorCount++;
  } else {
    if (type == AdfFacesMessage.TYPE_FATAL) {
      messageCountObj.fatalCount++;
    } else {
      if (type == AdfFacesMessage.TYPE_WARNING) {
        messageCountObj.warningCount++;
      } else {
        if (type == AdfFacesMessage.TYPE_INFO) {
          messageCountObj.infoCount++;
        }
      }
    }
  }
  return messageCountObj;
};
AdfDhtmlCodeEditorPeer.prototype._editorBlur = function(editor) {
  if (editor) {
    editor.save();
  }
};
AdfDhtmlCodeEditorPeer.prototype._editorChange = function(editor) {
  if (editor) {
    this._editorUpdated = true;
    AdfDhtmlCodeEditorPeer._saveHiddenCursorPosition(this.getComponent(), editor);
  }
};
AdfDhtmlCodeEditorPeer.prototype.Focus = function() {
  if (this.getEditorInstance() != null) {
    this.getEditorInstance().focus();
  } else {
    var component = this.getComponent();
    AdfPage.PAGE.scheduleTimer(component, component.focus, null, 300);
  }
};
AdfDhtmlCodeEditorPeer.prototype._onBlurTimeout = function(state) {
  var page = AdfPage.PAGE;
  delete this._blurTimeout;
  var componentId = state.componentId;
  var activeElement = document.activeElement;
  if (!AdfDomUtils.isAncestorOrSelf(this.getDomElement(), activeElement)) {
    var component = page.findComponent(componentId);
    if (component) {
      this.bind(component);
      this.RunValidation(component, state.targetNode, true);
    }
  }
};
AdfDhtmlCodeEditorPeer.prototype._resizeEditor = function(component, componentContentHeight) {
  var clientId = component.getClientId();
  var agent = AdfAgent.AGENT;
  var codeEditorContainerNode = agent.getElementById(AdfRichUIPeer.CreateSubId(clientId, AdfDhtmlCodeEditorPeer._CODE_EDITOR_CONTENT_INPUT_CONTAINER_ID));
  var markerSubId = this._getMarkersSubId();
  var markersContainerNode = agent.getElementById(markerSubId);
  var markersLabelNode = agent.getElementById(this._getMarkersLabelSubId());
  var componentContentNode = AdfDhtmlEditableValuePeer.getContentNode(component, this.getDomElement());
  var toolbarNode = agent.getElementById(AdfRichUIPeer.CreateSubId(clientId, AdfDhtmlCodeEditorPeer._CODE_EDITOR_TOOLBAR_ID));
  var toolbarHeight = toolbarNode.offsetHeight;
  if (!markersContainerNode && !markersLabelNode) {
    agent.setAttribute(codeEditorContainerNode, "style", "width:auto;height:" + (componentContentHeight - toolbarHeight) + "px");
    return;
  }
  var markersContentNode = markersContainerNode.children[0];
  var maxMsgHeight = this._getMaxMsgHeight(component);
  if (markersContentNode.children == null) {
    return;
  }
  var markersLabelHeight = markersLabelNode.offsetHeight;
  var msgHeight = markersContainerNode.offsetHeight;
  if (msgHeight > maxMsgHeight) {
    msgHeight = maxMsgHeight;
  }
  agent.setAttribute(codeEditorContainerNode, "style", "width:auto;height:" + (componentContentHeight - toolbarHeight - markersLabelHeight - msgHeight) + "px;");
  agent.setAttribute(markersContainerNode, "style", "width:auto;height:" + msgHeight + "px;");
};
AdfDhtmlCodeEditorPeer.prototype._getMaxMsgHeight = function(component) {
  var agent = AdfAgent.AGENT;
  var clientId = component.getClientId();
  var laf = AdfPage.PAGE.getLookAndFeel();
  var maxMsgHeightParam = laf.getSkinProperty("af|codeEditor-tr-markers-max-height");
  var componentContentNode = AdfDhtmlEditableValuePeer.getContentNode(component, this.getDomElement());
  var componentContentHeight = componentContentNode.clientHeight;
  var toolbarNode = agent.getElementById(AdfRichUIPeer.CreateSubId(clientId, AdfDhtmlCodeEditorPeer._CODE_EDITOR_TOOLBAR_ID));
  var toolbarHeight = toolbarNode.offsetHeight;
  var markersLabelNode = agent.getElementById(this._getMarkersLabelSubId());
  var markersLabelHeight = markersLabelNode.offsetHeight;
  var maxAvailableHeight = componentContentHeight - toolbarHeight - markersLabelHeight;
  var maxMsgHeight = null;
  if (maxMsgHeightParam.indexOf("%", maxMsgHeightParam.length - 1) !== -1) {
    maxMsgHeight = maxAvailableHeight * maxMsgHeightParam.substr(0, maxMsgHeightParam.length - 1) / 100;
  } else {
    if (maxMsgHeightParam.indexOf("px", maxMsgHeightParam.length - 1) !== -1 || parseInt(maxMsgHeightParam) != NaN) {
      if (parseInt(maxMsgHeightParam) != NaN) {
        maxMsgHeight = parseInt(maxMsgHeightParam);
      } else {
        maxMsgHeight = parseInt(maxMsgHeightParam.substr(0, maxMsgHeightParam.length - 2));
      }
      maxMsgHeight = Math.min(maxAvailableHeight, maxMsgHeight);
    }
  }
  return maxMsgHeight;
};
AdfDhtmlCodeEditorPeer.prototype._getMarkersSubId = function() {
  return AdfRichUIPeer.createSubId(this.getComponent().getClientId(), "markers");
};
AdfDhtmlCodeEditorPeer.prototype._getMarkersLabelSubId = function() {
  return AdfRichUIPeer.createSubId(this.getComponent().getClientId(), "markersLabel");
};
AdfDhtmlCodeEditorPeer.prototype._getMarkerDom = function(markerInfo) {
  var agent = AdfAgent.AGENT;
  var page = AdfPage.PAGE;
  var laf = page.getLookAndFeel();
  var doc = page.getDomDocument();
  var marker = markerInfo.marker;
  var markerRoot = doc.createElement("a");
  AdfDomUtils.addCSSClassName(markerRoot, laf.getStyleClass(AdfDhtmlCodeEditorPeer._CODE_EDITOR_MARKERS_TEXT_CLASS));
  var markerString = this._getMarkerString(marker);
  markerRoot.title = markerString;
  markerRoot.href = "javascript:;";
  agent.setAttribute(markerRoot, "_markerInfoId", markerInfo.id);
  var jumpToMarkerCallback = this.createCallback(this._jumpToMarker);
  AdfAgent.AGENT.addBubbleEventListener(markerRoot, "click", jumpToMarkerCallback);
  markerRoot.appendChild(doc.createTextNode(markerString));
  return markerRoot;
};
AdfDhtmlCodeEditorPeer.prototype._getMarkerImgDom = function(styleClass) {
  var laf = AdfPage.PAGE.getLookAndFeel();
  var icon = laf.getIcon(styleClass);
  return icon;
};
AdfDhtmlCodeEditorPeer.prototype._jumpToMarker = function(event) {
  var agent = AdfAgent.AGENT;
  agent.preventDefault(event);
  var targetElement = agent.getEventTarget(event);
  var markerInfoId = targetElement.getAttribute("_markerInfoId");
  if (markerInfoId) {
    var markerInfo = this._markerInfoArray[markerInfoId];
    var location = markerInfo.markText.find();
    var line = markerInfo.marker.getStartLine();
    var column = markerInfo.marker.getStartColumn();
    if (location.from != null) {
      line = location.from["line"] + 1;
      column = location.from.ch + 1;
    }
    this._setCursor(line, column);
  }
  this.getComponent().focus();
};
AdfDhtmlCodeEditorPeer.prototype._getMarkerString = function(marker) {
  var startString = "(" + marker.getStartLine() + "," + marker.getStartColumn() + ") ";
  var endString = null;
  var rangeString = startString;
  if (endString != null) {
    rangeString = "(" + startString + "-" + endString + ")";
  }
  var type = AdfFacesMessage.getType(marker.getSeverity());
  var severityString = AdfMessageUtils.getString(type, false);
  var markerString = null;
  if (marker.getMessage() != null) {
    markerString = severityString + rangeString + ": " + marker.getMessage();
  } else {
    markerString = severityString + rangeString + ": ";
  }
  return markerString;
};
AdfDhtmlCodeEditorPeer.prototype._addCommandBinding = function(componentId, command, commandParameter) {
  AdfAssert.assertString(componentId);
  AdfAssert.assertString(command);
  if (!this._commandObservers) {
    this._commandObservers = new Array;
  }
  var length = this._commandObservers.length;
  var commandObserver = null;
  for (var i = 0;i < length;i++) {
    var observerObj = this._commandObservers[i];
    if (observerObj.componentId == componentId && observerObj.command == command) {
      observerObj.commandParameter = commandParameter;
      commandObserver = observerObj;
      break;
    }
  }
  if (commandObserver == null) {
    commandObserver = {componentId:componentId, command:command, commandParameter:commandParameter};
    this._commandObservers.push(commandObserver);
  }
  var bindComponent = AdfPage.PAGE.findComponent(componentId);
  if (!bindComponent) {
    return;
  }
  if (!bindComponent.isDescendant(this.getComponent())) {
    bindComponent.addEventListener(AdfActionEvent.ACTION_EVENT_TYPE, this._commandBindingActionListener, this);
  }
};
AdfDhtmlCodeEditorPeer.prototype._removeCommandBindings = function(component) {
  var observers = this._commandObservers;
  if (observers == undefined) {
    return;
  }
  var length = observers.length;
  var listener = this._commandBindingActionListener;
  for (var i = 0;i < length;i++) {
    var observer = observers[i];
    var boundComponent = AdfPage.PAGE.findComponent(observer.componentId);
    if (boundComponent != undefined) {
      if (!boundComponent.isDescendant(component)) {
        boundComponent.removeEventListener(AdfActionEvent.ACTION_EVENT_TYPE, listener, this);
      }
    }
  }
};
AdfDhtmlCodeEditorPeer.prototype._execCommand = function(command, parameter) {
  AdfAssert.assertString(command);
  if (command == AdfDhtmlCodeEditorPeer.COMMAND_UNDO) {
    return this._undo();
  } else {
    if (command == AdfDhtmlCodeEditorPeer.COMMAND_REDO) {
      return this._redo();
    } else {
      if (command == AdfDhtmlCodeEditorPeer.COMMAND_SEARCH_NEXT) {
        if (parameter[0] != null) {
          return this._searchNext(parameter);
        }
      } else {
        if (command == AdfDhtmlCodeEditorPeer.COMMAND_SEARCH_PREVIOUS) {
          if (parameter[0] != null) {
            return this._searchPrevious(parameter);
          }
        } else {
          if (command == AdfDhtmlCodeEditorPeer.COMMAND_REPLACE_ALL) {
            if (parameter[0] != null && parameter[1] != null) {
              return this._replaceAll(parameter);
            }
          } else {
            if (command == AdfDhtmlCodeEditorPeer.COMMAND_REPLACE_NEXT) {
              if (parameter[0] != null && parameter[1] != null) {
                return this._replaceNext(parameter);
              }
            } else {
              if (command == AdfDhtmlCodeEditorPeer.COMMAND_JUMP) {
                if (parameter != null) {
                  return this._jump(parameter);
                }
              }
            }
          }
        }
      }
    }
  }
  return null;
};
AdfDhtmlCodeEditorPeer.prototype._addContextChangeListeners = function(component) {
  var agent = AdfAgent.AGENT;
  var componentId = component.getId();
  var codeEditorContentNode = AdfDhtmlCodeEditorPeer._getCodeEditorContentNode(component);
  var editorNode = codeEditorContentNode.parentNode;
  var searchFieldNode = agent.getElementById(componentId + AdfDhtmlCodeEditorPeer._COMMAND_SEARCH_TOOLBAR_FIELD_ID);
  var jumpFieldNode = agent.getElementById(componentId + AdfDhtmlCodeEditorPeer._COMMAND_JUMP_FIELD_ID);
  this._contextChangeCallback = this.createCallback(this._handleContextChanged);
  agent.addBubbleEventListener(editorNode, "mouseup", this._contextChangeCallback);
  agent.addBubbleEventListener(editorNode, "keyup", this._contextChangeCallback);
  if (searchFieldNode) {
    agent.addBubbleEventListener(searchFieldNode, "keyup", this._contextChangeCallback);
  }
  if (jumpFieldNode) {
    agent.addBubbleEventListener(jumpFieldNode, "keyup", this._contextChangeCallback);
  }
};
AdfDhtmlCodeEditorPeer.prototype._handleContextChanged = function() {
  var component = this.getComponent();
  if (!component) {
    return;
  }
  if (!component || component.getDisabled()) {
    return;
  }
  if (!this._loaded) {
    var peer = component.getPeer();
    setTimeout(function() {
      peer._handleContextChanged();
    }, 500);
    return;
  }
  var commandObservers = this._commandObservers;
  var length = commandObservers.length;
  var oldCommandValues = this._oldCommandValues;
  var editor = this.getEditorInstance();
  var history = editor.historySize();
  var componentId = this.getComponent().getId();
  if (oldCommandValues == undefined || oldCommandValues == null) {
    oldCommandValues = {};
  }
  var cached = {};
  for (var i = 0;i < length;i++) {
    var observerObj = commandObservers[i];
    var commandKey = observerObj.command;
    var listenerComponent = AdfPage.PAGE.findComponent(observerObj.componentId);
    if (!listenerComponent) {
      continue;
    }
    var isChanged = false;
    if (cached[commandKey] === undefined) {
      if (commandKey == AdfDhtmlCodeEditorPeer.COMMAND_UNDO) {
        if (history.undo && history.undo > 0) {
          cached[commandKey] = true;
        } else {
          cached[commandKey] = false;
        }
        isChanged = true;
      } else {
        if (commandKey == AdfDhtmlCodeEditorPeer.COMMAND_REDO) {
          if (history.redo && history.redo > 0) {
            cached[commandKey] = true;
          } else {
            cached[commandKey] = false;
          }
          isChanged = true;
        } else {
          if (commandKey == AdfDhtmlCodeEditorPeer.COMMAND_SEARCH_NEXT) {
            if (observerObj.componentId == componentId + AdfDhtmlCodeEditorPeer._COMMAND_SEARCH_NEXT_BUTTON_ID) {
              var searchField = AdfPage.PAGE.findComponent(observerObj.commandParameter[0]);
              var searchFieldValue = searchField.getSubmittedValue();
              if (searchFieldValue != null && searchFieldValue.length > 0) {
                cached[commandKey] = true;
              } else {
                cached[commandKey] = false;
              }
              isChanged = true;
            }
          } else {
            if (commandKey == AdfDhtmlCodeEditorPeer.COMMAND_SEARCH_PREVIOUS) {
              if (observerObj.componentId == componentId + AdfDhtmlCodeEditorPeer._COMMAND_SEARCH_PREVIOUS_BUTTON_ID) {
                var searchField = AdfPage.PAGE.findComponent(observerObj.commandParameter[0]);
                var searchFieldValue = searchField.getSubmittedValue();
                if (searchFieldValue != null && searchFieldValue.length > 0) {
                  cached[commandKey] = true;
                } else {
                  cached[commandKey] = false;
                }
                isChanged = true;
              }
            } else {
              if (commandKey == AdfDhtmlCodeEditorPeer.COMMAND_JUMP) {
                if (observerObj.componentId == componentId + AdfDhtmlCodeEditorPeer._COMMAND_JUMP_FIELD_ID) {
                  var jumpField = AdfPage.PAGE.findComponent(observerObj.commandParameter);
                  var jumpFieldValue = jumpField.getSubmittedValue();
                  if (jumpFieldValue != null && jumpFieldValue.length > 0) {
                    cached[commandKey] = true;
                  } else {
                    cached[commandKey] = false;
                  }
                  isChanged = true;
                }
              }
            }
          }
        }
      }
    }
    if (oldCommandValues[commandKey] !== cached[commandKey] && isChanged) {
      listenerComponent.setProperty("disabled", !cached[commandKey], false, false);
    }
  }
  this._oldCommandValues = cached;
};
AdfDhtmlCodeEditorPeer.prototype._undo = function() {
  var editor = this.getEditorInstance();
  editor.undo();
  editor.save();
  var history = editor.historySize();
  return history.undo;
};
AdfDhtmlCodeEditorPeer.prototype._redo = function() {
  var editor = this.getEditorInstance();
  editor.redo();
  editor.save();
  var history = editor.historySize();
  return history.redo;
};
AdfDhtmlCodeEditorPeer.prototype._jump = function(line) {
  this._unmarkLine();
  this._markLine(line);
  this._setCursor(line, 1);
};
AdfDhtmlCodeEditorPeer.prototype._getSearchCursor = function(text, caseSensitive, wholeWords) {
  var editor = this.getEditorInstance();
  var isInitSearchCursor = false;
  if (!this._searchText) {
    isInitSearchCursor = true;
  } else {
    if (this._searchText.text != text || this._searchText.caseSensitive != caseSensitive || this._searchText.wholeWords != wholeWords) {
      isInitSearchCursor = true;
    }
  }
  if (isInitSearchCursor) {
    var caseFold = !(caseSensitive == true);
    this._searchText = {text:text, caseSensitive:caseSensitive, wholeWords:wholeWords};
    var isNonAscii = false;
    var regexp = null;
    if (wholeWords) {
      var flags = "g";
      if (caseFold) {
        flags = flags + "i";
      }
      if (text) {
        for (var i = 0;i < text.length;i++) {
          if (text.charCodeAt(i) > 128) {
            isNonAscii = true;
            break;
          }
        }
      }
      if (isNonAscii) {
        regexp = new RegExp("(^|\\s)" + "[!-//:-@[-`{-~]?" + text + "[!-//:-@[-`{-~]?" + "(?\x3d\\s|$)", flags);
      } else {
        regexp = new RegExp("\\b" + text + "\\b", flags);
      }
      this._searchCursor = editor.getSearchCursor(regexp, {"line":0, "ch":0}, caseFold);
    } else {
      this._searchCursor = editor.getSearchCursor(text, {"line":0, "ch":0}, caseFold);
    }
    this._isInitSearchCursor = true;
  } else {
    this._isInitSearchCursor = false;
  }
  return this._searchCursor;
};
AdfDhtmlCodeEditorPeer.prototype._searchNext = function(parameter) {
  var text = parameter[0];
  var caseSensitive = parameter[1];
  var wholeWords = parameter[2];
  var wrap = parameter[3];
  var laf = AdfPage.PAGE.getLookAndFeel();
  this._unmark();
  if (!text) {
    return false;
  }
  var editor = this.getEditorInstance();
  var cursor = this._getSearchCursor(text, caseSensitive, wholeWords);
  if (cursor.findNext()) {
    this._getMarked().push({markerClass:AdfDhtmlCodeEditorPeer._CODE_EDITOR_EDITOR_MARKER_SEARCH_CLASS, marker:editor.markText(cursor.from(), cursor.to(), {className:laf.getSkinProperty(AdfDhtmlCodeEditorPeer._CODE_EDITOR_EDITOR_MARKER_SEARCH_CLASS)})});
    this._setCursor(cursor.from()["line"], cursor.from().ch);
    return true;
  } else {
    if (this._isInitSearchCursor) {
      return false;
    } else {
      if (wrap) {
        while (cursor.findPrevious()) {
        }
        if (cursor.findNext()) {
          this._getMarked().push({markerClass:AdfDhtmlCodeEditorPeer._CODE_EDITOR_EDITOR_MARKER_SEARCH_CLASS, marker:editor.markText(cursor.from(), cursor.to(), {className:laf.getSkinProperty(AdfDhtmlCodeEditorPeer._CODE_EDITOR_EDITOR_MARKER_SEARCH_CLASS)})});
          this._setCursor(cursor.from()["line"], cursor.from().ch);
          return true;
        } else {
          return false;
        }
      }
    }
  }
  return false;
};
AdfDhtmlCodeEditorPeer.prototype._searchPrevious = function(parameter) {
  var text = parameter[0];
  var caseSensitive = parameter[1];
  var wholeWords = parameter[2];
  var wrap = parameter[3];
  var laf = AdfPage.PAGE.getLookAndFeel();
  this._unmark();
  if (!text) {
    return false;
  }
  var editor = this.getEditorInstance();
  var cursor = this._getSearchCursor(text, caseSensitive, wholeWords);
  if (cursor.findPrevious()) {
    this._getMarked().push({markerClass:AdfDhtmlCodeEditorPeer._CODE_EDITOR_EDITOR_MARKER_SEARCH_CLASS, marker:editor.markText(cursor.from(), cursor.to(), {className:laf.getSkinProperty(AdfDhtmlCodeEditorPeer._CODE_EDITOR_EDITOR_MARKER_SEARCH_CLASS)})});
    this._setCursor(cursor.from()["line"], cursor.from().ch);
    return true;
  } else {
    if (this._isInitSearchCursor) {
      return false;
    } else {
      if (wrap) {
        while (cursor.findNext()) {
        }
        if (cursor.findPrevious()) {
          this._getMarked().push({markerClass:AdfDhtmlCodeEditorPeer._CODE_EDITOR_EDITOR_MARKER_SEARCH_CLASS, marker:editor.markText(cursor.from(), cursor.to(), {className:laf.getSkinProperty(AdfDhtmlCodeEditorPeer._CODE_EDITOR_EDITOR_MARKER_SEARCH_CLASS)})});
          this._setCursor(cursor.from()["line"], cursor.from().ch);
          return true;
        } else {
          return false;
        }
      }
    }
  }
  return false;
};
AdfDhtmlCodeEditorPeer.prototype._replaceAll = function(parameter) {
  var text = parameter[0];
  var replace = parameter[1];
  var caseSensitive = parameter[2];
  var wholeWords = parameter[3];
  var laf = AdfPage.PAGE.getLookAndFeel();
  var editor = this.getEditorInstance();
  this._unmark();
  if (!text) {
    return false;
  }
  this._getSearchCursor(null, caseSensitive, wholeWords);
  var cursor = this._getSearchCursor(text, caseSensitive);
  var replaceRanges = new Array;
  var isReplaced = false;
  while (cursor.findNext()) {
    replaceRanges.push({from:cursor.from(), to:cursor.to()});
    isReplaced = true;
  }
  for (var i = 0;i < replaceRanges.length;i++) {
    editor.replaceRange(replace, replaceRanges[i].from, replaceRanges[i].to);
  }
  editor.save();
  return isReplaced;
};
AdfDhtmlCodeEditorPeer.prototype._replaceNext = function(parameter) {
  var text = parameter[0];
  var replace = parameter[1];
  var caseSensitive = parameter[2];
  var wholeWords = parameter[3];
  var wrap = parameter[4];
  var laf = AdfPage.PAGE.getLookAndFeel();
  var isReplaced = false;
  var isMarked = false;
  if (!text) {
    return false;
  }
  var editor = this.getEditorInstance();
  var cursor = this._getSearchCursor(text, caseSensitive, wholeWords);
  for (var i = 0;i < this._getMarked().length;i++) {
    if (this._getMarked()[i].markerClass == AdfDhtmlCodeEditorPeer._CODE_EDITOR_EDITOR_MARKER_SEARCH_CLASS) {
      var markerPos = this._getMarked()[i].marker.find();
      if (markerPos.from.ch == cursor["pos"].from.ch && markerPos.from["line"] == cursor["pos"].from["line"] && markerPos.to.ch == cursor["pos"].to.ch && markerPos.to["line"] == cursor["pos"].to["line"]) {
        isMarked = true;
        break;
      }
    }
  }
  if (!isMarked) {
    if (cursor.findNext()) {
      isMarked = true;
    }
  }
  if (isMarked) {
    editor.replaceRange(replace, cursor.from(), cursor.to());
    this._unmark();
    if (cursor.findNext()) {
      this._getMarked().push({markerClass:AdfDhtmlCodeEditorPeer._CODE_EDITOR_EDITOR_MARKER_SEARCH_CLASS, marker:editor.markText(cursor.from(), cursor.to(), {className:laf.getSkinProperty(AdfDhtmlCodeEditorPeer._CODE_EDITOR_EDITOR_MARKER_SEARCH_CLASS)})});
      this._setCursor(cursor.from()["line"], cursor.from().ch);
    }
    isReplaced = true;
  } else {
    if (this._isInitSearchCursor) {
      isReplaced = false;
    } else {
      if (wrap) {
        while (cursor.findPrevious()) {
        }
        if (cursor.findNext()) {
          editor.replaceRange(replace, cursor.from(), cursor.to());
          this._unmark();
          if (cursor.findNext()) {
            this._getMarked().push({markerClass:AdfDhtmlCodeEditorPeer._CODE_EDITOR_EDITOR_MARKER_SEARCH_CLASS, marker:editor.markText(cursor.from(), cursor.to(), {className:laf.getSkinProperty(AdfDhtmlCodeEditorPeer._CODE_EDITOR_EDITOR_MARKER_SEARCH_CLASS)})});
            this._setCursor(cursor.from()["line"], cursor.from().ch);
          }
          isReplaced = true;
        } else {
          isReplaced = false;
        }
      }
    }
  }
  editor.save();
  return isReplaced;
};
AdfDhtmlCodeEditorPeer.prototype._setCursor = function(line, column) {
  AdfDhtmlCodeEditorPeer._setCursor(this.getComponent(), line, column);
};
AdfDhtmlCodeEditorPeer.prototype._unmark = function() {
  for (var i = 0;i < this._getMarked().length;i++) {
    this._getMarked()[i].marker.clear();
  }
  this._getMarked().length = 0;
};
AdfDhtmlCodeEditorPeer.prototype._unmarkLine = function() {
  if (this._markedLine) {
    this._markedLine.clear();
  }
};
AdfDhtmlCodeEditorPeer.prototype._getMarked = function() {
  if (this._marked == null) {
    this._marked = [];
  }
  return this._marked;
};
AdfDhtmlCodeEditorPeer.prototype._markLine = function(line) {
  var editor = this.getEditorInstance();
  this._markedLine = editor.markText({"line":line - 1, ch:0}, {"line":line - 1, ch:9999}, {className:AdfPage.PAGE.getLookAndFeel().getSkinProperty(AdfDhtmlCodeEditorPeer._CODE_EDITOR_EDITOR_MARKER_LINE_CLASS)});
};
AdfDhtmlCodeEditorPeer.prototype._addCSSResource = function(source, refresh) {
  var agent = AdfAgent.AGENT;
  var document = agent.getDomDocument();
  if (!this._loadedCss) {
    this._loadedCss = new Array;
  }
  if (this._loadedCss[source] == true) {
    return;
  } else {
    this._loadedCss[source] = false;
  }
  var head = AdfDomUtils.getFirstDescendentElement(document.documentElement, "HEAD");
  var links = head.getElementsByTagName("LINK");
  var firstLink = null;
  for (var i = 0;i < links.length;i++) {
    var link = links[i];
    if (link.getAttribute("href") != source) {
      firstLink = link;
      break;
    }
  }
  for (var i = 0;i < links.length;i++) {
    var link = links[i];
    if (link.getAttribute("href") == source) {
      if (refresh) {
        link.parentNode.removeChild(link);
        break;
      } else {
        return;
      }
    }
  }
  if (agent.getPlatform() == AdfAgent.IE_PLATFORM && agent.getVersion() < 11) {
    document.createStyleSheet(source);
  } else {
    var link = document.createElement("link");
    link.setAttribute("type", "text/css");
    link.setAttribute("rel", "stylesheet");
    link.setAttribute("href", source);
    if (firstLink) {
      head.insertBefore(link, firstLink);
    } else {
      head.appendChild(link);
    }
  }
};
AdfDhtmlCodeEditorPeer._retrieveCssContent = function(css, disabled) {
  if (!css || css.length === 0) {
    return "";
  }
  var cssTextContent = null;
  var disabledStyleClass = AdfRichUIPeer.DISABLED_STYLECLASS;
  for (var i = 0, j = css.length;i < j;i++) {
    var index = css[i].indexOf(disabledStyleClass);
    if (disabled && index > -1) {
      cssTextContent = css[i];
      break;
    } else {
      if (!disabled && index === -1) {
        cssTextContent = css[i];
        break;
      }
    }
  }
  return cssTextContent === null ? "" : AdfDhtmlCodeEditorPeer._getCSSText(cssTextContent);
};
AdfDhtmlCodeEditorPeer._initCodeMirror = function(component, domElement) {
  var agent = AdfAgent.AGENT;
  var clientId = component.getClientId();
  var peer = component.getPeer();
  var laf = AdfPage.PAGE.getLookAndFeel();
  var disabled = component.getDisabled();
  var searchAdfSkinOnly = true;
  for (var i in AdfDhtmlCodeEditorPeer._CSS_MAP) {
    var adfSelector = "." + laf.getSkinProperty(i);
    var codeMirrorSelector = AdfDhtmlCodeEditorPeer._CSS_MAP[i];
    var css = AdfDhtmlCodeEditorPeer._getCSS("(^|\\s|,)\\" + adfSelector + "([{|,|\\.|\\s]|$)", searchAdfSkinOnly);
    if (css != null) {
      AdfDhtmlCodeEditorPeer._addCSSStyle(component, codeMirrorSelector, AdfDhtmlCodeEditorPeer._retrieveCssContent(css, disabled));
    }
  }
  if (disabled) {
    var disabledSelector = "." + laf.getSkinProperty(AdfDhtmlCodeEditorPeer._CODE_EDITOR_EDITOR_DISABLED_TEXT_CLASS);
    var disabledCss = AdfDhtmlCodeEditorPeer._getCSS("(^|\\s|,)\\" + disabledSelector + "([{|,|\\.|\\s]|$)", searchAdfSkinOnly);
    AdfDhtmlCodeEditorPeer._replaceCSS(component, "^\\.cm-s-default span\\.cm", AdfDhtmlCodeEditorPeer._retrieveCssContent(disabledCss, disabled));
  }
  var modes = {};
  modes["java"] = "text/x-java";
  modes["text"] = "text/plain";
  var language = component.getLanguage();
  var readOnly = false;
  if (component.getDisabled() || component.getReadOnly()) {
    readOnly = true;
  }
  var modeString = modes[language];
  if (!modeString) {
    modeString = language;
  }
  var hintLanguage;
  if (modeString == AdfDhtmlCodeEditorPeer._LANGUAGE_JAVASCRIPT) {
    hintLanguage = CodeMirror.hint.javascript;
  } else {
    if (modeString == AdfDhtmlCodeEditorPeer._LANGUAGE_XML) {
      hintLanguage = CodeMirror.hint.xml;
    } else {
      if (modeString == AdfDhtmlCodeEditorPeer._LANGUAGE_GROOVY) {
        hintLanguage = CodeMirror.hint.javascript;
      }
    }
  }
  var useLineNumbers = true;
  if (component.getLineNumbers() == "no") {
    useLineNumbers = false;
  }
  var codeEditorContentNode = AdfDhtmlCodeEditorPeer._getCodeEditorContentNode(component);
  var isCodeFoldEnabled = false;
  var foldFunction;
  var result;
  if (component.getCodeFold() == "enabled") {
    foldFunction = function(cm) {
      cm.foldCode(cm.getCursor());
    };
    isCodeFoldEnabled = true;
  }
  peer._editor = CodeMirror.fromTextArea(codeEditorContentNode, {"gutter":true, "lineNumbers":useLineNumbers, "matchBrackets":true, "mode":modeString, "readOnly":readOnly, "theme":"default", "inputStyle":"contenteditable", "leaveSubmitMethodAlone":true, "foldGutter":isCodeFoldEnabled, "gutters":["CodeMirror-linenumbers", "breakpoints", "CodeMirror-foldgutter"], "extraKeys":{"Ctrl-Q":foldFunction, "Ctrl-Space":function(cm) {
    CodeMirror.showHint(cm, function(cm) {
      return peer.getHintsWrapper(cm, peer);
    });
  }}});
  if (peer._editor) {
    peer._editor.on("blur", peer.createCallback(peer._editorBlur));
    peer._editor.on("change", peer.createCallback(peer._editorChange));
  }
  var hiddenCursorPosition = AdfDhtmlCodeEditorPeer._getHiddenCursorPosition(component);
  if (hiddenCursorPosition != null && !component.getDisabled()) {
    AdfDhtmlCodeEditorPeer._restoreCursorPosition(component, hiddenCursorPosition);
  }
  var toolbarNode = agent.getElementById(AdfRichUIPeer.CreateSubId(clientId, AdfDhtmlCodeEditorPeer._CODE_EDITOR_TOOLBAR_ID));
  toolbarNode.style.visibility = "visible";
  var codeEditorContainerNode = agent.getElementById(AdfRichUIPeer.CreateSubId(clientId, AdfDhtmlCodeEditorPeer._CODE_EDITOR_CONTENT_INPUT_CONTAINER_ID));
  var codeMirrorCodeNode = AdfDhtmlCodeEditorPeer._getCodeMirrorCodeNode(codeEditorContainerNode);
  if (codeMirrorCodeNode) {
    var label = component.getLabel();
    if (label) {
      codeMirrorCodeNode.setAttribute("aria-label", label);
    } else {
      codeMirrorCodeNode.setAttribute("aria-label", "");
    }
    codeMirrorCodeNode.setAttribute("aria-multiline", "true");
    codeMirrorCodeNode.setAttribute("role", "textbox");
  }
  codeEditorContainerNode.style.visibility = "visible";
  AdfDhtmlCodeEditorPeer._setLoaded(component);
};
AdfDhtmlCodeEditorPeer._addCSSStyle = function(component, selector, cssText) {
  var peer = component.getPeer();
  var agent = AdfAgent.AGENT;
  var document = AdfPage.PAGE.getDomDocument();
  if (peer._styleElement == null) {
    peer._styleElement = document.createElement("style");
    peer._styleElement.type = "text/css";
    document.getElementsByTagName("head")[0].appendChild(peer._styleElement);
  }
  var styleElement = peer._styleElement;
  if (styleElement.styleSheet) {
    if (agent.getPlatform() == AdfAgent.IE_PLATFORM) {
      if (cssText != "") {
        styleElement.styleSheet.addRule(selector, cssText);
      }
    } else {
      styleElement.styleSheet.addRule(selector, cssText);
    }
  } else {
    styleElement.appendChild(document.createTextNode(selector + " {" + cssText + "}"));
  }
};
AdfDhtmlCodeEditorPeer._checkCSSResourceLoaded = function(component, source) {
  var agent = AdfAgent.AGENT;
  var peer = component.getPeer();
  var document = AdfPage.PAGE.getDomDocument();
  for (var i = 0;i < document.styleSheets.length;i++) {
    var styleSheet = document.styleSheets[i];
    if (AdfDhtmlCodeEditorPeer._isCodeMirrorStyleSheet(styleSheet, source)) {
      try {
        if (agent.getPlatform() == AdfAgent.IE_PLATFORM) {
          if (styleSheet.rules) {
            peer._loadedCss[source] = true;
            break;
          }
        } else {
          if (styleSheet.cssRules) {
            peer._loadedCss[source] = true;
            break;
          }
        }
      } catch (e) {
      }
    }
  }
};
AdfDhtmlCodeEditorPeer._getCodeEditorContentNode = function(component) {
  var agent = AdfAgent.AGENT;
  var clientId = component.getClientId();
  var codeEditorContentId = AdfRichUIPeer.CreateSubId(clientId, AdfDhtmlCodeEditorPeer._CODE_EDITOR_CONTENT_INPUT_ID);
  return agent.getElementById(codeEditorContentId);
};
AdfDhtmlCodeEditorPeer._getCSS = function(regex, isAdfStyleSheet) {
  var agent = AdfAgent.AGENT;
  var document = AdfPage.PAGE.getDomDocument();
  var regexObj = new RegExp(regex);
  var cssTextArray = new Array;
  for (var i = 0;i < document.styleSheets.length;i++) {
    var styleSheet = document.styleSheets[i];
    if (!AdfDhtmlCodeEditorPeer._isRelevantStyleSheet(styleSheet, isAdfStyleSheet)) {
      continue;
    }
    if (agent.getPlatform() == AdfAgent.IE_PLATFORM) {
      var ruleList = styleSheet.rules;
      if (ruleList != null) {
        for (var j = 0;j < ruleList.length;j++) {
          var rule = ruleList.item(j);
          if (regexObj.test(rule.selectorText)) {
            cssTextArray.push(rule.selectorText + " " + "{" + rule.style.cssText + "}");
          }
        }
      }
    } else {
      var ruleList = styleSheet.cssRules;
      if (ruleList != null) {
        for (var j = 0;j < ruleList.length;j++) {
          var rule = ruleList[j];
          var selector = AdfDhtmlCodeEditorPeer._getCSSSelector(rule.cssText);
          if (selector != null && regexObj.test(selector)) {
            cssTextArray.push(rule.cssText);
          }
        }
      }
    }
  }
  return cssTextArray;
};
AdfDhtmlCodeEditorPeer._getCSSSelector = function(css) {
  var selector = null;
  if (css != null) {
    selector = css.substring(0, css.indexOf("{") - 1);
    selector = selector.replace(/^\s+|\s+$/g, "");
  }
  return selector;
};
AdfDhtmlCodeEditorPeer._getCSSText = function(css) {
  var text = css.substring(css.indexOf("{") + 1, css.indexOf("}"));
  text = text.replace(/^\s+|\s+$/g, "");
  return text;
};
AdfDhtmlCodeEditorPeer._getHiddenCursorPosition = function(component) {
  var agent = AdfAgent.AGENT;
  var scrollPositionId = AdfRichUIPeer.CreateSubId(component.getClientId(), AdfDhtmlCodeEditorPeer._CODE_EDITOR_HIDDEN_SCROLLPOS_ID);
  var scrollPosition = agent.getElementById(scrollPositionId);
  var hiddenPositionValue = agent.getAttribute(scrollPosition, "value");
  if (hiddenPositionValue != null) {
    var hiddenPositionArray = hiddenPositionValue.split(",");
    if (hiddenPositionArray != null && hiddenPositionArray.length == 5) {
      return {start:{"line":Number(hiddenPositionArray[0]), ch:Number(hiddenPositionArray[1])}, end:{"line":Number(hiddenPositionArray[2]), ch:Number(hiddenPositionArray[3])}, scrollTop:Number(hiddenPositionArray[4])};
    }
  }
  return null;
};
AdfDhtmlCodeEditorPeer._isCodeMirrorStyleSheet = function(styleSheet, styleSheetSource) {
  if (!styleSheetSource) {
    return styleSheet.href && styleSheet.href.indexOf(AdfDhtmlCodeEditorPeer._CODE_MIRROR_CSS_PATH_PREFIX) != -1;
  }
  return styleSheet.href && styleSheet.href.match(styleSheetSource + "$") == styleSheetSource;
};
AdfDhtmlCodeEditorPeer._isAdfStyleSheet = function(styleSheet) {
  var styleSheetNode = styleSheet.ownerNode;
  return styleSheetNode.hasAttribute("data-afr-stylesheet") && !styleSheetNode.hasAttribute("afrres");
};
AdfDhtmlCodeEditorPeer._isRelevantStyleSheet = function(styleSheet, isAdfStyleSheet) {
  if (isAdfStyleSheet) {
    return AdfDhtmlCodeEditorPeer._isAdfStyleSheet(styleSheet);
  }
  return AdfDhtmlCodeEditorPeer._isCodeMirrorStyleSheet(styleSheet);
};
AdfDhtmlCodeEditorPeer._restoreCursorPosition = function(component, hiddenCursorPosition) {
  var peer = component.getPeer();
  if (hiddenCursorPosition.start["line"] == hiddenCursorPosition.end["line"] && hiddenCursorPosition.start.ch == hiddenCursorPosition.end.ch) {
    peer._editor.setCursor(Number(hiddenCursorPosition.start["line"]), Number(hiddenCursorPosition.start.ch));
  } else {
    peer._editor.setSelection(hiddenCursorPosition.start, hiddenCursorPosition.end);
  }
};
AdfDhtmlCodeEditorPeer._handleLoad = function(component) {
  var agent = AdfAgent.AGENT;
  var clientId = component.getClientId();
  var peer = component.getPeer();
  var lazyloadingId = AdfRichUIPeer.CreateSubId(clientId, AdfDhtmlCodeEditorPeer._CODE_EDITOR_LAZY_LOADING_IFRAME_ID);
  var lazyloadingValueId = AdfRichUIPeer.CreateSubId(clientId, AdfDhtmlCodeEditorPeer._CODE_EDITOR_LAZY_LOADING_VALUE_ID);
  var lazyloadingElement = agent.getElementById(lazyloadingId);
  var frameDocument = lazyloadingElement.contentWindow || lazyloadingElement.contentDocument;
  if (frameDocument.document) {
    frameDocument = frameDocument.document;
  }
  var lazyloadingValueElement = frameDocument.getElementById(lazyloadingValueId);
  var value = lazyloadingValueElement.value;
  if (value != null) {
    var editor = peer.getEditorInstance();
    if (editor != null) {
      var hiddenCursorPosition = AdfDhtmlCodeEditorPeer._getHiddenCursorPosition(component);
      editor.setValue(value);
      editor.save();
      if (hiddenCursorPosition != null) {
        AdfDhtmlCodeEditorPeer._restoreCursorPosition(component, hiddenCursorPosition);
      }
    } else {
      setTimeout(function() {
        AdfDhtmlCodeEditorPeer._handleLoad(component);
      }, 1E3);
    }
  }
};
AdfDhtmlCodeEditorPeer._isInCodeContainer = function(component, componentEvent) {
  var agent = AdfAgent.AGENT;
  var clientId = component.getClientId();
  var codeContentContainerId = AdfRichUIPeer.CreateSubId(clientId, AdfDhtmlCodeEditorPeer._CODE_EDITOR_CONTENT_INPUT_CONTAINER_ID);
  var eventTarget = componentEvent.getNativeEventTarget();
  var isInCodeContainer = false;
  var eventTargetId = agent.getAttribute(eventTarget, "id");
  if (eventTargetId == codeContentContainerId) {
    isInCodeContainer = true;
  }
  if (!isInCodeContainer) {
    var targetParentNode = eventTarget.parentNode;
    while (targetParentNode != null && targetParentNode.parentNode != null) {
      var targetParentNodeId = agent.getAttribute(targetParentNode, "id");
      if (targetParentNodeId == codeContentContainerId) {
        isInCodeContainer = true;
        break;
      } else {
        targetParentNode = targetParentNode.parentNode;
      }
    }
  }
  return isInCodeContainer;
};
AdfDhtmlCodeEditorPeer._markText = function(component, marker, markerInfo) {
  var laf = AdfPage.PAGE.getLookAndFeel();
  var peer = component.getPeer();
  var editor = peer.getEditorInstance();
  if (editor != null) {
    var startLine = marker.getStartLine();
    var startColumn = marker.getStartColumn();
    var endLine = marker.getEndLine();
    var endColumn = marker.getEndColumn();
    if (startColumn == null) {
      startColumn = 1;
    }
    if (endColumn == null) {
      var endLineInfo = editor.lineInfo(endLine - 1);
      var endLineText = endLineInfo["text"];
      endColumn = endLineText.length + 1;
    }
    var type = AdfFacesMessage.getType(marker.getSeverity());
    var markerSelector = null;
    if (type == AdfFacesMessage.TYPE_ERROR) {
      markerSelector = laf.getSkinProperty(AdfDhtmlCodeEditorPeer._CODE_EDITOR_EDITOR_MARKER_ERROR_CLASS);
    } else {
      if (type == AdfFacesMessage.TYPE_FATAL) {
        markerSelector = laf.getSkinProperty(AdfDhtmlCodeEditorPeer._CODE_EDITOR_EDITOR_MARKER_FATAL_CLASS);
      } else {
        if (type == AdfFacesMessage.TYPE_WARNING) {
          markerSelector = laf.getSkinProperty(AdfDhtmlCodeEditorPeer._CODE_EDITOR_EDITOR_MARKER_WARNING_CLASS);
        } else {
          if (type == AdfFacesMessage.TYPE_INFO) {
            markerSelector = laf.getSkinProperty(AdfDhtmlCodeEditorPeer._CODE_EDITOR_EDITOR_MARKER_INFO_CLASS);
          }
        }
      }
    }
    markerInfo.markText = editor.markText({"line":startLine - 1, ch:startColumn - 1}, {"line":endLine - 1, ch:endColumn - 1}, {className:markerSelector});
  } else {
    setTimeout(function() {
      AdfDhtmlCodeEditorPeer._markText(component, marker, markerInfo);
    }, 1E3);
  }
};
AdfDhtmlCodeEditorPeer._removeCSSStyle = function(selector) {
  var agent = AdfAgent.AGENT;
  var document = AdfPage.PAGE.getDomDocument();
  for (var i = 0;i < document.styleSheets.length;i++) {
    var styleSheet = document.styleSheets[i];
    if (!AdfDhtmlCodeEditorPeer._isCodeMirrorStyleSheet(styleSheet)) {
      return;
    }
    if (agent.getPlatform() == AdfAgent.IE_PLATFORM) {
      var ruleList = styleSheet.rules;
      for (var j = 0;j < ruleList.length;j++) {
        if (ruleList[j].selectorText == selector) {
          styleSheet.removeRule[j];
          break;
        }
      }
    } else {
      var ruleList = styleSheet.cssRules;
      for (var j = 0;j < ruleList.length;j++) {
        if (AdfDhtmlCodeEditorPeer._getCSSSelector(ruleList[j].cssText) == selector) {
          styleSheet.deleteRule[j];
          break;
        }
      }
    }
  }
};
AdfDhtmlCodeEditorPeer._replaceCSS = function(component, regex, cssText) {
  var cssList = AdfDhtmlCodeEditorPeer._getCSS(regex, false);
  for (var i = 0;i < cssList.length;i++) {
    var selector = AdfDhtmlCodeEditorPeer._getCSSSelector(cssList[i]);
    AdfDhtmlCodeEditorPeer._removeCSSStyle(selector);
    AdfDhtmlCodeEditorPeer._addCSSStyle(component, selector, cssText);
  }
};
AdfDhtmlCodeEditorPeer._setCursor = function(component, line, column) {
  var peer = component.getPeer();
  var editor = peer.getEditorInstance();
  if (editor != null) {
    if (line && line > 0) {
      line = line - 1;
    }
    if (column && column > 0) {
      column = column - 1;
    }
    var currentCursor = editor.getCursor();
    if (currentCursor["line"] == line && currentCursor.ch == column) {
      if (line > 0) {
        editor.setCursor({"line":line - 1, ch:column});
      } else {
        editor.setCursor({"line":line + 1, ch:column});
      }
    }
    editor.setCursor({"line":line, ch:column});
  } else {
    setTimeout(function() {
      AdfDhtmlCodeEditorPeer._setCursor(component, line, column);
    }, 1E3);
  }
};
AdfDhtmlCodeEditorPeer._saveHiddenCursorPosition = function(component, editor) {
  var agent = AdfAgent.AGENT;
  if (!component) {
    return;
  }
  var clientId = component.getClientId();
  var scrollPositionId = AdfRichUIPeer.CreateSubId(clientId, AdfDhtmlCodeEditorPeer._CODE_EDITOR_HIDDEN_SCROLLPOS_ID);
  var scrollPosition = agent.getElementById(scrollPositionId);
  var startCursor = editor.getCursor(true)["line"] + "," + editor.getCursor(true).ch;
  var endCursor = editor.getCursor(false)["line"] + "," + editor.getCursor(false).ch;
  var scrollTop = editor.getScrollerElement().scrollTop;
  agent.setAttribute(scrollPosition, "value", startCursor + "," + endCursor + "," + scrollTop);
};
AdfDhtmlCodeEditorPeer._setLoaded = function(component, refresh) {
  var agent = AdfAgent.AGENT;
  var clientId = component.getClientId();
  var peer = component.getPeer();
  var codeEditorContainerNode = agent.getElementById(AdfRichUIPeer.CreateSubId(clientId, AdfDhtmlCodeEditorPeer._CODE_EDITOR_CONTENT_INPUT_CONTAINER_ID));
  if (codeEditorContainerNode.clientWidth == 0) {
    setTimeout(function() {
      AdfDhtmlCodeEditorPeer._setLoaded(component, true);
    }, 500);
  } else {
    setTimeout(function() {
      if (agent.getPlatform() == AdfAgent.IE_PLATFORM || refresh) {
        peer._editor.refresh();
      }
      peer._handleContextChanged();
      peer._loaded = true;
      AdfPage.PAGE.unregisterLoadingComponent(peer.getComponent());
    }, 1E3);
  }
};
AdfDhtmlCodeEditorPeer._showPopup = function(component, popupId) {
  AdfPage.PAGE.clearMessages(component.getClientId());
  var popup = AdfPage.PAGE.findComponent(popupId);
  var hints = {};
  hints[AdfRichPopup.HINT_LAUNCH_ID] = component.getClientId();
  popup.show(hints);
};
AdfDhtmlCodeEditorPeer._waitForCSSResourcesLoad = function(component, domElement) {
  var peer = component.getPeer();
  if (!peer) {
    return;
  }
  var isLoaded = true;
  for (var i in peer._loadedCss) {
    AdfDhtmlCodeEditorPeer._checkCSSResourceLoaded(component, i);
    if (peer._loadedCss[i] == false) {
      isLoaded = false;
    }
  }
  if (!isLoaded) {
    setTimeout(function() {
      AdfDhtmlCodeEditorPeer._waitForCSSResourcesLoad(component, domElement);
    }, 2E3);
  } else {
    AdfDhtmlCodeEditorPeer._initCodeMirror(component, domElement);
  }
};
AdfDhtmlCodeEditorPeer._getCodeMirrorCodeNode = function(codeEditorContainerNode) {
  if (codeEditorContainerNode) {
    var codeMirrorCodeElements = codeEditorContainerNode.getElementsByClassName("CodeMirror-code");
    if (codeMirrorCodeElements) {
      var codeMirrorCodeSection = codeMirrorCodeElements[0];
      return codeMirrorCodeSection;
    }
  }
  return null;
};
