Annotation of Examples/IndexingKit/Ledger/JFTableViewLoader.m, revision 1.1

1.1     ! root        1: 
        !             2: #import "JFTableViewLoader.h"
        !             3: #import "JFTableVectorConfiguration.h"
        !             4: /* 
        !             5:  *     JFTableViewLoader, NeXT Systems Engineering
        !             6:  *     Written by Joe Freeman
        !             7:  *
        !             8:  *     A list of these configuration objects is fed to a JFTableViewLoader
        !             9:  *     to tell it what ivars and titles map into a DBTableView
        !            10:  */
        !            11: 
        !            12: 
        !            13: @implementation JFTableViewLoader
        !            14: 
        !            15: /* static char VERSION[] = " @(#) Version: 2, Project: TableViewLoader, Written By: Joe Freeman, 1992"; */
        !            16: 
        !            17: - (const char *)getInspectorClassName
        !            18: {
        !            19:     return "JFDBTVLoaderInspector";
        !            20: }
        !            21: 
        !            22: - setTableView:anObject;
        !            23: {
        !            24:     tableView = anObject;
        !            25:     [tableView setDataSource:self];
        !            26:     return self;
        !            27: }
        !            28: 
        !            29: 
        !            30: - setDataList:anObject
        !            31: {
        !            32:     dataList = anObject;
        !            33:     [tableView reloadData:self];
        !            34: 
        !            35:     return self;
        !            36: }
        !            37: 
        !            38: 
        !            39: /* this doesn't do what we want in the inspector in IB
        !            40:  * because it relies on the tableView nstance var being set up
        !            41:  * in ib, the connections in build mode, are fake.  So,
        !            42:  * we have to have this method happen in awake
        !            43:  */
        !            44: - setConfigurationList:cList
        !            45: {
        !            46: 
        !            47:     int                 i;
        !            48:     int                 tCount;
        !            49:     id                 <DBTableVectors > aVector;
        !            50: 
        !            51:     [[tableView window] disableFlushWindow];   /* DBTV ignores autodisplay */
        !            52:     configList = cList;
        !            53:  /* configure the columns */
        !            54:  /* first figure out how many columns there are, and how many we need */
        !            55:     tCount = [tableView columnCount];
        !            56: 
        !            57:     for (i = [configList count]; i < tCount; i++)
        !            58:        [tableView removeColumnAt:[configList count]];
        !            59: 
        !            60:  /* then make the numbers match and load up the titles and identifiers */
        !            61:     for (i = 0; i < [configList count]; i++) {
        !            62:        if (i < tCount) {
        !            63:            aVector = [tableView columnAt:i];
        !            64:            [aVector setIdentifier:(id)i];
        !            65:            [aVector setTitle:[[configList objectAt:i] title]];
        !            66:        } else {
        !            67:            [tableView addColumn:(id)i
        !            68:             withTitle:[[configList objectAt:i] title]];
        !            69:        }
        !            70:     }
        !            71: 
        !            72:     [[tableView window] reenableFlushWindow];
        !            73:     [[tableView window] flushWindowIfNeeded];
        !            74: 
        !            75:     return self;
        !            76: }
        !            77: 
        !            78: - setDataList:anObject andConfigurationList:cList
        !            79: {
        !            80:     [self setConfigurationList:cList];
        !            81:  /* now load em up */
        !            82:     [self setDataList:anObject];
        !            83:     return self;
        !            84: }
        !            85: 
        !            86: /*======================================================================
        !            87:  *     Inspector support
        !            88:  *======================================================================*/
        !            89: 
        !            90: - (DBTableView *) tableView
        !            91: {
        !            92:     return tableView;
        !            93: }
        !            94: 
        !            95: - (List *) dataList
        !            96: {
        !            97:     if (dataList)
        !            98:        return dataList;
        !            99:     else
        !           100:        return[[List alloc] init];
        !           101: }
        !           102: 
        !           103: - (List *) configList
        !           104: {
        !           105:     if (configList)
        !           106:        return configList;
        !           107:     else
        !           108:        return[[List alloc] init];
        !           109: }
        !           110: 
        !           111: /*======================================================================
        !           112:  *     Archiving
        !           113:  *======================================================================*/
        !           114: 
        !           115: - awakeFromNib
        !           116: {
        !           117:     [self setConfigurationList:configList];
        !           118:     return self;
        !           119: }
        !           120: 
        !           121: - read:(NXTypedStream *) typedStream
        !           122: {
        !           123:     [super read:typedStream];
        !           124: 
        !           125:     dataList = NXReadObject(typedStream);
        !           126:     configList = NXReadObject(typedStream);
        !           127:     tableView = NXReadObject(typedStream);
        !           128: 
        !           129:     return self;
        !           130: }
        !           131: 
        !           132: - write:(NXTypedStream *) typedStream
        !           133: {
        !           134:     [super write:typedStream];
        !           135: 
        !           136:     NXWriteObjectReference(typedStream, dataList);
        !           137:     NXWriteObject(typedStream, configList);
        !           138:     NXWriteObjectReference(typedStream, tableView);
        !           139:     return self;
        !           140: }
        !           141: 
        !           142: /*======================================================================
        !           143:  *     DBTableView data source (psuedo-delegate) methods
        !           144:  *======================================================================*/
        !           145: 
        !           146: - (unsigned int)rowCount
        !           147: {
        !           148:     return[dataList count];
        !           149: }
        !           150: 
        !           151: /* DBTV sends this message when it needs to know what to display */
        !           152: - getValueFor:identifier at:(unsigned int)aPosition into:aValue
        !           153: {
        !           154:  /*
        !           155:   * note that when loaded, we set the identifiers to be the locations of the
        !           156:   * configuration objects in the configuration list 
        !           157:   */
        !           158:     if (configList)
        !           159:        [[configList objectAt:(int)identifier]
        !           160:         getValueFromObject:[dataList objectAt:aPosition]
        !           161:         into:aValue];
        !           162:     else
        !           163:        [aValue setStringValue:""];
        !           164:     return nil;
        !           165: }
        !           166: 
        !           167: /* DBTV sends this message when data in a cell has changed */
        !           168: - setValueFor:identifier at:(unsigned int)aPosition from:aValue
        !           169: {
        !           170:     [[configList objectAt:(int)identifier]
        !           171:      setValueForObject:[dataList objectAt:aPosition]
        !           172:      from:aValue];
        !           173:     return nil;
        !           174: }
        !           175: 
        !           176: @end

unix.superglobalmegacorp.com

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