source: trunk/www/views/experiments/clone_reporters.jsp @ 5923

Last change on this file since 5923 was 5923, checked in by Nicklas Nordborg, 10 years ago

References #1655: GUI improvements

  • Edit dialogs for bioassay set, bioassay, transformation and some other experiment related dialogs
  • Analysis plug-in that have special jsp forms
  • Change history
  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 6.5 KB
Line 
1<%-- $Id $
2  ------------------------------------------------------------------
3  Copyright (C) 2011 Nicklas Nordborg
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--%>
23<%@ page pageEncoding="UTF-8" session="false"
24  import="net.sf.basedb.core.SessionControl"
25  import="net.sf.basedb.core.DbControl"
26  import="net.sf.basedb.core.Item"
27  import="net.sf.basedb.core.ItemContext"
28  import="net.sf.basedb.core.Permission"
29  import="net.sf.basedb.core.Experiment"
30  import="net.sf.basedb.core.VirtualDb"
31  import="net.sf.basedb.core.VirtualTable"
32  import="net.sf.basedb.core.ReporterCloneTemplate"
33  import="net.sf.basedb.core.ItemQuery"
34  import="net.sf.basedb.core.ItemResultList"
35  import="net.sf.basedb.core.Include"
36  import="net.sf.basedb.core.Type"
37  import="net.sf.basedb.core.query.Restrictions"
38  import="net.sf.basedb.core.query.Expressions"
39  import="net.sf.basedb.core.query.Orders"
40  import="net.sf.basedb.core.query.Hql"
41  import="net.sf.basedb.core.PermissionDeniedException"
42  import="net.sf.basedb.core.BaseException"
43  import="net.sf.basedb.core.Project"
44  import="net.sf.basedb.clients.web.Base"
45  import="net.sf.basedb.clients.web.WebException"
46  import="net.sf.basedb.clients.web.util.HTML"
47  import="net.sf.basedb.util.Values"
48  import="net.sf.basedb.util.Enumeration"
49  import="net.sf.basedb.core.plugin.GuiContext"
50  import="java.util.Arrays"
51  import="java.util.Date"
52  import="java.util.List"
53%>
54<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
55<%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %>
56<%
57final Item itemType = Item.EXPERIMENT;
58final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
59final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null);
60final int itemId = cc.getId();
61final String ID = sc.getId();
62final float scale = Base.getScale(sc);
63final DbControl dc = sc.newDbControl();
64try
65{
66  String title = "Clone reporters";
67  Experiment experiment = Experiment.getById(dc, itemId);
68  experiment.checkPermission(Permission.WRITE);
69  VirtualDb virtualDb = experiment.getVirtualDb();
70  boolean canCloneFromRaw = experiment.getRawDataType().isStoredInDb();
71  boolean canCloneFromVirtual = virtualDb.hasTable(VirtualTable.POSITION);
72 
73  if (!canCloneFromRaw && !canCloneFromVirtual)
74  {
75    throw new BaseException("Can't clone reporters for experiment since it has no raw data or analyzed data");
76  }
77 
78  List<ReporterCloneTemplate> recentTemplates = (List<ReporterCloneTemplate>)cc.getRecent(dc, Item.REPORTERCLONETEMPLATE);
79 
80  final String clazz = "class=\"text\"";
81  final String requiredClazz = "class=\"text required\"";
82  %>
83  <base:page type="popup" title="<%=title%>">
84  <base:head scripts="tabcontrol.js" styles="tabcontrol.css">
85    <script language="JavaScript">
86    // Validate the "Experiment" tab
87    function validateExperiment()
88    {
89      var frm = document.forms['clone'];
90     
91      if (frm.reporterclonetemplate_id.selectedIndex < 0)
92      {
93        alert('A template must be selected');
94        frm.reporterclonetemplate_id.focus();
95        return false;
96      }
97
98      return true;
99    }
100   
101    // Submit the form
102    function saveSettings()
103    {
104      var frm = document.forms['clone'];
105      if (validateExperiment())
106      {
107        frm.submit();
108      }
109    }
110   
111    function selectTemplateOnClick()
112    {
113      var frm = document.forms['clone'];
114      var url = '../../admin/reporterclonetemplates/index.jsp?ID=<%=ID%>&mode=selectone&callback=setTemplateCallback';
115      if (frm.reporterclonetemplate_id.length > 1)
116      {
117        var id = Math.abs(parseInt(frm.reporterclonetemplate_id[0].value));       
118        url += '&item_id='+id;
119      }
120      Main.openPopup(url, 'SelectReporterCloneTemplate', 1000, 700);
121    }
122    function setTemplateCallback(id, name)
123    {
124      var frm = document.forms['clone'];
125      var list = frm.reporterclonetemplate_id;
126      if (list.length < 2 || list[1].value == '0') // >
127      {
128        Forms.addListOption(list, 1, new Option());
129      }
130      list[1].value = id;
131      list[1].text = name;
132      list.selectedIndex = 1;
133    }
134
135    function init()
136    {
137      var frm = document.forms['clone'];
138    }
139    </script>
140  </base:head>
141  <base:body onload="init()">
142    <h1><%=title%> <base:help helpid="experiment.clonereporters" /></h1>
143    <form action="index.jsp?ID=<%=ID%>" method="post" name="clone" onsubmit="return false;">
144    <input type="hidden" name="cmd" value="CloneReporters">
145    <input type="hidden" name="item_id" value="<%=itemId %>">
146
147    <div class="content bottomborder">
148      <table class="fullform input100">
149      <tr>
150        <th>Clone template</th>
151        <td>
152          <base:select 
153            id="reporterclonetemplate_id"
154            clazz="selectionlist"
155            required="false"
156            current="<%=null%>"
157            denied="<%=false%>"
158            recent="<%=recentTemplates%>"
159            newitem="<%=false%>"
160            unselectedtext="- all properties -"
161            onselect="selectTemplateOnClick()"
162          />
163        </td>
164        <td></td>
165      </tr>
166      <tr>
167        <th>Clone source</th>
168        <td>
169          <select name="cloneSource">
170          <%
171          if (canCloneFromRaw && canCloneFromVirtual)
172          {
173            %>
174            <option value="AUTO">Auto
175            <%
176          }
177          if (canCloneFromVirtual)
178          {
179            %>
180            <option value="VIRTUAL">Analyzed data
181            <%
182          }
183          if (canCloneFromRaw)
184          {
185            %>
186            <option value="RAW">Raw data
187            <%
188          }
189          %>
190          </select>
191        </td>
192        <td></td>
193      </tr>
194      <tr class="dynamic">
195        <th>Description</th>
196        <td>
197          <textarea <%=clazz%> rows="6" name="description" 
198            ><%=HTML.encodeTags(experiment == null ? cc.getPropertyValue("description") : experiment.getDescription())%></textarea>
199        </td>
200        <td style="width: 20px;">
201          <base:icon image="zoom.png" 
202            onclick="Main.zoom('Description', 'clone', 'description')"
203            tooltip="Edit in larger window"
204          />
205        </td>
206      </tr>
207      </table>
208    </div>
209    </form>
210    <base:buttongroup subclass="dialogbuttons">
211      <base:button onclick="saveSettings()" title="Next" />
212      <base:button onclick="window.close()" title="Cancel" />
213    </base:buttongroup>
214
215  </base:body>
216  </base:page>
217  <%
218}
219finally
220{
221  if (dc != null) dc.close();
222}
223%>
Note: See TracBrowser for help on using the repository browser.