source: trunk/www/views/formulas/view_formula.jsp @ 5939

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

References #1655: GUI improvements

View pages for:

  • File server
  • Projects
  • Permission templates
  • Physical, derived and raw bioassays
  • Experiments, bioassay set
  • Formulas
  • Reporters
  • Reporter lists
  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 13.1 KB
Line 
1<%-- $Id: view_formula.jsp 5939 2012-01-30 14:42:18Z nicklas $
2  ------------------------------------------------------------------
3  Copyright (C) 2006 Jari Häkkinen, Nicklas Nordborg, Martin Svensson
4  Copyright (C) 2007 Nicklas Nordborg, Martin Svensson
5
6  This file is part of BASE - BioArray Software Environment.
7  Available at http://base.thep.lu.se/
8
9  BASE is free software; you can redistribute it and/or
10  modify it under the terms of the GNU General Public License
11  as published by the Free Software Foundation; either version 3
12  of the License, or (at your option) any later version.
13
14  BASE is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  GNU General Public License for more details.
18
19  You should have received a copy of the GNU General Public License
20  along with BASE. If not, see <http://www.gnu.org/licenses/>.
21  ------------------------------------------------------------------
22
23  @author Nicklas
24  @version 2.0
25--%>
26<%@ page pageEncoding="UTF-8" session="false"
27  import="net.sf.basedb.core.SessionControl"
28  import="net.sf.basedb.core.DbControl"
29  import="net.sf.basedb.core.SystemItems"
30  import="net.sf.basedb.core.Group"
31  import="net.sf.basedb.core.Item"
32  import="net.sf.basedb.core.ItemContext"
33  import="net.sf.basedb.core.ItemResultList"
34  import="net.sf.basedb.core.MultiPermissions"
35  import="net.sf.basedb.core.Permission"
36  import="net.sf.basedb.core.Formula"
37  import="net.sf.basedb.core.Coloring"
38  import="net.sf.basedb.core.User"
39  import="net.sf.basedb.core.RawDataType"
40  import="net.sf.basedb.core.PermissionDeniedException"
41  import="net.sf.basedb.core.PluginDefinition"
42  import="net.sf.basedb.core.plugin.GuiContext"
43  import="net.sf.basedb.core.plugin.Plugin"
44  import="net.sf.basedb.core.Project"
45  import="net.sf.basedb.util.Values"
46  import="net.sf.basedb.clients.web.Base"
47  import="net.sf.basedb.clients.web.ChangeHistoryUtil"
48  import="net.sf.basedb.clients.web.PermissionUtil"
49  import="net.sf.basedb.clients.web.util.HTML"
50  import="net.sf.basedb.util.formatter.Formatter"
51  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
52  import="net.sf.basedb.clients.web.extensions.ExtensionsControl"
53  import="net.sf.basedb.clients.web.extensions.JspContext"
54  import="net.sf.basedb.clients.web.extensions.renderer.PrefixSuffixRenderer"
55  import="net.sf.basedb.clients.web.extensions.toolbar.ToolbarUtil"
56  import="net.sf.basedb.util.extensions.ExtensionsInvoker"
57  import="java.util.Date"
58  import="java.util.Collections"
59  import="java.util.List"
60  import="java.util.Map"
61  import="java.util.Set"
62%>
63<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
64<%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %>
65<%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %>
66<%@ taglib prefix="p" uri="/WEB-INF/path.tld" %>
67<%@ taglib prefix="ext" uri="/WEB-INF/extensions.tld" %>
68<%!
69  private static final Item itemType = Item.FORMULA;
70  private static final GuiContext guiContext = new GuiContext(itemType, GuiContext.Type.ITEM);
71%>
72<%
73final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
74final String ID = sc.getId();
75final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null);
76final int itemId = cc.getId();
77final String tab = Values.getString(request.getParameter("tab"), "properties");
78final float scale = Base.getScale(sc);
79final DbControl dc = sc.newDbControl();
80try
81{
82  Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc);
83  Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext);
84
85  String title = null;
86  final Formula formula = Formula.getById(dc, itemId);
87  final RawDataType rawDataType = formula.getRawDataType();
88  final List<String> expressions = formula.getFormulas();
89  final Coloring coloring = formula.getColoring();
90 
91  final boolean writePermission = formula.hasPermission(Permission.WRITE);
92  final boolean deletePermission = formula.hasPermission(Permission.DELETE);
93  final boolean sharePermission = formula.hasPermission(Permission.SET_PERMISSION);
94  final boolean setOwnerPermission = formula.hasPermission(Permission.SET_OWNER);
95  final boolean isRemoved = formula.isRemoved();
96  final boolean isUsed = isRemoved && formula.isUsed();
97  final boolean deletePermanentlyPermission = deletePermission && !isUsed;
98  final boolean isOwner = formula.isOwner();
99  JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, guiContext, formula);
100  ExtensionsInvoker invoker = ToolbarUtil.useExtensions(jspContext);
101  %>
102  <base:page title="<%=title%>">
103  <base:head scripts="table.js,tabcontrol.js" styles="table.css,toolbar.css,headertabcontrol.css,path.css">
104    <ext:scripts context="<%=jspContext%>" />
105    <ext:stylesheets context="<%=jspContext%>" />
106    <script language="JavaScript">
107    function editItem()
108    {
109      Main.viewOrEditItem('<%=ID%>', '<%=itemType.name()%>', <%=itemId%>, true);
110    }
111    function shareItem()
112    {
113      Main.openPopup('index.jsp?ID=<%=ID%>&cmd=ShareItem&item_id=<%=itemId%>', 'ShareFormula', 600, 400);
114    }
115    function deleteItem()
116    {
117      location.replace('index.jsp?ID=<%=ID%>&cmd=DeleteItem&item_id=<%=itemId%>');
118    }
119    function restoreItem()
120    {
121      location.replace('index.jsp?ID=<%=ID%>&cmd=RestoreItem&item_id=<%=itemId%>');
122    }
123    function deleteItemPermanently()
124    {
125      Main.deleteItemPermanently('<%=ID%>', true, '<%=itemType.name()%>', <%=itemId%>, '&callback=itemDeleted');
126    }
127    function itemDeleted()
128    {
129      Main.listItems('<%=ID%>', '<%=itemType.name()%>');
130    }
131    function showUsingItems()
132    {
133      Main.showUsingItems('<%=ID%>', '<%=itemType.name()%>', <%=itemId%>);
134    }
135    function setOwner()
136    {
137      Main.openPopup('index.jsp?ID=<%=ID%>&cmd=SetOwnerOfItem&item_id=<%=itemId%>', 'SetOwnerOfItem', 450, 300);
138    }
139    function runPlugin(cmd)
140    {
141      Main.openPopup('index.jsp?ID=<%=ID%>&cmd='+cmd+'&item_id=<%=itemId%>', 'RunPlugin'+cmd, 750, 500);
142    }
143    function switchTab(tabControlId, tabId)
144    {
145      if (TabControl.isActive(tabControlId, tabId)) return;
146      if (tabId == 'history' && tabId != '<%=tab%>')
147      {
148        location.href = 'index.jsp?ID=<%=ID%>&cmd=ViewItem&item_id=<%=itemId%>&tab='+tabId;
149      }
150      else
151      {
152        TabControl.setActiveTab(tabControlId, tabId);
153      }
154    }
155    </script>
156  </base:head>
157  <base:body>
158    <p:path><p:pathelement
159      title="Formulas" href="<%="index.jsp?ID="+ID%>" 
160      /><p:pathelement title="<%=HTML.encodeTags(formula.getName())%>"
161      /></p:path>
162   
163    <t:tabcontrol 
164      id="main" 
165      subclass="content mastertabcontrol" 
166      active="<%=tab%>" switch="switchTab" remember="false">
167    <t:tab id="properties" title="Properties">
168      <div>
169      <table class="fullform bottomborder">
170      <tr>
171        <th class="itemstatus">
172          <base:icon 
173            image="shared.gif" 
174            visible="<%=formula.isShared()%>"
175            tooltip="This item is shared to other users, groups and/or projects"
176          />
177          <base:icon 
178            image="deleted.gif"
179            onclick="deleteItemPermanently()"
180            tooltip="This item has been flagged for deletion. Click to delete it now."
181            enabled="<%=deletePermanentlyPermission %>"
182            visible="<%=isRemoved%>" 
183          />
184          <base:icon image="used.gif" 
185            onclick="showUsingItems()"
186            tooltip="This item is used by other items and can't be permanently deleted. Show the items that are using this one"
187            visible="<%=isRemoved && isUsed%>" />
188        </th>
189        <td style="padding: 0px;">
190          <tbl:toolbar subclass="bottomborder">
191            <tbl:button 
192              disabled="<%=writePermission ? false : true%>" 
193              image="edit.gif" 
194              onclick="editItem()" 
195              title="Edit&hellip;" 
196              tooltip="<%=writePermission ? "Edit this formula" : "You do not have permission to edit this formula"%>" 
197            />
198            <tbl:button 
199              disabled="<%=deletePermission ? false : true%>" 
200              image="delete.gif" 
201              onclick="deleteItem()" 
202              title="Delete"
203              visible="<%=!formula.isRemoved()%>"
204              tooltip="<%=deletePermission ? "Delete this formula" : "You do not have permission to delete this formula"%>" 
205            />
206            <tbl:button 
207              disabled="<%=writePermission ? false : true%>" 
208              image="restore.gif" 
209              onclick="restoreItem()" 
210              title="Restore"
211              visible="<%=formula.isRemoved()%>"
212              tooltip="<%=writePermission ? "Restore this formula" : "You do not have permission to restore this formula"%>" 
213            />
214            <tbl:button 
215              disabled="<%=sharePermission ? false : true%>"
216              image="share.gif"
217              onclick="shareItem()" 
218              title="Share&hellip;" 
219              tooltip="<%=sharePermission ? "Share this formula to other user, groups and projects" : "You do not have permission to share this formula"%>"
220            />
221            <tbl:button 
222              disabled="<%=setOwnerPermission ? false : true%>"
223              image="take_ownership.png"
224              onclick="setOwner()" 
225              title="Set owner&hellip;"
226              tooltip="<%=setOwnerPermission ? "Change owner of this item" : "You do not have permission to change ownership of this item"%>"
227            />
228            <tbl:button 
229              image="import.gif" 
230              onclick="runPlugin('ImportItem')" 
231              title="Import&hellip;" 
232              tooltip="Import data" 
233              visible="<%=pluginCount.containsKey(Plugin.MainType.IMPORT)%>"
234            />
235            <tbl:button 
236              image="export.gif" 
237              onclick="runPlugin('ExportItem')" 
238              title="Export&hellip;" 
239              tooltip="Export data" 
240              visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>"
241            />
242            <tbl:button 
243              image="runplugin.gif" 
244              onclick="runPlugin('RunPlugin')" 
245              title="Run plugin&hellip;" 
246              tooltip="Run a plugin" 
247              visible="<%=pluginCount.containsKey(Plugin.MainType.OTHER)%>"
248            />
249            <ext:render extensions="<%=invoker%>" context="<%=jspContext%>" 
250              wrapper="<%=new PrefixSuffixRenderer(jspContext, "<td>", "</td>") %>"/>
251            <tbl:button
252              image="help.png"
253              onclick="<%="Main.openHelp('" + ID +"', 'formula.view.properties')"%>"
254              title="Help&hellip;"
255              tooltip="Get help about this page"
256            />
257          </tbl:toolbar>
258        </td>
259      </tr>
260      <tr>
261        <th>Name</th>
262        <td><%=HTML.encodeTags(formula.getName())%></td>
263      </tr>
264      <tr>
265        <th>Registered</th>
266        <td><%=dateFormatter.format(formula.getEntryDate())%></td>
267      </tr>
268      <tr>
269        <th>Type</th>
270        <td><%=formula.getFormulaType()%></td>
271      </tr>
272      <tr>
273        <th>Value type</th>
274        <td><%=formula.getValueType() == null ? "<i>- unknown -</i>" : formula.getValueType()%></td>
275      </tr>
276      <tr>
277        <th>Parser</th>
278        <td><%=formula.getParser()%></td>
279      </tr>
280      <tr>
281        <th>Raw data type</th>
282        <td><%=rawDataType == null ? "<i>- none -</i>" : HTML.encodeTags(rawDataType.getName())%></td>
283      </tr>
284      <tr>
285        <th>Channels</th>
286        <td><%=formula.getChannels()%></td>
287      </tr>
288      <tr class="big">
289        <th>Expressions</th>
290        <td>
291          <%
292          for (int i = 0; i < expressions.size(); ++i)
293          {
294            %>
295            <%=(i+1) + ": " + HTML.encodeTags(expressions.get(i))%><br>
296            <%
297          }
298          %>
299        </td>
300      </tr>
301      <tr>
302        <th>Avg. method</th>
303        <td><%=formula.getAverageMethod().toString()%></td>
304      </tr>
305      <tr>
306        <th>Source intensity transform</th>
307        <td><%=formula.getSourceIntensityTransform() == null ? "<i>- any -</i>" : formula.getSourceIntensityTransform().toString()%></td>
308      </tr>
309      <tr>
310        <th>Result intensity transform</th>
311        <td><%=formula.getResultIntensityTransform() == null ? "<i>- any -</i>" : formula.getResultIntensityTransform().toString()%></td>
312      </tr>
313      <tr>
314        <th>Use coloring</th>
315        <td>
316          <%=coloring.isUsingColors() ? "yes" : "no"%>
317          <%
318          if (coloring.isUsingColors())
319          {
320            %>
321            <b>Range</b> 
322            [<%=Values.formatNumber(coloring.getMinValue(), 2)%>,
323            <%=Values.formatNumber(coloring.getMidValue(), 2)%>,
324            <%=Values.formatNumber(coloring.getMaxValue(), 2)%>]
325            <b>Logarithmic</b> <%=coloring.isLogarithmic() ? "yes" : "no" %>
326            <%
327          }
328          %>
329        </td>
330      </tr>
331      <tr>
332        <th>Owner</th>
333        <td><base:propertyvalue item="<%=formula%>" property="owner" /></td>
334      </tr>
335      <tr>
336        <th>Permissions</th>
337        <td><%=PermissionUtil.getFullPermissionNames(formula)%></td>
338      </tr>
339      <tr>
340        <th>Description</th>
341        <td><%=HTML.niceFormat(formula.getDescription())%></td>
342      </tr>
343      </table>
344      </div>
345     
346      <jsp:include page="../../common/anytoany/list_anytoany.jsp">
347        <jsp:param name="ID" value="<%=ID%>" />
348        <jsp:param name="item_type" value="<%=itemType.name()%>" />
349        <jsp:param name="item_id" value="<%=itemId%>" />
350        <jsp:param name="title" value="Other items related to this formula" />
351      </jsp:include>
352      <jsp:include page="../../common/share/list_share.jsp">
353        <jsp:param name="ID" value="<%=ID%>" />
354        <jsp:param name="item_type" value="<%=itemType.name()%>" />
355        <jsp:param name="item_id" value="<%=itemId%>" />
356        <jsp:param name="title" value="Shared to" />
357      </jsp:include>
358    </t:tab>
359    <t:tab id="history" title="Change history" 
360      tooltip="Displays a log of all modifications made to this item"
361      visible="<%=ChangeHistoryUtil.showChangeHistoryTab(sc)%>">
362      <%
363      if ("history".equals(tab))
364      {
365        %>
366        <jsp:include page="../../common/history/frameset.jsp">
367          <jsp:param name="source_type" value="<%=itemType.name()%>" />
368          <jsp:param name="source_id" value="<%=itemId%>" />
369          <jsp:param name="ID" value="<%=ID%>" />
370        </jsp:include>
371        <%
372      }
373      %>
374    </t:tab>
375    </t:tabcontrol>
376
377  </base:body>
378  </base:page>
379  <%
380}
381finally
382{
383  if (dc != null) dc.close();
384}
385
386%>
Note: See TracBrowser for help on using the repository browser.