source: trunk/www/biomaterials/lists/list_lists.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: 16.8 KB
Line 
1<%-- $Id: list_lists.jsp 6604 2014-11-18 10:39:22Z nicklas $
2  ------------------------------------------------------------------
3  Copyright (C) 2008 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  @version 2.10
24--%>
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.BioMaterialList"
30  import="net.sf.basedb.core.AnnotationType"
31  import="net.sf.basedb.core.AnnotationSet"
32  import="net.sf.basedb.core.Annotation"
33  import="net.sf.basedb.core.ItemQuery"
34  import="net.sf.basedb.core.ItemResultIterator"
35  import="net.sf.basedb.core.ItemResultList"
36  import="net.sf.basedb.core.ItemContext"
37  import="net.sf.basedb.core.Nameable"
38  import="net.sf.basedb.core.Permission"
39  import="net.sf.basedb.core.PluginDefinition"
40  import="net.sf.basedb.core.plugin.GuiContext"
41  import="net.sf.basedb.core.plugin.Plugin"
42  import="net.sf.basedb.core.query.Hql"
43  import="net.sf.basedb.core.query.Orders"
44  import="net.sf.basedb.core.snapshot.AnnotationLoaderUtil"
45  import="net.sf.basedb.core.snapshot.AnnotationTypeFilter"
46  import="net.sf.basedb.core.snapshot.AnnotationSnapshot"
47  import="net.sf.basedb.core.snapshot.AnnotationSetSnapshot"
48  import="net.sf.basedb.core.snapshot.SnapshotManager"
49  import="net.sf.basedb.clients.web.Base"
50  import="net.sf.basedb.clients.web.PermissionUtil"
51  import="net.sf.basedb.clients.web.ModeInfo"
52  import="net.sf.basedb.clients.web.util.HTML"
53  import="net.sf.basedb.util.Enumeration"
54  import="net.sf.basedb.util.ShareableUtil"
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.ArrayList"
68%>
69<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
70<%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %>
71<%@ taglib prefix="ext" uri="/WEB-INF/extensions.tld" %>
72<%!
73  private static final Item itemType = Item.BIOMATERIALLIST;
74  private static final GuiContext guiContext = new GuiContext(itemType, GuiContext.Type.LIST);
75  private static Enumeration<String, String> memberTypes = new Enumeration<String, String>();
76  static
77  {
78    memberTypes.add(Integer.toString(Item.BIOSOURCE.getValue()), Item.BIOSOURCE.toString());
79    memberTypes.add(Integer.toString(Item.SAMPLE.getValue()), Item.SAMPLE.toString());
80    memberTypes.add(Integer.toString(Item.EXTRACT.getValue()), Item.EXTRACT.toString());
81  }
82
83%>
84<%
85final SessionControl sc = Base.getExistingSessionControl(pageContext, Permission.DENIED, itemType);
86final String ID = sc.getId();
87final boolean createPermission = sc.hasPermission(Permission.CREATE, itemType);
88final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null);
89
90final ModeInfo mode = ModeInfo.get(request.getParameter("mode"));
91final String callback = request.getParameter("callback");
92final String title = mode.generateTitle("biomaterial list", "biomaterial lists");
93final DbControl dc = sc.newDbControl();
94ItemResultIterator<BioMaterialList> lists = null;
95List<AnnotationLoaderUtil> annotationLoaders = new ArrayList<AnnotationLoaderUtil>();
96try
97{
98  Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext);
99  final ItemQuery<AnnotationType> annotationTypeQuery = Base.getAnnotationTypesQuery(itemType);
100  SnapshotManager manager = new SnapshotManager();
101  for (AnnotationType at : annotationTypeQuery.list(dc))
102  {
103    annotationLoaders.add(new AnnotationLoaderUtil(dc, manager, at));
104  }
105  try
106  {
107    final ItemQuery<BioMaterialList> query = Base.getConfiguredQuery(dc, cc, true, BioMaterialList.getQuery(), mode);
108    lists = query.iterate(dc);
109  }
110  catch (Throwable t)
111  {
112    cc.setMessage(t.getMessage());
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 ? "Biomaterial lists" : title%>" type="<%=mode.getPageType()%>" id="list-page">
120  <base:head scripts="table.js,~lists.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 ? "Biomaterial lists" : title%></h1>
127    <div class="content">
128    <tbl:table 
129      id="lists" 
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="externalId"
159        property="externalId"
160        datatype="string"
161        title="External ID"
162        sortable="true" 
163        filterable="true"
164        exportable="true"
165      />
166      <tbl:columndef 
167        id="memberType"
168        property="memberType"
169        datatype="int"
170        title="Member type"
171        sortable="true" 
172        filterable="true"
173        exportable="true"
174        enumeration="<%=memberTypes%>"
175      />
176      <tbl:columndef 
177        id="size"
178        property="size"
179        datatype="int"
180        title="Size"
181        sortable="true" 
182        filterable="true"
183        exportable="true"
184      />
185      <tbl:columndef 
186        id="id"
187        clazz="uniquecol"
188        property="id"
189        datatype="int"
190        title="ID"
191        sortable="true"
192        filterable="true"
193        exportable="true"
194      />
195      <tbl:columndef 
196        id="owner"
197        property="owner.name"
198        datatype="string"
199        title="Owner"
200        sortable="true" 
201        filterable="true"
202        exportable="true"
203      />
204      <tbl:columndef 
205        id="description"
206        property="description"
207        datatype="string"
208        title="Description" 
209        sortable="true" 
210        filterable="true" 
211        exportable="true"
212      />
213      <%
214      for (AnnotationLoaderUtil loader : annotationLoaders)
215      {
216        AnnotationType at = loader.getAnnotationType();
217        Enumeration<String, String> annotationEnum = null;
218        Formatter formatter = FormatterFactory.getTypeFormatter(sc, at.getValueType());
219        if (at.isEnumeration())
220        {
221          annotationEnum = new Enumeration<String, String>();
222          List<?> values = at.getValues();
223          for (Object value : values)
224          {
225            String encoded = formatter.format(value);
226            annotationEnum.add(encoded, encoded);
227          }
228        }
229        %>
230        <tbl:columndef 
231          id="<%="at"+at.getId()%>"
232          title="<%=HTML.encodeTags(at.getName())+" [A]"%>" 
233          property="<%="#"+at.getId()%>"
234          annotation="true"
235          datatype="<%=at.getValueType().getStringValue()%>"
236          enumeration="<%=annotationEnum%>"
237          smartenum="<%=at.getDisplayAsList() %>"
238          sortable="<%=at.getMultiplicity() == 1%>" 
239          filterable="true" 
240          exportable="true"
241          formatter="<%=formatter%>"
242          unit="<%=at.getDefaultUnit()%>"
243        />
244        <%
245      }
246      %>
247      <tbl:columndef
248        id="permission"
249        title="Permission"
250      />
251      <tbl:columndef
252        id="sharedTo"
253        title="Shared to"
254        filterable="true"
255        filterproperty="!sharedTo.name"
256        datatype="string"
257      />
258      <tbl:columndef 
259        id="xt-columns" 
260        extensions="<%=columnsInvoker%>" 
261        jspcontext="<%=jspContext%>" 
262      />
263      <div class="panelgroup bg-filled-50 bottomborder">
264        <tbl:toolbar
265          subclass="bottomborder"
266          visible="<%=mode.hasToolbar()%>"
267          >
268          <tbl:button 
269            id="btnNewItem"
270            disabled="<%=!createPermission%>" 
271            image="new.png" 
272            title="New&hellip;" 
273            tooltip="<%=createPermission ? "Create new biomaterial list" : "You do not have permission to create biomaterial lists"%>" 
274          />
275          <tbl:button 
276            id="btnDeleteItems"
277            image="delete.png"
278            title="Delete" 
279            tooltip="Delete the selected items" 
280          />
281          <tbl:button 
282            id="btnRestoreItems"
283            image="restore.png"
284            title="Restore" 
285            tooltip="Restore the selected (deleted) items"
286          />
287          <tbl:button 
288            id="btnShareItems"
289            image="share.png"
290            title="Share&hellip;" 
291            tooltip="Share the selected items"
292          />
293          <tbl:button 
294            id="btnSetOwner"
295            image="take_ownership.png"
296            title="Set owner&hellip;"
297            tooltip="Change owner of the selected items"
298          />
299          <tbl:button 
300            id="btnColumns"
301            image="columns.png" 
302            title="Columns&hellip;" 
303            tooltip="Show, hide and re-order columns" 
304          />
305          <tbl:button 
306            id="btnImport"
307            data-plugin-type="IMPORT"
308            image="import.png" 
309            title="Import&hellip;" 
310            tooltip="Import data" 
311            visible="<%=pluginCount.containsKey(Plugin.MainType.IMPORT)%>"
312          />
313          <tbl:button 
314            id="btnExport"
315            data-plugin-type="EXPORT"
316            image="export.png" 
317            title="Export&hellip;" 
318            tooltip="Export data" 
319            visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>"
320          />
321          <tbl:button 
322            id="btnRunPlugin"
323            data-plugin-type="OTHER"
324            image="runplugin.png" 
325            title="Run plugin&hellip;" 
326            tooltip="Run a plugin" 
327            visible="<%=pluginCount.containsKey(Plugin.MainType.OTHER)%>"
328          />
329          <ext:render extensions="<%=invoker%>" context="<%=jspContext%>" 
330            wrapper="<%=new PrefixSuffixRenderer(jspContext, "<td>", "</td>") %>"/>
331        </tbl:toolbar>
332        <tbl:panel>
333          <tbl:presetselector />
334          <tbl:navigator
335            page="<%=cc.getPage()%>" 
336            rowsperpage="<%=cc.getRowsPerPage()%>" 
337            totalrows="<%=lists == null ? 0 : lists.getTotalCount()%>" 
338            visible="<%=mode.hasNavigator()%>"
339          />
340        </tbl:panel>
341      </div>
342      <tbl:data>
343        <tbl:headers>
344          <tbl:headerrow>
345            <tbl:header colspan="3" />
346            <tbl:columnheaders />
347          </tbl:headerrow>
348          <tbl:headerrow>
349            <tbl:header subclass="index" />
350            <tbl:header 
351              subclass="check" 
352              visible="<%=mode.hasCheck()%>"
353              ><base:icon 
354                id="check.uncheck"
355                image="check_uncheck.png" 
356                tooltip="Check/uncheck all" 
357                 
358              /></tbl:header>
359            <tbl:header 
360              subclass="check" 
361              visible="<%=mode.hasRadio()%>"
362              />
363            <tbl:header 
364              subclass="icons" 
365              visible="<%=mode.hasIcons()%>"
366              />
367            <tbl:propertyfilter />
368          </tbl:headerrow>
369        </tbl:headers>
370        <tbl:rows>
371          <%
372          if (cc.getMessage() != null)
373          {
374            %>
375            <tbl:panel subclass="bg-filled-50">
376              <div class="messagecontainer error"><%=cc.getMessage()%></div>
377            </tbl:panel>
378            <%
379            cc.setMessage(null);
380          }
381          int index = cc.getPage()*cc.getRowsPerPage();
382          int selectedItemId = cc.getId();
383          if (lists != null)
384          {           
385            while (lists.hasNext())
386            {
387              BioMaterialList item = lists.next();
388              int itemId = item.getId();       
389             
390             
391              boolean deletePermission = item.hasPermission(Permission.DELETE);
392              boolean sharePermission = item.hasPermission(Permission.SET_PERMISSION); 
393              boolean usePermission = item.hasPermission(Permission.USE);
394              boolean writePermission = item.hasPermission(Permission.WRITE);
395              String tooltip = mode.isSelectionMode() ? 
396                  "Select this item" : "View this item" + (writePermission ? " (use CTRL, ALT or SHIFT to edit)" : "");
397              String name = HTML.encodeTags(item.getName());
398              index++;
399              numListed++;
400              %>
401              <tbl:row>
402                <tbl:header 
403                  clazz="index"
404                  ><%=index%></tbl:header>
405                <tbl:header 
406                  clazz="check" 
407                  visible="<%=mode.hasCheck()%>"
408                  ><input 
409                    type="checkbox" 
410                    name="<%=itemId%>" 
411                    value="<%=itemId%>" 
412                    title="<%=name%>" 
413                    <%=cc.getSelected().contains(itemId) ? "checked" : ""%> 
414                  ></tbl:header>
415                <tbl:header 
416                  clazz="check" 
417                  visible="<%=mode.hasRadio()%>"
418                  ><input 
419                    type="radio" 
420                    name="item_id" 
421                    value="<%=itemId%>" 
422                    title="<%=name%>" 
423                    <%=selectedItemId == itemId ? "checked" : ""%>
424                  ></tbl:header>
425                <tbl:header 
426                  clazz="icons" 
427                  visible="<%=mode.hasIcons()%>"
428                  ><base:icon 
429                    image="deleted.png"
430                    id="<%="delete."+itemId %>"
431                    subclass="<%=deletePermission ? "table-delete-item" : null %>"
432                    data-item-id="<%=itemId%>"
433                    tooltip="This item has been scheduled for deletion" 
434                    visible="<%=item.isRemoved()%>"
435                  /><base:icon 
436                    image="shared.png" 
437                    id="<%="share."+itemId %>"
438                    subclass="<%=sharePermission ? "table-share-item" : null %>"
439                    data-item-id="<%=itemId%>"
440                    tooltip="This item is shared to other users, groups and/or projects" 
441                    visible="<%=item.isShared()%>"
442                  />&nbsp;</tbl:header>
443                <tbl:cell column="name"><div 
444                  class="link table-item"
445                  data-item-id="<%=itemId%>"
446                  data-no-edit="<%=writePermission ? 0 : 1 %>" 
447                  tabindex="0"
448                  title="<%=tooltip%>"><%=name%></div></tbl:cell>
449                <tbl:cell column="id"><%=item.getId()%></tbl:cell>
450                <tbl:cell column="size"><%=item.getSize()%></tbl:cell>
451                <tbl:cell column="externalId"><%=HTML.encodeTags(item.getExternalId())%></tbl:cell>
452                <tbl:cell column="memberType"><%=item.getMemberType()%></tbl:cell>
453                <tbl:cell column="owner"
454                  ><base:propertyvalue 
455                    item="<%=item%>" 
456                    property="owner"
457                    enableEditLink="<%=mode.hasEditLink()%>" 
458                    enablePropertyLink="<%=mode.hasPropertyLink()%>"
459                  /></tbl:cell>
460                <tbl:cell column="description"><%=HTML.encodeTags(item.getDescription())%></tbl:cell>
461                <%
462                if (item.isAnnotated())
463                {
464                  AnnotationSetSnapshot snapshot = manager.getSnapshot(dc, item.getAnnotationSet().getId());
465                  for (AnnotationLoaderUtil loader : annotationLoaders)
466                  {
467                    if (loader.find(snapshot))
468                    {
469                      %>
470                      <tbl:cell 
471                        column="<%="at"+loader.getId()%>"
472                        ><tbl:cellvalue 
473                          list="<%=loader.getValues()%>"
474                          suffix="<%=loader.getUnitSymbol()%>"
475                      /></tbl:cell>
476                      <%
477                    }
478                  }
479                }
480                %>
481                <tbl:cell column="permission"><%=PermissionUtil.getShortPermissions(item)%></tbl:cell>
482                <tbl:cell column="sharedTo">
483                  <%
484                  Iterator<Nameable> sharees = ShareableUtil.getSharedTo(dc, item).iterator();
485                  while(sharees.hasNext())
486                  {
487                    Nameable n = sharees.next();
488                    if (mode.hasPropertyLink())
489                    {
490                      out.write(Base.getLinkedName(ID, n, false, mode.hasEditLink()));
491                    }
492                    else
493                    {
494                      out.write(HTML.encodeTags(n.getName()));
495                    }
496                    out.write(sharees.hasNext() ? ", " : "");
497                  }
498                  %>
499                </tbl:cell>
500                <tbl:xt-cells dc="<%=dc%>" item="<%=item%>">
501                  <tbl:cell column="xt-columns" />
502                </tbl:xt-cells>
503              </tbl:row>
504              <%
505              }
506            }
507          if (numListed == 0)
508          {
509            %>
510            <tbl:panel subclass="bg-filled-50">
511              <div class="messagecontainer note">
512              <%=lists == null || lists.getTotalCount() == 0 ? "No lists were found" : "No lists on this page. Please select another page!" %>
513              </div>
514            </tbl:panel>
515            <%
516          }
517          %>
518        </tbl:rows>
519      </tbl:data>
520    </tbl:table>
521    </div>
522   
523    <base:buttongroup subclass="dialogbuttons">
524      <base:button id="btnOk" title="Ok" visible="<%=mode.hasOkButton()%>" />
525      <base:button id="close" title="Cancel" visible="<%=mode.hasCancelButton()%>" />
526      <base:button id="close" title="Close" visible="<%=mode.hasCloseButton()%>" />
527    </base:buttongroup>
528   
529  </base:body>
530  </base:page>
531  <%
532}
533finally
534{
535  if (lists != null) lists.close();
536  if (dc != null) dc.close();
537}
538%>
Note: See TracBrowser for help on using the repository browser.