Revision: 18447
          http://bibdesk.svn.sourceforge.net/bibdesk/?rev=18447&view=rev
Author:   hofman
Date:     2012-01-28 12:16:46 +0000 (Sat, 28 Jan 2012)
Log Message:
-----------
Simplify previous commit. Add filer error controller to document's window 
controllers, so it will be automatically closed with the document and retained 
as long as needed, as well as knowing about the document.

Modified Paths:
--------------
    trunk/bibdesk/BDSKFiler.h
    trunk/bibdesk/BDSKFiler.m
    trunk/bibdesk/BDSKFilerErrorController.h
    trunk/bibdesk/BDSKFilerErrorController.m
    trunk/bibdesk/BibDocument.m

Modified: trunk/bibdesk/BDSKFiler.h
===================================================================
--- trunk/bibdesk/BDSKFiler.h   2012-01-28 12:06:37 UTC (rev 18446)
+++ trunk/bibdesk/BDSKFiler.h   2012-01-28 12:16:46 UTC (rev 18447)
@@ -68,7 +68,6 @@
 
 @interface BDSKFiler : NSWindowController {
        IBOutlet NSProgressIndicator *progressIndicator;
-    NSMutableArray *errorControllers;
 }
 
 + (BDSKFiler *)sharedFiler;
@@ -101,8 +100,6 @@
 */
 - (BOOL)movePapers:(NSArray *)paperInfos forField:(NSString *)field 
fromDocument:(BibDocument *)doc options:(BDSKFilerOptions)masks;
 
-- (void)closeErrorControllersForDocument:(BibDocument *)document;
-
 @end
 
 

Modified: trunk/bibdesk/BDSKFiler.m
===================================================================
--- trunk/bibdesk/BDSKFiler.m   2012-01-28 12:06:37 UTC (rev 18446)
+++ trunk/bibdesk/BDSKFiler.m   2012-01-28 12:16:46 UTC (rev 18447)
@@ -69,34 +69,9 @@
 
 - (id)init{
     BDSKPRECONDITION(sharedFiler == nil);
-       self = [super initWithWindowNibName:@"AutoFileProgress"];
-    if (self) {
-        errorControllers = [[NSMutableArray alloc] init];
-    }
-    return self;
+       return [super initWithWindowNibName:@"AutoFileProgress"];
 }
 
-- (void)dealloc {
-    BDSKDESTROY(errorControllers);
-    [super dealloc];
-}
-
-- (void)handleErrorWindowWillCloseNotification:(NSNotification *)notification {
-    NSWindow *window = [notification object];
-    BDSKFilerErrorController *errorController = [[[window windowController] 
retain] autorelease];
-    [errorControllers removeObject:errorController];
-    [[NSNotificationCenter defaultCenter] removeObserver:self 
name:NSWindowWillCloseNotification object:window];
-}
-
-- (void)closeErrorControllersForDocument:(BibDocument *)document {
-    NSUInteger i = [errorControllers count];
-    while (i-- > 0) {
-        BDSKFilerErrorController *errorController = [errorControllers 
objectAtIndex:i];
-        if ([errorController document] == document)
-            [errorController close];
-    }
-}
-
 #pragma mark Auto file methods
 
 - (BOOL)checkPapersFolder {
@@ -253,10 +228,9 @@
         [[[doc undoManager] prepareWithInvocationTarget:self] 
movePapers:fileInfoDicts forField:field fromDocument:doc options:0];
        
        if ([errorInfoDicts count] > 0) {
-               BDSKFilerErrorController *errorController = 
[[[BDSKFilerErrorController alloc] initWithErrors:errorInfoDicts forField:field 
fromDocument:doc options:mask] autorelease];
-        [errorControllers addObject:errorController];
+               BDSKFilerErrorController *errorController = 
[[[BDSKFilerErrorController alloc] initWithErrors:errorInfoDicts forField:field 
options:mask] autorelease];
+        [doc addWindowController:errorController];
         [errorController showWindow:nil];
-        [[NSNotificationCenter defaultCenter] addObserver:self 
selector:@selector(handleErrorWindowWillCloseNotification:) 
name:NSWindowWillCloseNotification object:[errorController window]];
     }
     
     return [fileInfoDicts count] > 0;

Modified: trunk/bibdesk/BDSKFilerErrorController.h
===================================================================
--- trunk/bibdesk/BDSKFilerErrorController.h    2012-01-28 12:06:37 UTC (rev 
18446)
+++ trunk/bibdesk/BDSKFilerErrorController.h    2012-01-28 12:16:46 UTC (rev 
18447)
@@ -38,7 +38,6 @@
 
 #import <Cocoa/Cocoa.h>
 
-@class BibDocument;
 
 @interface BDSKFilerErrorController : NSWindowController <NSTableViewDelegate, 
NSTableViewDataSource> {
        IBOutlet NSTableView *tv;
@@ -47,14 +46,13 @@
        IBOutlet NSButton *forceCheckButton;
        IBOutlet NSMenu *contextMenu;
     
-    BibDocument *document;
     NSString *fieldName;
     NSInteger options;
     
        NSArray *errorInfoDicts;
 }
 
-- (id)initWithErrors:(NSArray *)infoDicts forField:(NSString *)field 
fromDocument:(BibDocument *)doc options:(NSInteger)masks;
+- (id)initWithErrors:(NSArray *)infoDicts forField:(NSString *)field 
options:(NSInteger)masks;
 
 - (IBAction)done:(id)sender;
 - (IBAction)tryAgain:(id)sender;
@@ -62,8 +60,6 @@
 - (IBAction)selectAll:(id)sender;
 - (IBAction)showFile:(id)sender;
 
-- (BibDocument *)sourceDocument;
-
 - (NSArray *)errorInfoDicts;
 - (NSUInteger)countOfErrorInfoDicts;
 - (id)objectInErrorInfoDictsAtIndex:(NSUInteger)index;

Modified: trunk/bibdesk/BDSKFilerErrorController.m
===================================================================
--- trunk/bibdesk/BDSKFilerErrorController.m    2012-01-28 12:06:37 UTC (rev 
18446)
+++ trunk/bibdesk/BDSKFilerErrorController.m    2012-01-28 12:16:46 UTC (rev 
18447)
@@ -61,10 +61,9 @@
                                                                        
forName:BDSKNewPathColorTransformerName];
 }
 
