-
-
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
Update database context in state manager after loading #9450
Changes from 1 commit
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 |
---|---|---|
|
@@ -235,22 +235,31 @@ public void onDatabaseLoadingFailed(Exception ex) { | |
dialogService.showErrorDialogAndWait(title, content, ex); | ||
} | ||
|
||
public void feedData(BibDatabaseContext bibDatabaseContext) { | ||
public void feedData(BibDatabaseContext bibDatabaseContextFromParserResult) { | ||
cleanUp(); | ||
|
||
this.bibDatabaseContext = Objects.requireNonNull(bibDatabaseContext); | ||
// this.bibDatabaseContext.getDatabase().insertEntries(bibDatabaseContextFromParserResult.getEntries()); | ||
|
||
// When you open an existing library, a library tab with a loading animation is added immediately. | ||
// At that point, the library tab is given a temporary bibDatabaseContext with no entries. | ||
// This line is necessary because, while there is already a binding that updates the active database when a new tab is added, | ||
// it doesn't handle the case when a library is loaded asynchronously. | ||
stateManager.setActiveDatabase(bibDatabaseContext); | ||
stateManager.setActiveDatabase(bibDatabaseContextFromParserResult); | ||
|
||
bibDatabaseContext.getDatabase().registerListener(this); | ||
bibDatabaseContext.getMetaData().registerListener(this); | ||
Optional<BibDatabaseContext> x = stateManager.getOpenDatabases().stream().filter(ctx -> ctx.equals(this.bibDatabaseContext)).findFirst(); | ||
|
||
x.ifPresent(s -> stateManager.getOpenDatabases().remove(s)); | ||
|
||
this.bibDatabaseContext = Objects.requireNonNull(bibDatabaseContextFromParserResult); | ||
|
||
stateManager.getOpenDatabases().add(bibDatabaseContextFromParserResult); | ||
|
||
bibDatabaseContextFromParserResult.getDatabase().registerListener(this); | ||
bibDatabaseContextFromParserResult.getMetaData().registerListener(this); | ||
Comment on lines
+255
to
+256
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. This is duplicate of LibraryTab's constructor lines 138 Proposal: Two LibraryTab constructors. One with BibDatabaseContext and one without. Add a new method "setBibDatabaseContext" including the initialization of listeners etc. Following listeners this.getDatabase().registerListener(new SearchListener());
this.getDatabase().registerListener(new IndexUpdateListener());
this.getDatabase().registerListener(new EntriesRemovedListener());
// ensure that at each addition of a new entry, the entry is added to the groups interface
this.bibDatabaseContext.getDatabase().registerListener(new GroupTreeListener());
// ensure that all entry changes mark the panel as changed
this.bibDatabaseContext.getDatabase().registerListener(this);
this.getDatabase().registerListener(new UpdateTimestampListener(preferencesService)); 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. The new constructor should have 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 just moved the lines down... And as we replace the existing object the listeners need to be replaced as well 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. We really should eventually rework the groups panel and the OpenDatabase mechanism working with CompletableFutures. 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. Completable Futures aren't that different from our BackgroundTask |
||
|
||
this.tableModel = new MainTableDataModel(getBibDatabaseContext(), preferencesService, stateManager); | ||
citationStyleCache = new CitationStyleCache(bibDatabaseContext); | ||
annotationCache = new FileAnnotationCache(bibDatabaseContext, preferencesService.getFilePreferences()); | ||
citationStyleCache = new CitationStyleCache(bibDatabaseContextFromParserResult); | ||
annotationCache = new FileAnnotationCache(bibDatabaseContextFromParserResult, preferencesService.getFilePreferences()); | ||
|
||
setupMainPanel(); | ||
setupAutoCompletion(); | ||
|
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.
Variable names
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.
Reworked. Was just a temporary leftover from yesterdays late late evening