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

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

References #1655: GUI improvements

  • File manager dialogs
  • File server edit dialog
  • Changed zoom.gif to png
  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 6.9 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 (TabControl.validateActiveTab('settings'))
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    <p>
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    <h3 class="docked"><%=title%> <base:help tabcontrol="settings" /></h3>
148    <t:tabcontrol id="settings" contentstyle="<%="height: "+(int)(scale*360)+"px;"%>" 
149      position="bottom" remember="true">
150    <t:tab id="info" title="Experiment" validate="validateExperiment()" helpid="experiment.edit">
151      <table class="form" cellspacing=0>
152     
153      <tr>
154        <td class="prompt">Clone template</td>
155        <td>
156          <base:select 
157            id="reporterclonetemplate_id"
158            clazz="selectionlist"
159            required="false"
160            current="<%=null%>"
161            denied="<%=false%>"
162            recent="<%=recentTemplates%>"
163            newitem="<%=false%>"
164            unselectedtext="- all properties -"
165            onselect="selectTemplateOnClick()"
166          />
167        </td>
168      </tr>
169      <tr>
170        <td class="prompt">Clone source</td>
171        <td>
172          <select name="cloneSource">
173          <%
174          if (canCloneFromRaw && canCloneFromVirtual)
175          {
176            %>
177            <option value="AUTO">Auto
178            <%
179          }
180          if (canCloneFromVirtual)
181          {
182            %>
183            <option value="VIRTUAL">Analyzed data
184            <%
185          }
186          if (canCloneFromRaw)
187          {
188            %>
189            <option value="RAW">Raw data
190            <%
191          }
192          %>
193          </select>
194        </td>
195      </tr>
196     
197      <tr >
198        <td class="prompt">Description</td>
199        <td nowrap>
200          <textarea <%=clazz%> rows="4" cols="40" name="description" 
201            ><%=HTML.encodeTags(experiment == null ? cc.getPropertyValue("description") : experiment.getDescription())%></textarea>
202          <a href="javascript:Main.zoom('Description', 'clone', 'description')"
203            title="Edit in larger window"><base:icon image="zoom.png" /></a>
204        </td>
205      </tr>
206      </table>
207      <div align=right>
208        &nbsp;<i><base:icon image="required.gif" /> = required information</i>
209        </div>
210    </t:tab>
211    </t:tabcontrol>
212
213    <table align="center">
214    <tr>
215      <td width="50%"><base:button onclick="saveSettings()" title="Next" /></td>
216      <td width="50%"><base:button onclick="window.close()" title="Cancel" /></td>
217    </tr>
218    </table>
219    </form>
220  </base:body>
221  </base:page>
222  <%
223}
224finally
225{
226  if (dc != null) dc.close();
227}
228%>
Note: See TracBrowser for help on using the repository browser.