source: trunk/www/views/experiments/reporters/list_reporters.jsp @ 5900

Last change on this file since 5900 was 5900, checked in by Nicklas Nordborg, 10 years ago

References #1655: GUI improvements

  • Added a CacheControlFilter which can be configured to disable caching for certain file types. This is very useful in a development environment, but not recommended in production.
  • Redesigned buttons with rounded corners.


  • Use more modern css rules for buttons and button groups. Got rid of "align" attribute that is deprecated in html.


  • Place buttons in popup dialogs using coordinates

relative to the bottom of the dialog so that they follow along if the dialog is resized. Only the popups in the "BASE" menu has been fixed so far.

Due to changes in css files, some other layout is now really "ugly", but this will be fixed later...

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 13.4 KB
Line 
1<%-- $Id: list_reporters.jsp 5900 2011-12-07 13:43:15Z nicklas $
2  ------------------------------------------------------------------
3  Copyright (C) 2011 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--%>
23<%@ page pageEncoding="UTF-8" session="false"
24  import="net.sf.basedb.core.SessionControl"
25  import="net.sf.basedb.core.DbControl"
26  import="net.sf.basedb.core.Item"
27  import="net.sf.basedb.core.Type"
28  import="net.sf.basedb.core.ItemContext"
29  import="net.sf.basedb.core.Permission"
30  import="net.sf.basedb.core.Experiment"
31  import="net.sf.basedb.core.VirtualDb"
32  import="net.sf.basedb.core.BaseException"
33  import="net.sf.basedb.core.DynamicReporterQuery"
34  import="net.sf.basedb.core.Reporter"
35  import="net.sf.basedb.core.DynamicResultIterator"
36  import="net.sf.basedb.core.PluginDefinition"
37  import="net.sf.basedb.core.Formula"
38  import="net.sf.basedb.core.IntensityTransform"
39  import="net.sf.basedb.core.plugin.GuiContext"
40  import="net.sf.basedb.core.plugin.Plugin"
41  import="net.sf.basedb.core.query.Expressions"
42  import="net.sf.basedb.core.query.Restrictions"
43  import="net.sf.basedb.core.query.Selects"
44  import="net.sf.basedb.core.query.Dynamic"
45  import="net.sf.basedb.core.query.SqlResult"
46  import="net.sf.basedb.util.Enumeration"
47  import="net.sf.basedb.util.ColorGenerator"
48  import="net.sf.basedb.util.formatter.LookupFormatter"
49  import="net.sf.basedb.clients.web.Base"
50  import="net.sf.basedb.clients.web.ChangeHistoryUtil"
51  import="net.sf.basedb.clients.web.ModeInfo"
52  import="net.sf.basedb.clients.web.DynamicUtil"
53  import="net.sf.basedb.clients.web.WebException"
54  import="net.sf.basedb.clients.web.util.HTML"
55  import="net.sf.basedb.util.Values"
56  import="net.sf.basedb.clients.web.taglib.table.TableColumn"
57  import="java.util.Map"
58  import="java.util.HashMap"
59  import="java.util.List"
60  import="java.util.LinkedList"
61  import="java.util.ArrayList"
62  import="java.util.Set"
63  import="java.util.HashSet"
64  import="java.util.Arrays"
65%>
66<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
67<%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %>
68<%@ taglib prefix="p" uri="/WEB-INF/path.tld" %>
69<%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %>
70<%@ taglib prefix="ext" uri="/WEB-INF/extensions.tld" %>
71<%!
72  private static final Item itemType = Item.REPORTER;
73  private static final GuiContext guiContext = new GuiContext(itemType, GuiContext.Type.LIST);
74%>
75<%
76final int experimentId = Values.getInt(request.getParameter("experiment_id"));
77final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
78final String ID = sc.getId();
79
80final ModeInfo mode = ModeInfo.get(request.getParameter("mode"));
81final String callback = request.getParameter("callback");
82final String title = mode.generateTitle("spot data", "spot data");
83final DbControl dc = sc.newDbControl();
84DynamicResultIterator reporters = null;
85try
86{
87  final Experiment experiment = Experiment.getById(dc, experimentId);
88  final String subContext = "clonedreporters." + experimentId;
89  final boolean writePermission = experiment.hasPermission(Permission.WRITE);
90  VirtualDb virtualDb = experiment.getVirtualDb();
91  if (!virtualDb.hasClonedReporters()) 
92  {
93    response.sendRedirect("../index.jsp?ID="+ID + "&cmd=ViewItem&item_id="+experimentId);
94    return;
95  }
96
97  final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, subContext, null, null);
98  Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext);
99 
100  List<TableColumn> columns = new LinkedList<TableColumn>();
101  DynamicUtil.addReporterColumns(columns, dc, experiment.getVirtualDb().getReporterCloneTemplate(), "cln.", "@", "[Cln] ");
102  DynamicUtil.addReporterColumns(columns, dc, "mst.", "@@", "[Mst] ");
103  DynamicUtil.SelectedInfo selected = DynamicUtil.getSelectedColumns(cc, columns, false);
104  final boolean hasUpToDateColumn = true;
105  try
106  {
107    final DynamicReporterQuery query = Reporter.getDynamicQuery(experiment);
108    query.select(Selects.expression(Dynamic.reporter("id"), "id", true));
109    if (hasUpToDateColumn)
110    {
111      query.select(
112        Selects.expression(
113          Expressions.bool(Restrictions.eq(Dynamic.reporter("version", true), Dynamic.reporter("version", false))),
114          "upToDate"
115        ));
116    }
117    cc.configureQuery(dc, query, selected.selectedProperties);
118    query.setFailSafe(true);
119    reporters = query.iterate(dc);
120  }
121  catch (Throwable t)
122  {
123    cc.setMessage(t.getMessage());
124    t.printStackTrace();
125  }
126  int numListed = 0;
127  %>
128  <base:page title="<%=title%>">
129  <base:head scripts="table.js,tabcontrol.js" styles="table.css,toolbar.css,headertabcontrol.css,path.css">
130    <script language="JavaScript">
131    var submitPage = 'index.jsp';
132    var formId = 'reporters';
133    function editItem(itemId)
134    {
135      Main.viewOrEditItem('<%=ID%>', '<%=itemType.name()%>', itemId, true);
136    }
137    function viewItem(itemId)
138    {
139      Main.viewOrEditItem('<%=ID%>', '<%=itemType.name()%>', itemId, false);
140    }
141    function itemOnClick(evt, itemId)
142    {
143      Table.itemOnClick(formId, evt, itemId, 'DEFAULT', viewItem, editItem, null);
144    }   
145    function configureColumns()
146    {
147      Table.configureColumns('<%=ID%>', formId, '<%=itemType.name()%>', '<%=(String)cc.getObject("defaultColumns")%>', '<%=subContext%>');
148    }
149    function presetOnChange()
150    {
151      Table.presetOnChange('<%=ID%>', formId, '<%=itemType.name()%>', '<%=(String)cc.getObject("defaultColumns")%>', '<%=subContext%>');
152    }
153    function runPlugin(cmd)
154    {
155      Table.submitToPopup(formId, cmd, 800, 500);
156    }
157    function switchTab(tabControlId, tabId)
158    {
159      if (tabId == 'properties' || tabId == 'overview' || tabId == 'history')
160      {
161        location.href = '../index.jsp?ID=<%=ID%>&cmd=ViewItem&item_id=<%=experimentId%>&tab='+tabId;
162      }
163      else if (tabId == 'bioassaysets')
164      {
165        viewBioAssaySets();
166      }
167      else
168      {
169        TabControl.setActiveTab(tabControlId, tabId);
170      }
171    }
172    function viewBioAssaySets()
173    {
174      location.href = '../bioassaysets/index.jsp?ID=<%=ID%>&experiment_id=<%=experimentId%>';
175    }
176    function newReporterList()
177    {
178      Table.submitToPopup(formId, 'CreateReporterList', 540, 400);
179    }
180    function removeClonedReporters()
181    {
182      if (confirm('Are you sure that you want to remove all cloned reporter annotations?\nThis action can\'t be undone.'))
183      {
184        Main.openPopup('../index.jsp?ID=<%=ID%>&cmd=RemoveClonedReporters&item_id=<%=experimentId%>', 'RemoveClonedReporters', 400, 300);
185      }
186    }
187    function updateClonedReporters()
188    {
189      Main.openPopup('index.jsp?ID=<%=ID%>&cmd=UpdateClonedReporters&experiment_id=<%=experimentId%>', 'UpdateClonedReporters', 640, 480);
190    }
191    </script>
192  </base:head>
193  <base:body>
194    <p>
195    <p:path>
196      <p:pathelement title="Experiments" href="<%="../index.jsp?ID="+ID%>" />
197      <p:pathelement title="<%=HTML.encodeTags(experiment.getName())%>" />
198    </p:path>
199
200    <t:tabcontrol id="main" active="clonedreporters" switch="switchTab">
201    <t:tab id="properties" title="Properties" />
202    <t:tab id="bioassaysets" title="Bioassay sets" />
203
204    <t:tab id="clonedreporters" title="Cloned reporters" >
205    <%
206    if (cc.getMessage() != null)
207    {
208      %>
209      <div class="error"><%=cc.getMessage()%></div>
210      <%
211      cc.setMessage(null);
212    }
213    %>
214    <tbl:table 
215      id="reporters" 
216      clazz="itemlist" 
217      columns="<%=cc.getSetting("columns")%>"
218      sortby="<%=cc.getSortProperty()%>" 
219      direction="<%=cc.getSortDirection()%>"
220      title="<%=title%>"
221      action="index.jsp"
222      sc="<%=sc%>"
223      item="<%=itemType%>"
224      subcontext="<%=subContext%>"
225      >
226      <tbl:hidden 
227        name="mode" 
228        value="<%=mode.getName()%>" 
229      />
230      <tbl:hidden 
231        name="experiment_id" 
232        value="<%=String.valueOf(experimentId)%>" 
233      />
234      <tbl:hidden 
235        name="callback" 
236        value="<%=callback%>" 
237        skip="<%=callback == null%>" 
238      />
239      <%
240      for (TableColumn tc : columns)
241      {
242        %>
243        <tbl:columndef
244          id="<%=tc.getId()%>"
245          property="<%=tc.getProperty()%>"
246          tooltip="<%=tc.getDescription()%>"
247          datatype="<%=tc.getDatatype().getStringValue()%>"
248          title="<%=HTML.encodeTags(tc.getTitle())%>"
249          sortable="<%=tc.getSortable()%>"
250          filterable="<%=tc.getFilterable()%>"
251          exportable="<%=tc.getExportable()%>"
252          show="<%="cln.externalId".equals(tc.getId()) ? "always" : tc.getShow()%>"
253          formatter="<%=tc.getFormatter()%>"
254        />
255        <%
256      }
257      %>
258      <tbl:columndef
259        id="upToDate"
260        property="upToDate"
261        filterproperty="=rep('version') == mrep('version')"
262        exportproperty="=rep('version') == mrep('version')"
263        datatype="boolean"
264        title="Up to date"
265        filterable="true"
266        exportable="true"
267      />
268      <tbl:columndef 
269        id="reporterList"
270        property="£reporterList"
271        datatype="int"
272        title="Reporter list"
273        filterable="true"
274        enumeration="<%=Base.getReporterListsEnum(dc)%>"
275        multiple="false"
276      />
277      <tbl:toolbar
278        visible="<%=mode.hasToolbar()%>"
279        >
280        <tbl:button 
281          image="columns.gif" 
282          onclick="configureColumns()" 
283          title="Columns&hellip;" 
284          tooltip="Show, hide and re-order columns" 
285        />
286        <tbl:button
287          image="add.png"
288          onclick="newReporterList()"
289          title="New reporter list&hellip;"
290          tooltip="Create a new reporter list from matching spots"
291          visible="<%=sc.hasPermission(Permission.CREATE, Item.REPORTERLIST)%>"
292        />
293        <tbl:button
294          visible="<%=writePermission%>"
295          image="refresh.gif"
296          onclick="updateClonedReporters()"
297          title="Update cloned reporters&hellip;"
298          tooltip="Update all cloned reporter annotations with information from the master table"
299        />
300        <tbl:button
301          visible="<%=writePermission%>"
302          image="delete_permanently.png"
303          onclick="removeClonedReporters()"
304          title="Remove cloned reporters&hellip;"
305          tooltip="Remove all cloned reporter annotations"
306        />
307        <tbl:button 
308          image="export.gif" 
309          onclick="runPlugin('ExportItems')" 
310          title="Export&hellip;" 
311          tooltip="Export data" 
312          visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>"
313        />
314      </tbl:toolbar>
315      <tbl:navigator
316        page="<%=cc.getPage()%>" 
317        rowsperpage="<%=cc.getRowsPerPage()%>" 
318        totalrows="<%=reporters == null ? 0 : reporters.getTotalCount()%>" 
319        visible="<%=mode.hasNavigator()%>"
320      />
321      <tbl:data>
322        <tbl:columns>
323        <tbl:presetselector 
324          clazz="columnheader"
325          colspan="2"
326          onchange="presetOnChange()"
327        />
328        </tbl:columns>
329        <tr>
330          <tbl:header 
331            clazz="index"
332            >&nbsp;</tbl:header>
333          <tbl:header 
334            clazz="icons" 
335            visible="<%=mode.hasIcons()%>"
336            >&nbsp;</tbl:header>
337          <tbl:propertyfilter />
338        </tr>
339   
340          <tbl:rows>
341          <%
342          int index = cc.getPage()*cc.getRowsPerPage();
343          int selectedItemId = cc.getId();
344          if (reporters != null)
345          {
346            while (reporters.hasNext())
347            {
348              SqlResult item = reporters.next();
349              int itemId = item.getInt(1);
350              index++;
351              numListed++;
352              %>
353              <tbl:row>
354                <tbl:header 
355                  clazz="index"
356                  ><%=index%></tbl:header>
357                <tbl:header 
358                  clazz="icons" 
359                  visible="<%=mode.hasIcons()%>"
360                  >&nbsp;</tbl:header>
361                  <tbl:cell column="upToDate" visible="<%=hasUpToDateColumn %>">
362                    <%=item.getObject(2) %>
363                  </tbl:cell>
364                <%
365                int colIndex = hasUpToDateColumn ? 3 : 2;
366                for (String columnId : selected.selectedIds)
367                {
368                  if ("cln.externalId".equals(columnId))
369                  {
370                    %>
371                    <tbl:cell column="cln.externalId"><div class="link" onclick="itemOnClick(event, <%=itemId%>)" 
372                      title="View this item (use CTRL, ALT or SHIFT to edit)"><%=HTML.encodeTags(item.getString(colIndex))%></div></tbl:cell>
373                    <%
374                  }
375                  else
376                  {
377                    %>
378                    <tbl:cell column="<%=columnId%>" value="<%=item.getObject(colIndex)%>" />
379                    <%
380                  }
381                  ++colIndex;
382                }
383                %>
384              </tbl:row>
385              <%
386            }
387          }
388          %>
389          </tbl:rows>
390        </tbl:data>
391      <%
392      if (numListed == 0)
393      {
394        %>
395        <tbl:panel><%=reporters == null || reporters.getTotalCount() == 0 ? "No reporters were found" : "No reporters on this page. Please select another page!" %></tbl:panel>
396        <%
397      }
398      else
399      {
400        %>
401        <tbl:navigator
402          page="<%=cc.getPage()%>" 
403          rowsperpage="<%=cc.getRowsPerPage()%>" 
404          totalrows="<%=reporters == null ? 0 : reporters.getTotalCount()%>" 
405          visible="<%=mode.hasNavigator()%>"
406          locked="true"
407        />
408        <%
409      }
410      %>
411    </tbl:table>
412    <base:buttongroup>
413      <base:button onclick="returnSelected();" title="Ok" visible="<%=mode.hasOkButton()%>" />
414      <base:button onclick="window.close();" title="Cancel" visible="<%=mode.hasCancelButton()%>" />
415      <base:button onclick="window.close();" title="Close" visible="<%=mode.hasCloseButton()%>" />
416    </base:buttongroup>
417    </t:tab>
418
419    <t:tab id="overview" title="Overview" 
420      tooltip="Display a tree overview of related items" />
421    <t:tab id="history" title="Change history" 
422      tooltip="Displays a log of all modifications made to this item"
423      visible="<%=ChangeHistoryUtil.showChangeHistoryTab(sc)%>" />
424    </t:tabcontrol>
425
426  </base:body>
427  </base:page>
428  <%
429}
430finally
431{
432  if (dc != null) dc.close();
433}
434%>
Note: See TracBrowser for help on using the repository browser.