Revision: 11888
http://bibdesk.svn.sourceforge.net/bibdesk/?rev=11888&view=rev
Author: hofman
Date: 2007-12-12 14:11:21 -0800 (Wed, 12 Dec 2007)
Log Message:
-----------
Reorganize bibitem change notification handler.
Modified Paths:
--------------
trunk/bibdesk/BDSKEditor.m
Modified: trunk/bibdesk/BDSKEditor.m
===================================================================
--- trunk/bibdesk/BDSKEditor.m 2007-12-12 21:46:21 UTC (rev 11887)
+++ trunk/bibdesk/BDSKEditor.m 2007-12-12 22:11:21 UTC (rev 11888)
@@ -1874,7 +1874,6 @@
NSString *changeType = [userInfo objectForKey:@"type"];
NSString *changeKey = [userInfo objectForKey:@"key"];
NSString *newValue = [userInfo objectForKey:@"value"];
- NSString *oldValue = [userInfo objectForKey:@"oldValue"];
BibItem *sender = (BibItem *)[notification object];
NSString *crossref = [publication valueOfField:BDSKCrossrefString
inherit:NO];
OFPreferenceWrapper *pw = [OFPreferenceWrapper sharedPreferenceWrapper];
@@ -1883,41 +1882,23 @@
[crossref
caseInsensitiveCompare:[userInfo objectForKey:@"oldCiteKey"]] ==
NSOrderedSame));
// If it is not our item or his crossref parent, we don't care, but our
parent may have changed his cite key
- if (sender != publication && !parentDidChange)
+ if (sender != publication && NO == parentDidChange)
return;
- // these should always be updated
- if([changeKey isEqualToString:BDSKTitleString] || [changeKey
isEqualToString:BDSKChapterString] || [changeKey
isEqualToString:BDSKPagesString]){
- [[self window] setTitle:[publication displayTitle]];
- }
- else if([changeKey isPersonField]){
- [authorTableView reloadData];
- }
-
- if ([changeType isEqualToString:@"Change Field"]) {
- if ((([NSString isEmptyAsComplexString:newValue] && [fields
containsObject:changeKey]) ||
- ([NSString isEmptyAsComplexString:oldValue] && [fields
containsObject:changeKey] == NO)) &&
- [changeKey isRatingField] == NO && [changeKey isBooleanField] ==
NO && [changeKey isTriStateField] == NO && [changeKey isNoteField] == NO) {
- [self setupFields];
- return;
- }
- }
- else if([changeType isEqualToString:@"Add/Del File"]){
+ if([changeType isEqualToString:@"Add/Del File"]){
[fileView reloadIcons];
- return;
}
-
- // Rebuild the form if the crossref changed, or our parent's cite key
changed.
- if([changeKey isEqualToString:BDSKCrossrefString] ||
+ else if([changeKey isEqualToString:BDSKCrossrefString] ||
(parentDidChange && [changeKey isEqualToString:BDSKCiteKeyString])){
- // if we are editing a crossref field, we should first set the new
value, because setupFields will set the edited value. This happens when it is
set through drag/drop
- // @@ fixme: is this correct, i.e. what happens with complex or
inherited strings?
+ // Reset if the crossref changed, or our parent's cite key changed.
+ // If we are editing a crossref field, we should first set the new
value, because setupFields will set the edited value. This happens when it is
set through drag/drop
int editedRow = [tableView editedRow];
if (editedRow != -1 && [[fields objectAtIndex:editedRow]
isEqualToString:changeKey])
[[tableView currentEditor] setString:[publication
valueOfField:changeKey]];
- [self setupFields];
- [[self window] setTitle:[publication displayTitle]];
+ // every field value could change, but not the displayed field names
+ [tableView reloadData];
[authorTableView reloadData];
+ [[self window] setTitle:[publication displayTitle]];
}
else if([changeKey isEqualToString:BDSKPubTypeString]){
[self setupFields];
@@ -1928,34 +1909,33 @@
[self updateCiteKeyAutoGenerateStatus];
[self updateCiteKeyDuplicateWarning];
}
- else if([changeKey isEqualToString:BDSKAnnoteString]){
- if(ignoreFieldChange) return;
- // make a copy of the current value, so we don't overwrite it when we
set the field value to the text storage
- NSString *tmpValue = [[publication valueOfField:BDSKAnnoteString
inherit:NO] copy];
- [notesView setString:(tmpValue == nil ? @"" : tmpValue)];
- [tmpValue release];
- if(currentEditedView == notesView)
- [[self window] makeFirstResponder:[self window]];
- [notesViewUndoManager removeAllActions];
+ else if([changeKey isNoteField]){
+ if(ignoreFieldChange == NO) {
+ if([changeKey isEqualToString:BDSKAnnoteString]){
+ // make a copy of the current value, so we don't overwrite it
when we set the field value to the text storage
+ NSString *tmpValue = [[publication
valueOfField:BDSKAnnoteString inherit:NO] copy];
+ [notesView setString:(tmpValue == nil ? @"" : tmpValue)];
+ [tmpValue release];
+ if(currentEditedView == notesView)
+ [[self window] makeFirstResponder:[self window]];
+ [notesViewUndoManager removeAllActions];
+ } else if([changeKey isEqualToString:BDSKAbstractString]){
+ NSString *tmpValue = [[publication
valueOfField:BDSKAbstractString inherit:NO] copy];
+ [abstractView setString:(tmpValue == nil ? @"" : tmpValue)];
+ [tmpValue release];
+ if(currentEditedView == abstractView)
+ [[self window] makeFirstResponder:[self window]];
+ [abstractViewUndoManager removeAllActions];
+ } else if([changeKey isEqualToString:BDSKRssDescriptionString]){
+ NSString *tmpValue = [[publication
valueOfField:BDSKRssDescriptionString inherit:NO] copy];
+ [rssDescriptionView setString:(tmpValue == nil ? @"" :
tmpValue)];
+ [tmpValue release];
+ if(currentEditedView == rssDescriptionView)
+ [[self window] makeFirstResponder:[self window]];
+ [rssDescriptionViewUndoManager removeAllActions];
+ }
+ }
}
- else if([changeKey isEqualToString:BDSKAbstractString]){
- if(ignoreFieldChange) return;
- NSString *tmpValue = [[publication valueOfField:BDSKAbstractString
inherit:NO] copy];
- [abstractView setString:(tmpValue == nil ? @"" : tmpValue)];
- [tmpValue release];
- if(currentEditedView == abstractView)
- [[self window] makeFirstResponder:[self window]];
- [abstractViewUndoManager removeAllActions];
- }
- else if([changeKey isEqualToString:BDSKRssDescriptionString]){
- if(ignoreFieldChange) return;
- NSString *tmpValue = [[publication
valueOfField:BDSKRssDescriptionString inherit:NO] copy];
- [rssDescriptionView setString:(tmpValue == nil ? @"" : tmpValue)];
- [tmpValue release];
- if(currentEditedView == rssDescriptionView)
- [[self window] makeFirstResponder:[self window]];
- [rssDescriptionViewUndoManager removeAllActions];
- }
else if([changeKey isRatingField] || [changeKey isBooleanField] ||
[changeKey isTriStateField]){
NSEnumerator *cellE = [[extraBibFields cells] objectEnumerator];
@@ -1969,7 +1949,21 @@
}
}
else{
- [tableView reloadData];
+ // this is a normal field displayed in the tableView
+
+ if([changeKey isEqualToString:BDSKTitleString] || [changeKey
isEqualToString:BDSKChapterString] || [changeKey
isEqualToString:BDSKPagesString])
+ [[self window] setTitle:[publication displayTitle]];
+ else if([changeKey isPersonField])
+ [authorTableView reloadData];
+
+ if (([NSString isEmptyAsComplexString:newValue] && [fields
containsObject:changeKey]) ||
+ ([NSString isEmptyAsComplexString:newValue] == NO && [fields
containsObject:changeKey] == NO)) {
+ // a field was added or removed
+ [self setupFields];
+ } else {
+ // a field value changed
+ [tableView reloadData];
+ }
}
}
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