Skip to content
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

Convert merge shared entries to javafx #5042

Merged
merged 3 commits into from
Jun 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
116 changes: 0 additions & 116 deletions src/main/java/org/jabref/gui/shared/MergeSharedEntryDialog.java

This file was deleted.

40 changes: 37 additions & 3 deletions src/main/java/org/jabref/gui/shared/SharedDatabaseUIManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.util.Optional;

import javafx.scene.control.Alert.AlertType;
import javafx.scene.control.ButtonBar;
import javafx.scene.control.ButtonBar.ButtonData;
import javafx.scene.control.ButtonType;

Expand All @@ -14,6 +15,7 @@
import org.jabref.gui.JabRefFrame;
import org.jabref.gui.entryeditor.EntryEditor;
import org.jabref.gui.exporter.SaveDatabaseAction;
import org.jabref.gui.mergeentries.MergeEntriesDialog;
import org.jabref.gui.undo.UndoableRemoveEntry;
import org.jabref.logic.importer.ParserResult;
import org.jabref.logic.l10n.Localization;
Expand All @@ -31,6 +33,7 @@
import org.jabref.model.database.BibDatabaseMode;
import org.jabref.model.database.shared.DatabaseNotSupportedException;
import org.jabref.model.database.shared.DatabaseSynchronizer;
import org.jabref.model.entry.BibEntry;

import com.google.common.eventbus.Subscribe;

Expand Down Expand Up @@ -81,9 +84,40 @@ public void listen(UpdateRefusedEvent updateRefusedEvent) {

jabRefFrame.getDialogService().notify(Localization.lang("Update refused."));

new MergeSharedEntryDialog(jabRefFrame, dbmsSynchronizer, updateRefusedEvent.getLocalBibEntry(),
updateRefusedEvent.getSharedBibEntry(),
updateRefusedEvent.getBibDatabaseContext().getMode()).showMergeDialog();
BibEntry localBibEntry = updateRefusedEvent.getLocalBibEntry();
BibEntry sharedBibEntry = updateRefusedEvent.getSharedBibEntry();

StringBuilder message = new StringBuilder();
message.append(Localization.lang("Update could not be performed due to existing change conflicts."));
message.append("\r\n");
message.append(Localization.lang("You are not working on the newest version of BibEntry."));
message.append("\r\n");
message.append(Localization.lang("Shared version: %0", String.valueOf(sharedBibEntry.getSharedBibEntryData().getVersion())));
message.append("\r\n");
message.append(Localization.lang("Local version: %0", String.valueOf(localBibEntry.getSharedBibEntryData().getVersion())));
message.append("\r\n");
message.append(Localization.lang("Press \"Merge entries\" to merge the changes and resolve this problem."));
message.append("\r\n");
message.append(Localization.lang("Canceling this operation will leave your changes unsynchronized."));

ButtonType merge = new ButtonType(Localization.lang("Merge entries"), ButtonBar.ButtonData.YES);

Optional<ButtonType> response = dialogService.showCustomButtonDialogAndWait(AlertType.CONFIRMATION, Localization.lang("Update refused"), message.toString(), ButtonType.CANCEL, merge);

if (response.isPresent() && response.get().equals(merge)) {
MergeEntriesDialog dialog = new MergeEntriesDialog(localBibEntry, sharedBibEntry, updateRefusedEvent.getBibDatabaseContext().getMode());
Optional<BibEntry> mergedEntry = dialog.showAndWait();

mergedEntry.ifPresent(mergedBibEntry -> {
mergedBibEntry.getSharedBibEntryData().setSharedID(sharedBibEntry.getSharedBibEntryData().getSharedID());
mergedBibEntry.getSharedBibEntryData().setVersion(sharedBibEntry.getSharedBibEntryData().getVersion());

dbmsSynchronizer.synchronizeSharedEntry(mergedBibEntry);
dbmsSynchronizer.synchronizeLocalDatabase();
});

}

}

@Subscribe
Expand Down
6 changes: 2 additions & 4 deletions src/main/resources/l10n/JabRef_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1753,14 +1753,12 @@ Work\ offline=Work offline
Working\ offline.=Working offline.
Update\ refused.=Update refused.
Update\ refused=Update refused
Local\ entry=Local entry
Shared\ entry=Shared entry
Update\ could\ not\ be\ performed\ due\ to\ existing\ change\ conflicts.=Update could not be performed due to existing change conflicts.
You\ are\ not\ working\ on\ the\ newest\ version\ of\ BibEntry.=You are not working on the newest version of BibEntry.
Local\ version\:\ %0=Local version: %0
Shared\ version\:\ %0=Shared version: %0
Please\ merge\ the\ shared\ entry\ with\ yours\ and\ press\ "Merge\ entries"\ to\ resolve\ this\ problem.=Please merge the shared entry with yours and press "Merge entries" to resolve this problem.
Canceling\ this\ operation\ will\ leave\ your\ changes\ unsynchronized.\ Cancel\ anyway?=Canceling this operation will leave your changes unsynchronized. Cancel anyway?
Press\ "Merge\ entries"\ to\ merge\ the\ changes\ and\ resolve\ this\ problem.=Press "Merge entries" to merge the changes and resolve this problem.
Canceling\ this\ operation\ will\ leave\ your\ changes\ unsynchronized.=Canceling this operation will leave your changes unsynchronized.
Shared\ entry\ is\ no\ longer\ present=Shared entry is no longer present
The\ entry\ you\ currently\ work\ on\ has\ been\ deleted\ on\ the\ shared\ side.=The entry you currently work on has been deleted on the shared side.
You\ can\ restore\ the\ entry\ using\ the\ "Undo"\ operation.=You can restore the entry using the "Undo" operation.
Expand Down