-
-
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
Performance improvements for GUI start up #5423
Changes from all commits
08c5141
7471e17
c0ccee9
bc8bce6
3f2dd7d
90e4a92
2edec2a
588dca5
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 |
---|---|---|
|
@@ -143,10 +143,12 @@ public class BasePanel extends StackPane { | |
// the query the user searches when this BasePanel is active | ||
private Optional<SearchQuery> currentSearchQuery = Optional.empty(); | ||
private Optional<DatabaseChangeMonitor> changeMonitor = Optional.empty(); | ||
private JabRefExecutorService executorService; | ||
|
||
public BasePanel(JabRefFrame frame, BasePanelPreferences preferences, BibDatabaseContext bibDatabaseContext, ExternalFileTypes externalFileTypes) { | ||
this.preferences = Objects.requireNonNull(preferences); | ||
this.frame = Objects.requireNonNull(frame); | ||
this.executorService = JabRefExecutorService.INSTANCE; | ||
this.bibDatabaseContext = Objects.requireNonNull(bibDatabaseContext); | ||
this.externalFileTypes = Objects.requireNonNull(externalFileTypes); | ||
this.undoManager = frame.getUndoManager(); | ||
|
@@ -674,7 +676,7 @@ private void createMainTable() { | |
String clearSearch = "clearSearch"; | ||
mainTable.getInputMap().put(Globals.getKeyPrefs().getKey(KeyBinding.CLEAR_SEARCH), clearSearch); | ||
mainTable.getActionMap().put(clearSearch, new AbstractAction() { | ||
|
||
@Override | ||
public void actionPerformed(ActionEvent e) { | ||
// need to close these here, b/c this action overshadows the responsible actions when the main table is selected | ||
|
@@ -695,9 +697,9 @@ public void actionPerformed(ActionEvent e) { | |
} | ||
} | ||
}); | ||
|
||
mainTable.getActionMap().put(Actions.CUT, new AbstractAction() { | ||
|
||
@Override | ||
public void actionPerformed(ActionEvent e) { | ||
try { | ||
|
@@ -708,7 +710,7 @@ public void actionPerformed(ActionEvent e) { | |
} | ||
}); | ||
mainTable.getActionMap().put(Actions.COPY, new AbstractAction() { | ||
|
||
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. Please double check your IDE config. We recommend IntelliJ. See https://github.com/jabref/jabref/wiki/Guidelines-for-setting-up-a-local-workspace for detailed steps. Please let @Siedlerchr know if you use Eclipse. Reason: We do not want to have code changes only because of a style. 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 am using IntelliJ IDE and followed the IntelliJ IDEA Code Style Configuration (https://github.com/JabRef/jabref/tree/master/config) before posting any commits to this project. Therefore the malformed code style has been in the file before I made any changes and has been corrected by the IDE automatically. 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. Interesting. Did you format all code? - At the diff of all the files (button on GitHub) there were spaces introduced to an empty line. 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. Yes, I always format the whole file after any changes (for example to remove unused imports). But actually I noticed something odd going on here. Eventhough I had the JabRef code style configured, it was still overridden by the default editor config (for some reason). This should be fixed by now and we got proper formatting as desired. |
||
@Override | ||
public void actionPerformed(ActionEvent e) { | ||
try { | ||
|
@@ -719,7 +721,7 @@ public void actionPerformed(ActionEvent e) { | |
} | ||
}); | ||
mainTable.getActionMap().put(Actions.PASTE, new AbstractAction() { | ||
|
||
@Override | ||
public void actionPerformed(ActionEvent e) { | ||
try { | ||
|
@@ -747,11 +749,12 @@ public void setupMainPanel() { | |
splitPane.getItems().add(pane); | ||
|
||
// Set up name autocompleter for search: | ||
instantiateSearchAutoCompleter(); | ||
executorService.execute(() -> { | ||
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 would leave the 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. Fixed |
||
instantiateSearchAutoCompleter(); | ||
setupAutoCompletion(); | ||
}); | ||
this.getDatabase().registerListener(new SearchAutoCompleteListener()); | ||
|
||
setupAutoCompletion(); | ||
|
||
// Saves the divider position as soon as it changes | ||
// We need to keep a reference to the subscription, otherwise the binding gets garbage collected | ||
dividerPositionSubscription = EasyBind.monadic(Bindings.valueAt(splitPane.getDividers(), 0)) | ||
|
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.
Did you tried if this works (i.e. if JabRef still starts and loads the databases)? That would be cool, but I fear that there might be an exception thrown as things are not initialized correctly on the javafx thread.
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.
Well, both lines work pretty similar, which is to open the databases at some point in the future. The only difference is, that it's no longer executed by the JavaFX thread. That prevents any GUI freeze on startup. In my opinion the GUI has to be able to start up completely empty and get the data fed in as it's loaded. So in case that you are right and the program does not start correctly anymore due to this change, then we got a clear indicator for some bad code smell somewhere else in the project. Anyway - I'll test it to see how the program behaves. Just to make sure what's going on exactly.
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.
You are of course completely right. It should work in principle. However, the GUI code is smelly at some points and the database handling is some of the extra smelly parts. This is why I'm a bit afraid it doesn't work. If it does, perfect and we can merge! Otherwise I would leave the current solution for now.
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.
Alright, I finally managed to test it and it seems working to me. I imported several (smaller) databases and restarted the program a few times. Nothing too concerning happend. Therefore I think this is good to go.
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.
"Nothing too concerning happend. “
Sounds convincing 😂
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.
If @matthiasgeiger is convinced, then I'm too! As already a few devs had a look at this PR, I'll merge.