Пример #1
0
  private void manageChunkIcons(AceEditorNative editor) {
    Element container = editor.getContainer();
    if (container == null) return;

    Element[] icons =
        DomUtils.getElementsByClassName(container, ThemeStyles.INSTANCE.inlineChunkToolbar());

    for (Element icon : icons) icon.removeFromParent();

    if (!uiPrefs_.showInlineToolbarForRCodeChunks().getValue()) return;

    if (!shouldDisplayIcons(editor)) return;

    Element[] chunkStarts = DomUtils.getElementsByClassName("rstudio_chunk_start ace_start");

    for (int i = 0; i < chunkStarts.length; i++) {
      Element el = chunkStarts[i];

      if (isPseudoMarker(el)) continue;

      if (!isRunnableChunk(el, editor)) continue;

      if (!DomUtils.isVisibleVert(container, el)) continue;

      if (el.getChildCount() > 0) el.removeAllChildren();

      addToolbar(el, isSetupChunk(el, editor), editor);
    }
  }
Пример #2
0
  public void setAttributes(HashMap<String, String> map) {
    NodeList<Element> elements = rootElement.getElementsByTagName("attributes");
    assert elements.getLength() > 0;
    Element attributesNode = elements.getItem(0);
    attributesNode.removeAllChildren();

    Node last = null;

    for (String key : map.keySet()) {
      Element element = JSFunctions.createTextElement("attribute", "");
      element.setAttribute("name", key);
      element.setAttribute("value", map.get(key));
      last = attributesNode.insertAfter(element, last);
    }
  }