source: trunk/www/filemanager/select_file.jsp @ 5713

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

References #1604: Support for multiple files of the same type in a FileSet?

Added data and core layer classes. Started with the gui and seems to work when adding single files of a type. There are some remaining things to implement when used with multiple files. File validation is not yet fully functional. Some of the batch importers need to be fixed as well to be able to handle multiple files of the same type.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 5.0 KB
Line 
1<%-- $Id: select_file.jsp 5713 2011-09-02 13:01:58Z nicklas $
2  ------------------------------------------------------------------
3  Copyright (C) 2006 Jari Häkkinen, 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.*"
27  import="net.sf.basedb.clients.web.*"
28%>
29<%@ taglib
30  prefix="base" uri="/WEB-INF/base.tld"
31%>
32<%
33SessionControl sc = Base.getExistingSessionControl(pageContext, Permission.DENIED, Item.FILE);
34String ID = sc.getId();
35String requestTitle = request.getParameter("title");
36String callback = request.getParameter("callback");
37final ModeInfo mode = ModeInfo.get(request.getParameter("mode"));
38final String title = mode.generateTitle("file", "files");
39%>
40<base:page title="<%=requestTitle == null ? title : requestTitle%>" type="popup">
41<base:head >
42  <script language="JavaScript">
43  var timer = 0;
44  var inCall = false;
45  function adjustIFrameSize()
46  {
47    if (inCall) return;
48    inCall = true;
49    var iframeElement = document.getElementById("idManager");
50    // Find the top coordinate of the IFrame
51    var offsetTop = 1;
52    var offsetTrail = iframeElement;
53    while (offsetTrail)
54    {
55      offsetTop += offsetTrail.offsetTop;
56      offsetTrail = offsetTrail.offsetParent;
57    }
58
59    // Find the browser window height
60    var windowHeight = Main.getWindowHeight();
61    var controlsPos = Main.getElementPosition(document.getElementById('controls'));
62    iframeElement.height = windowHeight-offsetTop - controlsPos.height - 15;
63
64    // Adjust the height of the frames
65    var iframe = window.frames['manager'];
66    var directories = iframe.frames['directories'].document.getElementById('main');
67    if (directories) directories.style.height = (iframeElement.height-1)+'px';
68    var joust = iframe.frames['directories'].document.getElementById('joust');
69    if (joust) joust.style.height = (iframeElement.height-1-30)+'px';
70    var files = iframe.frames['files'].document.getElementById('main');
71    if (files) files.style.height = iframeElement.height+'px';
72    inCall = false;
73  }
74  function setTimer()
75  {
76    if (inCall) return;
77    if (timer) clearTimeout(timer);
78    timer = setTimeout('adjustIFrameSize()', 150);
79  }
80  function setSelected(fileId, path)
81  {
82    var frm = document.forms['file'];
83    frm.file_id.value = fileId;
84    frm.path.value = path;
85  }
86  function addSelected(fileId, path)
87  {
88    var frm = document.forms['file'];
89    if (getSelectedFileIndex(fileId) == -1)
90    {
91      frm.paths[frm.paths.length] = new Option(path, fileId);
92    }
93  }
94  function removeSelected(fileId)
95  {
96    var frm = document.forms['file'];
97    var index = getSelectedFileIndex(fileId);
98    if (index >= 0) frm.paths[index] = null;
99  }
100 
101  function getSelectedFileIndex(fileId)
102  {
103    var frm = document.forms['file'];
104    for (var i = 0; i < frm.paths.length; i++)
105    {
106      if (frm.paths[i].value == fileId) return i;
107    }
108    return -1;
109  }
110 
111  function returnSelected()
112  {
113    var frm = document.forms['file'];
114    <%
115    if (mode == ModeInfo.SELECTONE)
116    {
117      %>
118      if (frm.file_id.value)
119      {
120        window.opener.<%=callback%>(frm.file_id.value, frm.path.value);
121      }
122      <%
123    }
124    else
125    {
126      %>
127      for (var i = 0; i < frm.paths.length; i++)
128      {
129        window.opener.<%=callback%>(frm.paths[i].value, frm.paths[i].text);
130      }
131      <%
132    }
133    %>   
134    window.close();
135  }
136  </script>
137</base:head>
138<base:body attributes="onresize='setTimer();'">
139  <h3><%=requestTitle == null ? title : requestTitle%></h3>
140  <iframe name="manager" id="idManager" src="frameset.jsp?ID=<%=ID%>&mode=<%=mode.getName()%>" width="100%" 
141    frameborder="0" vspace="0" hspace="0"
142    marginwidth="0" marginheight="0" scrolling="no" style="overflow: visible"></iframe>
143
144  <div style="border-top: 1px solid #666666" id="controls">
145  <form name="file">
146  <input type="hidden" name="file_id" value="">
147  <table class="form" align="center">
148  <%
149  if (mode == ModeInfo.SELECTONE)
150  {
151    %>
152    <tr>
153      <td class="prompt">Selected file</td>
154      <td><input type="text" class="text" name="path" size="100" value=""></td>
155    </tr>
156    <%
157  }
158  else
159  {
160    %>
161    <tr>
162      <td class="prompt">Selected files</td>
163      <td><select name="paths" size="5" multiple style="width: 50em;"></select></td>
164    </tr>
165    <%
166  }
167  %>
168  </table>
169  </form>
170 
171  <table align="center">
172  <tr>
173    <td width="50%"><base:button onclick="returnSelected();" title="Ok"  /></td>
174    <td width="50%"><base:button onclick="window.top.close();" title="Cancel" /></td>
175  </tr>
176  </table>
177  </div>
178</base:body>
179</base:page>
Note: See TracBrowser for help on using the repository browser.