本文整理汇总了Java中com.google.gwt.dom.client.AnchorElement类的典型用法代码示例。如果您正苦于以下问题:Java AnchorElement类的具体用法?Java AnchorElement怎么用?Java AnchorElement使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AnchorElement类属于com.google.gwt.dom.client包,在下文中一共展示了AnchorElement类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: redraw
import com.google.gwt.dom.client.AnchorElement; //导入依赖的package包/类
@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());
}
}
示例2: 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);
}
}
示例3: setAccessKey
import com.google.gwt.dom.client.AnchorElement; //导入依赖的package包/类
@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);
}
}
示例4: pageDiff
import com.google.gwt.dom.client.AnchorElement; //导入依赖的package包/类
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;
}
示例5: testResolveLinkHref
import com.google.gwt.dom.client.AnchorElement; //导入依赖的package包/类
public void testResolveLinkHref() {
Element root = TestUtil.createDiv(0);
mBody.appendChild(root);
AnchorElement anchor = TestUtil.createAnchor("", "");
root.appendChild(anchor);
String url = "http://example.com/path/toward/page.html";
checkResolveLinkHref(anchor, url, "http://dummy/link", "http://dummy/link");
checkResolveLinkHref(anchor, url, "https://dummy/link", "https://dummy/link");
checkResolveLinkHref(anchor, url, "http://example.com/next", "/next");
checkResolveLinkHref(anchor, url, "http://example.com/path/toward/next", "next");
checkResolveLinkHref(anchor, url, "http://example.com/path/next", "../next");
checkResolveLinkHref(anchor, url, "http://example.com/1/2/next", "../../1/3/../2/next");
checkResolveLinkHref(anchor, url, "javascript:void(0)", "javascript:void(0)");
checkResolveLinkHref(anchor, url, "mailto:[email protected]", "mailto:[email protected]");
checkResolveLinkHref(anchor, url, "http://example.com/path/toward/page.html?page=2#table_of_content", "?page=2#table_of_content");
}
示例6: testPopularBadLinks
import com.google.gwt.dom.client.AnchorElement; //导入依赖的package包/类
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);
}
示例7: testBaseTag
import com.google.gwt.dom.client.AnchorElement; //导入依赖的package包/类
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);
}
示例8: testNextArticleLinks
import com.google.gwt.dom.client.AnchorElement; //导入依赖的package包/类
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);
}
示例9: onOpenRow
import com.google.gwt.dom.client.AnchorElement; //导入依赖的package包/类
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();
}
示例10: AddToAny
import com.google.gwt.dom.client.AnchorElement; //导入依赖的package包/类
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);
}
}
}
示例11: convertItemToOpenable
import com.google.gwt.dom.client.AnchorElement; //导入依赖的package包/类
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;
}
示例12: addEntry
import com.google.gwt.dom.client.AnchorElement; //导入依赖的package包/类
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);
}
示例13: addSourceCodeItem
import com.google.gwt.dom.client.AnchorElement; //导入依赖的package包/类
@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("");
}
});
}
示例14: declareVariable
import com.google.gwt.dom.client.AnchorElement; //导入依赖的package包/类
@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);
}
});
}
示例15: addBreadcrumbItem
import com.google.gwt.dom.client.AnchorElement; //导入依赖的package包/类
@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");
}
}