-
-
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
Add eprint cleanup #4445
Merged
Merged
Add eprint cleanup #4445
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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
33 changes: 33 additions & 0 deletions
33
src/main/java/org/jabref/gui/cleanup/CleanupPresetPanel.fxml
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,33 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<?import javafx.geometry.Insets?> | ||
<?import javafx.scene.control.CheckBox?> | ||
<?import javafx.scene.control.Label?> | ||
<?import javafx.scene.layout.VBox?> | ||
<fx:root xmlns:fx="http://javafx.com/fxml/1" spacing="10.0" type="VBox" xmlns="http://javafx.com/javafx/8.0.121" | ||
fx:controller="org.jabref.gui.cleanup.CleanupPresetPanel"> | ||
|
||
<CheckBox fx:id="cleanUpDOI" text="%Move DOIs from note and URL field to DOI field and remove http prefix"/> | ||
<CheckBox fx:id="cleanUpEprint" | ||
text="%Move preprint information from 'URL' and 'journal' field to the 'eprint' field"/> | ||
<CheckBox fx:id="cleanUpISSN" text="%Reformat ISSN"/> | ||
<CheckBox fx:id="cleanUpUpgradeExternalLinks"/> | ||
<CheckBox fx:id="cleanUpMovePDF"/> | ||
<CheckBox fx:id="cleanUpMakePathsRelative" text="%Make paths of linked files relative (if possible)"/> | ||
<CheckBox fx:id="cleanUpRenamePDF" text="%Rename PDFs to given filename format pattern"/> | ||
<VBox spacing="5.0"> | ||
<Label fx:id="cleanupRenamePDFLabel"/> | ||
<CheckBox fx:id="cleanUpRenamePDFonlyRelativePaths" text="%Rename only PDFs having a relative path"/> | ||
<VBox.margin> | ||
<Insets left="40.0"/> | ||
</VBox.margin> | ||
</VBox> | ||
|
||
<CheckBox fx:id="cleanUpBiblatex" | ||
text="%Convert to biblatex format (for example, move the value of the 'journal' field to 'journaltitle')"/> | ||
<CheckBox fx:id="cleanUpBibtex" | ||
text="%Convert to BibTeX format (for example, move the value of the 'journaltitle' field to 'journal')"/> | ||
|
||
<VBox fx:id="formatterContainer"/> | ||
|
||
</fx:root> |
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 |
---|---|---|
|
@@ -6,11 +6,10 @@ | |
import java.util.Optional; | ||
import java.util.Set; | ||
|
||
import javafx.scene.Group; | ||
import javafx.fxml.FXML; | ||
import javafx.scene.control.CheckBox; | ||
import javafx.scene.control.Label; | ||
import javafx.scene.control.ScrollPane; | ||
import javafx.scene.layout.GridPane; | ||
import javafx.scene.layout.VBox; | ||
|
||
import org.jabref.Globals; | ||
import org.jabref.logic.cleanup.CleanupPreset; | ||
|
@@ -20,110 +19,93 @@ | |
import org.jabref.model.entry.FieldName; | ||
import org.jabref.preferences.JabRefPreferences; | ||
|
||
public class CleanupPresetPanel extends ScrollPane { | ||
import com.airhacks.afterburner.views.ViewLoader; | ||
|
||
public class CleanupPresetPanel extends VBox { | ||
|
||
private final BibDatabaseContext databaseContext; | ||
private CheckBox cleanUpDOI; | ||
private CheckBox cleanUpISSN; | ||
private CheckBox cleanUpMovePDF; | ||
private CheckBox cleanUpMakePathsRelative; | ||
private CheckBox cleanUpRenamePDF; | ||
private CheckBox cleanUpRenamePDFonlyRelativePaths; | ||
private CheckBox cleanUpUpgradeExternalLinks; | ||
private CheckBox cleanUpBiblatex; | ||
private CheckBox cleanUpBibtex; | ||
private final CleanupPreset cleanupPreset; | ||
@FXML private Label cleanupRenamePDFLabel; | ||
@FXML private CheckBox cleanUpDOI; | ||
@FXML private CheckBox cleanUpEprint; | ||
@FXML private CheckBox cleanUpISSN; | ||
@FXML private CheckBox cleanUpMovePDF; | ||
@FXML private CheckBox cleanUpMakePathsRelative; | ||
@FXML private CheckBox cleanUpRenamePDF; | ||
@FXML private CheckBox cleanUpRenamePDFonlyRelativePaths; | ||
@FXML private CheckBox cleanUpUpgradeExternalLinks; | ||
@FXML private CheckBox cleanUpBiblatex; | ||
@FXML private CheckBox cleanUpBibtex; | ||
@FXML private VBox formatterContainer; | ||
private FieldFormatterCleanupsPanel cleanUpFormatters; | ||
|
||
private CleanupPreset cleanupPreset; | ||
|
||
public CleanupPresetPanel(BibDatabaseContext databaseContext, CleanupPreset cleanupPreset) { | ||
this.cleanupPreset = Objects.requireNonNull(cleanupPreset); | ||
this.databaseContext = Objects.requireNonNull(databaseContext); | ||
this.cleanupPreset = cleanupPreset; | ||
|
||
// Load FXML | ||
ViewLoader.view(this) | ||
.root(this) | ||
.load(); | ||
|
||
init(); | ||
} | ||
|
||
private void init() { | ||
cleanUpDOI = new CheckBox( | ||
Localization.lang("Move DOIs from note and URL field to DOI field and remove http prefix")); | ||
cleanUpISSN = new CheckBox(Localization.lang("Reformat ISSN")); | ||
Optional<Path> firstExistingDir = databaseContext | ||
.getFirstExistingFileDir(JabRefPreferences.getInstance().getFilePreferences()); | ||
Optional<Path> firstExistingDir = databaseContext.getFirstExistingFileDir(JabRefPreferences.getInstance().getFilePreferences()); | ||
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. You could now also inject the Preferences Service |
||
if (firstExistingDir.isPresent()) { | ||
cleanUpMovePDF = new CheckBox(Localization.lang("Move linked files to default file directory %0", | ||
firstExistingDir.get().toString())); | ||
cleanUpMovePDF.setText(Localization.lang("Move linked files to default file directory %0", firstExistingDir.get().toString())); | ||
} else { | ||
cleanUpMovePDF = new CheckBox(Localization.lang("Move linked files to default file directory %0", "...")); | ||
cleanUpMovePDF.setDisable(true); | ||
cleanUpMovePDF.setText(Localization.lang("Move linked files to default file directory %0", "...")); | ||
|
||
// Since the directory does not exist, we cannot move it to there. So, this option is not checked - regardless of the presets stored in the preferences. | ||
cleanUpMovePDF.setDisable(true); | ||
cleanUpMovePDF.setSelected(false); | ||
} | ||
cleanUpMakePathsRelative = new CheckBox( | ||
Localization.lang("Make paths of linked files relative (if possible)")); | ||
cleanUpRenamePDF = new CheckBox(Localization.lang("Rename PDFs to given filename format pattern")); | ||
cleanUpRenamePDF.selectedProperty().addListener( | ||
event -> cleanUpRenamePDFonlyRelativePaths.setDisable(!cleanUpRenamePDF.isSelected())); | ||
cleanUpRenamePDFonlyRelativePaths = new CheckBox(Localization.lang("Rename only PDFs having a relative path")); | ||
cleanUpUpgradeExternalLinks = new CheckBox( | ||
Localization.lang("Upgrade external PDF/PS links to use the '%0' field.", FieldName.FILE)); | ||
cleanUpBiblatex = new CheckBox(Localization.lang( | ||
"Convert to biblatex format (for example, move the value of the 'journal' field to 'journaltitle')")); | ||
cleanUpBibtex = new CheckBox(Localization.lang( | ||
"Convert to BibTeX format (for example, move the value of the 'journaltitle' field to 'journal')")); | ||
Group biblatexConversion = new Group(); // Only make "to Biblatex" or "to BibTeX" selectable | ||
biblatexConversion.getChildren().add(cleanUpBiblatex); | ||
biblatexConversion.getChildren().add(cleanUpBibtex); | ||
|
||
cleanUpFormatters = new FieldFormatterCleanupsPanel(Localization.lang("Run field formatter:"), | ||
Cleanups.DEFAULT_SAVE_ACTIONS); | ||
|
||
updateDisplay(cleanupPreset); | ||
cleanUpRenamePDFonlyRelativePaths.disableProperty().bind(cleanUpRenamePDF.selectedProperty().not()); | ||
|
||
GridPane container = new GridPane(); | ||
container.add(cleanUpDOI, 0, 0); | ||
container.add(cleanUpUpgradeExternalLinks, 0, 1); | ||
container.add(cleanUpMovePDF, 0, 2); | ||
container.add(cleanUpMakePathsRelative, 0, 3); | ||
container.add(cleanUpRenamePDF, 0, 4); | ||
String currentPattern = Localization.lang("Filename format pattern").concat(": "); | ||
currentPattern = currentPattern.concat(Globals.prefs.get(JabRefPreferences.IMPORT_FILENAMEPATTERN)); | ||
container.add(new Label(currentPattern), 0, 5); | ||
container.add(cleanUpRenamePDFonlyRelativePaths, 0, 6); | ||
container.add(cleanUpBibtex, 0, 7); | ||
container.add(cleanUpBiblatex, 0, 8); | ||
container.add(cleanUpISSN, 0, 9); | ||
container.add(cleanUpFormatters, 0, 10); | ||
|
||
setContent(container); | ||
setVbarPolicy(ScrollBarPolicy.AS_NEEDED); | ||
cleanUpUpgradeExternalLinks.setText(Localization.lang("Upgrade external PDF/PS links to use the '%0' field.", FieldName.FILE)); | ||
|
||
cleanUpFormatters = new FieldFormatterCleanupsPanel(Localization.lang("Run field formatter:"), Cleanups.DEFAULT_SAVE_ACTIONS); | ||
formatterContainer.getChildren().setAll(cleanUpFormatters); | ||
|
||
String currentPattern = Localization.lang("Filename format pattern") | ||
.concat(": ") | ||
.concat(Globals.prefs.get(JabRefPreferences.IMPORT_FILENAMEPATTERN)); | ||
cleanupRenamePDFLabel.setText(currentPattern); | ||
|
||
updateDisplay(cleanupPreset); | ||
} | ||
|
||
private void updateDisplay(CleanupPreset preset) { | ||
cleanUpDOI.setSelected(preset.isCleanUpDOI()); | ||
cleanUpDOI.setSelected(preset.isActive(CleanupPreset.CleanupStep.CLEAN_UP_DOI)); | ||
cleanUpEprint.setSelected(preset.isActive(CleanupPreset.CleanupStep.CLEANUP_EPRINT)); | ||
if (!cleanUpMovePDF.isDisabled()) { | ||
cleanUpMovePDF.setSelected(preset.isMovePDF()); | ||
cleanUpMovePDF.setSelected(preset.isActive(CleanupPreset.CleanupStep.MOVE_PDF)); | ||
} | ||
cleanUpMakePathsRelative.setSelected(preset.isMakePathsRelative()); | ||
cleanUpRenamePDF.setSelected(preset.isRenamePDF()); | ||
cleanUpRenamePDFonlyRelativePaths.setSelected(preset.isRenamePdfOnlyRelativePaths()); | ||
cleanUpRenamePDFonlyRelativePaths.setDisable(!cleanUpRenamePDF.isSelected()); | ||
cleanUpUpgradeExternalLinks.setSelected(preset.isCleanUpUpgradeExternalLinks()); | ||
cleanUpBiblatex.setSelected(preset.isConvertToBiblatex()); | ||
cleanUpBibtex.setSelected(preset.isConvertToBibtex()); | ||
cleanUpISSN.setSelected(preset.isCleanUpISSN()); | ||
cleanUpMakePathsRelative.setSelected(preset.isActive(CleanupPreset.CleanupStep.MAKE_PATHS_RELATIVE)); | ||
cleanUpRenamePDF.setSelected(preset.isRenamePDFActive()); | ||
cleanUpRenamePDFonlyRelativePaths.setSelected(preset.isActive(CleanupPreset.CleanupStep.RENAME_PDF_ONLY_RELATIVE_PATHS)); | ||
cleanUpUpgradeExternalLinks.setSelected(preset.isActive(CleanupPreset.CleanupStep.CLEAN_UP_UPGRADE_EXTERNAL_LINKS)); | ||
cleanUpBiblatex.setSelected(preset.isActive(CleanupPreset.CleanupStep.CONVERT_TO_BIBLATEX)); | ||
cleanUpBibtex.setSelected(preset.isActive(CleanupPreset.CleanupStep.CONVERT_TO_BIBTEX)); | ||
cleanUpISSN.setSelected(preset.isActive(CleanupPreset.CleanupStep.CLEAN_UP_ISSN)); | ||
cleanUpFormatters.setValues(preset.getFormatterCleanups()); | ||
} | ||
|
||
public CleanupPreset getCleanupPreset() { | ||
|
||
Set<CleanupPreset.CleanupStep> activeJobs = EnumSet.noneOf(CleanupPreset.CleanupStep.class); | ||
|
||
if (cleanUpMovePDF.isSelected()) { | ||
activeJobs.add(CleanupPreset.CleanupStep.MOVE_PDF); | ||
} | ||
|
||
if (cleanUpDOI.isSelected()) { | ||
activeJobs.add(CleanupPreset.CleanupStep.CLEAN_UP_DOI); | ||
} | ||
if (cleanUpEprint.isSelected()) { | ||
activeJobs.add(CleanupPreset.CleanupStep.CLEANUP_EPRINT); | ||
} | ||
if (cleanUpISSN.isSelected()) { | ||
activeJobs.add(CleanupPreset.CleanupStep.CLEAN_UP_ISSN); | ||
} | ||
|
@@ -149,7 +131,6 @@ public CleanupPreset getCleanupPreset() { | |
|
||
activeJobs.add(CleanupPreset.CleanupStep.FIX_FILE_LINKS); | ||
|
||
cleanupPreset = new CleanupPreset(activeJobs, cleanUpFormatters.getFormatterCleanups()); | ||
return cleanupPreset; | ||
return new CleanupPreset(activeJobs, cleanUpFormatters.getFormatterCleanups()); | ||
} | ||
} |
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.
I don't understand the second sentence