Java 类com.google.gwt.dom.client.AnchorElement 实例源码

项目:putnami-web-toolkit    文件:BreadcrumbLink.java   
@Override
public void redraw() {
    StyleUtils.toggleStyle(this, LinkStyle.ACTIVE, this.active);
    Element elem = getElement();
    elem.removeAllChildren();
    if (!active) {
        elem = Document.get().createAnchorElement();
        getElement().appendChild(elem);
        if (this.link != null) {
            AnchorElement.as(elem).setHref(this.link);
        }
    }

    if (this.label != null) {
        elem.setInnerHTML(this.label);
    }
    if (this.iconType != null) {
        Icon icon = new Icon();
        icon.setType(this.iconType);
        elem.insertFirst(icon.getElement());
    }
}
项目:gwt-history    文件:HistoryTest.java   
@DoNotRunWith(Platform.HtmlUnitUnknown)
public void testClickLink() {
  AnchorElement anchorElement = Document.get().createAnchorElement();
  anchorElement.setHref("#href1");
  Document.get().getBody().appendChild(anchorElement);

  try {
    History.newItem("something_as_base");

    addHistoryListenerImpl(
        event -> {
          assertEquals("href1", event.getValue());
          finishTest();
        });

    delayTestFinish(5000);

    NativeEvent clickEvent =
        Document.get().createClickEvent(0, 0, 0, 0, 0, false, false, false, false);

    anchorElement.dispatchEvent(clickEvent);

  } finally {
    Document.get().getBody().removeChild(anchorElement);
  }
}
项目:gwt-material    文件:FocusableMixin.java   
@Override
public void setAccessKey(final char key) {
    final Element element = uiObject.getElement();
    final String accessKey = Character.toString(key);

    if (AnchorElement.is(element)) {
        AnchorElement.as(element).setAccessKey(accessKey);
    } else if (ButtonElement.is(element)) {
        ButtonElement.as(element).setAccessKey(accessKey);
    } else if (InputElement.is(element)) {
        InputElement.as(element).setAccessKey(accessKey);
    }
}
项目:dom-distiller    文件:PagingLinksFinder.java   
public static Integer pageDiff(String url, String linkHref, AnchorElement link, int skip) {
    int commonLen = skip;
    int i;
    url = StringUtil.decodeURIComponent(url);
    linkHref = StringUtil.decodeURIComponent(linkHref);
    for (i=skip; i<Math.min(url.length(), linkHref.length()); i++) {
        if (url.charAt(i) != linkHref.charAt(i)) {
            break;
        }
    }
    commonLen = i;
    url = url.substring(commonLen, url.length());
    linkHref = linkHref.substring(commonLen, linkHref.length());
    appendDbgStrForLink(link, "remains: " + url + ", " + linkHref);

    int linkAsNumber = JavaScript.parseInt(linkHref, 10);
    int urlAsNumber = JavaScript.parseInt(url, 10);
    appendDbgStrForLink(link, "remains: " + urlAsNumber + ", " + linkAsNumber);
    if (urlAsNumber > 0 && linkAsNumber > 0) {
        return linkAsNumber - urlAsNumber;
    }
    return null;
}
项目:dom-distiller    文件:PagingLinksFinderTest.java   
public void testPopularBadLinks() {
    Element root = TestUtil.createDiv(0);
    mBody.appendChild(root);
    AnchorElement nextAnchor = TestUtil.createAnchor("page2", "next page");
    root.appendChild(nextAnchor);
    // If the same bad URL can get scores accumulated across links,
    // it would wrongly get selected.
    AnchorElement bad1 = TestUtil.createAnchor("not-page1", "not");
    root.appendChild(bad1);
    AnchorElement bad2 = TestUtil.createAnchor("not-page1", "not");
    root.appendChild(bad2);
    AnchorElement bad3 = TestUtil.createAnchor("not-page1", "not");
    root.appendChild(bad3);
    AnchorElement bad4 = TestUtil.createAnchor("not-page1", "not");
    root.appendChild(bad4);
    AnchorElement bad5 = TestUtil.createAnchor("not-page1", "not");
    root.appendChild(bad5);

    checkLinks(nextAnchor, null, root);
}
项目:dom-distiller    文件:PagingLinksFinderTest.java   
public void testBaseTag() {
    Element root = TestUtil.createDiv(0);
    mBody.appendChild(root);

    // Base.href should not be mixed up with original_url.
    String base = resolveLinkHref("page2", EXAMPLE_URL);
    BaseElement baseTag = Document.get().createBaseElement();
    baseTag.setHref(base);
    mHead.appendChild(baseTag);

    AnchorElement nextAnchor = TestUtil.createAnchor("page2", "next page");
    root.appendChild(nextAnchor);

    assertEquals(base, PagingLinksFinder.getBaseUrlForRelative(mRoot, EXAMPLE_URL));
    checkLinks(nextAnchor, null, mRoot);

    mHead.removeChild(baseTag);
}
项目:dom-distiller    文件:PagingLinksFinderTest.java   
public void testNextArticleLinks() {
    Element root = TestUtil.createDiv(0);
    mBody.appendChild(root);
    AnchorElement anchor = TestUtil.createAnchor("page2", "next article");
    root.appendChild(anchor);
    assertNull(PagingLinksFinder.findNext(root, EXAMPLE_URL));

    // The banned word "article" also affects anchor2 because it has the same hRef as anchor.
    AnchorElement anchor2 = TestUtil.createAnchor("page2", "next page");
    root.appendChild(anchor2);
    assertNull(PagingLinksFinder.findNext(root, EXAMPLE_URL));

    // Removing the banned word revives the link.
    anchor.setInnerHTML("next thing");
    checkLinks(anchor, null, root);
}
项目:gerrit    文件:RelatedChangesTab.java   
private void onOpenRow(Element row) {
  // Find the first HREF of the anchor of the select row (if any)
  if (row != null) {
    NodeList<Element> nodes = row.getElementsByTagName(AnchorElement.TAG);
    for (int i = 0; i < nodes.getLength(); i++) {
      String url = nodes.getItem(i).getAttribute("href");
      if (!url.isEmpty()) {
        if (url.startsWith("#")) {
          Gerrit.display(url.substring(1));
        } else {
          Window.Location.assign(url);
        }
        break;
      }
    }
  }

  saveSelectedTab();
}
项目:blogwt    文件:AddToAny.java   
public AddToAny () {
    initWidget(uiBinder.createAndBindUi(this));

    String share = PropertyController.get()
            .stringProperty(PropertyHelper.POST_SHARE_ENABLED);
    if (share != null && !PropertyHelper.NONE_VALUE.equals(share)) {
        List<String> shareWith = TagHelper.convertToTagList(share);

        AnchorElement anchor;
        Document doc = Document.get();
        for (String service : shareWith) {
            anchor = doc.createAnchorElement();
            anchor.setClassName("a2a_button_" + service);
            elAddToAny.insertBefore(anchor, lnkAddToAny);
        }
    }
}
项目:blogwt    文件:HeaderPart.java   
private Element convertItemToOpenable (String key, SafeHtml title) {
    activateItem(key, false);
    Element element = getItem(key);
    ensureItems().remove(key);
    element.setClassName("dropdown");
    final AnchorElement a = AnchorElement
            .as(element.getFirstChildElement());
    a.removeAttribute("href");
    Event.sinkEvents(a, Event.ONCLICK);
    Event.setEventListener(a, new EventListener() {

        @Override
        public void onBrowserEvent (Event event) {
            openableClick(a);
            event.stopPropagation();
        }
    });
    a.addClassName("dropdown-toggle");
    a.setInnerSafeHtml(title);
    Element ul = Document.get().createULElement();
    ul.addClassName("dropdown-menu");
    element.appendChild(ul);
    ensureOpenables().put(key, element);

    return element;
}
项目:appformer    文件:TopMenuBar.java   
private void addEntry(String entry, boolean logout) {
    AnchorElement anchor = Document.get().createAnchorElement();
    anchor.setInnerText(entry);

    Event.sinkEvents(anchor, Event.ONCLICK);
    Event.setEventListener(anchor, event -> {
        if (Event.ONCLICK == event.getTypeInt()) {
            if (!logout) {
                onRoleClicked(entry);
            } else {
                onLogoutClicked();
            }
        }
    });

    LIElement li = Document.get().createLIElement();
    li.getStyle().setCursor(Style.Cursor.POINTER);
    li.appendChild(anchor);
    roleList.appendChild((Node) li);
}
项目:appformer    文件:DisplayerHtmlEditorView.java   
@Override
public void addSourceCodeItem(String name) {
    AnchorElement anchor = Document.get().createAnchorElement();
    String displayName = DisplayerHtmlConstants.INSTANCE.getString("displayer_source_code_" + name);
    anchor.setInnerText(displayName);

    LIElement li = Document.get().createLIElement();
    li.getStyle().setCursor(Style.Cursor.POINTER);
    li.appendChild(anchor);
    tabList.appendChild((Node) li);

    Event.sinkEvents(anchor, Event.ONCLICK);
    Event.setEventListener(anchor, event -> {
        if(Event.ONCLICK == event.getTypeInt()) {
            presenter.onSourceCodeItemSelected(name);
            if (selectedItem != null) {
                selectedItem.setClassName("");
                selectedItem.getStyle().setCursor(Style.Cursor.POINTER);
            }
            selectedItem = li;
            selectedItem.setClassName("active");
            selectedItem.getStyle().setCursor(Style.Cursor.DEFAULT);
            previewItem.setClassName("");
        }
    });
}
项目:appformer    文件:SourceCodeEditorView.java   
@Override
public void declareVariable(String var, String description) {

    SpanElement span = Document.get().createSpanElement();
    span.setInnerText(var);

    AnchorElement anchor = Document.get().createAnchorElement();
    anchor.setTitle(description);
    anchor.appendChild(span);

    LIElement li = Document.get().createLIElement();
    li.getStyle().setCursor(Style.Cursor.POINTER);
    li.appendChild(anchor);

    variablesMenu.appendChild((Node) li);

    Event.sinkEvents(anchor, Event.ONCLICK);
    Event.setEventListener(anchor, event -> {
        if(Event.ONCLICK == event.getTypeInt()) {
            presenter.onVariableSelected(var);
        }
    });
}
项目:appformer    文件:NavTilesWidgetView.java   
@Override
public void addBreadcrumbItem(String navItemName, Command onClicked) {
    LIElement li = Document.get().createLIElement();
    breadcrumb.appendChild((Node) li);

    if (onClicked != null) {
        AnchorElement anchor = Document.get().createAnchorElement();
        anchor.setInnerText(navItemName);
        li.appendChild(anchor);
        li.getStyle().setCursor(Style.Cursor.POINTER);

        Event.sinkEvents(anchor, Event.ONCLICK);
        Event.setEventListener(anchor, event -> {
            if (Event.ONCLICK == event.getTypeInt()) {
                onClicked.execute();
            }
        });
    } else {
        ((Node) li).setTextContent(navItemName);
        li.setClassName("active");
    }
}
项目:appformer    文件:NavComponentConfigModalView.java   
private void addItem(UnorderedList unorderedList, String name, boolean selected, Command onSelect) {
    AnchorElement anchor = Document.get().createAnchorElement();
    anchor.setInnerText(name);

    LIElement li = Document.get().createLIElement();
    li.getStyle().setCursor(Style.Cursor.POINTER);
    li.appendChild(anchor);
    li.setClassName(selected ? "selected" : "");
    unorderedList.appendChild((Node) li);

    Event.sinkEvents(anchor, Event.ONCLICK);
    Event.setEventListener(anchor, event -> {
        if(Event.ONCLICK == event.getTypeInt()) {
            onSelect.execute();
        }
    });
}
项目:appformer    文件:TargetPerspectiveEditorView.java   
private void addItem(UnorderedList unorderedList, String name, boolean selected, Command onSelect) {
    AnchorElement anchor = Document.get().createAnchorElement();
    anchor.setInnerText(name);

    LIElement li = Document.get().createLIElement();
    li.getStyle().setCursor(Style.Cursor.POINTER);
    li.appendChild(anchor);
    li.setClassName(selected ? "selected" : "");
    unorderedList.appendChild((Node) li);

    Event.sinkEvents(anchor, Event.ONCLICK);
    Event.setEventListener(anchor, event -> {
        if(Event.ONCLICK == event.getTypeInt()) {
            onSelect.execute();
        }
    });
}
项目:appformer    文件:NavItemDefaultEditorView.java   
@Override
public void addCommand(String name, Command command) {
    AnchorElement anchor = Document.get().createAnchorElement();
    anchor.setInnerText(name);

    LIElement li = Document.get().createLIElement();
    li.getStyle().setCursor(Style.Cursor.POINTER);
    li.appendChild(anchor);
    commandMenu.appendChild((Node) li);

    Event.sinkEvents(anchor, Event.ONCLICK);
    Event.setEventListener(anchor, event -> {
        if(Event.ONCLICK == event.getTypeInt()) {
            command.execute();
        }
    });
}
项目:appformer    文件:BaseNavWidgetView.java   
@Override
public void addItem(String id, String name, String description, Command onItemSelected) {
    AnchorElement anchor = Document.get().createAnchorElement();
    anchor.setInnerText(name);
    if (description != null && !description.equals(name)) {
        anchor.setTitle(description);
    }

    LIElement li = Document.get().createLIElement();
    li.getStyle().setCursor(Style.Cursor.POINTER);
    li.appendChild(anchor);
    navWidget.appendChild((Node) li);
    itemMap.put(id, li);

    Event.sinkEvents(anchor, Event.ONCLICK);
    Event.setEventListener(anchor, event -> {
        if (Event.ONCLICK == event.getTypeInt()) {
            onItemSelected.execute();
        }
    });
}
项目:appformer    文件:PerspectivesExplorerView.java   
@Override
public void addPerspective(String name, Command onClicked) {
    AnchorElement anchor = Document.get().createAnchorElement();
    anchor.getStyle().setCursor(Style.Cursor.POINTER);
    anchor.getStyle().setColor("black");
    anchor.getStyle().setProperty("fontSize", "larger");
    anchor.setInnerText(name);

    Event.sinkEvents(anchor, Event.ONCLICK);
    Event.setEventListener(anchor, event -> {
        if(Event.ONCLICK == event.getTypeInt()) {
            onClicked.execute();
        }
    });

    SpanElement icon = Document.get().createSpanElement();
    icon.getStyle().setMarginRight(10, Style.Unit.PX);
    icon.setClassName("pficon-virtual-machine");
    icon.getStyle().setProperty("fontSize", "larger");

    DivElement gi = createItemDiv(new Element[] {icon, anchor});
    perspectivesDiv.appendChild((Node) gi);
}
项目:appformer    文件:PerspectiveDragConfigModalView.java   
@Override
public void addItem(String name, Command onSelect) {
    AnchorElement anchor = Document.get().createAnchorElement();
    anchor.setInnerText(name);

    LIElement li = Document.get().createLIElement();
    li.getStyle().setCursor(Style.Cursor.POINTER);
    li.appendChild(anchor);
    selectorItems.appendChild((Node) li);

    Event.sinkEvents(anchor, Event.ONCLICK);
    Event.setEventListener(anchor, event -> {
        if(Event.ONCLICK == event.getTypeInt()) {
            onSelect.execute();
        }
    });
}
项目:dashbuilder    文件:TopMenuBar.java   
private void addEntry(String entry, boolean logout) {
    AnchorElement anchor = Document.get().createAnchorElement();
    anchor.setInnerText(entry);

    Event.sinkEvents(anchor, Event.ONCLICK);
    Event.setEventListener(anchor, event -> {
        if (Event.ONCLICK == event.getTypeInt()) {
            if (!logout) {
                onRoleClicked(entry);
            } else {
                onLogoutClicked();
            }
        }
    });

    LIElement li = Document.get().createLIElement();
    li.getStyle().setCursor(Style.Cursor.POINTER);
    li.appendChild(anchor);
    roleList.appendChild((Node) li);
}
项目:dashbuilder    文件:DisplayerHtmlEditorView.java   
@Override
public void addSourceCodeItem(String name) {
    AnchorElement anchor = Document.get().createAnchorElement();
    String displayName = DisplayerHtmlConstants.INSTANCE.getString("displayer_source_code_" + name);
    anchor.setInnerText(displayName);

    LIElement li = Document.get().createLIElement();
    li.getStyle().setCursor(Style.Cursor.POINTER);
    li.appendChild(anchor);
    tabList.appendChild((Node) li);

    Event.sinkEvents(anchor, Event.ONCLICK);
    Event.setEventListener(anchor, event -> {
        if(Event.ONCLICK == event.getTypeInt()) {
            presenter.onSourceCodeItemSelected(name);
            if (selectedItem != null) {
                selectedItem.setClassName("");
                selectedItem.getStyle().setCursor(Style.Cursor.POINTER);
            }
            selectedItem = li;
            selectedItem.setClassName("active");
            selectedItem.getStyle().setCursor(Style.Cursor.DEFAULT);
            previewItem.setClassName("");
        }
    });
}
项目:dashbuilder    文件:SourceCodeEditorView.java   
@Override
public void declareVariable(String var, String description) {

    SpanElement span = Document.get().createSpanElement();
    span.setInnerText(var);

    AnchorElement anchor = Document.get().createAnchorElement();
    anchor.setTitle(description);
    anchor.appendChild(span);

    LIElement li = Document.get().createLIElement();
    li.getStyle().setCursor(Style.Cursor.POINTER);
    li.appendChild(anchor);

    variablesMenu.appendChild((Node) li);

    Event.sinkEvents(anchor, Event.ONCLICK);
    Event.setEventListener(anchor, event -> {
        if(Event.ONCLICK == event.getTypeInt()) {
            presenter.onVariableSelected(var);
        }
    });
}
项目:dashbuilder    文件:NavTilesWidgetView.java   
@Override
public void addBreadcrumbItem(String navItemName, Command onClicked) {
    LIElement li = Document.get().createLIElement();
    breadcrumb.appendChild((Node) li);

    if (onClicked != null) {
        AnchorElement anchor = Document.get().createAnchorElement();
        anchor.setInnerText(navItemName);
        li.appendChild(anchor);
        li.getStyle().setCursor(Style.Cursor.POINTER);

        Event.sinkEvents(anchor, Event.ONCLICK);
        Event.setEventListener(anchor, event -> {
            if (Event.ONCLICK == event.getTypeInt()) {
                onClicked.execute();
            }
        });
    } else {
        ((Node) li).setTextContent(navItemName);
        li.setClassName("active");
    }
}
项目:dashbuilder    文件:NavComponentConfigModalView.java   
private void addItem(UnorderedList unorderedList, String name, boolean selected, Command onSelect) {
    AnchorElement anchor = Document.get().createAnchorElement();
    anchor.setInnerText(name);

    LIElement li = Document.get().createLIElement();
    li.getStyle().setCursor(Style.Cursor.POINTER);
    li.appendChild(anchor);
    li.setClassName(selected ? "selected" : "");
    unorderedList.appendChild((Node) li);

    Event.sinkEvents(anchor, Event.ONCLICK);
    Event.setEventListener(anchor, event -> {
        if(Event.ONCLICK == event.getTypeInt()) {
            onSelect.execute();
        }
    });
}
项目:dashbuilder    文件:NavRootNodeEditorView.java   
@Override
public void addCommand(String name, Command command) {
    AnchorElement anchor = Document.get().createAnchorElement();
    anchor.setInnerText(name);

    LIElement li = Document.get().createLIElement();
    li.getStyle().setCursor(Style.Cursor.POINTER);
    li.appendChild(anchor);
    commandMenu.appendChild((Node) li);

    Event.sinkEvents(anchor, Event.ONCLICK);
    Event.setEventListener(anchor, event -> {
        if(Event.ONCLICK == event.getTypeInt()) {
            command.execute();
        }
    });
}
项目:dashbuilder    文件:TargetPerspectiveEditorView.java   
private void addItem(UnorderedList unorderedList, String name, boolean selected, Command onSelect) {
    AnchorElement anchor = Document.get().createAnchorElement();
    anchor.setInnerText(name);

    LIElement li = Document.get().createLIElement();
    li.getStyle().setCursor(Style.Cursor.POINTER);
    li.appendChild(anchor);
    li.setClassName(selected ? "selected" : "");
    unorderedList.appendChild((Node) li);

    Event.sinkEvents(anchor, Event.ONCLICK);
    Event.setEventListener(anchor, event -> {
        if(Event.ONCLICK == event.getTypeInt()) {
            onSelect.execute();
        }
    });
}
项目:dashbuilder    文件:NavItemDefaultEditorView.java   
@Override
public void addCommand(String name, Command command) {
    AnchorElement anchor = Document.get().createAnchorElement();
    anchor.setInnerText(name);

    LIElement li = Document.get().createLIElement();
    li.getStyle().setCursor(Style.Cursor.POINTER);
    li.appendChild(anchor);
    commandMenu.appendChild((Node) li);

    Event.sinkEvents(anchor, Event.ONCLICK);
    Event.setEventListener(anchor, event -> {
        if(Event.ONCLICK == event.getTypeInt()) {
            command.execute();
        }
    });
}
项目:dashbuilder    文件:BaseNavWidgetView.java   
@Override
public void addItem(String id, String name, String description, Command onItemSelected) {
    AnchorElement anchor = Document.get().createAnchorElement();
    anchor.setInnerText(name);
    if (description != null && !description.equals(name)) {
        anchor.setTitle(description);
    }

    LIElement li = Document.get().createLIElement();
    li.getStyle().setCursor(Style.Cursor.POINTER);
    li.appendChild(anchor);
    navWidget.appendChild((Node) li);
    itemMap.put(id, li);

    Event.sinkEvents(anchor, Event.ONCLICK);
    Event.setEventListener(anchor, event -> {
        if (Event.ONCLICK == event.getTypeInt()) {
            onItemSelected.execute();
        }
    });
}
项目:dashbuilder    文件:PerspectivesExplorerView.java   
@Override
public void addPerspective(String name, Command onClicked) {
    AnchorElement anchor = Document.get().createAnchorElement();
    anchor.getStyle().setCursor(Style.Cursor.POINTER);
    anchor.getStyle().setColor("black");
    anchor.getStyle().setProperty("fontSize", "larger");
    anchor.setInnerText(name);

    Event.sinkEvents(anchor, Event.ONCLICK);
    Event.setEventListener(anchor, event -> {
        if(Event.ONCLICK == event.getTypeInt()) {
            onClicked.execute();
        }
    });

    SpanElement icon = Document.get().createSpanElement();
    icon.getStyle().setMarginRight(10, Style.Unit.PX);
    icon.setClassName("pficon-virtual-machine");
    icon.getStyle().setProperty("fontSize", "larger");

    DivElement gi = createItemDiv(new Element[] {icon, anchor});
    perspectivesDiv.appendChild((Node) gi);
}
项目:dashbuilder    文件:PerspectiveDragConfigModalView.java   
@Override
public void addItem(String name, Command onSelect) {
    AnchorElement anchor = Document.get().createAnchorElement();
    anchor.setInnerText(name);

    LIElement li = Document.get().createLIElement();
    li.getStyle().setCursor(Style.Cursor.POINTER);
    li.appendChild(anchor);
    selectorItems.appendChild((Node) li);

    Event.sinkEvents(anchor, Event.ONCLICK);
    Event.setEventListener(anchor, event -> {
        if(Event.ONCLICK == event.getTypeInt()) {
            onSelect.execute();
        }
    });
}
项目:putnami-web-toolkit    文件:Button.java   
public Button(Button<T> source) {
    super(source);

    this.element = AnchorElement.as(this.getElement());
    this.endConstruct();

    this.setName(source.name);
    this.setText(source.text);
    this.setType(source.type);
    this.setIconType(source.iconType);
    this.setSize(source.size);
    this.setBlock(source.block);
    this.setDisabled(source.disabled);

    if (source.tabIndex != null) {
        this.setTabIndex(source.tabIndex);
    }
}
项目:putnami-web-toolkit    文件:OutputEmail.java   
@Override
public void edit(String value) {
    this.getElement().removeAllChildren();
    if (value != null) {
        AnchorElement anchor = Document.get().createAnchorElement();
        Icon icon = new Icon();
        icon.setType(IconFont.ICON_MAIL);
        StringBuffer sb = new StringBuffer();
        sb.append("mailto:").append(value);
        anchor.setHref(sb.toString());
        anchor.appendChild(icon.getElement());
        anchor.appendChild(Document.get().createTextNode(value));

        this.getElement().appendChild(anchor);
    }
}
项目:gwtbootstrap3    文件:FocusableMixin.java   
@Override
public void setAccessKey(final char key) {
    final Element element = uiObject.getElement();
    final String accessKey = Character.toString(key);

    if (AnchorElement.is(element)) {
        AnchorElement.as(element).setAccessKey(accessKey);
    } else if (ButtonElement.is(element)) {
        ButtonElement.as(element).setAccessKey(accessKey);
    } else if (InputElement.is(element)) {
        InputElement.as(element).setAccessKey(accessKey);
    }
}
项目:mapper    文件:TodoListMapper.java   
private void setActive(final AnchorElement element, final UListElement active, final List<UListElement> allElements) {
  $(element).click(new Function() {
    @Override
    public boolean f(Event e) {
      $("a.inline").removeClass("selected");
      $(element).addClass("selected");
      for (UListElement otherElement : allElements) {
        if (otherElement != active) {
          $(otherElement).hide();
        }
      }
      $(active).show();
      return false;
    }
  });
}
项目:drools-wb    文件:HitPolicySelectorViewImpl.java   
@Override
public void addHitPolicyOption( final GuidedDecisionTable52.HitPolicy hitPolicy ) {
    final AnchorElement anchor = Document.get()
            .createAnchorElement();
    anchor.setInnerText( HitPolicyInternationalizer.internationalize( hitPolicy ) );

    Event.sinkEvents( anchor,
                      Event.ONCLICK );
    Event.setEventListener( anchor,
                            event -> {
                                if ( Event.ONCLICK == event.getTypeInt() ) {
                                    presenter.onHitPolicySelected( hitPolicy );
                                }
                            } );

    final LIElement li = Document.get()
            .createLIElement();
    li.appendChild( anchor );
    listOfAvailableHitModes.appendChild( (Node) li );
}
项目:dom-distiller    文件:DomUtil.java   
/**
 * Check to see if a provided URL has the specified root domain (ex. http://a.b.c/foo/bar has
 * root domain of b.c).
 * @param url The URL to test.
 * @param root The root domain to test against.
 * @return True if url has the specified root domain.
 */
