source: branches/2.8-stable/www/common/plugin/select_plugin.jsp @ 4506

Last change on this file since 4506 was 4506, checked in by Nicklas Nordborg, 14 years ago

References #118: Change problematic forms to use POST instead of GET

I have changed most of the forms I could find to use POST instead of GET. Many of them are probably not problematic, but I found some:

  • Form for JEP extra value calculator plug-in
  • Form for JEP intensity transformer plug-in
  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 9.3 KB
Line 
1<%-- $Id: select_plugin.jsp 4506 2008-09-11 09:29:40Z nicklas $
2  ------------------------------------------------------------------
3  Copyright (C) 2006 Jari Hakkinen, Nicklas Nordborg
4  Copyright (C) 2007 Nicklas Nordborg
5
6  This file is part of BASE - BioArray Software Environment.
7  Available at http://base.thep.lu.se/
8
9  BASE is free software; you can redistribute it and/or
10  modify it under the terms of the GNU General Public License
11  as published by the Free Software Foundation; either version 3
12  of the License, or (at your option) any later version.
13
14  BASE is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  GNU General Public License for more details.
18
19  You should have received a copy of the GNU General Public License
20  along with this program; if not, write to the Free Software
21  Foundation, Inc., 59 Temple Place - Suite 330,
22  Boston, MA  02111-1307, USA.
23  ------------------------------------------------------------------
24
25  @author Nicklas
26  @version 2.0
27--%>
28<%@ page session="false"
29  import="net.sf.basedb.core.SessionControl"
30  import="net.sf.basedb.core.DbControl"
31  import="net.sf.basedb.core.Item"
32  import="net.sf.basedb.core.PluginDefinition"
33  import="net.sf.basedb.core.PluginConfiguration"
34  import="net.sf.basedb.core.PluginType"
35  import="net.sf.basedb.core.ItemQuery"
36  import="net.sf.basedb.core.ItemResultList"
37  import="net.sf.basedb.core.Include"
38  import="net.sf.basedb.core.Job"
39  import="net.sf.basedb.core.query.Hql"
40  import="net.sf.basedb.core.query.Expressions"
41  import="net.sf.basedb.core.query.Restrictions"
42  import="net.sf.basedb.core.query.Orders"
43  import="net.sf.basedb.core.plugin.GuiContext"
44  import="net.sf.basedb.core.plugin.Plugin"
45  import="net.sf.basedb.core.plugin.InteractivePlugin"
46  import="net.sf.basedb.core.plugin.AutoDetectingImporter"
47  import="net.sf.basedb.clients.web.Base"
48  import="net.sf.basedb.util.Values"
49  import="net.sf.basedb.util.ContextUtil"
50  import="net.sf.basedb.util.ContextUtil.ContextResult"
51  import="net.sf.basedb.clients.web.util.HTML"
52  import="java.util.Set"
53  import="java.util.Map"
54  import="java.util.List"
55%>
56<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
57<%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %>
58
59<%
60final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
61final String ID = sc.getId();
62final Item itemType = Item.valueOf(request.getParameter("item_type"));
63final String subContext = Values.getString(request.getParameter("subcontext"), "");
64final GuiContext.Type contextType = GuiContext.Type.valueOf(request.getParameter("context_type"));
65final Plugin.MainType mainType = Plugin.MainType.valueOf(request.getParameter("main_type"));
66final GuiContext context = new GuiContext(itemType, contextType);
67final String title = request.getParameter("title");
68final String message = request.getParameter("message");
69final DbControl dc = sc.newDbControl();
70final float scale = Base.getScale(sc);
71final boolean anotherIsOpen = sc.getSessionSetting("plugin.configure.plugin") != null;
72
73try
74{
75  List<ContextResult> contextResults = (List<ContextResult>)sc.getSessionSetting("PLUGINS");
76  Set<String> messages = (Set<String>)sc.getSessionSetting("MESSAGES");
77  StringBuilder descriptions = new StringBuilder();
78  %>
79  <base:page type="popup" title="<%=title%>">
80  <base:head scripts="plugin.js">
81    <script language="JavaScript">
82    function doNext()
83    {
84      var frm = document.forms['plugin'];
85      var anotherIsOpen = <%=anotherIsOpen%>;
86      if (anotherIsOpen)
87      {
88        if (!confirm('Are you sure? Unsaved settings in the other wizard will be lost.')) return;
89        frm.warnIfOpen.value = '0';
90      }
91      frm.submit();
92    }
93   
94    var lastSelectedPlugin;
95    function pluginOnChange()
96    {
97      var frm = document.forms['plugin'];
98      var pluginList = frm.plugindefinition_id;
99      var configurationList = frm.pluginconfiguration_id;
100      var plugin = pluginList[pluginList.selectedIndex].plugin;
101      Plugins.updateConfigurationsList(plugin, configurationList);
102      if (configurationList.length == 0)
103      {
104        Main.hide('configurations');
105      }
106      else
107      {
108        Main.show('configurations');
109      }
110      if (lastSelectedPlugin)
111      {
112        Main.hide('description.'+lastSelectedPlugin.id);
113      }
114      else
115      {
116        Main.show('descriptions');
117      }
118      if (lastSelectedConfig)
119      {
120        Main.hide('description.config.'+lastSelectedConfig.id);
121      }
122      Main.show('description.'+plugin.id);
123      lastSelectedPlugin = plugin;
124      lastSelectedConfig = null;
125      configOnChange();
126    }
127   
128    var lastSelectedConfig;
129    function configOnChange()
130    {
131      var frm = document.forms['plugin'];
132      var configurationList = frm.pluginconfiguration_id;
133      if (configurationList.selectedIndex < 0) return; 
134      var config = configurationList[configurationList.selectedIndex].configuration;
135      if (lastSelectedConfig)
136      {
137        Main.hide('description.config.'+lastSelectedConfig.id);
138      }
139      else
140      {
141        Main.show('descriptions');
142      }
143      if (config)
144      {
145        Main.show('description.config.'+config.id);
146      }
147      else
148      {
149        Main.hide('descriptions');
150      }
151      lastSelectedConfig = config;
152    }
153   
154    function init()
155    {
156      var frm = document.forms['plugin'];
157      var pluginList = frm.plugindefinition_id;
158      var configurationList = frm.pluginconfiguration_id;
159      <%
160      PluginDefinition lastPlugin = null;
161      for (ContextResult result : contextResults)
162      {
163        if (result.isInContext())
164        {
165          PluginDefinition pd = result.getPluginDefinition();
166          if (!pd.equals(lastPlugin))
167          {
168            lastPlugin = pd;
169            dc.reattachItem(pd);
170            String supportsConfig = pd.supportsConfigurations() ? "true" : "false";
171            String requiresConfig = pd.requiresConfiguration() ? "true" : "false";
172            descriptions.append("<div id=\"description." + pd.getId() +"\" style=\"display: none;\">");
173            descriptions.append(HTML.niceFormat("<b>" + pd.getName() + "</b>\n" + Values.getString(pd.getDescription())));
174            descriptions.append("</div>");
175            %>
176            var thePlugin = new Plugin(<%=pd.getId()%>, '<%=HTML.javaScriptEncode(pd.getName())%>', false, <%=supportsConfig%>, <%=requiresConfig%>);
177            <%
178          }
179          PluginConfiguration pc = result.getPluginConfiguration();
180          if (pc != null)
181          {
182            descriptions.append("<div id=\"description.config." + pc.getId() + "\" style=\"display: none; padding-top: 6px;\">");
183            descriptions.append(HTML.niceFormat("<b>" + pc.getName() + "</b>\n" +Values.getString(pc.getDescription())));           
184            descriptions.append("</div>");
185            %>
186            thePlugin.addConfiguration(<%=pc.getId()%>, '<%=HTML.javaScriptEncode(pc.getName())%>');
187            <%
188          }
189        }
190      }
191      %>
192      Plugins.populateLists(pluginList, configurationList);
193      pluginOnChange();
194    }
195    </script>
196  </base:head>
197  <base:body onload="init()">
198    <form name="plugin" action="index.jsp" method="post" onsubmit="return false;">
199    <input type="hidden" name="ID" value="<%=ID%>">
200    <input type="hidden" name="cmd" value="NewJob">
201    <input type="hidden" name="item_type" value="<%=itemType.name()%>">
202    <input type="hidden" name="subcontext" value="<%=subContext%>">
203    <input type="hidden" name="context_type" value="<%=contextType.name()%>">
204    <input type="hidden" name="main_type" value="<%=mainType.name()%>">
205    <input type="hidden" name="title" value="<%=title%>">
206    <input type="hidden" name="warnIfOpen" value="1">
207
208    <h3 class="docked"><%=title%> <base:help helpid="runplugin.selectplugin" /></h3>
209    <div class="boxed" style="height: <%=(int)(scale*420)%>px; overflow: auto;">
210      <div class="helpmessage">
211      <%
212      if (message != null)
213      {
214        %>
215        <%=message%>
216        <%
217      }
218      else
219      {
220        %>
221        Please select the plugin and, optionally, the configuration to use.
222        <%
223      }
224      %>
225      </div>
226   
227      <table class="form" width="100%">
228      <tr valign="top">
229        <td class="prompt">Plugin</td>
230        <td>
231          <select name="plugindefinition_id" class="required" onchange="pluginOnChange()">
232          </select>
233        </td>
234      </tr>
235      <tr valign="top" id="configurations">
236        <td class="prompt">Configuration</td>
237        <td>
238          <select name="pluginconfiguration_id" onchange="configOnChange()">
239          </select>
240        </td>
241      </tr>
242      <%
243      if (messages != null && messages.size() > 0)
244      {
245        %>
246        <tr>
247          <td class="prompt">&nbsp;</td>
248          <td>
249            <base:icon image="bullet.gif" />
250            <a href="javascript:Main.showHide('pluginMessages')" 
251              title="Show/hide the messages from the plugins that couldn't be used">
252            Some plugins couldn't be used
253            </a>
254            <div id="pluginMessages" style="display: none;">
255            <ul>
256            <li><%=Values.getString(messages, "<li>", true)%>
257            </ul>
258            </div>
259          </td>
260        </tr>
261        <%
262      }
263      %>
264      </table>
265      <div align=right>&nbsp;<i><base:icon image="required.gif" /> = required information</i></div>
266      <div id="descriptions" class="helpmessage" 
267        style="height: <%=(int)(scale*270)%>px; overflow: auto; display: none;">
268      <%=descriptions.toString()%>
269      </div>
270    </div>
271    </form>
272 
273    <%
274    if (anotherIsOpen)
275    {
276      %>
277      <div class="error">
278        Another plug-in configuration wizard is open, or it hasn't properly
279        clean up after itself.<br>
280        If you continue unsaved settings in the other wizard is lost.
281      </div>
282      <%
283    }
284    %>
285    <table align="center">
286    <tr>
287      <td width="50%"><base:button onclick="doNext();" title="Next" /></td>
288      <td width="50%"><base:button onclick="window.close();" title="Cancel" /></td>
289    </tr>
290    </table>
291  </base:body>
292  </base:page>
293  <%
294}
295finally
296{
297  if (dc != null) dc.close();
298}
299%>
300
Note: See TracBrowser for help on using the repository browser.