1 | <%-- $Id: view_plugintype.jsp 5425 2010-09-23 13:30:07Z 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 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.Include" |
---|
31 | import="net.sf.basedb.core.ItemContext" |
---|
32 | import="net.sf.basedb.core.Permission" |
---|
33 | import="net.sf.basedb.core.PluginType" |
---|
34 | import="net.sf.basedb.core.ItemQuery" |
---|
35 | import="net.sf.basedb.core.ItemResultList" |
---|
36 | import="net.sf.basedb.core.PermissionDeniedException" |
---|
37 | import="net.sf.basedb.core.PluginDefinition" |
---|
38 | import="net.sf.basedb.core.plugin.GuiContext" |
---|
39 | import="net.sf.basedb.core.plugin.Plugin" |
---|
40 | import="net.sf.basedb.core.query.Restrictions" |
---|
41 | import="net.sf.basedb.core.query.Hql" |
---|
42 | import="net.sf.basedb.core.query.Orders" |
---|
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="net.sf.basedb.util.Values" |
---|
47 | import="net.sf.basedb.clients.web.util.NameablePluginAdaptor" |
---|
48 | import="net.sf.basedb.util.formatter.Formatter" |
---|
49 | import="net.sf.basedb.clients.web.formatter.FormatterFactory" |
---|
50 | import="net.sf.basedb.clients.web.extensions.ExtensionsControl" |
---|
51 | import="net.sf.basedb.clients.web.extensions.JspContext" |
---|
52 | import="net.sf.basedb.clients.web.extensions.renderer.PrefixSuffixRenderer" |
---|
53 | import="net.sf.basedb.clients.web.extensions.toolbar.ToolbarUtil" |
---|
54 | import="net.sf.basedb.util.extensions.ExtensionsInvoker" |
---|
55 | import="java.util.Date" |
---|
56 | import="java.util.Map" |
---|
57 | %> |
---|
58 | <%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> |
---|
59 | <%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %> |
---|
60 | <%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %> |
---|
61 | <%@ taglib prefix="p" uri="/WEB-INF/path.tld" %> |
---|
62 | <%@ taglib prefix="ext" uri="/WEB-INF/extensions.tld" %> |
---|
63 | <%! |
---|
64 | private static final Item itemType = Item.PLUGINTYPE; |
---|
65 | private static final GuiContext guiContext = new GuiContext(itemType, GuiContext.Type.ITEM); |
---|
66 | %> |
---|
67 | <% |
---|
68 | final SessionControl sc = Base.getExistingSessionControl(pageContext, true); |
---|
69 | final String ID = sc.getId(); |
---|
70 | final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null); |
---|
71 | final int itemId = cc.getId(); |
---|
72 | final float scale = Base.getScale(sc); |
---|
73 | final DbControl dc = sc.newDbControl(); |
---|
74 | try |
---|
75 | { |
---|
76 | Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc); |
---|
77 | Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext); |
---|
78 | |
---|
79 | String title = null; |
---|
80 | PluginType pluginType = PluginType.getById(dc, itemId); |
---|
81 | |
---|
82 | final boolean writePermission = pluginType.hasPermission(Permission.WRITE); |
---|
83 | final boolean deletePermission = pluginType.hasPermission(Permission.DELETE); |
---|
84 | final boolean isRemoved = pluginType.isRemoved(); |
---|
85 | final boolean isUsed = isRemoved && pluginType.isUsed(); |
---|
86 | final boolean deletePermanentlyPermission = deletePermission && !isUsed; |
---|
87 | JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, guiContext, pluginType); |
---|
88 | ExtensionsInvoker invoker = ToolbarUtil.useExtensions(jspContext); |
---|
89 | %> |
---|
90 | <base:page title="<%=title%>"> |
---|
91 | <base:head scripts="tabcontrol.js" styles="toolbar.css,headertabcontrol.css,path.css,table.css"> |
---|
92 | <ext:scripts context="<%=jspContext%>" /> |
---|
93 | <ext:stylesheets context="<%=jspContext%>" /> |
---|
94 | <script language="JavaScript"> |
---|
95 | function editItem() |
---|
96 | { |
---|
97 | Main.viewOrEditItem('<%=ID%>', '<%=itemType.name()%>', <%=itemId%>, true); |
---|
98 | } |
---|
99 | function deleteItem() |
---|
100 | { |
---|
101 | location.replace('index.jsp?ID=<%=ID%>&cmd=DeleteItem&item_id=<%=itemId%>'); |
---|
102 | } |
---|
103 | function restoreItem() |
---|
104 | { |
---|
105 | location.replace('index.jsp?ID=<%=ID%>&cmd=RestoreItem&item_id=<%=itemId%>'); |
---|
106 | } |
---|
107 | function deleteItemPermanently() |
---|
108 | { |
---|
109 | Main.deleteItemPermanently('<%=ID%>', true, '<%=itemType.name()%>', <%=itemId%>, '&callback=itemDeleted'); |
---|
110 | } |
---|
111 | function itemDeleted() |
---|
112 | { |
---|
113 | Main.listItems('<%=ID%>', '<%=itemType.name()%>'); |
---|
114 | } |
---|
115 | function showUsingItems() |
---|
116 | { |
---|
117 | Main.showUsingItems('<%=ID%>', '<%=itemType.name()%>', <%=itemId%>); |
---|
118 | } |
---|
119 | function runPlugin(cmd) |
---|
120 | { |
---|
121 | Main.openPopup('index.jsp?ID=<%=ID%>&cmd='+cmd+'&item_id=<%=itemId%>', 'RunPlugin'+cmd, 740, 540); |
---|
122 | } |
---|
123 | </script> |
---|
124 | </base:head> |
---|
125 | <base:body> |
---|
126 | <p> |
---|
127 | <p:path> |
---|
128 | <p:pathelement title="Plugin types" href="<%="index.jsp?ID="+ID%>" /> |
---|
129 | <p:pathelement title="<%=HTML.encodeTags(pluginType.getName())%>" /> |
---|
130 | </p:path> |
---|
131 | |
---|
132 | <t:tabcontrol id="main" active="properties"> |
---|
133 | <t:tab id="properties" title="Properties"> |
---|
134 | |
---|
135 | <tbl:toolbar |
---|
136 | > |
---|
137 | <tbl:button |
---|
138 | disabled="<%=writePermission ? false : true%>" |
---|
139 | image="<%=writePermission ? "edit.gif" : "edit_disabled.gif"%>" |
---|
140 | onclick="editItem()" |
---|
141 | title="Edit…" |
---|
142 | tooltip="<%=writePermission ? "Edit this plugin type" : "You do not have permission to edit this plugin type"%>" |
---|
143 | /> |
---|
144 | <tbl:button |
---|
145 | disabled="<%=deletePermission ? false : true%>" |
---|
146 | image="<%=deletePermission ? "delete.gif" : "delete_disabled.gif"%>" |
---|
147 | onclick="deleteItem()" |
---|
148 | title="Delete" |
---|
149 | visible="<%=!pluginType.isRemoved()%>" |
---|
150 | tooltip="<%=deletePermission ? "Delete this plugin type" : "You do not have permission to delete this plugin type"%>" |
---|
151 | /> |
---|
152 | <tbl:button |
---|
153 | disabled="<%=writePermission ? false : true%>" |
---|
154 | image="<%=writePermission ? "restore.gif" : "restore_disabled.gif"%>" |
---|
155 | onclick="restoreItem()" |
---|
156 | title="Restore" |
---|
157 | visible="<%=pluginType.isRemoved()%>" |
---|
158 | tooltip="<%=writePermission ? "Restore this plugin type" : "You do not have permission to restore this plugin type"%>" |
---|
159 | /> |
---|
160 | <tbl:button |
---|
161 | image="import.gif" |
---|
162 | onclick="runPlugin('ImportItem')" |
---|
163 | title="Import…" |
---|
164 | tooltip="Import data" |
---|
165 | visible="<%=pluginCount.containsKey(Plugin.MainType.IMPORT)%>" |
---|
166 | /> |
---|
167 | <tbl:button |
---|
168 | image="export.gif" |
---|
169 | onclick="runPlugin('ExportItem')" |
---|
170 | title="Export…" |
---|
171 | tooltip="Export data" |
---|
172 | visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>" |
---|
173 | /> |
---|
174 | <tbl:button |
---|
175 | image="runplugin.gif" |
---|
176 | onclick="runPlugin('RunPlugin')" |
---|
177 | title="Run plugin…" |
---|
178 | tooltip="Run a plugin" |
---|
179 | visible="<%=pluginCount.containsKey(Plugin.MainType.OTHER)%>" |
---|
180 | /> |
---|
181 | <ext:render extensions="<%=invoker%>" context="<%=jspContext%>" |
---|
182 | wrapper="<%=new PrefixSuffixRenderer(jspContext, "<td>", "</td>") %>"/> |
---|
183 | <tbl:button |
---|
184 | image="help.gif" |
---|
185 | onclick="<%="Main.openHelp('" + ID +"', 'plugintype.view.properties')"%>" |
---|
186 | title="Help…" |
---|
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(pluginType)%></i></div> |
---|
192 | <% |
---|
193 | if (pluginType.isRemoved()) |
---|
194 | { |
---|
195 | %> |
---|
196 | <div class="itemstatus"> |
---|
197 | <base:icon |
---|
198 | image="<%=deletePermanentlyPermission ? "deleted.gif" : "deleted_disabled.gif"%>" |
---|
199 | onclick="<%=deletePermanentlyPermission ? "deleteItemPermanently()" : null%>" |
---|
200 | tooltip="<%=deletePermanentlyPermission ? "Permanently delete this item" : null%>" |
---|
201 | visible="<%=isRemoved%>"> This item has been flagged for deletion<br></base:icon> |
---|
202 | <base:icon image="used.gif" |
---|
203 | onclick="showUsingItems()" |
---|
204 | tooltip="Show the items that are using this one" |
---|
205 | visible="<%=isUsed%>"> This item is used by other items and can't be permanently deleted<br></base:icon> |
---|
206 | </div> |
---|
207 | <% |
---|
208 | } |
---|
209 | %> |
---|
210 | <table class="form" cellspacing=0> |
---|
211 | <tr> |
---|
212 | <td class="prompt">Name</td> |
---|
213 | <td><%=HTML.encodeTags(pluginType.getName())%></td> |
---|
214 | </tr> |
---|
215 | <tr> |
---|
216 | <td class="prompt">Registered</td> |
---|
217 | <td><%=dateFormatter.format(pluginType.getEntryDate())%></td> |
---|
218 | </tr> |
---|
219 | <tr> |
---|
220 | <td class="prompt">Interface</td> |
---|
221 | <td><%=HTML.encodeTags(pluginType.getInterfaceName())%></td> |
---|
222 | </tr> |
---|
223 | <tr> |
---|
224 | <td class="prompt">Jar path</td> |
---|
225 | <td><%=Values.getString(pluginType.getJarPath(), "<i>- internal -</i>")%></td> |
---|
226 | </tr> |
---|
227 | <tr> |
---|
228 | <td class="prompt">Description</td> |
---|
229 | <td><%=HTML.niceFormat(pluginType.getDescription())%></td> |
---|
230 | </tr> |
---|
231 | </table> |
---|
232 | |
---|
233 | <% |
---|
234 | ItemQuery<PluginDefinition> pluginQuery = pluginType.getPlugins(); |
---|
235 | pluginQuery.include(Include.ALL); |
---|
236 | pluginQuery.order(Orders.asc(Hql.property("name"))); |
---|
237 | ItemResultList<PluginDefinition> plugins = pluginQuery.list(dc); |
---|
238 | |
---|
239 | if (plugins.size() == 0) |
---|
240 | { |
---|
241 | %> |
---|
242 | <h4>Plugins</h4> |
---|
243 | There are no plugins of this type (or, you don't have permission to view them). |
---|
244 | <% |
---|
245 | } |
---|
246 | else |
---|
247 | { |
---|
248 | %> |
---|
249 | <base:section |
---|
250 | id="plugins" |
---|
251 | title="<%="Plugins (" + plugins.size() + ")"%>" |
---|
252 | context="<%=cc%>" |
---|
253 | > |
---|
254 | <tbl:table |
---|
255 | id="plugins" |
---|
256 | clazz="itemlist" |
---|
257 | columns="all" |
---|
258 | > |
---|
259 | <tbl:columndef |
---|
260 | id="name" |
---|
261 | title="Name" |
---|
262 | /> |
---|
263 | <tbl:columndef |
---|
264 | id="class" |
---|
265 | title="Class" |
---|
266 | /> |
---|
267 | <tbl:columndef |
---|
268 | id="description" |
---|
269 | title="Description" |
---|
270 | /> |
---|
271 | <tbl:data> |
---|
272 | <tbl:columns> |
---|
273 | </tbl:columns> |
---|
274 | <tbl:rows> |
---|
275 | <% |
---|
276 | for (PluginDefinition plugin : plugins) |
---|
277 | { |
---|
278 | %> |
---|
279 | <tbl:row> |
---|
280 | <tbl:cell column="name"><base:icon |
---|
281 | image="deleted.gif" |
---|
282 | tooltip="This item has been scheduled for deletion" |
---|
283 | visible="<%=plugin.isRemoved()%>" |
---|
284 | /><%=Base.getLinkedName(ID, new NameablePluginAdaptor(plugin), false, true)%></tbl:cell> |
---|
285 | <tbl:cell column="class"><%=HTML.encodeTags(plugin.getClassName())%></tbl:cell> |
---|
286 | <tbl:cell column="description"><%=HTML.encodeTags(plugin.getDescription())%></tbl:cell> |
---|
287 | </tbl:row> |
---|
288 | <% |
---|
289 | } |
---|
290 | %> |
---|
291 | </tbl:rows> |
---|
292 | </tbl:data> |
---|
293 | </tbl:table> |
---|
294 | </base:section> |
---|
295 | <% |
---|
296 | } |
---|
297 | %> |
---|
298 | </div> |
---|
299 | </t:tab> |
---|
300 | </t:tabcontrol> |
---|
301 | |
---|
302 | </base:body> |
---|
303 | </base:page> |
---|
304 | <% |
---|
305 | } |
---|
306 | finally |
---|
307 | { |
---|
308 | if (dc != null) dc.close(); |
---|
309 | } |
---|
310 | |
---|
311 | %> |
---|