source: trunk/www/my_base/messages/list_messages.jsp @ 7604

Last change on this file since 7604 was 7604, checked in by Nicklas Nordborg, 4 years ago

References #2151: Pre-compile all JSP pages before releases

Getting rid of rawtypes warnings. Most of them are relatively simple by adding a type parameter.

Utility functions that are used with generics are typically a bit harder.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 13.5 KB
Line 
1<%-- $Id: list_messages.jsp 7604 2019-02-25 12:19:50Z nicklas $
2  ------------------------------------------------------------------
3  Copyright (C) 2006 Jari Häkkinen, Nicklas Nordborg, Martin Svensson
4  Copyright (C) 2007 Johan Enell
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.Message"
31  import="net.sf.basedb.core.User"
32  import="net.sf.basedb.core.ItemQuery"
33  import="net.sf.basedb.core.Include"
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.Permission"
38  import="net.sf.basedb.core.PluginDefinition"
39  import="net.sf.basedb.core.PermissionDeniedException"
40  import="net.sf.basedb.core.query.Hql"
41  import="net.sf.basedb.core.query.Restrictions"
42  import="net.sf.basedb.core.query.Expressions"
43  import="net.sf.basedb.core.plugin.GuiContext"
44  import="net.sf.basedb.core.plugin.Plugin"
45  import="net.sf.basedb.util.Enumeration"
46  import="net.sf.basedb.clients.web.Base"
47  import="net.sf.basedb.clients.web.ModeInfo"
48  import="net.sf.basedb.clients.web.PermissionUtil"
49  import="net.sf.basedb.clients.web.util.HTML"
50  import="net.sf.basedb.util.Values"
51  import="net.sf.basedb.util.formatter.Formatter"
52  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
53  import="net.sf.basedb.clients.web.extensions.ExtensionsControl"
54  import="net.sf.basedb.clients.web.extensions.JspContext"
55  import="net.sf.basedb.clients.web.extensions.renderer.PrefixSuffixRenderer"
56  import="net.sf.basedb.clients.web.extensions.toolbar.ButtonAction" 
57  import="net.sf.basedb.clients.web.extensions.toolbar.ToolbarUtil"
58  import="net.sf.basedb.clients.web.extensions.list.ListColumnAction"
59  import="net.sf.basedb.clients.web.extensions.list.ListColumnUtil"
60  import="net.sf.basedb.util.extensions.ExtensionsInvoker"
61  import="java.util.List"
62  import="java.util.Map"
63  import="java.util.Date"
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.MESSAGE;
70  private static final GuiContext guiContext = new GuiContext(itemType, GuiContext.Type.LIST);
71%>
72<%
73final SessionControl sc = Base.getExistingSessionControl(pageContext, Permission.DENIED, itemType);
74final String ID = sc.getId();
75final boolean createPermission = sc.hasPermission(Permission.CREATE, itemType);
76final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null);
77
78final ModeInfo mode = ModeInfo.get(request.getParameter("mode"));
79final String callback = request.getParameter("callback");
80final String title = mode.generateTitle("message", "messages");
81final DbControl dc = sc.newDbControl();
82ItemResultIterator<Message> messages = null;
83try
84{
85  final User user = User.getById(dc, sc.getLoggedInUserId());
86
87  Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext);
88  try
89  {
90    final ItemQuery<Message> query = Base.getConfiguredQuery(dc, cc, true, Message.getQuery(user), mode);
91    messages = query.iterate(dc);
92  }
93  catch (Throwable t)
94  {
95    cc.setMessage(t.getMessage());
96  }
97  int numListed = 0;
98  Formatter<Date> dateTimeFormatter = FormatterFactory.getDateTimeFormatter(sc);
99  JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, guiContext, null);
100  ExtensionsInvoker<ButtonAction> invoker = ToolbarUtil.useExtensions(jspContext);
101  ExtensionsInvoker<ListColumnAction<Message,?>> columnsInvoker = ListColumnUtil.useExtensions(jspContext);
102  %>
103  <base:page title="<%=title==null ? "Messages" : title%>" type="<%=mode.getPageType()%>" id="list-page">
104  <base:head scripts="table.js,~messages.js" styles="table.css,toolbar.css">
105    <ext:scripts context="<%=jspContext%>" />
106    <ext:stylesheets context="<%=jspContext%>" />
107  </base:head>
108 
109  <base:body>
110    <h1><%=title==null ? "Messages" : title%></h1>
111    <div class="content">
112    <tbl:table 
113      id="messages" 
114      columns="<%=cc.getSetting("columns")%>"
115      sortby="<%=cc.getSortProperty()%>" 
116      direction="<%=cc.getSortDirection()%>"
117      action="index.jsp"
118      sc="<%=sc%>"
119      item="<%=itemType%>"
120      filterrows="<%=cc.getFilterRows()%>"
121      subclass="fulltable"
122      >
123      <tbl:hidden 
124        name="mode" 
125        value="<%=mode.getName()%>" 
126      />
127      <tbl:hidden 
128        name="callback" 
129        value="<%=callback%>" 
130        skip="<%=callback == null%>" 
131      />
132      <tbl:columndef 
133        id="name"
134        property="name"
135        datatype="string"
136        title="Subject"
137        sortable="true" 
138        filterable="true"
139        exportable="true"
140        show="always" 
141      />
142      <tbl:columndef 
143        id="id"
144        clazz="uniquecol"
145        property="id"
146        datatype="int"
147        title="ID"
148        sortable="true"
149        filterable="true"
150        exportable="true"
151      />
152      <tbl:columndef 
153        id="from"
154        property="from"
155        datatype="string"
156        title="From"
157        sortable="true" 
158        filterable="true"
159        exportable="true"
160      />
161      <tbl:columndef 
162        id="timeSent"
163        property="timeSent"
164        datatype="timestamp"
165        title="Time sent"
166        sortable="true" 
167        filterable="true"
168        exportable="true"
169        formatter="<%=dateTimeFormatter%>"
170      />
171      <tbl:columndef 
172        id="job"
173        property="job.name"
174        datatype="string"
175        title="Job"
176        sortable="true" 
177        filterable="true"
178        exportable="true"
179      />
180      <tbl:columndef 
181        id="description"
182        property="description"
183        datatype="string"
184        title="Message" 
185        sortable="true" 
186        filterable="true" 
187        exportable="true"
188      />
189      <tbl:columndef
190        id="permission"
191        title="Permission"
192      />
193      <tbl:columndef 
194        id="xt-columns" 
195        extensions="<%=columnsInvoker%>" 
196        jspcontext="<%=jspContext%>" 
197      />
198      <div class="panelgroup bg-filled-50 bottomborder">
199        <tbl:toolbar
200          subclass="bottomborder"
201          visible="<%=mode.hasToolbar()%>"
202          >
203          <tbl:button 
204            id="btnMarkAsRead"
205            image="message.png" 
206            title="Mark as read" 
207            tooltip="Mark the selected messages as read" 
208          />
209          <tbl:button 
210            id="btnDeleteItems"
211            image="delete.png"
212            title="Delete" 
213            tooltip="Delete the selected items" 
214          />
215          <tbl:button 
216            id="btnRestoreItems"
217            image="restore.png"
218            title="Restore" 
219            tooltip="Restore the selected (deleted) items"
220          />
221          <tbl:button 
222            id="btnColumns"
223            image="columns.png" 
224            title="Columns&hellip;" 
225            tooltip="Show, hide and re-order columns" 
226          />
227          <tbl:button 
228            id="btnImport"
229            data-plugin-type="IMPORT"
230            image="import.png" 
231            title="Import&hellip;" 
232            tooltip="Import data" 
233            visible="<%=pluginCount.containsKey(Plugin.MainType.IMPORT)%>"
234          />
235          <tbl:button 
236            id="btnExport"
237            data-plugin-type="EXPORT"
238            image="export.png" 
239            title="Export&hellip;" 
240            tooltip="Export data" 
241            visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>"
242          />
243          <tbl:button 
244            id="btnRunPlugin"
245            data-plugin-type="OTHER"
246            image="runplugin.png" 
247            title="Run plugin&hellip;" 
248            tooltip="Run a plugin" 
249            visible="<%=pluginCount.containsKey(Plugin.MainType.OTHER)%>"
250          />
251          <ext:render extensions="<%=invoker%>" context="<%=jspContext%>" 
252            wrapper="<%=new PrefixSuffixRenderer<ButtonAction>(jspContext, "<td>", "</td>") %>"/>
253        </tbl:toolbar>
254        <tbl:panel>
255          <tbl:presetselector />
256          <tbl:navigator
257            page="<%=cc.getPage()%>" 
258            rowsperpage="<%=cc.getRowsPerPage()%>" 
259            totalrows="<%=messages == null ? 0 : messages.getTotalCount()%>" 
260            visible="<%=mode.hasNavigator()%>"
261          />
262        </tbl:panel>
263      </div>
264      <tbl:data>
265        <tbl:headers>
266          <tbl:headerrow>
267            <tbl:header colspan="3" />
268            <tbl:columnheaders />
269          </tbl:headerrow>
270          <%
271          int numFilters = cc.getNumPropertyFilters();
272          int numRows = cc.getFilterRows();
273          for (int filterNo = 0; filterNo < numRows; filterNo++)
274          {
275            boolean lastRow = filterNo == numRows-1;
276            %>
277            <tbl:headerrow>
278              <tbl:header subclass="index" />
279              <tbl:header 
280                subclass="check" 
281                visible="<%=mode.hasCheck()%>"
282                ><base:icon 
283                  subclass="link table-check"
284                  image="check_uncheck.png" 
285                  tooltip="Toggle all (use CTRL, ALT or SHIFT to check/uncheck)" 
286                  visible="<%=lastRow%>"
287                /></tbl:header>
288              <tbl:header 
289                subclass="check" 
290                visible="<%=mode.hasRadio()%>"
291                />
292              <tbl:header 
293                subclass="icons" 
294                visible="<%=mode.hasIcons()%>"
295                >
296                <base:icon
297                  subclass="link table-filter-row-action"
298                  image="add.png"
299                  tooltip="Add extra filter row"
300                  visible="<%=lastRow%>"
301                /><base:icon
302                  subclass="link table-filter-row-action"
303                  image="remove.png"
304                  tooltip="Remove this filter row"
305                  visible="<%=numRows > 1 || numFilters > 0 %>"
306                  data-remove-row="<%=filterNo%>"
307                />
308              </tbl:header>
309              <tbl:propertyfilter row="<%=filterNo%>" />
310            </tbl:headerrow>
311            <%
312          }
313          %>
314        </tbl:headers>
315        <tbl:rows>
316          <%
317          if (cc.getMessage() != null)
318          {
319            %>
320            <tbl:panel subclass="bg-filled-50">
321              <div class="messagecontainer error"><%=cc.getMessage()%></div>
322            </tbl:panel>
323            <%
324            cc.setMessage(null);
325          }
326          int index = cc.getPage()*cc.getRowsPerPage();
327          int selectedItemId = cc.getId();
328          boolean  editLink = false;
329          if (messages != null)
330          {
331            String tooltip = mode.isSelectionMode() ?
332              "Select this item" : "View this item";
333            while (messages.hasNext())
334            {
335              Message item = messages.next();
336              int itemId = item.getId();
337              String name = HTML.encodeTags(item.getName());
338             
339              boolean deletePermission = item.hasPermission(Permission.DELETE);
340              index++;
341              numListed++;
342              String style = null;
343              if (!item.isRead()) style = "font-weight: bold;";
344              %>
345              <tbl:row style="<%=style%>">
346                <tbl:header 
347                  clazz="index"
348                  ><%=index%></tbl:header>
349                <tbl:header 
350                  clazz="check" 
351                  visible="<%=mode.hasCheck()%>"
352                  ><input 
353                    type="checkbox" 
354                    name="<%=itemId%>" 
355                    value="<%=itemId%>" 
356                    title="<%=name%>" 
357                    <%=cc.getSelected().contains(itemId) ? "checked" : ""%> 
358                  ></tbl:header>
359                <tbl:header 
360                  clazz="check" 
361                  visible="<%=mode.hasRadio()%>"
362                  ><input 
363                    type="radio" 
364                    name="item_id" 
365                    value="<%=itemId%>" 
366                    title="<%=name%>" 
367                    <%=selectedItemId == itemId ? "checked" : ""%>
368                  ></tbl:header>
369                <tbl:header 
370                  clazz="icons" 
371                  visible="<%=mode.hasIcons()%>"
372                  ><base:icon 
373                    image="message.png" 
374                    tooltip="This is a new message" 
375                    visible="<%=!item.isRead()%>"
376                  /><base:icon 
377                    image="deleted.png"
378                    id="<%="delete."+itemId %>"
379                    subclass="<%=deletePermission ? "table-delete-item" : "disabled" %>"
380                    data-item-id="<%=itemId%>"
381                    tooltip="This item has been scheduled for deletion" 
382                    visible="<%=item.isRemoved()%>"
383                  />&nbsp;</tbl:header>
384                <tbl:cell column="name"><div 
385                  class="link table-item"
386                  data-item-id="<%=itemId%>"
387                  data-no-edit="1"
388                  tabindex="0"
389                  title="<%=tooltip%>"><%=name%></div></tbl:cell>
390                <tbl:cell column="id"><%=item.getId()%></tbl:cell>
391                <tbl:cell column="from"><%=HTML.encodeTags(item.getFrom())%></tbl:cell>
392                <tbl:cell column="timeSent" value="<%=item.getTimeSent()%>" />
393                <tbl:cell column="description"><%=HTML.encodeTags(item.getDescription())%></tbl:cell>
394                <tbl:cell column="job"><base:propertyvalue item="<%=item%>" property="job" enableEditLink="<%=editLink%>" enablePropertyLink="<%=mode.hasPropertyLink()%>"/></tbl:cell>
395                <tbl:cell column="permission"><%=PermissionUtil.getShortPermissions(item)%></tbl:cell>
396                <tbl:xt-cells dc="<%=dc%>" item="<%=item%>">
397                  <tbl:cell column="xt-columns" />
398                </tbl:xt-cells>
399              </tbl:row>
400              <%
401              }
402            }
403          if (numListed == 0)
404          {
405            %>
406            <tbl:panel subclass="bg-filled-50">
407              <div class="messagecontainer note">
408              <%=messages == null || messages.getTotalCount() == 0 ? "No messages were found" : "No messages on this page. Please select another page!" %>
409              </div>
410            </tbl:panel>
411            <%
412          }
413          %>
414        </tbl:rows>
415      </tbl:data>
416    </tbl:table>
417    </div>
418   
419    <base:buttongroup subclass="dialogbuttons">
420      <base:button id="btnOk" title="Ok" visible="<%=mode.hasOkButton()%>" />
421      <base:button id="close" title="Cancel" visible="<%=mode.hasCancelButton()%>" />
422      <base:button id="close" title="Close" visible="<%=mode.hasCloseButton()%>" />
423    </base:buttongroup>
424   
425  </base:body>
426  </base:page>
427  <%
428}
429finally
430{
431  if (messages != null) messages.close();
432  if (dc != null) dc.close();
433}
434%>
Note: See TracBrowser for help on using the repository browser.