001/*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.apache.juneau.rest.server.widget;
018
019import org.apache.juneau.rest.server.*;
020import org.apache.juneau.rest.server.converter.*;
021
022/**
023 * Widget that returns a menu-item drop-down form for entering BeanQuery search/view/sort/paging arguments
024 * (<c>search</c>/<c>view</c>/<c>sort</c>/<c>position</c>/<c>limit</c> &mdash; see {@link Queryable} and
025 * {@link org.apache.juneau.http.BeanQueryRequest}).
026 *
027 * <p>
028 * The variable it resolves is <js>"$W{QueryMenuItem}"</js>.
029 *
030 * <h5 class='section'>Example:</h5>
031 * <p class='bjava'>
032 *    <ja>@Rest</ja>(widgets=QueryMenuItem.<jk>class</jk>)
033 *    <ja>@HtmlDocConfig</ja>(navlinks={<js>"$W{QueryMenuItem}"</js>})
034 *    <jk>public class</jk> MyResource <jk>extends</jk> BasicRestServlet {}
035 * </p>
036 *
037 * <h5 class='section'>See Also:</h5><ul>
038 *    <li class='jc'>{@link Queryable}
039 *    <li class='jc'>{@link org.apache.juneau.http.BeanQueryRequest}
040 *    <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/HtmlPredefinedWidgets">Predefined Widgets</a>
041 *    <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/HtmlWidgets">Widgets</a>
042 * </ul>
043 */
044public class QueryMenuItem extends MenuItemWidget {
045
046   @Override /* Overridden from MenuItemWidget */
047   public String getContent(RestRequest req, RestResponse res) {
048      return loadHtml(req, "QueryMenuItem.html");
049   }
050
051   @Override /* Overridden from MenuItemWidget */
052   public String getLabel(RestRequest req, RestResponse res) {
053      return "query";
054   }
055
056   /**
057    * Returns CSS for the tooltips.
058    */
059   @Override
060   public String getStyle(RestRequest req, RestResponse res) {
061      return super.getStyle(req, res) + "\n" + loadStyle(req, "styles/QueryMenuItem.css");
062   }
063}