From: <ho...@us...> - 2007-08-23 19:38:51
|
Revision: 10975 http://bibdesk.svn.sourceforge.net/bibdesk/?rev=10975&view=rev Author: hofman Date: 2007-08-23 12:38:51 -0700 (Thu, 23 Aug 2007) Log Message: ----------- Merge in items when creating a field group with external items. Delay editing new group from selection, because the groups table may get updated at the end of the event loop, which may otherwise end the edit immediately. Modified Paths: -------------- trunk/bibdesk/BibDocument_Groups.m Modified: trunk/bibdesk/BibDocument_Groups.m =================================================================== --- trunk/bibdesk/BibDocument_Groups.m 2007-08-23 19:04:59 UTC (rev 10974) +++ trunk/bibdesk/BibDocument_Groups.m 2007-08-23 19:38:51 UTC (rev 10975) @@ -1173,6 +1173,19 @@ } } +- (void)editGroupWithoutWarning:(BDSKGroup *)group { + unsigned i = [groups indexOfObject:group]; + OBASSERT(i != NSNotFound); + + if(i != NSNotFound){ + [groupTableView selectRowIndexes:[NSIndexSet indexSetWithIndex:i] byExtendingSelection:NO]; + [groupTableView scrollRowToVisible:i]; + + // don't show the warning sheet, since presumably the user wants to change the group name + [groupTableView editColumn:0 row:i withEvent:nil select:YES]; + } +} + - (IBAction)editNewStaticGroupWithSelection:(id)sender{ NSArray *names = [[groups staticGroups] valueForKeyPath:@"@distinctUnionOfObjects.name"]; NSArray *pubs = [self selectedPublications]; @@ -1193,16 +1206,7 @@ [groups addStaticGroup:group]; [groupTableView deselectAll:nil]; - i = [[groups staticGroups] indexOfObject:group]; - OBASSERT(i != NSNotFound); - - if(i != NSNotFound){ - i += [groups rangeOfStaticGroups].location; - [groupTableView selectRowIndexes:[NSIndexSet indexSetWithIndex:i] byExtendingSelection:NO]; - [groupTableView scrollRowToVisible:i]; - - [groupTableView editColumn:0 row:i withEvent:nil select:YES]; - } + [self performSelector:@selector(editGroupWithoutWarning:) withObject:group afterDelay:0.0]; } - (IBAction)editNewCategoryGroupWithSelection:(id)sender{ @@ -1210,31 +1214,30 @@ NSBeep(); return; } - NSArray *names = [[groups categoryGroups] valueForKeyPath:@"@distinctUnionOfObjects.name"]; + + BOOL isAuthor = [currentGroupField isPersonField]; + NSArray *names = [[groups categoryGroups] valueForKeyPath:isAuthor ? @"@distinctUnionOfObjects.name.lastName" : @"@distinctUnionOfObjects.name"]; NSArray *pubs = [self selectedPublications]; NSString *baseName = NSLocalizedString(@"Untitled", @""); - NSString *name = baseName; + id name = baseName; BDSKCategoryGroup *group; unsigned int i = 1; while ([names containsObject:name]) name = [NSString stringWithFormat:@"%@%d", baseName, i++]; + if (isAuthor) + name = [BibAuthor authorWithName:name andPub:nil]; group = [[[BDSKCategoryGroup alloc] initWithName:name key:currentGroupField count:[pubs count]] autorelease]; + // first merge in shared groups + if ([self hasExternalGroupsSelected]) + pubs = [self mergeInPublications:pubs]; + [self addPublications:pubs toGroup:group]; [groupTableView deselectAll:nil]; + [self updateCategoryGroupsPreservingSelection:NO]; - i = [[groups categoryGroups] indexOfObject:group]; - OBASSERT(i != NSNotFound); - - if(i != NSNotFound){ - i += [groups rangeOfCategoryGroups].location; - [groupTableView selectRowIndexes:[NSIndexSet indexSetWithIndex:i] byExtendingSelection:NO]; - [groupTableView scrollRowToVisible:i]; - - // don't show the warning sheet, since presumably the user wants to change the group name - [groupTableView editColumn:0 row:i withEvent:nil select:YES]; - } + [self performSelector:@selector(editGroupWithoutWarning:) withObject:group afterDelay:0.0]; } - (IBAction)mergeInExternalGroup:(id)sender{ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |