source: trunk/www/admin/hardware/edit_hardware.jsp @ 6296

Last change on this file since 6296 was 6296, checked in by Nicklas Nordborg, 9 years ago

References #1729 and #1730. Fixed for the file types, extra value types and hardware edit dialogs.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 7.3 KB
Line 
1<%-- $Id: edit_hardware.jsp 6296 2013-06-13 13:39:50Z nicklas $
2  ------------------------------------------------------------------
3  Copyright (C) 2005 Nicklas Nordborg
4  Copyright (C) 2006 Jari Häkkinen, Nicklas Nordborg, Martin Svensson
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 BASE. If not, see <http://www.gnu.org/licenses/>.
21  ------------------------------------------------------------------
22
23
24  @author Nicklas
25  @version 2.0
26--%>
27<%@ page pageEncoding="UTF-8" session="false"
28  import="net.sf.basedb.core.SessionControl"
29  import="net.sf.basedb.core.DbControl"
30  import="net.sf.basedb.core.Item"
31  import="net.sf.basedb.core.ItemContext"
32  import="net.sf.basedb.core.Permission"
33  import="net.sf.basedb.core.Hardware"
34  import="net.sf.basedb.core.ItemSubtype"
35  import="net.sf.basedb.core.ItemQuery"
36  import="net.sf.basedb.core.Include"
37  import="net.sf.basedb.core.ItemResultList"
38  import="net.sf.basedb.core.PermissionDeniedException"
39  import="net.sf.basedb.core.query.Orders"
40  import="net.sf.basedb.core.query.Hql"
41  import="net.sf.basedb.clients.web.Base"
42  import="net.sf.basedb.clients.web.util.HTML"
43  import="net.sf.basedb.util.Values"
44  import="net.sf.basedb.core.plugin.GuiContext"
45  import="net.sf.basedb.clients.web.extensions.ExtensionsControl"
46  import="net.sf.basedb.clients.web.extensions.JspContext"
47  import="net.sf.basedb.clients.web.extensions.edit.EditUtil"
48  import="net.sf.basedb.util.extensions.ExtensionsInvoker"
49%>
50<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
51<%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %>
52<%@ taglib prefix="ext" uri="/WEB-INF/extensions.tld" %>
53<%
54final Item itemType = Item.HARDWARE;
55final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
56final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null);
57final int itemId = cc.getId();
58final String ID = sc.getId();
59final float scale = Base.getScale(sc);
60final DbControl dc = sc.newDbControl();
61try
62{
63  String title = null;
64  Hardware hardware = null;
65  boolean readCurrentSubtype = true;
66  int currentSubtypeId = 0;
67
68  if (itemId == 0)
69  {
70    title = "Create hardware";
71    cc.removeObject("item");
72    currentSubtypeId = Values.getInt(request.getParameter("subtype_id"));
73    if (currentSubtypeId == 0)
74    {
75      int recentSubtypeId = Values.getInt(cc.getRecent(Item.ITEMSUBTYPE.name(), 0));
76      currentSubtypeId = Values.getInt(cc.getPropertyValue("itemSubtype"), recentSubtypeId);
77    }
78  }
79  else
80  {
81    hardware = Hardware.getById(dc, itemId);
82    hardware.checkPermission(Permission.WRITE);
83    cc.setObject("item", hardware);
84    title = "Edit hardware -- " + HTML.encodeTags(hardware.getName());
85    try
86    {
87      ItemSubtype subtype = hardware.getItemSubtype();
88      if (subtype != null) currentSubtypeId = subtype.getId();
89    }
90    catch (PermissionDeniedException ex)
91    {
92      readCurrentSubtype = false;
93    }
94  }
95 
96  // Query to retrieve file types
97  final ItemQuery<ItemSubtype> subtypesQuery = Base.getSubtypesQuery(itemType);
98  subtypesQuery.include(Include.ALL);
99   
100  JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.item(itemType), hardware);
101  ExtensionsInvoker invoker = EditUtil.useEditExtensions(jspContext);
102  %>
103  <base:page type="popup" title="<%=title%>" id="edit-page">
104  <base:head scripts="tabcontrol-2.js,subtypes.js,~hardware.js" styles="tabcontrol.css">
105    <ext:scripts context="<%=jspContext%>" />
106    <ext:stylesheets context="<%=jspContext%>" />
107  </base:head>
108  <base:body>
109    <h1><%=title%> <base:help tabcontrol="settings" /></h1>
110    <form action="index.jsp?ID=<%=ID%>" method="post" name="hardware">
111    <input type="hidden" name="cmd" value="UpdateItem">
112
113    <t:tabcontrol id="settings"
114      subclass="content dialogtabcontrol"
115      position="bottom"  remember="<%=hardware != null%>"
116      extensions="<%=invoker%>">
117    <t:tab id="info" title="Hardware" helpid="hardware.edit">
118      <table class="fullform input100 smaller">
119      <tr>
120        <th>Name</th>
121        <td><input class="text required auto-init" type="text" name="name" data-auto-init="<%=hardware == null ? "focus-select" : "focus" %>"
122          value="<%=HTML.encodeTags(hardware == null ? Values.getString(cc.getPropertyValue("name"), "New hardware") : hardware.getName())%>" 
123          maxlength="<%=Hardware.MAX_NAME_LENGTH%>"></td>
124        <td></td>
125      </tr>
126      <tr>
127        <th>Type</th>
128        <td>
129          <select name="subtype_id" id="subtype_id"
130            <%=!readCurrentSubtype ? "disabled readonly class=\"disabled selectionlist\"" : "class=\"selectionlist\""%>
131            >
132          <%
133          if (!readCurrentSubtype)
134          {
135            %>
136            <option value="-1">- denied -
137            <%
138          }
139          else
140          {
141            %>
142            <option value="0">-none-
143            <%
144            for (ItemSubtype subtype : subtypesQuery.list(dc))
145            {
146              int id = subtype.getId();
147              if (id != currentSubtypeId && subtype.isRemoved()) continue;
148              %>
149              <option value="<%=id == currentSubtypeId && hardware != null ? -id : id%>" 
150                <%=id == currentSubtypeId ? "selected" : ""%>
151                title="<%=HTML.encodeTags(subtype.getDescription()) %>"
152                ><%=HTML.encodeTags(subtype.getName())%>
153              <%
154            }
155          }
156          %>
157          </select>
158        </td>
159        <td></td>
160      </tr>
161      <tr>
162        <th>Version</th>
163        <td><input class="text" type="text" name="version" 
164          value="<%=HTML.encodeTags(hardware == null ? cc.getPropertyValue("versionString") : hardware.getVersionString())%>" 
165          maxlength="<%=Hardware.MAX_VERSIONSTRING_LENGTH%>"></td>
166        <td></td>
167      </tr>
168      <tr class="dynamic">
169        <th>Description</th>
170        <td>
171          <textarea class="text" rows="6" name="description" id="description"
172            ><%=HTML.encodeTags(hardware == null ? cc.getPropertyValue("description") : hardware.getDescription())%></textarea>
173        </td>
174        <td style="width: 20px;">
175          <base:zoom textarea="description" title="Description" />
176        </td>
177      </tr>
178      <%
179      if (sc.getActiveProjectId() != 0 && hardware == null && sc.getActiveProjectPermissions().contains(Permission.WRITE))
180      {
181        %>
182        <tr>
183          <th></th>
184          <td style="white-space: nowrap; overflow: hidden; padding-bottom: 2px;">
185            <input type="checkbox" id="setAsProjectDefault" name="setAsProjectDefault" value="1" 
186              checked><label for="setAsProjectDefault">Add as project default</label><br>
187            <input type="checkbox" id="replaceExistingDefault" name="replaceExistingDefault" value="1"
188              checked><label for="replaceExistingDefault">Replace existing default</label>
189              <span id="currentDefault" style="font-style: italic;"></span>
190          </td>
191          <td></td>
192        </tr>
193        <%
194      }
195      %>
196      </table>
197    </t:tab>
198    </t:tabcontrol>
199    </form>
200   
201    <div class="legend">
202      <base:icon image="required.png" />= required information
203    </div>
204
205    <base:buttongroup subclass="dialogbuttons">
206      <base:button id="btnSave" title="Save" />
207      <base:button id="close" title="Cancel" />
208    </base:buttongroup>
209  </base:body>
210  </base:page>
211  <%
212}
213finally
214{
215  if (dc != null) dc.close();
216}
217%>
Note: See TracBrowser for help on using the repository browser.