KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > springframework > ui > context > support > DelegatingThemeSource


1 /*
2  * Copyright 2002-2005 the original author or authors.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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
39     public void setParentThemeSource(ThemeSource parentThemeSource) {
40         this.parentThemeSource = parentThemeSource;
41     }
42
43     public ThemeSource getParentThemeSource() {
44         return parentThemeSource;
45     }
46
47
48     public Theme getTheme(String JavaDoc themeName) {
49         if (this.parentThemeSource != null) {
50             return this.parentThemeSource.getTheme(themeName);
51         }
52         else {
53             return null;
54         }
55     }
56
57 }
58
Popular Tags