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

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

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

Added icons for flagging modified JAR/XML files to make it easier to spot that something has been updated already in the tree overview.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 12.9 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('XmlFileModified', path + 'itemmodified.gif', 18, 16);
153    IconStore.addIcon('XmlFileError', path + 'itemerror.gif', 18, 16);
154    IconStore.addIcon('XmlFileErrorModified', path + 'itemerrormodified.gif', 18, 16);
155    IconStore.addIcon('XmlFileSelected', path + 'itemselected.gif', 18, 16);
156    IconStore.addIcon('XmlFileModifiedSelected', path + 'itemmodifiedselected.gif', 18, 16);
157    IconStore.addIcon('XmlFileErrorSelected', path + 'itemerrorselected.gif', 18, 16);
158    IconStore.addIcon('XmlFileErrorModifiedSelected', path + 'itemerrormodifiedselected.gif', 18, 16);
159    IconStore.addIcon('JarFile', path + 'jarfile.png', 18, 16);
160    IconStore.addIcon('JarFileModified', path + 'jarfilemodified.png', 18, 16);
161    IconStore.addIcon('JarFileError', path + 'jarfileerror.png', 18, 16);
162    IconStore.addIcon('JarFileErrorModified', path + 'jarfileerrormodified.png', 18, 16);
163    IconStore.addIcon('JarFileSelected', path + 'jarfileselected.png', 18, 16);
164    IconStore.addIcon('JarFileModifiedSelected', path + 'jarfilemodifiedselected.png', 18, 16);
165    IconStore.addIcon('JarFileErrorSelected', path + 'jarfileerrorselected.png', 18, 16);
166    IconStore.addIcon('JarFileErrorModifiedSelected', path + 'jarfileerrormodifiedselected.png', 18, 16);
167
168    var byExtPoint = JoustMenu.addMenuItem(-1, 'Root', 'By extension point', 'rootOnClick()', '', '');
169    var toolbars = JoustMenu.addChildItem(byExtPoint, 'Folder', 'Toolbars');
170    var editDialogs = JoustMenu.addChildItem(byExtPoint, 'Folder', 'Edit dialogs');
171    var ep;
172    var ext;
173    var plugin;
174    <%
175    ExtensionsControl ec = ExtensionsControl.get(dc);
176    List<ExtensionPoint<?>> extensionPoints = ec.getExtensionPoints();
177    for (ExtensionPoint ep : extensionPoints)
178    {
179      String id = ep.getId();
180      String parent = "byExtPoint";
181      if (id.startsWith("net.sf.basedb.clients.web.toolbar.")) parent = "toolbars";
182      if (id.startsWith("net.sf.basedb.clients.web.tabcontrol.edit.")) parent = "editDialogs";
183      if (id.startsWith("net.sf.basedb.clients.web.onsave.")) parent = "editDialogs";
184      %>
185      <%=getJoustExtensionPoint(parent, ec, ep, ec.getFileByObjectKey(new ExtensionPointKey(ep)))%>
186      <%
187      List<Extension<?>> extensions = ec.getExtensions(ep.getId());
188      for (Extension ext : extensions)
189      {
190        %>
191        <%=getJoustExtension("ep", ec, ext, ec.getFileByObjectKey(new ExtensionKey(ext)), false, true)%>
192        <%
193      }
194    }
195    %>
196    var byFile = JoustMenu.addMenuItem(-1, 'Root', 'By file', 'rootOnClick()');
197    var file;
198    var group;
199    <%
200    for (ExtensionsFile ef : ec.getFiles())
201    {
202      if (!ef.isInstalled()) continue;
203     
204      String efName = ef.getName();
205      String icon = ef.isJar() ? "JarFile" : "XmlFile";
206      if (ef.hasError()) icon += "Error";
207      if (ef.checkModified()) icon += "Modified";
208      String id = efName;
209      %>
210      file = JoustMenu.addChildItem(byFile, '<%=icon%>', '<%=HTML.javaScriptEncode(efName)%>', 'fileOnClick("<%=ef.getURI().toString()%>")', '', '<%=id%>');
211      <%
212      List<ExtensionPoint> eps = ef.getObjectsOfClass(ExtensionPoint.class);
213      for (ExtensionPoint ep : eps)
214      {
215        %>
216        <%=getJoustExtensionPoint("file", ec, ep, ef)%>
217        <%
218      }
219      List<Extension> exts = ef.getObjectsOfClass(Extension.class);
220      String currentGroupId = null;
221      for (Extension ext : exts)
222      {
223        int groupIndex = ext.getId().indexOf(":");
224        // ID:s containing ':' should be grouped
225        if (groupIndex > 0)
226        {
227          String groupId = ext.getId().substring(0, groupIndex);
228          if (!groupId.equals(currentGroupId))
229          {
230            currentGroupId = groupId;
231            %>
232            <%=getExtensionGroup("file", ec, ext, currentGroupId)%>
233            <%
234          }
235        }
236        else
237        {
238          currentGroupId = null;
239        }
240        %>
241        <%=getJoustExtension(currentGroupId == null ? "file" : "group", ec, ext, ef, currentGroupId != null, false)%>
242        <%
243      }
244      List<PluginInfo> plugins = ef.getObjectsOfClass(PluginInfo.class);
245      for (PluginInfo info : plugins)
246      {
247        %>
248        <%=getJoustPlugin("file", ec, info, ef)%>
249        <%
250      }
251    }
252    %>
253    JoustMenu.menuItems[byExtPoint].isOpen = true;
254    JoustMenu.menuItems[byFile].isOpen = true;
255    JoustMenu.draw('joust');
256    isInitialised = true;
257  }
258
259  function openAll()
260  {
261    JoustMenu.openAll();
262  }
263
264  function closeAll()
265  {
266    JoustMenu.closeAll();
267  }
268 
269  function setIcon(nodeId, iconName)
270  {
271    var icons = new Array();
272    icons[nodeId] = iconName;
273    setIconsByExternalId(icons);
274  }
275 
276  function setChildIcons(parentNodeId, enable)
277  {
278    var node = JoustMenu.menuItems[parentNodeId];
279    if (!node) return;
280    var childNode = JoustMenu.menuItems[node.firstChildIndex];
281    var icons = new Array();
282    var numChildren = 0;
283    while (childNode)
284    {
285      numChildren++;
286      var iconName = childNode.iconName;
287      var isDisabled = iconName.indexOf('Disabled') > 0;
288      if (enable && isDisabled)
289      {
290        iconName = iconName.replace('Disabled', '');
291      }
292      else if (!enable && !isDisabled)
293      {
294        iconName += 'Disabled';
295      }
296      icons[childNode.externalId] = iconName;
297      childNode = JoustMenu.menuItems[childNode.nextItemIndex];
298    }
299    if (numChildren > 0) setIconsByExternalId(icons);
300  }
301 
302  function setIconsByExternalId(icons)
303  {
304    for (var i = 0; i < JoustMenu.menuItems.length; i++)
305    {
306      var node = JoustMenu.menuItems[i];
307      var iconName = icons[node.externalId];
308      if (iconName)
309      {
310        node.iconName = iconName;
311        JoustMenu.updateIconsAndText(node.index);
312      }
313    }
314  }
315 
316  function selectFile(filename)
317  {
318    var fileNode = JoustMenu.menuItems[filename];
319    if (fileNode)
320    {
321      JoustMenu.open(fileNode.index);
322      JoustMenu.select(fileNode.index);
323    }
324  }
325 
326  function rootOnClick()
327  {
328    parent.frames['details'].location.href = 'details.jsp?ID=<%=ID%>';
329  }
330 
331  function extensionPointOnClick(extensionPointId)
332  {
333    parent.frames['details'].location.href = 'details.jsp?ID=<%=ID%>&extensionPointId='+escape(extensionPointId);
334  }
335  function extensionOnClick(extensionId)
336  {
337    parent.frames['details'].location.href = 'details.jsp?ID=<%=ID%>&extensionId='+escape(extensionId);
338  }
339  function fileOnClick(fileuri)
340  {
341    parent.frames['details'].location.href = 'details.jsp?ID=<%=ID%>&fileuri='+escape(fileuri); 
342  }
343  function pluginOnClick(className)
344  {
345    parent.frames['details'].location.href = '../plugindefinitions/index.jsp?ID=<%=ID%>&cmd=ViewItemByClass&iframe=1&className='+escape(className);
346  }
347  </script>
348  <style>
349  .itemref {
350    font-size: 10px;
351    color: #777777;
352  }
353  </style>
354  </base:head>
355    <base:body onload="initialise()">
356    <div id="main" class="joust" style="width:100%;">
357      <div id="joust" style="overflow: auto;">
358      </div>
359    </div>
360    </base:body>
361  </base:page>
362  <%
363}
364finally
365{
366  if (dc != null) dc.close();
367}
368%>
Note: See TracBrowser for help on using the repository browser.