]> err.no Git - sope/blob - sope-appserver/samples/WOxExtTest/TableView.m
Add libxml2-dev to libsope-xml4.7-dev deps
[sope] / sope-appserver / samples / WOxExtTest / TableView.m
1 /*
2   Copyright (C) 2000-2005 SKYRIX Software AG
3
4   This file is part of SOPE.
5
6   SOPE 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   SOPE 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 SOPE; 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
22 #include <NGObjWeb/WOComponent.h>
23
24 @class NSArray;
25
26 @interface TableView : WOComponent < NSCoding >
27 {
28   NSArray *list;
29   int clicks;
30 }
31 @end
32
33 #include "common.h"
34
35 @implementation TableView
36
37 - (id)init {
38   if ((self = [super init]) != nil) {
39     WOResourceManager *rm;
40     NSString          *file;
41
42     rm   = [[self application] resourceManager];
43
44     file = [rm pathForResourceNamed:@"TableView.plist"
45                inFramework:nil
46                languages:nil];
47                               
48     self->list = [[NSArray alloc] initWithContentsOfFile:file];
49     
50     [self takeValue:@"4"       forKey:@"batchSize"];
51     [self takeValue:@"#FCF8DF" forKey:@"evenColor"];
52     [self takeValue:@"#FFFFF0" forKey:@"oddColor"];
53     [self takeValue:@"#FFDAAA" forKey:@"headerColor"];
54     [self takeValue:@"#FFDAAA" forKey:@"footerColor"];
55     [self takeValue:@"#FAE8B8" forKey:@"titleColor"];
56   }
57   return self;
58 }
59
60 - (void)dealloc {
61   [self->list release];
62   [super dealloc];
63 }
64
65 /* accessors */
66
67 - (void)setList:(NSArray *)_list {
68   ASSIGN(self->list, _list);
69 }
70 - (NSArray *)list {
71   return self->list;
72 }
73
74 - (BOOL)isGroupCity {
75   NSDictionary *obj1, *obj2;
76   
77   obj1 = [self valueForKey:@"item"];
78   obj2 = [self valueForKey:@"previousItem"];
79
80   return [[obj1 objectForKey:@"city"] isEqualToString:
81                                       [obj2 objectForKey:@"city"]];
82 }
83
84 - (BOOL)isGroupZip {
85   NSDictionary *obj1, *obj2;
86
87   obj1 = [self valueForKey:@"item"];
88   obj2 = [self valueForKey:@"previousItem"];
89   
90   return [[obj1 objectForKey:@"zip"] isEqualToString:
91                                      [obj2 objectForKey:@"zip"]];
92 }
93
94 - (void)setClicks:(int)_clicks {
95   self->clicks = _clicks;
96 }
97 - (int)clicks {
98   return self->clicks;
99 }
100
101 /* actions */
102
103 - (id)increaseClicks {
104   self->clicks++;
105   [self takeValue:[self valueForKey:@"item"] forKey:@"clickedItem"];
106   return nil;
107 }
108
109 /* NSCoding */
110
111 - (void)encodeWithCoder:(NSCoder *)_coder {
112   [super encodeWithCoder:_coder];
113   [_coder encodeObject:self->list];
114 }
115 - (id)initWithCoder:(NSCoder *)_coder {
116   if ((self = [super initWithCoder:_coder])) {
117     self->list = [[_coder decodeObject] retain];
118   }
119   return self;
120 }
121
122 @end /* TableView */