Revision: 27472
http://sourceforge.net/p/bibdesk/svn/27472
Author: hofman
Date: 2022-05-24 09:19:37 +0000 (Tue, 24 May 2022)
Log Message:
-----------
convenience method to get the represented object for the textfield button
Modified Paths:
--------------
trunk/bibdesk/BDSKEditor.m
Modified: trunk/bibdesk/BDSKEditor.m
===================================================================
--- trunk/bibdesk/BDSKEditor.m 2022-05-24 09:00:33 UTC (rev 27471)
+++ trunk/bibdesk/BDSKEditor.m 2022-05-24 09:19:37 UTC (rev 27472)
@@ -126,6 +126,7 @@
- (void)updateStatusForAutoGenerate:(BDSKAutoGenerateStatus)mask;
- (void)mergeWithPublication:(BibItem *)pub;
- (BDSKEditorTextField *)textFieldAtRow:(NSInteger)row;
+- (id)representedObjectForValue:(NSString *)value forField:(NSString *)field;
@end
@@ -2541,12 +2542,7 @@
NSString *tmpValue = [publication valueOfField:changeKey] ?:
@"";
BDSKEditorTextField *textField = [self textFieldAtRow:row];
[textField setObjectValue:tmpValue];
- id object = nil;
- if ([tmpValue isInherited])
- object = [[[BDSKField alloc] initWithName:changeKey
bibItem:nil] autorelease];
- else if ([changeKey isURLField])
- object = [publication URLForField:changeKey];
- [textField setRepresentedObject:object];
+ [textField setRepresentedObject:[self
representedObjectForValue:tmpValue forField:changeKey]];
if ([textField currentEditor] && [tableCellFormatter
editAsComplexString])
[tableCellFormatter didStartEditor:[textField
currentEditor]];
}
@@ -3215,13 +3211,8 @@
else if ([field isCitationField])
formatter = citationFormatter;
[textField setFormatter:formatter];
- id object = nil;
- if ([value isInherited] || ([field
isEqualToString:BDSKCrossrefString] && [NSString isEmptyString:value] == NO))
- object = [[[BDSKField alloc] initWithName:field bibItem:nil]
autorelease];
- else if ([field isURLField])
- object = [publication URLForField:field];
[(BDSKEditorTextField *)textField
setButtonAction:@selector(tableButtonAction:)];
- [(BDSKEditorTextField *)textField setRepresentedObject:object];
+ [(BDSKEditorTextField *)textField setRepresentedObject:[self
representedObjectForValue:value forField:field]];
[textField setEditable:editorFlags.isEditable];
// this can be reset by the previous call
[textField setSelectable:YES];
@@ -3406,12 +3397,7 @@
[fields enumerateObjectsUsingBlock:^(NSString *field, NSUInteger row, BOOL
*stop){
BDSKEditorTextField *textField = [self textFieldAtRow:row];
NSString *value = [publication valueOfField:field] ?: @"";
- id object = nil;
- if ([value isInherited] || ([field isEqualToString:BDSKCrossrefString]
&& [NSString isEmptyString:value] == NO))
- object = [[[BDSKField alloc] initWithName:field bibItem:nil]
autorelease];
- else if ([field isURLField])
- object = [publication URLForField:field];
- [textField setRepresentedObject:object];
+ [textField setRepresentedObject:[self representedObjectForValue:value
forField:field]];
NSFormatter *formatter = [field isEqualToString:BDSKCrossrefString] ?
crossrefFormatter : [field isCitationField] ? citationFormatter :
tableCellFormatter;
if (formatter != [textField formatter]) {
[textField setFormatter:formatter];
@@ -3671,6 +3657,15 @@
return (BDSKEditorTextField *)[[tableView viewAtColumn:1 row:row
makeIfNecessary:NO] textField];
}
+- (id)representedObjectForValue:(NSString *)value forField:(NSString *)field {
+ if ([value isInherited] || ([field isEqualToString:BDSKCrossrefString] &&
[NSString isEmptyString:value] == NO))
+ return [[[BDSKField alloc] initWithName:field bibItem:nil]
autorelease];
+ else if ([field isURLField])
+ return [publication URLForField:field];
+ else
+ return nil;
+}
+
@end
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