source: trunk/www/admin/software/edit_software.jsp @ 6334

Last change on this file since 6334 was 6334, checked in by olle, 9 years ago

Refs #1772. Support for annotatable Software items added.

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