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