Revision: 11627
          http://bibdesk.svn.sourceforge.net/bibdesk/?rev=11627&view=rev
Author:   hofman
Date:     2007-11-17 10:40:44 -0800 (Sat, 17 Nov 2007)

Log Message:
-----------
Implement linked file and URL actions and re-add main menu items. They can work 
either for a single URL passed as the representedObject, or all local files or 
remote URLs relevant to the context. Add skim notes menu items to document 
fileview context menu.

Modified Paths:
--------------
    branches/TRY_ARM_FILE_INTERFACE/bibdesk/BibDocument.m
    branches/TRY_ARM_FILE_INTERFACE/bibdesk/BibDocument_Actions.h
    branches/TRY_ARM_FILE_INTERFACE/bibdesk/BibDocument_Actions.m
    branches/TRY_ARM_FILE_INTERFACE/bibdesk/BibDocument_DataSource.m
    branches/TRY_ARM_FILE_INTERFACE/bibdesk/BibEditor.h
    branches/TRY_ARM_FILE_INTERFACE/bibdesk/BibEditor.m
    branches/TRY_ARM_FILE_INTERFACE/bibdesk/BibItem.m
    
branches/TRY_ARM_FILE_INTERFACE/bibdesk/English.lproj/BibDocument.nib/classes.nib
    
branches/TRY_ARM_FILE_INTERFACE/bibdesk/English.lproj/BibDocument.nib/keyedobjects.nib
    
branches/TRY_ARM_FILE_INTERFACE/bibdesk/English.lproj/BibEditor.nib/classes.nib
    branches/TRY_ARM_FILE_INTERFACE/bibdesk/English.lproj/BibEditor.nib/info.nib
    
branches/TRY_ARM_FILE_INTERFACE/bibdesk/English.lproj/BibEditor.nib/keyedobjects.nib
    
branches/TRY_ARM_FILE_INTERFACE/bibdesk/English.lproj/MainMenu.nib/classes.nib
    branches/TRY_ARM_FILE_INTERFACE/bibdesk/English.lproj/MainMenu.nib/info.nib
    
branches/TRY_ARM_FILE_INTERFACE/bibdesk/English.lproj/MainMenu.nib/keyedobjects.nib
    
branches/TRY_ARM_FILE_INTERFACE/bibdesk/French.lproj/MainMenu.nib/classes.nib
    branches/TRY_ARM_FILE_INTERFACE/bibdesk/French.lproj/MainMenu.nib/info.nib
    
branches/TRY_ARM_FILE_INTERFACE/bibdesk/French.lproj/MainMenu.nib/keyedobjects.nib

Modified: branches/TRY_ARM_FILE_INTERFACE/bibdesk/BibDocument.m
===================================================================
--- branches/TRY_ARM_FILE_INTERFACE/bibdesk/BibDocument.m       2007-11-17 
16:04:20 UTC (rev 11626)
+++ branches/TRY_ARM_FILE_INTERFACE/bibdesk/BibDocument.m       2007-11-17 
18:40:44 UTC (rev 11627)
@@ -2848,12 +2848,27 @@
 
 - (void)fileView:(FileView *)aFileView willPopUpMenu:(NSMenu *)menu 
