From 3051c7a774e0ef3cf54bc518672eb85486517b7e Mon Sep 17 00:00:00 2001 From: Siedlerchr Date: Tue, 5 Jun 2018 10:10:01 +0200 Subject: [PATCH 1/7] Migrate Review field in entry preview to comment --- CHANGELOG.md | 1 + .../migrations/PreferencesMigrations.java | 63 +++++++++++-------- .../jabref/preferences/JabRefPreferences.java | 18 +++--- 3 files changed, 47 insertions(+), 35 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0b388a96140..2d11a9ad67d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,6 +40,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `# - We reworked the "Edit file" dialog to make it resizeable and improved the workflow for adding and editing files https://github.com/JabRef/jabref/issues/2970 - We fixed an issue where the month was not shown in the preview https://github.com/JabRef/jabref/issues/3239. - Rewritten logic to detect a second jabref instance. [#4023](https://github.com/JabRef/jabref/issues/4023) +- We fixed an issue where the default entry preview style still contained the field `review`. The field `review` in the style is now replaced with comment to be consistent with the entry editor [#4098](https://github.com/JabRef/jabref/issues/4098) ### Removed - The feature to "mark entries" was removed and merged with the groups functionality. For migration, a group is created for every value of the `__markedentry` field and the entry is added to this group. diff --git a/src/main/java/org/jabref/migrations/PreferencesMigrations.java b/src/main/java/org/jabref/migrations/PreferencesMigrations.java index fe1c9ae49a8..eb46c8796f2 100644 --- a/src/main/java/org/jabref/migrations/PreferencesMigrations.java +++ b/src/main/java/org/jabref/migrations/PreferencesMigrations.java @@ -22,6 +22,7 @@ import org.slf4j.LoggerFactory; public class PreferencesMigrations { + private static final Logger LOGGER = LoggerFactory.getLogger(PreferencesMigrations.class); private PreferencesMigrations() { @@ -40,6 +41,7 @@ public static void runMigrations() { upgradeKeyBindingsToJavaFX(); addCrossRefRelatedFieldsForAutoComplete(); upgradeObsoleteLookAndFeels(); + upgradePreviewStyleFromReviewToComment(); } /** @@ -157,7 +159,7 @@ private static void upgradeStoredCustomEntryTypes() { try { if (mainPrefsNode.nodeExists(JabRefPreferences.CUSTOMIZED_BIBTEX_TYPES) || - mainPrefsNode.nodeExists(JabRefPreferences.CUSTOMIZED_BIBLATEX_TYPES)) { + mainPrefsNode.nodeExists(JabRefPreferences.CUSTOMIZED_BIBLATEX_TYPES)) { // skip further processing as prefs already have been migrated } else { LOGGER.info("Migrating old custom entry types."); @@ -213,12 +215,12 @@ private static void migrateFileImportPattern(String oldStylePattern, String newS String preferenceFileNamePattern = mainPrefsNode.get(JabRefPreferences.IMPORT_FILENAMEPATTERN, null); if ((preferenceFileNamePattern != null) && - oldStylePattern.equals(preferenceFileNamePattern)) { + oldStylePattern.equals(preferenceFileNamePattern)) { // Upgrade the old-style File Name pattern to new one: mainPrefsNode.put(JabRefPreferences.IMPORT_FILENAMEPATTERN, newStylePattern); LOGGER.info("migrated old style " + JabRefPreferences.IMPORT_FILENAMEPATTERN + - " value \"" + oldStylePattern + "\" to new value \"" + - newStylePattern + "\" in the preference file"); + " value \"" + oldStylePattern + "\" to new value \"" + + newStylePattern + "\" in the preference file"); if (prefs.hasKey(JabRefPreferences.IMPORT_FILENAMEPATTERN)) { // Update also the key in the current application settings, if necessary: @@ -226,8 +228,8 @@ private static void migrateFileImportPattern(String oldStylePattern, String newS if (oldStylePattern.equals(fileNamePattern)) { prefs.put(JabRefPreferences.IMPORT_FILENAMEPATTERN, newStylePattern); LOGGER.info("migrated old style " + JabRefPreferences.IMPORT_FILENAMEPATTERN + - " value \"" + oldStylePattern + "\" to new value \"" + - newStylePattern + "\" in the running application"); + " value \"" + oldStylePattern + "\" to new value \"" + + newStylePattern + "\" in the running application"); } } } @@ -242,10 +244,10 @@ static void upgradeImportFileAndDirePatterns() { // Check for prefs node for Version <= 4.0 if (mainPrefsNode.get(JabRefPreferences.IMPORT_FILENAMEPATTERN, null) != null) { - String[] oldStylePatterns = new String[]{"\\bibtexkey", - "\\bibtexkey\\begin{title} - \\format[RemoveBrackets]{\\title}\\end{title}"}; - String[] newStylePatterns = new String[]{"[bibtexkey]", - "[bibtexkey] - [fulltitle]"}; + String[] oldStylePatterns = new String[] {"\\bibtexkey", + "\\bibtexkey\\begin{title} - \\format[RemoveBrackets]{\\title}\\end{title}"}; + String[] newStylePatterns = new String[] {"[bibtexkey]", + "[bibtexkey] - [fulltitle]"}; for (int i = 0; i < oldStylePatterns.length; i++) { migrateFileImportPattern(oldStylePatterns[i], newStylePatterns[i], prefs, mainPrefsNode); } @@ -281,11 +283,11 @@ private static void addCrossRefRelatedFieldsForAutoComplete() { } private static void migrateTypedKeyPrefs(JabRefPreferences prefs, Preferences oldPatternPrefs) - throws BackingStoreException { + throws BackingStoreException { LOGGER.info("Found old Bibtex Key patterns which will be migrated to new version."); GlobalBibtexKeyPattern keyPattern = GlobalBibtexKeyPattern.fromPattern( - prefs.get(JabRefPreferences.DEFAULT_BIBTEX_KEY_PATTERN)); + prefs.get(JabRefPreferences.DEFAULT_BIBTEX_KEY_PATTERN)); for (String key : oldPatternPrefs.keys()) { keyPattern.addBibtexKeyPattern(key, oldPatternPrefs.get(key, null)); } @@ -297,20 +299,27 @@ private static void upgradeObsoleteLookAndFeels() { String currentLandF = prefs.get(JabRefPreferences.WIN_LOOK_AND_FEEL); Stream.of("com.jgoodies.looks.windows.WindowsLookAndFeel", "com.jgoodies.looks.plastic.PlasticLookAndFeel", - "com.jgoodies.looks.plastic.Plastic3DLookAndFeel", "com.jgoodies.looks.plastic.PlasticXPLookAndFeel", - "com.sun.java.swing.plaf.gtk.GTKLookAndFeel") - .filter(style -> style.equals(currentLandF)) - .findAny() - .ifPresent(loolAndFeel -> { - if (OS.WINDOWS) { - String windowsLandF = "com.sun.java.swing.plaf.windows.WindowsLookAndFeel"; - prefs.put(JabRefPreferences.WIN_LOOK_AND_FEEL, windowsLandF); - LOGGER.info("Switched from obsolete look and feel " + currentLandF + " to " + windowsLandF); - } else { - String nimbusLandF = "javax.swing.plaf.nimbus.NimbusLookAndFeel"; - prefs.put(JabRefPreferences.WIN_LOOK_AND_FEEL, nimbusLandF); - LOGGER.info("Switched from obsolete look and feel " + currentLandF + " to " + nimbusLandF); - } - }); + "com.jgoodies.looks.plastic.Plastic3DLookAndFeel", "com.jgoodies.looks.plastic.PlasticXPLookAndFeel", + "com.sun.java.swing.plaf.gtk.GTKLookAndFeel") + .filter(style -> style.equals(currentLandF)) + .findAny() + .ifPresent(loolAndFeel -> { + if (OS.WINDOWS) { + String windowsLandF = "com.sun.java.swing.plaf.windows.WindowsLookAndFeel"; + prefs.put(JabRefPreferences.WIN_LOOK_AND_FEEL, windowsLandF); + LOGGER.info("Switched from obsolete look and feel " + currentLandF + " to " + windowsLandF); + } else { + String nimbusLandF = "javax.swing.plaf.nimbus.NimbusLookAndFeel"; + prefs.put(JabRefPreferences.WIN_LOOK_AND_FEEL, nimbusLandF); + LOGGER.info("Switched from obsolete look and feel " + currentLandF + " to " + nimbusLandF); + } + }); + } + + private static void upgradePreviewStyleFromReviewToComment() { + JabRefPreferences prefs = Globals.prefs; + String currentPreviewStyle = prefs.get(JabRefPreferences.PREVIEW_STYLE); + String migratedStyle = currentPreviewStyle.replace("\\begin{review}

Review: \\format[HTMLChars]{\\review} \\end{review}", "\\begin{comment}

Comment: \\format[HTMLChars]{\\comment} \\end{comment}"); + prefs.put(JabRefPreferences.PREVIEW_STYLE, migratedStyle); } } diff --git a/src/main/java/org/jabref/preferences/JabRefPreferences.java b/src/main/java/org/jabref/preferences/JabRefPreferences.java index 3f62361f1d3..34fd22a89c7 100644 --- a/src/main/java/org/jabref/preferences/JabRefPreferences.java +++ b/src/main/java/org/jabref/preferences/JabRefPreferences.java @@ -366,6 +366,15 @@ public class JabRefPreferences implements PreferencesService { // Id Entry Generator Preferences public static final String ID_ENTRY_GENERATOR = "idEntryGenerator"; + // Preview + //public because needed for pref migration + public static final String PREVIEW_STYLE = "previewStyle"; + + private static final String CYCLE_PREVIEW_POS = "cyclePreviewPos"; + private static final String CYCLE_PREVIEW = "cyclePreview"; + private static final String PREVIEW_PANEL_HEIGHT = "previewPanelHeightFX"; + private static final String PREVIEW_ENABLED = "previewEnabled"; + // Auto completion private static final String AUTO_COMPLETE = "autoComplete"; private static final String AUTOCOMPLETER_FIRSTNAME_MODE = "autoCompFirstNameMode"; @@ -396,13 +405,6 @@ public class JabRefPreferences implements PreferencesService { //GroupViewMode private static final String GROUP_INTERSECT_UNION_VIEW_MODE = "groupIntersectUnionViewModes"; - // Preview - private static final String CYCLE_PREVIEW_POS = "cyclePreviewPos"; - private static final String CYCLE_PREVIEW = "cyclePreview"; - private static final String PREVIEW_PANEL_HEIGHT = "previewPanelHeightFX"; - private static final String PREVIEW_STYLE = "previewStyle"; - private static final String PREVIEW_ENABLED = "previewEnabled"; - // Helper string private static final String USER_HOME = System.getProperty("user.home"); // solves the issue java.lang.RuntimeException: Internal graphics not initialized yet @@ -788,7 +790,7 @@ private JabRefPreferences() { + "\\begin{year}\\year\\end{year}\\begin{volume}, \\volume\\end{volume}" + "\\begin{pages}, \\format[FormatPagesForHTML]{\\pages} \\end{pages}__NEWLINE__" + "\\begin{abstract}

Abstract: \\format[HTMLChars]{\\abstract} \\end{abstract}__NEWLINE__" - + "\\begin{review}

Review: \\format[HTMLChars]{\\review} \\end{review}" + + "\\begin{comment}

Comment: \\format[HTMLChars]{\\comment} \\end{comment}" + "__NEWLINE__

"); setLanguageDependentDefaultValues(); From d30d65a12b403d98d80bfb7cc234a15ab15caaba Mon Sep 17 00:00:00 2001 From: Siedlerchr Date: Tue, 5 Jun 2018 10:13:29 +0200 Subject: [PATCH 2/7] Replace review with comment in every layout file --- .../layout/listrefs/listrefs.begin.layout | 30 +++++++++---------- .../resource/layout/listrefs/listrefs.layout | 10 +++---- .../layout/listrefs/listrefs.misc.layout | 10 +++---- .../layout/tablerefs/tablerefs.begin.layout | 4 +-- .../tablerefsabsbib.begin.layout | 26 ++++++++-------- .../tablerefsabsbib/tablerefsabsbib.layout | 10 +++---- 6 files changed, 45 insertions(+), 45 deletions(-) diff --git a/src/main/resources/resource/layout/listrefs/listrefs.begin.layout b/src/main/resources/resource/layout/listrefs/listrefs.begin.layout index b3c7469a96d..2d4118c7fcc 100644 --- a/src/main/resources/resource/layout/listrefs/listrefs.begin.layout +++ b/src/main/resources/resource/layout/listrefs/listrefs.begin.layout @@ -24,7 +24,7 @@ // Search settings var searchAbstract = true; // search in abstract -var searchReview = true; // search in review +var searchComment = true; // search in comment var noSquiggles = true; // ignore diacritics when searching var searchRegExp = false; // enable RegExp searches @@ -65,7 +65,7 @@ function loadTableData() { searchTable = document.getElementById('qs_table'); var allRows = searchTable.getElementsByTagName('tbody')[0].getElementsByTagName('tr'); - // split all rows into entryRows and infoRows (e.g. abstract, review, bibtex) + // split all rows into entryRows and infoRows (e.g. abstract, comment, bibtex) entryRows = new Array(); infoRows = new Array(); absRows = new Array(); revRows = new Array(); // get data from each row @@ -81,11 +81,11 @@ function loadTableData() { j ++; } else { infoRows[k++] = allRows[i]; - // check for abstract/review + // check for abstract/comment if (allRows[i].className.match(/abstract/)) { absRows.push(allRows[i]); absRowsData[j-1] = stripDiacritics(getTextContent(allRows[i])); - } else if (allRows[i].className.match(/review/)) { + } else if (allRows[i].className.match(/comment/)) { revRows.push(allRows[i]); revRowsData[j-1] = stripDiacritics(getTextContent(allRows[i])); } @@ -141,7 +141,7 @@ function quickSearch(){ if(searchAbstract && absRowsData[i]!=undefined) { if (absRowsData[i].search(textRegExp) != -1){ found=true; } } - if(searchReview && revRowsData[i]!=undefined) { + if(searchComment && revRowsData[i]!=undefined) { if (revRowsData[i].search(textRegExp) != -1){ found=true; } } } @@ -217,8 +217,8 @@ function toggleInfo(articleid,info) { if (abs && info == 'abstract') { abs.className.indexOf('noshow') == -1?abs.className = 'abstract noshow':abs.className = 'abstract show'; - } else if (rev && info == 'review') { - rev.className.indexOf('noshow') == -1?rev.className = 'review noshow':rev.className = 'review show'; + } else if (rev && info == 'comment') { + rev.className.indexOf('noshow') == -1?rev.className = 'comment noshow':rev.className = 'comment show'; } else if (bib && info == 'bibtex') { bib.className.indexOf('noshow') == -1?bib.className = 'bibtex noshow':bib.className = 'bibtex show'; } else { @@ -240,12 +240,12 @@ function toggleInfo(articleid,info) { } } - // When there's a combination of abstract/review/bibtex showing, need to add class for correct styling + // When there's a combination of abstract/comment/bibtex showing, need to add class for correct styling if(absshow) { (revshow||bibshow)?abs.className = 'abstract nextshow':abs.className = 'abstract'; } if (revshow) { - bibshow?rev.className = 'review nextshow': rev.className = 'review'; + bibshow?rev.className = 'comment nextshow': rev.className = 'comment'; } } @@ -304,8 +304,8 @@ function updateSetting(obj){ searchAbstract=!searchAbstract; redoQS(); break; - case "opt_searchRev": - searchReview=!searchReview; + case "opt_searchComment": + searchComment=!searchComment; redoQS(); break; case "opt_useRegExp": @@ -322,12 +322,12 @@ function updateSetting(obj){ function initPreferences(){ if(searchAbstract){document.getElementById("opt_searchAbs").checked = true;} - if(searchReview){document.getElementById("opt_searchRev").checked = true;} + if(searchComment){document.getElementById("opt_searchComment").checked = true;} if(noSquiggles){document.getElementById("opt_noAccents").checked = true;} if(searchRegExp){document.getElementById("opt_useRegExp").checked = true;} if(numAbs==0) {document.getElementById("opt_searchAbs").parentNode.style.display = 'none';} - if(numRev==0) {document.getElementById("opt_searchRev").parentNode.style.display = 'none';} + if(numRev==0) {document.getElementById("opt_searchComment").parentNode.style.display = 'none';} } function toggleSettings(){ @@ -375,7 +375,7 @@ td a:hover { text-decoration: underline; } tr.noshow { display: none;} tr.highlight td { background-color: #EFEFEF; border-top: 2px #2E2E2E solid; font-weight: bold; } -tr.abstract td, tr.review td, tr.bibtex td { background-color: #EFEFEF; text-align: justify; border-bottom: 2px #2E2E2E solid; } +tr.abstract td, tr.comment td, tr.bibtex td { background-color: #EFEFEF; text-align: justify; border-bottom: 2px #2E2E2E solid; } tr.nextshow td { border-bottom-style: none; } tr.bibtex pre { width: 100%; overflow: auto; white-space: pre-wrap;} @@ -396,7 +396,7 @@ p.infolinks { margin: 0.3em 0em 0em 0em; padding: 0px; }