1<%-- 2CDDL HEADER START 3 4The contents of this file are subject to the terms of the 5Common Development and Distribution License (the "License"). 6You may not use this file except in compliance with the License. 7 8See LICENSE.txt included in this distribution for the specific 9language governing permissions and limitations under the License. 10 11When distributing Covered Code, include this CDDL HEADER in each 12file and include the License file at LICENSE.txt. 13If applicable, add the following below this CDDL HEADER, with the 14fields enclosed by brackets "[]" replaced with your own identifying 15information: Portions Copyright [yyyy] [name of copyright owner] 16 17CDDL HEADER END 18 19Copyright (c) 2007, 2021, Oracle and/or its affiliates. All rights reserved. 20Portions Copyright 2011 Jens Elkner. 21Portions Copyright (c) 2020, Chris Fraire <cfraire@me.com>. 22 23--%> 24<%@page import=" 25java.util.Map, 26java.util.Set, 27java.util.SortedSet, 28java.util.TreeSet, 29 30org.opengrok.indexer.configuration.Group, 31org.opengrok.indexer.configuration.Project, 32org.opengrok.indexer.search.QueryBuilder, 33org.opengrok.web.PageConfig, 34org.opengrok.web.ProjectHelper, 35org.opengrok.indexer.web.QueryParameters, 36org.opengrok.indexer.web.SearchHelper, 37org.opengrok.indexer.web.Util, 38org.opengrok.indexer.web.messages.MessagesUtils" 39%> 40<% 41/* ---------------------- menu.jspf start --------------------- */ 42{ 43 PageConfig cfg = PageConfig.get(request); 44 ProjectHelper ph = ProjectHelper.getInstance(cfg); 45 String messages; 46 Set<Project> projects = ph.getAllProjects(); 47 int projectsSize = ph.getAllUngrouped().size(); 48 if (ph.getGroups().size() > 0 && ph.getAllUngrouped().size() > 0) 49 projectsSize++; 50 for (Group group : ph.getGroups()) { 51 projectsSize++; 52 projectsSize += ph.getAllGrouped(group).size(); 53 } 54 QueryBuilder queryParams = cfg.getQueryBuilder(); 55%> 56<script type="text/javascript">/* <![CDATA[ */ 57document.domReady.push(function() { domReadyMenu(); }); 58/* ]]> */ 59</script> 60<form action="<%= request.getContextPath() %>/search" id="sbox" onsubmit="searchSubmit(this)"> 61<div id="qtbl"> 62 <table aria-label="query table"> 63 <% 64 if (projects.size() != 0) { 65 %> 66 <tbody id="ptbl"> 67 <tr> 68 <td id="projectLabelTd"> 69 <label for="<%= QueryParameters.PROJECT_SEARCH_PARAM %>">Project(s)</label> 70 </td> 71 <td colspan="2"> 72 <select tabindex="8" class="q" id="<%= QueryParameters.PROJECT_SEARCH_PARAM %>" 73 name="<%= QueryParameters.PROJECT_SEARCH_PARAM %>" multiple="multiple" size="<%= 74 Math.min(15, projectsSize) %>"><% 75 SortedSet<String> pRequested = new TreeSet<>(cfg.getRequestedProjects()); 76 for (Group group : ph.getGroups()) { 77 Set<Project> groupProjects = ph.getAllGrouped(group); 78 if (groupProjects.size() > 0) { 79 %><optgroup label="<%= group.getName() %>"><% 80 for (Project p : groupProjects) { 81 if (!p.isIndexed()) { 82 continue; 83 } 84 85 // TODO below "selected" has no effect if one refreshes the page 86 // with F5 87 88 %><option value="<%= p.getName() %>"<% 89 if (pRequested.contains(p.getName())) { 90 %> selected="selected"<% 91 pRequested.remove(p.getName()); 92 } 93 if (!(messages = MessagesUtils.messagesToJson(p)).isEmpty()) { 94 %> data-messages='<%= messages %>' data-messages-level='<%= MessagesUtils.getMessageLevel(p.getName()) %>' <% 95 } 96 %>><%= Util.formQuoteEscape(p.getName()) %></option><% 97 } 98 %></optgroup><% 99 } 100 } 101 102 // Handle projects not listed in any group. 103 if (ph.getGroups().size() > 0 && ph.getAllUngrouped().size() > 0) { 104 %><optgroup label="Other"><% 105 } 106 for (Project p : ph.getAllUngrouped()) { 107 if (!p.isIndexed()) { 108 continue; 109 } 110 111 %><option value="<%= p.getName() %>"<% 112 if (pRequested.contains(p.getName())) { 113 %> selected="selected"<% 114 pRequested.remove(p.getName()); 115 } 116 if (!(messages = MessagesUtils.messagesToJson(p)).isEmpty()) { 117 %> data-messages='<%= messages %>' data-messages-level='<%= MessagesUtils.getMessageLevel(p.getName()) %>' <% 118 } 119 %>><%= Util.formQuoteEscape(p.getName()) %></option><% 120 } 121 if (ph.getGroups().size() > 0 && ph.getAllUngrouped().size() > 0) { 122 %></optgroup><% 123 } 124 %></select> 125 </td> 126 </tr> 127 <tr> 128 <td colspan="3" > 129 <button tabindex="6" type="button" 130 onclick="selectAllProjects(); return false;" 131 >select all</button> 132 133 <button tabindex="7" type="button" 134 onclick="invertAllProjects(); return false;" 135 >invert selection</button> 136 137 <button tabindex="8" type="button" 138 onclick="deselectAllProjects(); return false;" 139 >clear</button> 140 </td> 141 </tr> 142 </tbody> 143 <% 144 } 145 %> 146 <tbody> 147 <tr> 148 <td><label for="<%= QueryParameters.FULL_SEARCH_PARAM %>" 149 title="Text token(s) or other fields to be found (Lucene query--this is not full text)"> 150 Full Search</label></td> 151 <td colspan="2"><input tabindex="1" class="q" 152 name="<%= QueryParameters.FULL_SEARCH_PARAM %>" 153 id="<%= QueryParameters.FULL_SEARCH_PARAM %>" type="text" value="<%= 154 Util.formQuoteEscape(queryParams.getFreetext()) %>"/></td> 155 </tr> 156 <tr> 157 <td><label for="<%= QueryParameters.DEFS_SEARCH_PARAM %>" 158 title="Definitions of function/variable/class">Definition</label></td> 159 <td colspan="2"><input class="q" tabindex="2" 160 name="<%= QueryParameters.DEFS_SEARCH_PARAM %>" 161 id="<%= QueryParameters.DEFS_SEARCH_PARAM %>" type="text" value="<%= 162 Util.formQuoteEscape(queryParams.getDefs()) %>"/></td> 163 </tr> 164 <tr> 165 <td><label for="<%= QueryParameters.REFS_SEARCH_PARAM %>" 166 title="Usage of function/variable/class">Symbol</label></td> 167 <td colspan="2"><input class="q" tabindex="3" 168 name="<%= QueryParameters.REFS_SEARCH_PARAM %>" 169 id="<%= QueryParameters.REFS_SEARCH_PARAM %>" type="text" value="<%= 170 Util.formQuoteEscape(queryParams.getRefs()) %>"/></td> 171 </tr> 172 <tr> 173 <td><label for="<%= QueryParameters.PATH_SEARCH_PARAM %>" 174 title="Path or parts of it (no need to use separators)">File Path</label></td> 175 <td colspan="2"><input class="q" tabindex="4" 176 name="<%= QueryParameters.PATH_SEARCH_PARAM %>" 177 id="<%= QueryParameters.PATH_SEARCH_PARAM %>" type="text" value="<%= 178 Util.formQuoteEscape(queryParams.getPath()) %>"/></td> 179 </tr> 180 <% 181 if (cfg.getEnv().isHistoryEnabled()) { 182 %> 183 <tr> 184 <td><label for="<%= QueryParameters.HIST_SEARCH_PARAM %>" 185 title="Search in project(s) repository log messages">History</label></td> 186 <td colspan="2"><input class="q" tabindex="5" 187 name="<%= QueryParameters.HIST_SEARCH_PARAM %>" 188 id="<%= QueryParameters.HIST_SEARCH_PARAM %>" type="text" value="<%= 189 Util.formQuoteEscape(queryParams.getHist()) %>"/></td> 190 </tr> 191 <% 192 } 193 %> 194 <tr> 195 <td id="typeLabelTd"><label for="<%= QueryParameters.TYPE_SEARCH_PARAM %>">Type</label></td> 196 <td><select class="q" tabindex="6" name="<%= QueryParameters.TYPE_SEARCH_PARAM %>" 197 id="<%= QueryParameters.TYPE_SEARCH_PARAM %>"><% 198 String selection = queryParams.getType(); 199 %> 200 <option value="">Any</option><% 201 for (Map.Entry<String, String> d : SearchHelper.getFileTypeDescriptions()) { 202 %> 203 <option value="<%= Util.formQuoteEscape(d.getKey()) %>"<% 204 if (d.getKey().equals(selection)) { 205 %> selected="selected"<% 206 } 207 %>><%= Util.htmlize(d.getValue()) %></option><% 208 } 209 %> 210 </select> 211 </td> 212 <td id="type-select-container"> 213 <!-- filled with javascript --> 214 </td> 215 </tr> 216 </tbody> 217</table> 218<div id="form-controls"> 219 <input tabindex="9" class="submit btn" onclick="$('#xrd').val(''); $('#sbox').submit()" 220 type="submit" value="Search"/> 221 <input tabindex="10" class="submit btn" onclick="clearSearchFrom();" 222 type="button" value="Clear"/> 223 <input tabindex="11" class="submit btn" onclick="window.open('help.jsp', '_blank');" 224 type="button" value="Help"/> 225 <input tabindex="12" class="submit btn" onclick="window.open('settings.jsp', '_self');" 226 type="button" value="Settings"/> 227</div> 228</div> 229<div id="ltbl"> 230 <!-- filled with javascript --> 231</div> 232<input type="hidden" id="<%= QueryParameters.NO_REDIRECT_PARAM %>" 233 name="<%= QueryParameters.NO_REDIRECT_PARAM %>" value=""/> 234<input type="hidden" id="<%= QueryParameters.NUM_SELECTED_PARAM %>" 235 name="<%= QueryParameters.NUM_SELECTED_PARAM %>" value=""/> 236</form> 237<div class="clearfix"></div> 238<% 239} 240/* ---------------------- menu.jspf end --------------------- */ 241%> 242