Changeset 264
- Timestamp:
- 11/18/07 13:42:49 (1 year ago)
- Files:
-
- trunk/cocoa/mogenerator/Xmod/Xmod.h (modified) (1 diff)
- trunk/cocoa/mogenerator/Xmod/Xmod.m (modified) (5 diffs)
- trunk/cocoa/mogenerator/Xmod/Xmod.xcodeproj/wolf.mode1 (modified) (14 diffs)
- trunk/cocoa/mogenerator/Xmod/Xmod.xcodeproj/wolf.pbxuser (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/cocoa/mogenerator/Xmod/Xmod.h
r250 r264 2 2 #import <objc/objc-class.h> 3 3 4 @interface Xmod : NSObject {} 4 @interface Xmod : NSObject { 5 NSBundle *bundle; 6 } 7 + (id)sharedXmod; 8 - (id)initWithBundle:(NSBundle*)bundle_; 5 9 - (IBAction)autocustomizeEntityClasses:(id)sender_; 10 - (void)runScriptNamed:(NSString*)scriptName_; 6 11 @end trunk/cocoa/mogenerator/Xmod/Xmod.m
r263 r264 1 1 #import "Xmod.h" 2 2 #import "MethodSwizzle.h" 3 4 NSBundle *selfBundle;5 6 static void runScriptNamed(NSString *scriptName) {7 NSString *scriptPath = [selfBundle pathForResource:scriptName ofType:@"scpt" inDirectory:@"Scripts"];8 NSCAssert1(scriptPath, @"failed to find %@.scpt", scriptName);9 NSDictionary *scriptInitError = nil;10 NSAppleScript *script = [[[NSAppleScript alloc] initWithContentsOfURL:[NSURL fileURLWithPath:scriptPath]11 error:&scriptInitError] autorelease];12 NSCAssert2(!scriptInitError, @"failed to init %@.scpt: %@", scriptName, scriptInitError);13 if (!scriptInitError) {14 NSDictionary *scriptExecuteError = nil;15 [script executeAndReturnError:&scriptExecuteError];16 NSCAssert2(!scriptInitError, @"failed to execute %@.scpt: %@", scriptName, scriptExecuteError);17 }18 }19 3 20 4 @interface NSObject (xmod_saveModelToFile) … … 23 7 - (BOOL)xmod_saveModelToFile:(NSString*)modelPackagePath_ { 24 8 BOOL result = [self xmod_saveModelToFile:modelPackagePath_]; 25 if (result) { 26 runScriptNamed(@"Xmod"); 27 } 9 if (result) 10 [[Xmod sharedXmod] performSelector:@selector(runScriptNamed:) withObject:@"Xmod" afterDelay:0.0]; 28 11 return result; 29 12 } … … 32 15 @implementation Xmod 33 16 17 Xmod *gSharedXmod; 18 34 19 + (void)pluginDidLoad:(NSBundle*)bundle_ { 35 selfBundle = bundle_; 36 [[self alloc] init]; 20 gSharedXmod = [[self alloc] initWithBundle:bundle_]; 21 } 22 23 + (id)sharedXmod { 24 return gSharedXmod; 25 } 26 27 - (id)initWithBundle:(NSBundle*)bundle_ { 28 self = [super init]; 29 if (self) { 30 bundle = [bundle_ retain]; 31 [[NSNotificationCenter defaultCenter] addObserver:self 32 selector:@selector(applicationDidFinishLaunching:) 33 name:NSApplicationDidFinishLaunchingNotification 34 object:nil]; 35 } 36 return self; 37 } 38 39 - (void)applicationDidFinishLaunching:(NSNotification*)notification_ { 40 // Force loading of the Core Data XDesign plugin so we can find the class to swizzle its instance method. 41 NSBundle *coreDataPlugin = nil; 37 42 38 // Force loading of the Core Data XDesign plugin so we can find the class to swizzle its instance method. 39 #define Xcode24_XDCoreDataModelPlugin @"/Library/Application Support/Apple/Developer Tools/Plug-ins/XDCoreDataModel.xdplugin" 40 #define Xcode25_XDCoreDataModelPlugin @"/Xcode2.5/Library/Xcode/Plug-ins/XDCoreDataModel.xdplugin" 41 42 NSBundle *coreDataPlugin = nil; 43 if ([[NSFileManager defaultManager] fileExistsAtPath:Xcode25_XDCoreDataModelPlugin]) { 44 coreDataPlugin = [NSBundle bundleWithPath:Xcode25_XDCoreDataModelPlugin]; 43 NSString *xcodeVersion = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]; 44 NSAssert(xcodeVersion, @"failed to read Xcode version"); 45 if ([xcodeVersion isEqualToString:@"2.4"]) { 46 coreDataPlugin = [NSBundle bundleWithPath:@"/Library/Application Support/Apple/Developer Tools/Plug-ins/XDCoreDataModel.xdplugin"]; 47 } else if ([xcodeVersion isEqualToString:@"2.5"]) { 48 coreDataPlugin = [NSBundle bundleWithPath:@"/Xcode2.5/Library/Xcode/Plug-ins/XDCoreDataModel.xdplugin"]; 45 49 } else { 46 coreDataPlugin = [NSBundle bundleWithPath:Xcode24_XDCoreDataModelPlugin]; 47 } 50 // Unknown territory, exit. 51 return; 52 } 48 53 NSAssert(coreDataPlugin, @"failed to load XDCoreDataModel.xdplugin"); 49 54 [coreDataPlugin load]; … … 56 61 @selector(xmod_saveModelToFile:)); 57 62 NSAssert(swizzled, @"failed to swizzle -[XDPersistenceDocumentController saveModelToFile:]"); 58 } 59 60 - (id)init { 61 self = [super init]; 62 if (self) { 63 [[NSNotificationCenter defaultCenter] addObserver:self 64 selector:@selector(applicationDidFinishLaunching:) 65 name:NSApplicationDidFinishLaunchingNotification 66 object:nil]; 67 } 68 return self; 69 } 70 71 - (void)applicationDidFinishLaunching:(NSNotification*)notification_ { 63 64 // Install the Autocustomize menu item. 72 65 NSMenu *designMenu = [[[NSApp mainMenu] itemWithTitle:@"Design"] submenu]; 73 66 NSMenu *dataModelMenu = [[designMenu itemWithTitle:@"Data Model"] submenu]; … … 81 74 82 75 - (IBAction)autocustomizeEntityClasses:(id)sender_ { 83 runScriptNamed(@"Autocustomize Entity Classes"); 76 [self runScriptNamed:@"Autocustomize Entity Classes"]; 77 } 78 79 - (void)runScriptNamed:(NSString*)scriptName_ { 80 NSString *scriptPath = [bundle pathForResource:scriptName_ ofType:@"scpt" inDirectory:@"Scripts"]; 81 NSAssert1(scriptPath, @"failed to find %@.scpt", scriptName_); 82 NSDictionary *scriptInitError = nil; 83 NSAppleScript *script = [[[NSAppleScript alloc] initWithContentsOfURL:[NSURL fileURLWithPath:scriptPath] 84 error:&scriptInitError] autorelease]; 85 NSAssert2(!scriptInitError, @"failed to init %@.scpt: %@", scriptName_, scriptInitError); 86 if (!scriptInitError) { 87 NSDictionary *scriptExecuteError = nil; 88 [script executeAndReturnError:&scriptExecuteError]; 89 NSAssert2(!scriptInitError, @"failed to execute %@.scpt: %@", scriptName_, scriptExecuteError); 90 } 84 91 } 85 92 trunk/cocoa/mogenerator/Xmod/Xmod.xcodeproj/wolf.mode1
r250 r264 1 1 <?xml version="1.0" encoding="UTF-8"?> 2 <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">2 <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> 3 3 <plist version="1.0"> 4 4 <dict> … … 186 186 <array/> 187 187 <key>OpenEditors</key> 188 <array/> 188 <array> 189 <dict> 190 <key>Content</key> 191 <dict> 192 <key>PBXProjectModuleGUID</key> 193 <string>7907BA1F0CED0E23003A8BA0</string> 194 <key>PBXProjectModuleLabel</key> 195 <string>Xmod.m</string> 196 <key>PBXSplitModuleInNavigatorKey</key> 197 <dict> 198 <key>Split0</key> 199 <dict> 200 <key>PBXProjectModuleGUID</key> 201 <string>7907BA200CED0E23003A8BA0</string> 202 <key>PBXProjectModuleLabel</key> 203 <string>Xmod.m</string> 204 <key>_historyCapacity</key> 205 <integer>0</integer> 206 <key>bookmark</key> 207 <string>794C2E670CF0CA330003EC27</string> 208 <key>history</key> 209 <array> 210 <string>79A7D2BE0CF0C56F00193A80</string> 211 </array> 212 </dict> 213 <key>SplitCount</key> 214 <string>1</string> 215 </dict> 216 <key>StatusBarVisibility</key> 217 <true/> 218 </dict> 219 <key>Geometry</key> 220 <dict> 221 <key>Frame</key> 222 <string>{{0, 20}, {921, 831}}</string> 223 <key>PBXModuleWindowStatusBarHidden2</key> 224 <false/> 225 <key>RubberWindowFrame</key> 226 <string>396 144 921 872 0 0 1680 1028 </string> 227 </dict> 228 </dict> 229 <dict> 230 <key>Content</key> 231 <dict> 232 <key>PBXProjectModuleGUID</key> 233 <string>798EFBDB0CF0B4980090D926</string> 234 <key>PBXProjectModuleLabel</key> 235 <string>Xmod.h</string> 236 <key>PBXSplitModuleInNavigatorKey</key> 237 <dict> 238 <key>Split0</key> 239 <dict> 240 <key>PBXProjectModuleGUID</key> 241 <string>798EFBDC0CF0B4980090D926</string> 242 <key>PBXProjectModuleLabel</key> 243 <string>Xmod.h</string> 244 <key>_historyCapacity</key> 245 <integer>0</integer> 246 <key>bookmark</key> 247 <string>794C2E680CF0CA330003EC27</string> 248 <key>history</key> 249 <array> 250 <string>794C2E520CF0CA070003EC27</string> 251 </array> 252 </dict> 253 <key>SplitCount</key> 254 <string>1</string> 255 </dict> 256 <key>StatusBarVisibility</key> 257 <true/> 258 </dict> 259 <key>Geometry</key> 260 <dict> 261 <key>Frame</key> 262 <string>{{0, 20}, {743, 597}}</string> 263 <key>PBXModuleWindowStatusBarHidden2</key> 264 <false/> 265 <key>RubberWindowFrame</key> 266 <string>896 377 743 638 0 0 1680 1028 </string> 267 </dict> 268 </dict> 269 </array> 189 270 <key>PerspectiveWidths</key> 190 271 <array> … … 199 280 <string>active-target-popup</string> 200 281 <string>active-buildstyle-popup</string> 282 <string>action</string> 201 283 <string>NSToolbarFlexibleSpaceItem</string> 202 284 <string>buildOrClean</string> … … 259 341 <string>08FB77AFFE84173DC02AAC07</string> 260 342 <string>089C167CFE841241C02AAC07</string> 343 <string>19C28FB8FE9D52D311CA2CBB</string> 261 344 <string>1C37FBAC04509CD000000102</string> 262 345 <string>1C37FABC05509CD000000102</string> … … 265 348 <array> 266 349 <array> 267 <integer>1 1</integer>268 <integer> 7</integer>350 <integer>14</integer> 351 <integer>13</integer> 269 352 <integer>0</integer> 270 353 </array> … … 290 373 </array> 291 374 <key>RubberWindowFrame</key> 292 <string> 1107 1061 853 471 0 0 2560 1578 </string>375 <string>536 535 853 471 0 0 1680 1028 </string> 293 376 </dict> 294 377 <key>Module</key> … … 327 410 <string>{{0, 0}, {645, 0}}</string> 328 411 <key>RubberWindowFrame</key> 329 <string> 1107 1061 853 471 0 0 2560 1578 </string>412 <string>536 535 853 471 0 0 1680 1028 </string> 330 413 </dict> 331 414 <key>Module</key> … … 347 430 <string>{{0, 5}, {645, 425}}</string> 348 431 <key>RubberWindowFrame</key> 349 <string> 1107 1061 853 471 0 0 2560 1578 </string>432 <string>536 535 853 471 0 0 1680 1028 </string> 350 433 </dict> 351 434 <key>Module</key> … … 371 454 <key>TableOfContents</key> 372 455 <array> 373 <string>79 88A27E0C8FF1B00098F17A</string>456 <string>794C2E4B0CF0C61A0003EC27</string> 374 457 <string>1CE0B1FE06471DED0097A5F4</string> 375 <string>79 88A27F0C8FF1B00098F17A</string>458 <string>794C2E4C0CF0C61A0003EC27</string> 376 459 <string>1CE0B20306471E060097A5F4</string> 377 460 <string>1CE0B20506471E060097A5F4</string> … … 508 591 <array> 509 592 <string>79DFC1390B59BFE80056C80E</string> 593 <string>798EFBDB0CF0B4980090D926</string> 594 <string>7907BA1F0CED0E23003A8BA0</string> 510 595 <string>/Users/wolf/code/sf/redshed/cocoa/mogenerator/Xmod/Xmod.xcodeproj</string> 511 596 </array> 512 597 <key>WindowString</key> 513 <string> 1107 1061 853 471 0 0 2560 1578 </string>598 <string>536 535 853 471 0 0 1680 1028 </string> 514 599 <key>WindowTools</key> 515 600 <array> … … 541 626 <string>{{0, 0}, {500, 218}}</string> 542 627 <key>RubberWindowFrame</key> 543 <string> 63 1019 500 500 0 0 2560 1578 </string>628 <string>36 501 500 500 0 0 1680 1028 </string> 544 629 </dict> 545 630 <key>Module</key> … … 565 650 <string>{{0, 223}, {500, 236}}</string> 566 651 <key>RubberWindowFrame</key> 567 <string> 63 1019 500 500 0 0 2560 1578 </string>652 <string>36 501 500 500 0 0 1680 1028 </string> 568 653 </dict> 569 654 <key>Module</key> … … 588 673 <array> 589 674 <string>79DFC1390B59BFE80056C80E</string> 590 <string>79 88A2800C8FF1B00098F17A</string>675 <string>794C2E540CF0CA070003EC27</string> 591 676 <string>1CD0528F0623707200166675</string> 592 677 <string>XCMainBuildResultsModuleGUID</string> … … 595 680 <string>xcode.toolbar.config.build</string> 596 681 <key>WindowString</key> 597 <string> 63 1019 500 500 0 0 2560 1578 </string>682 <string>36 501 500 500 0 0 1680 1028 </string> 598 683 <key>WindowToolGUID</key> 599 684 <string>79DFC1390B59BFE80056C80E</string> trunk/cocoa/mogenerator/Xmod/Xmod.xcodeproj/wolf.pbxuser
r250 r264 77 77 ); 78 78 }; 79 PBXPerProjectTemplateStateSaveDate = 210759999; 80 PBXWorkspaceStateSaveDate = 210759999; 79 PBXPerProjectTemplateStateSaveDate = 217105925; 80 PBXWorkspaceStateSaveDate = 217105925; 81 }; 82 perUserProjectItems = { 83 794C2E520CF0CA070003EC27 /* PBXTextBookmark */ = 794C2E520CF0CA070003EC27 /* PBXTextBookmark */; 84 794C2E670CF0CA330003EC27 /* PBXTextBookmark */ = 794C2E670CF0CA330003EC27 /* PBXTextBookmark */; 85 794C2E680CF0CA330003EC27 /* PBXTextBookmark */ = 794C2E680CF0CA330003EC27 /* PBXTextBookmark */; 86 79A7D2BE0CF0C56F00193A80 /* PBXTextBookmark */ = 79A7D2BE0CF0C56F00193A80 /* PBXTextBookmark */; 81 87 }; 82 88 sourceControlManager = 79DFC1170B59B8870056C80E /* Source Control */; 83 89 userBuildSettings = { 84 90 }; 91 }; 92 794C2E520CF0CA070003EC27 /* PBXTextBookmark */ = { 93 isa = PBXTextBookmark; 94 fRef = 79DFC11D0B59B8C80056C80E /* Xmod.h */; 95 name = "+ (id)sharedXmod;"; 96 rLen = 17; 97 rLoc = 103; 98 rType = 0; 99 vrLen = 265; 100 vrLoc = 0; 101 }; 102 794C2E670CF0CA330003EC27 /* PBXTextBookmark */ = { 103 isa = PBXTextBookmark; 104 fRef = 79DFC11E0B59B8C80056C80E /* Xmod.m */; 105 name = "Xmod.m: 1"; 106 rLen = 0; 107 rLoc = 0; 108 rType = 0; 109 vrLen = 1983; 110 vrLoc = 0; 111 }; 112 794C2E680CF0CA330003EC27 /* PBXTextBookmark */ = { 113 isa = PBXTextBookmark; 114 fRef = 79DFC11D0B59B8C80056C80E /* Xmod.h */; 115 name = "+ (id)sharedXmod;"; 116 rLen = 17; 117 rLoc = 103; 118 rType = 0; 119 vrLen = 265; 120 vrLoc = 0; 121 }; 122 79A7D2BE0CF0C56F00193A80 /* PBXTextBookmark */ = { 123 isa = PBXTextBookmark; 124 fRef = 79DFC11E0B59B8C80056C80E /* Xmod.m */; 125 name = "Xmod.m: 51"; 126 rLen = 0; 127 rLoc = 1767; 128 rType = 0; 129 vrLen = 2211; 130 vrLoc = 1164; 85 131 }; 86 132 79D150FA0C8FBDE9006706AF /* Xmod.applescript */ = { … … 106 152 79DFC11D0B59B8C80056C80E /* Xmod.h */ = { 107 153 uiCtxt = { 108 sepNavIntBoundsRect = "{{0, 0}, { 1261, 667}}";109 sepNavSelRange = "{1 34, 0}";110 sepNavVisRect = "{{0, 0}, { 1261, 667}}";111 sepNavWindowFrame = "{{ 751, 476}, {1300, 725}}";154 sepNavIntBoundsRect = "{{0, 0}, {704, 565}}"; 155 sepNavSelRange = "{103, 17}"; 156 sepNavVisRect = "{{0, 0}, {704, 565}}"; 157 sepNavWindowFrame = "{{896, 345}, {743, 670}}"; 112 158 }; 113 159 }; 114 160 79DFC11E0B59B8C80056C80E /* Xmod.m */ = { 115 161 uiCtxt = { 116 sepNavIntBoundsRect = "{{0, 0}, { 1186, 1106}}";162 sepNavIntBoundsRect = "{{0, 0}, {882, 1316}}"; 117 163 sepNavSelRange = "{0, 0}"; 118 sepNavVisRect = "{{0, 0}, { 1186, 856}}";119 sepNavWindowFrame = "{{ 1120, 289}, {1225, 914}}";164 sepNavVisRect = "{{0, 0}, {882, 799}}"; 165 sepNavWindowFrame = "{{396, 112}, {921, 904}}"; 120 166 }; 121 167 };
