Changeset 250

Show
Ignore:
Timestamp:
09/06/07 03:30:36 (1 year ago)
Author:
rentzsch
Message:

[NEW] Xmo'd: Autocustomize Entity Classes Xcode 2.x menu item.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/cocoa/mogenerator/Xmod/Autocustomize Entity Classes.applescript

    r248 r250  
    77                error "Please open an .xcdatamodel file and re-run the script." 
    88        tell item 1 of (every data model document whose path is mainWindowFilePath) 
    9                 using terms from application "Finder" 
     9                (*using terms from application "Finder" 
    1010                        display alert "Autocustomize Entity Classes" message "Automatically customize all generic entity classes based on their names? (This is undoable.)" buttons {"Cancel", "Auto-customize"} cancel button 1 
    1111                end using terms from 
    12                 if button returned of result is "Auto-customize" then 
    13                        repeat with entityIt in (every entity) 
    14                                set object class of entityIt to name of entityIt & "MO" 
    15                        end repeat 
    16                 end if 
     12                if button returned of result is "Auto-customize" then*) 
     13                repeat with entityIt in (every entity) 
     14                        set object class of entityIt to name of entityIt & "MO" 
     15                end repeat 
     16                --end if 
    1717        end tell 
    1818end tell 
  • trunk/cocoa/mogenerator/Xmod/Xmod.h

    r207 r250  
    11#import <Cocoa/Cocoa.h> 
     2#import <objc/objc-class.h> 
    23 
    34@interface Xmod : NSObject {} 
     5- (IBAction)autocustomizeEntityClasses:(id)sender_; 
    46@end 
  • trunk/cocoa/mogenerator/Xmod/Xmod.m

    r249 r250  
    44NSBundle *selfBundle; 
    55 
     6static 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 
    620@interface NSObject (xmod_saveModelToFile) 
    721@end 
    822@implementation NSObject (xmod_saveModelToFile) 
    9  
    1023- (BOOL)xmod_saveModelToFile:(NSString*)modelPackagePath_ { 
    1124        BOOL result = [self xmod_saveModelToFile:modelPackagePath_]; 
    1225        if (result) { 
    13                 NSString *scriptPath = [selfBundle pathForResource:@"Xmod" ofType:@"scpt" inDirectory:@"Scripts"]; 
    14                 NSAssert(scriptPath, @"failed to find Xmod.scpt"); 
    15                 NSDictionary *scriptInitError = nil; 
    16                 NSAppleScript *script = [[[NSAppleScript alloc] initWithContentsOfURL:[NSURL fileURLWithPath:scriptPath] 
    17                                                                                                                                                 error:&scriptInitError] autorelease]; 
    18                 NSAssert1(!scriptInitError, @"failed to init Xmod.scpt: %@", scriptInitError); 
    19                 if (!scriptInitError) { 
    20                         NSDictionary *scriptExecuteError = nil; 
    21                         [script executeAndReturnError:&scriptExecuteError]; 
    22                         NSAssert1(!scriptInitError, @"failed to execute Xmod.scpt: %@", scriptExecuteError); 
    23                 } 
     26                runScriptNamed(@"Xmod"); 
    2427        } 
    2528        return result; 
    2629} 
    27  
    2830@end 
    2931 
     
    3234+ (void)pluginDidLoad:(NSBundle*)bundle_ { 
    3335        selfBundle = bundle_; 
     36        [[self alloc] init]; 
    3437         
    3538        //      Force loading of the Core Data XDesign plugin so we can find the class to swizzle its instance method. 
     
    4750} 
    4851 
     52- (id)init { 
     53        self = [super init]; 
     54        if (self) { 
     55                [[NSNotificationCenter defaultCenter] addObserver:self 
     56                                                                                                 selector:@selector(applicationDidFinishLaunching:) 
     57                                                                                                         name:NSApplicationDidFinishLaunchingNotification 
     58                                                                                                   object:nil]; 
     59        } 
     60        return self; 
     61} 
     62 
     63- (void)applicationDidFinishLaunching:(NSNotification*)notification_ { 
     64        NSMenu *designMenu = [[[NSApp mainMenu] itemWithTitle:@"Design"] submenu]; 
     65        NSMenu *dataModelMenu = [[designMenu itemWithTitle:@"Data Model"] submenu]; 
     66         
     67        NSMenuItem *myMenuItem = [dataModelMenu insertItemWithTitle:@"Autocustomize Entity Classes" 
     68                                                                                                                 action:@selector(autocustomizeEntityClasses:) 
     69                                                                                                  keyEquivalent:@"" 
     70                                                                                                                atIndex:0]; 
     71        [myMenuItem setTarget:self]; 
     72} 
     73 
     74- (IBAction)autocustomizeEntityClasses:(id)sender_ { 
     75        runScriptNamed(@"Autocustomize Entity Classes"); 
     76} 
     77 
    4978@end 
  • trunk/cocoa/mogenerator/Xmod/Xmod.xcodeproj/project.pbxproj

    r249 r250  
    1414                        files = ( 
    1515                                79D150FE0C8FBE01006706AF /* Xmod.applescript in AppleScript */, 
     16                                79F8A9C30C8FF06700082291 /* Autocustomize Entity Classes.applescript in AppleScript */, 
    1617                        ); 
    1718                        isSharedContext = 0; 
     
    2425                79DFC11F0B59B8C80056C80E /* Xmod.m in Sources */ = {isa = PBXBuildFile; fileRef = 79DFC11E0B59B8C80056C80E /* Xmod.m */; }; 
    2526                79DFC1290B59BFD60056C80E /* MethodSwizzle.m in Sources */ = {isa = PBXBuildFile; fileRef = 79DFC1280B59BFD60056C80E /* MethodSwizzle.m */; }; 
     27                79F8A9C30C8FF06700082291 /* Autocustomize Entity Classes.applescript in AppleScript */ = {isa = PBXBuildFile; fileRef = 79F8A9C20C8FF06600082291 /* Autocustomize Entity Classes.applescript */; settings = {ATTRIBUTES = (Debug, ); }; }; 
    2628                8D5B49B0048680CD000E48DA /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C167DFE841241C02AAC07 /* InfoPlist.strings */; }; 
    2729                8D5B49B4048680CD000E48DA /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */; }; 
     
    3941                79DFC1270B59BFD60056C80E /* MethodSwizzle.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = MethodSwizzle.h; sourceTree = "<group>"; }; 
    4042                79DFC1280B59BFD60056C80E /* MethodSwizzle.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = MethodSwizzle.m; sourceTree = "<group>"; }; 
     43                79F8A9C20C8FF06600082291 /* Autocustomize Entity Classes.applescript */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.applescript; path = "Autocustomize Entity Classes.applescript"; sourceTree = "<group>"; }; 
    4144                8D5B49B6048680CD000E48DA /* Xmod.pbplugin */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = Xmod.pbplugin; sourceTree = BUILT_PRODUCTS_DIR; }; 
    4245                8D5B49B7048680CD000E48DA /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = Info.plist; sourceTree = "<group>"; }; 
     
    8386                                089C167DFE841241C02AAC07 /* InfoPlist.strings */, 
    8487                                79D150FA0C8FBDE9006706AF /* Xmod.applescript */, 
     88                                79F8A9C20C8FF06600082291 /* Autocustomize Entity Classes.applescript */, 
    8589                        ); 
    8690                        name = Resources; 
  • trunk/cocoa/mogenerator/Xmod/Xmod.xcodeproj/wolf.mode1

    r249 r250  
    186186        <array/> 
    187187        <key>OpenEditors</key> 
    188         <array> 
    189                 <dict> 
    190                         <key>Content</key> 
    191                         <dict> 
    192                                 <key>PBXProjectModuleGUID</key> 
    193                                 <string>799F3CE50C8FC14900E2007D</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>799F3CE60C8FC14900E2007D</string> 
    202                                                 <key>PBXProjectModuleLabel</key> 
    203                                                 <string>Xmod.m</string> 
    204                                                 <key>_historyCapacity</key> 
    205                                                 <integer>0</integer> 
    206                                                 <key>bookmark</key> 
    207                                                 <string>79C011900C8FC56D00E87B35</string> 
    208                                                 <key>history</key> 
    209                                                 <array> 
    210                                                         <string>79C0118F0C8FC56D00E87B35</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}, {762, 944}}</string> 
    223                                 <key>PBXModuleWindowStatusBarHidden2</key> 
    224                                 <false/> 
    225                                 <key>RubberWindowFrame</key> 
    226                                 <string>1501 193 762 985 0 0 2560 1578 </string> 
    227                         </dict> 
    228                 </dict> 
    229                 <dict> 
    230                         <key>Content</key> 
    231                         <dict> 
    232                                 <key>PBXProjectModuleGUID</key> 
    233                                 <string>79C011910C8FC56D00E87B35</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>79C011920C8FC56D00E87B35</string> 
    242                                                 <key>PBXProjectModuleLabel</key> 
    243                                                 <string>Xmod.h</string> 
    244                                                 <key>_historyCapacity</key> 
    245                                                 <integer>0</integer> 
    246                                                 <key>bookmark</key> 
    247                                                 <string>79C011940C8FC56D00E87B35</string> 
    248                                                 <key>history</key> 
    249                                                 <array> 
    250                                                         <string>79C011930C8FC56D00E87B35</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}, {762, 944}}</string> 
    263                                 <key>PBXModuleWindowStatusBarHidden2</key> 
    264                                 <false/> 
    265                                 <key>RubberWindowFrame</key> 
    266                                 <string>1441 274 762 985 0 0 2560 1578 </string> 
    267                         </dict> 
    268                 </dict> 
    269         </array> 
     188        <array/> 
    270189        <key>PerspectiveWidths</key> 
    271190        <array> 
     
    341260                                                                <string>089C167CFE841241C02AAC07</string> 
    342261                                                                <string>1C37FBAC04509CD000000102</string> 
    343                                                                 <string>79C0118C0C8FC56D00E87B35</string> 
    344262                                                                <string>1C37FABC05509CD000000102</string> 
    345263                                                        </array> 
     
    347265                                                        <array> 
    348266                                                                <array> 
    349                                                                         <integer>3</integer> 
    350                                                                         <integer>1</integer> 
     267                                                                        <integer>11</integer> 
     268                                                                        <integer>7</integer> 
    351269                                                                        <integer>0</integer> 
    352270                                                                </array> 
    353271                                                        </array> 
    354272                                                        <key>PBXSmartGroupTreeModuleOutlineStateVisibleRectKey</key> 
    355                                                         <string>{{0, 0}, {186, 532}}</string> 
     273                                                        <string>{{0, 0}, {186, 412}}</string> 
    356274                                                </dict> 
    357275                                                <key>PBXTopSmartGroupGIDs</key> 
     
    365283                                        <dict> 
    366284                                                <key>Frame</key> 
    367                                                 <string>{{0, 0}, {203, 550}}</string> 
     285                                                <string>{{0, 0}, {203, 430}}</string> 
    368286                                                <key>GroupTreeTableConfiguration</key> 
    369287                                                <array> 
     
    372290                                                </array> 
    373291                                                <key>RubberWindowFrame</key> 
    374                                                 <string>1216 946 921 591 0 0 2560 1578 </string> 
     292                                                <string>1107 1061 853 471 0 0 2560 1578 </string> 
    375293                                        </dict> 
    376294                                        <key>Module</key> 
     
    407325                                                        <dict> 
    408326                                                                <key>Frame</key> 
    409                                                                 <string>{{0, 0}, {713, 0}}</string> 
     327                                                                <string>{{0, 0}, {645, 0}}</string> 
    410328                                                                <key>RubberWindowFrame</key> 
    411                                                                 <string>1216 946 921 591 0 0 2560 1578 </string> 
     329                                                                <string>1107 1061 853 471 0 0 2560 1578 </string> 
    412330                                                        </dict> 
    413331                                                        <key>Module</key> 
     
    427345                                                        <dict> 
    428346                                                                <key>Frame</key> 
    429                                                                 <string>{{0, 5}, {713, 545}}</string> 
     347                                                                <string>{{0, 5}, {645, 425}}</string> 
    430348                                                                <key>RubberWindowFrame</key> 
    431                                                                 <string>1216 946 921 591 0 0 2560 1578 </string> 
     349                                                                <string>1107 1061 853 471 0 0 2560 1578 </string> 
    432350                                                        </dict> 
    433351                                                        <key>Module</key> 
    434352                                                        <string>XCDetailModule</string> 
    435353                                                        <key>Proportion</key> 
    436                                                         <string>545pt</string> 
     354                                                        <string>425pt</string> 
    437355                                                </dict> 
    438356                                        </array> 
    439357                                        <key>Proportion</key> 
    440                                         <string>713pt</string> 
     358                                        <string>645pt</string> 
    441359                                </dict> 
    442360                        </array> 
     
    453371                        <key>TableOfContents</key> 
    454372                        <array> 
    455                                 <string>79C0118D0C8FC56D00E87B35</string> 
     373                                <string>7988A27E0C8FF1B00098F17A</string> 
    456374                                <string>1CE0B1FE06471DED0097A5F4</string> 
    457                                 <string>79C0118E0C8FC56D00E87B35</string> 
     375                                <string>7988A27F0C8FF1B00098F17A</string> 
    458376                                <string>1CE0B20306471E060097A5F4</string> 
    459377                                <string>1CE0B20506471E060097A5F4</string> 
     
    591509                <string>79DFC1390B59BFE80056C80E</string> 
    592510                <string>/Users/wolf/code/sf/redshed/cocoa/mogenerator/Xmod/Xmod.xcodeproj</string> 
    593                 <string>79C011910C8FC56D00E87B35</string> 
    594                 <string>799F3CE50C8FC14900E2007D</string> 
    595511        </array> 
    596512        <key>WindowString</key> 
    597         <string>1216 946 921 591 0 0 2560 1578 </string> 
     513        <string>1107 1061 853 471 0 0 2560 1578 </string> 
    598514        <key>WindowTools</key> 
    599515        <array> 
     
    672588                        <array> 
    673589                                <string>79DFC1390B59BFE80056C80E</string> 
    674                                 <string>79C011950C8FC56D00E87B35</string> 
     590                                <string>7988A2800C8FF1B00098F17A</string> 
    675591                                <string>1CD0528F0623707200166675</string> 
    676592                                <string>XCMainBuildResultsModuleGUID</string> 
  • trunk/cocoa/mogenerator/Xmod/Xmod.xcodeproj/wolf.pbxuser

    r249 r250  
    1414                                PBXFileTableDataSourceColumnWidthsKey = ( 
    1515                                        20, 
    16                                         474
     16                                        406
    1717                                        20, 
    1818                                        48, 
     
    7777                                ); 
    7878                        }; 
    79                         PBXPerProjectTemplateStateSaveDate = 210749283; 
    80                         PBXWorkspaceStateSaveDate = 210749283; 
    81                 }; 
    82                 perUserProjectItems = { 
    83                         79C0118F0C8FC56D00E87B35 = 79C0118F0C8FC56D00E87B35 /* PBXTextBookmark */; 
    84                         79C011900C8FC56D00E87B35 = 79C011900C8FC56D00E87B35 /* PBXTextBookmark */; 
    85                         79C011930C8FC56D00E87B35 = 79C011930C8FC56D00E87B35 /* PBXTextBookmark */; 
    86                         79C011940C8FC56D00E87B35 = 79C011940C8FC56D00E87B35 /* PBXTextBookmark */; 
     79                        PBXPerProjectTemplateStateSaveDate = 210759999; 
     80                        PBXWorkspaceStateSaveDate = 210759999; 
    8781                }; 
    8882                sourceControlManager = 79DFC1170B59B8870056C80E /* Source Control */; 
    8983                userBuildSettings = { 
    9084                }; 
    91         }; 
    92         79C0118F0C8FC56D00E87B35 /* PBXTextBookmark */ = { 
    93                 isa = PBXTextBookmark; 
    94                 fRef = 79DFC11E0B59B8C80056C80E /* Xmod.m */; 
    95                 name = "Xmod.m: 4"; 
    96                 rLen = 0; 
    97                 rLoc = 65; 
    98                 rType = 0; 
    99                 vrLen = 2613; 
    100                 vrLoc = 0; 
    101         }; 
    102         79C011900C8FC56D00E87B35 /* PBXTextBookmark */ = { 
    103                 isa = PBXTextBookmark; 
    104                 fRef = 79DFC11E0B59B8C80056C80E /* Xmod.m */; 
    105                 name = "Xmod.m: 14"; 
    106                 rLen = 0; 
    107                 rLoc = 365; 
    108                 rType = 0; 
    109                 vrLen = 2621; 
    110                 vrLoc = 0; 
    111         }; 
    112         79C011930C8FC56D00E87B35 /* PBXTextBookmark */ = { 
    113                 isa = PBXTextBookmark; 
    114                 fRef = 79DFC11D0B59B8C80056C80E /* Xmod.h */; 
    115                 name = "Xmod.h: bundle"; 
    116                 rLen = 0; 
    117                 rLoc = 53; 
    118                 rType = 0; 
    119                 vrLen = 60; 
    120                 vrLoc = 0; 
    121         }; 
    122         79C011940C8FC56D00E87B35 /* PBXTextBookmark */ = { 
    123                 isa = PBXTextBookmark; 
    124                 fRef = 79DFC11D0B59B8C80056C80E /* Xmod.h */; 
    125                 name = "Xmod.h: 3"; 
    126                 rLen = 0; 
    127                 rLoc = 53; 
    128                 rType = 0; 
    129                 vrLen = 60; 
    130                 vrLoc = 0; 
    13185        }; 
    13286        79D150FA0C8FBDE9006706AF /* Xmod.applescript */ = { 
     
    152106        79DFC11D0B59B8C80056C80E /* Xmod.h */ = { 
    153107                uiCtxt = { 
    154                         sepNavIntBoundsRect = "{{0, 0}, {723, 927}}"; 
    155                         sepNavSelRange = "{53, 0}"; 
    156                         sepNavVisRect = "{{0, 0}, {723, 927}}"; 
    157                         sepNavWindowFrame = "{{1441, 274}, {762, 985}}"; 
     108                        sepNavIntBoundsRect = "{{0, 0}, {1261, 667}}"; 
     109                        sepNavSelRange = "{134, 0}"; 
     110                        sepNavVisRect = "{{0, 0}, {1261, 667}}"; 
     111                        sepNavWindowFrame = "{{751, 476}, {1300, 725}}"; 
    158112                }; 
    159113        }; 
    160114        79DFC11E0B59B8C80056C80E /* Xmod.m */ = { 
    161115                uiCtxt = { 
    162                         sepNavIntBoundsRect = "{{0, 0}, {723, 980}}"; 
    163                         sepNavSelRange = "{371, 0}"; 
    164                         sepNavVisRect = "{{0, 0}, {723, 927}}"; 
    165                         sepNavWindowFrame = "{{1501, 193}, {762, 985}}"; 
     116                        sepNavIntBoundsRect = "{{0, 0}, {1186, 1106}}"; 
     117                        sepNavSelRange = "{0, 0}"; 
     118                        sepNavVisRect = "{{0, 0}, {1186, 856}}"; 
     119                        sepNavWindowFrame = "{{1120, 289}, {1225, 914}}"; 
     120                }; 
     121        }; 
     122        79DFC1280B59BFD60056C80E /* MethodSwizzle.m */ = { 
     123                uiCtxt = { 
     124                        sepNavIntBoundsRect = "{{0, 0}, {1186, 1722}}"; 
     125                        sepNavSelRange = "{3053, 23}"; 
     126                        sepNavVisRect = "{{0, 586}, {1186, 856}}"; 
     127                        sepNavWindowFrame = "{{38, 638}, {1225, 914}}"; 
     128                }; 
     129        }; 
     130        79F8A9C20C8FF06600082291 /* Autocustomize Entity Classes.applescript */ = { 
     131                uiCtxt = { 
     132                        sepNavIntBoundsRect = "{{0, 0}, {566, 375}}"; 
     133                        sepNavSelRange = "{911, 0}"; 
     134                        sepNavVisRect = "{{0, 0}, {566, 375}}"; 
     135                        sepNavWindowFrame = "{{512, 306}, {605, 433}}"; 
    166136                }; 
    167137        }; 
     
    172142                uiCtxt = { 
    173143                        sepNavIntBoundsRect = "{{0, 0}, {723, 927}}"; 
    174                         sepNavSelRange = "{0, 0}"; 
     144                        sepNavSelRange = "{698, 0}"; 
    175145                        sepNavVisRect = "{{0, 0}, {723, 927}}"; 
    176                         sepNavWindowFrame = "{{15, 38}, {762, 985}}"; 
     146                        sepNavWindowFrame = "{{1302, 337}, {762, 985}}"; 
    177147                }; 
    178148        };