source: trunk/www/filemanager/directories/edit_directory.jsp @ 3719

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

References #411: Most of the basic functionality is now in place and has been documented
On major issue is that the Affymetrix Fusion SDK will not work with compressed files since
it expects direct access to the java.io.File object. I will try to solve this by modifying the
Affymetric Fusion SDK to work with InputStream:s instead. This would be better than to decompress
CEL and CDF files everytime they are needed. In most cases we only scan the headers anyway, so
it would be good if we can avoid copying the entire 40+ MB file(s) each time.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 5.8 KB
Line 
1<%-- $Id: edit_directory.jsp 3719 2007-09-12 13:02:59Z nicklas $
2  ------------------------------------------------------------------
3  Copyright (C) 2006 Jari Hakkinen, Nicklas Nordborg, Martin Svensson
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 2
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 this program; if not, write to the Free Software
20  Foundation, Inc., 59 Temple Place - Suite 330,
21  Boston, MA  02111-1307, USA.
22  ------------------------------------------------------------------
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.SystemItems"
33  import="net.sf.basedb.core.ItemContext"
34  import="net.sf.basedb.core.Permission"
35  import="net.sf.basedb.core.Directory"
36  import="net.sf.basedb.core.PermissionDeniedException"
37  import="net.sf.basedb.core.BaseException"
38  import="net.sf.basedb.core.query.Orders"
39  import="net.sf.basedb.core.query.Hql"
40  import="net.sf.basedb.clients.web.Base"
41  import="net.sf.basedb.clients.web.util.HTML"
42  import="net.sf.basedb.util.Values"
43  import="java.util.List"
44  import="java.util.Set"
45  import="java.util.HashSet"
46%>
47<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
48<%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %>
49<%
50final Item itemType = Item.DIRECTORY;
51final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
52final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null);
53final int itemId = cc.getId();
54final String ID = sc.getId();
55final float scale = Base.getScale(sc);
56final DbControl dc = sc.newDbControl();
57try
58{
59  String title = null;
60  Directory directory = null;
61  Directory parent = null;
62  boolean autoCompress = false;
63
64  if (itemId == 0)
65  {
66    title = "Create directory";
67    parent = Directory.getById(dc, Values.getInt(request.getParameter("parent_id"), 
68      SystemItems.getId(Directory.ROOT))
69    );
70    autoCompress = parent.getAutoCompress();
71    cc.removeObject("item");
72  }
73  else
74  {
75    directory = Directory.getById(dc, itemId);
76    parent = directory.getParent();
77    autoCompress = directory.getAutoCompress();
78    cc.setObject("item", directory);
79    title = "Edit directory -- " + HTML.encodeTags(directory.getName());
80  }
81  if (directory != null && !directory.hasPermission(Permission.WRITE))
82  {
83    throw new PermissionDeniedException(Permission.WRITE, itemType.toString());
84  }
85
86  final String clazz = "class=\"text\"";
87  final String requiredClazz = "class=\"text required\"";
88  %>
89
90  <base:page type="popup" title="<%=title%>">
91  <base:head scripts="tabcontrol.js" styles="tabcontrol.css">
92    <script language="JavaScript">
93    // Validate the "Directory" tab
94    function validateDirectory()
95    {
96      var frm = document.forms['directory'];
97      if (Main.trimString(frm.name.value) == '')
98      {
99        alert("You must enter a name");
100        frm.name.focus();
101        return false;
102      }
103      return true;
104    }
105    // Submit the form
106    function saveSettings()
107    {
108      var frm = document.forms['directory'];
109      if (TabControl.validateActiveTab('settings'))
110      {
111        frm.submit();
112      }
113    }
114   
115    function init()
116    {
117      <%
118      if (directory == null)
119      {
120        %>
121        var frm = document.forms['directory'];
122        frm.name.focus();
123        frm.name.select();
124        <%
125      }
126      %>
127    }
128    </script>
129  </base:head>
130  <base:body onload="init()">
131    <p>
132    <form action="index.jsp?ID=<%=ID%>" method="post" name="directory" onsubmit="return false;">
133    <input type="hidden" name="cmd" value="UpdateItem">
134    <input type="hidden" name="parent_id" value="<%=parent.getId()%>">
135
136    <h3 class="docked"><%=title%> <base:help tabcontrol="settings" /></h3>
137    <t:tabcontrol id="settings" contentstyle="<%="height: "+(int)(scale*180)+"px;"%>" 
138      position="bottom" remember="<%=directory != null%>">
139    <t:tab id="info" title="Directory" validate="validateDirectory()" helpid="directory.edit">
140      <table class="form" cellspacing=0>
141      <tr>
142        <td class="prompt">Path</td>
143        <td><%=HTML.encodeTags(parent.getPath().toString())%></td>
144      </tr>
145      <tr>
146        <td class="prompt">Name</td>
147        <td><input <%=requiredClazz%> type="text" name="name" 
148          value="<%=HTML.encodeTags(directory == null ? Values.getString(cc.getPropertyValue("name"), "New directory") : directory.getName())%>" 
149          size="40" maxlength="<%=Directory.MAX_NAME_LENGTH%>"></td>
150      </tr>
151      <tr>
152        <td class="prompt">Compress files</td>
153        <td>
154          <input type="radio" name="autoCompress" value="0" <%=!autoCompress ? "checked" : ""%>>no
155          <input type="radio" name="autoCompress" value="1" <%=autoCompress ? "checked" : ""%>>yes
156        </td>
157      </tr> 
158      <tr valign=top>
159        <td class="prompt">Description</td>
160        <td nowrap>
161          <textarea <%=clazz%> rows="4" cols="40" name="description" wrap="virtual"
162            ><%=HTML.encodeTags(directory == null ? cc.getPropertyValue("description") : directory.getDescription())%></textarea>
163          <a href="javascript:Main.zoom('Description', 'directory', 'description')"
164            title="Edit in larger window"><base:icon image="zoom.gif" /></a>
165        </td>
166      </tr>
167      </table>
168      <div align=right>&nbsp;<i><base:icon image="required.gif" /> = required information</i></div>
169    </t:tab>
170
171    </t:tabcontrol>
172
173    <table align="center">
174    <tr>
175      <td width="50%"><base:button onclick="saveSettings()" title="Save" /></td>
176      <td width="50%"><base:button onclick="window.close()" title="Cancel" /></td>
177    </tr>
178    </table>
179    </form>
180  </base:body>
181  </base:page>
182  <%
183}
184finally
185{
186  if (dc != null) dc.close();
187}
188%>
Note: See TracBrowser for help on using the repository browser.