]> err.no Git - sope/blob - sope-appserver/samples/WOxExtTest/TableView.m
include config.make in makefiles
[sope] / sope-appserver / samples / WOxExtTest / TableView.m
1 /*
2   Copyright (C) 2000-2003 SKYRIX Software AG
3
4   This file is part of OGo
5
6   OGo is free software; you can redistribute it and/or modify it under
7   the terms of the GNU Lesser General Public License as published by the
8   Free Software Foundation; either version 2, or (at your option) any
9   later version.
10
11   OGo is distributed in the hope that it will be useful, but WITHOUT ANY
12   WARRANTY; without even the implied warranty of MERCHANTABILITY or
13   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
14   License for more details.
15
16   You should have received a copy of the GNU Lesser General Public
17   License along with OGo; see the file COPYING.  If not, write to the
18   Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
19   02111-1307, USA.
20 */
21 // $Id$
22
23 #include <NGObjWeb/WOComponent.h>
24
25 @class NSArray;
26
27 @interface TableView : WOComponent < NSCoding >
28 {
29   NSArray *list;
30   int clicks;
31 }
32 @end
33
34 #include "common.h"
35
36 @implementation TableView
37
38 - (id)init {
39   if ((self = [super init])) {
40     WOResourceManager *rm;
41     NSString          *file;
42
43     rm   = [[self application] resourceManager];
44
45     file = [rm pathForResourceNamed:@"TableView.plist"
46                inFramework:nil
47                languages:nil];
48                               
49     self->list = [[NSArray alloc] initWithContentsOfFile:file];
50     
51     [self takeValue:@"4"       forKey:@"batchSize"];
52     [self takeValue:@"#FCF8DF" forKey:@"evenColor"];
53     [self takeValue:@"#FFFFF0" forKey:@"oddColor"];
54     [self takeValue:@"#FFDAAA" forKey:@"headerColor"];
55     [self takeValue:@"#FFDAAA" forKey:@"footerColor"];
56     [self takeValue:@"#FAE8B8" forKey:@"titleColor"];
57   }
58   return self;
59 }
60
61 - (void)dealloc {
62   [self->list release];
63   [super dealloc];
64 }
65
66 /* accessors */
67
68 - (NSArray *)list {
69   return self->list;
70 }
71 - (void)setList:(NSArray *)_list {
72   ASSIGN(self->list, _list);
73 }
74
75 - (BOOL)isGroupCity {
76   id obj1;
77   id obj2;
78
79   obj1 = [self valueForKey:@"item"];
80   obj2 = [self valueForKey:@"previousItem"];
81
82   return [[obj1 objectForKey:@"city"] isEqualToString:
83                                       [obj2 objectForKey:@"city"]];
84 }
85
86 - (BOOL)isGroupZip {
87   id obj1;
88   id obj2;
89
90   obj1 = [self valueForKey:@"item"];
91   obj2 = [self valueForKey:@"previousItem"];
92   
93   return [[obj1 objectForKey:@"zip"] isEqualToString:
94                                      [obj2 objectForKey:@"zip"]];
95 }
96
97 - (void)setClicks:(int)_clicks {
98   self->clicks = _clicks;
99 }
100 - (int)clicks {
101   return self->clicks;
102 }
103
104 /* actions */
105
106 - (id)increaseClicks {
107   self->clicks++;
108   [self takeValue:[self valueForKey:@"item"] forKey:@"clickedItem"];
109   return nil;
110 }
111
112 /* NSCoding */
113
114 - (void)encodeWithCoder:(NSCoder *)_coder {
115   [super encodeWithCoder:_coder];
116   [_coder encodeObject:self->list];
117 }
118 - (id)initWithCoder:(NSCoder *)_coder {
119   if ((self = [super initWithCoder:_coder])) {
120     self->list = [[_coder decodeObject] retain];
121   }
122   return self;
123 }
124
125 @end /* TableView */