1 | <%-- $Id: merge.jsp 6217 2012-12-14 13:05:00Z nicklas $ |
---|
2 | ------------------------------------------------------------------ |
---|
3 | Copyright (C) 2006 Jari Häkkinen, Nicklas Nordborg, Martin Svensson |
---|
4 | |
---|
5 | This file is part of BASE - BioArray Software Environment. |
---|
6 | Available at http://base.thep.lu.se/ |
---|
7 | |
---|
8 | BASE is free software; you can redistribute it and/or |
---|
9 | modify it under the terms of the GNU General Public License |
---|
10 | as published by the Free Software Foundation; either version 3 |
---|
11 | of the License, or (at your option) any later version. |
---|
12 | |
---|
13 | BASE is distributed in the hope that it will be useful, |
---|
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
16 | GNU General Public License for more details. |
---|
17 | |
---|
18 | You should have received a copy of the GNU General Public License |
---|
19 | along with BASE. If not, see <http://www.gnu.org/licenses/>. |
---|
20 | ------------------------------------------------------------------ |
---|
21 | |
---|
22 | @author Nicklas |
---|
23 | @version 2.0 |
---|
24 | --%> |
---|
25 | <%@ page pageEncoding="UTF-8" session="false" |
---|
26 | import="net.sf.basedb.core.SessionControl" |
---|
27 | import="net.sf.basedb.core.DbControl" |
---|
28 | import="net.sf.basedb.core.Item" |
---|
29 | import="net.sf.basedb.core.ItemContext" |
---|
30 | import="net.sf.basedb.core.Permission" |
---|
31 | import="net.sf.basedb.core.ReporterList" |
---|
32 | import="net.sf.basedb.core.PermissionDeniedException" |
---|
33 | import="net.sf.basedb.clients.web.Base" |
---|
34 | import="net.sf.basedb.clients.web.util.HTML" |
---|
35 | import="net.sf.basedb.util.Values" |
---|
36 | import="java.util.List" |
---|
37 | %> |
---|
38 | <%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> |
---|
39 | <%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %> |
---|
40 | <% |
---|
41 | final Item itemType = Item.REPORTERLIST; |
---|
42 | final SessionControl sc = Base.getExistingSessionControl(pageContext, true); |
---|
43 | final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null); |
---|
44 | final int itemId = cc.getId(); |
---|
45 | final String ID = sc.getId(); |
---|
46 | final float scale = Base.getScale(sc); |
---|
47 | final DbControl dc = sc.newDbControl(); |
---|
48 | try |
---|
49 | { |
---|
50 | String mergeType = request.getParameter("mergeType"); |
---|
51 | ReporterList reporterList = ReporterList.getById(dc, itemId); |
---|
52 | cc.setObject("item", reporterList); |
---|
53 | String title = "Add/keep/remove reporters: " + HTML.encodeTags(reporterList.getName()); |
---|
54 | reporterList.checkPermission(Permission.WRITE); |
---|
55 | |
---|
56 | |
---|
57 | |
---|
58 | %> |
---|
59 | |
---|
60 | <base:page type="popup" title="<%=title%>"> |
---|
61 | <base:head scripts="linkitems.js"> |
---|
62 | <script> |
---|
63 | // Validate the "Reporter list" tab |
---|
64 | function validateForm() |
---|
65 | { |
---|
66 | var frm = document.forms['merge']; |
---|
67 | if (frm.reporterLists.length == 0) |
---|
68 | { |
---|
69 | Forms.showNotification('btnAddReporterLists', 'You must select at least one other reporter list'); |
---|
70 | return false; |
---|
71 | } |
---|
72 | return true; |
---|
73 | } |
---|
74 | |
---|
75 | // Submit the form |
---|
76 | function saveSettings() |
---|
77 | { |
---|
78 | var frm = document.forms['merge']; |
---|
79 | if (validateForm()) |
---|
80 | { |
---|
81 | frm.sourceLists.value = Link.getActionIds(1, 'R').join(','); |
---|
82 | frm.submit(); |
---|
83 | } |
---|
84 | } |
---|
85 | |
---|
86 | function addReporterListsOnClick() |
---|
87 | { |
---|
88 | var frm = document.forms['merge']; |
---|
89 | var ids = Link.getListIds(frm.reporterLists, 'R'); |
---|
90 | ids[ids.length] = <%=itemId%>; |
---|
91 | var excludes = ids.join(','); |
---|
92 | var url = 'index.jsp?ID=<%=ID%>&cmd=UpdateContext&mode=selectmultiple&callback=addReporterListsCallback'; |
---|
93 | url += "&exclude="+excludes; |
---|
94 | Main.openPopup(url, 'AddReporterLists', 1050, 700); |
---|
95 | } |
---|
96 | function addReporterListsCallback(reporterListId, name) |
---|
97 | { |
---|
98 | var item = Link.getItem('R', reporterListId); |
---|
99 | if (!item) item = new Item('R', reporterListId, name); |
---|
100 | Link.addItem(document.forms['merge'].reporterLists, item); |
---|
101 | } |
---|
102 | function removeReporterListsOnClick() |
---|
103 | { |
---|
104 | Link.removeSelected(document.forms['merge'].reporterLists); |
---|
105 | } |
---|
106 | |
---|
107 | function updateImage() |
---|
108 | { |
---|
109 | var frm = document.forms['merge']; |
---|
110 | var img = document.getElementById('mergeImage'); |
---|
111 | var mergeType = frm.mergeType[frm.mergeType.selectedIndex].value; |
---|
112 | var sourceMerge = frm.sourceMerge[frm.sourceMerge.selectedIndex].value; |
---|
113 | var url = '../../images/set_operations/'+mergeType+'_'+sourceMerge+'.png'; |
---|
114 | img.src = url; |
---|
115 | } |
---|
116 | function mergeTypeOnChange() |
---|
117 | { |
---|
118 | updateImage(); |
---|
119 | } |
---|
120 | function sourceMergeOnChange() |
---|
121 | { |
---|
122 | updateImage(); |
---|
123 | } |
---|
124 | function init() |
---|
125 | { |
---|
126 | updateImage(); |
---|
127 | } |
---|
128 | </script> |
---|
129 | </base:head> |
---|
130 | <base:body onload="init()"> |
---|
131 | <h1><%=title%> <base:help helpid="reporterlist.merge" /></h1> |
---|
132 | <form action="index.jsp?ID=<%=ID%>" method="post" name="merge"> |
---|
133 | <input type="hidden" name="cmd" value="MergeItem"> |
---|
134 | |
---|
135 | <div class="content bottomborder"> |
---|
136 | <table class="fullform input100"> |
---|
137 | <tr> |
---|
138 | <th>This list</th> |
---|
139 | <td><%=HTML.encodeTags(reporterList.getName())%></td> |
---|
140 | <td rowspan="2"> |
---|
141 | <img id="mergeImage" src="../../images/set_operations/union_union.png" alt=""> |
---|
142 | </td> |
---|
143 | </tr> |
---|
144 | <tr class="big"> |
---|
145 | <th>What to do</th> |
---|
146 | <td> |
---|
147 | <select name="mergeType" onchange="mergeTypeOnChange()"> |
---|
148 | <option value="union" <%="union".equals(mergeType) ? "selected" : ""%> |
---|
149 | >Add reporters to |
---|
150 | <option value="intersection" <%="intersection".equals(mergeType) ? "selected" : ""%> |
---|
151 | >Keep reporters in |
---|
152 | <option value="complement" <%="complement".equals(mergeType) ? "selected" : ""%> |
---|
153 | >Remove reporters from |
---|
154 | </select><br> |
---|
155 | this list that are present in |
---|
156 | <br> |
---|
157 | <select name="sourceMerge" onchange="sourceMergeOnChange()"> |
---|
158 | <option value="union" <%="intersection".equals(mergeType) ? "" : "selected"%> |
---|
159 | >some of |
---|
160 | <option value="intersection" <%="intersection".equals(mergeType) ? "selected" : ""%> |
---|
161 | >all of |
---|
162 | </select><br> |
---|
163 | the reporter lists selected below. |
---|
164 | <p> |
---|
165 | After the operation this list will |
---|
166 | contain reporters from the gray-colored areas in the image. |
---|
167 | |
---|
168 | </td> |
---|
169 | </tr> |
---|
170 | <tr class="dynamic"> |
---|
171 | <th>Reporter lists</th> |
---|
172 | <td colspan="2"> |
---|
173 | <div class="selectionlist"> |
---|
174 | <table> |
---|
175 | <tr> |
---|
176 | <td> |
---|
177 | <select name="reporterLists" size="10" multiple> |
---|
178 | </select> |
---|
179 | <input type="hidden" name="sourceLists" value=""> |
---|
180 | </td> |
---|
181 | <td> |
---|
182 | <td style="vertical-align: top;"> |
---|
183 | <base:buttongroup vertical="true"> |
---|
184 | <base:button |
---|
185 | id="btnAddReporterLists" |
---|
186 | subclass="leftaligned" |
---|
187 | style="width: 12em;" |
---|
188 | onclick="addReporterListsOnClick()" |
---|
189 | title="Add reporter lists…" |
---|
190 | tooltip="Add reporter lists" |
---|
191 | /> |
---|
192 | <base:button |
---|
193 | subclass="leftaligned" |
---|
194 | style="width: 12em;" |
---|
195 | onclick="removeReporterListsOnClick()" |
---|
196 | title="Remove" |
---|
197 | tooltip="Remove the selected reporter lists" |
---|
198 | /> |
---|
199 | </base:buttongroup> |
---|
200 | <input type="hidden" name="sourceLists" value=""> |
---|
201 | </td> |
---|
202 | </tr> |
---|
203 | </table> |
---|
204 | </div> |
---|
205 | </td> |
---|
206 | </tr> |
---|
207 | </table> |
---|
208 | </div> |
---|
209 | </form> |
---|
210 | |
---|
211 | <base:buttongroup subclass="dialogbuttons"> |
---|
212 | <base:button onclick="saveSettings()" title="Ok" /> |
---|
213 | <base:button onclick="window.close()" title="Cancel" /> |
---|
214 | </base:buttongroup> |
---|
215 | </base:body> |
---|
216 | </base:page> |
---|
217 | <% |
---|
218 | } |
---|
219 | finally |
---|
220 | { |
---|
221 | if (dc != null) dc.close(); |
---|
222 | } |
---|
223 | %> |
---|