Revision: 18296
http://bibdesk.svn.sourceforge.net/bibdesk/?rev=18296&view=rev
Author: hofman
Date: 2011-12-06 13:23:25 +0000 (Tue, 06 Dec 2011)
Log Message:
-----------
set known fields for field name formatter as property rather than using a
delegate method
Modified Paths:
--------------
trunk/bibdesk/BDSKConditionController.h
trunk/bibdesk/BDSKConditionController.m
trunk/bibdesk/BDSKFieldNameFormatter.h
trunk/bibdesk/BDSKFieldNameFormatter.m
trunk/bibdesk/BDSKFieldSheetController.h
trunk/bibdesk/BDSKFieldSheetController.m
trunk/bibdesk/BDSKFindController.h
trunk/bibdesk/BDSKFindController.m
Modified: trunk/bibdesk/BDSKConditionController.h
===================================================================
--- trunk/bibdesk/BDSKConditionController.h 2011-12-06 07:35:09 UTC (rev
18295)
+++ trunk/bibdesk/BDSKConditionController.h 2011-12-06 13:23:25 UTC (rev
18296)
@@ -38,12 +38,11 @@
#import <Cocoa/Cocoa.h>
#import "BDSKCondition.h"
-#import "BDSKFieldNameFormatter.h"
@class BDSKFilterController, BDSKRatingButton;
-@interface BDSKConditionController : NSViewController
<BDSKFieldNameFormatterDelegate> {
+@interface BDSKConditionController : NSViewController {
IBOutlet NSObjectController *objectController;
IBOutlet NSComboBox *keyComboBox;
IBOutlet NSPopUpButton *comparisonPopUp;
Modified: trunk/bibdesk/BDSKConditionController.m
===================================================================
--- trunk/bibdesk/BDSKConditionController.m 2011-12-06 07:35:09 UTC (rev
18295)
+++ trunk/bibdesk/BDSKConditionController.m 2011-12-06 13:23:25 UTC (rev
18296)
@@ -42,6 +42,7 @@
#import "BDSKBooleanValueTransformer.h"
#import "BDSKRatingButton.h"
#import "NSInvocation_BDSKExtensions.h"
+#import "BDSKFieldNameFormatter.h"
#define BDSKBooleanValueTransformerName @"BDSKBooleanValueTransformer"
#define BDSKTriStateValueTransformerName @"BDSKTriStateValueTransformer"
@@ -134,8 +135,8 @@
[toDateTextField setFormatter:formatter];
BDSKFieldNameFormatter *fieldFormatter = [[[BDSKFieldNameFormatter alloc]
init] autorelease];
+ [fieldFormatter setKnownFieldNames:keys];
[keyComboBox setFormatter:fieldFormatter];
- [fieldFormatter setDelegate:self];
[self layoutComparisonControls];
[self layoutValueControls];
@@ -151,13 +152,6 @@
}
}
-- (NSArray *)fieldNameFormatterKnownFieldNames:(BDSKFieldNameFormatter
*)formatter {
- if (formatter == [keyComboBox formatter])
- return keys;
- else
- return nil;
-}
-
- (IBAction)addNewCondition:(id)sender {
[filterController insertNewConditionAfter:self];
}
@@ -198,6 +192,7 @@
if (keys != newKeys) {
[keys release];
keys = [newKeys mutableCopy];
+ [(BDSKFieldNameFormatter *)[keyComboBox formatter]
setKnownFieldNames:keys];
}
}
Modified: trunk/bibdesk/BDSKFieldNameFormatter.h
===================================================================
--- trunk/bibdesk/BDSKFieldNameFormatter.h 2011-12-06 07:35:09 UTC (rev
18295)
+++ trunk/bibdesk/BDSKFieldNameFormatter.h 2011-12-06 13:23:25 UTC (rev
18296)
@@ -40,19 +40,12 @@
#import "BDSKStringConstants.h"
#import "BDSKTypeManager.h"
-@class BDSKFieldNameFormatter;
-@protocol BDSKFieldNameFormatterDelegate <NSObject>
-@optional
-- (NSArray *)fieldNameFormatterKnownFieldNames:(BDSKFieldNameFormatter
*)formatter;
-@end
-
-
@interface BDSKFieldNameFormatter : NSFormatter {
- id<BDSKFieldNameFormatterDelegate> delegate;
+ NSArray *knownFieldNames;
}
-- (id<BDSKFieldNameFormatterDelegate>)delegate;
-- (void)setDelegate:(id<BDSKFieldNameFormatterDelegate>)newDelegate;
+- (NSArray *)knownFieldNames;
+- (void)setKnownFieldNames:(NSArray *)array;
@end
Modified: trunk/bibdesk/BDSKFieldNameFormatter.m
===================================================================
--- trunk/bibdesk/BDSKFieldNameFormatter.m 2011-12-06 07:35:09 UTC (rev
18295)
+++ trunk/bibdesk/BDSKFieldNameFormatter.m 2011-12-06 13:23:25 UTC (rev
18296)
@@ -49,15 +49,22 @@
@implementation BDSKFieldNameFormatter
-- (id)delegate {
- return delegate;
+- (void)dealloc {
+ BDSKDESTROY(knownFieldNames);
+ [super dealloc];
}
-- (void)setDelegate:(id)newDelegate {
- BDSKPRECONDITION(newDelegate == nil || [newDelegate
respondsToSelector:@selector(fieldNameFormatterKnownFieldNames:)]);
- delegate = newDelegate;
+- (NSArray *)knownFieldNames {
+ return knownFieldNames;
}
+- (void)setKnownFieldNames:(NSArray *)array {
+ if (knownFieldNames != array) {
+ [knownFieldNames release];
+ knownFieldNames = [array copy];
+ }
+}
+
- (NSString *)stringForObjectValue:(id)obj{
return obj;
}
@@ -67,8 +74,8 @@
}
- (BOOL)getObjectValue:(id *)obj forString:(NSString *)string
errorDescription:(NSString **)error{
- // first check the delegate for known field names, which may include
special names containing spaces such as Cite Key, this is called on Leopard
when auto-completing an item from the combobox
- if ([[delegate fieldNameFormatterKnownFieldNames:self]
containsObject:string]) {
+ // first check for known field names, which may include special names
containing spaces such as Cite Key, this is called on Leopard when
auto-completing an item from the combobox
+ if ([knownFieldNames containsObject:string]) {
*obj = string;
return YES;
}
@@ -98,8 +105,8 @@
- (BOOL)isPartialStringValid:(NSString **)partialStringPtr
proposedSelectedRange:(NSRangePointer)proposedSelRangePtr
originalString:(NSString *)origString
originalSelectedRange:(NSRange)origSelRange errorDescription:(NSString **)error
{
NSString *partialString = *partialStringPtr;
- // first check the delegate for known field names, which may include
special names containing spaces such as Cite Key, this is called on Leopard
when auto-completing an item from the combobox
- if ([[delegate fieldNameFormatterKnownFieldNames:self]
containsObject:partialString]) {
+ // first check for known field names, which may include special names
containing spaces such as Cite Key, this is called on Leopard when
auto-completing an item from the combobox
+ if ([knownFieldNames containsObject:partialString]) {
return YES;
}
NSCharacterSet *invalidSet = [[BDSKTypeManager sharedManager]
invalidFieldNameCharacterSet];
Modified: trunk/bibdesk/BDSKFieldSheetController.h
===================================================================
--- trunk/bibdesk/BDSKFieldSheetController.h 2011-12-06 07:35:09 UTC (rev
18295)
+++ trunk/bibdesk/BDSKFieldSheetController.h 2011-12-06 13:23:25 UTC (rev
18296)
@@ -37,7 +37,6 @@
*/
#import <Cocoa/Cocoa.h>
-#import "BDSKFieldNameFormatter.h"
@interface BDSKFieldSheetController : NSWindowController
{
@@ -62,10 +61,10 @@
@end
-@interface BDSKAddFieldSheetController : BDSKFieldSheetController
<BDSKFieldNameFormatterDelegate>
+@interface BDSKAddFieldSheetController : BDSKFieldSheetController
@end
-@interface BDSKRemoveFieldSheetController : BDSKFieldSheetController
<BDSKFieldNameFormatterDelegate>
+@interface BDSKRemoveFieldSheetController : BDSKFieldSheetController
@end
@interface BDSKChangeFieldSheetController : BDSKRemoveFieldSheetController {
Modified: trunk/bibdesk/BDSKFieldSheetController.m
===================================================================
--- trunk/bibdesk/BDSKFieldSheetController.m 2011-12-06 07:35:09 UTC (rev
18295)
+++ trunk/bibdesk/BDSKFieldSheetController.m 2011-12-06 13:23:25 UTC (rev
18296)
@@ -38,6 +38,7 @@
#import "BDSKFieldSheetController.h"
#import "NSWindowController_BDSKExtensions.h"
+#import "BDSKFieldNameFormatter.h"
@implementation BDSKFieldSheetController
@@ -123,19 +124,17 @@
- (void)awakeFromNib{
BDSKFieldNameFormatter *formatter = [[[BDSKFieldNameFormatter alloc] init]
autorelease];
- [(NSTextField *)fieldsControl setFormatter:formatter];
- [formatter setDelegate:self];
+ [formatter setKnownFieldNames:[self fieldsArray]];
+ [fieldsControl setFormatter:formatter];
}
- (NSString *)windowNibName{
return @"AddFieldSheet";
}
-- (NSArray *)fieldNameFormatterKnownFieldNames:(BDSKFieldNameFormatter
*)formatter {
- if (formatter == [(NSTextField *)fieldsControl formatter])
- return [self fieldsArray];
- else
- return nil;
+- (void)setFieldsArray:(NSArray *)array{
+ [super setFieldsArray:array];
+ [[fieldsControl formatter] setKnownFieldNames:array];
}
@end
@@ -182,8 +181,8 @@
- (void)awakeFromNib{
BDSKFieldNameFormatter *formatter = [[[BDSKFieldNameFormatter alloc] init]
autorelease];
+ [formatter setKnownFieldNames:[self replaceFieldsArray]];
[replaceFieldsComboBox setFormatter:formatter];
- [formatter setDelegate:self];
}
- (NSString *)windowNibName{
@@ -209,6 +208,7 @@
if (replaceFieldsArray != array) {
[replaceFieldsArray release];
replaceFieldsArray = [array retain];
+ [[replaceFieldsComboBox formatter] setKnownFieldNames:array];
}
}
@@ -252,11 +252,4 @@
[replaceFieldsComboBox setFrame:replaceFieldsFrame];
}
-- (NSArray *)fieldNameFormatterKnownFieldNames:(BDSKFieldNameFormatter
*)formatter {
- if (formatter == [(NSTextField *)replaceFieldsComboBox formatter])
- return [self replaceFieldsArray];
- else
- return nil;
-}
-
@end
Modified: trunk/bibdesk/BDSKFindController.h
===================================================================
--- trunk/bibdesk/BDSKFindController.h 2011-12-06 07:35:09 UTC (rev 18295)
+++ trunk/bibdesk/BDSKFindController.h 2011-12-06 13:23:25 UTC (rev 18296)
@@ -39,11 +39,10 @@
#import <Cocoa/Cocoa.h>
#import "BDSKStatusBar.h"
-#import "BDSKFieldNameFormatter.h"
@class BibDocument;
-@interface BDSKFindController : NSWindowController
<BDSKFieldNameFormatterDelegate> {
+@interface BDSKFindController : NSWindowController {
// outlets
IBOutlet NSComboBox *fieldToSearchComboBox;
IBOutlet NSPopUpButton *searchTypePopUpButton;
Modified: trunk/bibdesk/BDSKFindController.m
===================================================================
--- trunk/bibdesk/BDSKFindController.m 2011-12-06 07:35:09 UTC (rev 18295)
+++ trunk/bibdesk/BDSKFindController.m 2011-12-06 13:23:25 UTC (rev 18296)
@@ -50,6 +50,7 @@
#import "BDSKFindFieldEditor.h"
#import "BDSKLinkedFile.h"
#import "NSArray_BDSKExtensions.h"
+#import "BDSKFieldNameFormatter.h"
#define MAX_HISTORY_COUNT 10
@@ -132,13 +133,14 @@
BDSKTypeManager *btm = [BDSKTypeManager sharedManager];
NSMutableArray *extraFields = [NSMutableArray
arrayWithObjects:BDSKCiteKeyString, BDSKPubTypeString, BDSKRemoteURLString,
nil];
[extraFields addObjectsFromArray:[[btm noteFieldsSet] allObjects]];
- [fieldToSearchComboBox removeAllItems];
- [fieldToSearchComboBox addItemsWithObjectValues:[btm
allFieldNamesIncluding:extraFields excluding:nil]];
+ NSArray *fields = [btm allFieldNamesIncluding:extraFields
excluding:nil];
+ [fieldToSearchComboBox removeAllItems];
+ [fieldToSearchComboBox addItemsWithObjectValues:fields];
// make sure we enter valid field names
BDSKFieldNameFormatter *formatter = [[BDSKFieldNameFormatter alloc] init];
+ [formatter setKnownFieldNames:fields];
[fieldToSearchComboBox setFormatter:formatter];
- [formatter setDelegate:self];
[formatter release];
[[self window] setAutorecalculatesContentBorderThickness:NO
forEdge:NSMinYEdge];
@@ -597,13 +599,6 @@
return YES;
}
-- (NSArray *)fieldNameFormatterKnownFieldNames:(BDSKFieldNameFormatter
*)formatter {
- if (formatter == [fieldToSearchComboBox formatter])
- return [fieldToSearchComboBox objectValues] ;
- else
- return nil;
-}
-
#pragma mark Action methods
- (IBAction)openHelp:(id)sender{
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