Revision: 18299
          http://bibdesk.svn.sourceforge.net/bibdesk/?rev=18299&view=rev
Author:   hofman
Date:     2011-12-07 13:19:52 +0000 (Wed, 07 Dec 2011)
Log Message:
-----------
Combine cite key and crossref formatters into single class

Modified Paths:
--------------
    trunk/bibdesk/BDSKCiteKeyFormatter.h
    trunk/bibdesk/BDSKCiteKeyFormatter.m
    trunk/bibdesk/BDSKEditor.h
    trunk/bibdesk/BDSKEditor.m
    trunk/bibdesk/BDSKTextImportController.h
    trunk/bibdesk/BDSKTextImportController.m
    trunk/bibdesk/Bibdesk.xcodeproj/project.pbxproj

Removed Paths:
-------------
    trunk/bibdesk/BDSKCrossrefFormatter.h
    trunk/bibdesk/BDSKCrossrefFormatter.m

Modified: trunk/bibdesk/BDSKCiteKeyFormatter.h
===================================================================
--- trunk/bibdesk/BDSKCiteKeyFormatter.h        2011-12-07 07:35:27 UTC (rev 
18298)
+++ trunk/bibdesk/BDSKCiteKeyFormatter.h        2011-12-07 13:19:52 UTC (rev 
18299)
@@ -38,7 +38,10 @@
 
 
 @interface BDSKCiteKeyFormatter : NSFormatter {
-
+    BOOL allowsEmptyString;
 }
 
+- (BOOL)allowsEmptyString;
+- (void)setAllowsEmptyString:(BOOL)flag;
+
 @end

Modified: trunk/bibdesk/BDSKCiteKeyFormatter.m
===================================================================
--- trunk/bibdesk/BDSKCiteKeyFormatter.m        2011-12-07 07:35:27 UTC (rev 
18298)
+++ trunk/bibdesk/BDSKCiteKeyFormatter.m        2011-12-07 13:19:52 UTC (rev 
18299)
@@ -38,6 +38,14 @@
 
 @implementation BDSKCiteKeyFormatter 
 
+- (BOOL)allowsEmptyString {
+    return allowsEmptyString;
+}
+
+- (void)setAllowsEmptyString:(BOOL)flag {
+    allowsEmptyString = flag;
+}
+
 - (NSString *)stringForObjectValue:(id)obj{
     return obj;
 }
@@ -47,7 +55,7 @@
 }
 
 - (BOOL)getObjectValue:(id *)obj forString:(NSString *)string 
