]> err.no Git - sope/blob - sope-appserver/WEExtensions/WETableView/WETableViewLabelConfig.m
milli => micro
[sope] / sope-appserver / WEExtensions / WETableView / WETableViewLabelConfig.m
1 /*
2   Copyright (C) 2000-2004 SKYRIX Software AG
3
4   This file is part of OpenGroupware.org.
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 "WETableViewLabelConfig.h"
24 #include "WETableViewDefines.h"
25 #include "common.h"
26
27 @implementation WETableViewLabelConfig
28
29 - (id)initWithAssociations:(NSDictionary *)_config {
30   if ((self = [super initWithAssociations:_config])) {
31     self->ofLabel        = WOExtGetProperty(_config, @"ofLabel");
32     self->toLabel        = WOExtGetProperty(_config, @"toLabel");
33     self->firstLabel     = WOExtGetProperty(_config, @"firstLabel");
34     self->previousLabel  = WOExtGetProperty(_config, @"previousLabel");
35     self->nextLabel      = WOExtGetProperty(_config, @"nextLabel");
36     self->lastLabel      = WOExtGetProperty(_config, @"lastLabel");
37     self->pageLabel      = WOExtGetProperty(_config, @"pageLabel");
38     self->sortLabel      = WOExtGetProperty(_config, @"sortLabel");
39
40     /* defaults */
41 #define SetAssociationValue(_a_, _value_) \
42          if (_a_ == nil)                  \
43            _a_ = [[WOAssociation associationWithValue:_value_] retain];
44     
45     SetAssociationValue(self->ofLabel,       @"/");
46     SetAssociationValue(self->toLabel,       @"-");
47     SetAssociationValue(self->firstLabel,    @"<<");
48     SetAssociationValue(self->previousLabel, @"<");
49     SetAssociationValue(self->nextLabel,     @">");
50     SetAssociationValue(self->lastLabel,     @">>");
51     SetAssociationValue(self->pageLabel,     @"Page");
52     SetAssociationValue(self->sortLabel,     @"sort column");
53 #undef SetAssociationValue
54   }
55   return self;
56 }
57
58 - (void)dealloc {
59   [self->ofLabel       release];
60   [self->toLabel       release];
61   [self->firstLabel    release];
62   [self->previousLabel release];
63   [self->nextLabel release];
64   [self->lastLabel release];
65   [self->pageLabel release];
66   [self->sortLabel release];
67   [super dealloc];
68 }
69
70 - (void)updateConfigInContext:(WOContext *)_ctx {
71   WOComponent *cmp;
72   NSString    *tmp;
73
74   cmp = [_ctx component];
75   
76 #define SetConfigInContext(_a_, _key_)                                  \
77       if (_a_ && (tmp = [_a_ valueInComponent:cmp]))                    \
78         [_ctx setObject:tmp forKey:_key_];
79   SetConfigInContext(self->ofLabel,         WETableView_ofLabel);
80   SetConfigInContext(self->toLabel,         WETableView_toLabel);
81   SetConfigInContext(self->firstLabel,      WETableView_firstLabel);
82   SetConfigInContext(self->previousLabel,   WETableView_previousLabel);
83   SetConfigInContext(self->nextLabel,       WETableView_nextLabel);
84   SetConfigInContext(self->lastLabel,       WETableView_lastLabel);
85   SetConfigInContext(self->pageLabel,       WETableView_pageLabel);
86   SetConfigInContext(self->sortLabel,       WETableView_sortLabel);
87 #undef SetConfigInContext
88 }
89
90 @end /* WETableViewLabelConfig */