Revision: 24769 http://sourceforge.net/p/bibdesk/svn/24769 Author: hofman Date: 2020-05-12 15:42:59 +0000 (Tue, 12 May 2020) Log Message: ----------- add an option to import script command to merge with or withour overwriting without showing the merge sheet
Modified Paths: -------------- trunk/bibdesk/BDSKMergeController.h trunk/bibdesk/BDSKMergeController.m trunk/bibdesk/BibDocument+Scripting.m trunk/bibdesk/Scripting/BibDesk.sdef Modified: trunk/bibdesk/BDSKMergeController.h =================================================================== --- trunk/bibdesk/BDSKMergeController.h 2020-05-12 14:39:15 UTC (rev 24768) +++ trunk/bibdesk/BDSKMergeController.h 2020-05-12 15:42:59 UTC (rev 24769) @@ -70,5 +70,6 @@ @property (nonatomic, readonly) BOOL mayOverwrite; - (void)merge; +- (void)mergeOverwriting; @end Modified: trunk/bibdesk/BDSKMergeController.m =================================================================== --- trunk/bibdesk/BDSKMergeController.m 2020-05-12 14:39:15 UTC (rev 24768) +++ trunk/bibdesk/BDSKMergeController.m 2020-05-12 15:42:59 UTC (rev 24769) @@ -376,6 +376,11 @@ } } +- (void)mergeOverwriting { + [overwriteFields setValue:[NSNumber numberWithBool:YES] forKey:SELECTED_COLUMNID]; + [self merge]; +} + #pragma mark NSTableView datasource - (NSInteger)numberOfRowsInTableView:(NSTableView *)tv { Modified: trunk/bibdesk/BibDocument+Scripting.m =================================================================== --- trunk/bibdesk/BibDocument+Scripting.m 2020-05-12 14:39:15 UTC (rev 24768) +++ trunk/bibdesk/BibDocument+Scripting.m 2020-05-12 15:42:59 UTC (rev 24769) @@ -1076,6 +1076,7 @@ id url = [params objectForKey:@"with"]; id wait = [params objectForKey:@"wait"]; id mergePub = [params objectForKey:@"merge"]; + id overwrite = [params objectForKey:@"overwrite"]; BOOL synchronous = [wait respondsToSelector:@selector(boolValue)] ? [wait boolValue] : (mergePub == nil); NSArray *pubs = nil; @@ -1115,7 +1116,13 @@ } } } - [BDSKMergeController mergePublication:pub withPublication:mergePub fromDocument:self window:documentWindow completionHandler:NULL]; + BDSKMergeController *mergeController = [[[BDSKMergeController alloc] initWithPublication:pub mergedPublication:mergePub fromDocument:self completionHandler:NULL] autorelease]; + if ([overwrite unsignedIntValue] == 'no ' || [mergeController mayOverwrite] == NO) + [mergeController merge]; + else if ([overwrite unsignedIntValue] == 'yes ') + [mergeController mergeOverwriting]; + else + [mergeController beginSheetModalForWindow:documentWindow completionHandler:NULL]; }; } else { handler = ^(NSArray *result){ Modified: trunk/bibdesk/Scripting/BibDesk.sdef =================================================================== --- trunk/bibdesk/Scripting/BibDesk.sdef 2020-05-12 14:39:15 UTC (rev 24768) +++ trunk/bibdesk/Scripting/BibDesk.sdef 2020-05-12 15:42:59 UTC (rev 24769) @@ -670,6 +670,11 @@ <type type="publication"/> <cocoa key="merge"/> </parameter> + <parameter name="overwriting" code="OWrt" optional="yes" + description="Whether to overwrite existing fields when merging. Default is to ask."> + <type type="save options"/> + <cocoa key="overwrite"/> + </parameter> <parameter name="waiting" code="Wait" optional="yes" description="Whether to wait for the import to finish. Default is true when not merging. Does not return a value when false."> <type type="boolean"/> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. _______________________________________________ Bibdesk-commit mailing list Bibdesk-commit@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/bibdesk-commit