mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
options tree: infinte selection jumping fixed
This commit is contained in:
@@ -642,6 +642,10 @@ public class AbstractTreeBuilder implements Disposable {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isSelectionBeingAdjusted() {
|
||||
return getUi().isSelectionBeingAdjusted();
|
||||
}
|
||||
|
||||
private void assertDisposed() {
|
||||
assert !isDisposed();
|
||||
}
|
||||
|
||||
@@ -182,6 +182,8 @@ public class AbstractTreeUi {
|
||||
private boolean mySelectionIsAdjusted;
|
||||
private boolean myReleaseRequested;
|
||||
|
||||
private boolean mySelectionIsBeingAdjusted;
|
||||
|
||||
private final Set<Object> myRevalidatedObjects = new HashSet<Object>();
|
||||
|
||||
private final Set<Runnable> myUserRunnables = new HashSet<Runnable>();
|
||||
@@ -3713,7 +3715,7 @@ public class AbstractTreeUi {
|
||||
}
|
||||
|
||||
Set<Object> toSelect = new HashSet<Object>();
|
||||
myTree.clearSelection();
|
||||
clearSelection();
|
||||
ContainerUtil.addAll(toSelect, elements);
|
||||
if (addToSelection) {
|
||||
toSelect.addAll(currentElements);
|
||||
@@ -3734,7 +3736,7 @@ public class AbstractTreeUi {
|
||||
if (wasRootNodeInitialized()) {
|
||||
final int[] originalRows = myTree.getSelectionRows();
|
||||
if (!addToSelection) {
|
||||
myTree.clearSelection();
|
||||
clearSelection();
|
||||
}
|
||||
addNext(elementsToSelect, 0, new Runnable() {
|
||||
public void run() {
|
||||
@@ -3760,6 +3762,20 @@ public class AbstractTreeUi {
|
||||
});
|
||||
}
|
||||
|
||||
private void clearSelection() {
|
||||
mySelectionIsBeingAdjusted = true;
|
||||
try {
|
||||
myTree.clearSelection();
|
||||
}
|
||||
finally {
|
||||
mySelectionIsBeingAdjusted = false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isSelectionBeingAdjusted() {
|
||||
return mySelectionIsBeingAdjusted;
|
||||
}
|
||||
|
||||
private void restoreSelection(Set<Object> selection) {
|
||||
for (Object each : selection) {
|
||||
DefaultMutableTreeNode node = getNodeForElement(each, false);
|
||||
@@ -4564,7 +4580,7 @@ public class AbstractTreeUi {
|
||||
final UpdaterTreeState state = new UpdaterTreeState(this);
|
||||
|
||||
myTree.collapsePath(new TreePath(myTree.getModel().getRoot()));
|
||||
myTree.clearSelection();
|
||||
clearSelection();
|
||||
getRootNode().removeAllChildren();
|
||||
|
||||
myRootNodeWasQueuedToInitialize = false;
|
||||
|
||||
@@ -172,11 +172,20 @@ public class OptionsTree extends JPanel implements Disposable, OptionsEditorColl
|
||||
}
|
||||
}
|
||||
|
||||
private Configurable myQueuedConfigurable;
|
||||
|
||||
ActionCallback queueSelection(final Configurable configurable) {
|
||||
if (myBuilder.isSelectionBeingAdjusted()) {
|
||||
return new ActionCallback.Rejected();
|
||||
}
|
||||
|
||||
final ActionCallback callback = new ActionCallback();
|
||||
|
||||
myQueuedConfigurable = configurable;
|
||||
final Update update = new Update(this) {
|
||||
public void run() {
|
||||
if (configurable != myQueuedConfigurable) return;
|
||||
|
||||
if (configurable == null) {
|
||||
myTree.getSelectionModel().clearSelection();
|
||||
myContext.fireSelected(null, OptionsTree.this);
|
||||
@@ -185,6 +194,8 @@ public class OptionsTree extends JPanel implements Disposable, OptionsEditorColl
|
||||
myBuilder.getReady(this).doWhenDone(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (configurable != myQueuedConfigurable) return;
|
||||
|
||||
final EditorNode editorNode = myConfigurable2Node.get(configurable);
|
||||
FilteringTreeStructure.Node editorUiNode = myBuilder.getVisibleNodeFor(editorNode);
|
||||
if (editorUiNode == null) return;
|
||||
|
||||
Reference in New Issue
Block a user