Exemplo n.º 1
0
 private void addToTab(
     String id,
     String image,
     String text,
     String link,
     HashMap<String, Element> map,
     HashMap<String, String> mapTexts,
     ArrayList<String> texts,
     Element nav) {
   // Find position
   texts.add(text);
   Collections.sort(texts);
   int index = texts.indexOf(text);
   // Create element
   Element e = createElement(image, text, link);
   // Insert element
   if (index >= nav.getChildCount()) {
     nav.appendChild(e);
   } else {
     Node after = nav.getChild(index);
     nav.insertBefore(e, after);
   }
   // Add to map
   mapTexts.put(id, text);
   map.put(id, e);
 }
Exemplo n.º 2
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);
    }
  }
Exemplo n.º 3
0
 /**
  * Do additional content sync between <code>original</code> element and its <code>copy</code> if
  * needed.
  *
  * @since 7.2
  * @param original original element
  * @param copy copy of original element
  */
 private void syncContent(Element original, Element copy) {
   for (int i = 0; i < original.getChildCount(); i++) {
     Node child = original.getChild(i);
     if (child instanceof Element) {
       syncContent((Element) child, (Element) copy.getChild(i));
     }
   }
   doSyncContent(original, copy);
 }
Exemplo n.º 4
0
  private Element findAppNameElement(Element parent) {
    for (int i = 0; i < parent.getChildCount(); i++) {
      Node childNode = parent.getChild(i);

      if (Element.is(childNode)) {
        Element child = Element.as(childNode);
        if (child.getAttribute("name").equalsIgnoreCase(appearance.download())) { // $NON-NLS-1$
          return child;
        }
      }
    }
    return null;
  }
  @Test
  public void html() {
    // Given
    FlexTable t = new FlexTable();

    // When
    t.setHTML(1, 1, "<h1>test</h1>");

    // Then
    assertThat(t.getHTML(1, 1)).isEqualTo("<h1>test</h1>");
    Element e = t.getCellFormatter().getElement(1, 1);
    assertThat(e.getChildCount()).isEqualTo(1);
    HeadingElement h1 = e.getChild(0).cast();
    assertThat(h1.getTagName()).isEqualTo("H1");
    assertThat(h1.getInnerText()).isEqualTo("test");
  }
Exemplo n.º 6
0
 protected static void hideBlackMask(Element mainPageElem) {
   if (mainPageElem == null) {
     return;
   }
   Element menuElem = mainPageElem.getParentElement();
   if (menuElem == null) {
     return;
   }
   for (int it = 0; it < menuElem.getChildCount(); it++) {
     Element menuChildElem = menuElem.getChild(it).cast();
     String color = menuChildElem.getStyle().getBackgroundColor();
     if ("black".equalsIgnoreCase(color)) {
       menuChildElem.getStyle().setBackgroundColor("transparent");
     }
   }
 }
Exemplo n.º 7
0
  /**
   * Returns a mutable map which is not bound to the TaggedEntity; any changes made in the map will
   * not be reflected in the tagName.
   *
   * @return mutable unbound map
   */
  public HashMap<String, String> getAttributes() {
    NodeList<Element> elements = rootElement.getElementsByTagName("attributes");
    assert elements.getLength() > 0;
    Element attributesNode = elements.getItem(0);

    HashMap<String, String> rvalue = new HashMap<>();
    for (int i = 0; i < attributesNode.getChildCount(); i++) {
      final Node node = attributesNode.getChild(i);
      JsArray<Node> attributeList = getAttributes((Element) node);
      String name = attributeList.get(0).getNodeValue();
      String value = attributeList.get(1).getNodeValue();
      rvalue.put(name, value);
    }

    return rvalue;
  }
Exemplo n.º 8
0
  public void moveTab(int index, int delta) {
    // do no work if we haven't been asked to move anywhere
    if (delta == 0) return;

    Element tabHost = getTabBarElement();

    // ignore moving left if the tab is already the leftmost tab (same for
    // right)
    int dest = index + delta;
    if (dest < 0 || dest >= tabHost.getChildCount()) return;

    // rearrange the DOM
    Element tab = Element.as(tabHost.getChild(index));
    Element prev = Element.as(tabHost.getChild(dest));
    tabHost.removeChild(tab);
    if (delta > 0) tabHost.insertAfter(tab, prev);
    else tabHost.insertBefore(tab, prev);

    // fire the tab reorder event (this syncs the editor state)
    TabReorderEvent event = new TabReorderEvent(index, dest);
    fireEvent(event);
  }