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

Last change on this file since 5599 was 5599, checked in by Nicklas Nordborg, 12 years ago

References #1582: Extended support for external files

Defined an extension point for external file support ('net.sf.basedb.core.uri.connection-manager').

Added possibility to set a specific connection manager factory on a FileServer. If not set automatic detection is used as before.

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