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