source: trunk/www/admin/mimetypes/view_mimetype.jsp @ 5941

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

References #1655: GUI improvements

View pages for all items in the Adminstrate menu.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 8.7 KB
Line 
1<%-- $Id: view_mimetype.jsp 5941 2012-02-01 13:26:23Z 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.MimeType"
33  import="net.sf.basedb.core.PermissionDeniedException"
34  import="net.sf.basedb.core.PluginDefinition"
35  import="net.sf.basedb.core.plugin.GuiContext"
36  import="net.sf.basedb.core.plugin.Plugin"
37  import="net.sf.basedb.clients.web.Base"
38  import="net.sf.basedb.clients.web.PermissionUtil"
39  import="net.sf.basedb.clients.web.util.HTML"
40  import="net.sf.basedb.util.Values"
41  import="net.sf.basedb.util.formatter.Formatter"
42  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
43  import="net.sf.basedb.clients.web.extensions.ExtensionsControl"
44  import="net.sf.basedb.clients.web.extensions.JspContext"
45  import="net.sf.basedb.clients.web.extensions.renderer.PrefixSuffixRenderer"
46  import="net.sf.basedb.clients.web.extensions.toolbar.ToolbarUtil"
47  import="net.sf.basedb.util.extensions.ExtensionsInvoker"
48  import="java.util.Date"
49  import="java.util.Map"
50%>
51<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
52<%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %>
53<%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %>
54<%@ taglib prefix="p" uri="/WEB-INF/path.tld" %>
55<%@ taglib prefix="ext" uri="/WEB-INF/extensions.tld" %>
56<%!
57  private static final Item itemType = Item.MIMETYPE;
58  private static final GuiContext guiContext = new GuiContext(itemType, GuiContext.Type.ITEM);
59%>
60<%
61final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
62final String ID = sc.getId();
63final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null);
64final int itemId = cc.getId();
65final float scale = Base.getScale(sc);
66final DbControl dc = sc.newDbControl();
67try
68{
69  Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc);
70  Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext);
71
72  String title = null;
73  MimeType mimeType = MimeType.getById(dc, itemId);
74 
75  final boolean writePermission = mimeType.hasPermission(Permission.WRITE);
76  final boolean deletePermission = mimeType.hasPermission(Permission.DELETE);
77  final boolean isRemoved = mimeType.isRemoved();
78  final boolean isUsed = isRemoved && mimeType.isUsed();
79  final boolean deletePermanentlyPermission = deletePermission && !isUsed;
80  JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, guiContext, mimeType);
81  ExtensionsInvoker invoker = ToolbarUtil.useExtensions(jspContext);
82  %>
83  <base:page title="<%=title%>">
84  <base:head scripts="tabcontrol.js,table.js" styles="toolbar.css,headertabcontrol.css,path.css,table.css">
85    <ext:scripts context="<%=jspContext%>" />
86    <ext:stylesheets context="<%=jspContext%>" />
87    <script language="JavaScript">
88    function editItem()
89    {
90      Main.viewOrEditItem('<%=ID%>', '<%=itemType.name()%>', <%=itemId%>, true);
91    }
92    function deleteItem()
93    {
94      location.replace('index.jsp?ID=<%=ID%>&cmd=DeleteItem&item_id=<%=itemId%>');
95    }
96    function restoreItem()
97    {
98      location.replace('index.jsp?ID=<%=ID%>&cmd=RestoreItem&item_id=<%=itemId%>');
99    }
100    function deleteItemPermanently()
101    {
102      Main.deleteItemPermanently('<%=ID%>', true, '<%=itemType.name()%>', <%=itemId%>, '&callback=itemDeleted');
103    }
104    function itemDeleted()
105    {
106      Main.listItems('<%=ID%>', '<%=itemType.name()%>');
107    }
108    function showUsingItems()
109    {
110      Main.showUsingItems('<%=ID%>', '<%=itemType.name()%>', <%=itemId%>);
111    }
112    function runPlugin(cmd)
113    {
114      Main.openPopup('index.jsp?ID=<%=ID%>&cmd='+cmd+'&item_id=<%=itemId%>', 'RunPlugin'+cmd, 750, 500);
115    }
116    </script>
117  </base:head>
118  <base:body>
119    <p:path><p:pathelement 
120      title="MIME types" href="<%="index.jsp?ID="+ID%>" 
121      /><p:pathelement title="<%=HTML.encodeTags(mimeType.getName() + " (" + mimeType.getExtension() + ")")%>" 
122      /></p:path>
123   
124    <t:tabcontrol 
125      id="main" 
126      subclass="content mastertabcontrol" 
127      active="properties">
128    <t:tab id="properties" title="Properties">
129      <div>
130      <table class="fullform bottomborder">
131      <tr>
132        <th class="itemstatus">
133          <base:icon 
134            image="deleted.gif"
135            onclick="deleteItemPermanently()"
136            tooltip="This item has been flagged for deletion. Click to delete it now."
137            enabled="<%=deletePermanentlyPermission %>"
138            visible="<%=isRemoved%>" 
139          />
140          <base:icon image="used.gif" 
141            onclick="showUsingItems()"
142            tooltip="This item is used by other items and can't be permanently deleted. Show the items that are using this one"
143            visible="<%=isRemoved && isUsed%>" />
144        </th>
145        <td style="padding: 0px;">
146          <tbl:toolbar subclass="bottomborder">
147            <tbl:button 
148              disabled="<%=writePermission ? false : true%>" 
149              image="edit.gif" 
150              onclick="editItem()" 
151              title="Edit&hellip;" 
152              tooltip="<%=writePermission ? "Edit this MIME type" : "You do not have permission to edit this MIME type"%>" 
153            />
154            <tbl:button 
155              disabled="<%=deletePermission ? false : true%>" 
156              image="delete.gif" 
157              onclick="deleteItem()" 
158              title="Delete"
159              visible="<%=!mimeType.isRemoved()%>"
160              tooltip="<%=deletePermission ? "Delete this MIME type" : "You do not have permission to delete this MIME type"%>" 
161            />
162            <tbl:button 
163              disabled="<%=writePermission ? false : true%>" 
164              image="restore.gif" 
165              onclick="restoreItem()" 
166              title="Restore"
167              visible="<%=mimeType.isRemoved()%>"
168              tooltip="<%=writePermission ? "Restore this MIME type" : "You do not have permission to restore this MIME type"%>" 
169            />
170            <tbl:button 
171              image="import.gif" 
172              onclick="runPlugin('ImportItem')" 
173              title="Import&hellip;" 
174              tooltip="Import data" 
175              visible="<%=pluginCount.containsKey(Plugin.MainType.IMPORT)%>"
176            />
177            <tbl:button 
178              image="export.gif" 
179              onclick="runPlugin('ExportItem')" 
180              title="Export&hellip;" 
181              tooltip="Export data" 
182              visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>"
183            />
184            <tbl:button 
185              image="runplugin.gif" 
186              onclick="runPlugin('RunPlugin')" 
187              title="Run plugin&hellip;" 
188              tooltip="Run a plugin" 
189              visible="<%=pluginCount.containsKey(Plugin.MainType.OTHER)%>"
190            />
191            <ext:render extensions="<%=invoker%>" context="<%=jspContext%>" 
192              wrapper="<%=new PrefixSuffixRenderer(jspContext, "<td>", "</td>") %>"/>
193            <tbl:button
194              image="help.png"
195              onclick="<%="Main.openHelp('" + ID +"', 'mimetype.view.properties')"%>"
196              title="Help&hellip;"
197              tooltip="Get help about this page"
198            />
199          </tbl:toolbar>
200        </td>
201      </tr>
202      <tr>
203        <th>File extension</th>
204        <td><%=HTML.encodeTags(mimeType.getExtension())%></td>
205      </tr>
206      <tr>
207        <th>Registered</th>
208        <td><%=dateFormatter.format(mimeType.getEntryDate())%></td>
209      </tr>
210      <tr>
211        <th>MIME type</th>
212        <td><%=HTML.encodeTags(mimeType.getName())%></td>
213      </tr>
214      <tr>
215        <th>File type</th>
216        <td><base:propertyvalue item="<%=mimeType%>" property="fileType" /></td>
217      </tr>
218      <tr>
219        <th>Auto compress</th>
220        <td><%=mimeType.getAutoCompress() ? "yes" : "no"%></td>
221      </tr>
222      <tr>
223        <th>Permissions</th>
224        <td><%=PermissionUtil.getFullPermissionNames(mimeType)%></td>
225      </tr>
226      <tr>
227        <th>Description</th>
228        <td><%=HTML.niceFormat(mimeType.getDescription())%></td>
229      </tr>
230      </table>
231      </div>
232      <jsp:include page="../../common/anytoany/list_anytoany.jsp">
233        <jsp:param name="ID" value="<%=ID%>" />
234        <jsp:param name="item_type" value="<%=itemType.name()%>" />
235        <jsp:param name="item_id" value="<%=itemId%>" />
236        <jsp:param name="title" value="Other items related to this sample" />
237      </jsp:include> 
238    </t:tab>
239    </t:tabcontrol>
240
241  </base:body>
242  </base:page>
243  <%
244}
245finally
246{
247  if (dc != null) dc.close();
248}
249
250%>
Note: See TracBrowser for help on using the repository browser.