PageRenderTime 133ms CodeModel.GetById 38ms app.highlight 22ms RepoModel.GetById 72ms app.codeStats 0ms

/FieldMapTableController.m

http://github.com/bububa/MongoHub-Mac
Objective C | 96 lines | 64 code | 24 blank | 8 comment | 7 complexity | 09c3b0fd53e8be2efbf790a635e2b379 MD5 | raw file
 1//
 2//  fieldMapTableController.m
 3//  MongoHub
 4//
 5//  Created by Syd on 10-6-22.
 6//  Copyright 2010 ThePeppersStudio.COM. All rights reserved.
 7//
 8
 9#import "FieldMapTableController.h"
10
11
12@implementation FieldMapTableController
13@synthesize nsMutaryDataObj;
14@synthesize idTableView;
15
16- (void)dealloc {
17    [nsMutaryDataObj release];
18    [idTableView release];
19    [super dealloc];
20}
21
22- (IBAction)addAtSelectedRow:(id)pId {
23    if ([idTableView selectedRow] > -1) {
24        NSString * zStr1 = @"Text Cell 1";
25        NSString * zStr2 = @"Text Cell 2";
26        FieldMapDataObject * zDataObject = [[FieldMapDataObject alloc]initWithSqlKey:zStr1 
27                                                               andMongoKey:zStr2 ];
28        [self.nsMutaryDataObj insertObject:zDataObject 
29                                   atIndex:[idTableView selectedRow]];
30        [zDataObject release];
31        [idTableView reloadData];
32    } // end if
33    
34} // end deleteSelectedRow
35
36
37- (IBAction)deleteSelectedRow:(id)pId {
38    if ([idTableView selectedRow] > -1) {
39        [self.nsMutaryDataObj removeObjectAtIndex:[idTableView selectedRow]];
40        [idTableView reloadData];
41    } // end if
42} // end deleteSelectedRow
43
44
45- (void)addRow:(FieldMapDataObject *)pDataObj {
46    [self.nsMutaryDataObj addObject:pDataObj];
47    [idTableView reloadData];
48} // end addRow
49
50
51- (int)numberOfRowsInTableView:(NSTableView *)pTableViewObj {
52    return [self.nsMutaryDataObj count];
53} // end numberOfRowsInTableView
54
55
56- (id) tableView:(NSTableView *)pTableViewObj 
57objectValueForTableColumn:(NSTableColumn *)pTableColumn
58             row:(int)pRowIndex {
59    FieldMapDataObject * zDataObject = (FieldMapDataObject *)[self.nsMutaryDataObj objectAtIndex:pRowIndex];
60    if (! zDataObject) {
61        NSLog(@"tableView: objectAtIndex:%d = NULL",pRowIndex);
62        return NULL;
63    } // end if
64    //NSLog(@"pTableColumn identifier = %@",[pTableColumn identifier]);
65    
66    if ([[pTableColumn identifier] isEqualToString:@"Col_ID1"]) {
67        return [zDataObject sqlKey];
68    }
69    
70    if ([[pTableColumn identifier] isEqualToString:@"Col_ID2"]) {
71        return [zDataObject mongoKey];
72    }
73    
74    NSLog(@"***ERROR** dropped through pTableColumn identifiers");
75    return NULL;
76    
77} // end tableView:objectValueForTableColumn:row:
78
79
80- (void)tableView:(NSTableView *)pTableViewObj 
81   setObjectValue:(id)pObject 
82   forTableColumn:(NSTableColumn *)pTableColumn 
83              row:(int)pRowIndex {
84    
85    FieldMapDataObject * zDataObject   = (FieldMapDataObject *)[self.nsMutaryDataObj objectAtIndex:pRowIndex];
86    
87    if ([[pTableColumn identifier] isEqualToString:@"Col_ID1"]) {
88        [zDataObject setSqlKey:(NSString *)pObject];
89    }
90    
91    if ([[pTableColumn identifier] isEqualToString:@"Col_ID2"]) {
92        [zDataObject setMongoKey:(NSString *)pObject];
93    }
94} // end tableView:setObjectValue:forTableColumn:row:
95
96@end