-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Copy to option #12374
Draft
priyanshu16095
wants to merge
10
commits into
JabRef:main
Choose a base branch
from
priyanshu16095:copyToOption
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Copy to option #12374
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
507d51e
Implemented 'Copy to' context menu with cross-reference inclusion/exc…
priyanshu16095 f502f68
Merge remote-tracking branch 'upstream/main'
priyanshu16095 ba7536a
Merge branch 'main' into copyToOption
priyanshu16095 bb2b77c
Fixing checkstye error
priyanshu16095 ca5775b
Merge branch 'copyToOption' of https://github.com/priyanshu16095/jabr…
priyanshu16095 31bb403
Updated code based on feedback
priyanshu16095 858015f
Use FileUtil to collect file paths
priyanshu16095 dea0ed9
Merge branch 'JabRef:main' into main
priyanshu16095 24966f5
Merge remote-tracking branch 'origin/main' into copyToOption
priyanshu16095 a283264
Make menu items clickable and copy entry without checks
priyanshu16095 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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package org.jabref.gui.edit; | ||
|
||
import java.util.List; | ||
|
||
import org.jabref.gui.DialogService; | ||
import org.jabref.gui.LibraryTab; | ||
import org.jabref.gui.StateManager; | ||
import org.jabref.gui.actions.ActionHelper; | ||
import org.jabref.gui.actions.SimpleCommand; | ||
import org.jabref.logic.l10n.Localization; | ||
import org.jabref.model.database.BibDatabaseContext; | ||
import org.jabref.model.entry.BibEntry; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
public class CopyTo extends SimpleCommand { | ||
|
||
private static final Logger LOGGER = LoggerFactory.getLogger(CopyMoreAction.class); | ||
|
||
private final DialogService dialogService; | ||
private final StateManager stateManager; | ||
private final CopyToPreferences copyToPreferences; | ||
private final LibraryTab libraryTab; | ||
private final BibDatabaseContext sourceDatabaseContext; | ||
private final BibDatabaseContext targetDatabaseContext; | ||
|
||
public CopyTo(DialogService dialogService, | ||
StateManager stateManager, | ||
CopyToPreferences copyToPreferences, | ||
LibraryTab libraryTab, | ||
BibDatabaseContext sourceDatabaseContext, | ||
BibDatabaseContext targetDatabaseContext) { | ||
this.dialogService = dialogService; | ||
this.stateManager = stateManager; | ||
this.copyToPreferences = copyToPreferences; | ||
this.libraryTab = libraryTab; | ||
this.sourceDatabaseContext = sourceDatabaseContext; | ||
this.targetDatabaseContext = targetDatabaseContext; | ||
|
||
this.executable.bind(ActionHelper.needsEntriesSelected(stateManager)); | ||
} | ||
|
||
@Override | ||
public void execute() { | ||
boolean includeCrossReferences = askForCrossReferencedEntries(); | ||
copyToPreferences.setShouldIncludeCrossReferences(includeCrossReferences); | ||
|
||
copyEntryToAnotherLibrary(sourceDatabaseContext, targetDatabaseContext); | ||
} | ||
|
||
public void copyEntryToAnotherLibrary(BibDatabaseContext sourceDatabaseContext, BibDatabaseContext targetDatabaseContext) { | ||
List<BibEntry> selectedEntries = stateManager.getSelectedEntries(); | ||
|
||
targetDatabaseContext.getDatabase().insertEntries(selectedEntries); | ||
} | ||
|
||
private boolean askForCrossReferencedEntries() { | ||
if (copyToPreferences.getShouldAskForIncludingCrossReferences()) { | ||
return dialogService.showConfirmationDialogWithOptOutAndWait( | ||
Localization.lang("Include or exclude cross-referenced entries"), | ||
Localization.lang("Would you like to include cross-reference entries in the current operation?"), | ||
Localization.lang("Include"), | ||
Localization.lang("Exclude"), | ||
Localization.lang("Do not ask again"), | ||
optOut -> copyToPreferences.setShouldAskForIncludingCrossReferences(!optOut) | ||
); | ||
} else { | ||
return copyToPreferences.getShouldIncludeCrossReferences(); | ||
} | ||
} | ||
} |
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,32 @@ | ||
package org.jabref.gui.edit; | ||
|
||
import javafx.beans.property.BooleanProperty; | ||
import javafx.beans.property.SimpleBooleanProperty; | ||
|
||
public class CopyToPreferences { | ||
private final BooleanProperty shouldIncludeCrossReferences = new SimpleBooleanProperty(); | ||
private final BooleanProperty shouldAskForIncludingCrossReferences = new SimpleBooleanProperty(); | ||
|
||
public CopyToPreferences(boolean shouldAskForIncludingCrossReferences, | ||
boolean shouldIncludeCrossReferences | ||
) { | ||
this.shouldIncludeCrossReferences.set(shouldIncludeCrossReferences); | ||
this.shouldAskForIncludingCrossReferences.set(shouldAskForIncludingCrossReferences); | ||
} | ||
|
||
public boolean getShouldIncludeCrossReferences() { | ||
return shouldIncludeCrossReferences.get(); | ||
} | ||
|
||
public void setShouldIncludeCrossReferences(boolean decision) { | ||
this.shouldIncludeCrossReferences.set(decision); | ||
} | ||
|
||
public boolean getShouldAskForIncludingCrossReferences() { | ||
return shouldAskForIncludingCrossReferences.get(); | ||
} | ||
|
||
public void setShouldAskForIncludingCrossReferences(boolean decision) { | ||
this.shouldAskForIncludingCrossReferences.set(decision); | ||
} | ||
} |
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
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.
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.
How about
shouldIncludeCrossReferences
? It reads better.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.
Is it in line 17 or 14?
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.
The method name. It is a nitpick so feel free to ignore.