errorDescription:(NSString **)error{
-    if([NSString isEmptyString:string]){
+    if(allowsEmptyString == NO && [NSString isEmptyString:string]){
         if(error) *error = NSLocalizedString(@"Empty cite keys are not 
allowed.", @"Error description");
         return NO;
     }

Deleted: trunk/bibdesk/BDSKCrossrefFormatter.h
===================================================================
--- trunk/bibdesk/BDSKCrossrefFormatter.h       2011-12-07 07:35:27 UTC (rev 
18298)
+++ trunk/bibdesk/BDSKCrossrefFormatter.h       2011-12-07 13:19:52 UTC (rev 
18299)
@@ -1,43 +0,0 @@
-//  BDSKCrossrefFormatter.h
-//  Created by Michael McCracken on Sat Jul 06 2002.
-/*
- This software is Copyright (c) 2002-2011
- Michael O. McCracken. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
-
- - Redistributions of source code must retain the above copyright
-   notice, this list of conditions and the following disclaimer.
-
- - Redistributions in binary form must reproduce the above copyright
-    notice, this list of conditions and the following disclaimer in
-    the documentation and/or other materials provided with the
-    distribution.
-
- - Neither the name of Michael O. McCracken nor the names of any
-    contributors may be used to endorse or promote products derived
-    from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import <Cocoa/Cocoa.h>
-
-
-@interface BDSKCrossrefFormatter : NSFormatter {
-
-}
-
-@end

Deleted: trunk/bibdesk/BDSKCrossrefFormatter.m
===================================================================
--- trunk/bibdesk/BDSKCrossrefFormatter.m       2011-12-07 07:35:27 UTC (rev 
18298)
+++ trunk/bibdesk/BDSKCrossrefFormatter.m       2011-12-07 13:19:52 UTC (rev 
18299)
@@ -1,75 +0,0 @@
-//  BDSKCiteStringFormatter.m
-//  Created by Michael McCracken on Sat Jul 06 2002.
-/*
- This software is Copyright (c) 2002-2011
- Michael O. McCracken. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
-
- - Redistributions of source code must retain the above copyright
-   notice, this list of conditions and the following disclaimer.
-
- - Redistributions in binary form must reproduce the above copyright
-    notice, this list of conditions and the following disclaimer in
-    the documentation and/or other materials provided with the
-    distribution.
-
- - Neither the name of Michael O. McCracken nor the names of any
-    contributors may be used to endorse or promote products derived
-    from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "BDSKCrossrefFormatter.h"
-#import "BDSKTypeManager.h"
-
-
-@implementation BDSKCrossrefFormatter 
-
-- (NSString *)stringForObjectValue:(id)obj{
-    return obj;
-}
-
-- (NSAttributedString *)attributedStringForObjectValue:(id)obj 
withDefaultAttributes:(NSDictionary *)attrs{
-    return [[[NSAttributedString alloc] initWithString:[self 
stringForObjectValue:obj] attributes:attrs] autorelease];
-}
-
-- (BOOL)getObjectValue:(id *)obj forString:(NSString *)string 
errorDescription:(NSString **)error{
-       NSCharacterSet *invalidSet = [[BDSKTypeManager sharedManager] 
invalidCharactersForField:BDSKCiteKeyString];
-    NSRange r = [string rangeOfCharacterFromSet:invalidSet];
-    if ( r.location != NSNotFound) {
-        if(error) *error = [NSString stringWithFormat:NSLocalizedString(@"The 
character \"%@\" is not allowed in a BibTeX cite key.", @"Error description"), 
[string substringWithRange:r]];
-        return NO;
-    }
-    *obj = string;
-    return YES;
-}
-
-- (BOOL)isPartialStringValid:(NSString *)partialString
-            newEditingString:(NSString **)newString
-            errorDescription:(NSString **)error{
-       NSCharacterSet *invalidSet = [[BDSKTypeManager sharedManager] 
invalidCharactersForField:BDSKCiteKeyString];
-    NSRange r = [partialString rangeOfCharacterFromSet:invalidSet];
-    if ( r.location != NSNotFound) {
-        // formatter will remove the last character typed
-        *newString = nil;
-        if(error) *error = [NSString stringWithFormat:NSLocalizedString(@"The 
character \"%@\" is not allowed in a BibTeX cite key.", @"Error description"), 
[partialString substringWithRange:r]];
-        return NO;
-    }else
-        return YES;
-}
-
-@end

Modified: trunk/bibdesk/BDSKEditor.h
===================================================================
--- trunk/bibdesk/BDSKEditor.h  2011-12-07 07:35:27 UTC (rev 18298)
+++ trunk/bibdesk/BDSKEditor.h  2011-12-07 13:19:52 UTC (rev 18299)
@@ -46,7 +46,7 @@
 #import <FileView/FileView.h>
 
 @class BDSKRatingButton, BDSKRatingButtonCell, BDSKStatusBar, 
BDSKZoomablePDFView, BDSKEditorTableView;
-@class BDSKCrossrefFormatter, BDSKComplexStringEditor;
+@class BDSKComplexStringEditor, BDSKCiteKeyFormatter;
 @class BibItem, BibAuthor;
 
 /*!
@@ -105,7 +105,7 @@
        
 // form cell formatter
     BDSKComplexStringFormatter *tableCellFormatter;
-    BDSKCrossrefFormatter *crossrefFormatter;
+    BDSKCiteKeyFormatter *crossrefFormatter;
        BDSKCitationFormatter *citationFormatter;
     
 // Author tableView

Modified: trunk/bibdesk/BDSKEditor.m
===================================================================
--- trunk/bibdesk/BDSKEditor.m  2011-12-07 07:35:27 UTC (rev 18298)
+++ trunk/bibdesk/BDSKEditor.m  2011-12-07 13:19:52 UTC (rev 18299)
@@ -51,7 +51,6 @@
 #import "BDSKDragWindow.h"
 #import "BibItem.h"
 #import "BDSKCiteKeyFormatter.h"
-#import "BDSKCrossrefFormatter.h"
 #import "BDSKAppController.h"
 #import "BDSKRatingButton.h"
 #import "BDSKComplexStringEditor.h"
@@ -211,7 +210,8 @@
     }
     
     tableCellFormatter = [[BDSKComplexStringFormatter alloc] 
initWithDelegate:self macroResolver:[publication macroResolver]];
-    crossrefFormatter = [[BDSKCrossrefFormatter alloc] init];
+    crossrefFormatter = [[BDSKCiteKeyFormatter alloc] init];
+    [crossrefFormatter setAllowsEmptyString:YES];
     citationFormatter = [[BDSKCitationFormatter alloc] initWithDelegate:self];
     
     [self resetFields];

Modified: trunk/bibdesk/BDSKTextImportController.h
===================================================================
--- trunk/bibdesk/BDSKTextImportController.h    2011-12-07 07:35:27 UTC (rev 
18298)
+++ trunk/bibdesk/BDSKTextImportController.h    2011-12-07 13:19:52 UTC (rev 
18299)
@@ -44,7 +44,7 @@
 #import "BDSKWebView.h"
 
 @class BibDocument, BibItem, BDSKEdgeView, WebDownload, 
BDSKComplexStringEditor;
-@class BDSKCiteKeyFormatter, BDSKCrossrefFormatter;
+@class BDSKCiteKeyFormatter;
 
 @interface BDSKTextImportController : NSWindowController <BDSKOwner, 
BDSKTextImportItemTableViewDelegate, NSTableViewDataSource, NSTextViewDelegate, 
NSSplitViewDelegate, BDSKComplexStringFormatterDelegate, 
BDSKCitationFormatterDelegate, BDSKWebViewDelegate> {
     IBOutlet NSTextView* sourceTextView;
@@ -76,7 +76,7 @@
     NSUndoManager *undoManager;
     
        BDSKComplexStringFormatter *tableCellFormatter;
-       BDSKCrossrefFormatter *crossrefFormatter;
+       BDSKCiteKeyFormatter *crossrefFormatter;
        BDSKCiteKeyFormatter *citeKeyFormatter;
        BDSKCitationFormatter *citationFormatter;
        NSTextView *tableFieldEditor;

Modified: trunk/bibdesk/BDSKTextImportController.m
===================================================================
--- trunk/bibdesk/BDSKTextImportController.m    2011-12-07 07:35:27 UTC (rev 
18298)
+++ trunk/bibdesk/BDSKTextImportController.m    2011-12-07 13:19:52 UTC (rev 
18299)
@@ -43,7 +43,6 @@
 #import "BDSKComplexStringEditor.h"
 #import "BDSKTypeSelectHelper.h"
 #import <WebKit/WebKit.h>
-#import "BDSKCrossrefFormatter.h"
 #import "BDSKCiteKeyFormatter.h"
 #import "BDSKFieldNameFormatter.h"
 #import "BDSKEdgeView.h"
@@ -123,7 +122,8 @@
         itemsAdded = [[NSMutableArray alloc] init];
                webSelection = nil;
                tableCellFormatter = [[BDSKComplexStringFormatter alloc] 
initWithDelegate:self macroResolver:[doc macroResolver]];
-               crossrefFormatter = [[BDSKCrossrefFormatter alloc] init];
+               crossrefFormatter = [[BDSKCiteKeyFormatter alloc] init];
+        [crossrefFormatter setAllowsEmptyString:YES];
                citationFormatter = [[BDSKCitationFormatter alloc] 
initWithDelegate:self];
                complexStringEditor = nil;
     }

Modified: trunk/bibdesk/Bibdesk.xcodeproj/project.pbxproj
===================================================================
--- trunk/bibdesk/Bibdesk.xcodeproj/project.pbxproj     2011-12-07 07:35:27 UTC 
(rev 18298)
+++ trunk/bibdesk/Bibdesk.xcodeproj/project.pbxproj     2011-12-07 13:19:52 UTC 
(rev 18299)
@@ -274,7 +274,6 @@
                CEB5D63F1072AE360001C135 /* SelectEncodingsPanel.xib in 
Resources */ = {isa = PBXBuildFile; fileRef = CEB5D6001072AE360001C135 /* 
SelectEncodingsPanel.xib */; };
                CEB5D6401072AE360001C135 /* TemplateDocument.xib in Resources 
*/ = {isa = PBXBuildFile; fileRef = CEB5D6021072AE360001C135 /* 
TemplateDocument.xib */; };
                CEB5D6411072AE360001C135 /* TextImport.xib in Resources */ = 
{isa = PBXBuildFile; fileRef = CEB5D6041072AE360001C135 /* TextImport.xib */; };
-               CEBA63D80A7CA0B500588BB7 /* BDSKCrossrefFormatter.m in Sources 
*/ = {isa = PBXBuildFile; fileRef = CEBA63D60A7CA0B400588BB7 /* 
BDSKCrossrefFormatter.m */; };
                CEBB8D8809C8B0D90074C79E /* Font.tiff in Resources */ = {isa = 
PBXBuildFile; fileRef = CEBB8D8709C8B0D90074C79E /* Font.tiff */; };
                CEBC676F0B4A845F00CE0B2D /* BDSKSearchGroupViewController.m in 
Sources */ = {isa = PBXBuildFile; fileRef = CEBC676D0B4A845F00CE0B2D /* 
BDSKSearchGroupViewController.m */; };
                CEC1CEA80F51D2CE00D18921 /* BDSKReadWriteLock.m in Sources */ = 
{isa = PBXBuildFile; fileRef = CEC1CEA60F51D2CE00D18921 /* BDSKReadWriteLock.m 
*/; };
@@ -1303,8 +1302,6 @@
                CEB772E90A34529D00B8A299 /* NSAttributedString_BDSKExtensions.m 
*/ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = 
sourcecode.c.objc; path = NSAttributedString_BDSKExtensions.m; sourceTree = 
"<group>"; };
                CEB9D5CD126CF0A000C1FADB /* French */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; name = 
French; path = French.lproj/WebGroupDownloads.html; sourceTree = "<group>"; };
                CEB9D5CE126CF0A400C1FADB /* German */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; name = 
German; path = German.lproj/WebGroupDownloads.html; sourceTree = "<group>"; };
-               CEBA63D50A7CA0B400588BB7 /* BDSKCrossrefFormatter.h */ = {isa = 
PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = 
BDSKCrossrefFormatter.h; sourceTree = "<group>"; };
-               CEBA63D60A7CA0B400588BB7 /* BDSKCrossrefFormatter.m */ = {isa = 
PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; 
path = BDSKCrossrefFormatter.m; sourceTree = "<group>"; };
                CEBB8D8709C8B0D90074C79E /* Font.tiff */ = {isa = 
PBXFileReference; lastKnownFileType = image.tiff; path = Font.tiff; sourceTree 
= "<group>"; };
                CEBC676C0B4A845F00CE0B2D /* BDSKSearchGroupViewController.h */ 
