当前位置: 首页>>代码示例>>Java>>正文


Java AnchorElement.setHref方法代码示例

本文整理汇总了Java中com.google.gwt.dom.client.AnchorElement.setHref方法的典型用法代码示例。如果您正苦于以下问题:Java AnchorElement.setHref方法的具体用法?Java AnchorElement.setHref怎么用?Java AnchorElement.setHref使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.gwt.dom.client.AnchorElement的用法示例。


在下文中一共展示了AnchorElement.setHref方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testClickLink

import com.google.gwt.dom.client.AnchorElement; //导入方法依赖的package包/类
@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);
  }
}
 
开发者ID:tbroyer,项目名称:gwt-history,代码行数:27,代码来源:HistoryTest.java

示例2: edit

import com.google.gwt.dom.client.AnchorElement; //导入方法依赖的package包/类
@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);
	}
}
 
开发者ID:Putnami,项目名称:putnami-web-toolkit,代码行数:17,代码来源:OutputEmail.java

示例3: hasRootDomain

import com.google.gwt.dom.client.AnchorElement; //导入方法依赖的package包/类
/**
 * 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);
}
 
开发者ID:chromium,项目名称:dom-distiller,代码行数:17,代码来源:DomUtil.java

示例4: extract

import com.google.gwt.dom.client.AnchorElement; //导入方法依赖的package包/类
@Override
public WebEmbed extract(Element e) {
    if (e == null || !relevantTags.contains(e.getTagName())) {
        return null;
    }
    String src = IFrameElement.as(e).getSrc();
    if (!DomUtil.hasRootDomain(src, "player.vimeo.com")) {
        return null;
    }

    // Get specific attributes about the Vimeo embed.
    AnchorElement anchor = Document.get().createAnchorElement();
    anchor.setHref(src);
    String path = anchor.getPropertyString("pathname");

    Map<String, String> paramMap =
            DomUtil.splitUrlParams(anchor.getPropertyString("search").substring(1));

    String id = getVimeoIdFromPath(path);
    if (id == null) {
        return null;
    }

    if (LogUtil.isLoggable(LogUtil.DEBUG_LEVEL_VISIBILITY_INFO)) {
        LogUtil.logToConsole("Vimeo embed extracted:");
        LogUtil.logToConsole("    ID:    " + id);
    }

    return new WebEmbed(e, "vimeo", id, paramMap);
}
 
开发者ID:chromium,项目名称:dom-distiller,代码行数:31,代码来源:VimeoExtractor.java

示例5: testNonHttpOrHttpsLink

import com.google.gwt.dom.client.AnchorElement; //导入方法依赖的package包/类
public void testNonHttpOrHttpsLink() {
    Element root = TestUtil.createDiv(0);
    mBody.appendChild(root);
    AnchorElement anchor = TestUtil.createAnchor("javascript:void(0)",
                                                 "NEXT");
    root.appendChild(anchor);
    assertNull(PagingLinksFinder.findNext(root, EXAMPLE_URL));

    anchor.setHref("file://test.html");
    assertNull(PagingLinksFinder.findNext(root, EXAMPLE_URL));
}
 
开发者ID:chromium,项目名称:dom-distiller,代码行数:12,代码来源:PagingLinksFinderTest.java

示例6: testEmptyBlockNotMergedWithNextBlock

import com.google.gwt.dom.client.AnchorElement; //导入方法依赖的package包/类
public void testEmptyBlockNotMergedWithNextBlock() {
    // <ul>
    //   <li><a href="foo.html> </a>
    //   </li>
    //   <li>TEXT1
    //   </li>
    // </ul>
    Element ul = createULElement();
    startElement(ul);
    addText("\n");

    Element li = createLIElement();
    startElement(li);
    AnchorElement anchor = createAnchorElement();
    anchor.setHref("foo.html");
    startElement(anchor);
    addText(" ");
    endElement(anchor);
    addText("\n");
    endElement(li);
    addText("\n");

    startElement(li);
    addText(TEXT1);
    addText("\n");
    endElement(li);
    endElement(ul);

    endBodyAndDocument();

    List<TextBlock> textBlocks = getHandlerTextBlocks();
    assertEquals(1, textBlocks.size());
    assertEquals(TEXT1 + "\n", textBlocks.get(0).getText());
}
 
开发者ID:chromium,项目名称:dom-distiller,代码行数:35,代码来源:WebDocumentBuilderTest.java

示例7: testFigureCaptionWithAnchor

import com.google.gwt.dom.client.AnchorElement; //导入方法依赖的package包/类
public void testFigureCaptionWithAnchor() {
    mHead.setInnerHTML("<base href=\"http://example.com/\">");

    ImageElement image = TestUtil.createImage();
    image.setSrc("http://wwww.example.com/image.jpeg");
    image.setAttribute("width", "100");
    image.setAttribute("height", "100");

    Element figure = Document.get().createElement("FIGURE");
    figure.appendChild(image);
    figure.setAttribute("class", "test");
    figure.setAttribute("attribute", "value");

    Element figcaption = Document.get().createElement("FIGCAPTION");
    AnchorElement anchor = Document.get().createAnchorElement();
    anchor.setHref("link_page.html");
    anchor.setInnerHTML("caption<br>link");
    figcaption.appendChild(TestUtil.createText("This is a "));
    figcaption.appendChild(anchor);
    figure.appendChild(figcaption);
    mBody.appendChild(figure);
    String expected =
        "<figure>" +
            "<img src=\"http://wwww.example.com/image.jpeg\"" +
                " width=\"100\" height=\"100\">" +
            "<figcaption>This is a " +
                "<a href=\"http://example.com/link_page.html\">caption<br>link</a>" +
            "</figcaption>" +
        "</figure>";
    EmbedExtractor extractor = new ImageExtractor();
    WebElement result = extractor.extract(figure);
    assertEquals(expected, TestUtil.removeAllDirAttributes(
            result.generateOutput(false)));
    assertEquals("This is a caption\nlink", result.generateOutput(true));
}
 
开发者ID:chromium,项目名称:dom-distiller,代码行数:36,代码来源:EmbedExtractorTest.java

示例8: getProperty

import com.google.gwt.dom.client.AnchorElement; //导入方法依赖的package包/类
private static String getProperty(String url, String property) {
    AnchorElement anchor = Document.get().createAnchorElement();
    anchor.setHref(url);
    String value = anchor.getPropertyString(property);
    anchor.removeFromParent();
    return value;
}
 
开发者ID:uom-daris,项目名称:daris,代码行数:8,代码来源:URL.java

示例9: addItem

import com.google.gwt.dom.client.AnchorElement; //导入方法依赖的package包/类
private void addItem (Element parent, SafeHtml title, SafeUri href) {
	String key = href.asString().replaceFirst("#", "");
	Element element = getItem(key);

	if (element == null) {
		element = Document.get().createLIElement();
		final AnchorElement a = Document.get().createAnchorElement();
		a.setHref(href);
		element.appendChild(a);
		a.setInnerSafeHtml(title);
		parent.appendChild(element);
		ensureItems().put(key, element);
	}
}
 
开发者ID:billy1380,项目名称:blogwt,代码行数:15,代码来源:HeaderPart.java

示例10: Page

import com.google.gwt.dom.client.AnchorElement; //导入方法依赖的package包/类
Page(String label, int page) {
	this.setElement(Document.get().createLIElement());
	this.page = page;
	if (Pagination.this.currentPage == page) {
		StyleUtils.addStyle(this, Pagination.STYLE_ACTIVE);
	} else {
		this.addDomHandler(this, ClickEvent.getType());
	}
	AnchorElement anchor = Document.get().createAnchorElement();
	anchor.setHref(AnchorUtils.DUMMY_HREF);
	anchor.setInnerText(label);
	this.getElement().appendChild(anchor);
}
 
开发者ID:Putnami,项目名称:putnami-web-toolkit,代码行数:14,代码来源:Pagination.java

示例11: NavigationPage

import com.google.gwt.dom.client.AnchorElement; //导入方法依赖的package包/类
NavigationPage(boolean previous) {
	this.previous = previous;
	this.setElement(Document.get().createLIElement());
	this.addDomHandler(this, ClickEvent.getType());
	AnchorElement anchor = Document.get().createAnchorElement();
	anchor.setHref(AnchorUtils.DUMMY_HREF);
	anchor.setInnerHTML(previous ? "&laquo;" : "&raquo;");
	this.getElement().appendChild(anchor);
	StyleUtils.addStyle(this, previous ? Pagination.PREVIOUS_STYLE : Pagination.NEXT_STYLE);
}
 
开发者ID:Putnami,项目名称:putnami-web-toolkit,代码行数:11,代码来源:Pagination.java

示例12: SuggestionItem

import com.google.gwt.dom.client.AnchorElement; //导入方法依赖的package包/类
SuggestionItem(Oracle.Suggestion<T> suggestion, String displayedValue) {
	this.setElement(Document.get().createLIElement());
	this.suggestion = suggestion;
	AnchorElement anchor = Document.get().createAnchorElement();
	anchor.setHref(AnchorUtils.DUMMY_HREF);
	anchor.setInnerHTML(displayedValue);
	this.getElement().appendChild(anchor);
}
 
开发者ID:Putnami,项目名称:putnami-web-toolkit,代码行数:9,代码来源:ContentAssistAspect.java

示例13: checkResolveLinkHref

import com.google.gwt.dom.client.AnchorElement; //导入方法依赖的package包/类
private static void checkResolveLinkHref(AnchorElement anchor, String original_url, String expected, String href) {
    anchor.setHref(href);
    AnchorElement baseAnchor = PagingLinksFinder.createAnchorWithBase(original_url);
    assertEquals(expected, PagingLinksFinder.resolveLinkHref(anchor, baseAnchor));
}
 
开发者ID:chromium,项目名称:dom-distiller,代码行数:6,代码来源:PagingLinksFinderTest.java

示例14: createAnchor

import com.google.gwt.dom.client.AnchorElement; //导入方法依赖的package包/类
public static AnchorElement createAnchor(String href, String text) {
    AnchorElement l = Document.get().createAnchorElement();
    l.setHref(href);
    l.setInnerHTML(text);
    return l;
}
 
开发者ID:chromium,项目名称:dom-distiller,代码行数:7,代码来源:TestUtil.java


注:本文中的com.google.gwt.dom.client.AnchorElement.setHref方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。