source: trunk/www/admin/extensions/tree.jsp @ 5616

Last change on this file since 5616 was 5616, checked in by Nicklas Nordborg, 11 years ago

References #1592: Unified installation procedure for plug-ins, extensions and more...

Re-organized the installation procedure. The first step will now show scan for new/updated/deleted files and present a list of options for each one (eg. install/uninstall).

We keep track of each installed extension in the settings file which should be safer since no automatic installation is done any longer.

There may still be some error handling issues, and plug-in configuration are still not installed.

Re-organized the Administrate and Extensions menus in the web client. All plug-in/extensions installation is now done from Administrate -> Plug-ins & extensions -> Overview.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 12.2 KB
Line 
1<%-- $Id:tree.jsp 4187 2008-03-20 11:15:25Z nicklas $
2  ------------------------------------------------------------------
3  Copyright (C) 2006 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.Item"
29  import="net.sf.basedb.core.Permission"
30  import="net.sf.basedb.clients.web.Base"
31  import="net.sf.basedb.clients.web.util.HTML"
32  import="net.sf.basedb.util.Values"
33  import="net.sf.basedb.util.extensions.ExtensionPoint"
34  import="net.sf.basedb.util.extensions.Extension"
35  import="net.sf.basedb.util.extensions.Action"
36  import="net.sf.basedb.util.extensions.manager.ExtensionsFile"
37  import="net.sf.basedb.util.extensions.manager.ExtensionKey"
38  import="net.sf.basedb.util.extensions.manager.ExtensionPointKey"
39  import="net.sf.basedb.util.extensions.xml.PluginInfo"
40  import="net.sf.basedb.clients.web.extensions.ExtensionsControl"
41  import="net.sf.basedb.core.plugin.About"
42  import="java.util.List"
43  import="java.util.Iterator"
44%>
45<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
46<%!
47String getJoustExtensionPoint(String parentNode, ExtensionsControl ec, ExtensionPoint ep, ExtensionsFile ef)
48{
49  String id = ep.getId();
50  String name = ep.getName();
51  if (name == null) name = id;
52  String icon = ec.isEnabled(ep) ? "ExtensionPoint" : "ExtensionPointDisabled";
53  if ((ef != null && ef.hasError()) || ec.getLastExtensionPointError(id) != null) 
54  {
55    icon = "ExtensionPointError";
56  }
57  String joust = "ep = JoustMenu.addChildItem(" + parentNode +", '" + icon + "', " + 
58      "'" + HTML.javaScriptEncode(name) + "', 'extensionPointOnClick(\"" + id + "\")', " + 
59      "'', '" + id + "')";
60  return joust;
61}
62String getJoustExtension(String parentNode, ExtensionsControl ec, Extension ext, ExtensionsFile ef, boolean inGroup, boolean showFile)
63{
64  String id = ext.getId();
65  About about = ext.getAbout();
66  String name = about == null || about.getName() == null ? id : about.getName();
67  if (inGroup) name = ext.getId().substring(ext.getId().indexOf(":"));
68  if (showFile)
69  {
70    name += " <span class=\"itemref\">[" + ef.getName() + "]</span>";
71  }
72  else
73  {
74    name += " <span class=\"itemref\">[" + ec.getExtensionPoint(ext.getExtends()).getName() + "]</span>";
75  }
76  String icon = ec.isEnabled(ext) ? "Extension" : "ExtensionDisabled";
77  if ((ef != null && ef.hasError()) || ec.getLastExtensionError(id) != null)
78  {
79    icon = "ExtensionError";
80  }
81  String joust = "ext = JoustMenu.addChildItem(" + parentNode + ", '" + icon + "', " + 
82      "'" + HTML.javaScriptEncode(name) + "', 'extensionOnClick(\"" + id + "\")', " + 
83      "'', '" + id + "')";
84  return joust;
85}
86String getExtensionGroup(String parentNode, ExtensionsControl ec, Extension ext, String groupId)
87{
88  String id = ext.getId();
89  About about = ext.getAbout();
90  String name = about == null || about.getName() == null ? id : about.getName();
91  String icon = "Folder";
92  String joust = "group = JoustMenu.addChildItem(" + parentNode + ", '" + icon + "', " + 
93      "'" + HTML.javaScriptEncode(name) + "', 'extensionOnClick(\"" + id + "\")', " + 
94      "'', '" + groupId + "')";
95  return joust;
96}
97String getJoustPlugin(String parentNode, ExtensionsControl ex, PluginInfo info, ExtensionsFile ef)
98{
99  String id = info.getClassName();
100  About about = info.getAbout();
101  String name = about == null || about.getName() == null ? id : about.getName();
102  String icon = info.isDisabled() ? "PluginDisabled" : "Plugin";
103  if ((ef != null && ef.hasError()) || !info.isInstalled())
104  {
105    icon = "PluginError";
106  }
107 
108  String joust = "plugin = JoustMenu.addChildItem(" + parentNode +", '" + icon + "', " + 
109      "'" + HTML.javaScriptEncode(name) + "', 'pluginOnClick(\"" + id + "\")', " +
110      "'', '" + id + "')";
111  return joust;
112}
113%>
114<%
115final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
116final String ID = sc.getId();
117final float scale = Base.getScale(sc);
118DbControl dc = null;
119try
120{
121  dc = sc.newDbControl();
122  %>
123  <base:page title="" type="popup">
124  <base:head scripts="newjoust.js" styles="newjoust.css">
125  <script language="JavaScript">
126  var isInitialised = false;
127  function initialise()
128  {
129    if (parent && parent.parent && parent.parent.adjustIFrameSize) parent.parent.adjustIFrameSize();
130    var path = getRoot()+'images/joust/';
131    IconStore.init();
132   
133    IconStore.addIcon('ExtensionPoint', path + 'extensionpoint.png', 16, 16);
134    IconStore.addIcon('ExtensionPointSelected', path + 'extensionpointselected.png', 16, 16);
135    IconStore.addIcon('ExtensionPointDisabled', path + 'extensionpointdisabled.png', 16, 16);
136    IconStore.addIcon('ExtensionPointDisabledSelected', path + 'extensionpointdisabledselected.png', 16, 16);
137    IconStore.addIcon('ExtensionPointError', path + 'extensionpointerror.png', 16, 16);
138    IconStore.addIcon('ExtensionPointErrorSelected', path + 'extensionpointerrorselected.png', 16, 16);
139    IconStore.addIcon('Extension', path + 'extension.png', 16, 16);
140    IconStore.addIcon('ExtensionSelected', path + 'extensionselected.png', 16, 16);
141    IconStore.addIcon('ExtensionDisabled', path + 'extensiondisabled.png', 16, 16);
142    IconStore.addIcon('ExtensionDisabledSelected', path + 'extensiondisabledselected.png', 16, 16);
143    IconStore.addIcon('ExtensionError', path + 'extensionerror.png', 16, 16);
144    IconStore.addIcon('ExtensionErrorSelected', path + 'extensionerrorselected.png', 16, 16);
145    IconStore.addIcon('Plugin', path + 'plugin.png', 18, 16);
146    IconStore.addIcon('PluginSelected', path + 'pluginselected.png', 18, 16);
147    IconStore.addIcon('PluginDisabled', path + 'plugindisabled.png', 18, 16);
148    IconStore.addIcon('PluginDisabledSelected', path + 'plugindisabledselected.png', 18, 16);
149    IconStore.addIcon('PluginError', path + 'pluginerror.png', 18, 16);
150    IconStore.addIcon('PluginErrorSelected', path + 'pluginerrorselected.png', 18, 16);
151    IconStore.addIcon('XmlFile', path + 'item.gif', 18, 16);
152    IconStore.addIcon('XmlFileError', path + 'itemerror.gif', 18, 16);
153    IconStore.addIcon('XmlFileSelected', path + 'itemselected.gif', 18, 16);
154    IconStore.addIcon('XmlFileErrorSelected', path + 'itemerrorselected.gif', 18, 16);
155    IconStore.addIcon('JarFile', path + 'jarfile.png', 18, 16);
156    IconStore.addIcon('JarFileError', path + 'jarfileerror.png', 18, 16);
157    IconStore.addIcon('JarFileSelected', path + 'jarfileselected.png', 18, 16);
158    IconStore.addIcon('JarFileErrorSelected', path + 'jarfileerrorselected.png', 18, 16);
159
160    var byExtPoint = JoustMenu.addMenuItem(-1, 'Root', 'By extension point', 'rootOnClick()', '', '');
161    var toolbars = JoustMenu.addChildItem(byExtPoint, 'Folder', 'Toolbars');
162    var editDialogs = JoustMenu.addChildItem(byExtPoint, 'Folder', 'Edit dialogs');
163    var ep;
164    var ext;
165    var plugin;
166    <%
167    ExtensionsControl ec = ExtensionsControl.get(dc);
168    List<ExtensionPoint<?>> extensionPoints = ec.getExtensionPoints();
169    for (ExtensionPoint ep : extensionPoints)
170    {
171      String id = ep.getId();
172      String parent = "byExtPoint";
173      if (id.startsWith("net.sf.basedb.clients.web.toolbar.")) parent = "toolbars";
174      if (id.startsWith("net.sf.basedb.clients.web.tabcontrol.edit.")) parent = "editDialogs";
175      if (id.startsWith("net.sf.basedb.clients.web.onsave.")) parent = "editDialogs";
176      %>
177      <%=getJoustExtensionPoint(parent, ec, ep, ec.getFileByObjectKey(new ExtensionPointKey(ep)))%>
178      <%
179      List<Extension<?>> extensions = ec.getExtensions(ep.getId());
180      for (Extension ext : extensions)
181      {
182        %>
183        <%=getJoustExtension("ep", ec, ext, ec.getFileByObjectKey(new ExtensionKey(ext)), false, true)%>
184        <%
185      }
186    }
187    %>
188    var byFile = JoustMenu.addMenuItem(-1, 'Root', 'By file', 'rootOnClick()');
189    var file;
190    var group;
191    <%
192    for (ExtensionsFile ef : ec.getFiles())
193    {
194      if (!ef.isInstalled()) continue;
195     
196      String efName = ef.getName();
197      String icon = ef.isJar() ? "JarFile" : "XmlFile";
198      if (ef.hasError()) icon += "Error";
199      String id = efName;
200      %>
201      file = JoustMenu.addChildItem(byFile, '<%=icon%>', '<%=HTML.javaScriptEncode(efName)%>', 'fileOnClick("<%=ef.getURI().toString()%>")', '', '<%=id%>');
202      <%
203      List<ExtensionPoint> eps = ef.getObjectsOfClass(ExtensionPoint.class);
204      for (ExtensionPoint ep : eps)
205      {
206        %>
207        <%=getJoustExtensionPoint("file", ec, ep, ef)%>
208        <%
209      }
210      List<Extension> exts = ef.getObjectsOfClass(Extension.class);
211      String currentGroupId = null;
212      for (Extension ext : exts)
213      {
214        int groupIndex = ext.getId().indexOf(":");
215        // ID:s containing ':' should be grouped
216        if (groupIndex > 0)
217        {
218          String groupId = ext.getId().substring(0, groupIndex);
219          if (!groupId.equals(currentGroupId))
220          {
221            currentGroupId = groupId;
222            %>
223            <%=getExtensionGroup("file", ec, ext, currentGroupId)%>
224            <%
225          }
226        }
227        else
228        {
229          currentGroupId = null;
230        }
231        %>
232        <%=getJoustExtension(currentGroupId == null ? "file" : "group", ec, ext, ef, currentGroupId != null, false)%>
233        <%
234      }
235      List<PluginInfo> plugins = ef.getObjectsOfClass(PluginInfo.class);
236      for (PluginInfo info : plugins)
237      {
238        %>
239        <%=getJoustPlugin("file", ec, info, ef)%>
240        <%
241      }
242    }
243    %>
244    JoustMenu.menuItems[byExtPoint].isOpen = true;
245    JoustMenu.menuItems[byFile].isOpen = true;
246    JoustMenu.draw('joust');
247    isInitialised = true;
248  }
249
250  function openAll()
251  {
252    JoustMenu.openAll();
253  }
254
255  function closeAll()
256  {
257    JoustMenu.closeAll();
258  }
259 
260  function setIcon(nodeId, iconName)
261  {
262    var icons = new Array();
263    icons[nodeId] = iconName;
264    setIconsByExternalId(icons);
265  }
266 
267  function setChildIcons(parentNodeId, enable)
268  {
269    var node = JoustMenu.menuItems[parentNodeId];
270    if (!node) return;
271    var childNode = JoustMenu.menuItems[node.firstChildIndex];
272    var icons = new Array();
273    var numChildren = 0;
274    while (childNode)
275    {
276      numChildren++;
277      var iconName = childNode.iconName;
278      var isDisabled = iconName.indexOf('Disabled') > 0;
279      if (enable && isDisabled)
280      {
281        iconName = iconName.replace('Disabled', '');
282      }
283      else if (!enable && !isDisabled)
284      {
285        iconName += 'Disabled';
286      }
287      icons[childNode.externalId] = iconName;
288      childNode = JoustMenu.menuItems[childNode.nextItemIndex];
289    }
290    if (numChildren > 0) setIconsByExternalId(icons);
291  }
292 
293  function setIconsByExternalId(icons)
294  {
295    for (var i = 0; i < JoustMenu.menuItems.length; i++)
296    {
297      var node = JoustMenu.menuItems[i];
298      var iconName = icons[node.externalId];
299      if (iconName)
300      {
301        node.iconName = iconName;
302        JoustMenu.updateIconsAndText(node.index);
303      }
304    }
305  }
306 
307  function selectFile(filename)
308  {
309    var fileNode = JoustMenu.menuItems[filename];
310    if (fileNode)
311    {
312      JoustMenu.open(fileNode.index);
313      JoustMenu.select(fileNode.index);
314    }
315  }
316 
317  function rootOnClick()
318  {
319    parent.frames['details'].location.href = 'details.jsp?ID=<%=ID%>';
320  }
321 
322  function extensionPointOnClick(extensionPointId)
323  {
324    parent.frames['details'].location.href = 'details.jsp?ID=<%=ID%>&extensionPointId='+escape(extensionPointId);
325  }
326  function extensionOnClick(extensionId)
327  {
328    parent.frames['details'].location.href = 'details.jsp?ID=<%=ID%>&extensionId='+escape(extensionId);
329  }
330  function fileOnClick(fileuri)
331  {
332    parent.frames['details'].location.href = 'details.jsp?ID=<%=ID%>&fileuri='+escape(fileuri); 
333  }
334  function pluginOnClick(className)
335  {
336    parent.frames['details'].location.href = '../plugindefinitions/index.jsp?ID=<%=ID%>&cmd=ViewItemByClass&iframe=1&className='+escape(className);
337  }
338  </script>
339  <style>
340  .itemref {
341    font-size: 10px;
342    color: #777777;
343  }
344  </style>
345  </base:head>
346    <base:body onload="initialise()">
347    <div id="main" class="joust" style="width:100%;">
348      <div id="joust" style="overflow: auto;">
349      </div>
350    </div>
351    </base:body>
352  </base:page>
353  <%
354}
355finally
356{
357  if (dc != null) dc.close();
358}
359%>
Note: See TracBrowser for help on using the repository browser.