Skip to content

Commit

Permalink
• add ‘prototype’ command ("$DIALOG" help prototype)
Browse files Browse the repository at this point in the history
This was previously the ‘--prototype’ argument to ‘nib’ (which is now removed).


git-svn-id: http://svn.textmate.org/trunk/Tools/Dialog@11531 dfb7d73b-c2ec-0310-8fea-fb051d288c6d
  • Loading branch information
sorbits committed May 10, 2009
1 parent 5324278 commit 62c2696
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 23 deletions.
File renamed without changes.
File renamed without changes.
47 changes: 47 additions & 0 deletions Commands/prototype/prototype.mm
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#import "TMDChameleon.h"
#import "../../Dialog2.h"
#import "../../TMDCommand.h"

@interface TMDPrototype : TMDCommand
{
}
@end

@implementation TMDPrototype
+ (void)load
{
[TMDPrototype registerObject:[self new] forCommand:@"prototype"];
}

- (void)handleCommand:(CLIProxy*)proxy
{
NSDictionary* args = [proxy parameters];

if(NSDictionary* values = [args objectForKey:@"register"])
{
// FIXME this is needed only because we presently can’t express argument constraints (CLIProxy would otherwise correctly validate/convert CLI arguments)
if([values isKindOfClass:[NSString class]])
values = [NSPropertyListSerialization propertyListFromData:[(NSString*)values dataUsingEncoding:NSUTF8StringEncoding] mutabilityOption:NSPropertyListImmutable format:nil errorDescription:NULL];

enumerate([values allKeys], id key)
[TMDChameleon createSubclassNamed:key withValues:[values objectForKey:key]];
}

if(NSString* show = [args objectForKey:@"show"])
{
id obj = [[NSClassFromString(show) new] autorelease];
[proxy writeStringToOutput:[obj description] ?: [NSString stringWithFormat:@"error: no class named ‘%@", show]];
[proxy writeStringToOutput:@"\n"];
}
}

- (NSString *)commandDescription
{
return @"Register classes for use with NSArrayController.";
}

- (NSString *)usageForInvocation:(NSString *)invocation;
{
return [NSString stringWithFormat:@"\t%1$@ --register \"{ SQL_New_Connection = { title = untitled; serverType = MySQL; hostName = localhost; userName = '$LOGNAME'; }; }\"\n\t%1$@ --show SQL_New_Connection\n", invocation];
}
@end
16 changes: 2 additions & 14 deletions Commands/window.mm
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#import "../Dialog2.h"
#import "../TMDCommand.h"
#import "../OptionParser.h"
#import "Utilities/TMDChameleon.h"
#import "Utilities/TMDNibController.h"

// ==========
Expand Down Expand Up @@ -72,7 +71,7 @@ + (void)load
"$DIALOG" nib --dispose 1
"$DIALOG" nib --list
"$DIALOG" nib --load "$TM_SUPPORT_PATH/../Bundles/SQL.tmbundle/Support/nibs/connections.nib" --defaults "{'SQL Connections' = ( { title = untitled; serverType = MySQL; hostName = localhost; userName = '$LOGNAME'; } ); }" --prototypes "{ SQL_New_Connection = { title = untitled; serverType = MySQL; hostName = localhost; userName = '$LOGNAME'; }; }"
"$DIALOG" nib --load "$TM_SUPPORT_PATH/../Bundles/SQL.tmbundle/Support/nibs/connections.nib" --defaults "{'SQL Connections' = ( { title = untitled; serverType = MySQL; hostName = localhost; userName = '$LOGNAME'; } ); }"
"$DIALOG" help nib
*/
Expand Down Expand Up @@ -126,16 +125,6 @@ - (void)handleCommand:(CLIProxy*)proxy
}
}

if(NSDictionary* prototypes = [args objectForKey:@"prototypes"])
{
// FIXME this is needed only because we presently can’t express argument constraints (CLIProxy would otherwise correctly validate/convert CLI arguments)
if([prototypes isKindOfClass:[NSString class]])
prototypes = [NSPropertyListSerialization propertyListFromData:[(NSString*)prototypes dataUsingEncoding:NSUTF8StringEncoding] mutabilityOption:NSPropertyListImmutable format:nil errorDescription:NULL];

enumerate([prototypes allKeys], id key)
[TMDChameleon createSubclassNamed:key withValues:[prototypes objectForKey:key]];
}

