-
-
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.
Show a warning in the merge dialog when authors are the same but form…
…atted differently (#9088) * Show a warning when the authors are the same but formatted differently * Update CHANGELOG.md * Link issue rather than pr in the changelog * Checkstyle * Show the warning for all fields with person names * Modify warning message Co-authored-by: ThiloteE <73715071+thilotee@users.noreply.github.com> * Use an info icon rather than a warning * Checkstyle * Add a comment for why InfoButton command is empty * Delete FieldRowController.java * Hide diffs if persons names are the same * i18n Co-authored-by: ThiloteE <73715071+thilotee@users.noreply.github.com>
- Loading branch information
1 parent
5a34184
commit 7239503
Showing
6 changed files
with
108 additions
and
7 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
34 changes: 34 additions & 0 deletions
34
src/main/java/org/jabref/gui/mergeentries/newmergedialog/PersonsNameFieldRowView.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,34 @@ | ||
package org.jabref.gui.mergeentries.newmergedialog; | ||
|
||
import org.jabref.gui.mergeentries.newmergedialog.cell.sidebuttons.InfoButton; | ||
import org.jabref.gui.mergeentries.newmergedialog.fieldsmerger.FieldMergerFactory; | ||
import org.jabref.logic.importer.AuthorListParser; | ||
import org.jabref.logic.l10n.Localization; | ||
import org.jabref.model.entry.AuthorList; | ||
import org.jabref.model.entry.BibEntry; | ||
import org.jabref.model.entry.field.Field; | ||
import org.jabref.model.entry.field.FieldProperty; | ||
|
||
public class PersonsNameFieldRowView extends FieldRowView { | ||
private final AuthorList leftEntryNames; | ||
private final AuthorList rightEntryNames; | ||
|
||
public PersonsNameFieldRowView(Field field, BibEntry leftEntry, BibEntry rightEntry, BibEntry mergedEntry, FieldMergerFactory fieldMergerFactory, int rowIndex) { | ||
super(field, leftEntry, rightEntry, mergedEntry, fieldMergerFactory, rowIndex); | ||
assert field.getProperties().contains(FieldProperty.PERSON_NAMES); | ||
|
||
var authorsParser = new AuthorListParser(); | ||
leftEntryNames = authorsParser.parse(viewModel.getLeftFieldValue()); | ||
rightEntryNames = authorsParser.parse(viewModel.getRightFieldValue()); | ||
|
||
if (!leftEntry.equals(rightEntry) && leftEntryNames.equals(rightEntryNames)) { | ||
showPersonsNamesAreTheSameInfo(); | ||
shouldShowDiffs.set(false); | ||
} | ||
} | ||
|
||
private void showPersonsNamesAreTheSameInfo() { | ||
InfoButton infoButton = new InfoButton(Localization.lang("The %0s are the same. However, the order of field content differs", viewModel.getField().getName())); | ||
getFieldNameCell().addSideButton(infoButton); | ||
} | ||
} |
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
51 changes: 51 additions & 0 deletions
51
src/main/java/org/jabref/gui/mergeentries/newmergedialog/cell/sidebuttons/InfoButton.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,51 @@ | ||
package org.jabref.gui.mergeentries.newmergedialog.cell.sidebuttons; | ||
|
||
import javafx.beans.property.SimpleStringProperty; | ||
import javafx.beans.property.StringProperty; | ||
import javafx.scene.control.Button; | ||
|
||
import org.jabref.gui.Globals; | ||
import org.jabref.gui.actions.Action; | ||
import org.jabref.gui.actions.ActionFactory; | ||
import org.jabref.gui.actions.SimpleCommand; | ||
import org.jabref.gui.icon.IconTheme; | ||
|
||
import com.tobiasdiez.easybind.EasyBind; | ||
|
||
public class InfoButton extends Button { | ||
private final StringProperty infoMessage = new SimpleStringProperty(); | ||
private final ActionFactory actionFactory = new ActionFactory(Globals.getKeyPrefs()); | ||
|
||
public InfoButton(String infoMessage) { | ||
setInfoMessage(infoMessage); | ||
configureButton(); | ||
EasyBind.subscribe(infoMessageProperty(), newWarningMessage -> { | ||
configureButton(); | ||
}); | ||
} | ||
|
||
private void configureButton() { | ||
setMaxHeight(Double.MAX_VALUE); | ||
setFocusTraversable(false); | ||
Action mergeAction = new Action.Builder(getInfoMessage()).setIcon(IconTheme.JabRefIcons.INTEGRITY_INFO); | ||
|
||
actionFactory.configureIconButton(mergeAction, new SimpleCommand() { | ||
@Override | ||
public void execute() { | ||
// The info button is not meant to be clickable that's why this is empty | ||
} | ||
}, this); | ||
} | ||
|
||
private void setInfoMessage(String infoMessage) { | ||
infoMessageProperty().set(infoMessage); | ||
} | ||
|
||
public StringProperty infoMessageProperty() { | ||
return infoMessage; | ||
} | ||
|
||
public String getInfoMessage() { | ||
return infoMessage.get(); | ||
} | ||
} |
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