Revision: 11891
http://bibdesk.svn.sourceforge.net/bibdesk/?rev=11891&view=rev
Author: hofman
Date: 2007-12-12 17:26:19 -0800 (Wed, 12 Dec 2007)
Log Message:
-----------
avoid code duplication for citation field links.
Modified Paths:
--------------
trunk/bibdesk/BDSKEditor.m
Modified: trunk/bibdesk/BDSKEditor.m
===================================================================
--- trunk/bibdesk/BDSKEditor.m 2007-12-12 23:50:24 UTC (rev 11890)
+++ trunk/bibdesk/BDSKEditor.m 2007-12-13 01:26:19 UTC (rev 11891)
@@ -2199,14 +2199,23 @@
return [NSString stringWithFormat:@"(net_sourceforge_bibdesk_citekey =
'%@'cd) && ((kMDItemContentType != *) || (kMDItemContentType !=
com.apple.mail.emlx))", citekey];
}
+- (BOOL)citationFormatter:(BDSKCitationFormatter *)formatter
isValidKey:(NSString *)key {
+ BOOL isValid;
+ if ([[[publication owner] publications] itemForCiteKey:key] == nil) {
+ NSString *queryString = queryStringWithCiteKey(key);
+ if ([[BDSKPersistentSearch sharedSearch] hasQuery:queryString] == NO) {
+ [[BDSKPersistentSearch sharedSearch] addQuery:queryString
scopes:[NSArray arrayWithObject:[[NSFileManager defaultManager]
spotlightCacheFolderPathByCreating:NULL]]];
+ }
+ isValid = ([[[BDSKPersistentSearch sharedSearch]
resultsForQuery:queryString attribute:(id)kMDItemPath] count] > 0);
+ } else {
+ isValid = YES;
+ }
+ return isValid;
+}
+
- (BOOL)control:(NSControl *)control textView:(NSTextView *)textView
isValidKey:(NSString *)key {
if ([control isEqual:tableView]) {
- if ([[[publication owner] publications] itemForCiteKey:key] == nil) {
- // don't add a search with the query here, since it gets called on
every keystroke; the formatter method gets called at the end, or when scrolling
- NSString *queryString = queryStringWithCiteKey(key);
- return [[[BDSKPersistentSearch sharedSearch]
resultsForQuery:queryString attribute:(id)kMDItemPath] count] > 0;
- }
- return YES;
+ return [self citationFormatter:citationFormatter isValidKey:key];
}
return NO;
}
@@ -2229,20 +2238,6 @@
return NO;
}
-- (BOOL)citationFormatter:(BDSKCitationFormatter *)formatter
isValidKey:(NSString *)key {
- BOOL isValid;
- if ([[[publication owner] publications] itemForCiteKey:key] == nil) {
- NSString *queryString = queryStringWithCiteKey(key);
- if ([[BDSKPersistentSearch sharedSearch] hasQuery:queryString] == NO) {
- [[BDSKPersistentSearch sharedSearch] addQuery:queryString
scopes:[NSArray arrayWithObject:[[NSFileManager defaultManager]
spotlightCacheFolderPathByCreating:NULL]]];
- }
- isValid = ([[[BDSKPersistentSearch sharedSearch]
resultsForQuery:queryString attribute:(id)kMDItemPath] count] > 0);
- } else {
- isValid = YES;
- }
- return isValid;
-}
-
#pragma mark dragging destination delegate methods
- (NSDragOperation)dragWindow:(BDSKDragWindow *)window canReceiveDrag:(id
<NSDraggingInfo>)sender{
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
-------------------------------------------------------------------------
SF.Net email is sponsored by:
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services
for just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Bibdesk-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit