/** Finds VisualizerNode for given node. * @param ch the children this visualizer should belong to * @param n the node * @return the visualizer or null */ public static synchronized VisualizerNode getVisualizer(VisualizerChildren ch, Node n, boolean create) { TEMPLATE.hashCode = System.identityHashCode(n); TEMPLATE.node = n; Reference<VisualizerNode> r = cache.get(TEMPLATE); TEMPLATE.hashCode = 0; TEMPLATE.node = null; VisualizerNode v = (r == null) ? null : r.get(); if (v == null) { if (!create) { return null; } v = new VisualizerNode(n); cache.put(v, new WeakReference<VisualizerNode>(v)); } if (ch != null) { v.parent = ch; } return v; }
/** Adds visualizer listener. */ public synchronized void addNodeModel(NodeModel l) { add(NodeModel.class, l); }
public void run () { VisualizerNode v = (VisualizerNode)getRoot (); VisualizerNode nr = VisualizerNode.getVisualizer (null, root); if (v == nr) { // no change return; } v.removeNodeModel (listener ()); nr.addNodeModel (listener ()); setRoot (nr); } });
@Override public void run() { VisualizerNode v = (VisualizerNode) getRoot(); VisualizerNode nr = VisualizerNode.getVisualizer(null, root); if (v == nr) { // no change return; } v.removeNodeModel(listener()); nr.addNodeModel(listener()); setRoot(nr); if (visHolder != null) { visHolder.add(nr.getChildren()); visHolder.removeRecur(v.getChildren()); } } }
final String getToolTipTextImpl(MouseEvent event) { if (event != null) { Point p = event.getPoint(); int row = locationToIndex(p); if (row >= 0) { VisualizerNode v = (VisualizerNode) model.getElementAt(row); String tooltip = v.getShortDescription(); String displayName = v.getDisplayName(); if ((tooltip != null) && !tooltip.equals(displayName)) { return tooltip; } } } return null; }
if (this != parent.getChildren()) { Object[] listeners = p.getListenerList(); for (int i = listeners.length - 1; i >= 0; i -= 2) { ((NodeModel) listeners[i]).removed(ev); p = (VisualizerNode) p.getParent(); this.parent.notifyVisualizerChildrenChange(true, this);
String text = vis.getHtmlDisplayName(); boolean isHtml = text != null; if (!isHtml) { text = vis.getDisplayName();
/** Getter for list of children of this visualizer. * @return list of VisualizerNode objects */ public VisualizerChildren getChildren() { return getChildren(true); }
/** Notification of children addded event. Modifies the list of nodes * and fires info to all listeners. */ public void added(VisualizerEvent.Added ev) { if (this != parent.getChildren()) { // children were replaced, quit processing event return; } snapshot = ev.getSnapshot(); ListIterator<VisualizerNode> it = getVisNodes(true).listIterator(); int[] indxs = ev.getArray(); int current = 0; int inIndxs = 0; while (inIndxs < indxs.length) { while (current++ < indxs[inIndxs]) { it.next(); } it.add(null); inIndxs++; } recomputeIndexes(null); VisualizerNode p = this.parent; while (p != null) { Object[] listeners = p.getListenerList(); for (int i = listeners.length - 1; i >= 0; i -= 2) { ((NodeModel) listeners[i]).added(ev); } p = (VisualizerNode) p.getParent(); } }
Icon getIcon(boolean opened, boolean large) { int newCacheType = getCacheType(opened, large); if (cachedIconType != newCacheType) { int iconType = large ? BeanInfo.ICON_COLOR_32x32 : BeanInfo.ICON_COLOR_16x16; Image image; try { image = opened ? node.getOpenedIcon(iconType) : node.getIcon(iconType); // bugfix #28515, check if getIcon contract isn't broken if (image == null) { String method = opened ? "getOpenedIcon" : "getIcon"; // NOI18N LOG.warning( "Node \"" + node.getName() + "\" [" + node.getClass().getName() + "] cannot return null from " + method + "(). See Node." + method + " contract." ); // NOI18N } } catch (RuntimeException x) { LOG.log(Level.INFO, null, x); image = null; } if (image == null) { icon = getDefaultIcon(); } else { icon = ImageUtilities.image2Icon(image); } } cachedIconType = newCacheType; return icon; }
/** String name is taken from the node. */ @Override public String toString() { return getDisplayName(); }
if (--depth == 0) { return (VisualizerNode)vis.getChildAt(indx); Iterator it = vis.getChildren ().iterator (); while (it.hasNext ()) { VisualizerNode v = (VisualizerNode)it.next ();
/** Returns cached short description. * @return short description of represented node */ public String getShortDescription() { String desc = shortDescription; if (desc == UNKNOWN) { shortDescription = desc = node.getShortDescription(); } String toolTip = ImageUtilities.getImageToolTip(ImageUtilities.icon2Image(icon != null ? icon : getIcon(false, false))); if (toolTip.length() > 0) { StringBuilder str = new StringBuilder(128); str.append("<html>").append(desc).append("<br>").append(toolTip).append("</html>"); desc = str.toString(); } return desc; }
return (VisualizerNode) vis.getChildAt(indx); Enumeration it = vis.children(); while (it.hasMoreElements()) { VisualizerNode v = (VisualizerNode) it.nextElement();
visHolder.removeRecur(vn.getChildren(false)); if (selPaths != null) { TreePath path = new TreePath(vn.getPathToRoot()); for(TreePath tp : selPaths) { if (path.isDescendant(tp)) {
public String getToolTipText(MouseEvent event) { if(event != null) { Point p = event.getPoint(); int selRow = getRowForLocation(p.x, p.y); if(selRow != -1) { TreePath path = getPathForRow(selRow); VisualizerNode v = (VisualizerNode)path.getLastPathComponent(); String tooltip = v.getShortDescription(); String displayName = v.getDisplayName (); if ((tooltip != null) && !tooltip.equals (displayName)) return tooltip; } } return null; }
String text = vis.getHtmlDisplayName(); boolean isHtml = text != null; if (!isHtml) { text = vis.getDisplayName();
public javax.swing.tree.TreeNode getChildAt(int p1) { List ch = getChildren(); VisualizerNode vn = (VisualizerNode)ch.get (p1); assert vn != null : "Null child in " + ch + " from " + node; return vn; }
if (this != parent.getChildren()) { Object[] listeners = p.getListenerList(); for (int i = listeners.length - 1; i >= 0; i -= 2) { ((NodeModel) listeners[i]).reordered(ev); p = (VisualizerNode) p.getParent();
Icon getIcon(boolean opened, boolean large) { int newCacheType = getCacheType(opened, large); if (cachedIconType != newCacheType) { int iconType = large ? BeanInfo.ICON_COLOR_32x32 : BeanInfo.ICON_COLOR_16x16; Image image = opened ? node.getOpenedIcon( iconType) : node.getIcon( iconType); // bugfix #28515, check if getIcon contract isn't broken if (image == null) { String method = opened ? "getOpenedIcon" : "getIcon"; // NOI18N ErrorManager.getDefault ().log (ErrorManager.WARNING, "Node \"" + node.getName () + "\" [" + node.getClass().getName()+ "] cannot return null from " + method + "(). See Node." + method + " contract."); // NOI18N icon = getDefaultIcon (); } else { icon = new ImageIcon (image); } } cachedIconType = newCacheType; return icon; }