mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
use our own getVisibleRowCount() because the standard one returns 20
This commit is contained in:
+3
-15
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -70,7 +70,7 @@ public class ContentEntryTreeEditor {
|
||||
protected final Tree myTree;
|
||||
private FileSystemTreeImpl myFileSystemTree;
|
||||
private final JPanel myTreePanel;
|
||||
private final DefaultMutableTreeNode EMPTY_TREE_ROOT = new DefaultMutableTreeNode(ProjectBundle.message("module.paths.empty.node"));
|
||||
private final TreeNode EMPTY_TREE_ROOT = new DefaultMutableTreeNode(ProjectBundle.message("module.paths.empty.node"));
|
||||
protected final DefaultActionGroup myEditingActionsGroup;
|
||||
private ContentEntryEditor myContentEntryEditor;
|
||||
private final MyContentEntryEditorListener myContentEntryEditorListener = new MyContentEntryEditorListener();
|
||||
@@ -205,7 +205,7 @@ public class ContentEntryTreeEditor {
|
||||
if (myFileSystemTree != null) {
|
||||
myFileSystemTree.updateTree();
|
||||
final DefaultTreeModel model = (DefaultTreeModel)myTree.getModel();
|
||||
final int visibleRowCount = myTree.getVisibleRowCount();
|
||||
final int visibleRowCount = TreeUtil.getVisibleRowCount(myTree);
|
||||
for (int row = 0; row < visibleRowCount; row++) {
|
||||
final TreePath pathForRow = myTree.getPathForRow(row);
|
||||
if (pathForRow != null) {
|
||||
@@ -218,18 +218,6 @@ public class ContentEntryTreeEditor {
|
||||
}
|
||||
}
|
||||
|
||||
private static class MarkSourceToggleActionsGroup extends DefaultActionGroup {
|
||||
public MarkSourceToggleActionsGroup(String groupName, final Icon rootIcon) {
|
||||
super(groupName, true);
|
||||
getTemplatePresentation().setIcon(rootIcon);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean displayTextInToolbar() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private class MyContentEntryEditorListener extends ContentEntryEditorListenerAdapter {
|
||||
@Override
|
||||
public void sourceFolderAdded(@NotNull ContentEntryEditor editor, SourceFolder folder) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -297,7 +297,7 @@ public final class TreeUtil {
|
||||
private static IndexTreePathState removeLastPathComponent(@NotNull final DefaultTreeModel model, @NotNull final TreePath pathToBeRemoved) {
|
||||
final IndexTreePathState selectionState = new IndexTreePathState(pathToBeRemoved);
|
||||
if (((MutableTreeNode) pathToBeRemoved.getLastPathComponent()).getParent() == null) return selectionState;
|
||||
model.removeNodeFromParent((MutableTreeNode) pathToBeRemoved.getLastPathComponent());
|
||||
model.removeNodeFromParent((MutableTreeNode)pathToBeRemoved.getLastPathComponent());
|
||||
return selectionState;
|
||||
}
|
||||
|
||||
@@ -661,7 +661,7 @@ public final class TreeUtil {
|
||||
return row;
|
||||
}
|
||||
|
||||
private static int getVisibleRowCount(@NotNull final JTree tree) {
|
||||
public static int getVisibleRowCount(@NotNull final JTree tree) {
|
||||
final Rectangle visible = tree.getVisibleRect();
|
||||
|
||||
if (visible == null) return 0;
|
||||
@@ -677,6 +677,17 @@ public final class TreeUtil {
|
||||
return count;
|
||||
}
|
||||
|
||||
/**
|
||||
* works correctly for trees with fixed row height only.
|
||||
* For variable height trees (e.g. trees with custom tree node renderer) use the {@link #getVisibleRowCount(JTree)} which is slower
|
||||
*/
|
||||
public static int getVisibleRowCountForFixedRowHeight(@NotNull final JTree tree) {
|
||||
// myTree.getVisibleRowCount returns 20
|
||||
Rectangle bounds = tree.getRowBounds(0);
|
||||
int rowHeight = bounds == null ? 0 : bounds.height;
|
||||
return rowHeight == 0 ? tree.getVisibleRowCount() : tree.getVisibleRect().height / rowHeight;
|
||||
}
|
||||
|
||||
@SuppressWarnings({"HardCodedStringLiteral"})
|
||||
public static void installActions(@NotNull final JTree tree) {
|
||||
tree.getActionMap().put("scrollUpChangeSelection", new AbstractAction() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -408,7 +408,7 @@ public class TreePopupImpl extends WizardPopup implements TreePopup {
|
||||
|
||||
Rectangle visibleRect = getVisibleRect();
|
||||
int rowForLocation = getClosestRowForLocation(0, visibleRect.y);
|
||||
for (int i = rowForLocation; i < rowForLocation + getVisibleRowCount() + 1; i++) {
|
||||
for (int i = rowForLocation; i < rowForLocation + TreeUtil.getVisibleRowCount(this) + 1; i++) {
|
||||
final TreePath eachPath = getPathForRow(i);
|
||||
if (eachPath == null) continue;
|
||||
|
||||
|
||||
@@ -310,9 +310,7 @@ public class UsageViewImpl implements UsageView, UsageModelTracker.UsageModelTra
|
||||
|
||||
private int getVisibleRowCount() {
|
||||
// myTree.getVisibleRowCount returns 20
|
||||
Rectangle bounds = myTree.getRowBounds(0);
|
||||
int rowHeight = bounds == null ? 0 : bounds.height;
|
||||
return rowHeight == 0 ? myTree.getVisibleRowCount() : myTree.getVisibleRect().height / rowHeight;
|
||||
return TreeUtil.getVisibleRowCountForFixedRowHeight(myTree);
|
||||
}
|
||||
|
||||
private void setupCentralPanel() {
|
||||
|
||||
Reference in New Issue
Block a user