Refine search
/** Traverse a path from a parent node down, by an enumeration of names. * @param start node to start searching at * @param names names of nodes * along the path * @return the node with such a path from the start node * @exception NodeNotFoundException if the node with such name * does not exists; the exception contains additional information * about the failure. */ public static Node findPath(Node start, String[] names) throws NodeNotFoundException { return findPath(start, Enumerations.array(names)); }
/** Traverse a path from a parent node down, by an enumeration of names. * @param start node to start searching at * @param names enumeration of names of nodes * along the path * @return the node with such a path from the start node * @exception NodeNotFoundException if the node with such name * does not exists; the exception contains additional information * about the failure. */ public static Node findPath(Node start, Enumeration<String> names) throws NodeNotFoundException { int depth = 0; while (names.hasMoreElements()) { String name = names.nextElement(); Node next = findChild(start, name); if (next == null) { // no element in list matched the name => fail // fire exception with the last accessed node and the // name of child that does not exists throw new NodeNotFoundException(start, name, depth); } else { // go on next node start = next; } // continue on next depth depth++; } return start; }
/** Constructor - asociates with given cookie action */ public CookiesChangeListener(CookieAction a) { listener = org.openide.nodes.NodeOp.weakNodeListener(this, null); action = new WeakReference<CookieAction>(a); }
private Node findPathPlain(FileObject fo, FileObject groupRoot, Node rootNode) { FileObject folder = fo.isFolder() ? fo : fo.getParent(); String relPath = FileUtil.getRelativePath(groupRoot, folder); List<String> path = new ArrayList<String>(); StringTokenizer strtok = new StringTokenizer(relPath, "/"); // NOI18N while (strtok.hasMoreTokens()) { String token = strtok.nextToken(); path.add(token); } try { Node folderNode = folder.equals(groupRoot) ? rootNode : NodeOp.findPath(rootNode, Collections.enumeration(path)); if (fo.isFolder()) { return folderNode; } else { Node[] childs = folderNode.getChildren().getNodes(true); for (int i = 0; i < childs.length; i++) { DataObject dobj = childs[i].getLookup().lookup(DataObject.class); if (dobj != null && dobj.getPrimaryFile().getNameExt().equals(fo.getNameExt())) { return childs[i]; } } } } catch (NodeNotFoundException e) { e.printStackTrace(); } return null; }
Node parent = NodeOp.findPath(root, Collections.enumeration(path)); if (parent != null) { Node[] nds = parent.getChildren().getNodes(true); for (int i = 0; i < nds.length; i++) { DataObject dobj = nds[i].getLookup().lookup(DataObject.class); if (dobj != null && fo.equals(dobj.getPrimaryFile())) { return nds[i]; try { DataObject dobj = DataObject.find(fo); name = dobj.getNodeDelegate().getName(); } catch (DataObjectNotFoundException ex) {
/** * Computes a common popup menu for the specified nodes. * Provides only those actions supplied by all nodes in the list. * <p>Component action maps are not taken into consideration. * {@link Utilities#actionsToPopup(Action[], Component)} is a better choice * if you want to use actions such as "Paste" which look at action maps. * @param nodes the nodes * @return the menu for all nodes */ public static JPopupMenu findContextMenu(Node[] nodes) { Action[] arr = findActions(nodes); // prepare lookup representing all the selected nodes List<Lookup> allLookups = new ArrayList<Lookup>(); for (Node n : nodes) { allLookups.add(n.getLookup()); } Lookup lookup = new ProxyLookup(allLookups.toArray(new Lookup[allLookups.size()])); return Utilities.actionsToPopup(arr, lookup); }
Node result = NodeOp.findChild(root,rootfo.getName()); if (result == null) { return null; result = NodeOp.findChild(result, st.nextToken()); if (result == null) { return null; for (Node child : result.getChildren().getNodes(true)) DataObject dobj = child.getLookup().lookup(DataObject.class); if (dobj != null && dobj.getPrimaryFile().getNameExt().equals(fo.getNameExt()))
public void selectNode( String name ) { Children ch = manager.getRootContext().getChildren(); if ( ch != null ) { Node nodes[] = ch.getNodes( true ); node = NodeOp.findPath( manager.getRootContext(), NbCollections.checkedEnumerationByFilter(st, String.class, true) ); // NOI18N
Node[] preselectedNodes = this.getExplorerManager().getSelectedNodes(); if (preselectedNodes.length == 1) { LibraryTypeProvider provider = preselectedNodes[0].getLookup().lookup(LibraryTypeProvider.class); if (provider != null) { preselectedLibraryType = provider.getLibraryType(); area = preselectedNodes[0].getLookup().lookup(LibraryStorageArea.class); ExplorerManager mgr = this.getExplorerManager(); try { Node node = NodeOp.findPath(mgr.getRootContext(),path); if (node != null) { mgr.setSelectedNodes(new Node[] {node});
public void propertyChange(PropertyChangeEvent evt) { if (ExplorerManager.PROP_SELECTED_NODES.equals(evt.getPropertyName())){ if (getExplorerManager().getSelectedNodes().length == 1){ RemoteFile remote = (RemoteFile) getExplorerManager().getSelectedNodes()[0].getLookup().lookup(RemoteFile.class); if (remote == null){ RemoteFilesystemChooser.this.firePropertyChange(NotifyDescriptor.PROP_VALID, true, false); return; String[] path = NodeOp.createPath(getExplorerManager().getSelectedNodes()[0], getExplorerManager().getRootContext()); StringBuffer sb = new StringBuffer("\\"); //NOI18N for (int i = 0; i < path.length; i++){
private Node findNodeInServerFiles(Node root, FileObject fo) { Node configFiles = root.getChildren().findChild("setup"); // NOI18N if (configFiles == null) { return null; } return NodeOp.findChild(configFiles, fo.getName()); }
Node.Handle rCH = rootContext.getHandle(); fields.put("root", rCH); // NOI18N fields.put("rootName", rootContext.getDisplayName()); // NOI18N explored = null; } else if (isUnderRoot(exploredContext)) { explored = NodeOp.createPath(exploredContext, rootContext); } else { explored = null; selected.add(NodeOp.createPath(selectedNodes[i], rootContext));
/** Overrides superclass method. Initializes editor component. */ protected void initializeCloneableEditor (CloneableEditor editor) { DataObject obj = getDataObject(); if(obj.isValid()) { org.openide.nodes.Node ourNode = obj.getNodeDelegate(); editor.setActivatedNodes(new org.openide.nodes.Node[] {ourNode}); editor.setIcon(ourNode.getIcon (java.beans.BeanInfo.ICON_COLOR_16x16)); NodeListener nl = new DataNodeListener(editor); ourNode.addNodeListener(org.openide.nodes.NodeOp.weakNodeListener (nl, ourNode)); nodeL = nl; } }
/** Converts path of strings to TreePath if exists null otherwise */ private TreePath stringPath2TreePath(String[] sp) { try { Node n = NodeOp.findPath(getRootContext(), sp); // Create the tree path TreeNode tns[] = new TreeNode[sp.length + 1]; for (int i = sp.length; i >= 0; i--) { tns[i] = Visualizer.findVisualizer(n); n = n.getParentNode(); } return new TreePath(tns); } catch (NodeNotFoundException e) { return null; } } }
/** Creates new VisualizerNode * @param n node to refer to */ private VisualizerNode(Node n) { node = n; hashCode = System.identityHashCode(node); // attach as a listener node.addNodeListener(NodeOp.weakNodeListener(this, node)); // uiListener = WeakListener.propertyChange (this, null); // UIManager.addPropertyChangeListener (uiListener); name = UNKNOWN; displayName = UNKNOWN; shortDescription = UNKNOWN; }
actionsByNode[n] = nodes[n].getActions(false); actionsByNode[n] = getDefaultActions();
popup = Utilities.actionsToPopup(manager.getExploredContext().getActions(true), this); } else { Action[] actions = NodeOp.findActions(manager.getSelectedNodes()); popup = Utilities.actionsToPopup(actions, this);
void createExtendedPopup(int xpos, int ypos, JMenu newMenu) { Node[] ns = manager.getSelectedNodes(); JPopupMenu popup = null; if (ns.length > 0) { // if any nodes are selected --> find theirs actions Action[] actions = NodeOp.findActions(ns); popup = Utilities.actionsToPopup(actions, this); } else { // if none node is selected --> get context actions from view's root if (manager.getRootContext() != null) { popup = manager.getRootContext().getContextMenu(); } } int cnt = 0; if (popup == null) { popup = SystemAction.createPopupMenu(new SystemAction[] { }); } popup.add(newMenu); createPopup(xpos, ypos, popup); }
private boolean equalNodes (Node[] arr1, Node[] arr2) { // generic tests if (!Arrays.equals (arr1, arr2)) return false; if (arr1 == null || arr1.length == 0) return true; // compare paths from each node to root int i = 0; while ( i < arr1.length && Arrays.equals ( NodeOp.createPath (arr1[i], null), NodeOp.createPath (arr2[i], null))) { i++; } return i == arr1.length; }