source: trunk/www/views/reporterlists/edit_reporterlist.jsp @ 4305

Last change on this file since 4305 was 4305, checked in by Nicklas Nordborg, 15 years ago

References #1015: Add reporter list from tables that list reporters/reporter info

It is now possible to create reporter lists from features, wells and raw data, eg. all DataQuery?-based item types. Creating the lists using queries from the dynamic database needs a different solution.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 9.4 KB
Line 
1<%-- $Id: edit_reporterlist.jsp 4305 2008-05-21 11:11:20Z nicklas $
2  ------------------------------------------------------------------
3  Copyright (C) 2006 Jari Hakkinen, 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 2
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 this program; if not, write to the Free Software
20  Foundation, Inc., 59 Temple Place - Suite 330,
21  Boston, MA  02111-1307, USA.
22  ------------------------------------------------------------------
23
24  @author Nicklas
25  @version 2.0
26--%>
27<%@ page session="false"
28  import="net.sf.basedb.core.SessionControl"
29  import="net.sf.basedb.core.DbControl"
30  import="net.sf.basedb.core.Item"
31  import="net.sf.basedb.core.ItemContext"
32  import="net.sf.basedb.core.Permission"
33  import="net.sf.basedb.core.ReporterList"
34  import="net.sf.basedb.core.PermissionDeniedException"
35  import="net.sf.basedb.clients.web.Base"
36  import="net.sf.basedb.clients.web.util.HTML"
37  import="net.sf.basedb.util.Values"
38  import="java.util.List"
39%>
40<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
41<%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %>
42<%
43final Item itemType = Item.REPORTERLIST;
44final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
45final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null);
46final int itemId = cc.getId();
47final String ID = sc.getId();
48final float scale = Base.getScale(sc);
49final DbControl dc = sc.newDbControl();
50try
51{
52  String title = null;
53  String name = null;
54  ReporterList reporterList = null;
55  boolean addReporters = false;
56  boolean mergeReporterLists = false;
57  int numSelectedLists = cc.getSelected().size();
58  String formId = Values.getString(request.getParameter("formId"), "reporters");
59  String fromContext = Values.getString(request.getParameter("fromContext"), "REPORTER");
60  String subContext = request.getParameter("subContext");
61
62  if (itemId == 0)
63  {
64    title = "Create reporter list";
65    cc.removeObject("item");
66    addReporters = Values.getBoolean(request.getParameter("addReporters"));
67    mergeReporterLists = !addReporters && numSelectedLists > 0;
68    name = request.getParameter("name");
69    if (name == null) name = Values.getString(cc.getPropertyValue("name"), "New reporter list");
70  }
71  else
72  {
73    reporterList = ReporterList.getById(dc, itemId);
74    name = reporterList.getName();
75    cc.setObject("item", reporterList);
76    title = "Edit reporter list -- " + HTML.encodeTags(reporterList.getName());
77  }
78  if (reporterList != null) reporterList.checkPermission(Permission.WRITE);
79 
80  final String clazz = "class=\"text\"";
81  final String requiredClazz = "class=\"text required\"";
82  %>
83
84  <base:page type="popup" title="<%=title%>">
85  <base:head scripts="tabcontrol.js" styles="tabcontrol.css">
86    <script language="JavaScript">
87    // Validate the "Reporter list" tab
88    function validateReporterList()
89    {
90      var frm = document.forms['reporterList'];
91      if (Main.trimString(frm.name.value) == '')
92      {
93        alert("You must enter a name");
94        frm.name.focus();
95        return false;
96      }
97      if (frm.minCount)
98      {
99        var checked = Forms.getCheckedRadio(frm.create);
100        if (checked.value == 'count')
101        {
102          if (!Numbers.isInteger(frm.minCount.value))
103          {
104            alert('You must specify the number of reporter lists');
105            frm.count.focus();
106            return false;
107          }
108          else
109          {
110            var minCount = parseInt(frm.minCount.value);
111            if (minCount < 1 || minCount > <%=numSelectedLists%>)
112            {
113              alert('You must specify between 1 and <%=numSelectedLists%>');
114              frm.count.focus();
115              return false;
116            }
117          }
118        }
119      }
120      return true;
121    }
122
123    // Submit the form
124    function saveSettings()
125    {
126      var frm = document.forms['reporterList'];
127      if (TabControl.validateActiveTab('settings'))
128      {
129        if (frm.which) Forms.createHidden(frm, 'items', getSelectedItems().join(','));
130        frm.submit();
131      }
132    }
133   
134    function init()
135    {
136      var frm = document.forms['reporterList'];
137      <%
138      if (reporterList == null)
139      {
140        %>
141        frm.name.focus();
142        frm.name.select();
143        <%
144      }
145      %>
146      if (frm.which && getSelectedItems().length == 0)
147      {
148        frm.which[0].disabled = true;
149        var aSelected = document.getElementById('which.selected');
150        aSelected.href = 'javascript:void(0)';
151        aSelected.disabled = true;
152        Main.addClass(aSelected, 'disabled');
153      }
154    }
155    // Get the ID:s of all selected reorters
156    var selectedItems;
157    function getSelectedItems()
158    {
159      if (!selectedItems)
160      {
161        selectedItems = window.opener.Table.getSelected('<%=formId%>');
162      }
163      return selectedItems;
164    }
165    function checkRadio(radio, name)
166    {
167      Forms.checkRadio(radio, name);
168    }
169    </script>
170  </base:head>
171  <base:body onload="init()">
172    <p>
173    <form action="index.jsp?ID=<%=ID%>" method="post" name="reporterList" onsubmit="return false;">
174    <input type="hidden" name="cmd" value="UpdateItem">
175    <input type="hidden" name="fromContext" value="<%=fromContext%>">
176    <%
177    if (subContext != null)
178    {
179      %>
180      <input type="hidden" name="subContext" value="<%=subContext%>">
181      <%
182    }
183    %>
184    <h3 class="docked"><%=title%> <base:help tabcontrol="settings" /></h3>
185    <t:tabcontrol id="settings" contentstyle="<%="height: "+(int)(scale*260)+"px;"%>" 
186      position="bottom" remember="<%=reporterList != null%>">
187    <t:tab id="info" title="Reporter list" 
188      validate="validateReporterList()" helpid="reporterlist.edit">
189      <table class="form" cellspacing=0>
190      <tr>
191        <td class="prompt">Name</td>
192        <td><input <%=requiredClazz%> type="text" name="name" 
193          value="<%=HTML.encodeTags(name)%>" 
194          size="40" maxlength="<%=ReporterList.MAX_NAME_LENGTH%>"></td>
195      </tr>
196      <tr>
197        <td class="prompt">External ID</td>
198        <td><input <%=clazz%> type="text" name="external_id" 
199          value="<%=HTML.encodeTags(reporterList == null ? Values.getString(cc.getPropertyValue("externalId")) : reporterList.getExternalId())%>" 
200          size="40" maxlength="<%=ReporterList.MAX_EXTERNAL_ID_LENGTH%>"></td>
201      </tr>
202      <%
203      if (addReporters)
204      {
205        %>
206        <tr valign="top">
207          <td class="prompt">Which reporters?</td>
208          <td>
209            <input type="radio" name="which" value="selected"><a 
210              id="which.selected"
211              href="javascript:checkRadio(document.forms['reporterList'].which, 'selected');"
212              >Selected items</a><br>
213            <input type="radio" name="which" value="page"><a 
214              href="javascript:checkRadio(document.forms['reporterList'].which, 'page');"
215              >Current page</a><br>
216            <input type="radio" name="which" value="all" checked><a 
217              href="javascript:checkRadio(document.forms['reporterList'].which, 'all');"
218              >All pages</a><br>
219          </td>
220        </tr>
221        <%
222      }
223      else if (mergeReporterLists)
224      {
225        %>
226        <tr valign="top">
227          <td class="prompt">Add reporters?</td>
228          <td>
229            <input type="radio" name="create" value=""><a
230              href="javascript:checkRadio(document.forms['reporterList'].create, '');"
231              title="The new reporter list will be empty"
232              >No</a><br>
233            <input type="radio" name="create" value="union" checked><a
234              href="javascript:checkRadio(document.forms['reporterList'].create, 'union');"
235              title="The new reporter list contains all reporters from the selected lists"
236              >Union of selected lists</a> <base:icon image="set_operations/union_small.png" /><br>
237            <input type="radio" name="create" value="intersection"><a
238              href="javascript:checkRadio(document.forms['reporterList'].create, 'intersection');"
239              title="The new reporter lists contains only reporters that are present in ALL selected lists"
240              >Intersection of selected lists</a> <base:icon image="set_operations/intersection_small.png" /><br>
241            <input type="radio" name="create" value="count"><a
242              href="javascript:checkRadio(document.forms['reporterList'].create, 'count');"
243              title="The new reporter lists contains only reporters that are present in some of selected lists"
244              >Present in at least</a>
245              <input type="text" class="text" name="minCount" size="2" maxlength="2"
246                value="1"
247                onkeypress="return Numbers.integerOnly(event)"
248                onfocus="checkRadio(document.forms['reporterList'].create, 'count');">
249              of the selected lists (1-<%=numSelectedLists%>).
250              <br>
251           
252          </td>
253        </tr>
254        <%
255      }
256      %>
257      <tr valign=top>
258        <td class="prompt">Description</td>
259        <td nowrap>
260          <textarea <%=clazz%> rows="4" cols="40" name="description" wrap="virtual"
261            ><%=HTML.encodeTags(reporterList == null ? cc.getPropertyValue("description") : reporterList.getDescription())%></textarea>
262          <a href="javascript:Main.zoom('Description', 'reporterList', 'description')"
263            title="Edit in larger window"><base:icon image="zoom.gif" /></a>
264        </td>
265      </tr>
266      </table>
267      <div align=right>&nbsp;<i><base:icon image="required.gif" /> = required information</i></div>
268    </t:tab>
269    </t:tabcontrol>
270
271    <table align="center">
272    <tr>
273      <td width="50%"><base:button onclick="saveSettings()" title="Save" /></td>
274      <td width="50%"><base:button onclick="window.close()" title="Cancel" /></td>
275    </tr>
276    </table>
277    </form>
278  </base:body>
279  </base:page>
280  <%
281}
282finally
283{
284  if (dc != null) dc.close();
285}
286%>
Note: See TracBrowser for help on using the repository browser.