1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19 package org.apache.myfaces.trinidad.skin;
20
21 import java.util.Collections;
22
23 import javax.el.ValueExpression;
24
25 import javax.faces.el.ValueBinding;
26
27 import org.apache.myfaces.trinidad.context.LocaleContext;
28
29 /**
30 * <p>
31 * SkinAddition objects are used by custom component developers who have created custom
32 * components, and they need a way to 'push' in their own stylesheet and
33 * resource bundle for these components into some skin of their choosing,
34 * most likely the simple skin.</p>
35 * <p>
36 * A Skin object contains zero or more SkinAdditions. The SkinAdditions' stylesheets
37 * are merged into the Skin's own stylesheet. The SkinAdditions' resource
38 * bundle is looked at along with the Skin's own resource bundle when Skin's
39 * getTranslatedValue is called.
40 * </p>
41 * <p>
42 * If you want to 'push' your styles into a specific skin, then you would create a skin-addition in the trinidad-skins.xml file.
43 * You specify a <skin-addition>. The children are: <skin-id>,
44 * <style-sheet-name>, <bundle-name>, and <translation-source>.
45 * The <skin-id> is used to specify which skin you want to 'push' your stylesheet/resource bundle into.
46 * Most likely this is the simple.desktop skin.
47 * The other elements are used to create a SkinAddition object.
48 * </p>
49 *
50 *
51 */
52 public class SkinAddition
53 {
54
55
56 /**
57 * Constructor takes a styleSheet name and a resourceBundle name.
58 */
59 public SkinAddition (
60 String styleSheetName,
61 String resourceBundleName
62 )
63 {
64 _styleSheetName = styleSheetName;
65 _resourceBundleName = resourceBundleName;
66 _translationSourceVE = null;
67 _translationSourceVB = null;
68 }
69
70 /**
71 * Constructor takes a styleSheet name and a translationSource ValueExpression.
72 */
73 public SkinAddition (
74 String styleSheetName,
75 ValueExpression translationSourceValueExpression
76 )
77 {
78 _styleSheetName = styleSheetName;
79 _resourceBundleName = null;
80 _translationSourceVE = translationSourceValueExpression;
81 _translationSourceVB = null;
82 }
83 /**
84 * Constructor takes a styleSheet name. resource bundle name and
85 * translation source value expression will be null.
86 */
87 public SkinAddition (
88 String styleSheetName
89 )
90 {
91 _styleSheetName = styleSheetName;
92 _resourceBundleName = null;
93 _translationSourceVE = null;
94 _translationSourceVB = null;
95 }
96
97 /**
98 * Constructor takes a styleSheet name and a translationSource ValueBinding.
99 * @deprecated
100 */
101 @Deprecated
102 public SkinAddition (
103 String styleSheetName,
104 ValueBinding translationSourceValueBinding
105 )
106 {
107 _styleSheetName = styleSheetName;
108 _resourceBundleName = null;
109 _translationSourceVE = null;
110 _translationSourceVB = translationSourceValueBinding;
111 }
112
113 /**
114 * Gets the SkinAddition's style sheet name.
115 */
116 public String getStyleSheetName()
117 {
118 return _styleSheetName;
119 }
120
121 /**
122 * Gets the SkinAddition's resource bundle.
123 * Note: A skin cannot have both a resourceBundleName and a translation source
124 * value expression. If they do, then the resourceBundleName takes precedence.
125 */
126 public String getResourceBundleName()
127 {
128 return _resourceBundleName;
129 }
130
131 /**
132 * Gets the SkinAddition's translation source ValueExpresion. The
133 * ValueExpression can point to a Map or a ResourceBundle.
134 * Note: A skin cannot have both a resourceBundleName and a translation source
135 * value expression. If they do, then the resourceBundleName takes precedence.
136 */
137 public ValueExpression getTranslationSourceValueExpression()
138 {
139 return _translationSourceVE;
140 }
141
142 /**
143 * Gets the SkinAddition's translation source ValueBinding. The
144 * ValueBinding can point to a Map or a ResourceBundle.
145 * Note: A skin cannot have both a resourceBundleName and a translation source
146 * value binding. If they do, then the resourceBundleName takes precedence.
147 * @deprecated
148 */
149 @Deprecated
150 public ValueBinding getTranslationSourceValueBinding()
151 {
152 return _translationSourceVB;
153 }
154
155 private final String _styleSheetName;
156 private final String _resourceBundleName;
157 private final ValueExpression _translationSourceVE;
158 private final ValueBinding _translationSourceVB;
159
160 }