List of usage examples for javax.swing JTree getClass
@HotSpotIntrinsicCandidate public final native Class<?> getClass();
From source file:org.eclipse.jubula.rc.swing.tester.util.TreeOperationContext.java
/** * {@inheritDoc}//from w w w .j a v a 2 s. c o m */ public void collapseNode(Object node) { final JTree tree = (JTree) getTree(); final ClassLoader oldCl = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader(tree.getClass().getClassLoader()); final int row = getRowForTreeNode(node); final Rectangle nodeBounds = getNodeBounds(node); final boolean collapsed = tree.isCollapsed(row); boolean doAction = isExpanded(node); final IEventThreadQueuer queuer = new EventThreadQueuerAwtImpl(); queuer.invokeAndWait("scrollRowToVisible", new IRunnable() { //$NON-NLS-1$ public Object run() { tree.scrollRowToVisible(row); return null; } }); Rectangle visibleNodeBounds = getVisibleRowBounds(nodeBounds); getRobot().move(tree, visibleNodeBounds); if (doAction) { if (log.isDebugEnabled()) { log.debug((collapsed ? "Expanding" : "Collapsing") + " node: " //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + node); log.debug("Row : " + row); //$NON-NLS-1$ log.debug("Node bounds : " + visibleNodeBounds); //$NON-NLS-1$ } queuer.invokeAndWait("collapseRow", new IRunnable() { //$NON-NLS-1$ public Object run() { tree.collapseRow(row); return null; } }); } } finally { Thread.currentThread().setContextClassLoader(oldCl); } }
From source file:org.eclipse.jubula.rc.swing.tester.util.TreeOperationContext.java
/** * {@inheritDoc}/*from w w w. j av a2 s . c o m*/ */ public void expandNode(Object node) { final JTree tree = (JTree) getTree(); final ClassLoader oldCl = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader(tree.getClass().getClassLoader()); final int row = getRowForTreeNode(node); final Rectangle nodeBounds = getNodeBounds(node); final boolean collapsed = tree.isCollapsed(row); boolean doAction = !isExpanded(node); final IEventThreadQueuer queuer = new EventThreadQueuerAwtImpl(); queuer.invokeAndWait("scrollRowToVisible", new IRunnable() { //$NON-NLS-1$ public Object run() { tree.scrollRowToVisible(row); return null; } }); Rectangle visibleNodeBounds = getVisibleRowBounds(nodeBounds); getRobot().move(tree, visibleNodeBounds); if (doAction) { if (log.isDebugEnabled()) { log.debug((collapsed ? "Expanding" : "Collapsing") + " node: " //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + node); log.debug("Row : " + row); //$NON-NLS-1$ log.debug("Node bounds : " + visibleNodeBounds); //$NON-NLS-1$ } queuer.invokeAndWait("expandRow", new IRunnable() { //$NON-NLS-1$ public Object run() { tree.expandRow(row); return null; } }); } } finally { Thread.currentThread().setContextClassLoader(oldCl); } }
From source file:org.kepler.gui.AnnotatedPTree.java
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) { if (isDebugging) { log.debug(/*from w w w.ja v a 2s . c o m*/ "getTreeCellRendererComponent(" + tree.getClass().getName() + ", " + value.getClass().getName() + ", " + selected + ", " + expanded + ", " + leaf + ", " + row + ", " + hasFocus + ")"); log.debug(tree.getShowsRootHandles()); } if (value instanceof ptolemy.moml.EntityLibrary) { EntityLibrary el = (EntityLibrary) value; if (isDebugging) { log.debug(el.getName() + " " + el.getClass().getName()); } if (el instanceof KAREntityLibrary) { setOpenIcon(_packIconOpen); setClosedIcon(_packIconClosed); } else if (el instanceof FolderEntityLibrary) { setOpenIcon(_folderIconOpen); setClosedIcon(_folderIconClosed); } else if (el instanceof OntologyEntityLibrary) { setOpenIcon(_ontIconOpen); setClosedIcon(_ontIconClosed); } else if (el instanceof SearchEntityLibrary) { setOpenIcon(_searchIcon); setClosedIcon(_searchIcon); } else if (el instanceof KARErrorEntityLibrary || el instanceof RemoteKARErrorEntityLibrary) { setOpenIcon(_packIconError); setClosedIcon(_packIconError); } else if (el instanceof DownloadableKAREntityLibrary) { // Icons for the KAR files - trash cans? setOpenIcon(_packIconOpen); setClosedIcon(_packIconClosed); } else if (el instanceof RemoteRepositoryEntityLibrary) { // Icons for the Remote repositories - computers setOpenIcon(_remoteIcon); setClosedIcon(_remoteIcon); // TODO: Also make sure that the top-level "Remote Components" is a globe } else { setOpenIcon(_generalIcon); setClosedIcon(_generalIcon); } } else { if (isDebugging) log.debug("set general icon"); setOpenIcon(_generalIcon); setClosedIcon(_generalIcon); } Component c = super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus); // if the object is a NamedObj, use display name for the label // since the display name is used on the canvas. the component returned // by super.getTreeCellRenderer() uses the display name for settables. if (!(value instanceof Settable) && (value instanceof NamedObj) && (c instanceof DefaultTreeCellRenderer)) { ((DefaultTreeCellRenderer) c).setText(((NamedObj) value).getDisplayName()); } if (isDebugging) log.debug("Component: " + c.getClass().getName()); return c; }