1 | <%-- $Id: edit_reporterlist.jsp 6314 2013-09-02 12:47:53Z 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="net.sf.basedb.core.plugin.GuiContext" |
---|
37 | import="net.sf.basedb.clients.web.extensions.ExtensionsControl" |
---|
38 | import="net.sf.basedb.clients.web.extensions.JspContext" |
---|
39 | import="net.sf.basedb.clients.web.extensions.edit.EditUtil" |
---|
40 | import="net.sf.basedb.util.extensions.ExtensionsInvoker" |
---|
41 | import="java.util.List" |
---|
42 | %> |
---|
43 | <%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> |
---|
44 | <%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %> |
---|
45 | <%@ taglib prefix="ext" uri="/WEB-INF/extensions.tld" %> |
---|
46 | <% |
---|
47 | final Item itemType = Item.REPORTERLIST; |
---|
48 | final SessionControl sc = Base.getExistingSessionControl(pageContext, true); |
---|
49 | final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null); |
---|
50 | final int itemId = cc.getId(); |
---|
51 | final String ID = sc.getId(); |
---|
52 | final float scale = Base.getScale(sc); |
---|
53 | final DbControl dc = sc.newDbControl(); |
---|
54 | try |
---|
55 | { |
---|
56 | String title = null; |
---|
57 | String name = null; |
---|
58 | ReporterList reporterList = null; |
---|
59 | boolean addReporters = false; |
---|
60 | boolean mergeReporterLists = false; |
---|
61 | int numSelectedLists = cc.getSelected().size(); |
---|
62 | String formId = request.getParameter("formId"); |
---|
63 | String fromContext = Values.getString(request.getParameter("fromContext"), "REPORTER"); |
---|
64 | String subContext = request.getParameter("subContext"); |
---|
65 | |
---|
66 | if (itemId == 0) |
---|
67 | { |
---|
68 | title = "Create reporter list"; |
---|
69 | cc.removeObject("item"); |
---|
70 | addReporters = Values.getBoolean(request.getParameter("addReporters")); |
---|
71 | mergeReporterLists = !addReporters && numSelectedLists > 0; |
---|
72 | name = request.getParameter("name"); |
---|
73 | if (name == null) name = Values.getString(cc.getPropertyValue("name"), "New reporter list"); |
---|
74 | } |
---|
75 | else |
---|
76 | { |
---|
77 | reporterList = ReporterList.getById(dc, itemId); |
---|
78 | reporterList.checkPermission(Permission.WRITE); |
---|
79 | name = reporterList.getName(); |
---|
80 | cc.setObject("item", reporterList); |
---|
81 | title = "Edit reporter list -- " + HTML.encodeTags(reporterList.getName()); |
---|
82 | } |
---|
83 | |
---|
84 | JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.item(itemType), reporterList); |
---|
85 | ExtensionsInvoker invoker = EditUtil.useEditExtensions(jspContext); |
---|
86 | %> |
---|
87 | <base:page type="popup" title="<%=title%>" id="edit-page"> |
---|
88 | <base:head scripts="tabcontrol-2.js,~reporterlists.js" styles="tabcontrol.css"> |
---|
89 | <ext:scripts context="<%=jspContext%>" /> |
---|
90 | <ext:stylesheets context="<%=jspContext%>" /> |
---|
91 | </base:head> |
---|
92 | <base:body> |
---|
93 | <h1><%=title%> <base:help tabcontrol="settings" /></h1> |
---|
94 | <div id="page-data" class="datacontainer" |
---|
95 | data-num-selected-lists="<%=numSelectedLists %>" |
---|
96 | data-add-reporters="<%=addReporters ? formId : "" %>" |
---|
97 | ></div> |
---|
98 | <form action="index.jsp?ID=<%=ID%>" method="post" name="reporterList"> |
---|
99 | <input type="hidden" name="cmd" value="UpdateItem"> |
---|
100 | <input type="hidden" name="fromContext" value="<%=fromContext%>"> |
---|
101 | <% |
---|
102 | if (subContext != null) |
---|
103 | { |
---|
104 | %> |
---|
105 | <input type="hidden" name="subContext" value="<%=subContext%>"> |
---|
106 | <% |
---|
107 | } |
---|
108 | %> |
---|
109 | <t:tabcontrol id="settings" |
---|
110 | subclass="content dialogtabcontrol" |
---|
111 | position="bottom" remember="<%=reporterList != null%>" |
---|
112 | extensions="<%=invoker%>"> |
---|
113 | <t:tab id="info" title="Reporter list" helpid="reporterlist.edit"> |
---|
114 | <table class="fullform input100"> |
---|
115 | <tr> |
---|
116 | <th>Name</th> |
---|
117 | <td><input class="text required auto-init" data-auto-init="<%=reporterList == null ? "focus-select" : "focus" %>" |
---|
118 | type="text" name="name" |
---|
119 | value="<%=HTML.encodeTags(name)%>" |
---|
120 | maxlength="<%=ReporterList.MAX_NAME_LENGTH%>"></td> |
---|
121 | <td></td> |
---|
122 | </tr> |
---|
123 | <tr> |
---|
124 | <th>External ID</th> |
---|
125 | <td><input class="text" type="text" name="external_id" |
---|
126 | value="<%=HTML.encodeTags(reporterList == null ? Values.getString(cc.getPropertyValue("externalId")) : reporterList.getExternalId())%>" |
---|
127 | maxlength="<%=ReporterList.MAX_EXTERNAL_ID_LENGTH%>"></td> |
---|
128 | <td></td> |
---|
129 | </tr> |
---|
130 | <% |
---|
131 | if (addReporters) |
---|
132 | { |
---|
133 | %> |
---|
134 | <tr> |
---|
135 | <th>Which reporters?</th> |
---|
136 | <td> |
---|
137 | <input type="radio" name="which" id="whichSelected" value="selected" |
---|
138 | ><label for="whichSelected" id="lblSelected">Selected items</label><br> |
---|
139 | <input type="radio" name="which" id="whichPage" value="page" |
---|
140 | ><label for="whichPage">Current page</label><br> |
---|
141 | <input type="radio" name="which" id="whichAll" value="all" checked |
---|
142 | ><label for="whichAll">All pages</label><br> |
---|
143 | </td> |
---|
144 | <td></td> |
---|
145 | </tr> |
---|
146 | <% |
---|
147 | } |
---|
148 | else if (mergeReporterLists) |
---|
149 | { |
---|
150 | %> |
---|
151 | <tr> |
---|
152 | <th>Add reporters?</th> |
---|
153 | <td> |
---|
154 | <input type="radio" name="create" id="createEmpty" value="" |
---|
155 | ><label for="createEmpty" |
---|
156 | title="The new reporter list will be empty">No</label><br> |
---|
157 | <input type="radio" name="create" id="createUnion" value="union" checked |
---|
158 | ><label for="createUnion" |
---|
159 | title="The new reporter list contains all reporters from the selected lists" |
---|
160 | >Union of selected lists</label> |
---|
161 | <base:icon image="set_operations/union_small.png" /><br> |
---|
162 | <input type="radio" name="create" id="createIntersection" value="intersection" |
---|
163 | ><label for="createIntersection" |
---|
164 | title="The new reporter lists contains only reporters that are present in ALL selected lists" |
---|
165 | >Intersection of selected lists</label> |
---|
166 | <base:icon image="set_operations/intersection_small.png" /><br> |
---|
167 | <input type="radio" name="create" id="createCount" value="count" |
---|
168 | ><label for="createCount" |
---|
169 | title="The new reporter lists contains only reporters that are present in some of selected lists" |
---|
170 | >Present in at least</label> |
---|
171 | <input type="text" class="text" name="minCount" id="minCount" |
---|
172 | style="width: 3em;" maxlength="2" value="1"> |
---|
173 | of the selected lists (1-<%=numSelectedLists%>). |
---|
174 | <br> |
---|
175 | </td> |
---|
176 | <td></td> |
---|
177 | </tr> |
---|
178 | <% |
---|
179 | } |
---|
180 | %> |
---|
181 | <tr class="dynamic"> |
---|
182 | <th>Description</th> |
---|
183 | <td> |
---|
184 | <textarea class="text" rows="6" name="description" id="description" |
---|
185 | ><%=HTML.encodeTags(reporterList == null ? cc.getPropertyValue("description") : reporterList.getDescription())%></textarea> |
---|
186 | </td> |
---|
187 | <td style="width: 20px;"> |
---|
188 | <base:zoom textarea="description" title="Description" /> |
---|
189 | </td> |
---|
190 | </tr> |
---|
191 | </table> |
---|
192 | </t:tab> |
---|
193 | </t:tabcontrol> |
---|
194 | </form> |
---|
195 | |
---|
196 | <div class="legend"> |
---|
197 | <base:icon image="required.png" />= required information |
---|
198 | </div> |
---|
199 | |
---|
200 | <base:buttongroup subclass="dialogbuttons"> |
---|
201 | <base:button id="btnSave" title="Save" /> |
---|
202 | <base:button id="close" title="Cancel" /> |
---|
203 | </base:buttongroup> |
---|
204 | </base:body> |
---|
205 | </base:page> |
---|
206 | <% |
---|
207 | } |
---|
208 | finally |
---|
209 | { |
---|
210 | if (dc != null) dc.close(); |
---|
211 | } |
---|
212 | %> |
---|