-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
[WIP] Batch Insert entries #5691
Changes from 62 commits
80e8377
48cb7fd
923b40e
a0ffcb5
b08ae88
3a830a8
4e57a46
b990e0d
3122e67
aac840c
90c27f1
a0cafc4
868deed
2afb868
460f44a
f11389e
f535a0b
77ff450
b0805cc
7ac7a1c
8255ad2
3b8dfea
5f1b811
c41dc17
bb88484
4c97c64
30d8d51
125d33a
5cf5965
1df2869
0f5d76f
13abf0c
455ce0c
17f04b0
30e5087
8ae5098
214e958
5f0e7f5
2824aed
940bf78
3e71219
a90c44e
648c5da
b0f585a
c6300e5
a187b42
d6d15a7
f8c94cc
aaf73e7
120b6d5
b023741
ef18bb0
f74717f
4adc9b0
3890e9d
2aa889a
dfe273e
fe3f830
1fd76fd
0e9f6a2
b7bb130
153fab3
6400f98
ee1bbc2
250d405
8913d4b
d673f55
ce86e71
5720593
0601c4c
d8e3ac2
772f8f6
454ccd0
2fb860a
039e223
790e7f2
76845c2
30fc8e5
a192c2f
a74381f
f2a517f
3f78aa9
d42890e
85ff37b
659db97
a2a619c
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 |
---|---|---|
|
@@ -161,7 +161,7 @@ public void runFetcherWorker() { | |
} else { | ||
// Regenerate CiteKey of imported BibEntry | ||
new BibtexKeyGenerator(basePanel.getBibDatabaseContext(), prefs.getBibtexKeyPatternPreferences()).generateAndSetKey(entry); | ||
basePanel.insertEntry(entry); | ||
basePanel.insertEntry(entry); // Should this be basePanel.getDatabase().insertEntry(entry);? | ||
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 called method does more: set automatic fields, do an unduable event, marks the database changed, selects the entry. Maybe, one does not want to have the entry marked? However, I would guess so as after a fetching (context of this method), I want to know which entry was fetched. 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. Okay, let me make sure I understand. It sounds like 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. @tobiasdiez Is this the idea? I really like the long code where the entry is updated (timestamp, owner field) and selected. This makes JabRef a better management software, not just BibTeX editing software. 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 |
||
} | ||
searchSuccesfulProperty.set(true); | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
package org.jabref.gui.autocompleter; | ||
|
||
import org.jabref.model.database.event.EntryAddedEvent; | ||
import java.util.List; | ||
|
||
import org.jabref.model.database.event.EntriesAddedEvent; | ||
import org.jabref.model.entry.BibEntry; | ||
import org.jabref.model.entry.event.EntryChangedEvent; | ||
|
||
import com.google.common.eventbus.Subscribe; | ||
|
@@ -17,8 +20,11 @@ public AutoCompleteUpdater(SuggestionProviders suggestionProviders) { | |
} | ||
|
||
@Subscribe | ||
public void listen(EntryAddedEvent addedEntryEvent) { | ||
suggestionProviders.indexEntry(addedEntryEvent.getBibEntry()); | ||
public void listen(EntriesAddedEvent addedEntryEvent) { | ||
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 variable be renamed to |
||
List<BibEntry> entries = addedEntryEvent.getBibEntries(); | ||
for (BibEntry entry : entries) { | ||
suggestionProviders.indexEntry(entry); | ||
} | ||
} | ||
|
||
@Subscribe | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,14 @@ | ||
package org.jabref.gui.collab; | ||
|
||
import java.util.Collections; | ||
|
||
import javafx.scene.Node; | ||
|
||
import org.jabref.Globals; | ||
import org.jabref.JabRefGUI; | ||
import org.jabref.gui.preview.PreviewViewer; | ||
import org.jabref.gui.undo.NamedCompound; | ||
import org.jabref.gui.undo.UndoableInsertEntry; | ||
import org.jabref.gui.undo.UndoableInsertEntries; | ||
import org.jabref.logic.l10n.Localization; | ||
import org.jabref.model.database.BibDatabaseContext; | ||
import org.jabref.model.entry.BibEntry; | ||
|
@@ -23,7 +25,7 @@ public EntryAddChangeViewModel(BibEntry diskEntry) { | |
@Override | ||
public void makeChange(BibDatabaseContext database, NamedCompound undoEdit) { | ||
database.getDatabase().insertEntry(diskEntry); | ||
undoEdit.addEdit(new UndoableInsertEntry(database.getDatabase(), diskEntry)); | ||
undoEdit.addEdit(new UndoableInsertEntries(database.getDatabase(), Collections.singletonList(diskEntry))); | ||
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. Having users of the method forced to wrap the parameter into 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 makes sense. My original purpose was to discourage users from using the singular version, but it would make it more consistent in that I have a singular 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. Would this just require a new constructor for 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. A new constructor should be sufficient. |
||
} | ||
|
||
@Override | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,16 +32,15 @@ | |
import org.jabref.gui.externalfiletype.ExternalFileTypes; | ||
import org.jabref.gui.keyboard.KeyBinding; | ||
import org.jabref.gui.keyboard.KeyBindingRepository; | ||
import org.jabref.gui.undo.NamedCompound; | ||
import org.jabref.gui.undo.UndoableInsertEntry; | ||
import org.jabref.gui.undo.UndoableInsertEntries; | ||
import org.jabref.gui.util.ControlHelper; | ||
import org.jabref.gui.util.CustomLocalDragboard; | ||
import org.jabref.gui.util.DefaultTaskExecutor; | ||
import org.jabref.gui.util.ViewModelTableRowFactory; | ||
import org.jabref.logic.l10n.Localization; | ||
import org.jabref.logic.util.UpdateField; | ||
import org.jabref.model.database.BibDatabaseContext; | ||
import org.jabref.model.database.event.AllInsertsFinishedEvent; | ||
import org.jabref.model.database.event.EntriesAddedEvent; | ||
import org.jabref.model.entry.BibEntry; | ||
import org.jabref.preferences.JabRefPreferences; | ||
|
||
|
@@ -130,8 +129,8 @@ public MainTable(MainTableDataModel model, JabRefFrame frame, | |
} | ||
|
||
@Subscribe | ||
public void listen(AllInsertsFinishedEvent event) { | ||
DefaultTaskExecutor.runInJavaFXThread(() -> clearAndSelect(event.getBibEntry())); | ||
public void listen(EntriesAddedEvent event) { | ||
DefaultTaskExecutor.runInJavaFXThread(() -> clearAndSelect(event.getFirstEntry())); | ||
} | ||
|
||
public void clearAndSelect(BibEntry bibEntry) { | ||
|
@@ -217,17 +216,12 @@ public void paste() { | |
List<BibEntry> entriesToAdd = Globals.clipboardManager.extractData(); | ||
|
||
if (!entriesToAdd.isEmpty()) { | ||
// Add new entries | ||
NamedCompound ce = new NamedCompound((entriesToAdd.size() > 1 ? Localization.lang("paste entries") : Localization.lang("paste entry"))); | ||
database.getDatabase().insertEntries(entriesToAdd); | ||
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. Reading the other code, I wonder why 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 also check if the |
||
// TODO because of this line, when implementing batch undo insert entries, model constructor after batch remove entries with a boolean for paste | ||
undoManager.addEdit(new UndoableInsertEntries(database.getDatabase(), entriesToAdd, true)); | ||
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 should avoid Please introduce an enum 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. What is the |
||
for (BibEntry entryToAdd : entriesToAdd) { | ||
UpdateField.setAutomaticFields(entryToAdd, Globals.prefs.getUpdateFieldPreferences()); | ||
|
||
database.getDatabase().insertEntry(entryToAdd); | ||
|
||
ce.addEdit(new UndoableInsertEntry(database.getDatabase(), entryToAdd)); | ||
} | ||
ce.end(); | ||
undoManager.addEdit(ce); | ||
|
||
// Show editor if user want us to do this | ||
BibEntry firstNewEntry = entriesToAdd.get(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.
Then please fix it or just remove it.
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.
See the question below. I am trying to ascertain the purpose of the method so I understand it.