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