View Javadoc
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  
20  package org.apache.myfaces.tobago.renderkit.css;
21  
22  import org.apache.myfaces.tobago.apt.annotation.Preliminary;
23  import org.apache.myfaces.tobago.context.Markup;
24  import org.apache.myfaces.tobago.layout.AlignItems;
25  import org.apache.myfaces.tobago.layout.JustifyContent;
26  
27  import java.util.ArrayList;
28  import java.util.List;
29  
30  /**
31   * Declaration of the Tobago CSS classes.
32   *
33   * @since 3.0.0
34   */
35  public enum TobagoClass implements CssItem {
36  
37    // general classes
38  
39    /**
40     * @deprecated since 4.5.0
41     */
42    @Deprecated
43    INPUT_PSEUDO("tobago-inputPseudo"),
44  
45    /**
46     * @deprecated since 4.0.0, use {@link BootstrapClass#ALIGN_ITEMS_BASELINE}
47     */
48    @Deprecated
49    ALIGN_ITEMS__BASELINE("tobago-alignItems-baseline"),
50    /**
51     * @deprecated since 4.0.0, use {@link BootstrapClass#ALIGN_ITEMS_CENTER}
52     */
53    @Deprecated
54    ALIGN_ITEMS__CENTER("tobago-alignItems-center"),
55    /**
56     * @deprecated since 4.0.0, use {@link BootstrapClass#ALIGN_ITEMS_END}
57     */
58    @Deprecated
59    ALIGN_ITEMS__FLEX_END("tobago-alignItems-flexEnd"),
60    /**
61     * @deprecated since 4.0.0, use {@link BootstrapClass#ALIGN_ITEMS_START}
62     */
63    @Deprecated
64    ALIGN_ITEMS__FLEX_START("tobago-alignItems-flexStart"),
65    /**
66     * @deprecated since 4.0.0, use {@link BootstrapClass#ALIGN_ITEMS_STRETCH}
67     */
68    @Deprecated
69    ALIGN_ITEMS__STRETCH("tobago-alignItems-stretch"),
70  
71    /**
72     * @deprecated since 4.0.0, use {@link BootstrapClass#JUSTIFY_CONTENT_CENTER}
73     */
74    @Deprecated
75    JUSTIFY_CONTENT__CENTER("tobago-justifyContent-center"),
76    /**
77     * @deprecated since 4.0.0, use {@link BootstrapClass#JUSTIFY_CONTENT_START}
78     */
79    @Deprecated
80    JUSTIFY_CONTENT__FLEX_START("tobago-justifyContent-flexStart"),
81    /**
82     * @deprecated since 4.0.0, use {@link BootstrapClass#JUSTIFY_CONTENT_END}
83     */
84    @Deprecated
85    JUSTIFY_CONTENT__FLEX_END("tobago-justifyContent-flexEnd"),
86    /**
87     * @deprecated since 4.0.0, use {@link BootstrapClass#JUSTIFY_CONTENT_BETWEEN}
88     */
89    @Deprecated
90    JUSTIFY_CONTENT__SPACE_BETWEEN("tobago-justifyContent-spaceBetween"),
91    /**
92     * @deprecated since 4.0.0, use {@link BootstrapClass#JUSTIFY_CONTENT_AROUND}
93     */
94    @Deprecated
95    JUSTIFY_CONTENT__SPACE_AROUND("tobago-justifyContent-spaceAround"),
96  
97    DROPDOWN__SUBMENU("tobago-dropdown-submenu"),
98    /**
99     * @deprecated Since 3.0.1. Please use {@link TobagoClass#DROPDOWN__SUBMENU}
100    */
101   @Deprecated
102   DROPDOWN_SUBMENU(DROPDOWN__SUBMENU.getName()),
103   TABLE_LAYOUT__FIXED("tobago-tableLayout-fixed"),
104 
105   /**
106    * @deprecated since 4.0.0
107    */
108   @Deprecated
109   HAS__INFO("tobago-has-info"),
110   /**
111    * @deprecated Since 3.0.1. Please use {@link TobagoClass#HAS__INFO}
112    */
113   @Deprecated
114   HAS_INFO(HAS__INFO.getName()),
115   REQUIRED("tobago-required"),
116   SPREAD("tobago-spread"),
117 
118   // component based classes
119 
120   BADGE("tobago-badge"),
121   BAR("tobago-bar"),
122 
123   /**
124    * @deprecated since 5.0.0
125    */
126   @Deprecated
127   BOX("tobago-box"),
128   BOX__HEADER("tobago-box-header"),
129   BUTTON("tobago-button"),
130   BUTTONS("tobago-buttons"),
131   COLLAPSED("tobago-collapsed"),
132   DATE("tobago-date"),
133   DATE__PICKER("tobago-date-picker"),
134   DROPDOWN__OPEN("tobago-dropdown-open"),
135   DROPDOWN__SELECTED("tobago-dropdown-selected"),
136   FILE("tobago-file"),
137   FLEX_LAYOUT("tobago-flexLayout"),
138   FLOW_LAYOUT("tobago-flowLayout"),
139   FIGURE("tobago-figure"),
140   FORM("tobago-form"),
141   GRID_LAYOUT("tobago-gridLayout"),
142   /**
143    * @deprecated Since 5.0.0. Please use {@link TobagoClass#POPOVER__BUTTON}
144    */
145   @Deprecated
146   HELP__BUTTON("tobago-help-button"),
147   IMAGE("tobago-image"),
148   IN("tobago-in"),
149   INPUT__GROUP__OUTER("tobago-input-group-outer"),
150   /**
151    * @deprecated Since 3.0.1. Please use {@link TobagoClass#INPUT__GROUP__OUTER}
152    */
153   @Deprecated
154   INPUT_GROUP_OUTER(INPUT__GROUP__OUTER.getName()),
155   LABEL("tobago-label"),
156   LABEL__CONTAINER("tobago-label-container"),
157   LINK("tobago-link"),
158   MESSAGES("tobago-messages"),
159   /**
160    * @deprecated Since 5.0.0. Please use {@link TobagoClass#POPOVER__BUTTON}
161    */
162   @Deprecated
163   MESSAGES__BUTTON("tobago-messages-button"),
164   MESSAGES__CONTAINER("tobago-messages-container"),
165   OBJECT("tobago-object"),
166   OUT("tobago-out"),
167   PAGE("tobago-page"),
168   PAGE__MENU_STORE("tobago-page-menuStore"),
169   PAGE__NOSCRIPT("tobago-page-noscript"),
170   PANEL("tobago-panel"),
171   POPOVER__BOX("tobago-popover-box"),
172   POPOVER__BUTTON("tobago-popover-button"),
173   PROGRESS("tobago-progress"),
174   /**
175    * @deprecated since 5.0.0
176    */
177   @Deprecated
178   SECTION("tobago-section"),
179   SECTION__CONTENT("tobago-section-content"),
180   SEGMENT_LAYOUT("tobago-segmentLayout"),
181   SELECT_BOOLEAN_CHECKBOX("tobago-selectBooleanCheckbox"),
182   SELECT_BOOLEAN_TOGGLE("tobago-selectBooleanToggle"),
183   /**
184    * @deprecated since 5.0.0
185    */
186   @Deprecated
187   SELECT_MANY_CHECKBOX("tobago-selectManyCheckbox"),
188   /**
189    * @deprecated since 5.0.0
190    */
191   @Deprecated
192   SELECT_MANY_CHECKBOX__INLINE("tobago-selectManyCheckbox-inline"),
193   SELECT_MANY_LISTBOX("tobago-selectManyListbox"),
194   SELECT_MANY_LISTBOX__OPTION("tobago-selectManyListbox-option"),
195   SELECT_MANY_SHUTTLE("tobago-selectManyShuttle"),
196   SELECT_MANY_SHUTTLE__ADD("tobago-selectManyShuttle-add"),
197   SELECT_MANY_SHUTTLE__ADD_ALL("tobago-selectManyShuttle-addAll"),
198   SELECT_MANY_SHUTTLE__HIDDEN("tobago-selectManyShuttle-hidden"),
199   SELECT_MANY_SHUTTLE__OPTION("tobago-selectManyShuttle-option"),
200   SELECT_MANY_SHUTTLE__REMOVE("tobago-selectManyShuttle-remove"),
201   SELECT_MANY_SHUTTLE__REMOVE_ALL("tobago-selectManyShuttle-removeAll"),
202   SELECT_MANY_SHUTTLE__SELECTED("tobago-selectManyShuttle-selected"),
203   SELECT_MANY_SHUTTLE__SELECTED_LABEL("tobago-selectManyShuttle-selectedLabel"),
204   SELECT_MANY_SHUTTLE__TOOL_BAR("tobago-selectManyShuttle-toolBar"),
205   SELECT_MANY_SHUTTLE__UNSELECTED("tobago-selectManyShuttle-unselected"),
206   SELECT_MANY_SHUTTLE__UNSELECTED_LABEL("tobago-selectManyShuttle-unselectedLabel"),
207   SELECT_ONE_CHOICE("tobago-selectOneChoice"),
208   SELECT_ONE_CHOICE__OPTION("tobago-selectOneChoice-option"),
209   SELECT_ONE_LISTBOX("tobago-selectOneListbox"),
210   SELECT_ONE_LISTBOX__OPTION("tobago-selectOneListbox-option"),
211   /**
212    * @deprecated since 5.0.0
213    */
214   @Deprecated
215   SELECT_ONE_RADIO("tobago-selectOneRadio"),
216   /**
217    * @deprecated since 5.0.0
218    */
219   @Deprecated
220   SELECT_ONE_RADIO__INLINE("tobago-selectOneRadio-inline"),
221   SEPARATOR("tobago-separator"),
222   SHEET("tobago-sheet"),
223   SHEET__CELL("tobago-sheet-cell"),
224   SHEET__FOOTER("tobago-sheet-footer"),
225   SHEET__BODY("tobago-sheet-body"),
226   SHEET__HEADER_CELL("tobago-sheet-headerCell"),
227   SHEET__HEADER_RESIZE("tobago-sheet-headerResize"),
228   SHEET__EXPANDED("tobago-sheet-expanded"),
229   SHEET__PAGING_TEXT("tobago-sheet-pagingText"),
230   SHEET__HEADER("tobago-sheet-header"),
231   SHEET__BODY_TABLE("tobago-sheet-bodyTable"),
232   SHEET__COLUMN_SELECTOR("tobago-sheet-columnSelector"),
233   SHEET__HEADER_TABLE("tobago-sheet-headerTable"),
234   SHEET__PAGING("tobago-sheet-paging"),
235   SHEET__PAGING_INPUT("tobago-sheet-pagingInput"),
236   SHEET__PAGING_OUTPUT("tobago-sheet-pagingOutput"),
237   SHEET__ROW("tobago-sheet-row"),
238   STARS("tobago-stars"),
239   STARS__CONTAINER("tobago-stars-container"),
240   STARS__FOCUS_BOX("tobago-stars-focusBox"),
241   STARS__PRESELECTED("tobago-stars-preselected"),
242   STARS__SELECTED("tobago-stars-selected"),
243   STARS__SLIDER("tobago-stars-slider"),
244   STARS__TOOLTIP("tobago-stars-tooltip"),
245   STARS__UNSELECTED("tobago-stars-unselected"),
246   TAB("tobago-tab"),
247   TAB__BAR_FACET("tobago-tab-barFacet"),
248   TAB__CONTENT("tobago-tab-content"),
249   TAB_GROUP("tobago-tabGroup"),
250   TEXTAREA("tobago-textarea"),
251   TEXT__JUSTIFY("tobago-text-justify"),
252   TREE("tobago-tree"),
253   TREE__EXPANDED("tobago-tree-expanded"),
254   TREE__SELECTED("tobago-tree-selected"),
255   TREE_LABEL("tobago-treeLabel"),
256   TREE_LISTBOX("tobago-treeListbox"),
257   TREE_LISTBOX__LEVEL("tobago-treeListbox-level"),
258   TREE_LISTBOX__SELECT("tobago-treeListbox-select"),
259   TREE_NODE("tobago-treeNode"),
260   TREE_NODE__TOGGLE("tobago-treeNode-toggle"),
261   TREE_SELECT("tobago-treeSelect"),
262   TREE_SELECT__LABEL("tobago-treeSelect-label");
263 
264   private final String name;
265 
266   TobagoClass(final String name) {
267     this.name = name;
268   }
269 
270   @Override
271   public String getName() {
272     return name;
273   }
274 
275   /**
276    * @deprecated since 4.0.0, use {@link BootstrapClass#valueOf(AlignItems)}
277    */
278   @Deprecated
279   public static CssItem valueOf(final AlignItems alignItems) {
280     return BootstrapClass.valueOf(alignItems);
281   }
282 
283   /**
284    * @deprecated since 4.0.0, use {@link BootstrapClass#valueOf(JustifyContent)}
285    */
286   @Deprecated
287   public static CssItem valueOf(final JustifyContent justifyContent) {
288     return BootstrapClass.valueOf(justifyContent);
289   }
290 
291   @Preliminary
292   public CssItem[] createMarkup(final Markup markup) {
293     if (markup != null) {
294       final List<CssItem> markups = new ArrayList<>();
295       for (final String markupString : markup) {
296         markups.add(new MarkupClass(this, markupString));
297       }
298       return markups.toArray(new CssItem[0]);
299     } else {
300       return null;
301     }
302   }
303 
304   private static class MarkupClass implements CssItem {
305 
306     private final TobagoClass rendererClass;
307     private final String markup;
308 
309     private MarkupClass(final TobagoClass rendererClass, final String markup) {
310       this.rendererClass = rendererClass;
311       this.markup = markup;
312     }
313 
314     @Override
315     public String getName() {
316       // These values are statistically tested length of the html class attribute
317       return rendererClass.getName() + "-markup-" + markup;
318     }
319   }
320 }