Revision: 12198 http://bibdesk.svn.sourceforge.net/bibdesk/?rev=12198&view=rev Author: amaxwell Date: 2008-01-02 11:09:32 -0800 (Wed, 02 Jan 2008)
Log Message: ----------- Add a flag to display the automatic migration alert after the window loads, so it can be a sheet, and the migration controller is guaranteed to be the front window. Modified Paths: -------------- trunk/bibdesk/BibDocument.h trunk/bibdesk/BibDocument.m Modified: trunk/bibdesk/BibDocument.h =================================================================== --- trunk/bibdesk/BibDocument.h 2008-01-02 18:29:14 UTC (rev 12197) +++ trunk/bibdesk/BibDocument.h 2008-01-02 19:09:32 UTC (rev 12198) @@ -224,6 +224,7 @@ BOOL isDocumentClosed; BOOL didImport; int itemChangeMask; + BOOL displayMigrationAlert; } docState; NSURL *saveTargetURL; Modified: trunk/bibdesk/BibDocument.m =================================================================== --- trunk/bibdesk/BibDocument.m 2008-01-02 18:29:14 UTC (rev 12197) +++ trunk/bibdesk/BibDocument.m 2008-01-02 19:09:32 UTC (rev 12198) @@ -258,6 +258,7 @@ docState.sortGroupsDescending = NO; docState.didImport = NO; docState.itemChangeMask = 0; + docState.displayMigrationAlert = NO; // these are created lazily when needed fileSearchController = nil; @@ -336,6 +337,15 @@ return @"BibDocument"; } +- (void)migrationAlertDidEnd:(BDSKAlert *)alert returnCode:(int)returnCode contextInfo:(void *)unused { + + if ([alert checkValue] == YES) + [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"BDSKDisableMigrationWarning"]; + + if (NSAlertDefaultReturn == returnCode) + [self migrateFiles:self]; +} + - (void)showWindows{ [super showWindows]; @@ -368,6 +378,23 @@ [self setSearchString:searchString]; } } + + + if (docState.displayMigrationAlert) { + + docState.displayMigrationAlert = NO; + // If a single file was migrated, this alert will be shown even if all other BibItems already use BDSKLinkedFile. However, I think that's an edge case, since the user had to manually add that pub in a text editor or by setting the local-url field. Items imported or added in BD will already use BDSKLinkedFile, so this notification won't be posted. + BDSKAlert *alert = [BDSKAlert alertWithMessageText:NSLocalizedString(@"Automatically migrated files", @"warning in document") + defaultButton:NSLocalizedString(@"Migrate", @"") + alternateButton:NSLocalizedString(@"Later", @"") + otherButton:nil + informativeTextWithFormat:NSLocalizedString(@"Local File and URL fields have been converted to use a more flexible storage format. Choose \"Migrate\" to display the migration interface, which can show problems and convert permanently to the new format.", @"")]; + + // @@ Should we show a check button? If the user saves the doc as-is, it'll have local-url and bdsk-file fields in it, and there will be no warning the next time it's opened. Someone who uses a script hook to convert bdsk-file back to local-url won't want to see it, though. + [alert setHasCheckButton:YES]; + [alert setCheckValue:NO]; + [alert beginSheetModalForWindow:[self windowForSheet] modalDelegate:self didEndSelector:@selector(migrationAlertDidEnd:returnCode:contextInfo:) contextInfo:NULL]; + } } - (void)windowControllerDidLoadNib:(NSWindowController *) aController @@ -528,6 +555,7 @@ [self updateCategoryGroupsPreservingSelection:NO]; [saveTextEncodingPopupButton setEncoding:0]; + } - (BOOL)undoManagerShouldUndoChange:(id)sender{ @@ -2759,28 +2787,9 @@ } - (void)handleTemporaryFileMigrationNotification:(NSNotification *)notification{ - if ([[NSUserDefaults standardUserDefaults] boolForKey:@"BDSKDisableMigrationWarning"] == NO) { - - // If a single file was migrated, this alert will be shown even if all other BibItems already use BDSKLinkedFile. However, I think that's an edge case, since the user had to manually add that pub in a text editor or by setting the local-url field. Items imported or added in BD will already use BDSKLinkedFile, so this notification won't be posted. - BDSKAlert *alert = [BDSKAlert alertWithMessageText:NSLocalizedString(@"Automatically migrated files", @"warning in document") - defaultButton:NSLocalizedString(@"Migrate", @"") - alternateButton:NSLocalizedString(@"Later", @"") - otherButton:nil - informativeTextWithFormat:NSLocalizedString(@"Local File and URL fields have been converted to use a more flexible storage format. Choose \"Migrate\" to display the migration interface, which can show problems and convert permanently to the new format.", @"")]; - - // @@ Should we show a check button? If the user saves the doc as-is, it'll have local-url and bdsk-file fields in it, and there will be no warning the next time it's opened. Someone who uses a script hook to convert bdsk-file back to local-url won't want to see it, though. - [alert setHasCheckButton:YES]; - [alert setCheckValue:NO]; - - // tried running as a sheet, but the document window may not be on screen yet - int rv = [alert runModal]; - - if ([alert checkValue] == YES) - [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"BDSKDisableMigrationWarning"]; - - if (NSAlertDefaultReturn == rv) - [self migrateFiles:self]; - } + // display after the window loads so we can use a sheet, and the migration controller window is in front + if ([[NSUserDefaults standardUserDefaults] boolForKey:@"BDSKDisableMigrationWarning"] == NO) + docState.displayMigrationAlert = YES; } - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { 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 Bibdesk-commit@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/bibdesk-commit