Revision: 18397
http://bibdesk.svn.sourceforge.net/bibdesk/?rev=18397&view=rev
Author: hofman
Date: 2012-01-12 13:01:57 +0000 (Thu, 12 Jan 2012)
Log Message:
-----------
Separate method to check for papers folder. Check whether files have been
filed, no need to set undo action name when we didn't
Modified Paths:
--------------
trunk/bibdesk/BDSKAutofileCommand.m
trunk/bibdesk/BDSKEditor.m
trunk/bibdesk/BDSKFiler.h
trunk/bibdesk/BDSKFiler.m
trunk/bibdesk/BDSKTextImportController.m
trunk/bibdesk/BibDocument_Actions.m
Modified: trunk/bibdesk/BDSKAutofileCommand.m
===================================================================
--- trunk/bibdesk/BDSKAutofileCommand.m 2012-01-12 12:48:23 UTC (rev 18396)
+++ trunk/bibdesk/BDSKAutofileCommand.m 2012-01-12 13:01:57 UTC (rev 18397)
@@ -89,12 +89,12 @@
[papersFolderPath stringByAppendingPathComponent:location];
}
NSArray *paperInfos = [NSArray arrayWithObject:[NSDictionary
dictionaryWithObjectsAndKeys:[localFiles objectAtIndex:i], BDSKFilerFileKey,
pub, BDSKFilerPublicationKey, location, BDSKFilerNewPathKey, nil]];
- [[BDSKFiler sharedFiler] movePapers:paperInfos
forField:BDSKLocalFileString fromDocument:doc options:mask];
- [[pub undoManager]
setActionName:NSLocalizedString(@"AppleScript",@"Undo action name for
AppleScript")];
+ if ([[BDSKFiler sharedFiler] movePapers:paperInfos
forField:BDSKLocalFileString fromDocument:doc options:mask])
+ [[pub undoManager]
setActionName:NSLocalizedString(@"AppleScript",@"Undo action name for
AppleScript")];
} else {
NSArray *files = indexNumber ? [NSArray arrayWithObject:[localFiles
objectAtIndex:i]] : [pub localFiles];
- [[BDSKFiler sharedFiler] autoFileLinkedFiles:files fromDocument:doc
check:check];
- [[pub undoManager]
setActionName:NSLocalizedString(@"AppleScript",@"Undo action name for
AppleScript")];
+ if ([[BDSKFiler sharedFiler] autoFileLinkedFiles:files
fromDocument:doc check:check])
+ [[pub undoManager]
setActionName:NSLocalizedString(@"AppleScript",@"Undo action name for
AppleScript")];
}
return nil;
Modified: trunk/bibdesk/BDSKEditor.m
===================================================================
--- trunk/bibdesk/BDSKEditor.m 2012-01-12 12:48:23 UTC (rev 18396)
+++ trunk/bibdesk/BDSKEditor.m 2012-01-12 13:01:57 UTC (rev 18397)
@@ -1005,11 +1005,10 @@
if ([files count] == 0)
return;
- [[BDSKFiler sharedFiler] autoFileLinkedFiles:files fromDocument:[self
document] check:NO];
+ if ([[BDSKFiler sharedFiler] autoFileLinkedFiles:files
fromDocument:[self document] check:NO])
+ [[self undoManager] setActionName:NSLocalizedString(@"Move File",
@"Undo action name")];
[tabView selectFirstTabViewItem:self];
-
- [[self undoManager] setActionName:NSLocalizedString(@"Move File",
@"Undo action name")];
}
- (IBAction)consolidateLinkedFiles:(id)sender{
Modified: trunk/bibdesk/BDSKFiler.h
===================================================================
--- trunk/bibdesk/BDSKFiler.h 2012-01-12 12:48:23 UTC (rev 18396)
+++ trunk/bibdesk/BDSKFiler.h 2012-01-12 13:01:57 UTC (rev 18397)
@@ -81,7 +81,7 @@
@discussion This is the main method that should be used to autofile
papers.
It calls the necessary methods to do the move and generates the new locations
for the papers.
*/
-- (void)autoFileLinkedFiles:(NSArray *)papers fromDocument:(BibDocument *)doc
check:(BOOL)check;
+- (BOOL)autoFileLinkedFiles:(NSArray *)papers fromDocument:(BibDocument *)doc
check:(BOOL)check;
/*!
@method movePapers:forField:fromDocument:options:
@@ -98,7 +98,7 @@
BDSKCheckCompleteAutoFileOptionMask indicates that for initial moves a check
will be done whether all required fields are set.
BDSKForceAutoFileOptionMask forces AutoFiling, even if there may be problems
moving the file.
*/
-- (void)movePapers:(NSArray *)paperInfos forField:(NSString *)field
fromDocument:(BibDocument *)doc options:(BDSKFilerOptions)masks;
+- (BOOL)movePapers:(NSArray *)paperInfos forField:(NSString *)field
fromDocument:(BibDocument *)doc options:(BDSKFilerOptions)masks;
@end
Modified: trunk/bibdesk/BDSKFiler.m
===================================================================
--- trunk/bibdesk/BDSKFiler.m 2012-01-12 12:48:23 UTC (rev 18396)
+++ trunk/bibdesk/BDSKFiler.m 2012-01-12 13:01:57 UTC (rev 18397)
@@ -74,7 +74,7 @@
#pragma mark Auto file methods
-- (void)autoFileLinkedFiles:(NSArray *)papers fromDocument:(BibDocument *)doc
check:(BOOL)check{
+- (BOOL)checkPapersFolder {
NSString *papersFolderPath = [[NSUserDefaults standardUserDefaults]
stringForKey:BDSKPapersFolderPathKey];
if (NO == [NSString isEmptyString:papersFolderPath]) {
@@ -97,10 +97,16 @@
[[BDSKPreferenceController sharedPreferenceController]
showWindow:self];
[[BDSKPreferenceController sharedPreferenceController]
selectPaneWithIdentifier:@"edu.ucsd.cs.mmccrack.bibdesk.prefpane.autofile"];
}
- return;
+ return NO;
}
}
-
+ return YES;
+}
+
+- (BOOL)autoFileLinkedFiles:(NSArray *)papers fromDocument:(BibDocument *)doc
check:(BOOL)check{
+ if ([self checkPapersFolder] == NO)
+ return NO;
+
BDSKFilerOptions mask = BDSKInitialAutoFileOptionMask;
if (check) mask |= BDSKCheckCompleteAutoFileOptionMask;
@@ -108,10 +114,10 @@
for (BDSKLinkedFile *file in papers)
[paperInfos addObject:[NSDictionary dictionaryWithObjectsAndKeys:file,
BDSKFilerFileKey, [file delegate], BDSKFilerPublicationKey, nil]];
- [self movePapers:paperInfos forField:BDSKLocalFileString
fromDocument:doc options:mask];
+ return [self movePapers:paperInfos forField:BDSKLocalFileString
fromDocument:doc options:mask];
}
-- (void)movePapers:(NSArray *)paperInfos forField:(NSString *)field
fromDocument:(BibDocument *)doc options:(BDSKFilerOptions)mask{
+- (BOOL)movePapers:(NSArray *)paperInfos forField:(NSString *)field
fromDocument:(BibDocument *)doc options:(BDSKFilerOptions)mask{
NSFileManager *fm = [NSFileManager defaultManager];
NSInteger numberOfPapers = [paperInfos count];
BibItem *pub = nil;
@@ -128,7 +134,7 @@
BOOL check = (initial) && (force == NO) && (mask &
BDSKCheckCompleteAutoFileOptionMask);
if (numberOfPapers == 0)
- return;
+ return NO;
if (initial && [field isEqualToString:BDSKLocalFileString] == NO)
[NSException raise:BDSKUnimplementedException format:@"%@ is only
implemented for local files for initial moves.",NSStringFromSelector(_cmd)];
@@ -221,6 +227,8 @@
BDSKFilerErrorController *errorController =
[[[BDSKFilerErrorController alloc] initWithErrors:errorInfoDicts forField:field
fromDocument:doc options:mask] autorelease];
[[errorController window] makeKeyAndOrderFront:nil];
}
+
+ return [fileInfoDicts count] > 0;
}
@end
Modified: trunk/bibdesk/BDSKTextImportController.m
===================================================================
--- trunk/bibdesk/BDSKTextImportController.m 2012-01-12 12:48:23 UTC (rev
18396)
+++ trunk/bibdesk/BDSKTextImportController.m 2012-01-12 13:01:57 UTC (rev
18397)
@@ -451,9 +451,8 @@
if ([files count] == 0)
return;
- [[BDSKFiler sharedFiler] autoFileLinkedFiles:files fromDocument:document
check:NO];
-
- [[self undoManager] setActionName:NSLocalizedString(@"Move File",
@"Undo action name")];
+ if ([[BDSKFiler sharedFiler] autoFileLinkedFiles:files
fromDocument:document check:NO])
+ [[self undoManager] setActionName:NSLocalizedString(@"Move File",
@"Undo action name")];
}
- (IBAction)consolidateLinkedFiles:(id)sender{
Modified: trunk/bibdesk/BibDocument_Actions.m
===================================================================
--- trunk/bibdesk/BibDocument_Actions.m 2012-01-12 12:48:23 UTC (rev 18396)
+++ trunk/bibdesk/BibDocument_Actions.m 2012-01-12 13:01:57 UTC (rev 18397)
@@ -1490,9 +1490,8 @@
// first we make sure all edits are committed
if ([self commitPendingEdits]) {
NSArray *selectedFiles = [[self selectedPublications]
valueForKeyPath:@"@unionOfArrays.localFiles"];
- [[BDSKFiler sharedFiler] autoFileLinkedFiles:selectedFiles
fromDocument:self check:(rv == NSAlertDefaultReturn)];
-
- [[self undoManager] setActionName:NSLocalizedString(@"AutoFile
Files", @"Undo action name")];
+ if ([[BDSKFiler sharedFiler] autoFileLinkedFiles:selectedFiles
fromDocument:self check:(rv == NSAlertDefaultReturn)])
+ [[self undoManager] setActionName:NSLocalizedString(@"AutoFile
Files", @"Undo action name")];
} else {
NSBeep();
}
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
RSA(R) Conference 2012
Mar 27 - Feb 2
Save $400 by Jan. 27
Register now!
http://p.sf.net/sfu/rsa-sfdev2dev2
_______________________________________________
Bibdesk-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit