Revision: 22595
          http://sourceforge.net/p/bibdesk/svn/22595
Author:   hofman
Date:     2018-09-13 21:03:43 +0000 (Thu, 13 Sep 2018)
Log Message:
-----------
Only allow removal of publications from groups when all selected groups allow 
removal. Convenience method to check whether a group allows removal of pubs for 
easier validation.

Modified Paths:
--------------
    trunk/bibdesk/BDSKCategoryGroup.m
    trunk/bibdesk/BDSKGroup.h
    trunk/bibdesk/BDSKGroup.m
    trunk/bibdesk/BDSKLibraryGroup.m
    trunk/bibdesk/BDSKStaticGroup.m
    trunk/bibdesk/BibDocument_DataSource.m
    trunk/bibdesk/BibDocument_Groups.m
    trunk/bibdesk/BibDocument_Menus.m

Modified: trunk/bibdesk/BDSKCategoryGroup.m
===================================================================
--- trunk/bibdesk/BDSKCategoryGroup.m   2018-09-13 20:39:41 UTC (rev 22594)
+++ trunk/bibdesk/BDSKCategoryGroup.m   2018-09-13 21:03:43 UTC (rev 22595)
@@ -199,6 +199,10 @@
     return [key isPersonField];
 }
 
+- (BOOL)allowsRemoval {
+    return [key isSingleValuedGroupField] == NO && [key 
isEqualToString:BDSKPubTypeString] == NO;
+}
+
 - (BOOL)isEmpty { return NO; }
 
 @end
@@ -247,6 +251,8 @@
 
 - (BOOL)isEditable { return NO; }
 
+- (BOOL)allowsRemoval { return NO; }
+
 - (BOOL)isEmpty { return YES; }
 
 @end

Modified: trunk/bibdesk/BDSKGroup.h
===================================================================
--- trunk/bibdesk/BDSKGroup.h   2018-09-13 20:39:41 UTC (rev 22594)
+++ trunk/bibdesk/BDSKGroup.h   2018-09-13 21:03:43 UTC (rev 22595)
@@ -130,12 +130,18 @@
 - (BOOL)isNameEditable;
 
 /*!
-    @method     isEditable
-    @abstract   Returns NO by default.  Editable subclasses should override 
this to allow editing of its properties.
-*/
+ @method     isEditable
+ @abstract   Returns NO by default.  Editable subclasses should override this 
to allow editing of its properties.
+ */
 - (BOOL)isEditable;
 
 /*!
+ @method     allowsRemoval
+ @abstract   Returns NO by default.  Subclasses that allow removing 
publications should override this to allow removal.
+ */
+- (BOOL)allowsRemoval;
+
+/*!
     @method     failedDownload
     @abstract   Method for remote groups.  Returns NO by default.
 */

Modified: trunk/bibdesk/BDSKGroup.m
===================================================================
--- trunk/bibdesk/BDSKGroup.m   2018-09-13 20:39:41 UTC (rev 22594)
+++ trunk/bibdesk/BDSKGroup.m   2018-09-13 21:03:43 UTC (rev 22595)
@@ -154,6 +154,8 @@
 
 - (BOOL)isEditable { return NO; }
 
+- (BOOL)allowsRemoval { return NO; }
+
 - (BOOL)failedDownload { return NO; }
 
 - (BOOL)isRetrieving { return NO; }

Modified: trunk/bibdesk/BDSKLibraryGroup.m
===================================================================
--- trunk/bibdesk/BDSKLibraryGroup.m    2018-09-13 20:39:41 UTC (rev 22594)
+++ trunk/bibdesk/BDSKLibraryGroup.m    2018-09-13 21:03:43 UTC (rev 22595)
@@ -63,6 +63,8 @@
 
 - (BDSKGroupType)groupType { return BDSKLibraryGroupType; }
 
+- (BOOL)allowsRemoval { return NO; }
+
 - (NSArray *)publications {
     return [[self document] publications];
 }

