Revision: 22660
          http://sourceforge.net/p/bibdesk/svn/22660
Author:   hofman
Date:     2018-09-24 15:50:29 +0000 (Mon, 24 Sep 2018)
Log Message:
-----------
Allow passing the container for the add command through the subject of the 
apple event

Modified Paths:
--------------
    trunk/bibdesk/BDSKAddCommand.m
    trunk/bibdesk/BDSKRemoveCommand.m
    trunk/bibdesk/Scripting/BibDesk.sdef

Modified: trunk/bibdesk/BDSKAddCommand.m
===================================================================
--- trunk/bibdesk/BDSKAddCommand.m      2018-09-24 06:30:25 UTC (rev 22659)
+++ trunk/bibdesk/BDSKAddCommand.m      2018-09-24 15:50:29 UTC (rev 22660)
@@ -85,6 +85,13 @@
             NSArray *classDescriptions = [insertionObjects 
valueForKey:@"scriptClassDescription"];
             NSScriptClassDescription *insertionClassDescription = 
[classDescriptions containsObject:[NSNull null]] ? nil : 
[NSScriptClassDescription commonAncestorForClassDescriptions:classDescriptions];
             
+            if (locationSpecifier == nil) {
+                // get it from the subject of the event when it was not given
+                locationSpecifier = [[self appleEvent] objCObjectValue];
+                if ([locationSpecifier isKindOfClass:[NSScriptObjectSpecifier 
class]] == NO)
+                    locationSpecifier = nil;
+            }
+            
             if ([locationSpecifier isKindOfClass:[NSPositionalSpecifier 
class]]) {
                 [locationSpecifier 
setInsertionClassDescription:insertionClassDescription];
                 insertionContainer = [locationSpecifier insertionContainer];

Modified: trunk/bibdesk/BDSKRemoveCommand.m
===================================================================
--- trunk/bibdesk/BDSKRemoveCommand.m   2018-09-24 06:30:25 UTC (rev 22659)
+++ trunk/bibdesk/BDSKRemoveCommand.m   2018-09-24 15:50:29 UTC (rev 22660)
@@ -82,11 +82,22 @@
             NSScriptClassDescription *removeClassDescription = 
[classDescriptions containsObject:[NSNull null]] ? nil : 
[NSScriptClassDescription commonAncestorForClassDescriptions:classDescriptions];
             
             if (containerSpecifier == nil) {
-                id obj = directParameter;
-                if ([obj isKindOfClass:[NSArray class]])
-                    obj = [obj firstObject];
-                if ([obj respondsToSelector:@selector(containerSpecifier)])
-                    containerSpecifier = [obj containerSpecifier];
+                
+                if (containerSpecifier == nil) {
+                    // get it from the subject of the event when it was not 
given
+                    containerSpecifier = [[self appleEvent] objCObjectValue];
+                    if ([containerSpecifier 
isKindOfClass:[NSScriptObjectSpecifier class]] == NO)
+                        containerSpecifier = nil;
+                }
+                
+                if (containerSpecifier == nil) {
+                    // finally, try the container of the objects
+                    id obj = directParameter;
+                    if ([obj isKindOfClass:[NSArray class]])
+                        obj = [obj firstObject];
+                    if ([obj respondsToSelector:@selector(containerSpecifier)])
+                        containerSpecifier = [obj containerSpecifier];
+                }
             }
             
             if ([containerSpecifier isKindOfClass:[NSPropertySpecifier 
class]]) {

Modified: trunk/bibdesk/Scripting/BibDesk.sdef
===================================================================
--- trunk/bibdesk/Scripting/BibDesk.sdef        2018-09-24 06:30:25 UTC (rev 
22659)
+++ trunk/bibdesk/Scripting/BibDesk.sdef        2018-09-24 15:50:29 UTC (rev 
22660)
@@ -444,7 +444,7 @@
                        description="Add items to a collection.">
             <cocoa class="BDSKAddCommand"/>
             <direct-parameter type="any" description="The object(s) to add."/>
-            <parameter name="to" code="insh"
+            <parameter name="to" code="insh" optional="yes"
                 description="The container or location to add the item to.">
                 <cocoa key="ToLocation"/>
                 <type type="specifier"/>

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