Revision: 28244
          http://sourceforge.net/p/bibdesk/svn/28244
Author:   hofman
Date:     2023-05-17 09:42:40 +0000 (Wed, 17 May 2023)
Log Message:
-----------
Add an extra pref option to ovverride existing cite keys when auto generating

Modified Paths:
--------------
    trunk/bibdesk/BDSKEditor.m
    trunk/bibdesk/BDSKStringConstants.h
    trunk/bibdesk/BDSKStringConstants.m
    trunk/bibdesk/Base.lproj/BibPref_CiteKey.xib
    trunk/bibdesk/BibItem.h
    trunk/bibdesk/BibItem.m
    trunk/bibdesk/Preferences.plist
    trunk/bibdesk/de.lproj/BibPref_CiteKey.strings
    trunk/bibdesk/en.lproj/BibPref_CiteKey.strings
    trunk/bibdesk/fr.lproj/BibPref_CiteKey.strings

Modified: trunk/bibdesk/BDSKEditor.m
===================================================================
--- trunk/bibdesk/BDSKEditor.m  2023-05-16 22:56:28 UTC (rev 28243)
+++ trunk/bibdesk/BDSKEditor.m  2023-05-17 09:42:40 UTC (rev 28244)
@@ -2853,7 +2853,7 @@
 }
 
 - (void)updateCiteKeyAutoGenerateStatus{
-       if ([publication hasEditedCiteKey] == NO && [[NSUserDefaults 
standardUserDefaults] boolForKey:BDSKCiteKeyAutogenerateKey]) {
+       if ([publication shouldAutogenerateCiteKey]) {
                if ([[statusBar iconIdentifiers] 
containsObject:BDSKNeedsToGenerateCiteKeyIdentifier] == NO) {
                        NSString *tooltip = NSLocalizedString(@"The cite key 
needs to be generated.", @"Tool tip message");
                        [statusBar addIcon:[NSImage 
imageNamed:@"CiteKeyPreferences"] 
withIdentifier:BDSKNeedsToGenerateCiteKeyIdentifier toolTip:tooltip];

Modified: trunk/bibdesk/BDSKStringConstants.h
===================================================================
--- trunk/bibdesk/BDSKStringConstants.h 2023-05-16 22:56:28 UTC (rev 28243)
+++ trunk/bibdesk/BDSKStringConstants.h 2023-05-17 09:42:40 UTC (rev 28244)
@@ -121,6 +121,7 @@
 extern NSString *BDSKCiteKeyFormatKey;
 extern NSString *BDSKCiteKeyFormatPresetKey;
 extern NSString *BDSKCiteKeyAutogenerateKey;
+extern NSString *BDSKCiteKeyAutogenerateExistingKey;
 extern NSString *BDSKCiteKeyLowercaseKey;
 extern NSString *BDSKCiteKeyCleanOptionKey;
 

Modified: trunk/bibdesk/BDSKStringConstants.m
===================================================================
--- trunk/bibdesk/BDSKStringConstants.m 2023-05-16 22:56:28 UTC (rev 28243)
+++ trunk/bibdesk/BDSKStringConstants.m 2023-05-17 09:42:40 UTC (rev 28244)
@@ -97,6 +97,7 @@
 NSString *BDSKCiteKeyFormatKey = @"Cite Key Format";
 NSString *BDSKCiteKeyFormatPresetKey = @"Cite Key Format Preset";
 NSString *BDSKCiteKeyAutogenerateKey = @"Cite Key Autogenerate";
+NSString *BDSKCiteKeyAutogenerateExistingKey = @"Cite Key Autogenerate 
Existing";
 NSString *BDSKCiteKeyLowercaseKey = @"Cite Key Generate Lowercase";
 NSString *BDSKCiteKeyCleanOptionKey = @"Cite Key Clean Braces or TeX";
 

Modified: trunk/bibdesk/Base.lproj/BibPref_CiteKey.xib
===================================================================
--- trunk/bibdesk/Base.lproj/BibPref_CiteKey.xib        2023-05-16 22:56:28 UTC 
(rev 28243)
+++ trunk/bibdesk/Base.lproj/BibPref_CiteKey.xib        2023-05-17 09:42:40 UTC 
(rev 28244)
@@ -24,8 +24,8 @@
         </customObject>
         <customObject id="-1" userLabel="First Responder" 
customClass="FirstResponder"/>
         <customObject id="-3" userLabel="Application" customClass="NSObject"/>
-        <customView misplaced="YES" 
translatesAutoresizingMaskIntoConstraints="NO" id="5" userLabel="View">
-            <rect key="frame" x="0.0" y="0.0" width="539" height="443"/>
+        <customView translatesAutoresizingMaskIntoConstraints="NO" id="5" 
userLabel="View">
+            <rect key="frame" x="0.0" y="0.0" width="539" height="468"/>
             <subviews>
                 <textField toolTip="This is the cite key that would be 
generated with the current settings for the item below" 
verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" 
translatesAutoresizingMaskIntoConstraints="NO" id="220">
                     <rect key="frame" x="52" y="120" width="8" height="21"/>
@@ -39,7 +39,7 @@
                     </connections>
                 </textField>
                 <textField verticalHuggingPriority="750" 
horizontalCompressionResistancePriority="250" 
translatesAutoresizingMaskIntoConstraints="NO" id="210">
-                    <rect key="frame" x="18" y="402" width="161" height="16"/>
+                    <rect key="frame" x="18" y="432" width="161" height="16"/>
                     <textFieldCell key="cell" scrollable="YES" 
lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="left" 
title="Cite Key Autogeneration" id="411">
                         <font key="font" metaFont="systemBold"/>
                         <color key="textColor" name="controlTextColor" 
catalog="System" colorSpace="catalog"/>
@@ -47,7 +47,7 @@
                     </textFieldCell>
                 </textField>
                 <button toolTip="Choose to automatically generate a cite key 
string when all the fields used in the format string are set" 
horizontalHuggingPriority="750" verticalHuggingPriority="750" 
translatesAutoresizingMaskIntoConstraints="NO" id="209">
-                    <rect key="frame" x="30" y="377" width="381" height="18"/>
+                    <rect key="frame" x="30" y="407" width="381" height="18"/>
                     <buttonCell key="cell" type="check" title="Autogenerate 
the cite key when enough fields are supplied" bezelStyle="regularSquare" 
imagePosition="left" alignment="left" inset="2" id="410">
                         <behavior key="behavior" changeContents="YES" 
doesNotDimImage="YES" lightByContents="YES"/>
                         <font key="font" metaFont="system"/>
@@ -118,7 +118,7 @@
                     </connections>
                 </popUpButton>
                 <button toolTip="Go to the online help for more information on 
the format syntax" horizontalHuggingPriority="750" 
verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" 
id="129">
-                    <rect key="frame" x="496" y="374" width="25" height="25"/>
+                    <rect key="frame" x="496" y="404" width="25" height="25"/>
                     <buttonCell key="cell" type="help" bezelStyle="helpButton" 
alignment="center" borderStyle="border" inset="2" id="406">
                         <behavior key="behavior" pushIn="YES" 
lightByBackground="YES" lightByGray="YES"/>
                         <font key="font" metaFont="system"/>
@@ -297,8 +297,20 @@
                         <outlet property="nextKeyView" destination="140" 
id="GCT-cg-h24"/>
                     </connections>
                 </button>
+                <button toolTip="Choose to override existing cite keys by 
automatically generate ones" horizontalHuggingPriority="750" 
verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" 
id="SjW-Y0-MJq">
+                    <rect key="frame" x="50" y="385" width="179" height="18"/>
+                    <buttonCell key="cell" type="check" title="Override 
existing cite key" bezelStyle="regularSquare" imagePosition="left" 
alignment="left" inset="2" id="gOj-Wl-9Ek">
+                        <behavior key="behavior" changeContents="YES" 
doesNotDimImage="YES" lightByContents="YES"/>
+                        <font key="font" metaFont="system"/>
+                    </buttonCell>
+                    <connections>
+                        <binding destination="MHB-P7-ZeL" name="value" 
keyPath="values.Cite Key Autogenerate" id="RVU-ir-Jjl"/>
+                        <outlet property="nextKeyView" destination="129" 
id="iMf-7u-ceJ"/>
+                    </connections>
+                </button>
             </subviews>
             <constraints>
+                <constraint firstItem="SjW-Y0-MJq" firstAttribute="leading" 
secondItem="5" secondAttribute="leading" constant="52" id="17b-7k-gvZ"/>
                 <constraint firstAttribute="bottom" secondItem="151" 
secondAttribute="bottom" constant="20" symbolic="YES" id="1fQ-FY-XkK"/>
                 <constraint firstAttribute="trailing" secondItem="129" 
secondAttribute="trailing" constant="20" symbolic="YES" id="2cA-bW-s4o"/>
                 <constraint firstItem="3aV-ee-hxp" firstAttribute="leading" 
secondItem="f17-94-izx" secondAttribute="trailing" constant="8" symbolic="YES" 
id="530-pj-KoF"/>
@@ -311,6 +323,7 @@
                 <constraint firstItem="129" firstAttribute="trailing" 
secondItem="151" secondAttribute="trailing" id="ApC-jd-HAT"/>
                 <constraint firstItem="210" firstAttribute="top" 
secondItem="5" secondAttribute="top" constant="20" symbolic="YES" 
id="C55-GP-FHn"/>
                 <constraint firstItem="251" firstAttribute="top" 
secondItem="140" secondAttribute="bottom" constant="20" id="DdU-AB-JQW"/>
+                <constraint firstItem="SjW-Y0-MJq" firstAttribute="top" 
secondItem="209" secondAttribute="bottom" constant="6" symbolic="YES" 
id="Doj-gp-UJs"/>
                 <constraint firstItem="3aV-ee-hxp" firstAttribute="width" 
secondItem="o1O-51-Xrt" secondAttribute="width" id="F5Q-n7-H0N"/>
                 <constraint firstItem="151" firstAttribute="top" 
secondItem="220" secondAttribute="bottom" constant="20" id="FdD-YX-NRJ"/>
                 <constraint firstItem="278" firstAttribute="leading" 
relation="greaterThanOrEqual" secondItem="5" secondAttribute="leading" 
constant="32" id="GHh-cv-9lV"/>
@@ -322,6 +335,7 @@
                 <constraint firstItem="251" firstAttribute="leading" 
secondItem="140" secondAttribute="leading" id="QUh-PP-UPw"/>
                 <constraint firstItem="o1O-51-Xrt" firstAttribute="leading" 
secondItem="272" secondAttribute="trailing" constant="6" symbolic="YES" 
id="Rgh-oA-rxG"/>
                 <constraint firstAttribute="trailing" 
relation="greaterThanOrEqual" secondItem="210" secondAttribute="trailing" 
constant="20" symbolic="YES" id="S6b-4b-eXV"/>
+                <constraint firstAttribute="trailing" 
relation="greaterThanOrEqual" secondItem="SjW-Y0-MJq" 
secondAttribute="trailing" constant="20" symbolic="YES" id="SM9-sm-Tjs"/>
                 <constraint firstItem="220" firstAttribute="leading" 
secondItem="5" secondAttribute="leading" constant="52" id="SN0-uS-PxX"/>
                 <constraint firstItem="140" firstAttribute="firstBaseline" 
secondItem="158" secondAttribute="firstBaseline" id="Tg2-I8-fej"/>
                 <constraint firstItem="254" firstAttribute="leading" 
secondItem="140" secondAttribute="leading" id="VhI-7F-f8C"/>
@@ -336,7 +350,6 @@
                 <constraint firstItem="270" firstAttribute="top" 
secondItem="254" secondAttribute="bottom" constant="20" id="b42-kf-77D"/>
                 <constraint firstItem="251" firstAttribute="trailing" 
secondItem="140" secondAttribute="trailing" id="dpd-Ar-hTV"/>
                 <constraint firstAttribute="trailing" 
relation="greaterThanOrEqual" secondItem="270" secondAttribute="trailing" 
constant="20" symbolic="YES" id="eXq-BT-Wbi"/>
-                <constraint firstItem="6" firstAttribute="top" 
secondItem="209" secondAttribute="bottom" constant="20" id="fPj-Rv-ubf"/>
                 <constraint firstItem="158" firstAttribute="leading" 
secondItem="209" secondAttribute="leading" id="gzF-Jd-zvH"/>
                 <constraint firstAttribute="trailing" 
relation="greaterThanOrEqual" secondItem="6" secondAttribute="trailing" 
constant="20" symbolic="YES" id="hdu-s6-dW7"/>
                 <constraint firstItem="f17-94-izx" firstAttribute="leading" 
secondItem="o1O-51-Xrt" secondAttribute="trailing" constant="8" symbolic="YES" 
id="l0N-x8-vfh"/>
@@ -345,6 +358,7 @@
                 <constraint firstItem="270" firstAttribute="leading" 
secondItem="5" secondAttribute="leading" constant="32" id="o4N-f5-Eyh"/>
                 <constraint firstItem="210" firstAttribute="leading" 
secondItem="5" secondAttribute="leading" constant="20" symbolic="YES" 
id="o6B-vP-JAQ"/>
                 <constraint firstItem="151" firstAttribute="leading" 
secondItem="220" secondAttribute="leading" id="oIJ-8x-0p6"/>
+                <constraint firstItem="6" firstAttribute="top" 
secondItem="SjW-Y0-MJq" secondAttribute="bottom" constant="28" id="pAU-wB-isN"/>
                 <constraint firstItem="127" firstAttribute="leading" 
secondItem="270" secondAttribute="leading" id="pAa-Oi-ddU"/>
                 <constraint firstItem="158" firstAttribute="leading" 
relation="greaterThanOrEqual" secondItem="5" secondAttribute="leading" 
constant="32" id="qYl-ud-A5a"/>
                 <constraint firstItem="129" firstAttribute="firstBaseline" 
secondItem="209" secondAttribute="firstBaseline" id="tSr-o8-gPe"/>

Modified: trunk/bibdesk/BibItem.h
===================================================================
--- trunk/bibdesk/BibItem.h     2023-05-16 22:56:28 UTC (rev 28243)
+++ trunk/bibdesk/BibItem.h     2023-05-17 09:42:40 UTC (rev 28244)
@@ -591,11 +591,7 @@
 @property (nonatomic, readonly) BOOL hasEmptyOrDefaultCiteKey;
 @property (nonatomic, readonly) BOOL hasEditedCiteKey;
 
-/*
-    @method canGenerateAndSetCiteKey
-    @abstract Returns a boolean indicating whether all fields required for the 
generated cite key are set and whether the item needs a cite key (checks 
hasEmptyOrDefaultCiteKey).
-    @discussion - 
-*/
+@property (nonatomic, readonly) BOOL shouldAutogenerateCiteKey;
 @property (nonatomic, readonly) BOOL canGenerateAndSetCiteKey;
 
 /*

Modified: trunk/bibdesk/BibItem.m
===================================================================
--- trunk/bibdesk/BibItem.m     2023-05-16 22:56:28 UTC (rev 28243)
+++ trunk/bibdesk/BibItem.m     2023-05-17 09:42:40 UTC (rev 28244)
@@ -199,7 +199,7 @@
 @implementation BibItem
 
 @synthesize owner, macroResolver, downloads, fileOrder, identifierURL, 
date=pubDate, dateAdded, dateModified, pubType, citeKey, hasEditedCiteKey, 
hasBeenEdited, pubFields, searchScore, imported, itemIndex;
-@dynamic undoManager, localFiles, existingLocalFiles, remoteURLs, usedMacros, 
usedLocalMacros, allPeople, people, numberOfAuthors, pubAuthors, firstAuthor, 
secondAuthor, thirdAuthor, lastAuthor, bibTeXAuthorString, 
numberOfAuthorsOrEditors, pubAuthorsOrEditors, firstAuthorOrEditor, 
secondAuthorOrEditor, thirdAuthorOrEditor, lastAuthorOrEditor, crossrefParent, 
title, displayTitle, container, sortingTitle, sortingContainer, 
sortingBooktitle, rating, color, suggestedCiteKey, hasEmptyOrDefaultCiteKey, 
canGenerateAndSetCiteKey, allFieldNames, searchIndexInfo, completionObject, 
bibTeXString, RISStringValue, MODSXMLValue, endNoteXMLValue, wordXMLValue, 
RSSStringValue, requiredFields, optionalFields, defaultFields, allFields, 
fields, urls, persons, fieldComponents, authors, editors, authorsOrEditors, 
keywords, currentDate, textSkimNotes, richTextSkimNotes, linkedText, remoteURL, 
localURL, localUrlPath, URLFields, skimNotesForLocalURL, bdskURL;
+@dynamic undoManager, localFiles, existingLocalFiles, remoteURLs, usedMacros, 
usedLocalMacros, allPeople, people, numberOfAuthors, pubAuthors, firstAuthor, 
secondAuthor, thirdAuthor, lastAuthor, bibTeXAuthorString, 
numberOfAuthorsOrEditors, pubAuthorsOrEditors, firstAuthorOrEditor, 
secondAuthorOrEditor, thirdAuthorOrEditor, lastAuthorOrEditor, crossrefParent, 
title, displayTitle, container, sortingTitle, sortingContainer, 
sortingBooktitle, rating, color, suggestedCiteKey, hasEmptyOrDefaultCiteKey, 
shouldAutogenerateCiteKey, canGenerateAndSetCiteKey, allFieldNames, 
searchIndexInfo, completionObject, bibTeXString, RISStringValue, MODSXMLValue, 
endNoteXMLValue, wordXMLValue, RSSStringValue, requiredFields, optionalFields, 
defaultFields, allFields, fields, urls, persons, fieldComponents, authors, 
editors, authorsOrEditors, keywords, currentDate, textSkimNotes, 
richTextSkimNotes, linkedText, remoteURL, localURL, localUrlPath, URLFields, 
skimNotesForLocalURL, bdskURL;
 
 + (void)initialize
 {
@@ -1092,14 +1092,21 @@
     return [NSString isEmptyString:key] || [key 
isEqualToString:defaultCiteKey] || [key isEqualToString:placeholderCiteKey];
 }
 
+- (BOOL)shouldAutogenerateCiteKey
+{
+    if ([[NSUserDefaults standardUserDefaults] 
boolForKey:BDSKCiteKeyAutogenerateKey] == NO)
+        return NO;
+    return [[NSUserDefaults standardUserDefaults] 
boolForKey:BDSKCiteKeyAutogenerateExistingKey] ? [self 
hasEmptyOrDefaultCiteKey] : hasEditedCiteKey;
+}
+
 - (BOOL)canGenerateAndSetCiteKey
 {
     NSArray *requiredFields = [[BDSKTypeManager sharedManager] 
requiredFieldsForCiteKey];
     
     // see if it needs to be set (hasEmptyOrDefaultCiteKey)
-       if (nil == requiredFields || hasEditedCiteKey)
+    if (nil == requiredFields || ([[NSUserDefaults standardUserDefaults] 
boolForKey:BDSKCiteKeyAutogenerateExistingKey] ? hasEditedCiteKey : [self 
hasEmptyOrDefaultCiteKey]))
                return NO;
-       
+    
     // see if we have enough fields to generate it
        for (NSString *fieldName in requiredFields) {
                if ([fieldName isEqualToString:BDSKAuthorEditorString]) {

Modified: trunk/bibdesk/Preferences.plist
===================================================================
--- trunk/bibdesk/Preferences.plist     2023-05-16 22:56:28 UTC (rev 28243)
+++ trunk/bibdesk/Preferences.plist     2023-05-17 09:42:40 UTC (rev 28244)
@@ -720,6 +720,8 @@
                                <dict>
                                        <key>Cite Key Autogenerate</key>
                                        <false/>
+                                       <key>Cite Key Autogenerate 
Existing</key>
+                                       <false/>
                                        <key>Cite Key Clean Braces or TeX</key>
                                        <integer>2</integer>
                                        <key>Cite Key Format</key>

Modified: trunk/bibdesk/de.lproj/BibPref_CiteKey.strings
===================================================================
(Binary files differ)

Modified: trunk/bibdesk/en.lproj/BibPref_CiteKey.strings
===================================================================
(Binary files differ)

Modified: trunk/bibdesk/fr.lproj/BibPref_CiteKey.strings
===================================================================
(Binary files differ)

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.



_______________________________________________
Bibdesk-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit

Reply via email to