source: trunk/www/biomaterials/bioplatetypes/list_platetypes.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: 14.3 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  @version 2.0
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.BioPlateType"
30  import="net.sf.basedb.core.ItemQuery"
31  import="net.sf.basedb.core.Include"
32  import="net.sf.basedb.core.Type"
33  import="net.sf.basedb.core.BioWell"
34  import="net.sf.basedb.core.ItemSubtype"
35  import="net.sf.basedb.core.ItemResultIterator"
36  import="net.sf.basedb.core.ItemQuery"
37  import="net.sf.basedb.core.ItemResultList"
38  import="net.sf.basedb.core.ItemContext"
39  import="net.sf.basedb.core.Permission"
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.util.Enumeration"
48  import="net.sf.basedb.clients.web.Base"
49  import="net.sf.basedb.clients.web.ModeInfo"
50  import="net.sf.basedb.clients.web.PermissionUtil"
51  import="net.sf.basedb.clients.web.util.HTML"
52  import="net.sf.basedb.util.Values"
53  import="net.sf.basedb.util.formatter.Formatter"
54  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
55  import="net.sf.basedb.clients.web.extensions.ExtensionsControl"
56  import="net.sf.basedb.clients.web.extensions.JspContext"
57  import="net.sf.basedb.clients.web.extensions.renderer.PrefixSuffixRenderer"
58  import="net.sf.basedb.clients.web.extensions.toolbar.ToolbarUtil"
59  import="net.sf.basedb.clients.web.extensions.list.ListColumnUtil"
60  import="net.sf.basedb.util.extensions.ExtensionsInvoker"
61  import="java.util.Date"
62  import="java.util.List"
63  import="java.util.Map"
64%>
65<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
66<%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %>
67<%@ taglib prefix="ext" uri="/WEB-INF/extensions.tld" %>
68<%!
69  private static final Item itemType = Item.BIOPLATETYPE;
70  private static final GuiContext guiContext = new GuiContext(itemType, GuiContext.Type.LIST);
71 
72  private static Enumeration<String, String> bioMaterialTypes = new Enumeration<String, String>();
73  static
74  {
75    bioMaterialTypes.add("", "-any-");
76    bioMaterialTypes.add(Integer.toString(Item.SAMPLE.getValue()), Item.SAMPLE.toString());
77    bioMaterialTypes.add(Integer.toString(Item.EXTRACT.getValue()), Item.EXTRACT.toString());
78  }
79  private static Enumeration<String, String> lockModes = new Enumeration<String, String>();
80  static
81  {
82    for (BioWell.LockMode lm : BioWell.LockMode.values())
83    {
84      lockModes.add(Integer.toString(lm.getValue()), lm.toString());
85    }
86  }
87 
88%>
89<%
90final SessionControl sc = Base.getExistingSessionControl(pageContext, Permission.DENIED, itemType);
91final String ID = sc.getId();
92final boolean createPermission = sc.hasPermission(Permission.CREATE, itemType);
93final boolean deletePermission = sc.hasPermission(Permission.DELETE, itemType);
94final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null);
95
96final ModeInfo mode = ModeInfo.get(request.getParameter("mode"));
97final String callback = request.getParameter("callback");
98final String title = mode.generateTitle("bioplate type", "bioplate types");
99final DbControl dc = sc.newDbControl();
100ItemResultIterator<BioPlateType> bioPlateTypes = null;
101try
102{
103  Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext);
104  final ItemQuery<ItemSubtype> subtypesQuery = Base.getSubtypesQuery(null);
105  subtypesQuery.restrict(
106    Restrictions.in(
107      Hql.property("itemType"), 
108      Expressions.integer(Item.SAMPLE.getValue()), Expressions.integer(Item.EXTRACT.getValue())
109    ));
110  final ItemQuery<ItemSubtype> storageTypeQuery = Base.getSubtypesQuery(Item.HARDWARE);
111  try
112  {
113    final ItemQuery<BioPlateType> query = Base.getConfiguredQuery(dc, cc, true, BioPlateType.getQuery(), mode);
114    bioPlateTypes = query.iterate(dc);
115  }
116  catch (Throwable t)
117  {
118    cc.setMessage(t.getMessage());
119  }
120  int numListed = 0;
121  JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, guiContext, null);
122  ExtensionsInvoker invoker = ToolbarUtil.useExtensions(jspContext);
123  ExtensionsInvoker columnsInvoker = ListColumnUtil.useExtensions(jspContext);
124  %>
125  <base:page title="<%=title==null ? "Bioplate types" : title%>" type="<%=mode.getPageType()%>" id="list-page">
126  <base:head scripts="table.js,~bioplatetypes.js" styles="table.css,toolbar.css">
127    <ext:scripts context="<%=jspContext%>" />
128    <ext:stylesheets context="<%=jspContext%>" />
129  </base:head>
130 
131  <base:body>
132    <h1><%=title==null ? "Bioplate types" : title%></h1>
133   
134    <div class="content">
135    <tbl:table 
136      id="bioplatetypes" 
137      columns="<%=cc.getSetting("columns")%>"
138      sortby="<%=cc.getSortProperty()%>" 
139      direction="<%=cc.getSortDirection()%>"
140      action="index.jsp"
141      sc="<%=sc%>"
142      item="<%=itemType%>"
143      subclass="fulltable"
144      >
145      <tbl:hidden 
146        name="mode" 
147        value="<%=mode.getName()%>" 
148      />
149      <tbl:hidden 
150        name="callback" 
151        value="<%=callback%>" 
152        skip="<%=callback == null%>" 
153      />
154      <tbl:columndef 
155        id="name"
156        property="name"
157        datatype="string"
158        title="Name"
159        sortable="true" 
160        filterable="true"
161        exportable="true"
162        show="always" 
163      />
164      <tbl:columndef 
165        id="id"
166        clazz="uniquecol"
167        property="id"
168        datatype="int"
169        title="ID"
170        sortable="true"
171        filterable="true"
172        exportable="true"
173      />
174      <tbl:columndef
175        id="bioMaterialType"
176        property="bioMaterialType"
177        title="Biomaterial type"
178        datatype="int"
179        sortable="true" 
180        filterable="true" 
181        exportable="true"
182        enumeration="<%=bioMaterialTypes%>"
183      />
184      <tbl:columndef 
185        id="itemSubtype"
186        property="itemSubtype"
187        sortproperty="itemSubtype.name"
188        exportproperty="itemSubtype.name:string"
189        datatype="int"
190        enumeration="<%=Enumeration.fromItems(subtypesQuery.list(dc), "-none-")%>"
191        title="Biomaterial subtype"
192        sortable="true" 
193        filterable="true"
194        exportable="true"
195      />
196      <tbl:columndef 
197        id="storageType"
198        property="storageType"
199        sortproperty="storageType.name"
200        exportproperty="storageType.name:string"
201        datatype="int"
202        enumeration="<%=Enumeration.fromItems(storageTypeQuery.list(dc), "-none-")%>"
203        title="Storage type"
204        sortable="true" 
205        filterable="true"
206        exportable="true"
207      />
208      <tbl:columndef
209        id="lockMode"
210        property="lockMode"
211        title="Well lock mode"
212        datatype="int"
213        sortable="true" 
214        filterable="true" 
215        exportable="true"
216        enumeration="<%=lockModes%>"
217      />
218      <tbl:columndef 
219        id="description"
220        property="description"
221        datatype="string"
222        title="Description" 
223        sortable="true" 
224        filterable="true" 
225        exportable="true"
226      />
227      <tbl:columndef 
228        id="xt-columns" 
229        extensions="<%=columnsInvoker%>" 
230        jspcontext="<%=jspContext%>" 
231      />
232      <div class="panelgroup bg-filled-50 bottomborder">
233        <tbl:toolbar
234          subclass="bottomborder"
235          visible="<%=mode.hasToolbar()%>"
236          >
237          <tbl:button 
238            id="btnNewItem"
239            disabled="<%=!createPermission%>" 
240            image="new.png" 
241            title="New&hellip;" 
242            tooltip="<%=createPermission ? "Create new bioplate type" : "You do not have permission to create bioplate types"%>" 
243          />
244          <tbl:button 
245            id="btnDeleteItems"
246            image="delete.png"
247            title="Delete" 
248            tooltip="Delete the selected items" 
249          />
250          <tbl:button 
251            id="btnRestoreItems"
252            image="restore.png"
253            title="Restore" 
254            tooltip="Restore the selected (deleted) items"
255          />
256          <tbl:button 
257            id="btnColumns"
258            image="columns.png" 
259            title="Columns&hellip;" 
260            tooltip="Show, hide and re-order columns" 
261          />
262          <tbl:button 
263            id="btnImport"
264            data-plugin-type="IMPORT"
265            image="import.png" 
266            title="Import&hellip;" 
267            tooltip="Import data" 
268            visible="<%=pluginCount.containsKey(Plugin.MainType.IMPORT)%>"
269          />
270          <tbl:button 
271            id="btnExport"
272            data-plugin-type="EXPORT"
273            image="export.png" 
274            title="Export&hellip;" 
275            tooltip="Export data" 
276            visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>"
277          />
278          <tbl:button 
279            id="btnRunPlugin"
280            data-plugin-type="OTHER"
281            image="runplugin.png" 
282            title="Run plugin&hellip;" 
283            tooltip="Run a plugin" 
284            visible="<%=pluginCount.containsKey(Plugin.MainType.OTHER)%>"
285          />
286          <ext:render extensions="<%=invoker%>" context="<%=jspContext%>" 
287            wrapper="<%=new PrefixSuffixRenderer(jspContext, "<td>", "</td>") %>"/>
288        </tbl:toolbar>
289        <tbl:panel>
290          <tbl:presetselector />
291          <tbl:navigator
292            page="<%=cc.getPage()%>" 
293            rowsperpage="<%=cc.getRowsPerPage()%>" 
294            totalrows="<%=bioPlateTypes == null ? 0 : bioPlateTypes.getTotalCount()%>" 
295            visible="<%=mode.hasNavigator()%>"
296          />
297        </tbl:panel>
298      </div>
299      <tbl:data>
300        <tbl:headers>
301          <tbl:headerrow>
302            <tbl:header colspan="3" />
303            <tbl:columnheaders />
304          </tbl:headerrow>
305          <tbl:headerrow>
306            <tbl:header subclass="index" />
307            <tbl:header 
308              subclass="check" 
309              visible="<%=mode.hasCheck()%>"
310              ><base:icon 
311                id="check.uncheck"
312                image="check_uncheck.png" 
313                tooltip="Check/uncheck all" 
314                 
315              /></tbl:header>
316            <tbl:header 
317              subclass="check" 
318              visible="<%=mode.hasRadio()%>"
319              />
320            <tbl:header 
321              subclass="icons" 
322              visible="<%=mode.hasIcons()%>"
323              />
324            <tbl:propertyfilter />
325          </tbl:headerrow>
326        </tbl:headers>
327        <tbl:rows>
328          <%
329          if (cc.getMessage() != null)
330          {
331            %>
332            <tbl:panel subclass="bg-filled-50">
333              <div class="messagecontainer error"><%=cc.getMessage()%></div>
334            </tbl:panel>
335            <%
336            cc.setMessage(null);
337          }
338          int index = cc.getPage()*cc.getRowsPerPage();
339          int selectedItemId = cc.getId();
340          if (bioPlateTypes != null)
341          {           
342            while (bioPlateTypes.hasNext())
343            {
344              BioPlateType item = bioPlateTypes.next();
345              int itemId = item.getId();
346              String name = HTML.encodeTags(item.getName());
347              boolean usePermission = item.hasPermission(Permission.USE);
348              boolean writePermission = item.hasPermission(Permission.WRITE);
349             
350              String tooltip = mode.isSelectionMode() ? 
351                  "Select this item" : "View this item" + (writePermission ? " (use CTRL, ALT or SHIFT to edit)" : "");
352              index++;
353              numListed++;
354              %>
355              <tbl:row>
356                <tbl:header 
357                  clazz="index"
358                  ><%=index%></tbl:header>
359                <tbl:header 
360                  clazz="check" 
361                  visible="<%=mode.hasCheck()%>"
362                  ><input 
363                    type="checkbox" 
364                    name="<%=itemId%>" 
365                    value="<%=itemId%>" 
366                    title="<%=name%>" 
367                    <%=cc.getSelected().contains(itemId) ? "checked" : ""%> 
368                  ></tbl:header>
369                <tbl:header 
370                  clazz="check" 
371                  visible="<%=mode.hasRadio()%>"
372                  ><input 
373                    type="radio" 
374                    name="item_id" 
375                    value="<%=itemId%>" 
376                    title="<%=name%>" 
377                    <%=selectedItemId == itemId ? "checked" : ""%>
378                  ></tbl:header>
379                <tbl:header 
380                  clazz="icons" 
381                  visible="<%=mode.hasIcons()%>"
382                  ><base:icon 
383                    image="deleted.png"
384                    id="<%="delete."+itemId %>"
385                    subclass="<%=deletePermission ? "table-delete-item" : null %>"
386                    data-item-id="<%=itemId%>"
387                    tooltip="This item has been scheduled for deletion" 
388                    visible="<%=item.isRemoved()%>"
389                  />&nbsp;</tbl:header>
390                <tbl:cell column="name"><div
391                  class="link table-item"
392                  data-item-id="<%=itemId%>"
393                  data-no-edit="<%=writePermission ? 0 : 1 %>" 
394                  tabindex="0"
395                  title="<%=tooltip%>"><%=name%></div></tbl:cell>
396                <tbl:cell column="id"><%=item.getId()%></tbl:cell>
397                <tbl:cell column="bioMaterialType"><%=item.getBioMaterialType() == null ? "<i>- any -</i>" : item.getBioMaterialType().toString() %></tbl:cell>
398                <tbl:cell column="itemSubtype"><base:propertyvalue 
399                    item="<%=item%>" 
400                    property="itemSubtype"
401                    enableEditLink="<%=mode.hasEditLink()%>" 
402                    enablePropertyLink="<%=mode.hasPropertyLink()%>"
403                  /></tbl:cell>
404                <tbl:cell column="storageType"><base:propertyvalue 
405                    item="<%=item%>" 
406                    property="storageType"
407                    enableEditLink="<%=mode.hasEditLink()%>" 
408                    enablePropertyLink="<%=mode.hasPropertyLink()%>"
409                  /></tbl:cell>
410                <tbl:cell column="lockMode"><%=item.getLockMode()%></tbl:cell>
411                <tbl:cell column="description"><%=HTML.encodeTags(item.getDescription())%></tbl:cell>
412                <tbl:xt-cells dc="<%=dc%>" item="<%=item%>">
413                  <tbl:cell column="xt-columns" />
414                </tbl:xt-cells>
415              </tbl:row>
416              <%
417              }
418            }
419          if (numListed == 0)
420          {
421            %>
422            <tbl:panel subclass="bg-filled-50">
423              <div class="messagecontainer note">
424              <%=bioPlateTypes == null || bioPlateTypes.getTotalCount() == 0 ? "No bioplate types were found" : "No bioplate types on this page. Please select another page!" %>
425              </div>
426            </tbl:panel>
427            <%
428          }
429          %>
430        </tbl:rows>
431      </tbl:data>
432    </tbl:table>
433    </div>
434   
435    <base:buttongroup subclass="dialogbuttons">
436      <base:button id="btnOk" title="Ok" visible="<%=mode.hasOkButton()%>" />
437      <base:button id="close" title="Cancel" visible="<%=mode.hasCancelButton()%>" />
438      <base:button id="close" title="Close" visible="<%=mode.hasCloseButton()%>" />
439    </base:buttongroup>
440
441  </base:body>
442  </base:page>
443  <%
444}
445finally
446{
447  if (bioPlateTypes != null) bioPlateTypes.close();
448  if (dc != null) dc.close();
449}
450%>
Note: See TracBrowser for help on using the repository browser.