onIconAtIndex:(NSUInteger)anIndex {
     NSURL *theURL = anIndex == NSNotFound ? nil : [self 
objectInFileViewURLsAtIndex:anIndex];
-    int i = [menu indexOfItemWithTag:FVOpenMenuItemTag];
+    int i;
     
     if (theURL && i != -1) {
+        i = [menu indexOfItemWithTag:FVOpenMenuItemTag];
         [menu insertItemWithTitle:[NSLocalizedString(@"Open With", @"Menu item 
title") stringByAppendingEllipsis]
                 andSubmenuOfApplicationsForURL:theURL atIndex:++i];
     }
+    if ([theURL isFileURL]) {
+        i = [menu indexOfItemWithTag:FVRevealMenuItemTag];
+        item = [menu insertItemWithTitle:[NSLocalizedString(@"Skim 
Notes",@"Menu item title: Skim Note...") stringByAppendingEllipsis]
+                                  action:@selector(showNotesForLinkedFile:)
+                           keyEquivalent:@""
+                                 atIndex:++i];
+        [item setRepresentedObject:theURL];
+        
+        item = [menu insertItemWithTitle:[NSLocalizedString(@"Copy Skim 
Notes",@"Menu item title: Copy Skim Notes...") stringByAppendingEllipsis]
+                                  action:@selector(copyNotesForLinkedFile:)
+                           keyEquivalent:@""
+                                 atIndex:++i];
+        [item setRepresentedObject:theURL];
+    }
 }
 
 - (void)displayLocalURLInPreviewPane{

Modified: branches/TRY_ARM_FILE_INTERFACE/bibdesk/BibDocument_Actions.h
===================================================================
--- branches/TRY_ARM_FILE_INTERFACE/bibdesk/BibDocument_Actions.h       
2007-11-17 16:04:20 UTC (rev 11626)
+++ branches/TRY_ARM_FILE_INTERFACE/bibdesk/BibDocument_Actions.h       
2007-11-17 18:40:44 UTC (rev 11627)
@@ -151,27 +151,29 @@
 - (IBAction)sendToLyX:(id)sender;
 - (IBAction)postItemToWeblog:(id)sender;
 
-#pragma mark | URL actions
+#pragma mark URL actions
 
+#pragma mark | URL Field actions
+
 /*!
-    @method openLinkedFile:
+    @method openLocalURL:
     @abstract Opens the linked file of the selected publication with the 
default application
     @discussion - 
     @param sender The sender. Not used.
 */
-- (IBAction)openLinkedFile:(id)sender;
+- (IBAction)openLocalURL:(id)sender;
 
-- (void)openLinkedFileForField:(NSString *)field;
+- (void)openLocalURLForField:(NSString *)field;
 
 /*!
-    @method revealLinkedFile:
+    @method revealLocalURL:
     @abstract Reveals the linked file of the selected publication in the Finder
     @discussion 
     @param sender The sender. Not used.
 */
-- (IBAction)revealLinkedFile:(id)sender;
+- (IBAction)revealLocalURL:(id)sender;
 
-- (void)revealLinkedFileForField:(NSString *)field;
+- (void)revealLocalURLForField:(NSString *)field;
 
 /*!
     @method openRemoteURL:
@@ -184,19 +186,31 @@
 - (void)openRemoteURLForField:(NSString *)field;
 
 /*!
-    @method showNotesForLinkedFile:
+    @method showNotesForLocalURL:
     @abstract Shows Skim notes of the selected publication in separate windows
     @discussion - 
     @param sender The sender. Not used.
 */
+- (IBAction)showNotesForLocalURL:(id)sender;
+
+- (void)showNotesForLocalURLForField:(NSString *)field;
+
+- (IBAction)copyNotesForLocalURL:(id)sender;
+
+- (void)copyNotesForLocalURLForField:(NSString *)field;
+
+#pragma mark | Linked File and URL actions
+
+- (IBAction)openLinkedFile:(id)sender;
+
+- (IBAction)revealLinkedFile:(id)sender;
+
+- (IBAction)openLinkedURL:(id)sender;
+
 - (IBAction)showNotesForLinkedFile:(id)sender;
 
-- (void)showNotesForLinkedFileForField:(NSString *)field;
-
 - (IBAction)copyNotesForLinkedFile:(id)sender;
 
-- (void)copyNotesForLinkedFileForField:(NSString *)field;
-
 #pragma mark View Actions
 
 /*!

Modified: branches/TRY_ARM_FILE_INTERFACE/bibdesk/BibDocument_Actions.m
===================================================================
--- branches/TRY_ARM_FILE_INTERFACE/bibdesk/BibDocument_Actions.m       
2007-11-17 16:04:20 UTC (rev 11626)
+++ branches/TRY_ARM_FILE_INTERFACE/bibdesk/BibDocument_Actions.m       
2007-11-17 18:40:44 UTC (rev 11627)
@@ -410,7 +410,7 @@
     NSString *colID = column != -1 ? [[[tableView tableColumns] 
objectAtIndex:column] identifier] : nil;
     
     if([colID isLocalFileField])
-               [self openLinkedFileForField:colID];
+               [self openLocalURLForField:colID];
     else if([colID isRemoteURLField])
                [self openRemoteURLForField:colID];
     else
@@ -549,15 +549,8 @@
 #endif
 }
 
-#pragma mark | URL actions
+#pragma mark URL actions
 
-- (IBAction)openLinkedFile:(id)sender{
-       NSString *field = [sender representedObject];
-    if (field == nil)
-               field = BDSKLocalUrlString;
-    [self openLinkedFileForField:field];
-}
-
 - (BOOL)textView:(NSTextView *)aTextView clickedOnLink:(id)aLink 
atIndex:(unsigned)charIndex
 {
     if ([aLink respondsToSelector:@selector(isFileURL)] && [aLink isFileURL]) {
@@ -576,7 +569,16 @@
     return NO;
 }
 
-- (void)openLinkedFileAlertDidEnd:(NSAlert *)alert returnCode:(int)returnCode 
contextInfo:(void *)contextInfo {
+#pragma mark | URL Field actions
+
+- (IBAction)openLocalURL:(id)sender{
+       NSString *field = [sender representedObject];
+    if (field == nil)
+               field = BDSKLocalUrlString;
+    [self openLocalURLForField:field];
+}
+
+- (void)openLocalURLAlertDidEnd:(NSAlert *)alert returnCode:(int)returnCode 
contextInfo:(void *)contextInfo {
     NSString *field = (NSString *)contextInfo;
     if (returnCode == NSAlertAlternateReturn) {
         NSEnumerator *e = [[self selectedPublications] objectEnumerator];
@@ -600,7 +602,7 @@
     [field release];
 }
 
-- (void)openLinkedFileForField:(NSString *)field{
+- (void)openLocalURLForField:(NSString *)field{
        int n = [self numberOfSelectedPubs];
     
     if (n > 6) {
@@ -612,21 +614,21 @@
                              informativeTextWithFormat:[NSString 
stringWithFormat:NSLocalizedString(@"BibDesk is about to open %i linked files. 
Do you want to proceed?" , @"Informative text in alert dialog"), n]];
         [alert beginSheetModalForWindow:documentWindow
                           modalDelegate:self
-                         
didEndSelector:@selector(openLinkedFileAlertDidEnd:returnCode:contextInfo:) 
+                         
didEndSelector:@selector(openLocalURLAlertDidEnd:returnCode:contextInfo:) 
                             contextInfo:[field retain]];
        } else {
-        [self openLinkedFileAlertDidEnd:nil returnCode:NSAlertAlternateReturn 
contextInfo:[field retain]];
+        [self openLocalURLAlertDidEnd:nil returnCode:NSAlertAlternateReturn 
contextInfo:[field retain]];
     }
 }
 
-- (IBAction)revealLinkedFile:(id)sender{
+- (IBAction)revealLocalURL:(id)sender{
        NSString *field = [sender representedObject];
     if (field == nil)
                field = BDSKLocalUrlString;
-    [self revealLinkedFileForField:field];
+    [self revealLocalURLForField:field];
 }
 
-- (void)revealLinkedFileAlertDidEnd:(NSAlert *)alert 
returnCode:(int)returnCode contextInfo:(void *)contextInfo {
+- (void)revealLocalURLAlertDidEnd:(NSAlert *)alert returnCode:(int)returnCode 
contextInfo:(void *)contextInfo {
     NSString *field = (NSString *)contextInfo;
     if (returnCode == NSAlertAlternateReturn) {
         NSEnumerator *e = [[self selectedPublications] objectEnumerator];
@@ -639,7 +641,7 @@
     [field release];
 }
 
-- (void)revealLinkedFileForField:(NSString *)field{
+- (void)revealLocalURLForField:(NSString *)field{
        int n = [self numberOfSelectedPubs];
     
     if (n > 6) {
@@ -651,10 +653,10 @@
                              informativeTextWithFormat:[NSString 
stringWithFormat:NSLocalizedString(@"BibDesk is about to reveal %i linked 
files. Do you want to proceed?" , @"Informative text in alert dialog"), n]];
         [alert beginSheetModalForWindow:documentWindow
                           modalDelegate:self
-                         
didEndSelector:@selector(revealLinkedFileAlertDidEnd:returnCode:contextInfo:) 
+                         
didEndSelector:@selector(revealLocalURLAlertDidEnd:returnCode:contextInfo:) 
                             contextInfo:[field retain]];
        } else {
-        [self revealLinkedFileAlertDidEnd:nil 
returnCode:NSAlertAlternateReturn contextInfo:[field retain]];
+        [self revealLocalURLAlertDidEnd:nil returnCode:NSAlertAlternateReturn 
contextInfo:[field retain]];
     }
 }
 
@@ -697,14 +699,14 @@
     }
 }
 
-- (IBAction)showNotesForLinkedFile:(id)sender{
+- (IBAction)showNotesForLocalURL:(id)sender{
        NSString *field = [sender representedObject];
     if (field == nil)
                field = BDSKLocalUrlString;
-    [self showNotesForLinkedFileForField:field];
+    [self showNotesForLocalURLForField:field];
 }
 
-- (void)showNotesForLinkedFileAlertDidEnd:(NSAlert *)alert 
returnCode:(int)returnCode contextInfo:(void *)contextInfo {
+- (void)showNotesForLocalURLAlertDidEnd:(NSAlert *)alert 
returnCode:(int)returnCode contextInfo:(void *)contextInfo {
     NSString *field = (NSString *)contextInfo;
     if (returnCode == NSAlertAlternateReturn) {
         NSEnumerator *e = [[self selectedPublications] objectEnumerator];
@@ -724,7 +726,7 @@
     [field release];
 }
 
-- (void)showNotesForLinkedFileForField:(NSString *)field{
+- (void)showNotesForLocalURLForField:(NSString *)field{
        int n = [self numberOfSelectedPubs];
     
     if (n > 6) {
@@ -736,21 +738,21 @@
                              informativeTextWithFormat:[NSString 
stringWithFormat:NSLocalizedString(@"BibDesk is about to open windows for notes 
for %i linked files. Do you want to proceed?" , @"Informative text in alert 
dialog"), n]];
         [alert beginSheetModalForWindow:documentWindow
                           modalDelegate:self
-                         
didEndSelector:@selector(showNotesForLinkedFileAlertDidEnd:returnCode:contextInfo:)
 
+                         
didEndSelector:@selector(showNotesForLocalURLAlertDidEnd:returnCode:contextInfo:)
 
                             contextInfo:[field retain]];
        } else {
-        [self showNotesForLinkedFileAlertDidEnd:nil 
returnCode:NSAlertAlternateReturn contextInfo:[field retain]];
+        [self showNotesForLocalURLAlertDidEnd:nil 
returnCode:NSAlertAlternateReturn contextInfo:[field retain]];
     }
 }
 
-- (IBAction)copyNotesForLinkedFile:(id)sender{
+- (IBAction)copyNotesForLocalURL:(id)sender{
        NSString *field = [sender representedObject];
     if (field == nil)
                field = BDSKLocalUrlString;
-    [self copyNotesForLinkedFileForField:field];
+    [self copyNotesForLocalURLForField:field];
 }
 
-- (void)copyNotesForLinkedFileForField:(NSString *)field{
+- (void)copyNotesForLocalURLForField:(NSString *)field{
     NSEnumerator *e = [[self selectedPublications] objectEnumerator];
     BibItem *pub;
     NSURL *fileURL;
@@ -776,6 +778,216 @@
     }
 }
 
+#pragma mark | Linked File actions
+
+- (void)openLinkedFileAlertDidEnd:(NSAlert *)alert returnCode:(int)returnCode 
contextInfo:(void *)contextInfo {
+    if (returnCode == NSAlertAlternateReturn) {
+        NSEnumerator *urlEnum;
+        NSURL *fileURL = [(NSURL *)contextInfo autorelease];
+        
+        if (fileURL)
+            urlEnum = [[NSArray arrayWithObject:fileURL] objectEnumerator];
+        else
+            urlEnum = [[[self selectedPublications] 
valueForKeyPath:@"@unionOfArrays.localFiles.URL"] objectEnumerator];
+        
+        NSString *searchString;
+        // See bug #1344720; don't search if this is a known field (Title, 
Author, etc.).  This feature can be annoying because Preview.app zooms in on 
the search result in this case, in spite of your zoom settings (bug report 
filed with Apple).
+        if([[searchButtonController selectedItemIdentifier] 
isEqualToString:BDSKFileContentSearchString])
+            searchString = [searchField stringValue];
+        else
+            searchString = @"";
+        
+        while (fileURL = [urlEnum nextObject]) {
+            if ([fileURL isEqual:[NSNull null]] == NO) {
+                [[NSWorkspace sharedWorkspace] openURL:fileURL 
withSearchString:searchString];
+            }
+        }
+    }
+}
+
+- (IBAction)openLinkedFile:(id)sender{
+    NSURL *fileURL = [sender representedObject];
+    if (fileURL) {
+        [self openLinkedFileAlertDidEnd:nil returnCode:NSAlertAlternateReturn 
contextInfo:(void *)[fileURL retain]];
+    } else {
+        int n = [[[self selectedPublications] 
valueForKeyPath:@"@unionOfArrays.localFiles"] count];
+        
+        if (n > 6) {
+            // Do we really want a gazillion of files open?
+            NSAlert *alert = [NSAlert 
alertWithMessageText:NSLocalizedString(@"Open Linked Files", @"Message in alert 
dialog when opening a lot of linked files")
+                                             
defaultButton:NSLocalizedString(@"No", @"Button title")
+                                           
alternateButton:NSLocalizedString(@"Open", @"Button title")
+                                               otherButton:nil
+                                 informativeTextWithFormat:[NSString 
stringWithFormat:NSLocalizedString(@"BibDesk is about to open %i linked files. 
Do you want to proceed?" , @"Informative text in alert dialog"), n]];
+            [alert beginSheetModalForWindow:documentWindow
+                              modalDelegate:self
+                             
didEndSelector:@selector(openLinkedFileAlertDidEnd:returnCode:contextInfo:) 
+                                contextInfo:NULL];
+        } else {
+            [self openLinkedFileAlertDidEnd:nil 
returnCode:NSAlertAlternateReturn contextInfo:NULL];
+        }
+    }
+}
+
+- (void)revealLinkedFileAlertDidEnd:(NSAlert *)alert 
returnCode:(int)returnCode contextInfo:(void *)contextInfo {
+    if (returnCode == NSAlertAlternateReturn) {
+        NSEnumerator *urlEnum;
+        NSURL *fileURL = [(NSURL *)contextInfo autorelease];
+        
+        if (fileURL)
+            urlEnum = [[NSArray arrayWithObject:fileURL] objectEnumerator];
+        else
+            urlEnum = [[[self selectedPublications] 
valueForKeyPath:@"@unionOfArrays.localFiles.URL"] objectEnumerator];
+        
+        while (fileURL = [urlEnum nextObject]) {
+            if ([fileURL isEqual:[NSNull null]] == NO) {
+                [[NSWorkspace sharedWorkspace]  selectFile:[fileURL path] 
inFileViewerRootedAtPath:nil];
+            }
+        }
+    }
+}
+
+- (IBAction)revealLinkedFile:(id)sender{
+    NSURL *fileURL = [sender representedObject];
+    if (fileURL) {
+        [self openLinkedFileAlertDidEnd:nil returnCode:NSAlertAlternateReturn 
contextInfo:(void *)[fileURL retain]];
+    } else {
+        int n = [[[self selectedPublications] 
valueForKeyPath:@"@unionOfArrays.localFiles"] count];
+        
+        if (n > 6) {
+            // Do we really want a gazillion of Finder windows?
+            NSAlert *alert = [NSAlert 
alertWithMessageText:NSLocalizedString(@"Reveal Linked Files", @"Message in 
alert dialog when trying to reveal a lot of linked files")
+                                             
defaultButton:NSLocalizedString(@"No", @"Button title")
+                                           
alternateButton:NSLocalizedString(@"Reveal", @"Button title")
+                                               otherButton:nil
+                                 informativeTextWithFormat:[NSString 
stringWithFormat:NSLocalizedString(@"BibDesk is about to reveal %i linked 
files. Do you want to proceed?" , @"Informative text in alert dialog"), n]];
+            [alert beginSheetModalForWindow:documentWindow
+                              modalDelegate:self
+                             
didEndSelector:@selector(revealLinkedFileAlertDidEnd:returnCode:contextInfo:) 
+                                contextInfo:NULL];
+        } else {
+            [self revealLinkedFileAlertDidEnd:nil 
returnCode:NSAlertAlternateReturn contextInfo:NULL];
+        }
+    }
+}
+
+- (void)openLinkedURLAlertDidEnd:(NSAlert *)alert returnCode:(int)returnCode 
contextInfo:(void *)contextInfo {
+    if(returnCode == NSAlertAlternateReturn){
+        NSEnumerator *urlEnum;
+        NSURL *remoteURL = [(NSURL *)contextInfo autorelease];
+        
+        if (remoteURL)
+            urlEnum = [[NSArray arrayWithObject:remoteURL] objectEnumerator];
+        else
+            urlEnum = [[[self selectedPublications] 
valueForKeyPath:@"@unionOfArrays.remoteURLs.URL"] objectEnumerator];
+        
+        while (remoteURL = [urlEnum nextObject]) {
+            if ([remoteURL isEqual:[NSNull null]] == NO) {
+                [[NSWorkspace sharedWorkspace] openURL:remoteURL];
+            }
+               }
+       }
+}
+
+- (IBAction)openLinkedURL:(id)sender{
+    NSURL *remoteURL = [sender representedObject];
+    if (remoteURL) {
+        [self openLinkedFileAlertDidEnd:nil returnCode:NSAlertAlternateReturn 
contextInfo:(void *)[remoteURL retain]];
+    } else {
+        int n = [[[self selectedPublications] 
valueForKeyPath:@"@unionOfArrays.remoteURLs"] count];
+        
+        if (n > 6) {
+            // Do we really want a gazillion of browser windows?
+            NSAlert *alert = [NSAlert 
alertWithMessageText:NSLocalizedString(@"Open Remote URL", @"Message in alert 
dialog when trying to open a lot of remote URLs")
+                                             
defaultButton:NSLocalizedString(@"No", @"Button title")
+                                          
alternateButton:NSLocalizedString(@"Open", @"Button title")
+                                              otherButton:nil
+                                informativeTextWithFormat:[NSString 
stringWithFormat:NSLocalizedString(@"BibDesk is about to open %i URLs. Do you 
want to proceed?" , @"Informative text in alert dialog"), n]];
+            [alert beginSheetModalForWindow:documentWindow
+                              modalDelegate:self
+                             
didEndSelector:@selector(openRemoteURLAlertDidEnd:returnCode:contextInfo:) 
+                                contextInfo:NULL];
+        } else {
+            [self openLinkedURLAlertDidEnd:nil 
returnCode:NSAlertAlternateReturn contextInfo:NULL];
+        }
+    }
+}
+
+- (void)showNotesForLinkedFileAlertDidEnd:(NSAlert *)alert 
returnCode:(int)returnCode contextInfo:(void *)contextInfo {
+    if (returnCode == NSAlertAlternateReturn) {
+        NSEnumerator *urlEnum;
+        NSURL *fileURL = [(NSURL *)contextInfo autorelease];
+        BDSKNotesWindowController *notesController;
+        
+        if (fileURL)
+            urlEnum = [[NSArray arrayWithObject:fileURL] objectEnumerator];
+        else
+            urlEnum = [[[self selectedPublications] 
valueForKeyPath:@"@unionOfArrays.localFiles.URL"] objectEnumerator];
+        while (fileURL = [urlEnum nextObject]) {
+            if ([fileURL isEqual:[NSNull null]] == NO) {
+                notesController = [[[BDSKNotesWindowController alloc] 
initWithURL:fileURL] autorelease];
+                [self addWindowController:notesController];
+                [notesController showWindow:self];
+            }
+        }
+    }
+}
+
+- (IBAction)showNotesForLinkedFile:(id)sender{
+    NSURL *fileURL = [sender representedObject];
+    if (fileURL) {
+        [self openLinkedFileAlertDidEnd:nil returnCode:NSAlertAlternateReturn 
contextInfo:(void *)[fileURL retain]];
+    } else {
+        int n = [[[self selectedPublications] 
valueForKeyPath:@"@unionOfArrays.localFiles"] count];
+        
+        if (n > 6) {
+            // Do we really want a gazillion of files open?
+            NSAlert *alert = [NSAlert 
alertWithMessageText:NSLocalizedString(@"Show Skim Notes For Linked Files", 
@"Message in alert dialog when showing notes for a lot of linked files")
+                                             
defaultButton:NSLocalizedString(@"No", @"Button title")
+                                           
alternateButton:NSLocalizedString(@"Open", @"Button title")
+                                               otherButton:nil
+                                 informativeTextWithFormat:[NSString 
stringWithFormat:NSLocalizedString(@"BibDesk is about to open windows for notes 
for %i linked files. Do you want to proceed?" , @"Informative text in alert 
dialog"), n]];
+            [alert beginSheetModalForWindow:documentWindow
+                              modalDelegate:self
+                             
didEndSelector:@selector(showNotesForLinkedFileAlertDidEnd:returnCode:contextInfo:)
 
+                                contextInfo:NULL];
+        } else {
+            [self showNotesForLinkedFileAlertDidEnd:nil 
returnCode:NSAlertAlternateReturn contextInfo:NULL];
+        }
+    }
+}
+
+- (IBAction)copyNotesForLinkedFile:(id)sender{
+    NSEnumerator *urlEnum;
+    NSURL *fileURL = [sender representedObject];
+    NSMutableString *notes = [NSMutableString string];
+    NSString *string;
+    
+    if (fileURL)
+        urlEnum = [[NSArray arrayWithObject:fileURL] objectEnumerator];
+    else
+        urlEnum = [[[self selectedPublications] 
valueForKeyPath:@"@unionOfArrays.localFiles.URL"] objectEnumerator];
+    
+    while (fileURL = [urlEnum nextObject]) {
+        if ([fileURL isEqual:[NSNull null]] == NO) {
+            string = [[BDSKSkimReader sharedReader] textNotesAtURL:fileURL];
+            if ([NSString isEmptyString:string] == NO) {
+                if ([notes length])
+                    [notes appendString:@"\n\n"];
+                [notes appendString:string];
+            }
+        }
+    }
+    
+    if ([notes isEqualToString:@""] == NO) {
+        NSPasteboard *pboard = [NSPasteboard generalPasteboard];
+        [pboard declareTypes:[NSArray arrayWithObject:NSStringPboardType] 
owner:nil];
+        [pboard setString:notes forType:NSStringPboardType];
+    } else {
+        NSBeep();
+    }
+}
+
 #pragma mark View Actions
 
 - (IBAction)selectAllPublications:(id)sender {

Modified: branches/TRY_ARM_FILE_INTERFACE/bibdesk/BibDocument_DataSource.m
===================================================================
--- branches/TRY_ARM_FILE_INTERFACE/bibdesk/BibDocument_DataSource.m    
2007-11-17 16:04:20 UTC (rev 11626)
+++ branches/TRY_ARM_FILE_INTERFACE/bibdesk/BibDocument_DataSource.m    
2007-11-17 18:40:44 UTC (rev 11627)
@@ -304,16 +304,16 @@
                if([tcId isURLField]){
             menu = [[NSMenu allocWithZone:[NSMenu menuZone]] init];
             if([tcId isLocalFileField]){
-                item = [menu addItemWithTitle:NSLocalizedString(@"Open Linked 
File", @"Menu item title") action:@selector(openLinkedFile:) keyEquivalent:@""];
+                item = [menu addItemWithTitle:NSLocalizedString(@"Open Linked 
File", @"Menu item title") action:@selector(openLocalURL:) keyEquivalent:@""];
                 [item setTarget:self];
                 [item setRepresentedObject:tcId];
-                item = [menu addItemWithTitle:NSLocalizedString(@"Reveal 
Linked File in Finder", @"Menu item title") action:@selector(revealLinkedFile:) 
keyEquivalent:@""];
+                item = [menu addItemWithTitle:NSLocalizedString(@"Reveal 
Linked File in Finder", @"Menu item title") action:@selector(revealLocalURL:) 
keyEquivalent:@""];
                 [item setTarget:self];
                 [item setRepresentedObject:tcId];
-                item = [menu addItemWithTitle:NSLocalizedString(@"Show Skim 
Notes For Linked File", @"Menu item title") 
action:@selector(showNotesForLinkedFile:) keyEquivalent:@""];
+                item = [menu addItemWithTitle:NSLocalizedString(@"Show Skim 
Notes For Linked File", @"Menu item title") 
action:@selector(showNotesForLocalURL:) keyEquivalent:@""];
                 [item setTarget:self];
                 [item setRepresentedObject:tcId];
-                item = [menu addItemWithTitle:NSLocalizedString(@"Copy Skim 
Notes For Linked File", @"Menu item title") 
action:@selector(copyNotesForLinkedFile:) keyEquivalent:@""];
+                item = [menu addItemWithTitle:NSLocalizedString(@"Copy Skim 
Notes For Linked File", @"Menu item title") 
action:@selector(copyNotesForLocalURL:) keyEquivalent:@""];
                 [item setTarget:self];
                 [item setRepresentedObject:tcId];
             }else{

Modified: branches/TRY_ARM_FILE_INTERFACE/bibdesk/BibEditor.h
===================================================================
--- branches/TRY_ARM_FILE_INTERFACE/bibdesk/BibEditor.h 2007-11-17 16:04:20 UTC 
(rev 11626)
+++ branches/TRY_ARM_FILE_INTERFACE/bibdesk/BibEditor.h 2007-11-17 18:40:44 UTC 
(rev 11627)
@@ -210,6 +210,12 @@
 */
 - (IBAction)moveLinkedFile:(id)sender;
 
+- (IBAction)openLinkedFile:(id)sender;
+
+- (IBAction)revealLinkedFile:(id)sender;
+
+- (IBAction)openLinkedURL:(id)sender;
+
 - (IBAction)showNotesForLinkedFile:(id)sender;
 
 - (IBAction)copyNotesForLinkedFile:(id)sender;

Modified: branches/TRY_ARM_FILE_INTERFACE/bibdesk/BibEditor.m
===================================================================
--- branches/TRY_ARM_FILE_INTERFACE/bibdesk/BibEditor.m 2007-11-17 16:04:20 UTC 
(rev 11626)
+++ branches/TRY_ARM_FILE_INTERFACE/bibdesk/BibEditor.m 2007-11-17 18:40:44 UTC 
(rev 11627)
@@ -471,38 +471,100 @@
     [field release];
 }
 
-- (IBAction)showNotesForLinkedFile:(id)sender{
+- (IBAction)openLinkedFile:(id)sender{
+    NSEnumerator *urlEnum = nil;
        NSURL *fileURL = [sender representedObject];
     
-    if (fileURL == nil) {
-        NSBeep();
-        return;
+    if (fileURL)
+        urlEnum = [[NSArray arrayWithObject:fileURL] objectEnumerator];
+    else
+        urlEnum = [[publication valueForKeyPath:@"localFiles.URL"] 
objectEnumerator];
+    
+    while (fileURL = [urlEnum nextObject]) {
+        if ([fileURL isEqual:[NSNull null]] == NO) {
+            [[NSWorkspace sharedWorkspace] openLinkedFile:[fileURL path]];
+        }
     }
+}
+
+- (IBAction)revealLinkedFile:(id)sender{
+    NSEnumerator *urlEnum = nil;
+       NSURL *fileURL = [sender representedObject];
     
-    BDSKNotesWindowController *notesController = [[[BDSKNotesWindowController 
alloc] initWithURL:fileURL] autorelease];
+    if (fileURL)
+        urlEnum = [[NSArray arrayWithObject:fileURL] objectEnumerator];
+    else
+        urlEnum = [[publication valueForKeyPath:@"remoteURLs.URL"] 
objectEnumerator];
     
-    [[self document] addWindowController:notesController];
-    [notesController showWindow:self];
+    while (fileURL = [urlEnum nextObject]) {
+        if ([fileURL isEqual:[NSNull null]] == NO) {
+            [[NSWorkspace sharedWorkspace]  selectFile:[fileURL path] 
inFileViewerRootedAtPath:nil];
+        }
+    }
 }
 
-- (IBAction)copyNotesForLinkedFile:(id)sender{
+- (IBAction)openLinkedURL:(id)sender{
+    NSEnumerator *urlEnum = nil;
+       NSURL *remoteURL = [sender representedObject];
+    
+    if (remoteURL)
+        urlEnum = [[NSArray arrayWithObject:remoteURL] objectEnumerator];
+    else
+        urlEnum = [[publication valueForKeyPath:@"remoteURLs.URL"] 
objectEnumerator];
+    
+    while (remoteURL = [urlEnum nextObject]) {
+        if ([remoteURL isEqual:[NSNull null]] == NO) {
+                       [[NSWorkspace sharedWorkspace] openURL:remoteURL];
+        }
+    }
+}
+
+- (IBAction)showNotesForLinkedFile:(id)sender{
+    NSEnumerator *urlEnum = nil;
        NSURL *fileURL = [sender representedObject];
     
-    if (fileURL == nil) {
-        NSBeep();
-        return;
+    if (fileURL)
+        urlEnum = [[NSArray arrayWithObject:fileURL] objectEnumerator];
+    else
+        urlEnum = [[publication valueForKeyPath:@"localFiles.URL"] 
objectEnumerator];
+    
+    while (fileURL = [urlEnum nextObject]) {
+        if ([fileURL isEqual:[NSNull null]] == NO) {
+            BDSKNotesWindowController *notesController = 
[[[BDSKNotesWindowController alloc] initWithURL:fileURL] autorelease];
+        
+            [[self document] addWindowController:notesController];
+            [notesController showWindow:self];
+        }
     }
+}
+
+- (IBAction)copyNotesForLinkedFile:(id)sender{
+    NSEnumerator *urlEnum = nil;
+       NSURL *fileURL = [sender representedObject];
+    NSMutableString *string = [NSMutableString string];
     
-    NSString *notes = [[BDSKSkimReader sharedReader] textNotesAtURL:fileURL];
+    if (fileURL)
+        urlEnum = [[NSArray arrayWithObject:fileURL] objectEnumerator];
+    else
+        urlEnum = [[publication valueForKeyPath:@"localFiles.URL"] 
objectEnumerator];
     
-    if ([notes isEqualToString:@""]) {
-        NSBeep();
-        return;
+    while (fileURL = [urlEnum nextObject]) {
+        if ([fileURL isEqual:[NSNull null]] == NO) {
+            NSString *notes = [[BDSKSkimReader sharedReader] 
textNotesAtURL:fileURL];
+            
+            if ([notes length]) {
+                if ([string length])
+                    [string appendString:@"\n\n"];
+                [string appendString:notes];
+            }
+            
+        }
     }
-    
-    NSPasteboard *pboard = [NSPasteboard generalPasteboard];
-    [pboard declareTypes:[NSArray arrayWithObject:NSStringPboardType] 
owner:nil];
-    [pboard setString:notes forType:NSStringPboardType];
+    if ([string length]) {
+        NSPasteboard *pboard = [NSPasteboard generalPasteboard];
+        [pboard declareTypes:[NSArray arrayWithObject:NSStringPboardType] 
owner:nil];
+        [pboard setString:string forType:NSStringPboardType];
+    }
 }
 
 #pragma mark Menus

Modified: branches/TRY_ARM_FILE_INTERFACE/bibdesk/BibItem.m
===================================================================
--- branches/TRY_ARM_FILE_INTERFACE/bibdesk/BibItem.m   2007-11-17 16:04:20 UTC 
(rev 11626)
+++ branches/TRY_ARM_FILE_INTERFACE/bibdesk/BibItem.m   2007-11-17 18:40:44 UTC 
(rev 11627)
@@ -3524,33 +3524,18 @@
     CFRelease(emptyFieldsToRemove);
 }
 
-static void addFileURLForFieldToArrayIfNotNil(const void *key, void *context)
+static void addURLForFieldToArrayIfNotNil(const void *key, void *context)
 {
     BibItem *self = (BibItem *)context;
-    NSURL *value = [self localFileURLForField:(id)key];
+    NSURL *value = [self URLForField:(id)key];
     if (value && [[self valueForKeyPath:@"files.URL"] containsObject:value] == 
NO) {
         // !!! file URLs are always absolute but the init method here always 
returns nil, which probably means that we should do the first initialization 
with relative paths instead of expending them first
-        BDSKLinkedFile *aFile = [[BDSKLinkedFile alloc] initWithURL:value 
delegate:self];
-        if (aFile) {
-            [self->files addObject:aFile];
-            [aFile release];
-        }
-        else NSLog(@"*** Unable to create alias to %@", value);
-    }
-}
-
-static void addRemoteURLForFieldToArrayIfNotNil(const void *key, void *context)
-{
-    BibItem *self = (BibItem *)context;
-    NSURL *value = [self remoteURLForField:(id)key];
-    if (value && [[self valueForKeyPath:@"files.URL"] containsObject:value] == 
NO) {
-        // !!! file URLs are always absolute but the init method here always 
returns nil, which probably means that we should do the first initialization 
with relative paths instead of expending them first
         BDSKLinkedFile *aURL = [[BDSKLinkedFile alloc] initWithURL:value 
delegate:self];
         if (aURL) {
             [self->files addObject:aURL];
             [aURL release];
         }
-        else NSLog(@"*** Unable to create URL to %@", value);
+        else NSLog(@"*** Unable to create file for %@", value);
     }
 }
 
@@ -3617,10 +3602,10 @@
     
     // @@ temporary hack to create an array of BDSKLinkedFiles from Local 
Files and BDSKLinkedURLs from Remote URLs
     if ([files count] == 0) {
-        CFSetRef fileSet = (CFSetRef)[[BDSKTypeManager sharedManager] 
localFileFieldsSet];
-        CFSetApplyFunction(fileSet, addFileURLForFieldToArrayIfNotNil, self);
-        CFSetRef remoteURLSet = (CFSetRef)[[BDSKTypeManager sharedManager] 
remoteURLFieldsSet];
-        CFSetApplyFunction(remoteURLSet, addRemoteURLForFieldToArrayIfNotNil, 
self);
+        CFArrayRef fieldsArray = (CFArrayRef)[[OFPreferenceWrapper 
sharedPreferenceWrapper] stringArrayForKey:BDSKLocalFileFieldsKey];
+        CFArrayApplyFunction(fieldsArray, CFRangeMake(0, 
CFArrayGetCount(fieldsArray)), addURLForFieldToArrayIfNotNil, self);
+        fieldsArray = (CFArrayRef)[[OFPreferenceWrapper 
sharedPreferenceWrapper] stringArrayForKey:BDSKRemoteURLFieldsKey];
+        CFArrayApplyFunction(fieldsArray, CFRangeMake(0, 
CFArrayGetCount(fieldsArray)), addURLForFieldToArrayIfNotNil, self);
     }
 }
 

Modified: 
branches/TRY_ARM_FILE_INTERFACE/bibdesk/English.lproj/BibDocument.nib/classes.nib
===================================================================
--- 
branches/TRY_ARM_FILE_INTERFACE/bibdesk/English.lproj/BibDocument.nib/classes.nib
   2007-11-17 16:04:20 UTC (rev 11626)
+++ 
branches/TRY_ARM_FILE_INTERFACE/bibdesk/English.lproj/BibDocument.nib/classes.nib
   2007-11-17 18:40:44 UTC (rev 11627)
@@ -158,6 +158,7 @@
             ACTIONS = {delete = id; selectNextIcon = id; selectPreviousIcon = 
id; }; 
             CLASS = FileView; 
             LANGUAGE = ObjC; 
+            OUTLETS = {dataSource = id; delegate = id; dragDataSource = id; }; 
             SUPERCLASS = NSView; 
         }, 
         {

Modified: 
branches/TRY_ARM_FILE_INTERFACE/bibdesk/English.lproj/BibDocument.nib/keyedobjects.nib
===================================================================
(Binary files differ)

Modified: 
branches/TRY_ARM_FILE_INTERFACE/bibdesk/English.lproj/BibEditor.nib/classes.nib
===================================================================
--- 
branches/TRY_ARM_FILE_INTERFACE/bibdesk/English.lproj/BibEditor.nib/classes.nib 
    2007-11-17 16:04:20 UTC (rev 11626)
+++ 
branches/TRY_ARM_FILE_INTERFACE/bibdesk/English.lproj/BibEditor.nib/classes.nib 
    2007-11-17 18:40:44 UTC (rev 11627)
@@ -92,7 +92,7 @@
             ACTIONS = {delete = id; selectNextIcon = id; selectPreviousIcon = 
id; }; 
             CLASS = FileView; 
             LANGUAGE = ObjC; 
-            OUTLETS = {dataSource = id; delegate = id; }; 
+            OUTLETS = {dataSource = id; delegate = id; dragDataSource = id; }; 
             SUPERCLASS = NSView; 
         }, 
         {CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; }, 

Modified: 
branches/TRY_ARM_FILE_INTERFACE/bibdesk/English.lproj/BibEditor.nib/info.nib
===================================================================
--- 
branches/TRY_ARM_FILE_INTERFACE/bibdesk/English.lproj/BibEditor.nib/info.nib    
    2007-11-17 16:04:20 UTC (rev 11626)
+++ 
branches/TRY_ARM_FILE_INTERFACE/bibdesk/English.lproj/BibEditor.nib/info.nib    
    2007-11-17 18:40:44 UTC (rev 11627)
@@ -26,15 +26,15 @@
        <key>IBOpenObjects</key>
        <array>
                <integer>726</integer>
+               <integer>74</integer>
+               <integer>640</integer>
                <integer>608</integer>
-               <integer>74</integer>
+               <integer>877</integer>
+               <integer>805</integer>
                <integer>759</integer>
-               <integer>805</integer>
-               <integer>877</integer>
-               <integer>640</integer>
        </array>
        <key>IBSystem Version</key>
-       <string>8R218</string>
+       <string>8S165</string>
        <key>targetFramework</key>
        <string>IBCocoaFramework</string>
 </dict>

Modified: 
branches/TRY_ARM_FILE_INTERFACE/bibdesk/English.lproj/BibEditor.nib/keyedobjects.nib
===================================================================
(Binary files differ)

Modified: 
branches/TRY_ARM_FILE_INTERFACE/bibdesk/English.lproj/MainMenu.nib/classes.nib
===================================================================
--- 
branches/TRY_ARM_FILE_INTERFACE/bibdesk/English.lproj/MainMenu.nib/classes.nib  
    2007-11-17 16:04:20 UTC (rev 11626)
+++ 
branches/TRY_ARM_FILE_INTERFACE/bibdesk/English.lproj/MainMenu.nib/classes.nib  
    2007-11-17 18:40:44 UTC (rev 11627)
@@ -88,7 +88,7 @@
                 openDocumentUsingFilter = id; 
                 openDocumentUsingPhonyCiteKeys = id; 
                 openLinkedFile = id; 
-                openRemoteURL = id; 
+                openLinkedURL = id; 
                 refreshAllExternalGroups = id; 
                 refreshScriptGroups = id; 
                 refreshSharedBrowsing = id; 

Modified: 
branches/TRY_ARM_FILE_INTERFACE/bibdesk/English.lproj/MainMenu.nib/info.nib
===================================================================
--- branches/TRY_ARM_FILE_INTERFACE/bibdesk/English.lproj/MainMenu.nib/info.nib 
2007-11-17 16:04:20 UTC (rev 11626)
+++ branches/TRY_ARM_FILE_INTERFACE/bibdesk/English.lproj/MainMenu.nib/info.nib 
2007-11-17 18:40:44 UTC (rev 11627)
@@ -18,7 +18,7 @@
                <integer>29</integer>
        </array>
        <key>IBSystem Version</key>
-       <string>8R218</string>
+       <string>8S165</string>
        <key>targetFramework</key>
        <string>IBCocoaFramework</string>
 </dict>

Modified: 
branches/TRY_ARM_FILE_INTERFACE/bibdesk/English.lproj/MainMenu.nib/keyedobjects.nib
===================================================================
(Binary files differ)

Modified: 
branches/TRY_ARM_FILE_INTERFACE/bibdesk/French.lproj/MainMenu.nib/classes.nib
===================================================================
--- 
branches/TRY_ARM_FILE_INTERFACE/bibdesk/French.lproj/MainMenu.nib/classes.nib   
    2007-11-17 16:04:20 UTC (rev 11626)
+++ 
branches/TRY_ARM_FILE_INTERFACE/bibdesk/French.lproj/MainMenu.nib/classes.nib   
    2007-11-17 18:40:44 UTC (rev 11627)
@@ -88,7 +88,7 @@
                 openDocumentUsingFilter = id; 
                 openDocumentUsingPhonyCiteKeys = id; 
                 openLinkedFile = id; 
-                openRemoteURL = id; 
+                openLinkedURL = id; 
                 refreshAllExternalGroups = id; 
                 refreshScriptGroups = id; 
                 refreshSharedBrowsing = id; 

Modified: 
branches/TRY_ARM_FILE_INTERFACE/bibdesk/French.lproj/MainMenu.nib/info.nib
===================================================================
--- branches/TRY_ARM_FILE_INTERFACE/bibdesk/French.lproj/MainMenu.nib/info.nib  
2007-11-17 16:04:20 UTC (rev 11626)
+++ branches/TRY_ARM_FILE_INTERFACE/bibdesk/French.lproj/MainMenu.nib/info.nib  
2007-11-17 18:40:44 UTC (rev 11627)
@@ -20,7 +20,7 @@
                <integer>29</integer>
        </array>
        <key>IBSystem Version</key>
-       <string>8R218</string>
+       <string>8S165</string>
        <key>targetFramework</key>
        <string>IBCocoaFramework</string>
 </dict>

Modified: 
branches/TRY_ARM_FILE_INTERFACE/bibdesk/French.lproj/MainMenu.nib/keyedobjects.nib
===================================================================
(Binary files differ)


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

Reply via email to