source: trunk/www/lims/arraydesigns/view_design.jsp @ 5935

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

References #1655: GUI improvements

  • More changes to table and section taglibs. Simple item lists should now display ok (after using a different set of tags for the header row)
  • Hidable sections have been re-designed and should now look a bit better. However, in many of the places we use a section it is only used when there is data to list. The section should be used in all cases so we need to move the conditional test inside.
  • The code for listing "Shared to" information for items have been moved to an "include" page and the old code has been replaced in a lot of pages (may still be missing some).
  • The "Annotations & parameter" tab have been fixed with the new design.
  • The biosource, sample, extract and tag view pages have also been fixed.


  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 19.1 KB
Line 
1<%-- $Id: view_design.jsp 5935 2012-01-26 15:22:21Z nicklas $
2  ------------------------------------------------------------------
3  Copyright (C) 2006 Jari Häkkinen, Nicklas Nordborg, Martin Svensson
4  Copyright (C) 2007 Nicklas Nordborg, Martin Svensson
5
6  This file is part of BASE - BioArray Software Environment.
7  Available at http://base.thep.lu.se/
8
9  BASE is free software; you can redistribute it and/or
10  modify it under the terms of the GNU General Public License
11  as published by the Free Software Foundation; either version 3
12  of the License, or (at your option) any later version.
13
14  BASE is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  GNU General Public License for more details.
18
19  You should have received a copy of the GNU General Public License
20  along with BASE. If not, see <http://www.gnu.org/licenses/>.
21  ------------------------------------------------------------------
22
23  @author Nicklas
24  @version 2.0
25--%>
26<%@ page pageEncoding="UTF-8" session="false"
27  import="net.sf.basedb.core.SessionControl"
28  import="net.sf.basedb.core.DbControl"
29  import="net.sf.basedb.core.SystemItems"
30  import="net.sf.basedb.core.Group"
31  import="net.sf.basedb.core.Item"
32  import="net.sf.basedb.core.ItemContext"
33  import="net.sf.basedb.core.ItemResultIterator"
34  import="net.sf.basedb.core.Permission"
35  import="net.sf.basedb.core.AnnotationType"
36  import="net.sf.basedb.core.FileSet"
37  import="net.sf.basedb.core.FileSetMember"
38  import="net.sf.basedb.core.DataFileType"
39  import="net.sf.basedb.core.AnnotationSet"
40  import="net.sf.basedb.core.ArrayDesign"
41  import="net.sf.basedb.core.ArrayBatch"
42  import="net.sf.basedb.core.File"
43  import="net.sf.basedb.core.ArrayDesignPlate"
44  import="net.sf.basedb.core.Plate"
45  import="net.sf.basedb.core.User"
46  import="net.sf.basedb.core.Job"
47  import="net.sf.basedb.core.ItemQuery"
48  import="net.sf.basedb.core.Include"
49  import="net.sf.basedb.core.ItemResultList"
50  import="net.sf.basedb.core.MultiPermissions"
51  import="net.sf.basedb.core.PermissionDeniedException"
52  import="net.sf.basedb.core.PluginDefinition"
53  import="net.sf.basedb.core.plugin.GuiContext"
54  import="net.sf.basedb.core.plugin.Plugin"
55  import="net.sf.basedb.core.Project"
56  import="net.sf.basedb.core.query.Orders"
57  import="net.sf.basedb.core.query.Hql"
58  import="net.sf.basedb.util.formatter.Formatter"
59  import="net.sf.basedb.clients.web.Base"
60  import="net.sf.basedb.clients.web.ChangeHistoryUtil"
61  import="net.sf.basedb.clients.web.PermissionUtil"
62  import="net.sf.basedb.clients.web.util.HTML"
63  import="net.sf.basedb.util.Values"
64  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
65  import="net.sf.basedb.clients.web.extensions.ExtensionsControl"
66  import="net.sf.basedb.clients.web.extensions.JspContext"
67  import="net.sf.basedb.clients.web.extensions.renderer.PrefixSuffixRenderer"
68  import="net.sf.basedb.clients.web.extensions.toolbar.ToolbarUtil"
69  import="net.sf.basedb.util.extensions.ExtensionsInvoker"
70  import="java.util.Collections"
71  import="java.util.Date"
72  import="java.util.Map"
73  import="java.util.Set"
74  import="java.util.List"
75  import="java.util.Date"
76%>
77<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
78<%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %>
79<%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %>
80<%@ taglib prefix="p" uri="/WEB-INF/path.tld" %>
81<%@ taglib prefix="ext" uri="/WEB-INF/extensions.tld" %>
82<%!
83  private static final Item itemType = Item.ARRAYDESIGN;
84  private static final GuiContext guiContext = new GuiContext(itemType, GuiContext.Type.ITEM);
85%>
86<%
87final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
88final String ID = sc.getId();
89final String root = request.getContextPath()+"/";
90final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null);
91final int itemId = cc.getId();
92final String tab = Values.getString(request.getParameter("tab"), "properties");
93final float scale = Base.getScale(sc);
94final DbControl dc = sc.newDbControl();
95try
96{
97  Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext);
98
99  String title = null;
100  ArrayDesign design = ArrayDesign.getById(dc, itemId);
101  Job job = null;
102  boolean readJob = true;
103  try
104  {
105    job = design.getJob();
106  }
107  catch (PermissionDeniedException ex)
108  {
109    readJob = false;
110  }
111  final Formatter<Date> dateTimeFormatter = FormatterFactory.getDateTimeFormatter(sc);
112  Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc);
113
114  final boolean usePermission = design.hasPermission(Permission.USE);
115  final boolean writePermission = design.hasPermission(Permission.WRITE);
116  final boolean deletePermission = design.hasPermission(Permission.DELETE);
117  final boolean sharePermission = design.hasPermission(Permission.SET_PERMISSION);
118  final boolean setOwnerPermission = design.hasPermission(Permission.SET_OWNER);
119  final boolean isRemoved = design.isRemoved();
120  final boolean isUsed = isRemoved && design.isUsed();
121  final boolean deletePermanentlyPermission = deletePermission && !isUsed;
122  final boolean isOwner = design.isOwner();
123  JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, guiContext, design);
124  ExtensionsInvoker invoker = ToolbarUtil.useExtensions(jspContext);
125  %>
126  <base:page title="<%=title%>">
127  <base:head scripts="table.js,tabcontrol.js" styles="table.css,toolbar.css,headertabcontrol.css,path.css">
128    <ext:scripts context="<%=jspContext%>" />
129    <ext:stylesheets context="<%=jspContext%>" />
130    <script language="JavaScript">
131    function editItem()
132    {
133      Main.viewOrEditItem('<%=ID%>', '<%=itemType.name()%>', <%=itemId%>, true);
134    }
135    function shareItem()
136    {
137      Main.openPopup('index.jsp?ID=<%=ID%>&cmd=ShareItem&item_id=<%=itemId%>', 'ShareArrayDesign', 600, 400);
138    }
139    function deleteItem()
140    {
141      location.replace('index.jsp?ID=<%=ID%>&cmd=DeleteItem&item_id=<%=itemId%>');
142    }
143    function restoreItem()
144    {
145      location.replace('index.jsp?ID=<%=ID%>&cmd=RestoreItem&item_id=<%=itemId%>');
146    }
147    function deleteItemPermanently()
148    {
149      Main.deleteItemPermanently('<%=ID%>', true, '<%=itemType.name()%>', <%=itemId%>, '&callback=itemDeleted');
150    }
151    function itemDeleted()
152    {
153      Main.listItems('<%=ID%>', '<%=itemType.name()%>');
154    }
155    function showUsingItems()
156    {
157      Main.showUsingItems('<%=ID%>', '<%=itemType.name()%>', <%=itemId%>);
158    }
159    function setOwner()
160    {
161      Main.openPopup('index.jsp?ID=<%=ID%>&cmd=SetOwnerOfItem&item_id=<%=itemId%>', 'SetOwnerOfItem', 450, 300);
162    }
163    function runPlugin(cmd)
164    {
165      Main.openPopup('index.jsp?ID=<%=ID%>&cmd='+cmd+'&item_id=<%=itemId%>', 'RunPlugin'+cmd, 750, 500);
166    }
167    function viewFeatures()
168    {
169      location.href = 'features/index.jsp?ID=<%=ID%>&arraydesign_id=<%=itemId%>';
170    }
171    function managePlates()
172    {
173      Main.openPopup('index.jsp?ID=<%=ID%>&cmd=ManagePlates&item_id=<%=itemId%>', 'ManagePlates', 600, 400);
174    }
175    function switchTab(tabControlId, tabId)
176    {
177      if (TabControl.isActive(tabControlId, tabId)) return;
178      if ((tabId == 'overview' || tabId == 'history') && tabId != '<%=tab%>')
179      {
180        location.href = 'index.jsp?ID=<%=ID%>&cmd=ViewItem&item_id=<%=itemId%>&tab='+tabId;
181      }
182      else if (tabId == 'features')
183      {
184        viewFeatures();
185      }
186      else
187      {
188        TabControl.setActiveTab(tabControlId, tabId);
189      }
190    }
191    function newBatch()
192    {
193      Main.viewOrEditItem('<%=ID%>', 'ARRAYBATCH', 0, true, '&arraydesign_id=<%=itemId%>');
194    }
195    function verifyReporters()
196    {
197      Main.openPopup('index.jsp?ID=<%=ID%>&cmd=VerifyReporters&item_id=<%=itemId%>', 'VerifyReporters', 750, 500);
198    }
199    </script>
200  </base:head>
201  <base:body>
202    <p>
203    <p:path>
204      <p:pathelement title="Array designs" href="<%="index.jsp?ID="+ID%>" />
205      <p:pathelement title="<%=HTML.encodeTags(design.getName())%>" />
206    </p:path>
207   
208    <t:tabcontrol id="main" active="<%=tab%>" switch="switchTab" remember="false">
209    <t:tab id="properties" title="Properties">
210    <tbl:toolbar
211      >
212      <tbl:button 
213        disabled="<%=writePermission ? false : true%>" 
214        image="<%=writePermission ? "edit.gif" : "edit_disabled.gif"%>" 
215        onclick="editItem()" 
216        title="Edit&hellip;" 
217        tooltip="<%=writePermission ? "Edit this array design" : "You do not have permission to edit this array design"%>" 
218      />
219      <tbl:button 
220        disabled="<%=deletePermission ? false : true%>" 
221        image="<%=deletePermission ? "delete.gif" : "delete_disabled.gif"%>" 
222        onclick="deleteItem()" 
223        title="Delete"
224        visible="<%=!design.isRemoved()%>"
225        tooltip="<%=deletePermission ? "Delete this array design" : "You do not have permission to delete this array design"%>" 
226      />
227      <tbl:button 
228        disabled="<%=writePermission ? false : true%>" 
229        image="<%=writePermission ? "restore.gif" : "restore_disabled.gif"%>" 
230        onclick="restoreItem()" 
231        title="Restore"
232        visible="<%=design.isRemoved()%>"
233        tooltip="<%=writePermission ? "Restore this array design" : "You do not have permission to restore this array design"%>" 
234      />
235      <tbl:button 
236        disabled="<%=sharePermission ? false : true%>"
237        image="<%=sharePermission ? "share.gif" : "share_disabled.gif"%>"
238        onclick="shareItem()" 
239        title="Share&hellip;" 
240        tooltip="<%=sharePermission ? "Share this array design to other user, groups and projects" : "You do not have permission to share this array design"%>"
241      />
242      <tbl:button 
243        disabled="<%=setOwnerPermission ? false : true%>"
244        image="<%=setOwnerPermission ? "take_ownership.png" : "take_ownership_disabled.png"%>"
245        onclick="setOwner()" 
246        title="Set owner&hellip;"
247        tooltip="<%=setOwnerPermission ? "Change owner of this item" : "You do not have permission to change ownership of this item"%>"
248      />
249      <tbl:button
250        image="add.png"
251        onclick="newBatch()"
252        title="New batch&hellip;"
253        tooltip="Create a new array batch with this design"
254        visible="<%=sc.hasPermission(Permission.CREATE, Item.ARRAYBATCH) && usePermission%>"
255      />
256      <tbl:button 
257        image="import.gif" 
258        onclick="runPlugin('ImportItem')" 
259        title="Import&hellip;" 
260        tooltip="Import data" 
261        visible="<%=pluginCount.containsKey(Plugin.MainType.IMPORT)%>"
262      />
263      <tbl:button 
264        image="export.gif" 
265        onclick="runPlugin('ExportItem')" 
266        title="Export&hellip;" 
267        tooltip="Export data" 
268        visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>"
269      />
270      <tbl:button 
271        image="runplugin.gif" 
272        onclick="runPlugin('RunPlugin')" 
273        title="Run plugin&hellip;" 
274        tooltip="Run a plugin" 
275        visible="<%=pluginCount.containsKey(Plugin.MainType.OTHER)%>"
276      />
277      <tbl:button 
278        onclick="managePlates()"
279        title="Manage plates&hellip;"
280        tooltip="Attach / detach plates to this array design"
281        visible="<%=writePermission && !design.hasFeatures()%>"
282      />
283      <ext:render extensions="<%=invoker%>" context="<%=jspContext%>" 
284        wrapper="<%=new PrefixSuffixRenderer(jspContext, "<td>", "</td>") %>"/>
285      <tbl:button
286        image="help.png"
287        onclick="<%="Main.openHelp('" + ID +"', 'arraydesign.view.properties')"%>"
288        title="Help&hellip;"
289        tooltip="Get help about this page"
290      />
291      </tbl:toolbar>
292     
293    <div class="boxedbottom">
294      <div class="itemstatus">Permissions on this item: <i><%=PermissionUtil.getFullPermissionNames(design)%></i></div>
295      <%
296      if (design.isRemoved() || design.isShared())
297      {
298        %>
299        <div class="itemstatus">
300          <base:icon 
301            image="<%=deletePermanentlyPermission ? "deleted.gif" : "deleted_disabled.gif"%>"
302            onclick="<%=deletePermanentlyPermission ? "deleteItemPermanently()" : null%>"
303            tooltip="<%=deletePermanentlyPermission ? "Permanently delete this item" : null%>"
304            visible="<%=isRemoved%>"> This item has been flagged for deletion<br></base:icon>
305          <base:icon image="used.gif" 
306            onclick="showUsingItems()"
307            tooltip="Show the items that are using this one"
308            visible="<%=isUsed%>"> This item is used by other items and can't be permanently deleted<br></base:icon>
309          <base:icon image="shared.gif" 
310            visible="<%=design.isShared()%>"> This item is shared to other users, groups and/or projects</base:icon>
311        </div>
312        <%
313      }
314      %>
315     
316      <table width="100%">
317      <tr >
318      <td>
319     
320      <table class="form" cellspacing="0">
321      <tr>
322        <td class="prompt">Name</td>
323        <td><%=HTML.encodeTags(design.getName())%></td>
324      </tr>
325      <tr>
326        <td class="prompt">Registered</td>
327        <td><%=dateFormatter.format(design.getEntryDate())%></td>
328      </tr>
329      <tr>
330        <td class="prompt">Platform</td>
331        <td><base:propertyvalue item="<%=design%>" property="platform" /></td>
332      </tr>
333      <tr>
334        <td class="prompt">Variant</td>
335        <td><base:propertyvalue item="<%=design%>" property="variant" /></td>
336      </tr>
337      <tr>
338        <td class="prompt">Arrays per slide</td>
339        <td><%=design.getNumArrays()%></td>
340      </tr>
341      <tr>
342        <td class="prompt">Features</td>
343        <td><%=design.hasFeatures() ? "yes (db: " + design.getNumDbFeatures() + "; file: " + design.getNumFileFeatures() + ")" : "no"%></td>
344      </tr>
345      <tr>
346        <td class="prompt">Feature identification method</td>
347        <td><%=design.getFeatureIdentificationMethod()%></td>
348      </tr>
349      <tr>
350        <td class="prompt">Owner</td>
351        <td><base:propertyvalue item="<%=design%>" property="owner" /></td>
352      </tr>
353      <tr>
354        <td class="prompt">Description</td>
355        <td><%=HTML.niceFormat(design.getDescription())%></td>
356      </tr>
357      </table>
358     
359      </td>
360      <td>
361      <%
362      if (design.getNumDbFeatures() > 0)
363      {
364        %>
365        <h4 style="margin-top: 0px;">Feature import</h4>
366        <table class="form" cellspacing="0">
367        <tr>
368          <td class="prompt">Job</td>
369          <td><%=Base.getLinkedName(ID, job, !readJob, true)%></td>
370        </tr>
371        <tr>
372          <td class="prompt">Date / time</td>
373          <td><%=job == null ? "" : dateTimeFormatter.format(job.getEnded())%></td>
374        </tr>
375        <tr>
376          <td class="prompt">Plugin</td>
377          <td><base:propertyvalue item="<%=design%>" property="job.pluginDefinition" /></td>
378        </tr>
379        <tr>
380          <td class="prompt">Configuration / file format</td>
381          <td><base:propertyvalue item="<%=design%>" property="job.pluginConfiguration" /></td>
382        </tr>
383        </table>
384        <%
385      }
386      %>
387       
388      </td>
389      </tr>
390      </table>
391     
392      <jsp:include page="../../common/datafiles/list_files.jsp">
393        <jsp:param name="item_type" value="<%=itemType.name()%>" />
394        <jsp:param name="item_id" value="<%=itemId%>" />
395        <jsp:param name="ID" value="<%=ID%>" />
396      </jsp:include>
397     
398      <%
399      ItemQuery<ArrayBatch> batchQuery = design.getArrayBatches();
400      batchQuery.include(Include.ALL);
401      batchQuery.order(Orders.asc(Hql.property("name")));
402      ItemResultList<ArrayBatch> batches = batchQuery.list(dc);
403      if (batches.size() == 0)
404      {
405        %>
406        <h4>Array batches</h4>
407        No batches exists for this design
408        (or, you don't have permission to view them).
409        <%
410      }
411      else
412      {
413        %>
414        <base:section 
415          id="batches" 
416          title="<%="Array batches (" + batches.size() +")"%>"
417          context="<%=cc%>">
418        <tbl:table
419          id="batches"
420         
421          columns="all"
422          >
423        <tbl:columndef 
424          id="name"
425          title="Name"
426        />
427        <tbl:columndef 
428          id="description"
429          title="Description"
430        />
431        <tbl:data>
432          <tbl:columns>
433          </tbl:columns>
434          <tbl:rows>
435          <%
436          for (ArrayBatch item : batches)
437          {
438            %>
439            <tbl:row>
440              <tbl:cell column="name"><base:icon 
441                  image="deleted.gif" 
442                  tooltip="This item has been scheduled for deletion" 
443                  visible="<%=item.isRemoved()%>"
444                /><%=Base.getLinkedName(ID, item, false, true)%></tbl:cell>
445              <tbl:cell column="description"><%=HTML.encodeTags(item.getDescription())%></tbl:cell>
446            </tbl:row>
447            <%
448          }
449          %>
450          </tbl:rows>
451        </tbl:data>
452        </tbl:table>
453        </base:section>
454        <%
455      }
456      %>
457     
458      <%
459      ItemQuery<ArrayDesignPlate> platesQuery = design.getArrayDesignPlates();
460      platesQuery.include(Include.ALL);
461      platesQuery.order(Orders.asc(Hql.property("position")));
462      ItemResultList<ArrayDesignPlate> plates = platesQuery.list(dc);
463      if (plates.size() == 0)
464      {
465        %>
466        <h4>Plates</h4>
467        This array design isn't connected to any plates (or, you don't have permission to view them).
468        <%
469      }
470      else
471      {
472        %>
473        <base:section 
474          id="plates" 
475          title="<%="Plates (" + plates.size() +")"%>" 
476          context="<%=cc%>">
477        <tbl:table
478          id="plates"
479         
480          columns="all"
481          >
482        <tbl:columndef 
483          id="name"
484          title="Name"
485        />
486        <tbl:columndef 
487          id="position"
488          title="Position"
489        />
490        <tbl:columndef 
491          id="description"
492          title="Description"
493        />
494        <tbl:data>
495          <tbl:columns>
496          </tbl:columns>
497          <tbl:rows>
498          <%
499          for (ArrayDesignPlate item : plates)
500          {
501            Plate plate = null;
502            boolean readPlate = true;
503            try
504            {
505              plate = item.getPlate();
506            }
507            catch (PermissionDeniedException ex)
508            {
509              readPlate = false;
510            }
511            %>
512            <tbl:row>
513              <tbl:cell column="name"><base:icon 
514                  image="deleted.gif" 
515                  tooltip="This item has been scheduled for deletion" 
516                  visible="<%=plate != null && plate.isRemoved()%>"
517                /><%=Base.getLinkedName(ID, plate, !readPlate, true)%></tbl:cell>
518              <tbl:cell column="position"><%=item.getPosition()+1%></tbl:cell>
519              <tbl:cell column="description"><%=HTML.encodeTags(plate == null ? "" : plate.getDescription())%></tbl:cell>
520            </tbl:row>
521            <%
522          }
523          %>
524          </tbl:rows>
525        </tbl:data>
526        </tbl:table>
527        </base:section>
528        <%
529      }
530      %>
531      <jsp:include page="../../common/anytoany/list_anytoany.jsp">
532        <jsp:param name="ID" value="<%=ID%>" />
533        <jsp:param name="item_type" value="<%=itemType.name()%>" />
534        <jsp:param name="item_id" value="<%=itemId%>" />
535        <jsp:param name="title" value="Other items related to this array design" />
536      </jsp:include>
537      <jsp:include page="../../common/share/list_share.jsp">
538        <jsp:param name="ID" value="<%=ID%>" />
539        <jsp:param name="item_type" value="<%=itemType.name()%>" />
540        <jsp:param name="item_id" value="<%=itemId%>" />
541        <jsp:param name="title" value="Shared to" />
542      </jsp:include>
543      </div>
544      </t:tab>
545     
546      <t:tab id="annotations" title="Annotations" 
547        tooltip="View annotation values" clazz="white">
548        <jsp:include page="../../common/annotations/list_annotations.jsp">
549          <jsp:param name="item_type" value="<%=itemType.name()%>" />
550          <jsp:param name="item_id" value="<%=itemId%>" />
551          <jsp:param name="ID" value="<%=ID%>" />
552        </jsp:include>
553      </t:tab>
554     
555      <t:tab id="features" title="Features" visible="<%=design.getNumDbFeatures() > 0%>"/>
556
557      <t:tab id="overview" title="Overview" 
558        tooltip="Display a tree overview of related items">
559        <%
560        if ("overview".equals(tab))
561        {
562          %>
563          <jsp:include page="../../common/overview/overview.jsp">
564            <jsp:param name="item_type" value="<%=itemType.name()%>" />
565            <jsp:param name="item_id" value="<%=itemId%>" />
566            <jsp:param name="ID" value="<%=ID%>" />
567          </jsp:include>
568          <%
569        }
570        %>
571      </t:tab>
572      <t:tab id="history" title="Change history" 
573        tooltip="Displays a log of all modifications made to this item"
574        visible="<%=ChangeHistoryUtil.showChangeHistoryTab(sc)%>">
575        <%
576        if ("history".equals(tab))
577        {
578          %>
579          <jsp:include page="../../common/history/frameset.jsp">
580            <jsp:param name="source_type" value="<%=itemType.name()%>" />
581            <jsp:param name="source_id" value="<%=itemId%>" />
582            <jsp:param name="ID" value="<%=ID%>" />
583          </jsp:include>
584          <%
585        }
586        %>
587      </t:tab>
588      </t:tabcontrol>
589
590  </base:body>
591  </base:page>
592  <%
593}
594finally
595{
596  if (dc != null) dc.close();
597}
598
599%>
Note: See TracBrowser for help on using the repository browser.