if(NSString* nibName = [args objectForKey:@"load"])
{
// TODO we should let an option type be ‘filename’ and have CLIProxy resolve these (and error when file does not exist)
Expand Down Expand Up @@ -171,8 +160,7 @@ - (NSString *)usageForInvocation:(NSString *)invocation;
@"%1$@ --list\n"
@"\nOptions:\n"
@"\t--center\n"
@"\t--model «plist»\n"
@"\t--prototypes «plist»\n",
@"\t--model «plist»\n",
invocation];
}
@end
30 changes: 21 additions & 9 deletions Dialog2.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
objects = {

/* Begin PBXBuildFile section */
172138720FB6C8E9001D3EAA /* prototype.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1721386F0FB6C8E9001D3EAA /* prototype.mm */; };
172138730FB6C8E9001D3EAA /* TMDChameleon.mm in Sources */ = {isa = PBXBuildFile; fileRef = 172138710FB6C8E9001D3EAA /* TMDChameleon.mm */; };
175614490EDEA3B80053AC52 /* images.mm in Sources */ = {isa = PBXBuildFile; fileRef = 175614480EDEA3B80053AC52 /* images.mm */; };
1756144D0EDEA96F0053AC52 /* defaults.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1756144C0EDEA96F0053AC52 /* defaults.mm */; };
177E4DA309132A0F0064163D /* Dialog2.mm in Sources */ = {isa = PBXBuildFile; fileRef = 177E4DA209132A0F0064163D /* Dialog2.mm */; };
Expand All @@ -29,7 +31,6 @@
91D6F9710CF2C803000F8170 /* htmltips.mm in Sources */ = {isa = PBXBuildFile; fileRef = 91D6F96E0CF2C803000F8170 /* htmltips.mm */; };
91D6F9730CF2C803000F8170 /* TMDHTMLTips.mm in Sources */ = {isa = PBXBuildFile; fileRef = 91D6F9700CF2C803000F8170 /* TMDHTMLTips.mm */; };
91D6F97E0CF2C8EF000F8170 /* WebKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 91D6F97D0CF2C8EF000F8170 /* WebKit.framework */; };
91D6F9940CF33A7A000F8170 /* TMDChameleon.mm in Sources */ = {isa = PBXBuildFile; fileRef = 91D6F9900CF33A7A000F8170 /* TMDChameleon.mm */; };
91D6F9950CF33A7A000F8170 /* ValueTransformers.mm in Sources */ = {isa = PBXBuildFile; fileRef = 91D6F9920CF33A7A000F8170 /* ValueTransformers.mm */; };
91D6F9960CF33A7A000F8170 /* window.mm in Sources */ = {isa = PBXBuildFile; fileRef = 91D6F9930CF33A7A000F8170 /* window.mm */; };
/* End PBXBuildFile section */
Expand All @@ -49,6 +50,9 @@
089C167EFE841241C02AAC07 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = "<group>"; };
089C167FFE841241C02AAC07 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = "<absolute>"; };
1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = "<absolute>"; };
1721386F0FB6C8E9001D3EAA /* prototype.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = prototype.mm; path = Commands/prototype/prototype.mm; sourceTree = "<group>"; };
172138700FB6C8E9001D3EAA /* TMDChameleon.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TMDChameleon.h; path = Commands/prototype/TMDChameleon.h; sourceTree = "<group>"; };
172138710FB6C8E9001D3EAA /* TMDChameleon.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = TMDChameleon.mm; path = Commands/prototype/TMDChameleon.mm; sourceTree = "<group>"; };
175614480EDEA3B80053AC52 /* images.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = images.mm; path = Commands/images.mm; sourceTree = "<group>"; };
1756144C0EDEA96F0053AC52 /* defaults.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = defaults.mm; path = Commands/defaults.mm; sourceTree = "<group>"; };
177E4DA109132A0F0064163D /* Dialog2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Dialog2.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -79,8 +83,6 @@
91D6F96E0CF2C803000F8170 /* htmltips.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = htmltips.mm; path = Commands/HTMLTips/htmltips.mm; sourceTree = "<group>"; };
91D6F9700CF2C803000F8170 /* TMDHTMLTips.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = TMDHTMLTips.mm; path = Commands/HTMLTips/TMDHTMLTips.mm; sourceTree = "<group>"; };
91D6F97D0CF2C8EF000F8170 /* WebKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WebKit.framework; path = /System/Library/Frameworks/WebKit.framework; sourceTree = "<absolute>"; };
91D6F98F0CF33A7A000F8170 /* TMDChameleon.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TMDChameleon.h; path = Commands/Utilities/TMDChameleon.h; sourceTree = "<group>"; };
91D6F9900CF33A7A000F8170 /* TMDChameleon.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = TMDChameleon.mm; path = Commands/Utilities/TMDChameleon.mm; sourceTree = "<group>"; };
91D6F9910CF33A7A000F8170 /* ValueTransformers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ValueTransformers.h; path = Commands/Utilities/ValueTransformers.h; sourceTree = "<group>"; };
91D6F9920CF33A7A000F8170 /* ValueTransformers.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = ValueTransformers.mm; path = Commands/Utilities/ValueTransformers.mm; sourceTree = "<group>"; };
91D6F9930CF33A7A000F8170 /* window.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = window.mm; path = Commands/window.mm; sourceTree = "<group>"; };
Expand Down Expand Up @@ -169,6 +171,16 @@
name = "Other Frameworks";
sourceTree = "<group>";
};
172138740FB6C8EE001D3EAA /* Prototype */ = {
isa = PBXGroup;
children = (
172138710FB6C8E9001D3EAA /* TMDChameleon.mm */,
172138700FB6C8E9001D3EAA /* TMDChameleon.h */,
1721386F0FB6C8E9001D3EAA /* prototype.mm */,
);
name = Prototype;
sourceTree = "<group>";
};
19C28FB8FE9D52D311CA2CBB /* Products */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -202,15 +214,16 @@
91D6F8FC0CF23E46000F8170 /* Commands */ = {
isa = PBXGroup;
children = (
91D6F94E0CF2BCEC000F8170 /* ExtendedPopUp */,
91D6F9680CF2C7E5000F8170 /* HTMLTips */,
172138740FB6C8EE001D3EAA /* Prototype */,
91D6F95E0CF2BD26000F8170 /* Utilities */,
1756144C0EDEA96F0053AC52 /* defaults.mm */,
175614480EDEA3B80053AC52 /* images.mm */,
91D6F9930CF33A7A000F8170 /* window.mm */,
91D6F94E0CF2BCEC000F8170 /* ExtendedPopUp */,
91D6F9680CF2C7E5000F8170 /* HTMLTips */,
91D6F9040CF23E7F000F8170 /* menu.mm */,
91D6F9010CF23E79000F8170 /* help.mm */,
91D6F8FD0CF23E51000F8170 /* alert.mm */,
91D6F95E0CF2BD26000F8170 /* Utilities */,
91234F950D9A84E900E346BA /* insert.mm */,
);
name = Commands;
Expand All @@ -229,8 +242,6 @@
91D6F95E0CF2BD26000F8170 /* Utilities */ = {
isa = PBXGroup;
children = (
91D6F98F0CF33A7A000F8170 /* TMDChameleon.h */,
91D6F9900CF33A7A000F8170 /* TMDChameleon.mm */,
91D6F9910CF33A7A000F8170 /* ValueTransformers.h */,
91D6F9920CF33A7A000F8170 /* ValueTransformers.mm */,
91D6F9670CF2C2B5000F8170 /* TextMate.h */,
Expand Down Expand Up @@ -351,7 +362,6 @@
91D6F95C0CF2BD16000F8170 /* TMDIncrementalPopUpMenu.mm in Sources */,
91D6F9710CF2C803000F8170 /* htmltips.mm in Sources */,
91D6F9730CF2C803000F8170 /* TMDHTMLTips.mm in Sources */,
91D6F9940CF33A7A000F8170 /* TMDChameleon.mm in Sources */,
91D6F9950CF33A7A000F8170 /* ValueTransformers.mm in Sources */,
91D6F9960CF33A7A000F8170 /* window.mm in Sources */,
9192ECB50CF7AF39003D9967 /* TMDNibController.mm in Sources */,
Expand All @@ -360,6 +370,8 @@
91234F960D9A84E900E346BA /* insert.mm in Sources */,
175614490EDEA3B80053AC52 /* images.mm in Sources */,
1756144D0EDEA96F0053AC52 /* defaults.mm in Sources */,
172138720FB6C8E9001D3EAA /* prototype.mm in Sources */,
172138730FB6C8E9001D3EAA /* TMDChameleon.mm in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down

0 comments on commit 62c2696

Please sign in to comment.