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