- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 3k
Show merge entries for modified entries #5688
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
          
     Merged
      
      
    
  
     Merged
                    Changes from all commits
      Commits
    
    
            Show all changes
          
          
            34 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      7eab878
              
                [WIP] Show merge entries for modified entries
              
              
                Siedlerchr 1965b74
              
                refactor and insert entry
              
              
                Siedlerchr ceb9a6a
              
                remove obsolete l10n key
              
              
                Siedlerchr abd0d5d
              
                Merge remote-tracking branch 'upstream/master' into changemergesdialog
              
              
                Siedlerchr ab2beef
              
                Merge remote-tracking branch 'upstream/master' into changemergesdialog
              
              
                Siedlerchr 743554a
              
                fix spacing
              
              
                Siedlerchr 21b4de3
              
                Merge remote-tracking branch 'upstream/master' into changemergesdialog
              
              
                Siedlerchr dd3defe
              
                fix javadoc
              
              
                Siedlerchr ab48a98
              
                Merge remote-tracking branch 'upstream/master' into changemergesdialog
              
              
                Siedlerchr 6884034
              
                pass second entry to merge dialog
              
              
                Siedlerchr 475fb6b
              
                add Exception logging to Databsae Change Monitor
              
              
                Siedlerchr 014edb1
              
                fix l10n
              
              
                Siedlerchr 916498f
              
                add changelog
              
              
                Siedlerchr 340a43f
              
                remove old entry, move merge Panel init to description
              
              
                Siedlerchr c909db9
              
                fix error
              
              
                Siedlerchr 2750183
              
                beautify controls
              
              
                Siedlerchr 22b0939
              
                improve layout of merge dialog
              
              
                Siedlerchr c825212
              
                Merge remote-tracking branch 'upstream/master' into changemergesdialog
              
              
                Siedlerchr 7b0ee12
              
                remove checkbox when merge entries
              
              
                Siedlerchr 392f51c
              
                make koppor happy
              
              
                Siedlerchr 001e3f0
              
                fix tests
              
              
                Siedlerchr e830f52
              
                remove obsolete parameter
              
              
                Siedlerchr 798d497
              
                Fix parameter name
              
              
                koppor 0b62ff6
              
                Remove obsolete newline
              
              
                koppor f266af3
              
                Fix localization
              
              
                koppor 241502c
              
                Change arrows
              
              
                koppor 1432148
              
                Fix checkstyle
              
              
                koppor 53a0b11
              
                Center selection column
              
              
                koppor 55e2f23
              
                Remove obsolete language keys
              
              
                koppor 09fbfca
              
                Remove l10n from arrows
              
              
                Siedlerchr f033134
              
                Update arrows (#5787)
              
              
                koppor 756d4bc
              
                preselect left
              
              
                Siedlerchr fa6fb54
              
                Merge remote-tracking branch 'upstream/master' into changemergesdialog
              
              
                Siedlerchr 4c0e055
              
                fix checkstyle
              
              
                Siedlerchr File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 | 
|---|---|---|
| @@ -1,24 +1,17 @@ | ||
| package org.jabref.gui.collab; | ||
|  | ||
| import java.util.ArrayList; | ||
| import java.util.Comparator; | ||
| import java.util.List; | ||
| import java.util.Optional; | ||
| import java.util.Set; | ||
| import java.util.TreeSet; | ||
|  | ||
| import javafx.geometry.Insets; | ||
| import javafx.scene.Node; | ||
| import javafx.scene.control.Label; | ||
| import javafx.scene.layout.VBox; | ||
|  | ||
| import org.jabref.gui.mergeentries.MergeEntries; | ||
| import org.jabref.gui.mergeentries.MergeEntries.DefaultRadioButtonSelectionMode; | ||
| import org.jabref.gui.undo.NamedCompound; | ||
| import org.jabref.gui.undo.UndoableFieldChange; | ||
| import org.jabref.gui.undo.UndoableInsertEntry; | ||
| import org.jabref.logic.l10n.Localization; | ||
| import org.jabref.model.FieldChange; | ||
| import org.jabref.model.database.BibDatabaseContext; | ||
| import org.jabref.model.entry.BibEntry; | ||
| import org.jabref.model.entry.field.Field; | ||
| import org.jabref.model.strings.StringUtil; | ||
|  | ||
| import org.slf4j.Logger; | ||
| import org.slf4j.LoggerFactory; | ||
|  | @@ -27,103 +20,44 @@ class EntryChangeViewModel extends DatabaseChangeViewModel { | |
|  | ||
| private static final Logger LOGGER = LoggerFactory.getLogger(EntryChangeViewModel.class); | ||
|  | ||
| private final List<FieldChangeViewModel> fieldChanges = new ArrayList<>(); | ||
| private final BibEntry oldEntry; | ||
| private final BibEntry newEntry; | ||
| private MergeEntries mergePanel; | ||
|  | ||
| private final BibDatabaseContext database; | ||
|  | ||
| public EntryChangeViewModel(BibEntry entry, BibEntry newEntry) { | ||
| public EntryChangeViewModel(BibEntry entry, BibEntry newEntry, BibDatabaseContext database) { | ||
| super(); | ||
|  | ||
| this.oldEntry = entry; | ||
| this.newEntry = newEntry; | ||
| this.database = database; | ||
|  | ||
| name = entry.getCiteKeyOptional() | ||
| .map(key -> Localization.lang("Modified entry") + ": '" + key + '\'') | ||
| .orElse(Localization.lang("Modified entry")); | ||
|  | ||
| Set<Field> allFields = new TreeSet<>(Comparator.comparing(Field::getName)); | ||
| allFields.addAll(entry.getFields()); | ||
| allFields.addAll(newEntry.getFields()); | ||
|  | ||
| for (Field field : allFields) { | ||
| Optional<String> value = entry.getField(field); | ||
| Optional<String> newValue = newEntry.getField(field); | ||
|  | ||
| if (value.isPresent() && newValue.isPresent()) { | ||
| if (!value.equals(newValue)) { | ||
| // Modified externally. | ||
| fieldChanges.add(new FieldChangeViewModel(entry, field, value.get(), newValue.get())); | ||
| } | ||
| } else { | ||
| // Added/removed externally. | ||
| fieldChanges.add(new FieldChangeViewModel(entry, field, value.orElse(null), newValue.orElse(null))); | ||
| } | ||
| } | ||
| } | ||
|  | ||
| @Override | ||
| public void makeChange(BibDatabaseContext database, NamedCompound undoEdit) { | ||
| for (DatabaseChangeViewModel c : fieldChanges) { | ||
| if (c.isAccepted()) { | ||
| c.makeChange(database, undoEdit); | ||
| } | ||
| } | ||
| database.getDatabase().removeEntry(oldEntry); | ||
| database.getDatabase().insertEntry(mergePanel.getMergeEntry()); | ||
| undoEdit.addEdit(new UndoableInsertEntry(database.getDatabase(), oldEntry)); | ||
| undoEdit.addEdit(new UndoableInsertEntry(database.getDatabase(), mergePanel.getMergeEntry())); | ||
| } | ||
|  | ||
| @Override | ||
| public Node description() { | ||
|  | ||
| mergePanel = new MergeEntries(oldEntry, newEntry, Localization.lang("In JabRef"), Localization.lang("On disk"), DefaultRadioButtonSelectionMode.LEFT); | ||
|  | ||
| VBox container = new VBox(10); | ||
| Label header = new Label(name); | ||
| header.getStyleClass().add("sectionHeader"); | ||
| container.getChildren().add(header); | ||
|  | ||
| for (FieldChangeViewModel change : fieldChanges) { | ||
| container.getChildren().add(change.description()); | ||
| } | ||
|  | ||
| container.getChildren().add(mergePanel); | ||
| container.setMargin(mergePanel, new Insets(5, 5, 5, 5)); | ||
| 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 does not seem to work, as there appears to be no space on the left side (or 5 is too small) | ||
| return container; | ||
| } | ||
|  | ||
| static class FieldChangeViewModel extends DatabaseChangeViewModel { | ||
|  | ||
| private final BibEntry entry; | ||
| private final Field field; | ||
| private final String value; | ||
| private final String newValue; | ||
|  | ||
| public FieldChangeViewModel(BibEntry entry, Field field, String value, String newValue) { | ||
| super(field.getName()); | ||
| this.entry = entry; | ||
| this.field = field; | ||
| this.value = value; | ||
| this.newValue = newValue; | ||
| } | ||
|  | ||
| @Override | ||
| public void makeChange(BibDatabaseContext database, NamedCompound undoEdit) { | ||
| Optional<FieldChange> change; | ||
| if (StringUtil.isBlank(newValue)) { | ||
| change = entry.clearField(field); | ||
| } else { | ||
| change = entry.setField(field, newValue); | ||
| } | ||
|  | ||
| change.map(UndoableFieldChange::new).ifPresent(undoEdit::addEdit); | ||
| } | ||
|  | ||
| @Override | ||
| public Node description() { | ||
| VBox container = new VBox(); | ||
| container.getChildren().add(new Label(Localization.lang("Modification of field") + " " + field.getDisplayName())); | ||
|  | ||
| if (StringUtil.isNotBlank(newValue)) { | ||
| container.getChildren().add(new Label(Localization.lang("Value set externally") + ": " + newValue)); | ||
| } else { | ||
| container.getChildren().add(new Label(Localization.lang("Value cleared externally"))); | ||
| } | ||
|  | ||
| if (StringUtil.isNotBlank(value)) { | ||
| container.getChildren().add(new Label(Localization.lang("Current value") + ": " + value)); | ||
| } else { | ||
| container.getChildren().add(new Label(Localization.lang("Current value") + ": " + Localization.lang("empty"))); | ||
| } | ||
|  | ||
| return container; | ||
| } | ||
|  | ||
| } | ||
| } | ||
  
    
      This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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.
        
    
  
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Uh oh!
There was an error while loading. Please reload this page.