use of javax.swing.plaf.basic.BasicTreeUI in project jdk8u_jdk by JetBrains.
the class bug8003830 method testNPEAtActionsPage.
public void testNPEAtActionsPage() {
JTree tree = new JTree();
BasicTreeUI ui = new NullReturningTreeUI();
tree.setUI(ui);
BasicTreeUI.TreePageAction tpa = ui.new TreePageAction(0, "down");
tpa.actionPerformed(new ActionEvent(tree, 0, ""));
}
use of javax.swing.plaf.basic.BasicTreeUI in project intellij-community by JetBrains.
the class DeferredIconImpl method paintIcon.
@Override
public void paintIcon(final Component c, @NotNull final Graphics g, final int x, final int y) {
if (!(myScaledDelegateIcon instanceof DeferredIconImpl && ((DeferredIconImpl) myScaledDelegateIcon).myScaledDelegateIcon instanceof DeferredIconImpl)) {
//SOE protection
myScaledDelegateIcon.paintIcon(c, g, x, y);
}
if (isDone() || myIsScheduled || PowerSaveMode.isEnabled()) {
return;
}
myIsScheduled = true;
final Component target = getTarget(c);
final Component paintingParent = SwingUtilities.getAncestorOfClass(PaintingParent.class, c);
final Rectangle paintingParentRec = paintingParent == null ? null : ((PaintingParent) paintingParent).getChildRec(c);
ourIconsCalculatingExecutor.execute(() -> {
int oldWidth = myScaledDelegateIcon.getIconWidth();
final Icon[] evaluated = new Icon[1];
final long startTime = System.currentTimeMillis();
if (myNeedReadAction) {
boolean result = ProgressIndicatorUtils.runInReadActionWithWriteActionPriority(() -> {
IconDeferrerImpl.evaluateDeferred(() -> evaluated[0] = evaluate());
if (myAutoUpdatable) {
myLastCalcTime = System.currentTimeMillis();
myLastTimeSpent = myLastCalcTime - startTime;
}
});
if (!result) {
myIsScheduled = false;
return;
}
} else {
IconDeferrerImpl.evaluateDeferred(() -> evaluated[0] = evaluate());
if (myAutoUpdatable) {
myLastCalcTime = System.currentTimeMillis();
myLastTimeSpent = myLastCalcTime - startTime;
}
}
final Icon result = evaluated[0];
myScaledDelegateIcon = result;
checkDelegationDepth();
final boolean shouldRevalidate = Registry.is("ide.tree.deferred.icon.invalidates.cache") && myScaledDelegateIcon.getIconWidth() != oldWidth;
ourLaterInvocator.offer(() -> {
setDone(result);
Component actualTarget = target;
if (actualTarget != null && SwingUtilities.getWindowAncestor(actualTarget) == null) {
actualTarget = paintingParent;
if (actualTarget == null || SwingUtilities.getWindowAncestor(actualTarget) == null) {
actualTarget = null;
}
}
if (actualTarget == null)
return;
if (shouldRevalidate) {
// revalidate will not work: JTree caches size of nodes
if (actualTarget instanceof JTree) {
final TreeUI ui = ((JTree) actualTarget).getUI();
if (ui instanceof BasicTreeUI) {
// this call is "fake" and only need to reset tree layout cache
((BasicTreeUI) ui).setLeftChildIndent(UIUtil.getTreeLeftChildIndent());
}
}
}
if (c == actualTarget) {
c.repaint(x, y, getIconWidth(), getIconHeight());
} else {
ourRepaintScheduler.pushDirtyComponent(actualTarget, paintingParentRec);
}
});
});
}
use of javax.swing.plaf.basic.BasicTreeUI in project intellij-community by JetBrains.
the class CommittedChangeListRenderer method getRowX.
public static int getRowX(JTree tree, int depth) {
if (tree == null)
return 0;
final TreeUI ui = tree.getUI();
if (ui instanceof BasicTreeUI) {
final BasicTreeUI treeUI = ((BasicTreeUI) ui);
return (treeUI.getLeftChildIndent() + treeUI.getRightChildIndent()) * depth;
}
final int leftIndent = UIUtil.getTreeLeftChildIndent();
final int rightIndent = UIUtil.getTreeRightChildIndent();
return (leftIndent + rightIndent) * depth;
}
use of javax.swing.plaf.basic.BasicTreeUI in project intellij-community by JetBrains.
the class UsageViewImpl method clearRendererCache.
private void clearRendererCache() {
ApplicationManager.getApplication().assertIsDispatchThread();
// to avoid quadratic row enumeration
if (expandingAll)
return;
// clear renderer cache of node preferred size
TreeUI ui = myTree.getUI();
if (ui instanceof BasicTreeUI) {
AbstractLayoutCache treeState = ReflectionUtil.getField(BasicTreeUI.class, ui, AbstractLayoutCache.class, "treeState");
Rectangle visibleRect = myTree.getVisibleRect();
int rowForLocation = myTree.getClosestRowForLocation(0, visibleRect.y);
int visibleRowCount = getVisibleRowCount();
for (int i = rowForLocation + visibleRowCount + 1; i >= rowForLocation; i--) {
final TreePath eachPath = myTree.getPathForRow(i);
if (eachPath == null)
continue;
treeState.invalidatePathBounds(eachPath);
}
myTree.repaint(visibleRect);
} else {
myTree.setCellRenderer(myUsageViewTreeCellRenderer);
}
}
use of javax.swing.plaf.basic.BasicTreeUI in project intellij-community by JetBrains.
the class ChangesTreeList method setChildIndent.
private void setChildIndent(boolean isFlat) {
BasicTreeUI treeUI = (BasicTreeUI) getUI();
treeUI.setLeftChildIndent(!isFlat ? UIUtil.getTreeLeftChildIndent() : 0);
treeUI.setRightChildIndent(!isFlat ? UIUtil.getTreeRightChildIndent() : 0);
}
Aggregations