2 Copyright (C) 2000-2004 SKYRIX Software AG
4 This file is part of OpenGroupware.org.
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
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.
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
23 #include "SoComponent.h"
24 #include "SoProductResourceManager.h"
25 #include "SoProductRegistry.h"
26 #include "SoProduct.h"
27 #include <NGObjWeb/WOApplication.h>
30 @implementation SoComponent
33 return [super version] + 0 /* v2 */;
36 static BOOL didInit = NO;
39 NSAssert2([super version] == 2,
40 @"invalid superclass (%@) version %i !",
41 NSStringFromClass([self superclass]), [super version]);
46 [self->soResourceManager release];
47 [self->soTemplate release];
48 [self->soBaseURL release];
52 /* resource manager */
54 - (NSBundle *)componentBundle {
55 return [NSBundle bundleForClass:[self class]];
57 - (SoProduct *)componentProduct {
58 static SoProductRegistry *reg = nil;
63 reg = [[SoProductRegistry sharedProductRegistry] retain];
65 [self logWithFormat:@"ERROR: missing product registry!"];
67 if ((bundle = [self componentBundle]) == nil)
68 [self logWithFormat:@"WARNING: did not find bundle of component !"];
70 if ((product = [reg productForBundle:bundle]) == nil)
72 @"WARNING: did not find product of component (bundle=%@)", bundle];
76 - (void)setResourceManager:(WOResourceManager *)_rm {
77 ASSIGN(self->soResourceManager, _rm);
79 - (WOResourceManager *)resourceManager {
80 if (self->soResourceManager)
81 return self->soResourceManager;
83 self->soResourceManager = [[[self componentProduct] resourceManager] retain];
84 if (self->soResourceManager)
85 return self->soResourceManager;
87 return [super resourceManager];
90 /* move some extra vars into ivars */
92 - (void)setBaseURL:(NSURL *)_url {
93 ASSIGN(self->soBaseURL, _url);
99 return self->soBaseURL;
101 url = [(WOApplication *)[self application] baseURL];
102 url = [NSURL URLWithString:@"WebServerResources" relativeToURL:url];
103 self->soBaseURL = [url copy];
104 return self->soBaseURL;
107 - (void)setTemplate:(id)_template {
109 WO has private API for this:
110 - (void)setTemplate:(WOElement *)template;
111 As mentioned in the OmniGroup WO mailing list ...
113 ASSIGN(self->soTemplate, _template);
115 - (WOElement *)_woComponentTemplate {
118 if (self->soTemplate)
119 return self->soTemplate;
121 tmpl = [self templateWithName:[self name]];
124 @"WARNING: found not template named '%@' for component.",
130 @end /* SoComponent */