Revision: 6928
          http://skim-app.svn.sourceforge.net/skim-app/?rev=6928&view=rev
Author:   hofman
Date:     2010-12-04 12:26:22 +0000 (Sat, 04 Dec 2010)

Log Message:
-----------
let bookmark initializer create children for session bookmark to avoid code 
duplication

Modified Paths:
--------------
    trunk/SKBookmark.h
    trunk/SKBookmark.m
    trunk/SKBookmarkController.m

Modified: trunk/SKBookmark.h
===================================================================
--- trunk/SKBookmark.h  2010-12-04 12:14:57 UTC (rev 6927)
+++ trunk/SKBookmark.h  2010-12-04 12:26:22 UTC (rev 6928)
@@ -61,7 +61,7 @@
 + (id)bookmarkWithSetup:(NSDictionary *)aSetupDict label:(NSString *)aLabel;
 + (id)bookmarkFolderWithChildren:(NSArray *)aChildren label:(NSString *)aLabel;
 + (id)bookmarkFolderWithLabel:(NSString *)aLabel;
-+ (id)bookmarkSessionWithChildren:(NSArray *)aChildren label:(NSString 
*)aLabel;
++ (id)bookmarkSessionWithSetups:(NSArray *)aSetupDicts label:(NSString 
*)aLabel;
 + (id)bookmarkSeparator;
 + (id)bookmarkWithProperties:(NSDictionary *)dictionary;
 
@@ -70,7 +70,7 @@
 - (id)initFolderWithChildren:(NSArray *)aChildren label:(NSString *)aLabel;
 - (id)initFolderWithLabel:(NSString *)aLabel;
 - (id)initRootWithChildren:(NSArray *)aChildren;
-- (id)initSessionWithChildren:(NSArray *)aChildren label:(NSString *)aLabel;
+- (id)initSessionWithSetups:(NSArray *)aSetupDicts label:(NSString *)aLabel;
 - (id)initSeparator;
 - (id)initWithProperties:(NSDictionary *)dictionary;
 

Modified: trunk/SKBookmark.m
===================================================================
--- trunk/SKBookmark.m  2010-12-04 12:14:57 UTC (rev 6927)
+++ trunk/SKBookmark.m  2010-12-04 12:26:22 UTC (rev 6928)
@@ -121,8 +121,8 @@
     return [[[self alloc] initFolderWithLabel:aLabel] autorelease];
 }
 
-+ (id)bookmarkSessionWithChildren:(NSArray *)aChildren label:(NSString 
*)aLabel {
-    return [[[self alloc] initSessionWithChildren:aChildren label:aLabel] 
autorelease];
++ (id)bookmarkSessionWithSetups:(NSArray *)aSetupDicts label:(NSString 
*)aLabel {
+    return [[[self alloc] initSessionWithSetups:aSetupDicts label:aLabel] 
autorelease];
 }
 
 + (id)bookmarkSeparator {
@@ -158,7 +158,7 @@
     return nil;
 }
 
-- (id)initSessionWithChildren:(NSArray *)aChildren label:(NSString *)aLabel {
+- (id)initSessionWithSetups:(NSArray *)aSetupDicts label:(NSString *)aLabel {
     [self doesNotRecognizeSelector:_cmd];
     return nil;
 }
@@ -288,14 +288,9 @@
                 break;
             case SKScriptingBookmarkTypeSession:
             {
-                NSMutableArray *children = [NSMutableArray array];
-                SKBookmark *child;
-                for (NSDictionary *setup in [[NSApp orderedDocuments] 
valueForKey:@"currentDocumentSetup"]) {
-                    if (child = [SKBookmark bookmarkWithSetup:setup label:@""])
-                        [children addObject:child];
-                }
+                NSArray *setups = [[NSApp orderedDocuments] 
valueForKey:@"currentDocumentSetup"];
                 NSString *aLabel = [properties objectForKey:@"label"] ?: @"";
-                bookmark = [SKBookmark bookmarkSessionWithChildren:children 
label:aLabel];
+                bookmark = [SKBookmark bookmarkSessionWithSetups:setups 
label:aLabel];
                 break;
             }
             default:
@@ -355,7 +350,15 @@
     return [[SKRootBookmark alloc] initFolderWithChildren:aChildren 
label:NSLocalizedString(@"Bookmarks Menu", @"Menu item title")];
 }
 
-- (id)initSessionWithChildren:(NSArray *)aChildren label:(NSString *)aLabel {
+- (id)initSessionWithSetups:(NSArray *)aSetupDicts label:(NSString *)aLabel {
+    NSMutableArray *aChildren = [NSMutableArray array];
+    SKBookmark *child;
+    for (NSDictionary *setup in aSetupDicts) {
+        if (child = [SKBookmark bookmarkWithSetup:setup label:@""])
+            [aChildren addObject:child];
+        else
+            NSLog(@"Failed to get child bookmark: %@", setup);
+    }
     return [[SKSessionBookmark alloc] initFolderWithChildren:aChildren 
label:aLabel];
 }
 

Modified: trunk/SKBookmarkController.m
===================================================================
--- trunk/SKBookmarkController.m        2010-12-04 12:14:57 UTC (rev 6927)
+++ trunk/SKBookmarkController.m        2010-12-04 12:26:22 UTC (rev 6928)
@@ -226,14 +226,9 @@
 }
 
 - (void)addBookmarkForSetups:(NSArray *)setupDicts label:(NSString *)label 
toFolder:(SKBookmark *)folder {
-    NSMutableArray *children = [NSMutableArray array];
-    SKBookmark *bookmark;
-    for (NSDictionary *setup in setupDicts) {
-        if (bookmark = [SKBookmark bookmarkWithSetup:setup label:@""])
-            [children addObject:bookmark];
-    }
     if (folder == nil) folder = bookmarkRoot;
-    if (bookmark = [SKBookmark bookmarkSessionWithChildren:children 
label:label])
+    SKBookmark *bookmark = [SKBookmark bookmarkSessionWithSetups:setupDicts 
label:label];
+    if (bookmark)
         [folder insertObject:bookmark inChildrenAtIndex:[folder 
countOfChildren]];
 }
 


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

------------------------------------------------------------------------------
What happens now with your Lotus Notes apps - do you make another costly 
upgrade, or settle for being marooned without product support? Time to move
off Lotus Notes and onto the cloud with Force.com, apps are easier to build,
use, and manage than apps on traditional platforms. Sign up for the Lotus 
Notes Migration Kit to learn more. http://p.sf.net/sfu/salesforce-d2d
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to