01: /*
02: * Copyright 2002-2005 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16:
17: package org.springframework.ui.context.support;
18:
19: import org.springframework.ui.context.HierarchicalThemeSource;
20: import org.springframework.ui.context.Theme;
21: import org.springframework.ui.context.ThemeSource;
22:
23: /**
24: * Empty ThemeSource that delegates all calls to the parent ThemeSource.
25: * If no parent is available, it simply won't resolve any theme.
26: *
27: * <p>Used as placeholder by UiApplicationContextUtils, if a context doesn't
28: * define its own ThemeSource. Not intended for direct use in applications.
29: *
30: * @author Juergen Hoeller
31: * @since 1.2.4
32: * @see UiApplicationContextUtils
33: */
34: public class DelegatingThemeSource implements HierarchicalThemeSource {
35:
36: private ThemeSource parentThemeSource;
37:
38: public void setParentThemeSource(ThemeSource parentThemeSource) {
39: this .parentThemeSource = parentThemeSource;
40: }
41:
42: public ThemeSource getParentThemeSource() {
43: return parentThemeSource;
44: }
45:
46: public Theme getTheme(String themeName) {
47: if (this.parentThemeSource != null) {
48: return this.parentThemeSource.getTheme(themeName);
49: } else {
50: return null;
51: }
52: }
53:
54: }
|