Revision: 12281
http://bibdesk.svn.sourceforge.net/bibdesk/?rev=12281&view=rev
Author: hofman
Date: 2008-01-05 10:57:48 -0800 (Sat, 05 Jan 2008)
Log Message:
-----------
Use separate scripting accessor for author and for editor, to avoid accessing
the ivars directly. Add editor element to document.
Modified Paths:
--------------
trunk/bibdesk/BibDocument+Scripting.h
trunk/bibdesk/BibDocument+Scripting.m
trunk/bibdesk/BibItem+Scripting.h
trunk/bibdesk/BibItem+Scripting.m
trunk/bibdesk/Scripting/BibDesk.sdef
Modified: trunk/bibdesk/BibDocument+Scripting.h
===================================================================
--- trunk/bibdesk/BibDocument+Scripting.h 2008-01-05 18:54:31 UTC (rev
12280)
+++ trunk/bibdesk/BibDocument+Scripting.h 2008-01-05 18:57:48 UTC (rev
12281)
@@ -50,9 +50,16 @@
- (BDSKMacro *)valueInMacrosWithName:(NSString *)name;
- (NSArray *)macros;
+- (unsigned int)countOfAuthors;
+- (BibAuthor *)objectInAuthorsAtIndex:(unsigned int)index;
+- (BibAuthor *)valueInAuthorsAtIndex:(unsigned int)index;
- (BibAuthor *)valueInAuthorsWithName:(NSString *)name;
-- (BibAuthor *)valueInAuthorsAtIndex:(unsigned int)index;
+- (unsigned int)countOfEditors;
+- (BibAuthor *)objectInEditorsAtIndex:(unsigned int)index;
+- (BibAuthor *)valueInEditorsAtIndex:(unsigned int)index;
+- (BibAuthor *)valueInEditorsWithName:(NSString *)name;
+
- (NSArray*) selection;
- (void) setSelection: (NSArray*) newSelection;
Modified: trunk/bibdesk/BibDocument+Scripting.m
===================================================================
--- trunk/bibdesk/BibDocument+Scripting.m 2008-01-05 18:54:31 UTC (rev
12280)
+++ trunk/bibdesk/BibDocument+Scripting.m 2008-01-05 18:57:48 UTC (rev
12281)
@@ -190,7 +190,29 @@
return macros;
}
-- (BibAuthor*) valueInAuthorsWithName:(NSString*) name {
+- (unsigned int)countOfAuthors {
+ NSMutableSet *auths = [NSMutableSet set];
+
+ [auths performSelector:@selector(addObjectsFromArray:)
withObjectsByMakingObjectsFromArray:publications
performSelector:@selector(pubAuthors)];
+
+ return [auths count];
+}
+
+- (BibAuthor *)objectInAuthorsAtIndex:(unsigned int)idx {
+ NSMutableSet *auths = [NSMutableSet set];
+
+ [auths performSelector:@selector(addObjectsFromArray:)
withObjectsByMakingObjectsFromArray:publications
performSelector:@selector(pubAuthors)];
+
+ if (idx < [auths count])
+ return [[auths allObjects] objectAtIndex:idx];
+ return nil;
+}
+
+- (BibAuthor *)valueInAuthorsAtIndex:(unsigned int)idx {
+ return [self objectInAuthorsAtIndex:idx];
+}
+
+- (BibAuthor *)valueInAuthorsWithName:(NSString*) name {
// create a new author so we can use BibAuthor's isEqual: method for
comparison
// instead of trying to do string comparisons
BibAuthor *newAuth = [BibAuthor authorWithName:name andPub:nil];
@@ -199,40 +221,77 @@
NSEnumerator *authEnum;
BibItem *pub;
BibAuthor *auth;
+ BibAuthor *author;
+ BibAuthor *editor = nil;
pubEnum = [publications objectEnumerator];
- while (pub = [pubEnum nextObject]) {
+ while (author == nil && (pub = [pubEnum nextObject])) {
authEnum = [[pub pubAuthors] objectEnumerator];
while (auth = [authEnum nextObject]) {
if ([auth isEqual:newAuth]) {
- return auth;
- }
+ author = auth;
+ break;
+ }
}
+ if (editor == nil) {
+ authEnum = [[pub pubEditors] objectEnumerator];
+ while (auth = [authEnum nextObject]) {
+ if ([auth isEqual:newAuth])
+ editor = auth;
+ }
+ }
}
+ return author ? author : editor;
+}
+
+- (unsigned int)countOfEditors {
+ NSMutableSet *auths = [NSMutableSet set];
+
+ [auths performSelector:@selector(addObjectsFromArray:)
withObjectsByMakingObjectsFromArray:publications
performSelector:@selector(pubEditors)];
+
+ return [auths count];
+}
+
+- (BibAuthor *)objectInEditorsAtIndex:(unsigned int)idx {
+ NSMutableSet *auths = [NSMutableSet set];
+
+ [auths performSelector:@selector(addObjectsFromArray:)
withObjectsByMakingObjectsFromArray:publications
performSelector:@selector(pubEditors)];
+
+ if (idx < [auths count])
+ return [[auths allObjects] objectAtIndex:idx];
+ return nil;
+}
+
+- (BibAuthor *)valueInEditorsAtIndex:(unsigned int)idx {
+ return [self objectInEditorsAtIndex:idx];
+}
+
+- (BibAuthor *)valueInEditorsWithName:(NSString*) name {
+ // create a new author so we can use BibAuthor's isEqual: method for
comparison
+ // instead of trying to do string comparisons
+ BibAuthor *newAuth = [BibAuthor authorWithName:name andPub:nil];
+
+ NSEnumerator *pubEnum;
+ NSEnumerator *authEnum;
+ BibItem *pub;
+ BibAuthor *auth;
+ BibAuthor *editor = nil;
+
pubEnum = [publications objectEnumerator];
while (pub = [pubEnum nextObject]) {
authEnum = [[pub pubEditors] objectEnumerator];
while (auth = [authEnum nextObject]) {
if ([auth isEqual:newAuth]) {
- return auth;
- }
+ editor = auth;
+ break;
+ }
}
}
return nil;
}
-- (BibAuthor*) valueInAuthorsAtIndex:(unsigned int)idx {
- NSMutableSet *auths = [NSMutableSet set];
-
- [auths performSelector:@selector(addObjectsFromArray:)
withObjectsByMakingObjectsFromArray:publications
performSelector:@selector(pubAuthors)];
-
- if (idx < [auths count])
- return [[auths allObjects] objectAtIndex:idx];
- return nil;
-}
-
- (NSArray*) selection {
NSMutableArray *selection = [NSMutableArray arrayWithCapacity:[self
numberOfSelectedPubs]];
NSEnumerator *pubE = [[self selectedPublications] objectEnumerator];
Modified: trunk/bibdesk/BibItem+Scripting.h
===================================================================
--- trunk/bibdesk/BibItem+Scripting.h 2008-01-05 18:54:31 UTC (rev 12280)
+++ trunk/bibdesk/BibItem+Scripting.h 2008-01-05 18:57:48 UTC (rev 12281)
@@ -46,8 +46,16 @@
- (BDSKField *)valueInBibFieldsWithName:(NSString *)name;
- (NSArray *)bibFields;
-- (BibAuthor*)valueInAuthorsWithName:(NSString*)name;
+- (unsigned int)countOfAsAuthors;
+- (BibAuthor *)objectInAsAuthorsAtIndex:(unsigned int)idx;
+- (BibAuthor *)valueInAsAuthorsAtIndex:(unsigned int)idx;
+- (BibAuthor*)valueInAsAuthorsWithName:(NSString*)name;
+- (unsigned int)countOfAsEditors;
+- (BibAuthor *)objectInAsEditorsAtIndex:(unsigned int)idx;
+- (BibAuthor *)valueInAsEditorsAtIndex:(unsigned int)idx;
+- (BibAuthor *)valueInAsEditorsWithName:(NSString *)name;
+
- (void)setBibTeXString:(NSString*) btString;
- (NSString *)asCiteKey;
Modified: trunk/bibdesk/BibItem+Scripting.m
===================================================================
--- trunk/bibdesk/BibItem+Scripting.m 2008-01-05 18:54:31 UTC (rev 12280)
+++ trunk/bibdesk/BibItem+Scripting.m 2008-01-05 18:57:48 UTC (rev 12281)
@@ -93,7 +93,19 @@
return bibFields;
}
-- (BibAuthor *)valueInAuthorsWithName:(NSString *)name {
+- (unsigned int)countOfAsAuthors {
+ return [[self pubAuthors] count];
+}
+
+- (BibAuthor *)objectInAsAuthorsAtIndex:(unsigned int)idx {
+ return [[self pubAuthors] objectAtIndex:idx];
+}
+
+- (BibAuthor *)valueInAsAuthorsAtIndex:(unsigned int)idx {
+ return [self objectInAsAuthorsAtIndex:idx];
+}
+
+- (BibAuthor *)valueInAsAuthorsWithName:(NSString *)name {
// create a new author so we can use BibAuthor's isEqual: method for
comparison
// instead of trying to do string comparisons
BibAuthor *newAuth = [BibAuthor authorWithName:name andPub:nil];
@@ -108,6 +120,33 @@
return nil;
}
+- (unsigned int)countOfAsEditors {
+ return [[self pubEditors] count];
+}
+
+- (BibAuthor *)objectInAsEditorsAtIndex:(unsigned int)idx {
+ return [[self pubEditors] objectAtIndex:idx];
+}
+
+- (BibAuthor *)valueInAsEditorsAtIndex:(unsigned int)idx {
+ return [self objectInAsEditorsAtIndex:idx];
+}
+
+- (BibAuthor *)valueInAsEditorsWithName:(NSString *)name {
+ // create a new author so we can use BibAuthor's isEqual: method for
comparison
+ // instead of trying to do string comparisons
+ BibAuthor *newAuth = [BibAuthor authorWithName:name andPub:nil];
+ NSEnumerator *authEnum = [[self pubEditors] objectEnumerator];
+ BibAuthor *auth;
+
+ while (auth = [authEnum nextObject]) {
+ if ([auth isEqual:newAuth]) {
+ return auth;
+ }
+ }
+ return nil;
+}
+
- (NSArray *)linkedFiles {
return [[self localFiles] valueForKey:@"URL"];
}
Modified: trunk/bibdesk/Scripting/BibDesk.sdef
===================================================================
--- trunk/bibdesk/Scripting/BibDesk.sdef 2008-01-05 18:54:31 UTC (rev
12280)
+++ trunk/bibdesk/Scripting/BibDesk.sdef 2008-01-05 18:57:48 UTC (rev
12281)
@@ -552,6 +552,10 @@
description="Authors of publications in the
bibliography">
<cocoa key="authors"/>
</element>
+ <element type="editor" name="editor" access="r"
+ description="Editors of publications in the bibliography.">
+ <cocoa key="editors"/>
+ </element>
<element type="macro" access="r"
description="Macros defined in the
bibliography">
<cocoa key="macros"/>
@@ -628,13 +632,13 @@
<class name="publication" plural="publications" code="bibi"
inherits="item"
description="A publication.">
<cocoa class="BibItem"/>
- <element type="author" name="author"
+ <element type="author" name="author" access="r"
description="Authors of the publication.">
- <cocoa key="pubAuthors"/>
+ <cocoa key="asAuthors"/>
</element>
- <element type="editor" name="editor"
+ <element type="editor" name="editor" access="r"
description="Editors of the publication.">
- <cocoa key="pubEditors"/>
+ <cocoa key="asEditors"/>
</element>
<element type="field"
description="The fields of the publication. These should be
accessed by name.">
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Bibdesk-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit