menu.jspf revision 117599e68158f1cdc904c452d5948136744e3e4d
<%--
$Id$
CDDL HEADER START
The contents of this file are subject to the terms of the
Common Development and Distribution License (the "License").
You may not use this file except in compliance with the License.
See LICENSE.txt included in this distribution for the specific
language governing permissions and limitations under the License.
When distributing Covered Code, include this CDDL HEADER in each
file and include the License file at LICENSE.txt.
If applicable, add the following below this CDDL HEADER, with the
fields enclosed by brackets "[]" replaced with your own identifying
information: Portions Copyright [yyyy] [name of copyright owner]
CDDL HEADER END
Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved.
Portions Copyright 2011 Jens Elkner.
--%><%@page import="java.util.TreeSet"%>
<%@page import="java.util.Set"%>
<%@page import="java.util.LinkedList"%>
<%@page import="org.opensolaris.opengrok.configuration.Group"%>
<%@page import="org.opensolaris.opengrok.web.ProjectHelper"%>
<%@page import="org.opensolaris.opengrok.web.SearchHelper"%>
<%@page import="java.util.Map"%>
<%@page import="
java.util.SortedSet,
java.util.TreeMap,
java.util.Map.Entry,
java.util.List,
java.util.HashMap,
java.util.ArrayList,
org.opensolaris.opengrok.configuration.Project,
org.opensolaris.opengrok.search.QueryBuilder,
org.opensolaris.opengrok.web.PageConfig,
org.opensolaris.opengrok.web.Prefix,
org.opensolaris.opengrok.web.Util"
%><%
/* ---------------------- menu.jspf start --------------------- */
{
// PageConfig cfg = PageConfig.get(request);
ProjectHelper ph = ProjectHelper.getInstance(cfg);
Set<Project> projects = ph.getAllProjects();
if (projects == null) {
projects = new TreeSet<>();
}
int projectsSize = ph.getAllUngrouped().size();
if(ph.getGroups().size() > 0 && ph.getAllUngrouped().size() > 0)
projectsSize++;
for (Group group : ph.getGroups()) {
projectsSize++;
projectsSize += ph.getAllGrouped(group).size();
}
TreeMap<String, String> pMap = new TreeMap<>();
QueryBuilder queryParams = cfg.getQueryBuilder();
if (projects.size() != 0) {
for (Project p : projects) {
String name = p.getDescription();
String esc = Util.formQuoteEscape(p.getDescription());
pMap.put(name, esc);
}
StringBuilder jsProjects = new StringBuilder(64);
jsProjects.append('\'');
for (String name : cfg.getRequestedProjects()) {
jsProjects.append(name).append("','");
}
if (jsProjects.length() > 1) {
jsProjects.setLength(jsProjects.length()-2);
} else {
jsProjects.setLength(0);
}
%>
<script type="text/javascript">/* <![CDATA[ */
document.projects = [ <%= Util.encode(jsProjects.toString())
%> ];document.xrefPath = '<%= request.getContextPath() + Prefix.XREF_P
%>';document.domReady.push(function() { domReadyMenu(); });
/* ]]> */
</script><%
}
%>
<form action="search" id="sbox">
<div id="qtbl">
<table>
<tr>
<td><label for="s1" title="The text token(s) or other fields to be found (lucene query, this is not full text!)">Full&nbsp;Search</label></td>
<td><input tabindex="1" class="q" name="q" id="q" type="text" value="<%=
Util.formQuoteEscape(queryParams.getFreetext()) %>"/></td>
</tr>
<tr>
<td><label for="s2" title="Definition of function/variable/class">Definition</label></td>
<td><input class="q" tabindex="2" name="defs" id="defs" type="text" value="<%=
Util.formQuoteEscape(queryParams.getDefs()) %>"/></td>
</tr>
<tr>
<td><label for="s3" title="Usage of function/variable/class">Symbol</label></td>
<td><input class="q" tabindex="3" name="refs" id="refs" type="text" value="<%=
Util.formQuoteEscape(queryParams.getRefs()) %>"/></td>
</tr>
<tr>
<td><label for="s4" title="path or parts of it, no need to use dividers">File&nbsp;Path</label></td>
<td><input class="q" tabindex="4" name="path" id="path" type="text" value="<%=
Util.formQuoteEscape(queryParams.getPath()) %>"/></td>
</tr>
<tr>
<td><label for="s5" title="Search in log messages">History</label></td>
<td><input class="q" tabindex="5" name="hist" id="hist" type="text" value="<%=
Util.formQuoteEscape(queryParams.getHist()) %>"/></td>
</tr>
<tr>
<td><label for="s5">Type</label></td>
<td><select class="q" tabindex="6" name="type" id="type"><%
String selection = queryParams.getType();
%>
<option value="">Any</option><%
for (Map.Entry<String, String> d : SearchHelper.getFileTypeDescriptions()) {
%>
<option value="<%= Util.formQuoteEscape(d.getKey()) %>"<%
if (d.getKey().equals(selection)) {
%> selected="selected"<%
}
%>><%= Util.htmlize(d.getValue()) %></option><%
}
%>
</select>
</td>
</tr>
<%-- TODO Bug 11749
<%
if (projects.size() != 0) {
String imgDir = cfg.getCssDir() + "/img/";
%>
<tr>
<td>Project(s)</td>
<td>
<table class="combo_table" id="combotable">
<tbody>
<tr>
<td class="combo_td1"><div class="combo_div4"
style="background: transparent url(<%=
imgDir %>transparent_pixel.gif)
repeat scroll 0% 0%;"><input
class="combo_input1 combo_input" id="project"
name="project" size="25"
value="<%= cfg.getRequestedProjectsAsString()
%>"/></div>
</td>
<td valign="top" align="left" class="combo_td2"
id="combotable_button"><a
onclick='javascript: $("#project").click();
$("#project").click();'/><img style="display: none;"
alt="" src="<%= imgDir %>button2.png"/>
</td>
</tr>
</tbody>
</table></td>
</tr><%
}
%>
--%>
</table>
<div id="form-controls">
<input tabindex="9" class="submit" type="submit" value="Search"/>
<input tabindex="10" class="submit" onclick="javascript: clearSearchFrom();"
type="button" value="Clear"/>
<a href="help.jsp" target="_blank" class="help btn" title="Help" tabindex="11" />Help</a>
</div>
</div><%
if (projects.size() != 0) {
%>
<div id="ptbl">
<p><label for="project">In Project(s)</label>
<button tabindex="6" type="button"
onclick="javascript: selectAllProjects(); return false;"
>select all</button>&nbsp;<button tabindex="7" type="button"
onclick="javascript: invertAllProjects(); return false;"
>invert selection</button>&nbsp;<button tabindex="8" type="button"
onclick="javascript: deselectAllProjects(); return false;"
>clear</button></p>
<select tabindex="8" class="q" id="project"
name="project" multiple="multiple" size="<%=
Math.min(15, projectsSize) %>"><%
SortedSet<String> pRequested = cfg.getRequestedProjects();
for ( Group group : ph.getGroups() ) {
Set<Project> groupProjects = ph.getAllGrouped(group);
if ( groupProjects.size() > 0) {
%><optgroup label="<%= group.getName() %>"><%
for (Project p : groupProjects) {
// TODO below "selected" has no effect if one refreshes the page
// with F5
%><option value="<%= p.getDescription() %>"<%
if (pRequested.contains(p.getDescription())) {
%> selected="selected"<%
}
%>><%= Util.formQuoteEscape(p.getDescription()) %></option><%
}
%></optgroup><%
}
}
if(ph.getGroups().size() > 0 && ph.getAllUngrouped().size() > 0) {
%><optgroup label="Other"><%
}
for ( Project p : ph.getAllUngrouped()) {
%><option value="<%= p.getDescription() %>"<%
if (pRequested.contains(p.getDescription())) {
%> selected="selected"<%
}
%>><%= Util.formQuoteEscape(p.getDescription()) %></option><%
}
if(ph.getGroups().size() > 0 && ph.getAllUngrouped().size() > 0) {
%></optgroup><%
}
%></select>
</div><%
}
%>
<div id="ltbl">
<!-- filled with javascript -->
</div>
</form>
<div class="clearfix"></div>
<%
}
/* ---------------------- menu.jspf end --------------------- */
%>