source: trunk/www/admin/datafiletypes/view_filetype.jsp @ 6605

Last change on this file since 6605 was 6605, checked in by Nicklas Nordborg, 8 years ago

References #1890: Improve skinnability of BASE

Updated regular view pages and edit dialogs.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 10.5 KB
Line 
1<%-- $Id:view_filetype.jsp 3820 2007-10-12 10:03:18Z nicklas $
2  ------------------------------------------------------------------
3  Copyright (C) 2006 Jari Häkkinen, Nicklas Nordborg, Martin Svensson
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.SystemItems"
29  import="net.sf.basedb.core.Item"
30  import="net.sf.basedb.core.ItemContext"
31  import="net.sf.basedb.core.Permission"
32  import="net.sf.basedb.core.DataFileType"
33  import="net.sf.basedb.core.Platform"
34  import="net.sf.basedb.core.PlatformVariant"
35  import="net.sf.basedb.core.PlatformFileType"
36  import="net.sf.basedb.core.Include"
37  import="net.sf.basedb.core.ItemQuery"
38  import="net.sf.basedb.core.ItemResultList"
39  import="net.sf.basedb.core.PermissionDeniedException"
40  import="net.sf.basedb.core.PluginDefinition"
41  import="net.sf.basedb.core.plugin.GuiContext"
42  import="net.sf.basedb.core.plugin.Plugin"
43  import="net.sf.basedb.core.query.Orders"
44  import="net.sf.basedb.core.query.Hql"
45  import="net.sf.basedb.clients.web.Base"
46  import="net.sf.basedb.clients.web.PermissionUtil"
47  import="net.sf.basedb.clients.web.util.HTML"
48  import="net.sf.basedb.util.formatter.Formatter"
49  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
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.ToolbarUtil"
54  import="net.sf.basedb.util.extensions.ExtensionsInvoker"
55  import="net.sf.basedb.util.Values"
56  import="java.util.Map"
57  import="java.util.Date"
58%>
59<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
60<%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %>
61<%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %>
62<%@ taglib prefix="p" uri="/WEB-INF/path.tld" %>
63<%@ taglib prefix="ext" uri="/WEB-INF/extensions.tld" %>
64<%!
65  private static final Item itemType = Item.DATAFILETYPE;
66  private static final GuiContext guiContext = new GuiContext(itemType, GuiContext.Type.ITEM);
67%>
68<%
69final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
70final String ID = sc.getId();
71final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null);
72final int itemId = cc.getId();
73final String tab = Values.getStringOrNull(request.getParameter("tab"));
74final float scale = Base.getScale(sc);
75final DbControl dc = sc.newDbControl();
76try
77{
78  Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext);
79
80  String title = null;
81  DataFileType fileType = DataFileType.getById(dc, itemId);
82 
83  final boolean writePermission = fileType.hasPermission(Permission.WRITE);
84  final boolean deletePermission = fileType.hasPermission(Permission.DELETE);
85  final boolean isRemoved = fileType.isRemoved();
86  final boolean isUsed = isRemoved && fileType.isUsed();
87  final boolean deletePermanentlyPermission = deletePermission && !isUsed;
88  JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, guiContext, fileType);
89  ExtensionsInvoker invoker = ToolbarUtil.useExtensions(jspContext);
90  %>
91  <base:page title="<%=title%>" id="view-page">
92  <base:head scripts="tabcontrol-2.js,~filetypes.js" styles="toolbar.css,headertabcontrol.css,path.css,table.css">
93    <ext:scripts context="<%=jspContext%>" />
94    <ext:stylesheets context="<%=jspContext%>" />
95  </base:head>
96  <base:body>
97    <p:path><p:pathelement 
98      title="Data file types" href="<%="index.jsp?ID="+ID%>" 
99      /><p:pathelement title="<%=HTML.encodeTags(fileType.getName())%>" 
100      /></p:path>
101    <div id="page-data" data-item-id="<%=itemId%>"></div>
102   
103    <t:tabcontrol 
104      id="main" 
105      subclass="content mastertabcontrol" 
106      active="<%=tab%>">
107    <t:tab id="properties" title="Properties">
108      <div>
109      <table class="fullform bottomborder">
110      <tr>
111        <th class="itemstatus">
112          <base:icon 
113            id="btnDeletePermanently"
114            image="deleted.png"
115            tooltip="This item has been flagged for deletion. Click to delete it now."
116            enabled="<%=deletePermanentlyPermission %>"
117            visible="<%=isRemoved%>" 
118          />
119          <base:icon 
120            id="btnUsingItems"
121            image="used.png" 
122            tooltip="This item is used by other items and can't be permanently deleted. Show the items that are using this one"
123            visible="<%=isRemoved && isUsed%>" />
124        </th>
125        <td style="padding: 0px;">
126          <tbl:toolbar subclass="bottomborder bg-filled-50">
127            <tbl:button 
128              id="btnEdit"
129              disabled="<%=!writePermission%>" 
130              image="edit.png" 
131              title="Edit&hellip;" 
132              tooltip="<%=writePermission ? "Edit this data file type" : "You do not have permission to edit this data file type"%>" 
133            />
134            <tbl:button 
135              id="btnDelete"
136              disabled="<%=!deletePermission%>" 
137              image="delete.png" 
138              title="Delete"
139              visible="<%=!fileType.isRemoved()%>"
140              tooltip="<%=deletePermission ? "Delete this data file type" : "You do not have permission to delete this data file type"%>" 
141            />
142            <tbl:button 
143              id="btnRestore"
144              disabled="<%=!writePermission%>" 
145              image="restore.png" 
146              title="Restore"
147              visible="<%=fileType.isRemoved()%>"
148              tooltip="<%=writePermission ? "Restore this data file type" : "You do not have permission to restore this data file type"%>" 
149            />
150            <tbl:button 
151              id="btnImport"
152              image="import.png" 
153              data-plugin-type="IMPORT" 
154              title="Import&hellip;" 
155              tooltip="Import data" 
156              visible="<%=pluginCount.containsKey(Plugin.MainType.IMPORT)%>"
157            />
158            <tbl:button 
159              id="btnExport"
160              image="export.png"
161              data-plugin-type="EXPORT" 
162              title="Export&hellip;" 
163              tooltip="Export data" 
164              visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>"
165            />
166            <tbl:button 
167              id="btnRunPlugin"
168              image="runplugin.png" 
169              data-plugin-type="OTHER" 
170              title="Run plugin&hellip;" 
171              tooltip="Run a plugin" 
172              visible="<%=pluginCount.containsKey(Plugin.MainType.OTHER)%>"
173            />
174            <ext:render extensions="<%=invoker%>" context="<%=jspContext%>" 
175              wrapper="<%=new PrefixSuffixRenderer(jspContext, "<td>", "</td>") %>"/>
176            <tbl:button
177              image="help.png"
178              subclass="auto-init"
179              data-auto-init="help"
180              data-help-id="datafiletype.view.properties"
181              title="Help&hellip;"
182              tooltip="Get help about this page"
183            />
184          </tbl:toolbar>
185        </td>
186      </tr>
187      <tr>
188        <th>Name</th>
189        <td><%=HTML.encodeTags(fileType.getName())%></td>
190      </tr>
191      <tr>
192        <th>External ID</th>
193        <td><%=HTML.encodeTags(fileType.getExternalId())%></td>
194      </tr>
195      <tr>
196        <th>Item type</th>
197        <td><%=fileType.getItemType()%></td>
198      </tr>
199      <tr>
200        <th>File extension</th>
201        <td><%=HTML.encodeTags(fileType.getExtension())%></td>
202      </tr>
203      <tr>
204        <th>Generic file type</th>
205        <td><base:propertyvalue item="<%=fileType%>" property="genericType" /></td>
206      </tr>
207      <tr>
208        <th>Permissions</th>
209        <td><%=PermissionUtil.getFullPermissionNames(fileType)%></td>
210      </tr>
211      <tr >
212        <th>Description</th>
213        <td><%=HTML.niceFormat(fileType.getDescription())%></td>
214      </tr>
215      </table>
216      </div>
217      <%
218      ItemQuery<PlatformFileType> platformQuery = fileType.getPlatforms();
219      platformQuery.include(Include.ALL);
220      platformQuery.order(Orders.asc(Hql.property("platform.name")));
221      ItemResultList<PlatformFileType> platforms = platformQuery.list(dc);
222      %>
223      <base:section 
224        id="platforms"
225        title="<%="Used on platforms (" + platforms.size() + ")"%>"
226        context="<%=cc%>"
227        >
228        <%
229        if (platforms.size() == 0)
230        {
231          %>
232          <div class="messagecontainer note">
233          This file type is not used by any platforms or variants
234          (or, you don't have permission to view them).
235          </div>
236          <%
237        }
238        else
239        {
240          %>
241          <tbl:table
242            id="tbl.platforms"
243            columns="all"
244            >
245            <tbl:columndef 
246              id="platform"
247              title="Platform"
248            />
249            <tbl:columndef 
250              id="variant"
251              title="Variant"
252            />
253            <tbl:columndef 
254              id="required"
255              title="Required"
256            />
257            <tbl:columndef 
258              id="multiple"
259              title="Multiple files"
260            />
261            <tbl:data>
262              <tbl:headers>
263                <tbl:headerrow>
264                  <tbl:columnheaders />
265                </tbl:headerrow>
266              </tbl:headers>
267              <tbl:rows>
268              <%
269              for (PlatformFileType item : platforms)
270              {
271                Platform p = item.getPlatform();
272                PlatformVariant v = item.getVariant();
273                %>
274                <tbl:row>
275                  <tbl:cell column="platform"><base:icon 
276                      image="deleted.png" 
277                      tooltip="This item has been scheduled for deletion" 
278                      visible="<%=p.isRemoved()%>"
279                    /><%=Base.getLinkedName(ID, p, false, true)%></tbl:cell>
280                  <tbl:cell column="variant"><base:icon 
281                      image="deleted.png" 
282                      tooltip="This item has been scheduled for deletion" 
283                      visible="<%=v!= null && v.isRemoved()%>"
284                    /><%=v == null ? "<i>- all -</i>" : Base.getLinkedName(ID, v, false, true)%></tbl:cell>
285                  <tbl:cell column="required"><%=item.isRequired() ? "yes" : "no"%></tbl:cell>
286                  <tbl:cell column="multiple"><%=item.getAllowMultiple() ? "yes" : "no"%></tbl:cell>
287                </tbl:row>
288                <%
289              }
290              %>
291              </tbl:rows>
292            </tbl:data>
293          </tbl:table>
294          <%
295        }
296        %>
297      </base:section>
298      <jsp:include page="../../common/anytoany/list_anytoany.jsp">
299        <jsp:param name="ID" value="<%=ID%>" />
300        <jsp:param name="item_type" value="<%=itemType.name()%>" />
301        <jsp:param name="item_id" value="<%=itemId%>" />
302        <jsp:param name="title" value="Other items related to this file type" />
303      </jsp:include>
304     
305      </t:tab>
306      </t:tabcontrol>
307  </base:body>
308  </base:page>
309  <%
310}
311finally
312{
313  if (dc != null) dc.close();
314}
315
316%>
Note: See TracBrowser for help on using the repository browser.