1 | <%-- $Id: reset_filters.jsp 5904 2011-12-09 13:52:53Z nicklas $ |
---|
2 | ------------------------------------------------------------------ |
---|
3 | Copyright (C) 2005 Nicklas Nordborg |
---|
4 | Copyright (C) 2006 Jari Häkkinen, Nicklas Nordborg, Martin Svensson |
---|
5 | Copyright (C) 2007 Johan Enell, Nicklas Nordborg, Martin Svensson |
---|
6 | |
---|
7 | This file is part of BASE - BioArray Software Environment. |
---|
8 | Available at http://base.thep.lu.se/ |
---|
9 | |
---|
10 | BASE is free software; you can redistribute it and/or |
---|
11 | modify it under the terms of the GNU General Public License |
---|
12 | as published by the Free Software Foundation; either version 3 |
---|
13 | of the License, or (at your option) any later version. |
---|
14 | |
---|
15 | BASE is distributed in the hope that it will be useful, |
---|
16 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
18 | GNU General Public License for more details. |
---|
19 | |
---|
20 | You should have received a copy of the GNU General Public License |
---|
21 | along with BASE. If not, see <http://www.gnu.org/licenses/>. |
---|
22 | ------------------------------------------------------------------ |
---|
23 | |
---|
24 | --%> |
---|
25 | <%@ page pageEncoding="UTF-8" session="false" |
---|
26 | import="net.sf.basedb.core.SessionControl" |
---|
27 | import="net.sf.basedb.core.Item" |
---|
28 | import="net.sf.basedb.core.ItemContext" |
---|
29 | import="net.sf.basedb.core.DbControl" |
---|
30 | import="net.sf.basedb.core.User" |
---|
31 | import="net.sf.basedb.clients.web.Base" |
---|
32 | import="net.sf.basedb.clients.web.util.HTML" |
---|
33 | import="net.sf.basedb.util.Values" |
---|
34 | import="net.sf.basedb.util.ToStringComparator" |
---|
35 | import="net.sf.basedb.util.NestedIterator" |
---|
36 | import="java.util.Iterator" |
---|
37 | import="java.util.List" |
---|
38 | import="java.util.Set" |
---|
39 | import="java.util.TreeSet" |
---|
40 | import="java.util.HashSet" |
---|
41 | import="java.util.Arrays" |
---|
42 | %> |
---|
43 | <%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> |
---|
44 | <% |
---|
45 | final SessionControl sc = Base.getExistingSessionControl(pageContext, true); |
---|
46 | final String ID = sc.getId(); |
---|
47 | final float scale = Base.getScale(sc); |
---|
48 | final String activePage = request.getParameter("page"); |
---|
49 | final DbControl dc = sc.newDbControl(); |
---|
50 | try |
---|
51 | { |
---|
52 | final User user = User.getById(dc, sc.getLoggedInUserId()); |
---|
53 | final String title = "Reset list settings for "+HTML.encodeTags(user.getName()); |
---|
54 | final List<ItemContext> inMemory = sc.getAllCurrentContexts(true, false); |
---|
55 | final List<ItemContext> inDatabase = sc.getAllCurrentContexts(false, true); |
---|
56 | final Set<Item> items = new TreeSet<Item>(new ToStringComparator<Item>(false)); |
---|
57 | final Set<Item> dbOnly = new HashSet<Item>(); |
---|
58 | Iterator<ItemContext> it = new NestedIterator(inMemory, inDatabase); |
---|
59 | for (ItemContext ctx : inMemory) |
---|
60 | { |
---|
61 | if (ctx.getNumPropertyFilters() > 0 || ctx.getSortProperty() != null) |
---|
62 | { |
---|
63 | items.add(ctx.getItemType()); |
---|
64 | } |
---|
65 | } |
---|
66 | for (ItemContext ctx : inDatabase) |
---|
67 | { |
---|
68 | if (ctx.getNumPropertyFilters() > 0 || ctx.getSortProperty() != null) |
---|
69 | { |
---|
70 | if (items.add(ctx.getItemType())) dbOnly.add(ctx.getItemType()); |
---|
71 | } |
---|
72 | } |
---|
73 | %> |
---|
74 | <base:page type="popup" title="<%=title%>"> |
---|
75 | <base:head> |
---|
76 | <script language="JavaScript"> |
---|
77 | function resetFilters() |
---|
78 | { |
---|
79 | var frm = document.forms['preferences']; |
---|
80 | frm.submit(); |
---|
81 | } |
---|
82 | function itemTypeOnChange() |
---|
83 | { |
---|
84 | var frm = document.forms['preferences']; |
---|
85 | var dbOnly = frm.item_type[frm.item_type.selectedIndex].text.indexOf('*') >= 0; |
---|
86 | frm.database.checked = dbOnly; |
---|
87 | } |
---|
88 | </script> |
---|
89 | </base:head> |
---|
90 | <base:body> |
---|
91 | <h1><%=title%><base:help helpid="userpreferences.resetfilters" /></h1> |
---|
92 | <form action="submit_user.jsp?ID=<%=ID%>" method="post" name="preferences" |
---|
93 | onsubmit="return false;"> |
---|
94 | <input type=hidden name="cmd" value="ResetFilters"> |
---|
95 | |
---|
96 | <div class="content filled"> |
---|
97 | <div> |
---|
98 | <table class="fullform smaller bottomborder"> |
---|
99 | <tr> |
---|
100 | <th>Which list?</th> |
---|
101 | <td> |
---|
102 | <select name="item_type" onchange="itemTypeOnChange()" class="selectionlist"> |
---|
103 | <option value="">- all - |
---|
104 | <% |
---|
105 | for (Item item : items) |
---|
106 | { |
---|
107 | %> |
---|
108 | <option value="<%=item.name()%>"><%=dbOnly.contains(item) ? "* " : "" %><%=item%> |
---|
109 | <% |
---|
110 | } |
---|
111 | %> |
---|
112 | </select><br> |
---|
113 | </td> |
---|
114 | </tr> |
---|
115 | <tr class="double"> |
---|
116 | <th>Location</th> |
---|
117 | <td> |
---|
118 | <input type="checkbox" name="memory" id="memory" value="1" checked disabled>In-memory<br> |
---|
119 | <input type="checkbox" name="database" id="database" value="1"><label for="database">In-database</label> |
---|
120 | </td> |
---|
121 | </tr> |
---|
122 | </table> |
---|
123 | </div> |
---|
124 | |
---|
125 | <div class="padded"> |
---|
126 | * = This setting is only in the database |
---|
127 | </div> |
---|
128 | |
---|
129 | <div class="padded"> |
---|
130 | Use this functionality if you are experiencing problems when listing |
---|
131 | items on a list page. Try first with only the 'In-memory' option selected. |
---|
132 | If that doesn't help, try the 'In-database' option. |
---|
133 | </div> |
---|
134 | |
---|
135 | </div> |
---|
136 | </form> |
---|
137 | |
---|
138 | <base:buttongroup subclass="dialogbuttons"> |
---|
139 | <base:button onclick="resetFilters();" title="Ok" /> |
---|
140 | <base:button onclick="window.close();" title="Cancel" /> |
---|
141 | </base:buttongroup> |
---|
142 | </base:body> |
---|
143 | </base:page> |
---|
144 | <% |
---|
145 | } |
---|
146 | finally |
---|
147 | { |
---|
148 | if (dc != null) dc.close(); |
---|
149 | } |
---|
150 | %> |
---|