-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor EntryEvents - removal part (#5410)
* Initial changes to remove entry functionality * Fix logic error in KeyChangeListener * Fix logic error in BasePanel * Changes to tests * Fix typo * Move remove entry calls to batch version * Un-propagate for loop in KeyChangeListener * Finalize changes to SharedEntriesNotPresentEvent * Fix bug * Fix other compile errors * Fix bug and update tests * Fix tests * Fix test omission * Update l10n * For loop to citationStyle * Add comment for method not working * Clarify var name * Allow single entry for undo * Replace compound edit undo with normal undo in BasePanel * Typo * Simplify loop in DBMSSynchronizer * Use if instead of stream * Pluralize Javadoc * EntryEvent -> EntriesEvent in Javadoc, comments, and var names * Make imports explicit in BasePanel * Final EntriesRemovedEvent fixes * Fix checkStyleMain * More checkStyle fixes * More fixes * Move List coercion into DuplicateSearchResult method * Fix typo * Fix pesky BibDatabaseTest error with setStrings * Fixed BibDatabase Javadoc
- Loading branch information
1 parent
204d922
commit 3d8a09d
Showing
36 changed files
with
428 additions
and
330 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
src/main/java/org/jabref/gui/undo/UndoableRemoveEntries.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
package org.jabref.gui.undo; | ||
|
||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
import org.jabref.logic.l10n.Localization; | ||
import org.jabref.model.database.BibDatabase; | ||
import org.jabref.model.entry.BibEntry; | ||
import org.jabref.model.entry.event.EntriesEventSource; | ||
import org.jabref.model.strings.StringUtil; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
/** | ||
* This class represents the removal of entries. The constructor needs | ||
* references to the database, the entries, and the map of open entry editors. | ||
* TODO is this map still being used? | ||
* The latter to be able to close the entry's editor if it is opened after | ||
* an undo, and the removal is then undone. | ||
*/ | ||
public class UndoableRemoveEntries extends AbstractUndoableJabRefEdit { | ||
|
||
private static final Logger LOGGER = LoggerFactory.getLogger(UndoableRemoveEntries.class); | ||
private final BibDatabase base; | ||
private final List<BibEntry> entries; | ||
private final boolean cut; | ||
|
||
public UndoableRemoveEntries(BibDatabase base, BibEntry entry) { | ||
this(base, Collections.singletonList(entry)); | ||
} | ||
|
||
public UndoableRemoveEntries(BibDatabase base, List<BibEntry> entries) { | ||
this(base, entries, false); | ||
} | ||
|
||
public UndoableRemoveEntries(BibDatabase base, List<BibEntry> entries, boolean cut) { | ||
this.base = base; | ||
this.entries = entries; | ||
this.cut = cut; | ||
} | ||
|
||
@Override | ||
public String getPresentationName() { | ||
if (cut) { | ||
if (entries.size() > 1) { | ||
return Localization.lang("cut entries"); | ||
} else if (entries.size() == 1) { | ||
return Localization.lang("cut entry %0", | ||
StringUtil.boldHTML(entries.get(0).getCiteKeyOptional().orElse(Localization.lang("undefined")))); | ||
} else { | ||
return null; | ||
} | ||
} else { | ||
if (entries.size() > 1) { | ||
return Localization.lang("remove entries"); | ||
} else if (entries.size() == 1) { | ||
return Localization.lang("remove entry %0", | ||
StringUtil.boldHTML(entries.get(0).getCiteKeyOptional().orElse(Localization.lang("undefined")))); | ||
} else { | ||
return null; | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
public void undo() { | ||
super.undo(); | ||
base.insertEntries(entries, EntriesEventSource.UNDO); | ||
} | ||
|
||
@Override | ||
public void redo() { | ||
super.redo(); | ||
|
||
// Redo the change. | ||
try { | ||
base.removeEntries(entries); | ||
} catch (Throwable ex) { | ||
LOGGER.warn("Problem to redo `remove entries`", ex); | ||
} | ||
} | ||
|
||
} |
53 changes: 0 additions & 53 deletions
53
src/main/java/org/jabref/gui/undo/UndoableRemoveEntry.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.