Revision: 22666
http://sourceforge.net/p/bibdesk/svn/22666
Author: hofman
Date: 2018-09-25 15:11:30 +0000 (Tue, 25 Sep 2018)
Log Message:
-----------
script command category to share implementation of subject specifier
Modified Paths:
--------------
trunk/bibdesk/BDSKAddCommand.m
trunk/bibdesk/BDSKRemoveCommand.m
trunk/bibdesk/BDSKSelectCommand.m
trunk/bibdesk/Bibdesk.xcodeproj/project.pbxproj
Added Paths:
-----------
trunk/bibdesk/NSScriptCommand_BDSKExtensions.h
trunk/bibdesk/NSScriptCommand_BDSKExtensions.m
Modified: trunk/bibdesk/BDSKAddCommand.m
===================================================================
--- trunk/bibdesk/BDSKAddCommand.m 2018-09-25 09:14:20 UTC (rev 22665)
+++ trunk/bibdesk/BDSKAddCommand.m 2018-09-25 15:11:30 UTC (rev 22666)
@@ -42,6 +42,7 @@
#import "KFASHandlerAdditions-TypeTranslation.h"
#import "NSScriptClassDescription_BDSKExtensions.h"
#import "NSObject_BDSKExtensions.h"
+#import "NSScriptCommand_BDSKExtensions.h"
@implementation BDSKAddCommand
@@ -92,12 +93,9 @@
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]
attributeDescriptorForKeyword:'subj'] objCObjectValue];
- if ([locationSpecifier isKindOfClass:[NSScriptObjectSpecifier
class]] == NO)
- locationSpecifier = nil;
- }
+ // get it from the subject of the event when it was not given
+ if (locationSpecifier == nil)
+ locationSpecifier = [self subjectSpecifier];
if ([locationSpecifier isKindOfClass:[NSPositionalSpecifier
class]]) {
[locationSpecifier
setInsertionClassDescription:insertionClassDescription];
Modified: trunk/bibdesk/BDSKRemoveCommand.m
===================================================================
--- trunk/bibdesk/BDSKRemoveCommand.m 2018-09-25 09:14:20 UTC (rev 22665)
+++ trunk/bibdesk/BDSKRemoveCommand.m 2018-09-25 15:11:30 UTC (rev 22666)
@@ -41,6 +41,7 @@
#import "NSScriptClassDescription_BDSKExtensions.h"
#import "KFASHandlerAdditions-TypeTranslation.h"
#import "NSObject_BDSKExtensions.h"
+#import "NSScriptCommand_BDSKExtensions.h"
@implementation BDSKRemoveCommand
@@ -92,12 +93,9 @@
if (containerSpecifier == nil) {
- if (containerSpecifier == nil) {
- // get it from the subject of the event when it was not
given
- containerSpecifier = [[[self appleEvent]
attributeDescriptorForKeyword:'subj'] objCObjectValue];
- if ([containerSpecifier
isKindOfClass:[NSScriptObjectSpecifier class]] == NO)
- containerSpecifier = nil;
- }
+ // get it from the subject of the event when it was not given
+ if (containerSpecifier == nil)
+ containerSpecifier = [self subjectSpecifier];
if (containerSpecifier == nil) {
// finally, try the container of the objects
Modified: trunk/bibdesk/BDSKSelectCommand.m
===================================================================
--- trunk/bibdesk/BDSKSelectCommand.m 2018-09-25 09:14:20 UTC (rev 22665)
+++ trunk/bibdesk/BDSKSelectCommand.m 2018-09-25 15:11:30 UTC (rev 22666)
@@ -43,6 +43,7 @@
#import "BDSKGroup.h"
#import "NSArray_BDSKExtensions.h"
#import "KFASHandlerAdditions-TypeTranslation.h"
+#import "NSScriptCommand_BDSKExtensions.h"
@implementation BDSKSelectCommand
@@ -65,9 +66,7 @@
if ([doc isDocument] == NO)
doc = [(id)doc document];
if (doc == nil) {
- id subject = [[[self appleEvent]
attributeDescriptorForKeyword:'subj'] objCObjectValue];
- if ([subject
respondsToSelector:@selector(objectsByEvaluatingSpecifier)])
- doc = [subject objectsByEvaluatingSpecifier];
+ doc = [[self subjectSpecifier] objectsByEvaluatingSpecifier];
if ([doc isKindOfClass:[BibDocument class]] == NO)
doc = (BibDocument *)[[NSApp orderedDocuments] firstObject];
}
Modified: trunk/bibdesk/Bibdesk.xcodeproj/project.pbxproj
===================================================================
--- trunk/bibdesk/Bibdesk.xcodeproj/project.pbxproj 2018-09-25 09:14:20 UTC
(rev 22665)
+++ trunk/bibdesk/Bibdesk.xcodeproj/project.pbxproj 2018-09-25 15:11:30 UTC
(rev 22666)
@@ -88,6 +88,7 @@
CE0B3B3C1292E1A500BA05EB /* BDSKErrorObject.m in Sources */ =
{isa = PBXBuildFile; fileRef = CE0B3B3A1292E1A500BA05EB /* BDSKErrorObject.m
*/; };
CE0C5C7816F37C8E00F53653 /* FieldSheet.xib in Resources */ =
{isa = PBXBuildFile; fileRef = CE0C5C7616F37C8E00F53653 /* FieldSheet.xib */; };
CE0CD73C1459812300488DE1 /* NSAttributedString+Scripting.m in
Sources */ = {isa = PBXBuildFile; fileRef = CE0CD73A1459812300488DE1 /*
NSAttributedString+Scripting.m */; };
+ CE0D24C9215A84F3001A3F47 /* NSScriptCommand_BDSKExtensions.m in
Sources */ = {isa = PBXBuildFile; fileRef = CE0D24C7215A84F3001A3F47 /*
NSScriptCommand_BDSKExtensions.m */; };
CE0EB4440DCFDE8A0034DF92 /* NSInvocation_BDSKExtensions.m in
Sources */ = {isa = PBXBuildFile; fileRef = CE0EB4420DCFDE8A0034DF92 /*
NSInvocation_BDSKExtensions.m */; };
CE0ECDAB0DE78619006EEDDB /* BDSKInspireParser.m in Sources */ =
{isa = PBXBuildFile; fileRef = CE0ECDA90DE78619006EEDDB /* BDSKInspireParser.m
*/; };
CE117D240D7047A5005BFCEB /*
NSScriptClassDescription_BDSKExtensions.m in Sources */ = {isa = PBXBuildFile;
fileRef = CE117D220D7047A4005BFCEB /* NSScriptClassDescription_BDSKExtensions.m
*/; };
@@ -852,6 +853,8 @@
CE0C5D3916F3910500F53653 /* French */ = {isa =
PBXFileReference; lastKnownFileType = file.xib; name = French; path =
French.lproj/FieldSheet.xib; sourceTree = "<group>"; };
CE0CD7391459812300488DE1 /* NSAttributedString+Scripting.h */ =
{isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h;
path = "NSAttributedString+Scripting.h"; sourceTree = "<group>"; };
CE0CD73A1459812300488DE1 /* NSAttributedString+Scripting.m */ =
{isa = PBXFileReference; fileEncoding = 4; lastKnownFileType =
sourcecode.c.objc; path = "NSAttributedString+Scripting.m"; sourceTree =
"<group>"; };
+ CE0D24C6215A84F3001A3F47 /* NSScriptCommand_BDSKExtensions.h */
= {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path =
NSScriptCommand_BDSKExtensions.h; sourceTree = "<group>"; };
+ CE0D24C7215A84F3001A3F47 /* NSScriptCommand_BDSKExtensions.m */
= {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path =
NSScriptCommand_BDSKExtensions.m; sourceTree = "<group>"; };
CE0EB4410DCFDE8A0034DF92 /* NSInvocation_BDSKExtensions.h */ =
{isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h;
path = NSInvocation_BDSKExtensions.h; sourceTree = "<group>"; };
CE0EB4420DCFDE8A0034DF92 /* NSInvocation_BDSKExtensions.m */ =
{isa = PBXFileReference; fileEncoding = 4; lastKnownFileType =
sourcecode.c.objc; path = NSInvocation_BDSKExtensions.m; sourceTree =
"<group>"; };
CE0ECDA80DE78619006EEDDB /* BDSKInspireParser.h */ = {isa =
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path =
BDSKInspireParser.h; sourceTree = "<group>"; };
@@ -2161,6 +2164,7 @@
CEC46E2F1629743200B51A9D /*
NSPasteboard_BDSKExtensions.m */,
CE564D240AECBA5B002F0A24 /*
NSScanner_BDSKExtensions.m */,
CE117D220D7047A4005BFCEB /*
NSScriptClassDescription_BDSKExtensions.m */,
+ CE0D24C7215A84F3001A3F47 /*
NSScriptCommand_BDSKExtensions.m */,
F9022C9F0758038000C3F701 /*
NSString_BDSKExtensions.m */,
F9463F4409436F7500CC4549 /*
NSSet_BDSKExtensions.m */,
F9022C5A075802E300C3F701 /*
NSTask_BDSKExtensions.m */,
@@ -2799,6 +2803,7 @@
CE7611500EA49B6E00301E45 /*
NSPrintOperation_BDSKExtensions.h */,
CE564D230AECBA5B002F0A24 /*
NSScanner_BDSKExtensions.h */,
CE117D210D7047A4005BFCEB /*
NSScriptClassDescription_BDSKExtensions.h */,
+ CE0D24C6215A84F3001A3F47 /*
NSScriptCommand_BDSKExtensions.h */,
CE6C96290CD9014A0022D69F /*
NSScrollView_BDSKExtensions.h */,
F9463F4309436F7500CC4549 /*
NSSet_BDSKExtensions.h */,
CEE7ACE6109E2F360072D63C /*
NSSplitView_BDSKExtensions.h */,
@@ -3442,6 +3447,7 @@
3D866C2908031CEC00FF1724 /*
BDSKCharacterConversion.m in Sources */,
27AFAF9D080D1E1B0096F5D2 /*
BDSKTextImportController.m in Sources */,
3D44F5630812A91D003C67F0 /* BDSKFormatParser.m
in Sources */,
+ CE0D24C9215A84F3001A3F47 /*
NSScriptCommand_BDSKExtensions.m in Sources */,
3D0D76B3084898C100A495A5 /* BibPref_Crossref.m
in Sources */,
3D7406940849F5430081EC6F /*
BDSKTypeNameFormatter.m in Sources */,
F97965F2086909EA00050427 /*
BDSKFindController.m in Sources */,
Added: trunk/bibdesk/NSScriptCommand_BDSKExtensions.h
===================================================================
--- trunk/bibdesk/NSScriptCommand_BDSKExtensions.h
(rev 0)
+++ trunk/bibdesk/NSScriptCommand_BDSKExtensions.h 2018-09-25 15:11:30 UTC
(rev 22666)
@@ -0,0 +1,45 @@
+//
+// NSScriptCommand_BDSKExtensions.h
+// BibDesk
+//
+// Created by Christiaan on 25/09/2018.
+/*
+ This software is Copyright (c) 2018
+ Christiaan Hofman. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+
+ - Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ - Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in
+ the documentation and/or other materials provided with the
+ distribution.
+
+ - Neither the name of Christiaan Hofman nor the names of any
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import <Cocoa/Cocoa.h>
+
+@interface NSScriptCommand (BDSKExtensions)
+
+- (NSScriptObjectSpecifier *)subjectSpecifier;
+
+@end
Added: trunk/bibdesk/NSScriptCommand_BDSKExtensions.m
===================================================================
--- trunk/bibdesk/NSScriptCommand_BDSKExtensions.m
(rev 0)
+++ trunk/bibdesk/NSScriptCommand_BDSKExtensions.m 2018-09-25 15:11:30 UTC
(rev 22666)
@@ -0,0 +1,50 @@
+//
+// NSScriptCommand_BDSKExtensions.m
+// BibDesk
+//
+// Created by Christiaan on 25/09/2018.
+/*
+ This software is Copyright (c) 2018
+ Christiaan Hofman. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+
+ - Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ - Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in
+ the documentation and/or other materials provided with the
+ distribution.
+
+ - Neither the name of Christiaan Hofman nor the names of any
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "NSScriptCommand_BDSKExtensions.h"
+
+@implementation NSScriptCommand (BDSKExtensions)
+
+- (NSScriptObjectSpecifier *)subjectSpecifier {
+ NSAppleEventDescriptor *subjectDescriptor = [[self appleEvent]
attributeDescriptorForKeyword:'subj'];
+ if ([subjectDescriptor descriptorType] == typeObjectSpecifier)
+ return [NSScriptObjectSpecifier
objectSpecifierWithDescriptor:subjectDescriptor];
+ return nil;
+}
+
+@end
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