-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix group search performance #3553
Changes from 3 commits
08d8a2c
2689faa
12aab7e
4246be7
3092915
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
|
||
import java.lang.reflect.InvocationTargetException; | ||
import java.lang.reflect.Method; | ||
import java.time.Duration; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Optional; | ||
|
@@ -47,6 +48,8 @@ | |
import org.controlsfx.control.textfield.CustomTextField; | ||
import org.controlsfx.control.textfield.TextFields; | ||
import org.fxmisc.easybind.EasyBind; | ||
import org.reactfx.util.FxTimer; | ||
import org.reactfx.util.Timer; | ||
|
||
public class GroupTreeController extends AbstractController<GroupTreeViewModel> { | ||
|
||
|
@@ -87,7 +90,13 @@ public void initialize() { | |
this::updateSelection | ||
); | ||
|
||
viewModel.filterTextProperty().bind(searchField.textProperty()); | ||
// We try to to prevent publishing changes in the searchfield directly to the search task that takes some time | ||
// for larger group structures. | ||
final Timer searchTask = FxTimer.create(Duration.ofMillis(400), () -> { | ||
LOGGER.info("Run Search " + searchField.getText()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think debug level is enough. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That log is really only for testing so that I could inspect when a new search was triggered and if my "reset the timer on new key" does actually work. This will be removed. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can the log level be changed to "debug" and the logging settings adjusted accordingly for you? |
||
viewModel.filterTextProperty().setValue(searchField.textProperty().getValue()); | ||
}); | ||
searchField.textProperty().addListener((observable, oldValue, newValue) -> searchTask.restart()); | ||
|
||
groupTree.rootProperty().bind( | ||
EasyBind.map(viewModel.rootGroupProperty(), | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think, it makes sense to extract this code to a helper method in
BindingsHelper
.