-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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] Implement copying cross-references #11228
base: main
Are you sure you want to change the base?
Changes from all commits
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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package org.jabref.gui; | ||
|
||
import javafx.scene.control.ButtonBar; | ||
import javafx.scene.control.ButtonType; | ||
import javafx.scene.layout.Region; | ||
|
||
import org.jabref.gui.util.BaseDialog; | ||
Check failure on line 7 in src/main/java/org/jabref/gui/CopyEntryToDialogView.java GitHub Actions / Checkstyle
|
||
import org.jabref.logic.l10n.Localization; | ||
|
||
public class CopyEntryToDialogView extends FXDialog { | ||
ButtonType copySelectedEntryOnly = new ButtonType("Copy selected entry only", ButtonBar.ButtonData.OK_DONE); | ||
ButtonType copySelectedEntryWithCrossReferencedEntries = new ButtonType("Copy cross references", ButtonBar.ButtonData.OK_DONE); | ||
ButtonType copySelectedEntryWithCrossReferencedEntriesRecursively = new ButtonType("Copy cross references recursively", ButtonBar.ButtonData.OK_DONE); | ||
|
||
public CopyEntryToDialogView() { | ||
super(AlertType.CONFIRMATION, Localization.lang("Copy entry to library"), true); | ||
setHeaderText(null); | ||
getDialogPane().setMinHeight(170); | ||
setResizable(true); | ||
setContentText(""" | ||
The selected entry cross references 4 other entries. | ||
|
||
Do you want to copy all of them or just the selected one? | ||
|
||
* Copying cross-references recursively means copying references of the selected entry, and references of its references, until all dependant entries are included."""); | ||
getDialogPane().getButtonTypes().setAll(copySelectedEntryOnly, copySelectedEntryWithCrossReferencedEntries, copySelectedEntryWithCrossReferencedEntriesRecursively, new ButtonType("Cancel", ButtonBar.ButtonData.LEFT)); | ||
getDialogPane().getButtonTypes().stream() | ||
.map(getDialogPane()::lookupButton) | ||
.forEach(btn-> { | ||
ButtonBar.setButtonUniformSize(btn, false); | ||
((Region) btn).setMinWidth(120); | ||
}); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package org.jabref.gui; | ||
|
||
import java.util.List; | ||
Check failure on line 3 in src/main/java/org/jabref/gui/CopyEntryToLibraryAction.java GitHub Actions / Checkstyle
|
||
|
||
import javafx.scene.control.TabPane; | ||
|
||
import org.jabref.gui.actions.ActionHelper; | ||
import org.jabref.gui.actions.SimpleCommand; | ||
import org.jabref.model.entry.BibEntry; | ||
import org.jabref.model.entry.field.StandardField; | ||
|
||
public class CopyEntryToLibraryAction extends SimpleCommand { | ||
private final DialogService dialogService; | ||
private final StateManager stateManager; | ||
private LibraryTab source; | ||
private LibraryTab destination; | ||
private final TabPane tabPane; | ||
|
||
public CopyEntryToLibraryAction(DialogService dialogService, StateManager stateManager, LibraryTab source, LibraryTab destination, TabPane tabPane) { | ||
this.dialogService = dialogService; | ||
this.stateManager = stateManager; | ||
this.source = source; | ||
this.destination = destination; | ||
this.tabPane = tabPane; | ||
|
||
this.executable.bind(ActionHelper.needsEntriesSelected(1, stateManager)); | ||
} | ||
|
||
@Override | ||
public void execute() { | ||
BibEntry selectedEntry = stateManager.getSelectedEntries().getFirst(); | ||
System.out.println(selectedEntry.getField(StandardField.EDITORA)); | ||
dialogService.showCustomDialogAndWait(new CopyEntryToDialogView()); | ||
|
||
// tabPane.getSelectionModel().select(destination); | ||
// destination.dropEntry(List.of((BibEntry) selectedEntry.clone())); | ||
// destination.dropEntry(); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ | |
public enum StandardActions implements Action { | ||
|
||
COPY_MORE(Localization.lang("Copy") + "..."), | ||
COPY_TO(Localization.lang("Copy to") + "..."), | ||
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 this ... should be part of the localization string. I would change the above one as well |
||
COPY_TITLE(Localization.lang("Copy title"), KeyBinding.COPY_TITLE), | ||
COPY_KEY(Localization.lang("Copy citation key"), KeyBinding.COPY_CITATION_KEY), | ||
COPY_CITE_KEY(Localization.lang("Copy citation key with configured cite command"), KeyBinding.COPY_CITE_CITATION_KEY), | ||
|
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.
Unfortunately, Localization.lang does not work with textblocks yet.... You need to use \n
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.
I remember that I tried to switch to JavaParser or similar tooling for better localization handling. However, this did not work in all cases and lead to upstream issues.
I was thinking to use Kilt for JabRef. However, I did not see fast enough how to keep our localization checks. (Because I like that we have a check that the messages are verbatim included in the code). - And it seems, we would have to change all our parameterized strings (poiu-de/kilt#23). (
%0
to{0}
). And some layer on top of Kilt (which is not that harmful, but effort. And thus, the effort added too much for me).Refs #7279
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.
Found the implementation:
c6c7edd
(#8050)