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

Last change on this file since 3679 was 3679, checked in by Jari Häkkinen, 14 years ago

Changing the pesky "a (ä) character to a.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 5.5 KB
Line 
1<%-- $Id: edit_directory.jsp 3679 2007-08-17 07:18:29Z jari $
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
63  if (itemId == 0)
64  {
65    title = "Create directory";
66    parent = Directory.getById(dc, Values.getInt(request.getParameter("parent_id"), 
67      SystemItems.getId(Directory.ROOT))
68    );
69    cc.removeObject("item");
70  }
71  else
72  {
73    directory = Directory.getById(dc, itemId);
74    parent = directory.getParent();
75    cc.setObject("item", directory);
76    title = "Edit directory -- " + HTML.encodeTags(directory.getName());
77  }
78  if (directory != null && !directory.hasPermission(Permission.WRITE))
79  {
80    throw new PermissionDeniedException(Permission.WRITE, itemType.toString());
81  }
82
83  final String clazz = "class=\"text\"";
84  final String requiredClazz = "class=\"text required\"";
85  %>
86
87  <base:page type="popup" title="<%=title%>">
88  <base:head scripts="tabcontrol.js" styles="tabcontrol.css">
89    <script language="JavaScript">
90    // Validate the "Directory" tab
91    function validateDirectory()
92    {
93      var frm = document.forms['directory'];
94      if (Main.trimString(frm.name.value) == '')
95      {
96        alert("You must enter a name");
97        frm.name.focus();
98        return false;
99      }
100      return true;
101    }
102    // Submit the form
103    function saveSettings()
104    {
105      var frm = document.forms['directory'];
106      if (TabControl.validateActiveTab('settings'))
107      {
108        frm.submit();
109      }
110    }
111   
112    function init()
113    {
114      <%
115      if (directory == null)
116      {
117        %>
118        var frm = document.forms['directory'];
119        frm.name.focus();
120        frm.name.select();
121        <%
122      }
123      %>
124    }
125    </script>
126  </base:head>
127  <base:body onload="init()">
128    <p>
129    <form action="index.jsp?ID=<%=ID%>" method="post" name="directory" onsubmit="return false;">
130    <input type="hidden" name="cmd" value="UpdateItem">
131    <input type="hidden" name="parent_id" value="<%=parent.getId()%>">
132
133    <h3 class="docked"><%=title%> <base:help tabcontrol="settings" /></h3>
134    <t:tabcontrol id="settings" contentstyle="<%="height: "+(int)(scale*180)+"px;"%>" 
135      position="bottom" remember="<%=directory != null%>">
136    <t:tab id="info" title="Directory" validate="validateDirectory()" helpid="directory.edit">
137      <table class="form" cellspacing=0>
138      <tr>
139        <td class="prompt">Path</td>
140        <td><%=HTML.encodeTags(parent.getPath().toString())%></td>
141      </tr>
142      <tr>
143        <td class="prompt">Name</td>
144        <td><input <%=requiredClazz%> type="text" name="name" 
145          value="<%=HTML.encodeTags(directory == null ? Values.getString(cc.getPropertyValue("name"), "New directory") : directory.getName())%>" 
146          size="40" maxlength="<%=Directory.MAX_NAME_LENGTH%>"></td>
147      </tr>
148      <tr valign=top>
149        <td class="prompt">Description</td>
150        <td nowrap>
151          <textarea <%=clazz%> rows="4" cols="40" name="description" wrap="virtual"
152            ><%=HTML.encodeTags(directory == null ? cc.getPropertyValue("description") : directory.getDescription())%></textarea>
153          <a href="javascript:Main.zoom('Description', 'directory', 'description')"
154            title="Edit in larger window"><base:icon image="zoom.gif" /></a>
155        </td>
156      </tr>
157      </table>
158      <div align=right>&nbsp;<i><base:icon image="required.gif" /> = required information</i></div>
159    </t:tab>
160
161    </t:tabcontrol>
162
163    <table align="center">
164    <tr>
165      <td width="50%"><base:button onclick="saveSettings()" title="Save" /></td>
166      <td width="50%"><base:button onclick="window.close()" title="Cancel" /></td>
167    </tr>
168    </table>
169    </form>
170  </base:body>
171  </base:page>
172  <%
173}
174finally
175{
176  if (dc != null) dc.close();
177}
178%>
Note: See TracBrowser for help on using the repository browser.