= {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = 
sourcecode.c.h; path = BDSKSearchGroupViewController.h; sourceTree = "<group>"; 
};
                CEBC676D0B4A845F00CE0B2D /* BDSKSearchGroupViewController.m */ 
= {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = 
sourcecode.c.objc; path = BDSKSearchGroupViewController.m; sourceTree = 
"<group>"; };
@@ -2257,7 +2254,6 @@
                                CEAB9F580B4FF20800673AC2 /* 
BDSKCitationFormatter.m */,
                                F9022C390758027800C3F701 /* 
BDSKCiteKeyFormatter.m */,
                                F9022C490758027800C3F701 /* 
BDSKComplexStringFormatter.m */,
-                               CEBA63D60A7CA0B400588BB7 /* 
BDSKCrossrefFormatter.m */,
                                F9022C450758027800C3F701 /* 
BDSKFieldNameFormatter.m */,
                                CE6DA03011052C81001CD28E /* 
BDSKFormatStringFormatter.m */,
                                3D7406920849F5430081EC6F /* 
BDSKTypeNameFormatter.m */,
@@ -2600,7 +2596,6 @@
                                CE34E9770A03C16B00222942 /* 
BDSKConditionsView.h */,
                                CE7595FD0ADDB0E0009C1329 /* BDSKContainerView.h 
*/,
                                F9022C3A0758027800C3F701 /* BDSKConverter.h */,
