source: extensions/net.sf.basedb.examples/trunk/resources/item_info.jsp @ 1537

Last change on this file since 1537 was 1537, checked in by Nicklas Nordborg, 12 years ago

Fixes #359: Changes related to new GUI in BASE 3.1

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 3.8 KB
Line 
1<%-- 
2  Copyright (C) 2011 Nicklas Nordborg
3
4  This file is part of the Example Code Package for BASE.
5  Available at http://baseplugins.thep.lu.se/
6  BASE main site: http://base.thep.lu.se/
7 
8  This 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  The software 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<%@ page
22  pageEncoding="UTF-8"
23  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.BasicItem"
28  import="net.sf.basedb.core.Nameable"
29  import="net.sf.basedb.core.Registered"
30  import="net.sf.basedb.core.Shareable"
31  import="net.sf.basedb.core.Removable"
32  import="net.sf.basedb.core.Ownable"
33  import="net.sf.basedb.core.Reporter"
34  import="net.sf.basedb.core.data.ReporterData"
35  import="net.sf.basedb.util.Values"
36  import="net.sf.basedb.util.formatter.Formatter"
37  import="net.sf.basedb.clients.web.Base"
38  import="net.sf.basedb.clients.web.util.HTML"
39  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
40  import="java.util.Date"
41%>
42<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
43<%
44final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
45final String ID = sc.getId();
46final DbControl dc = sc.newDbControl();
47final Item itemType = Item.valueOf(request.getParameter("item_type"));
48final int itemId = Values.getInt(request.getParameter("item_id"));
49try
50{
51  String name = null;
52  Date registered = null;
53  boolean isShared = false;
54  boolean isRemoved = false;
55  boolean isOwnedByYou = false;
56  if (itemType.getItemClass() != null)
57  {
58    BasicItem item = itemType.getById(dc, itemId);
59    name = item instanceof Nameable ? ((Nameable)item).getName() : item.toString();
60    if (item instanceof Registered) registered = ((Registered)item).getEntryDate();
61    if (item instanceof Shareable) isShared = ((Shareable)item).isShared();
62    if (item instanceof Removable) isRemoved = ((Removable)item).isRemoved();
63    if (item instanceof Ownable) isOwnedByYou = ((Ownable)item).isOwner();
64  }
65  else if (itemType == Item.REPORTER)
66  {
67    ReporterData reporter = Reporter.getById(dc, itemId);
68    name = reporter.getName();
69    registered = reporter.getEntryDate();
70  }
71
72  Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc);
73  %>
74  <base:page type="popup" title="Item information">
75  <base:head />
76  <base:body>
77    <h1>Item information</h1>
78    <div class="content bottomborder">
79     
80      <table class="fullform larger">
81      <tr>
82        <th>Type</th>
83        <td><%=itemType.name()%></td>
84      </tr>
85      <tr>
86        <th>ID</th>
87        <td><%=itemId%></td>
88      </tr>
89      <tr>
90        <th>Name</th>
91        <td><%=name == null ? "<i>unknown</i>" : HTML.niceFormat(name)%></td>
92      </tr>
93      <tr>
94        <th>Registration date</th>
95        <td><%=registered == null ? "<i>unknown</i>" : dateFormatter.format(registered)%></td>
96      </tr>
97      <tr>
98        <th>Owned by you?</th>
99        <td><%=isOwnedByYou ? "yes" : "no"%></td>
100      </tr>
101      <tr>
102        <th>Shared to other users?</th>
103        <td><%=isShared ? "yes" : "no"%></td>
104      </tr>
105      <tr>
106        <th>Marked for removal?</th>
107        <td><%=isRemoved ? "yes" : "no"%></td>
108      </tr>
109      <tr class="dynamic">
110        <th></th>
111        <td></td>
112      </tr>
113      </table>
114    </div>
115
116    <base:buttongroup subclass="dialogbuttons">
117      <base:button onclick="window.close()" title="Close" />
118    </base:buttongroup>
119  </base:body>
120  </base:page>
121  <%
122}
123finally
124{
125  if (dc != null) dc.close();
126}
127%>
Note: See TracBrowser for help on using the repository browser.