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