@Override Node nodeForRow(int row) { return Visualizer.findNode(tree.getPathForRow(row).getLastPathComponent()); }
public List<String[]> getExpandedPaths() { List<String[]> result = new ArrayList<String[]>(); TreeNode rtn = Visualizer.findVisualizer(getRootContext()); TreePath tp = new TreePath(rtn); // Get the root Enumeration<TreePath> paths = tree.getExpandedDescendants(tp); if (null != paths) { while (paths.hasMoreElements()) { TreePath ep = paths.nextElement(); Node en = Visualizer.findNode(ep.getLastPathComponent()); String[] path = NodeOp.createPath(en, getRootContext()); result.add(path); } } return result; }
/** Implements <code>CellEditorListener</code> interface method. */ public void editingStopped(ChangeEvent e) { //CellEditor sometimes(probably after stopCellEditing() call) gains one focus but loses two if (stopped) { return; } stopped = true; TreePath lastP = lastPath; if (lastP != null) { Node n = Visualizer.findNode(lastP.getLastPathComponent()); if ((n != null) && n.canRename()) { String newStr = (String) getCellEditorValue(); ViewUtil.nodeRename(n, newStr); } } }
private boolean toggle( TreePath treePath ) { if( treePath == null ) return false; Node node = Visualizer.findNode( treePath.getLastPathComponent() ); if( node == null ) return false ; Collection<? extends FixDescription> fixes = node.getLookup().lookupAll(FixDescription.class); if (!fixes.isEmpty()) { State s = CheckRenderer.getCheckState(fixes); boolean select = s != State.SELECTED; for (FixDescription fd : fixes) { fd.setSelected(select); } return true; // if( description.isSelectable() ) { // description.setSelected( !description.isSelected() ); // return true; // } else { // boolean newState = !description.isSelected(); // description.setSelected(newState); // toggleChildren( description.getSubs(), newState ); // } } return false; }
TreePath lastP = lastPath; if (lastP != null) { Node n = Visualizer.findNode (lastP.getLastPathComponent()); if (n != null && n.canRename ()) { String newStr = (String) getCellEditorValue(); try { if (!n.getName ().equals (newStr)) { n.setName (newStr);
Node node = Visualizer.findNode (selPath.getLastPathComponent()); Action a = node.getPreferredAction(); if (a != null) { a = ((ContextAwareAction)a).createContextAwareInstance(node.getLookup ());
@Override public void mouseClicked(MouseEvent e) { tree.stopEditing(); int selRow = tree.getRowForLocation(e.getX(), e.getY()); if ((selRow != -1) && SwingUtilities.isLeftMouseButton(e) && MouseUtils.isDoubleClick(e)) { // Default action. if (defaultActionEnabled) { TreePath selPath = tree.getPathForLocation(e.getX(), e.getY()); Node node = Visualizer.findNode(selPath.getLastPathComponent()); Action a = takeAction(node.getPreferredAction(), node); if (a != null) { if (a.isEnabled()) { a.actionPerformed(new ActionEvent(node, ActionEvent.ACTION_PERFORMED, "")); // NOI18N } else { Toolkit.getDefaultToolkit().beep(); } e.consume(); return; } } if (tree.isExpanded(selRow)) { tree.collapseRow(selRow); } else { tree.expandRow(selRow); } } }
/** Called under Children.MUTEX to refresh the currently selected nodes. */ public void run () { if (readAccessPaths == null) { return; } TreePath[] paths = readAccessPaths; // non null value caused leak in // ComponentInspector // When the last Form was closed then the ComponentInspector was // closed as well. Since this variable was not null - // last selected Node (RADComponentNode) was held ---> FormManager2 was held, etc. readAccessPaths = null; java.util.List ll = new java.util.ArrayList(paths.length); for (int i = 0; i < paths.length; i++) { Node n = Visualizer.findNode (paths[i].getLastPathComponent ()); if (n == manager.getRootContext() || n.getParentNode() != null) { ll.add (n); } } callSelectionChanged ((Node[])ll.toArray (new Node[ll.size ()])); }
/** * Tries to expand nodes selected in the explorer manager. */ private void expandSelection() { Node[] arr = manager.getSelectedNodes (); for (int i = 0; i < arr.length; i++) { if ( (arr[i].getParentNode() == null) && (! outline.isRootVisible())) { // don't try to show root if it is invisible continue; } TreeNode tn = Visualizer.findVisualizer(arr[i]); if (tn != null) { ArrayList<TreeNode> al = new ArrayList<TreeNode> (); while (tn != null) { al.add(tn); tn = tn.getParent(); } Collections.reverse(al); TreePath tp = new TreePath(al.toArray()); while ((tp != null) && (tp.getPathCount() > 0)) { tp = tp.getParentPath(); if (tp != null) { outline.expandPath(tp); } } } } }
private int rowForNode(Node n) { TreeNode tn = Visualizer.findVisualizer(n); if (tn != null) { ArrayList<TreeNode> al = new ArrayList<TreeNode> (); while (tn != null) { al.add(tn); tn = tn.getParent(); } Collections.reverse(al); TreePath tp = new TreePath(al.toArray()); int row = outline.getLayoutCache().getRowForPath(tp); return row; } return -1; }
public javax.swing.Icon getIcon(Object o) { Node n = Visualizer.findNode(o); if (n == null) { throw new IllegalStateException("TreeNode must be VisualizerNode but was: " + o + " of class " + o.getClass().getName()); } boolean expanded = false; if (o instanceof TreeNode) { TreeNode tn = (TreeNode)o; ArrayList<TreeNode> al = new ArrayList<TreeNode> (); while (tn != null) { al.add(tn); tn = tn.getParent(); } Collections.reverse(al); TreePath tp = new TreePath(al.toArray()); AbstractLayoutCache layout = table.getLayoutCache(); expanded = layout.isExpanded(tp); } java.awt.Image image = null; if (expanded) { image = n.getOpenedIcon(java.beans.BeanInfo.ICON_COLOR_16x16); } else { image = n.getIcon(java.beans.BeanInfo.ICON_COLOR_16x16); } return new ImageIcon(image); }
/** 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; } } }
boolean isSelected, boolean expanded, boolean leaf, int row, boolean hasFocus) { Node n = Visualizer.findNode(value); Collection<? extends FixDescription> descriptions = n.getLookup().lookupAll(FixDescription.class); String displayName = n.getHtmlDisplayName(); displayName = "<html>" + displayName; } else { displayName = n.getDisplayName();
selectorLabel.setForeground(foreground); mediaLabel.setForeground(foreground); Node node = Visualizer.findNode(value); Rule rule = node.getLookup().lookup(Rule.class); if (rule != null) { String matchedNode = node.getDisplayName(); matchedNodeLabel.setText("<html>"+matchedNode); // NOI18N String ruleLocation = null; RuleInfo ruleInfo = node.getLookup().lookup(RuleInfo.class); if (ruleInfo != null && ruleInfo.getMetaSourceFile() != null && ruleInfo.getMetaSourceLine() != -1) { ruleLocation = ruleInfo.getMetaSourceFile();
@Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { Node node = Visualizer.findNode(value); thumbImage = node.getIcon(BeanInfo.ICON_COLOR_32x32); this.selected = isSelected; label.setOpaque(selected); if (selected) { label.setBackground(UIManager.getColor("List.selectionBackground")); label.setForeground(UIManager.getColor("List.selectionForeground")); } else { label.setBackground(UIManager.getColor("Label.background")); label.setForeground(UIManager.getColor("Label.foreground")); } this.focused = cellHasFocus; this.label.setText(node.getDisplayName()); return this; }
private static Node[] getChildrenInDisplayedOrder(Node parent, OutlineView outlineView) { Outline outline = outlineView.getOutline(); Node[] unsortedChildren = parent.getChildren().getNodes(true); int rows = outlineView.getOutline().getRowCount(); int start = findRowIndexInOutline(parent, outline, rows); if (start == -1 && parent != ExplorerManager.find(outlineView).getRootContext()) { return unsortedChildren; } List<Node> children = new LinkedList<Node>(); for (int j = start + 1; j < rows; j++) { int childModelIndex = outline.convertRowIndexToModel(j); if (childModelIndex == -1) { continue; } Object childObject = outline.getModel().getValueAt( childModelIndex, 0); Node childNode = Visualizer.findNode(childObject); if (childNode.getParentNode() == parent) { children.add(childNode); } else if (children.size() == unsortedChildren.length) { break; } } return children.toArray(new Node[children.size()]); }
if (path != null && path.getPathCount() == 1) { node = (Node) value; } else { node = Visualizer.findNode(value);
@Override public String getColumnName(int column) { return (column == 0) ? Visualizer.findNode(tree.getModel().getRoot()).getDisplayName() : nodeTableModel.getColumnName(column - 1); }
public String getDisplayName(Object o) { Node n = Visualizer.findNode(o); if (n == null) { throw new IllegalStateException("TreeNode must be VisualizerNode but was: " + o + " of class " + o.getClass().getName()); } String text = n.getHtmlDisplayName(); if( null == text ) text = n.getDisplayName(); return text; }