-- (id)initWithErrors:(NSArray *)infoDicts forField:(NSString *)field 
fromDocument:(BibDocument *)doc options:(NSInteger)mask {
+- (id)initWithErrors:(NSArray *)infoDicts forField:(NSString *)field 
options:(NSInteger)mask {
     self = [super initWithWindowNibName:@"AutoFile"];
     if (self) {
-        document = [doc retain];
         fieldName = [field retain];
         options = mask;
         
@@ -81,7 +80,6 @@
     [tv setDelegate:nil];
     [tv setDataSource:nil];
     BDSKDESTROY(errorInfoDicts);
-    BDSKDESTROY(document);
     BDSKDESTROY(fieldName);
     [super dealloc];
 }
@@ -120,14 +118,13 @@
         return;
     }
     
-    BibDocument *doc = [[document retain] autorelease];
     NSString *field = [[fieldName retain] autorelease];
     BDSKFilerOptions mask = (options & BDSKInitialAutoFileOptionMask);
     mask |= ([forceCheckButton state]) ? BDSKForceAutoFileOptionMask : 
(options & BDSKCheckCompleteAutoFileOptionMask);
     
     [self close];
     
-    [[BDSKFiler sharedFiler] movePapers:fileInfoDicts forField:field 
fromDocument:doc options:mask];
+    [[BDSKFiler sharedFiler] movePapers:fileInfoDicts forField:field 
fromDocument:[self document] options:mask];
 }
 
 - (IBAction)dump:(id)sender{
@@ -201,17 +198,13 @@
         case 2:
             pub = [dict objectForKey:BDSKFilerPublicationKey];
             // at this moment we have the document set
-            [document editPub:pub];
+            [[self document] editPub:pub];
             break;
        }
 }
 
 #pragma mark Accessors
 
-- (BibDocument *)sourceDocument {
-    return document;
-}
-
 - (NSArray *)errorInfoDicts {
     return errorInfoDicts;
 }

Modified: trunk/bibdesk/BibDocument.m
===================================================================
--- trunk/bibdesk/BibDocument.m 2012-01-28 12:06:37 UTC (rev 18446)
+++ trunk/bibdesk/BibDocument.m 2012-01-28 12:16:46 UTC (rev 18447)
@@ -658,8 +658,6 @@
        [self numberOfSelectedPubs] != 0)
         [[BDSKPreviewer sharedPreviewer] updateWithBibTeXString:nil];    
        
-    [[BDSKFiler sharedFiler] closeErrorControllersForDocument:self];
-    
        [pboardHelper setDelegate:nil];
     [pboardHelper release];
     pboardHelper = nil;

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
_______________________________________________
Bibdesk-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit

Reply via email to