本文整理汇总了Java中elemental.dom.NodeList类的典型用法代码示例。如果您正苦于以下问题:Java NodeList类的具体用法?Java NodeList怎么用?Java NodeList使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
NodeList类属于elemental.dom包,在下文中一共展示了NodeList类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: divsWithDOM
import elemental.dom.NodeList; //导入依赖的package包/类
public void divsWithDOM() {
// Create a view and controller without ajax action
View view = new View();
Controller controller = new ControllerMock();
view.start(controller);
// after viewing
NodeList divs = Fluent.document.getElementsByTagName("DIV");
assertEquals("there should be one DIV", divs.length(), 1);
assertTrue("which contains the inner text 'Hi'", divs.item(0).getTextContent().contains("Hi"));
// after some AJAX
String random = Math.random() + "";
view.setResponse(200, random);
divs = Fluent.document.getElementsByTagName("DIV");
assertEquals("there should be two DIVs", divs.length(), 2);
assertEquals("and the 2nd should equal ajax", divs.item(1).getTextContent(), "Server said: " + random);
}
示例2: mvcBootstrapStateChange
import elemental.dom.NodeList; //导入依赖的package包/类
public void mvcBootstrapStateChange() {
Fluent.console.log("This runs in Javascript");
// This below is like 'new View().onModuleLoad()'
Store transport = new StoreNone(); // BUT with a different store!
View view = new View();
Controller controller = new Controller(transport, view);
view.start(controller);
// After pressing the menuBills button, check in the LI with class
// active, the name of the A-link.
controller.onMenuBills(null, null);
NodeList b = document.getElementsByClassName("active");
assertEquals("length of actives", b.length(), 1);
assertTrue("selected item title", ((Element) b.item(0).getChildNodes().at(0)).getTextContent().equals("Bills"));
}
示例3: printStructure
import elemental.dom.NodeList; //导入依赖的package包/类
private void printStructure(Element element) {
console.log("<" + element.getNodeName());
NamedNodeMap attributes = element.getAttributes();
if (attributes != null) {
for (int x = 0; x < attributes.length(); x++) {
Node attr = attributes.item(x);
console.log(" " + attr.getNodeName() + "=" + attr.getNodeValue());
}
}
console.log(">");
if (element.getTextContent() != null) {
console.log(element.getTextContent());
}
NodeList children = element.getChildNodes();
for (int x = 0; x < children.getLength(); x++) {
printStructure((Element) children.at(x));
}
console.log("</" + element.getNodeName() + ">");
}
示例4: rightArrowPressed
import elemental.dom.NodeList; //导入依赖的package包/类
/**
* Handles pressing the Right arrow button. Does nothing when user selected a file. Expands a
* folder if the user has selected one. Selects the first child if the folder is already selected
* and expanded.
*/
public void rightArrowPressed() {
if (getModel().getRoot() == null
|| getSelectionModel().getSelectedNodes().isEmpty()
|| getModel().dataAdapter.getChildren(getModel().getRoot()).isEmpty()) {
return;
}
D selected = getSelectionModel().getSelectedNodes().get(0);
TreeNodeElement<D> selectedTreeNodeElement =
getModel().dataAdapter.getRenderedTreeNode(selected);
if (selectedTreeNodeElement.hasChildrenContainer()) {
if (selectedTreeNodeElement.isOpen()) {
// Select the first child
NodeList children = selectedTreeNodeElement.getChildrenContainer().getChildNodes();
if (children.getLength() > 0) {
TreeNodeElement<D> firstChild = (TreeNodeElement<D>) children.item(0);
selectSingleNode(firstChild);
}
} else {
// Open the folder
expandNode(selectedTreeNodeElement, true, true);
}
}
}
示例5: getVisibleTreeNodes
import elemental.dom.NodeList; //导入依赖的package包/类
/**
* Gathers all visible nodes of subtree.
*
* @param node subtree parent
* @return array containing all visible nodes of subtree
*/
public List<TreeNodeElement<D>> getVisibleTreeNodes(TreeNodeElement<D> node) {
List<TreeNodeElement<D>> nodes = new ArrayList<>();
nodes.add(node);
if (node.isOpen() && node.hasChildNodes()) {
NodeList children = node.getChildrenContainer().getChildNodes();
for (int ci = 0; ci < children.getLength(); ci++) {
TreeNodeElement<D> child = (TreeNodeElement<D>) children.item(ci);
nodes.addAll(getVisibleTreeNodes(child));
}
}
return nodes;
}
示例6: removeStaleInfoPopups
import elemental.dom.NodeList; //导入依赖的package包/类
private static void removeStaleInfoPopups(final String markerClass) {
final Document documentElement = Elements.getDocument();
final NodeList markersToRemove = documentElement.getElementsByClassName(markerClass);
for (int i = 0; i < markersToRemove.getLength(); i++) {
final Node childToRemove = markersToRemove.item(i);
final Node parent = childToRemove.getParentNode();
if (parent != null) {
parent.removeChild(childToRemove);
}
}
}
示例7: nativeAttachFirstLink
import elemental.dom.NodeList; //导入依赖的package包/类
private static void nativeAttachFirstLink(Element styleElement) {
final HeadElement head = Elements.getDocument().getHead();
final NodeList nodes = head.getElementsByTagName("link");
if (nodes.length() > 0) {
head.insertBefore(styleElement, nodes.item(0));
} else {
head.appendChild(styleElement);
}
}
示例8: middleChildRemoval
import elemental.dom.NodeList; //导入依赖的package包/类
private void middleChildRemoval() {
ViewOn<Integer> children = Fluent.body.add(0, i -> {
switch (i) {
case 0:
return Ul(null, Li(null, "a"), Li(null, "b"), Li(null, "c"));
case 1:
return Ul(null, Li(null, "a"), Li(null, "b"), Li(null, "c"));
case 2:
return Ul(null, Li(null, "a"), Li(null, "c"));
case 3:
return Ul(null, Li(null, "a"), Li(null, "b"));
case 4:
return Ul(null, Li(null, "c"), Li(null, "b"), Li(null, "a"));
default:
return null;
}
});
NodeList nodes = Fluent.document.getElementsByTagName("LI");
assertEquals("1. length", 3, nodes.length());
assertEquals("1. first value", "a", nodes.item(0).getTextContent());
assertEquals("1. second value", "b", nodes.item(1).getTextContent());
assertEquals("1. third value", "c", nodes.item(2).getTextContent());
children.state(1);
nodes = Fluent.document.getElementsByTagName("LI");
assertEquals("2. length", 3, nodes.length());
assertEquals("2. first value", "a", nodes.item(0).getTextContent());
assertEquals("2. second value", "b", nodes.item(1).getTextContent());
assertEquals("2. third alue", "c", nodes.item(2).getTextContent());
children.state(2);
nodes = Fluent.document.getElementsByTagName("LI");
assertEquals("3. length", 2, nodes.length());
assertEquals("3. first value", "a", nodes.item(0).getTextContent());
assertEquals("3. second value", "c", nodes.item(1).getTextContent());
children.state(3);
nodes = Fluent.document.getElementsByTagName("LI");
assertEquals("4. length", 2, nodes.length());
assertEquals("4. first value", "a", nodes.item(0).getTextContent());
assertEquals("4. second value", "b", nodes.item(1).getTextContent());
children.state(1);
nodes = Fluent.document.getElementsByTagName("LI");
assertEquals("5. length", 3, nodes.length());
assertEquals("5. first value", "a", nodes.item(0).getTextContent());
assertEquals("5. second value", "b", nodes.item(1).getTextContent());
assertEquals("5. third alue", "c", nodes.item(2).getTextContent());
children.state(4);
nodes = Fluent.document.getElementsByTagName("LI");
assertEquals("6. length", 3, nodes.length());
assertEquals("6. first value", "c", nodes.item(0).getTextContent());
assertEquals("6. second value", "b", nodes.item(1).getTextContent());
assertEquals("6. third alue", "a", nodes.item(2).getTextContent());
}
示例9: ElementIterable
import elemental.dom.NodeList; //导入依赖的package包/类
private ElementIterable(NodeList nodes) {
this.nodes = nodes;
}
示例10: forEach
import elemental.dom.NodeList; //导入依赖的package包/类
public static MappedIterable<Element> forEach(NodeList children) {
return new ElementIterable(children);
}