-                               CEBA63D50A7CA0B400588BB7 /* 
BDSKCrossrefFormatter.h */,
                                CE7A4A8C0B0B475B00D1B333 /* 
BDSKCustomCiteDrawerController.h */,
                                F97198BF0DADD32F00CA57AA /* 
BDSKDBLPGroupServer.h */,
                                F97198C10DADD32F00CA57AA /* 
BDSKDBLPWebServices.h */,
@@ -3623,7 +3618,6 @@
                                CE3A32D60A345C2400984DC2 /* 
NSAttributedString_BDSKExtensions.m in Sources */,
                                CE6DACC50A503ECF00123185 /* BDSKToolbarItem.m 
in Sources */,
                                F9FD63DD0A61B87800F9871B /* 
NSMenu_BDSKExtensions.m in Sources */,
-                               CEBA63D80A7CA0B500588BB7 /* 
BDSKCrossrefFormatter.m in Sources */,
                                CE6775170A8506A7003CFC58 /* 
NSDictionary_BDSKExtensions.m in Sources */,
                                CE95A57C0A88883300334DFA /* 
BDSKReadMeController.m in Sources */,
                                CE22E1CE0A8CCF9D002CEFB8 /* 
BDSKOrphanedFilesFinder.m in Sources */,

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


------------------------------------------------------------------------------
Cloud Services Checklist: Pricing and Packaging Optimization
This white paper is intended to serve as a reference, checklist and point of 
discussion for anyone considering optimizing the pricing and packaging model 
of a cloud services business. Read Now!
http://www.accelacomm.com/jaw/sfnl/114/51491232/
_______________________________________________
Bibdesk-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit

Reply via email to