public static boolean hasRootDomain(String url, String root) {
    if (url == null || root == null) {
        return false;
    }
    AnchorElement anchor = Document.get().createAnchorElement();
    anchor.setHref(url);
    String host = anchor.getPropertyString("host");
    return ("." + host).endsWith("." + root);
}
项目:dom-distiller    文件:PageParameterParser.java   
/**
 * @return a populated PageInfoAndText if given link is to be added to mAdjacentNumbersGroups.
 * Otherwise, returns null if link is to be ignored.
 * "javascript:" links with numeric text are considered valid links to be added.
 *
 * @param link to process.
 * @param baseAnchor created for the current document.
 */
private PageInfoAndText getPageInfoAndText(AnchorElement link, AnchorElement baseAnchor) {
    // Ignore invisible links.
    if (!DomUtil.isVisible(link)) return null;

    // Use javascript innerText (instead of javascript textContent) to only get visible text.
    String linkText = StringUtil.jsTrim(DomUtil.getInnerText(link));
    int number = linkTextToNumber(linkText);
    if (!isPlainPageNumber(number)) return null;

    String linkHref = resolveLinkHref(link, baseAnchor);
    final boolean isEmptyHref = linkHref.isEmpty();
    boolean isJavascriptLink = false;
    ParsedUrl url = null;
    if (!isEmptyHref) {
        isJavascriptLink = isJavascriptHref(linkHref);
        url = ParsedUrl.create(linkHref);
        if (url == null ||
                (!isJavascriptLink && !url.getHost().equalsIgnoreCase(mParsedUrl.getHost()))) {
            return null;
        }
        url.setHash("");
    }

    if (isEmptyHref || isJavascriptLink || isDisabledLink(link)) {
        return new PageInfoAndText(number, "", linkText);
    }

    return new PageInfoAndText(number, sHrefCleaner.replace(url.toString(), ""), linkText);
}
项目:dom-distiller    文件:PageParameterParser.java   
/**
 * Adds PageParamInfo.PageInfo to the current adjacent group for a link if its text is numeric.
 * Otherwise, add a new group to break the adjacency.
 *
 * @Return true if link was added, false otherwise.
 */
private boolean addLinkIfValid(AnchorElement link, AnchorElement baseAnchor) {
    PageInfoAndText pageInfoAndText = getPageInfoAndText(link, baseAnchor);
    if (pageInfoAndText != null) {
        mAdjacentNumbersGroups.addPageInfo(pageInfoAndText.mPageInfo);
        return true;
    }
    mAdjacentNumbersGroups.addGroup();
    return false;
}