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

Last change on this file since 2918 was 2918, checked in by Nicklas Nordborg, 17 years ago

References #348: Take ownership of items

Implemented on all pages in the "View" menu.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 9.1 KB
Line 
1<%-- $Id: view_formula.jsp 2918 2006-11-15 11:21:13Z nicklas $
2  ------------------------------------------------------------------
3  Copyright (C) Authors contributing to this file.
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 2
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 this program; if not, write to the Free Software
20  Foundation, Inc., 59 Temple Place - Suite 330,
21  Boston, MA  02111-1307, USA.
22  ------------------------------------------------------------------
23
24  @author Nicklas
25  @version 2.0
26--%>
27<%@ page
28  import="net.sf.basedb.core.SessionControl"
29  import="net.sf.basedb.core.DbControl"
30  import="net.sf.basedb.core.SystemItems"
31  import="net.sf.basedb.core.Item"
32  import="net.sf.basedb.core.ItemContext"
33  import="net.sf.basedb.core.Permission"
34  import="net.sf.basedb.core.Formula"
35  import="net.sf.basedb.core.Coloring"
36  import="net.sf.basedb.core.User"
37  import="net.sf.basedb.core.RawDataType"
38  import="net.sf.basedb.core.PermissionDeniedException"
39  import="net.sf.basedb.core.PluginDefinition"
40  import="net.sf.basedb.core.plugin.GuiContext"
41  import="net.sf.basedb.core.plugin.Plugin"
42  import="net.sf.basedb.util.Values"
43  import="net.sf.basedb.clients.web.Base"
44  import="net.sf.basedb.clients.web.PermissionUtil"
45  import="net.sf.basedb.clients.web.util.HTML"
46  import="java.util.List"
47  import="java.util.Map"
48%>
49<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
50<%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %>
51<%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %>
52<%@ taglib prefix="p" uri="/WEB-INF/path.tld" %>
53<%!
54  private static final Item itemType = Item.FORMULA;
55  private static final GuiContext guiContext = new GuiContext(itemType, GuiContext.Type.ITEM);
56%>
57<%
58final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
59final String ID = sc.getId();
60final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null);
61final int itemId = cc.getId();
62final float scale = Base.getScale(sc);
63final DbControl dc = sc.newDbControl();
64try
65{
66  Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext);
67
68  String title = null;
69  final Formula formula = Formula.getById(dc, itemId);
70  final RawDataType rawDataType = formula.getRawDataType();
71  final List<String> expressions = formula.getFormulas();
72  final Coloring coloring = formula.getColoring();
73 
74  final boolean writePermission = formula.hasPermission(Permission.WRITE);
75  final boolean deletePermission = formula.hasPermission(Permission.DELETE);
76  final boolean sharePermission = formula.hasPermission(Permission.SET_PERMISSION);
77  final boolean setOwnerPermission = formula.hasPermission(Permission.SET_OWNER);
78  final boolean isOwner = formula.isOwner();
79  %>
80
81  <base:page title="<%=title%>">
82  <base:head scripts="tabcontrol.js" styles="toolbar.css,headertabcontrol.css,path.css">
83    <script language="JavaScript">
84    function editItem()
85    {
86      Main.viewOrEditItem('<%=ID%>', '<%=itemType.name()%>', <%=itemId%>, true);
87    }
88    function shareItem()
89    {
90      Main.openPopup('index.jsp?ID=<%=ID%>&cmd=ShareItem&item_id=<%=itemId%>', 'ShareFormula', 500, 400);
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 takeOwnership()
101    {
102      if (confirm('Are you sure that you want to take ownership of this item? It can\'t be undone.'))
103      {
104        location.replace('index.jsp?ID=<%=ID%>&cmd=TakeOwnershipOfItem&item_id=<%=itemId%>');
105      }
106    }
107    function runPlugin(cmd)
108    {
109      Main.openPopup('index.jsp?ID=<%=ID%>&cmd='+cmd+'&item_id=<%=itemId%>', 'RunPlugin'+cmd, 740, 540);
110    }
111    </script>
112  </base:head>
113  <base:body>
114    <p>
115    <p:path>
116      <p:pathelement title="Formulas" href="<%="index.jsp?ID="+ID%>" />
117      <p:pathelement title="<%=HTML.encodeTags(formula.getName())%>" />
118    </p:path>
119   
120    <t:tabcontrol id="main" active="properties">
121    <t:tab id="properties" title="Properties">
122    <tbl:toolbar
123      >
124      <tbl:button 
125        disabled="<%=writePermission ? false : true%>" 
126        image="<%=writePermission ? "edit.gif" : "edit_disabled.gif"%>" 
127        onclick="editItem()" 
128        title="Edit&hellip;" 
129        tooltip="<%=writePermission ? "Edit this formula" : "You do not have permission to edit this formula"%>" 
130      />
131      <tbl:button 
132        disabled="<%=deletePermission ? false : true%>" 
133        image="<%=deletePermission ? "delete.gif" : "delete_disabled.gif"%>" 
134        onclick="deleteItem()" 
135        title="Delete"
136        visible="<%=!formula.isRemoved()%>"
137        tooltip="<%=deletePermission ? "Delete this formula" : "You do not have permission to delete this formula"%>" 
138      />
139      <tbl:button 
140        disabled="<%=writePermission ? false : true%>" 
141        image="<%=writePermission ? "restore.gif" : "restore_disabled.gif"%>" 
142        onclick="restoreItem()" 
143        title="Restore"
144        visible="<%=formula.isRemoved()%>"
145        tooltip="<%=writePermission ? "Restore this formula" : "You do not have permission to restore this formula"%>" 
146      />
147      <tbl:button 
148        disabled="<%=sharePermission ? false : true%>"
149        image="<%=sharePermission ? "share.gif" : "share_disabled.gif"%>"
150        onclick="shareItem()" 
151        title="Share&hellip;" 
152        tooltip="<%=sharePermission ? "Share this formula to other user, groups and projects" : "You do not have permission to share this formula"%>"
153      />
154      <tbl:button 
155        disabled="<%=setOwnerPermission ? false : true%>"
156        image="<%=setOwnerPermission ? "take_ownership.png" : "take_ownership_disabled.png"%>"
157        onclick="takeOwnership()" 
158        title="Take ownership&hellip;"
159        visible="<%=!isOwner%>"
160        tooltip="<%=setOwnerPermission ? "Take ownership of this item" : "You do not have permission to take ownership of this item"%>"
161      />
162      <tbl:button 
163        image="import.gif" 
164        onclick="runPlugin('ImportItem')" 
165        title="Import&hellip;" 
166        tooltip="Import data" 
167        visible="<%=pluginCount.containsKey(Plugin.MainType.IMPORT)%>"
168      />
169      <tbl:button 
170        image="export.gif" 
171        onclick="runPlugin('ExportItem')" 
172        title="Export&hellip;" 
173        tooltip="Export data" 
174        visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>"
175      />
176      <tbl:button 
177        image="runplugin.gif" 
178        onclick="runPlugin('RunPlugin')" 
179        title="Run plugin&hellip;" 
180        tooltip="Run a plugin" 
181        visible="<%=pluginCount.containsKey(Plugin.MainType.OTHER)%>"
182      />
183      <tbl:button
184        image="help.gif"
185        onclick="<%="Main.openHelp('" + ID +"', 'formula.view.properties')"%>"
186        title="Help&hellip;"
187        tooltip="Get help about this page"
188      />
189      </tbl:toolbar>
190    <div class="boxedbottom">
191      <div class="itemstatus">Permissions on this item: <i><%=PermissionUtil.getFullPermissionNames(formula)%></i></div>
192      <%
193      if (formula.isRemoved() || formula.isShared())
194      {
195        %>
196        <div class="itemstatus">
197          <base:icon image="deleted.gif" 
198            visible="<%=formula.isRemoved()%>"> This item has been flagged for deletion<br></base:icon>
199          <base:icon image="shared.gif" 
200            visible="<%=formula.isShared()%>"> This item is shared to other user, groups and/or projects</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(formula.getName())%></td>
209      </tr>
210      <tr>
211        <td class="prompt">Type</td>
212        <td><%=formula.getFormulaType()%></td>
213      </tr>
214      <tr>
215        <td class="prompt">Parser</td>
216        <td><%=formula.getParser()%></td>
217      </tr>
218      <tr>
219        <td class="prompt">Raw data type</td>
220        <td><%=rawDataType == null ? "<i>- none -</i>" : HTML.encodeTags(rawDataType.getName())%></td>
221      </tr>
222      <tr>
223        <td class="prompt">Channels</td>
224        <td><%=formula.getChannels()%></td>
225      </tr>
226      <tr valign="baseline">
227        <td class="prompt">Expressions</td>
228        <td>
229          <%
230          for (int i = 0; i < expressions.size(); ++i)
231          {
232            %>
233            <%=(i+1) + ": " + HTML.encodeTags(expressions.get(i))%><br>
234            <%
235          }
236          %>
237        </td>
238      </tr>
239      <tr>
240        <td class="prompt">Use coloring</td>
241        <td>
242          <%=coloring.isUsingColors() ? "yes" : "no"%>
243          <%
244          if (coloring.isUsingColors())
245          {
246            %>
247            <b>Range</b> 
248            [<%=Values.formatNumber(coloring.getMinValue(), 2)%>,
249            <%=Values.formatNumber(coloring.getMidValue(), 2)%>,
250            <%=Values.formatNumber(coloring.getMaxValue(), 2)%>]
251            <b>Logarithmic</b> <%=coloring.isLogarithmic() ? "yes" : "no" %>
252            <%
253          }
254          %>
255        </td>
256      </tr>
257      <tr>
258        <td class="prompt">Owner</td>
259        <td><base:propertyvalue item="<%=formula%>" property="owner" /></td>
260      </tr>
261      <tr>
262        <td class="prompt">Description</td>
263        <td><%=HTML.niceFormat(formula.getDescription())%></td>
264      </tr>
265      </table>
266
267    </div>
268    </t:tab>
269    </t:tabcontrol>
270
271  </base:body>
272  </base:page>
273  <%
274}
275finally
276{
277  if (dc != null) dc.close();
278}
279
280%>
Note: See TracBrowser for help on using the repository browser.