Modified: trunk/bibdesk/BDSKStaticGroup.m
===================================================================
--- trunk/bibdesk/BDSKStaticGroup.m     2018-09-13 20:39:41 UTC (rev 22594)
+++ trunk/bibdesk/BDSKStaticGroup.m     2018-09-13 21:03:43 UTC (rev 22595)
@@ -125,6 +125,8 @@
 
 - (BDSKGroupType)groupType { return BDSKStaticGroupType; }
 
+- (BOOL)allowsRemoval { return NO; }
+
 - (NSArray *)publications {
     return publications;
 }

Modified: trunk/bibdesk/BibDocument_DataSource.m
===================================================================
--- trunk/bibdesk/BibDocument_DataSource.m      2018-09-13 20:39:41 UTC (rev 
22594)
+++ trunk/bibdesk/BibDocument_DataSource.m      2018-09-13 21:03:43 UTC (rev 
22595)
@@ -885,7 +885,7 @@
 
 - (BOOL)tableView:(NSTableView *)tv canDeleteRowsWithIndexes:(NSIndexSet 
*)rowIndexes {
        if (tv == tableView || tv == [fileSearchController tableView]) {
-               return [self hasGroupTypeSelected:BDSKExternalGroupType] == NO 
&& [rowIndexes count] > 0;
+        return [rowIndexes count] > 0 && NSNotFound == [[self selectedGroups] 
indexOfObjectPassingTest:^BOOL(id obj, NSUInteger idx, BOOL *stop){ return [obj 
allowsRemoval] == NO; }];
        }
     return NO;
 }

Modified: trunk/bibdesk/BibDocument_Groups.m
===================================================================
--- trunk/bibdesk/BibDocument_Groups.m  2018-09-13 20:39:41 UTC (rev 22594)
+++ trunk/bibdesk/BibDocument_Groups.m  2018-09-13 21:03:43 UTC (rev 22595)
@@ -1317,11 +1317,9 @@
        NSString *groupName = nil;
     
     for (BDSKCategoryGroup *group in groupArray){
-        if(([group groupType] & BDSKCategoryGroupType) == 0)
+        if(([group groupType] & BDSKCategoryGroupType) == 0 || [group 
allowsRemoval] == NO)
             continue;
-        if([group isEmpty])
-            continue;
-
+        
                if (groupName == nil)
                        groupName = [NSString 
stringWithFormat:NSLocalizedString(@"group %@", @"Partial status message"), 
[group name]];
                else
@@ -1335,9 +1333,6 @@
                BDSKFieldAction rv;
         NSInteger tmpCount = 0;
                
-        if([field isSingleValuedGroupField] || [field 
isEqualToString:BDSKPubTypeString])
-            continue;
-        
                for (BibItem *pub in pubs) {
                        BDSKASSERT([pub isKindOfClass:[BibItem class]]);        
                        

Modified: trunk/bibdesk/BibDocument_Menus.m
===================================================================
--- trunk/bibdesk/BibDocument_Menus.m   2018-09-13 20:39:41 UTC (rev 22594)
+++ trunk/bibdesk/BibDocument_Menus.m   2018-09-13 21:03:43 UTC (rev 22595)
@@ -126,7 +126,7 @@
     if ([self hasGroupTypeSelected:BDSKStaticGroupType])
         return YES;
     // don't remove from single valued group field, as that will clear the 
field, which is most probably a mistake. See bug # 1435344
-    if (NSNotFound != [[self selectedGroups] indexOfObjectPassingTest:^BOOL(id 
obj, NSUInteger idx, BOOL *stop){ return [obj groupType] == 
BDSKCategoryGroupType && [[obj key] isSingleValuedGroupField] == NO && [[obj 
key] isEqualToString:BDSKPubTypeString] == NO && [obj isEmpty] == NO; }])
+    if (NSNotFound == [[self selectedGroups] indexOfObjectPassingTest:^BOOL(id 
obj, NSUInteger idx, BOOL *stop){ return [obj allowsRemoval] == NO; }])
         return YES;
     return 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

Reply via email to