本文整理汇总了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);
}
}
示例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);
}
}
示例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);
}
示例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);
}
示例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));
}
示例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());
}
示例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));
}
示例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;
}
示例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);
}
}
示例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);
}
示例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 ? "«" : "»");
this.getElement().appendChild(anchor);
StyleUtils.addStyle(this, previous ? Pagination.PREVIOUS_STYLE : Pagination.NEXT_STYLE);
}
示例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);
}
示例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));
}
示例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;
}