Revision: 27486
http://sourceforge.net/p/bibdesk/svn/27486
Author: hofman
Date: 2022-05-27 14:10:38 +0000 (Fri, 27 May 2022)
Log Message:
-----------
Implement action to download linked URLs froma singular selected local item in
the main window
Modified Paths:
--------------
trunk/bibdesk/BibDocument_Actions.h
trunk/bibdesk/BibDocument_Actions.m
trunk/bibdesk/BibDocument_Menus.m
Modified: trunk/bibdesk/BibDocument_Actions.h
===================================================================
--- trunk/bibdesk/BibDocument_Actions.h 2022-05-27 06:30:12 UTC (rev 27485)
+++ trunk/bibdesk/BibDocument_Actions.h 2022-05-27 14:10:38 UTC (rev 27486)
@@ -150,6 +150,8 @@
- (IBAction)migrateFiles:(id)sender;
+- (IBAction)downloadRemoteURL:(id)sender;
+
#pragma mark View Actions
/*!
Modified: trunk/bibdesk/BibDocument_Actions.m
===================================================================
--- trunk/bibdesk/BibDocument_Actions.m 2022-05-27 06:30:12 UTC (rev 27485)
+++ trunk/bibdesk/BibDocument_Actions.m 2022-05-27 14:10:38 UTC (rev 27486)
@@ -1113,6 +1113,36 @@
[migrationController showWindow:self];
}
+- (IBAction)downloadRemoteURL:(id)sender{
+ BibItem *pub = [self singleSelectedPublication];
+ if (pub == nil) {
+ NSBeep();
+ return;
+ }
+ if ([[NSUserDefaults standardUserDefaults]
boolForKey:BDSKUseLocalUrlAndUrlKey]) {
+ if ([pub canDownloadURLForField:BDSKUrlString]) {
+ if ([NSString isEmptyString:[pub valueOfField:BDSKLocalUrlString
inherit:NO]]) {
+ [pub downloadURLForField:BDSKUrlString];
+ } else {
+ NSAlert *alert = [[[NSAlert alloc] init] autorelease];
+ [alert setMessageText:NSLocalizedString(@"Local-Url is set",
@"Message in alert dialog")];
+ [alert setInformativeText:NSLocalizedString(@"Downloading will
overwrite the current value of the Local-Url field. Do you want to proceed?",
@"Informative text in alert dialog")];
+ [alert addButtonWithTitle:NSLocalizedString(@"Download",
@"Button title")];
+ [alert addButtonWithTitle:NSLocalizedString(@"Cancel",
@"Button title")];
+ [alert beginSheetModalForWindow:[self windowForSheet]
completionHandler:^(NSInteger returnCode){
+ if (returnCode == NSAlertFirstButtonReturn)
+ [pub downloadURLForField:BDSKUrlString];
+ }];
+ }
+ }
+ } else {
+ for (BDSKLinkedFile *file in [pub remoteURLs]) {
+ if ([pub canDownloadLinkedFile:file])
+ [pub downloadLinkedFile:file replace:NO];
+ }
+ }
+}
+
#pragma mark URL actions
- (BOOL)textView:(NSTextView *)aTextView clickedOnLink:(id)aLink
atIndex:(NSUInteger)charIndex
Modified: trunk/bibdesk/BibDocument_Menus.m
===================================================================
--- trunk/bibdesk/BibDocument_Menus.m 2022-05-27 06:30:12 UTC (rev 27485)
+++ trunk/bibdesk/BibDocument_Menus.m 2022-05-27 14:10:38 UTC (rev 27486)
@@ -214,6 +214,21 @@
return ([[self selectedFileURLs] count] > 0 || [[self
selectedRemoteURLs] count] > 0);
}
+- (BOOL) validateDownloadRemoteURLMenuItem:(NSMenuItem*) menuItem {
+ BibItem *pub = [self singleSelectedPublication];
+ if (pub) {
+ if ([[NSUserDefaults standardUserDefaults]
boolForKey:BDSKUseLocalUrlAndUrlKey]) {
+ return [pub canDownloadURLForField:BDSKUrlString];
+ } else {
+ for (BDSKLinkedFile *file in [pub remoteURLs]) {
+ if ([pub canDownloadLinkedFile:file])
+ return YES;
+ }
+ }
+ }
+ return NO;
+}
+
- (BOOL) validateDuplicateTitleToBooktitleMenuItem:(NSMenuItem*) menuItem {
return ([self numberOfSelectedPubs] > 0 && [self displaysFileSearch] !=
NSMixedState && [self hasGroupTypeSelected:BDSKExternalGroupType] == NO);
}
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
_______________________________________________
Bibdesk-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit