table.setOnMousePressed(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent event) { if (event.isPrimaryButtonDown() && event.getClickCount() == 2) { Node node = ((Node) event.getTarget()).getParent(); TableRow row; if (node instanceof TableRow) { row = (TableRow) node; } else { // clicking on text part row = (TableRow) node.getParent(); } System.out.println(row.getItem()); } } });
String getXPath(Node node) { Node parent = node.getParent(); if (parent == null) { return "/" + node.getTagName(); } return getXPath(parent) + "/" + "[@id='" + node.getAttribute("id") + "']"; }
@Override public Node getParent() throws ItemNotFoundException, AccessDeniedException, RepositoryException { return baseNode.getParent(); }
@Override protected boolean nodeMatches(Node node) { // Only get children (child level 1) below parent path try { return StringUtils.equals(parentPath, node.getParent().getPath()); } catch (RepositoryException e) { return false; } } }
void rename(Node node, String newName) throws RepositoryException { node.getSession().move(node.getPath(), node.getParent().getPath() + "/" + newName); // Don't forget - not necessarily here at this place: // node.getSession().save(); }
for (Node n: chartBackground.getParent().getChildrenUnmodifiable()) { if (n != chartBackground && n != xAxis && n != yAxis) { n.setMouseTransparent(true);
/** * Convenience - delegate to {@link Node#orderBefore(String, String)}. */ public static void orderBefore(Node node, String siblingName) throws RepositoryException { node.getParent().orderBefore(node.getName(), siblingName); }
public static boolean isFirstSibling(Node node) throws RepositoryException { Node parent = node.getParent(); NodeIterator nodes = parent.getNodes(); return isSame(nodes.nextNode(), node); }
public static void moveNode(Node nodeToMove, Node newParent) throws RepositoryException { // ignore move request silently if moving within same folder. Such op, although in theory should be void, will fail in JR // with exception when same name siblings are restricted in NT definition. if (!newParent.getPath().equals(nodeToMove.getParent().getPath())) { String newPath = combinePathAndName(newParent.getPath(), nodeToMove.getName()); nodeToMove.getSession().move(nodeToMove.getPath(), newPath); } }
/** * Orders the node up one step among its siblings. If the node is the only sibling or the first sibling this method * has no effect. */ public static void orderNodeUp(Node node) throws RepositoryException { Node siblingBefore = getSiblingBefore(node); if (siblingBefore != null) { node.getParent().orderBefore(node.getName(), siblingBefore.getName()); } }
public static void moveNodeBefore(Node nodeToMove, Node target) throws RepositoryException { Node targetParent = target.getParent(); moveNode(nodeToMove, targetParent); targetParent.orderBefore(nodeToMove.getName(), target.getName()); }
public static void renameNode(Node node, String newName) throws RepositoryException { if (node.getName().equals(newName)) { return; } final Node parent = node.getParent(); final String newPath = combinePathAndName(parent.getPath(), newName); final Node siblingAfter = NodeUtil.getSiblingAfter(node); node.getSession().move(node.getPath(), newPath); if (siblingAfter != null) { parent.orderBefore(newName, siblingAfter.getName()); } }
@Override public Item getAncestor(int depth) throws ItemNotFoundException, AccessDeniedException, RepositoryException { // at some point we will enter the real hierarchy, so its easiest to loop Node parent = getParent(); while (parent.getDepth() > depth) { parent = parent.getParent(); } return parent; }
@Override protected void doExecute(InstallContext installContext) throws RepositoryException, TaskExecutionException { final Node node = installContext.getJCRSession(repository).getNode(path); node.getParent().orderBefore(node.getName(), orderBeforeNodeName); }
private Node getOrCreateParent(String key) throws RepositoryException { Node p = getParent(key); if (treeManager.isRoot(p)) { Node min = getMinimal(); if (min != null) { p = min.getParent(); renamePath(p, key); } } return p; }
@Test public void testNavigatingWithNodeParentStillHidesExcludedNode() throws Exception { Node unspecified = sessionWrapper.getRootNode().getNode("unspecified"); Node root = unspecified.getParent(); assertFalse(root.hasNode("excluded")); try { root.getNode("excluded"); fail(); } catch (PathNotFoundException expected) { } } }
@Override public Content getParent() throws PathNotFoundException, RepositoryException, AccessDeniedException { Node parentNode = getJCRNode().getParent(); return parentNode == null ? null : new MockContent((MockNode) parentNode); }
@Override public Item getAncestor(int depth) throws RepositoryException { if (this.getDepth() == depth) { return this; } Node parentNode = this.getParent(); while (parentNode.getDepth() != depth) { parentNode = parentNode.getParent(); } return parentNode; }