source: trunk/www/admin/platforms/variants/list_variants.jsp @ 7943

Last change on this file since 7943 was 7943, checked in by Nicklas Nordborg, 23 months ago

Merged BASE 3.18.1 to the trunk.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 15.2 KB
Line 
1<%-- $Id:list_variants.jsp 3820 2007-10-12 10:03:18Z nicklas $
2  ------------------------------------------------------------------
3  Copyright (C) 2006 Jari Häkkinen, Nicklas Nordborg, Martin Svensson
4  Copyright (C) 2007 Johan Enell, Nicklas Nordborg
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.ItemContext"
31  import="net.sf.basedb.core.Platform"
32  import="net.sf.basedb.core.PlatformVariant"
33  import="net.sf.basedb.core.RawDataType"
34  import="net.sf.basedb.core.ItemQuery"
35  import="net.sf.basedb.core.ItemResultIterator"
36  import="net.sf.basedb.core.Permission"
37  import="net.sf.basedb.core.PluginDefinition"
38  import="net.sf.basedb.core.PermissionDeniedException"
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.query.Hql"
43  import="net.sf.basedb.core.plugin.GuiContext"
44  import="net.sf.basedb.core.plugin.Plugin"
45  import="net.sf.basedb.clients.web.Base"
46  import="net.sf.basedb.clients.web.PermissionUtil"
47  import="net.sf.basedb.clients.web.ModeInfo"
48  import="net.sf.basedb.clients.web.util.HTML"
49  import="net.sf.basedb.util.Values"
50  import="net.sf.basedb.clients.web.extensions.ExtensionsControl"
51  import="net.sf.basedb.clients.web.extensions.JspContext"
52  import="net.sf.basedb.clients.web.extensions.renderer.PrefixSuffixRenderer"
53  import="net.sf.basedb.clients.web.extensions.toolbar.ButtonAction" 
54  import="net.sf.basedb.clients.web.extensions.toolbar.ToolbarUtil"
55  import="net.sf.basedb.clients.web.extensions.list.ListColumnAction"
56  import="net.sf.basedb.clients.web.extensions.list.ListColumnUtil"
57  import="net.sf.basedb.util.extensions.ExtensionsInvoker"
58  import="java.util.List"
59  import="java.util.Map"
60%>
61<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
62<%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %>
63<%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %>
64<%@ taglib prefix="p" uri="/WEB-INF/path.tld" %>
65<%@ taglib prefix="ext" uri="/WEB-INF/extensions.tld" %>
66<%!
67  private static final Item itemType = Item.PLATFORMVARIANT;
68  private static final GuiContext guiContext = new GuiContext(itemType, GuiContext.Type.LIST);
69%>
70<%
71final int platformId = Values.getInt(request.getParameter("platform_id"));
72final SessionControl sc = Base.getExistingSessionControl(pageContext, Permission.DENIED, itemType);
73final String ID = sc.getId();
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("platform variant", "platform variants");
79final DbControl dc = sc.newDbControl();
80ItemResultIterator<PlatformVariant> variants = null;
81try
82{
83  final Platform platform = platformId > 0 ? Platform.getById(dc, platformId) : null;
84  final boolean createPermission = platform == null ? false : platform.hasPermission(Permission.WRITE);
85  final boolean deletePermission = createPermission;
86  final boolean writePermission = createPermission;
87
88  Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext);
89  JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, guiContext, platform);
90  try
91  {
92    final ItemQuery<PlatformVariant> query = Base.getConfiguredQuery(dc, cc, jspContext, true, platform == null ? PlatformVariant.getQuery() : platform.getVariants(), mode);
93    variants = query.iterate(dc);
94  }
95  catch (Throwable t)
96  {
97    cc.setMessage(t.getMessage());
98  }
99  int numListed = 0;
100  ExtensionsInvoker<ButtonAction> invoker = ToolbarUtil.useExtensions(jspContext);
101  ExtensionsInvoker<ListColumnAction<PlatformVariant,?>> columnsInvoker = ListColumnUtil.useExtensions(jspContext);
102  %>
103  <base:page title="<%=title%>" type="<%=mode.getPageType()%>" id="list-page">
104  <base:head scripts="table.js,tabcontrol-2.js,~variants.js" styles="table.css,toolbar.css,headertabcontrol.css,path.css,help.css">
105    <ext:scripts context="<%=jspContext%>" />
106    <ext:stylesheets context="<%=jspContext%>" />
107  </base:head>
108 
109  <base:body>
110    <%
111    if (platform != null)
112    {
113      %>
114      <p:path><p:pathelement 
115        title="Platforms" href="<%="../index.jsp?ID="+ID%>" 
116        /><p:pathelement title="<%=HTML.encodeTags(platform.getName())%>" 
117        /></p:path>
118      <%
119    }
120    else
121    {
122      %>
123      <h1><%=title%></h1>
124      <%
125    }
126    %>
127
128    <t:tabcontrol 
129      id="main"
130      subclass="content mastertabcontrol"
131      active="variant" notabs="<%=platform == null %>">
132    <t:tab id="properties" title="Properties" visible="<%=platform != null %>"/>
133   
134    <t:tab id="variant" title="Variants">
135    <tbl:table 
136      id="variants" 
137      columns="<%=cc.getSetting("columns")%>"
138      sortby="<%=cc.getSortProperty()%>" 
139      direction="<%=cc.getSortDirection()%>"
140      action="index.jsp"
141      sc="<%=sc%>"
142      item="<%=itemType%>"
143      filterrows="<%=cc.getFilterRows()%>"
144      subclass="fulltable"
145      stickyheaders="name"
146      >
147      <tbl:hidden 
148        name="mode" 
149        value="<%=mode.getName()%>" 
150      />
151      <tbl:hidden 
152        name="platform_id" 
153        value="<%=String.valueOf(platformId)%>" 
154      />
155      <tbl:hidden 
156        name="callback" 
157        value="<%=callback%>" 
158        skip="<%=callback == null%>" 
159      />
160      <tbl:columndef 
161        id="platform" 
162        property="platform.name"
163        datatype="string"
164        title="Platform"
165        sortable="true" 
166        filterable="true"
167        exportable="true"
168        show="<%=platform==null ? "always" : "never" %>" 
169      />
170      <tbl:columndef 
171        id="name"
172        property="name"
173        datatype="string"
174        title="Name"
175        sortable="true" 
176        filterable="true"
177        exportable="true"
178        show="always" 
179      />
180      <tbl:columndef 
181        id="id"
182        clazz="uniquecol"
183        property="id"
184        datatype="int"
185        title="ID"
186        sortable="true"
187        filterable="true"
188        exportable="true"
189      />
190      <tbl:columndef 
191        id="externalId"
192        clazz="uniquecol"
193        property="externalId"
194        datatype="string"
195        title="External ID"
196        sortable="true"
197        filterable="true"
198        exportable="true"
199      />
200      <tbl:columndef 
201        id="fileOnly"
202        property="fileOnly"
203        datatype="boolean"
204        title="File-only"
205        sortable="true"
206        filterable="true"
207        exportable="true"
208      />
209      <tbl:columndef 
210        id="rawDataType"
211        property="rawDataType"
212        datatype="string"
213        title="Raw data type"
214        sortable="true"
215        filterable="true"
216        exportable="true"
217      />
218      <tbl:columndef 
219        id="channels"
220        property="channels"
221        datatype="int"
222        title="Channels"
223        sortable="true"
224        filterable="true"
225        exportable="true"
226      />
227      <tbl:columndef 
228        id="description"
229        property="description"
230        datatype="string"
231        title="Description" 
232        sortable="true" 
233        filterable="true" 
234        exportable="true"
235      />
236      <tbl:columndef 
237        id="xt-columns" 
238        extensions="<%=columnsInvoker%>" 
239        jspcontext="<%=jspContext%>" 
240      />
241      <div class="panelgroup bg-filled-50 bottomborder">
242        <tbl:toolbar
243          subclass="bottomborder"
244          visible="<%=mode.hasToolbar()%>"
245          >
246          <tbl:button 
247            id="btnNewItem"
248            data-extra-url="<%="&platform_id="+platformId%>"
249            disabled="<%=!createPermission%>" 
250            image="new.png" 
251            title="New&hellip;" 
252            tooltip="<%=createPermission ? "Create variant" : "You do not have permission to create variants"%>" 
253          />
254          <tbl:button 
255            id="btnDeleteItems"
256            disabled="<%=!deletePermission%>" 
257            image="delete.png" 
258            title="Delete" 
259            tooltip="<%=deletePermission ? "Delete the selected items" : "You do not have permission to delete variants" %>" 
260          />
261          <tbl:button 
262            id="btnRestoreItems"
263            disabled="<%=!writePermission%>" 
264            image="restore.png" 
265            title="Restore" 
266            tooltip="<%=writePermission ? "Restore the selected (deleted) items" : "You do not have permission to edit variants" %>" 
267          />
268          <tbl:button 
269            id="btnColumns"
270            image="columns.png" 
271            title="Columns&hellip;" 
272            tooltip="Show, hide and re-order columns" 
273          />
274          <tbl:button 
275            id="btnImport"
276            data-plugin-type="IMPORT"
277            image="import.png" 
278            title="Import&hellip;" 
279            tooltip="Import data" 
280            visible="<%=pluginCount.containsKey(Plugin.MainType.IMPORT)%>"
281          />
282          <tbl:button 
283            id="btnExport"
284            data-plugin-type="EXPORT"
285            image="export.png" 
286            title="Export&hellip;" 
287            tooltip="Export data" 
288            visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>"
289          />
290          <tbl:button 
291            id="btnRunPlugin"
292            data-plugin-type="OTHER"
293            image="runplugin.png" 
294            title="Run plugin&hellip;" 
295            tooltip="Run a plugin" 
296            visible="<%=pluginCount.containsKey(Plugin.MainType.OTHER)%>"
297          />
298          <ext:render extensions="<%=invoker%>" context="<%=jspContext%>" 
299            wrapper="<%=new PrefixSuffixRenderer<ButtonAction>(jspContext, "<td>", "</td>") %>"/>
300        </tbl:toolbar>
301        <tbl:panel>
302          <tbl:presetselector />
303          <tbl:navigator
304            page="<%=cc.getPage()%>" 
305            rowsperpage="<%=cc.getRowsPerPage()%>" 
306            totalrows="<%=variants == null ? 0 : variants.getTotalCount()%>" 
307            visible="<%=mode.hasNavigator()%>"
308          />
309        </tbl:panel>
310      </div>
311      <tbl:data>
312        <tbl:headers>
313          <tbl:headerrow>
314            <tbl:header clazz="row-index bg-filled-100" />
315            <tbl:columnheaders />
316          </tbl:headerrow>
317          <%
318          int numFilters = cc.getNumPropertyFilters();
319          int numRows = cc.getFilterRows();
320          for (int filterNo = 0; filterNo < numRows; filterNo++)
321          {
322            boolean lastRow = filterNo == numRows-1;
323            %>
324            <tbl:headerrow>
325              <tbl:header subclass="row-index bg-filled-100">
326                <div class="index-<%=mode.getName()%>">
327                  <div class="index"></div>
328                  <div class="check">
329                    <base:icon 
330                      subclass="link table-check"
331                      image="check_uncheck.png" 
332                      tooltip="Toggle all (use CTRL, ALT or SHIFT to check/uncheck)" 
333                      visible="<%=lastRow && mode.hasCheck()%>"
334                    />
335                  </div>
336                  <div class="icons">
337                    <base:icon
338                      subclass="link table-filter-row-action"
339                      image="add.png"
340                      tooltip="Add extra filter row"
341                      visible="<%=lastRow%>"
342                    /><base:icon
343                      subclass="link table-filter-row-action"
344                      image="remove.png"
345                      tooltip="Remove this filter row"
346                      visible="<%=numRows > 1 || numFilters > 0 %>"
347                      data-remove-row="<%=filterNo%>"
348                    />
349                  </div>
350                </div>
351              </tbl:header>
352              <tbl:propertyfilter row="<%=filterNo%>" />
353            </tbl:headerrow>
354            <%
355          }
356          %>
357          <tbl:columnsubtitles />
358        </tbl:headers>
359        <tbl:rows>
360          <%
361          if (cc.getMessage() != null)
362          {
363            %>
364            <tbl:panel subclass="bg-filled-50">
365              <div class="messagecontainer error"><%=cc.getMessage()%></div>
366            </tbl:panel>
367            <%
368            cc.setMessage(null);
369          }
370          int index = cc.getPage()*cc.getRowsPerPage();
371          int selectedItemId = cc.getId();
372          if (variants != null)
373          {           
374            while (variants.hasNext())
375            {
376              PlatformVariant item = variants.next();
377              RawDataType rdt = item.getRawDataType();
378              int itemId = item.getId();
379              String name = HTML.encodeTags(item.getName());
380              String tooltip = mode.isSelectionMode() ? 
381                  "Select this item" : "View this item" + (writePermission ? " (use CTRL, ALT or SHIFT to edit)" : ""); 
382             
383              index++;
384              numListed++;
385              %>
386              <tbl:row>
387                <tbl:header clazz="row-index bg-filled-100">
388                  <div class="index-<%=mode.getName()%>">
389                    <div class="index <%=index>999?"index-smaller":""%>"><%=index%></div>
390                    <div class="check">
391                      <base:input
392                        type="checkbox" 
393                        name="<%=itemId%>" 
394                        value="<%=itemId%>" 
395                        title="<%=name%>" 
396                        checked="<%=cc.getSelected().contains(itemId)%>"
397                        visible="<%=mode.hasCheck()%>"
398                      />
399                      <base:input 
400                        type="radio" 
401                        name="item_id" 
402                        value="<%=itemId%>" 
403                        title="<%=name%>" 
404                        checked="<%=selectedItemId == itemId%>"
405                        visible="<%=mode.hasRadio()%>"
406                      />
407                    </div>
408                    <div class="icons">
409                      <base:icon 
410                        image="deleted.png"
411                        id="<%="delete."+itemId %>"
412                        subclass="<%=deletePermission ? "table-delete-item" : "disabled" %>"
413                        data-item-id="<%=itemId%>"
414                        tooltip="This item has been scheduled for deletion" 
415                        visible="<%=item.isRemoved()%>"
416                      />
417                    </div>
418                  </div>
419                </tbl:header>
420                <tbl:cell column="name"><div 
421                  class="link table-item"
422                  data-item-id="<%=itemId%>"
423                  data-no-edit="<%=writePermission ? 0 : 1 %>" 
424                  data-extra-url="&platform_id=<%=platformId%>"
425                  tabindex="0"
426                  title="<%=tooltip%>"><%=name%></div></tbl:cell>
427                <tbl:cell column="id"><%=item.getId()%></tbl:cell>
428                <tbl:cell column="platform"><base:propertyvalue 
429                    item="<%=item%>" property="platform"
430                    enableEditLink="<%=mode.hasEditLink()%>" 
431                    enablePropertyLink="<%=mode.hasPropertyLink()%>"/></tbl:cell>
432                <tbl:cell column="externalId"><%=item.getExternalId()%></tbl:cell>
433                <tbl:cell column="fileOnly"><%=item.isFileOnly() ? "yes" : "no"%></tbl:cell>
434                <tbl:cell column="channels"><%=rdt == null ? "N/A" : rdt.getChannels()%></tbl:cell>
435                <tbl:cell column="rawDataType">
436                  <%=item.isFileOnly() ? "N/A" : (rdt == null ? "<i>- any -</i>" : rdt.getName())%>
437                </tbl:cell>
438                <tbl:cell column="description"><%=HTML.encodeTags(item.getDescription())%></tbl:cell>
439                <tbl:xt-cells dc="<%=dc%>" item="<%=item%>">
440                  <tbl:cell column="xt-columns" />
441                </tbl:xt-cells>
442              </tbl:row>
443              <%
444              }
445            }
446          if (numListed == 0)
447          {
448            %>
449            <tbl:panel subclass="bg-filled-50">
450              <div class="messagecontainer note">
451              <%=variants == null || variants.getTotalCount() == 0 ? "No variants were found" : "No variants on this page. Please select another page!" %>
452              </div>
453            </tbl:panel>
454            <%
455          }
456          %>
457        </tbl:rows>
458      </tbl:data>
459    </tbl:table>
460    <base:buttongroup subclass="dialogbuttons">
461      <base:button id="btnOk" title="Ok" visible="<%=mode.hasOkButton()%>" />
462      <base:button id="close" title="Cancel" visible="<%=mode.hasCancelButton()%>" />
463      <base:button id="close" title="Close" visible="<%=mode.hasCloseButton()%>" />
464    </base:buttongroup>
465    </t:tab>
466    </t:tabcontrol>
467
468  </base:body>
469  </base:page>
470  <%
471}
472finally
473{
474  if (variants != null) variants.close();
475  if (dc != null) dc.close();
476}
477%>
Note: See TracBrowser for help on using the repository browser.