source: trunk/www/biomaterials/bioplates/events/list_events.jsp @ 6604

Last change on this file since 6604 was 6604, checked in by Nicklas Nordborg, 9 years ago

References #1890: Improve skinnability of BASE

Updated table listings with some new css classes to make it easier to modify background color.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 17.9 KB
Line 
1<%-- $Id $
2  ------------------------------------------------------------------
3  Copyright (C) 2010 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  @author Nicklas
23--%>
24<%@page import="net.sf.basedb.core.BioPlateEventParticipant"%>
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.BioPlate"
30  import="net.sf.basedb.core.BioPlateEvent"
31  import="net.sf.basedb.core.ItemQuery"
32  import="net.sf.basedb.core.Include"
33  import="net.sf.basedb.core.ItemResultIterator"
34  import="net.sf.basedb.core.ItemResultList"
35  import="net.sf.basedb.core.ItemContext"
36  import="net.sf.basedb.core.Nameable"
37  import="net.sf.basedb.core.Permission"
38  import="net.sf.basedb.core.PermissionDeniedException"
39  import="net.sf.basedb.core.PlateGeometry"
40  import="net.sf.basedb.core.PluginDefinition"
41  import="net.sf.basedb.core.query.Hql"
42  import="net.sf.basedb.core.query.Restrictions"
43  import="net.sf.basedb.core.query.Expressions"
44  import="net.sf.basedb.core.query.Orders"
45  import="net.sf.basedb.core.plugin.GuiContext"
46  import="net.sf.basedb.core.plugin.Plugin"
47  import="net.sf.basedb.core.Type"
48  import="net.sf.basedb.util.Enumeration"
49  import="net.sf.basedb.util.ShareableUtil"
50  import="net.sf.basedb.clients.web.Base"
51  import="net.sf.basedb.clients.web.ChangeHistoryUtil"
52  import="net.sf.basedb.clients.web.ModeInfo"
53  import="net.sf.basedb.clients.web.PermissionUtil"
54  import="net.sf.basedb.clients.web.util.HTML"
55  import="net.sf.basedb.util.Values"
56  import="net.sf.basedb.util.formatter.Formatter"
57  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
58  import="net.sf.basedb.clients.web.extensions.ExtensionsControl"
59  import="net.sf.basedb.clients.web.extensions.JspContext"
60  import="net.sf.basedb.clients.web.extensions.renderer.PrefixSuffixRenderer"
61  import="net.sf.basedb.clients.web.extensions.toolbar.ToolbarUtil"
62  import="net.sf.basedb.clients.web.extensions.list.ListColumnUtil"
63  import="net.sf.basedb.util.extensions.ExtensionsInvoker"
64  import="java.util.Iterator" 
65  import="java.util.List"
66  import="java.util.Map"
67  import="java.util.Date"
68%>
69<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
70<%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %>
71<%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %>
72<%@ taglib prefix="p" uri="/WEB-INF/path.tld" %>
73<%@ taglib prefix="ext" uri="/WEB-INF/extensions.tld" %>
74<%!
75  private static final Item itemType = Item.BIOPLATEEVENT;
76  private static final GuiContext guiContext = new GuiContext(itemType, GuiContext.Type.LIST);
77%>
78<%
79final int bioPlateId = Values.getInt(request.getParameter("bioplate_id"));
80final SessionControl sc = Base.getExistingSessionControl(pageContext, Permission.DENIED, itemType);
81final String ID = sc.getId();
82final boolean createPermission = sc.hasPermission(Permission.CREATE, itemType);
83final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null);
84
85final ModeInfo mode =  ModeInfo.get(request.getParameter("mode"));
86final String callback = request.getParameter("callback");
87final String title = mode.generateTitle("bioplate event", "bioplate events");
88final DbControl dc = sc.newDbControl();
89ItemResultIterator<BioPlateEvent> events = null;
90try
91{
92
93  final BioPlate bioPlate = BioPlate.getById(dc, bioPlateId);
94  Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext);
95  try
96  {
97    final ItemQuery<BioPlateEvent> query = Base.getConfiguredQuery(dc, cc, true, bioPlate.getEvents(), mode);
98    events = query.iterate(dc);
99  }
100  catch (Throwable t)
101  {
102    cc.setMessage(t.getMessage());
103    t.printStackTrace();
104  }
105  int numListed = 0;
106  Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc);
107  JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, guiContext, bioPlate);
108  ExtensionsInvoker invoker = ToolbarUtil.useExtensions(jspContext);
109  ExtensionsInvoker columnsInvoker = ListColumnUtil.useExtensions(jspContext);
110  %>
111  <base:page title="<%=title%>" type="<%=mode.getPageType()%>" id="list-page">
112  <base:head scripts="table.js,tabcontrol-2.js,~events.js" styles="table.css,toolbar.css,headertabcontrol.css,path.css">
113    <ext:scripts context="<%=jspContext%>" />
114    <ext:stylesheets context="<%=jspContext%>" />
115  </base:head>
116  <base:body>
117    <%
118    if (!mode.isSelectionMode())
119    {
120      %>
121      <p:path><p:pathelement 
122        title="Bioplates" href="<%="../index.jsp?ID="+ID%>" 
123        /><p:pathelement title="<%=HTML.encodeTags(bioPlate.getName())%>"
124        /></p:path>
125      <%
126    }
127    else
128    {
129      %>
130      <h1><%=title %></h1>
131      <%
132    }
133    %>
134   
135    <t:tabcontrol 
136      id="main" 
137      subclass="content mastertabcontrol"
138      notabs="<%=mode.isSelectionMode() %>"
139      active="events">
140    <t:tab id="properties" title="Properties" />
141    <t:tab id="annotations" title="Annotations" />       
142    <t:tab id="biowells" title="Wells" />
143    <t:tab id="events" title="Plate events">
144    <tbl:table 
145      id="events" 
146      columns="<%=cc.getSetting("columns")%>"
147      sortby="<%=cc.getSortProperty()%>" 
148      direction="<%=cc.getSortDirection()%>"
149      action="index.jsp"
150      sc="<%=sc%>"
151      item="<%=itemType%>"
152      subclass="fulltable"
153      >
154      <tbl:hidden 
155        name="mode" 
156        value="<%=mode.getName()%>" 
157      />
158      <tbl:hidden 
159        name="bioplate_id" 
160        value="<%=String.valueOf(bioPlateId)%>" 
161      />
162      <tbl:hidden 
163        name="callback" 
164        value="<%=callback%>" 
165        skip="<%=callback == null%>" 
166      />
167      <tbl:columndef 
168        id="name"
169        property="name"
170        datatype="string"
171        title="Name"
172        sortable="true" 
173        filterable="true"
174        exportable="true"
175        show="always" 
176      />
177      <tbl:columndef 
178        id="id"
179        clazz="uniquecol"
180        property="id"
181        datatype="int"
182        title="ID"
183        sortable="true" 
184        filterable="true"
185        exportable="true" 
186      />
187      <tbl:columndef 
188        id="eventType"
189        property="eventType.name"
190        datatype="string"
191        title="Event type" 
192        sortable="true" 
193        filterable="true" 
194        exportable="true"
195      />     
196      <tbl:columndef 
197        id="role"
198        property="$bpp.role"
199        datatype="string"
200        title="Role" 
201        sortable="true" 
202        filterable="true" 
203        exportable="true"
204      />     
205      <tbl:columndef 
206        id="protocol"
207        property="protocol.name"
208        datatype="string"
209        title="Protocol"
210        sortable="true" 
211        filterable="true"
212        exportable="true"
213      />
214      <tbl:columndef 
215        id="hardware"
216        property="hardware.name"
217        datatype="string"
218        title="Hardware"
219        sortable="true" 
220        filterable="true"
221        exportable="true"
222      />
223      <tbl:columndef 
224        id="eventDate"
225        property="eventDate"
226        datatype="date"
227        title="Date"
228        sortable="true" 
229        filterable="true"
230        exportable="true"
231        formatter="<%=dateFormatter%>"
232      />
233      <tbl:columndef 
234        id="entryDate"
235        property="entryDate"
236        datatype="date"
237        title="Registered"
238        sortable="true" 
239        filterable="true"
240        exportable="true"
241        formatter="<%=dateFormatter%>"
242      />
243      <tbl:columndef
244        id="participants"
245        title="Participants"
246        property="&participants(bioPlate.name)"
247        datatype="string"
248        filterable="true"
249        exportable="true"
250      />
251      <tbl:columndef 
252        id="owner"
253        property="owner.name"
254        datatype="string"
255        title="Owner"
256        sortable="true" 
257        filterable="true"
258        exportable="true"
259      />
260      <tbl:columndef 
261        id="description"
262        property="description"
263        datatype="string"
264        title="Description" 
265        sortable="true" 
266        filterable="true" 
267        exportable="true"
268      />     
269      <tbl:columndef
270        id="permission"
271        title="Permission"
272      />
273      <tbl:columndef
274        id="sharedTo"
275        title="Shared to"
276        filterable="true"
277        filterproperty="!sharedTo.name"
278        datatype="string"
279      />
280      <tbl:columndef 
281        id="xt-columns" 
282        extensions="<%=columnsInvoker%>" 
283        jspcontext="<%=jspContext%>" 
284      />
285      <div class="panelgroup bg-filled-50 bottomborder">
286        <tbl:toolbar
287          visible="<%=mode.hasToolbar()%>"
288          subclass="bottomborder"
289          >
290          <tbl:button 
291            id="btnDeleteItems"
292            image="delete.png"
293            title="Delete" 
294            tooltip="Delete the selected items" 
295          />
296          <tbl:button 
297            id="btnRestoreItems"
298            image="restore.png"
299            title="Restore" 
300            tooltip="Restore the selected (deleted) items"
301          />
302          <tbl:button 
303            id="btnShareItems"
304            image="share.png"
305            title="Share&hellip;" 
306            tooltip="Share the selected items"
307          />
308          <tbl:button 
309            id="btnSetOwner"
310            image="take_ownership.png"
311            title="Set owner&hellip;"
312            tooltip="Change owner of the selected items"
313          />
314          <tbl:button 
315            id="btnColumns"
316            image="columns.png" 
317            title="Columns&hellip;" 
318            tooltip="Show, hide and re-order columns" 
319          />
320          <tbl:button 
321            id="btnImport"
322            data-plugin-type="IMPORT"
323            image="import.png" 
324            title="Import&hellip;" 
325            tooltip="Import data" 
326            visible="<%=pluginCount.containsKey(Plugin.MainType.IMPORT)%>"
327          />
328          <tbl:button 
329            id="btnExport"
330            data-plugin-type="EXPORT"
331            image="export.png" 
332            title="Export&hellip;" 
333            tooltip="Export data" 
334            visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>"
335          />
336          <tbl:button 
337            id="btnRunPlugin"
338            data-plugin-type="OTHER"
339            image="runplugin.png" 
340            title="Run plugin&hellip;" 
341            tooltip="Run a plugin" 
342            visible="<%=pluginCount.containsKey(Plugin.MainType.OTHER)%>"
343          />
344          <ext:render extensions="<%=invoker%>" context="<%=jspContext%>" 
345            wrapper="<%=new PrefixSuffixRenderer(jspContext, "<td>", "</td>") %>"/>
346        </tbl:toolbar>
347        <tbl:panel>
348          <tbl:presetselector />
349          <tbl:navigator
350            page="<%=cc.getPage()%>" 
351            rowsperpage="<%=cc.getRowsPerPage()%>" 
352            totalrows="<%=events == null ? 0 : events.getTotalCount()%>" 
353            visible="<%=mode.hasNavigator()%>"
354          />
355        </tbl:panel>
356      </div>
357      <tbl:data>
358        <tbl:headers>
359          <tbl:headerrow>
360            <tbl:header colspan="3" />
361            <tbl:columnheaders />
362          </tbl:headerrow>
363          <tbl:headerrow>
364            <tbl:header subclass="index" />
365            <tbl:header 
366              subclass="check" 
367              visible="<%=mode.hasCheck()%>"
368              ><base:icon 
369                id="check.uncheck"
370                image="check_uncheck.png" 
371                tooltip="Check/uncheck all" 
372                 
373              /></tbl:header>
374            <tbl:header 
375              subclass="check" 
376              visible="<%=mode.hasRadio()%>"
377              />
378            <tbl:header 
379              subclass="icons" 
380              visible="<%=mode.hasIcons()%>"
381              />
382            <tbl:propertyfilter />
383          </tbl:headerrow>
384        </tbl:headers>
385        <tbl:rows>
386          <%
387          if (cc.getMessage() != null)
388          {
389            %>
390            <tbl:panel subclass="bg-filled-50">
391              <div class="messagecontainer error"><%=cc.getMessage()%></div>
392            </tbl:panel>
393            <%
394            cc.setMessage(null);
395          }
396          int index = cc.getPage()*cc.getRowsPerPage();
397          int selectedItemId = cc.getId();
398          if (events != null)
399          {           
400            while (events.hasNext())
401            {
402              BioPlateEvent item = events.next();
403              int itemId = item.getId();
404              boolean usePermission = item.hasPermission(Permission.USE);
405             
406             
407              boolean deletePermission = item.hasPermission(Permission.DELETE);
408              boolean sharePermission = item.hasPermission(Permission.SET_PERMISSION);
409              boolean writePermission = item.hasPermission(Permission.WRITE);
410              String tooltip = mode.isSelectionMode() ?
411                  "Select this item" : "View this item" + (writePermission ? " (use CTRL, ALT or SHIFT to edit)" : "");
412              String name = HTML.encodeTags(item.getName());
413              index++;
414              numListed++;
415              %>
416              <tbl:row>
417                <tbl:header 
418                  clazz="index"
419                  ><%=index%></tbl:header>
420                <tbl:header 
421                  clazz="check" 
422                  visible="<%=mode.hasCheck()%>"
423                  ><input 
424                    type="checkbox" 
425                    name="<%=itemId%>" 
426                    value="<%=itemId%>" 
427                    title="<%=name%>" 
428                    <%=cc.getSelected().contains(itemId) ? "checked" : ""%> 
429                  ></tbl:header>
430                <tbl:header 
431                  clazz="check" 
432                  visible="<%=mode.hasRadio()%>"
433                  ><input 
434                    type="radio" 
435                    name="item_id" 
436                    value="<%=itemId%>" 
437                    title="<%=name%>" 
438                    <%=selectedItemId == itemId ? "checked" : ""%>
439                  ></tbl:header>
440                <tbl:header 
441                  clazz="icons" 
442                  visible="<%=mode.hasIcons()%>"
443                  ><base:icon 
444                    image="deleted.png"
445                    id="<%="delete."+itemId %>"
446                    subclass="<%=deletePermission ? "table-delete-item" : null %>"
447                    data-item-id="<%=itemId%>"
448                    tooltip="This item has been scheduled for deletion" 
449                    visible="<%=item.isRemoved()%>"
450                  /><base:icon 
451                    image="shared.png" 
452                    id="<%="share."+itemId %>"
453                    subclass="<%=sharePermission ? "table-share-item" : null %>"
454                    data-item-id="<%=itemId%>"
455                    tooltip="This item is shared to other users, groups and/or projects" 
456                    visible="<%=item.isShared()%>"
457                  />&nbsp;</tbl:header>
458                <tbl:cell column="name"><div 
459                  class="link table-item"
460                  data-item-id="<%=itemId%>"
461                  data-no-edit="<%=writePermission ? 0 : 1 %>" 
462                  data-extra-url="&bioplate_id=<%=bioPlateId%>"
463                  tabindex="0"
464                  title="<%=tooltip%>"><%=name%></div></tbl:cell>
465                <tbl:cell column="id"><%=item.getId()%></tbl:cell>
466                <tbl:cell column="eventType"><base:propertyvalue 
467                    item="<%=item%>" 
468                    property="eventType"
469                    enableEditLink="<%=mode.hasEditLink()%>" 
470                    enablePropertyLink="<%=mode.hasPropertyLink()%>"
471                  /></tbl:cell>
472                <tbl:cell column="role"><%=HTML.encodeTags(item.getParticipant(bioPlate).getRole())%></tbl:cell>
473                <tbl:cell column="protocol"
474                  ><base:propertyvalue 
475                    item="<%=item%>" 
476                    property="protocol"
477                    enableEditLink="<%=mode.hasEditLink()%>" 
478                    enablePropertyLink="<%=mode.hasPropertyLink()%>"
479                  /></tbl:cell>
480                <tbl:cell column="hardware"
481                  ><base:propertyvalue 
482                    item="<%=item%>" 
483                    property="hardware"
484                    enableEditLink="<%=mode.hasEditLink()%>" 
485                    enablePropertyLink="<%=mode.hasPropertyLink()%>"
486                  /></tbl:cell>
487                <tbl:cell column="eventDate" value="<%=item.getEventDate()%>" />
488                <tbl:cell column="entryDate" value="<%=item.getEntryDate()%>" />
489                <tbl:cell column="participants">
490                  <%
491                  ItemQuery<BioPlateEventParticipant> participantQuery = item.getParticipants();
492                  participantQuery.join(Hql.innerJoin(null, "bioPlate", "bpl", true));
493                  participantQuery.include(Include.ALL);
494                  participantQuery.order(Orders.asc(Hql.property("role")));
495                  participantQuery.order(Orders.asc(Hql.property("index")));
496                  participantQuery.order(Orders.asc(Hql.property("bpl", "name")));
497                  for (BioPlateEventParticipant participant : participantQuery.list(dc))
498                  {
499                    %>
500                    <base:propertyvalue 
501                      item="<%=participant%>" 
502                      property="bioPlate" 
503                      enableEditLink="<%=mode.hasEditLink()%>" 
504                      enablePropertyLink="<%=mode.hasPropertyLink()%>"
505                    /> (<%=participant.getRole()%>)<br>
506                    <%
507                  }
508                  %>
509                </tbl:cell>
510                <tbl:cell column="owner"
511                  ><base:propertyvalue 
512                    item="<%=item%>" 
513                    property="owner"
514                    enableEditLink="<%=mode.hasEditLink()%>" 
515                    enablePropertyLink="<%=mode.hasPropertyLink()%>" 
516                  /></tbl:cell>
517                <tbl:cell column="description"><%=HTML.encodeTags(item.getDescription())%></tbl:cell>               
518                <tbl:cell column="permission"><%=PermissionUtil.getShortPermissions(item)%></tbl:cell>
519                <tbl:cell column="sharedTo">
520                  <%
521                  Iterator<Nameable> sharees = ShareableUtil.getSharedTo(dc, item).iterator();
522                  while(sharees.hasNext())
523                  {
524                    Nameable n = sharees.next();
525                    if (mode.hasPropertyLink())
526                    {
527                      out.write(Base.getLinkedName(ID, n, false, mode.hasEditLink()));
528                    }
529                    else
530                    {
531                      out.write(HTML.encodeTags(n.getName()));
532                    }
533                    out.write(sharees.hasNext() ? ", " : "");
534                  }
535                  %>
536                </tbl:cell>
537                <tbl:xt-cells dc="<%=dc%>" item="<%=item%>">
538                  <tbl:cell column="xt-columns" />
539                </tbl:xt-cells>
540              </tbl:row>
541              <%
542              }
543            }
544          if (numListed == 0)
545          {
546            %>
547            <tbl:panel subclass="bg-filled-50">
548              <div class="messagecontainer note">
549                <%=events == null || events.getTotalCount() == 0 ? "No events were found" : "No events on this page. Please select another page!" %>
550              </div>
551            </tbl:panel>
552            <%
553          }
554          %>
555        </tbl:rows>
556      </tbl:data>
557    </tbl:table>
558    </t:tab>
559    <t:tab id="overview" title="Overview" 
560      tooltip="Display a tree overview of related items" />
561    <t:tab id="history" title="Change history" 
562        tooltip="Displays a log of all modifications made to this item"
563        visible="<%=ChangeHistoryUtil.showChangeHistoryTab(sc)%>" />
564    </t:tabcontrol>
565
566    <base:buttongroup subclass="dialogbuttons">
567      <base:button id="btnOk" title="Ok" visible="<%=mode.hasOkButton()%>" />
568      <base:button id="close" title="Cancel" visible="<%=mode.hasCancelButton()%>" />
569      <base:button id="close" title="Close" visible="<%=mode.hasCloseButton()%>" />
570    </base:buttongroup>
571
572  </base:body>
573  </base:page>
574  <%
575}
576finally
577{
578  if (events != null) events.close();
579  if (dc != null) dc.close();
580}
581%>
Note: See TracBrowser for help on using the repository browser.