View Javadoc

1   /**
2    * Copyright 2005-2011 The Kuali Foundation
3    *
4    * Licensed under the Educational Community 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.opensource.org/licenses/ecl2.php
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  package org.kuali.rice.krad.uif;
17  
18  import java.text.MessageFormat;
19  
20  /**
21   * Constants for CSS style strings
22   * 
23   * @author Kuali Rice Team (rice.collab@kuali.org)
24   */
25  public class CssConstants {
26  
27  	public static final String DISPLAY = "display: ";
28  
29  	public static class Displays {
30  		public static final String BLOCK = DISPLAY + "block;";
31  		public static final String INLINE = DISPLAY + "inline;";
32  		public static final String INLINE_BLOCK = DISPLAY + "inline-block;";
33  		public static final String NONE = DISPLAY + "none;";
34  	}
35  	
36  	public static final String TEXT_ALIGN = "text-align: ";
37  
38  	public static class TextAligns {
39  		public static final String LEFT = TEXT_ALIGN + "left;";
40  		public static final String RIGHT = TEXT_ALIGN + "right;";
41  		public static final String CENTER = TEXT_ALIGN + "center;";
42  		public static final String JUSTIFY = TEXT_ALIGN + "justify;";
43  		public static final String INHERIT = TEXT_ALIGN + "inherit;";
44  	}
45  
46  	public static final String VERTICAL_ALIGN = "vertical-align: ";
47  
48  	public static class VerticalAligns {
49  		public static final String BASELINE = VERTICAL_ALIGN + "Baseline;";
50  		public static final String BOTTOM = VERTICAL_ALIGN + "bottom;";
51  		public static final String MIDDLE = VERTICAL_ALIGN + "middle;";
52  		public static final String TOP = VERTICAL_ALIGN + "top;";
53  	}
54  
55  	public static class Margins {
56  		public static final String MARGIN_LEFT = "margin-left: {0};";
57  		public static final String MARGIN_RIGHT = "margin-right: {0};";
58  		public static final String MARGIN_TOP = "margin-top: {0};";
59  		public static final String MARGIN_BOTTOM = "margin-bottom: {0};";
60  	}
61  	
62  	public static class Padding {
63  		public static final String PADDING_LEFT = "padding-left: {0};";
64  		public static final String PADDING_RIGHT = "padding-right: {0};";
65  		public static final String PADDING_TOP = "padding-top: {0};";
66  		public static final String PADDING_BOTTOM = "padding-bottom: {0};";
67  	}
68  	
69  	public static final String WIDTH = "width: ";
70  
71  	/**
72  	 * Replaces parameters in the given CSS string with the corresponding
73  	 * parameter values given
74  	 * 
75  	 * @param style
76  	 *            - String with parameters to replace
77  	 * @param parameters
78  	 *            - One or more parameter values
79  	 * @return String given string with filled parameters
80  	 */
81  	public static final String getCssStyle(String style, String... parameters) {
82  		MessageFormat cssStyle = new MessageFormat(style);
83  
84  		return cssStyle.format(parameters);
85  	}
86  }