Annotation of Examples/EnterpriseObjects/SHLExamples/KeyValueCoding/AppController.m, revision 1.1

1.1     ! root        1: /*--------------------------------------------------------------------------
        !             2:  *
        !             3:  *     You may freely copy, distribute, and reuse the code in this example.
        !             4:  *     SHL Systemhouse disclaims any warranty of any kind, expressed or  
        !             5:  *     implied, as to its fitness for any particular use.
        !             6:  *
        !             7:  *     AppController
        !             8:  *
        !             9:  *     Inherits From:          NSObject
        !            10:  *
        !            11:  *     Conforms To:            None
        !            12:  *
        !            13:  *     Declared In:            AppController.h
        !            14:  *
        !            15:  *------------------------------------------------------------------------*/
        !            16: #import <foundation/NSString.h>
        !            17: 
        !            18: #import "AppController.h"
        !            19: #import "ScrollViewExtensions.h"
        !            20: #import "Catalog.h"
        !            21: #import <ansi/ctype.h>
        !            22: #include <ansi/time.h>
        !            23: 
        !            24: 
        !            25: #define SLEEP(sleeptime) \
        !            26:                do { \
        !            27:                        struct timeval tv; \
        !            28:                        tv.tv_sec = sleeptime; tv.tv_usec = 0; \
        !            29:                    select(0, NULL, NULL, NULL, &tv); \
        !            30:                } while(0)
        !            31: 
        !            32: 
        !            33: 
        !            34: 
        !            35: @implementation AppController
        !            36: 
        !            37: /*--------------------------------------------------------------------------
        !            38:  *     Application delegate methods
        !            39:  *------------------------------------------------------------------------*/
        !            40: - appDidInit: sender
        !            41: {
        !            42:        id      entity = [(EODatabaseDataSource *)[controller dataSource] entity];
        !            43:        id      qualifier = [[EOQualifier allocWithZone: [self zone]]
        !            44:                        initWithEntity:entity qualifierFormat:@"au_fname = \"Akiko\""];
        !            45: 
        !            46:        [window disableDisplay];
        !            47:        startup = YES;
        !            48: 
        !            49:        [textDisplay setVertScrollerRequired:NO];
        !            50:        [[textDisplay docView] setRetainedWhileDrawing:YES];
        !            51: 
        !            52:        /*----------------------------------------------------------------------
        !            53:         *      turn buffering on so changes never affect database
        !            54:         *--------------------------------------------------------------------*/
        !            55:        [controller setSavesToDataSourceAutomatically:NO];
        !            56:        [controller setSavesToObjectsAutomatically:YES];
        !            57: 
        !            58:        [[[(EODatabaseDataSource *)[controller dataSource] databaseChannel]
        !            59:                adaptorChannel] setDebugEnabled:YES];
        !            60: 
        !            61:        [(EODatabaseDataSource *)[controller dataSource] setQualifier:qualifier];
        !            62:        [controller fetch];
        !            63: 
        !            64: /*--------------------------------------------------------------------------
        !            65:  *     This was included in alpha to select a single record -- apparently, the
        !            66:  *     associations are smart enough now to display the first selected record.
        !            67:  *
        !            68:  *     [controller setSelectionIndexes: selectionArray];
        !            69:  *     [[controller associations] makeObjectsPerform:
        !            70:  *             @selector(selectionDidChange)];
        !            71:  *     [self updateObjectView:[[controller allObjects] objectAtIndex:0]];
        !            72:  *------------------------------------------------------------------------*/
        !            73: 
        !            74:        [[textDisplay docView] setText:""];
        !            75: 
        !            76:        [window reenableDisplay];
        !            77:        [window display];
        !            78:        [window makeKeyAndOrderFront:nil];
        !            79: 
        !            80:        startup = NO;
        !            81:        return self;
        !            82: }
        !            83: 
        !            84: 
        !            85: /*--------------------------------------------------------------------------
        !            86:  *     Printing Trace Information
        !            87:  *------------------------------------------------------------------------*/
        !            88: - console: (NSArray *) argArray
        !            89: {
        !            90:        BOOL    flag;
        !            91: 
        !            92:        if (startup == YES) return self;
        !            93: 
        !            94:        [[argArray objectAtIndex:1] getValue: &flag];
        !            95:        if ([[traceSetting cellAt:(int)flag:0] state] == NO)
        !            96:                return self;
        !            97: 
        !            98:        [console sprintf: "%s", [[argArray objectAtIndex:0] cString]];
        !            99: 
        !           100:        return self;
        !           101: }
        !           102: 
        !           103: 
        !           104: - display: (NSArray *) argArray
        !           105: {
        !           106:        BOOL    flag;
        !           107: 
        !           108:        if (startup == YES) return self;
        !           109: 
        !           110:        [[argArray objectAtIndex:1] getValue: &flag];
        !           111:        if ([[traceSetting cellAt:(int)flag:0] state] == NO)
        !           112:                return self;
        !           113: 
        !           114:        [[textDisplay docView] setText: [[argArray objectAtIndex:0] cString]];
        !           115: 
        !           116:        NXPing();
        !           117:        if ([traceDelay intValue])
        !           118:                SLEEP([traceDelay intValue]);
        !           119: 
        !           120: 
        !           121:        [[textDisplay docView] setText: ""];
        !           122: 
        !           123:        return self;
        !           124: }
        !           125: 
        !           126: 
        !           127: /*--------------------------------------------------------------------------
        !           128:  *     Update object view
        !           129:  *------------------------------------------------------------------------*/
        !           130: - updateObjectView: newObject
        !           131: {
        !           132:        BOOL temp = startup;
        !           133: 
        !           134:        startup = YES;
        !           135:        [objectName setStringValue: [[newObject authorName] cString]];
        !           136:        [objectPrice setStringValue:
        !           137:                        [[(NSNumber *)[newObject price] description] cString]];
        !           138:        [objectTitle setStringValue: [[newObject volumeTitle] cString]];
        !           139: 
        !           140:        startup = temp;
        !           141:        return self;
        !           142: }
        !           143: 
        !           144: @end

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.