001// ***************************************************************************************************************************
002// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.  See the NOTICE file *
003// * distributed with this work for additional information regarding copyright ownership.  The ASF licenses this file        *
004// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance            *
005// * with the License.  You may obtain a copy of the License at                                                              *
006// *                                                                                                                         *
007// *  http://www.apache.org/licenses/LICENSE-2.0                                                                             *
008// *                                                                                                                         *
009// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an  *
010// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the License for the        *
011// * specific language governing permissions and limitations under the License.                                              *
012// ***************************************************************************************************************************
013package org.apache.juneau.rest.widget;
014
015import static org.apache.juneau.dto.html5.HtmlBuilder.*;
016
017import org.apache.juneau.dto.html5.*;
018import org.apache.juneau.internal.*;
019import org.apache.juneau.rest.*;
020
021/**
022 * Widget that returns back a list of hyperlinks for rendering the contents of a page in the various default styles.
023 *
024 * <p>
025 * The variable it resolves is <js>"$W{ThemeMenuItem}"</js>.
026 *
027 * <h5 class='section'>See Also:</h5><ul>
028 *    <li class='link'><a class="doclink" href="../../../../../index.html#jrs.HtmlPredefinedWidgets">Predefined Widgets</a>
029 *    <li class='link'><a class="doclink" href="../../../../../index.html#jrs.HtmlWidgets">Widgets</a>
030 * </ul>
031 */
032public class ThemeMenuItem extends MenuItemWidget {
033
034   private static final String[] BUILT_IN_STYLES = {"devops", "light", "original", "dark"};
035
036   @Override /* Widget */
037   public String getLabel(RestRequest req, RestResponse res) {
038      return "themes";
039   }
040
041   @Override /* MenuItemWidget */
042   public Div getContent(RestRequest req, RestResponse res) {
043      Div div = div();
044      for (String s : BUILT_IN_STYLES) {
045         java.net.URI uri = req.getUri(true, CollectionUtils.<String,Object>map("stylesheet","htdocs/themes/"+s+".css"));
046         div.children(a(uri, s), br());
047      }
048      return div;
049   }
050}