source: trunk/www/admin/extravaluetypes/view_extravaluetype.jsp @ 5937

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

References #1655: GUI improvements

  • Fixes rest of view pages in biomaterials menu.
  • Use SVG filter to make disabled button images grayscale.
  • 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 5937 2012-01-27 11:00:26Z 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>
122    <p:path>
123      <p:pathelement title="Extra value types" href="<%="index.jsp?ID="+ID%>" />
124      <p:pathelement title="<%=HTML.encodeTags(extraValueType.getName())%>" />
125    </p:path>
126   
127    <t:tabcontrol id="main" active="properties">
128    <t:tab id="properties" title="Properties">
129   
130    <tbl:toolbar
131      >
132      <tbl:button 
133        disabled="<%=writePermission ? false : true%>" 
134        image="edit.gif" 
135        onclick="editItem()" 
136        title="Edit&hellip;" 
137        tooltip="<%=writePermission ? "Edit this extra value type" : "You do not have permission to edit this extra value type"%>" 
138      />
139      <tbl:button 
140        disabled="<%=deletePermission ? false : true%>" 
141        image="delete.gif" 
142        onclick="deleteItem()" 
143        title="Delete"
144        visible="<%=!extraValueType.isRemoved()%>"
145        tooltip="<%=deletePermission ? "Delete this extra value type" : "You do not have permission to delete this extra value type"%>" 
146      />
147      <tbl:button 
148        disabled="<%=writePermission ? false : true%>" 
149        image="restore.gif" 
150        onclick="restoreItem()" 
151        title="Restore"
152        visible="<%=extraValueType.isRemoved()%>"
153        tooltip="<%=writePermission ? "Restore this extra value type" : "You do not have permission to restore this extra value type"%>" 
154      />
155      <tbl:button 
156        image="import.gif" 
157        onclick="runPlugin('ImportItem')" 
158        title="Import&hellip;" 
159        tooltip="Import data" 
160        visible="<%=pluginCount.containsKey(Plugin.MainType.IMPORT)%>"
161      />
162      <tbl:button 
163        image="export.gif" 
164        onclick="runPlugin('ExportItem')" 
165        title="Export&hellip;" 
166        tooltip="Export data" 
167        visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>"
168      />
169      <tbl:button 
170        image="runplugin.gif" 
171        onclick="runPlugin('RunPlugin')" 
172        title="Run plugin&hellip;" 
173        tooltip="Run a plugin" 
174        visible="<%=pluginCount.containsKey(Plugin.MainType.OTHER)%>"
175      />
176      <ext:render extensions="<%=invoker%>" context="<%=jspContext%>" 
177        wrapper="<%=new PrefixSuffixRenderer(jspContext, "<td>", "</td>") %>"/>
178      <tbl:button
179        image="help.png"
180        onclick="<%="Main.openHelp('" + ID +"', 'extravaluetype.view.properties')"%>"
181        title="Help&hellip;"
182        tooltip="Get help about this page"
183      />
184      </tbl:toolbar>
185    <div class="boxedbottom">
186      <div class="itemstatus">Permissions on this item: <i><%=PermissionUtil.getFullPermissionNames(extraValueType)%></i></div>
187      <%
188      if (extraValueType.isRemoved())
189      {
190        %>
191        <div class="itemstatus">
192          <base:icon 
193            image="<%=deletePermanentlyPermission ? "deleted.gif" : "deleted_disabled.gif"%>"
194            onclick="<%=deletePermanentlyPermission ? "deleteItemPermanently()" : null%>"
195            tooltip="<%=deletePermanentlyPermission ? "Permanently delete this item" : null%>"
196            visible="<%=isRemoved%>"> This item has been flagged for deletion<br></base:icon>
197          <base:icon image="used.gif" 
198            onclick="showUsingItems()"
199            tooltip="Show the items that are using this one"
200            visible="<%=isUsed%>"> This item is used by other items and can't be permanently deleted<br></base:icon>
201        </div>
202        <%
203      }
204      %>
205      <table class="form" cellspacing=0>
206      <tr>
207        <td class="prompt">Name</td>
208        <td><%=HTML.encodeTags(extraValueType.getName())%></td>
209      </tr>
210      <tr>
211        <td class="prompt">Registered</td>
212        <td><%=dateFormatter.format(extraValueType.getEntryDate())%></td>
213      </tr>
214      <tr>
215        <td class="prompt">External ID</td>
216        <td><%=HTML.encodeTags(extraValueType.getExternalId())%></td>
217      </tr>
218      <tr>
219        <td class="prompt">Value type</td>
220        <td><%=extraValueType.getValueType()%></td>
221      </tr>
222      <tr>
223        <td class="prompt">Avg. method</td>
224        <td><%=extraValueType.getAverageMethod().toString()%></td>
225      </tr>
226      <tr>
227        <td class="prompt">Use coloring</td>
228        <td>
229          <%=coloring.isUsingColors() ? "yes" : "no"%>
230          <%
231          if (coloring.isUsingColors())
232          {
233            %>
234            <b>Range</b> 
235            [<%=Values.formatNumber(coloring.getMinValue(), 2)%>,
236            <%=Values.formatNumber(coloring.getMidValue(), 2)%>,
237            <%=Values.formatNumber(coloring.getMaxValue(), 2)%>]
238            <b>Logarithmic</b> <%=coloring.isLogarithmic() ? "yes" : "no" %>
239            <%
240          }
241          %>
242        </td>
243      </tr>
244      <tr>
245        <td class="prompt">Description</td>
246        <td><%=HTML.niceFormat(extraValueType.getDescription())%></td>
247      </tr>
248      </table>
249      <jsp:include page="../../common/anytoany/list_anytoany.jsp">
250        <jsp:param name="ID" value="<%=ID%>" />
251        <jsp:param name="item_type" value="<%=itemType.name()%>" />
252        <jsp:param name="item_id" value="<%=itemId%>" />
253        <jsp:param name="title" value="Other items related to this extra value type" />
254      </jsp:include>
255     
256    </div>
257      </t:tab>
258      </t:tabcontrol>
259
260  </base:body>
261  </base:page>
262  <%
263}
264finally
265{
266  if (dc != null) dc.close();
267}
268
269%>
Note: See TracBrowser for help on using the repository browser.