source: trunk/www/biomaterials/tags/edit_tag.jsp @ 6335

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

Refs #1773. Support for annotatable Tag items added.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 6.4 KB
Line 
1<%-- $Id: edit_tag.jsp 6335 2013-10-21 13:46:22Z 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.Tag"
35  import="net.sf.basedb.core.ItemSubtype"
36  import="net.sf.basedb.core.PermissionDeniedException"
37  import="net.sf.basedb.core.ItemQuery"
38  import="net.sf.basedb.core.Include"
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.core.plugin.GuiContext"
44  import="net.sf.basedb.clients.web.extensions.ExtensionsControl"
45  import="net.sf.basedb.clients.web.extensions.JspContext"
46  import="net.sf.basedb.clients.web.extensions.edit.EditUtil"
47  import="net.sf.basedb.util.extensions.ExtensionsInvoker"
48  import="net.sf.basedb.util.Values"
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.TAG;
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  Tag tag = null;
65  boolean readCurrentTagType = true;
66  int currentTagTypeId = 0;
67
68  if (itemId == 0)
69  {
70    title = "Create tag";
71    cc.removeObject("item");
72    currentTagTypeId = Values.getInt(request.getParameter("tagtype_id"));
73    if (currentTagTypeId == 0) 
74    {
75      int recentTagTypeId = Values.getInt(cc.getRecent(Item.ITEMSUBTYPE.name(), 0));
76      currentTagTypeId = Values.getInt(cc.getPropertyValue("itemSubtype"), recentTagTypeId);
77    }
78  }
79  else
80  {
81    tag = Tag.getById(dc, itemId);
82    tag.checkPermission(Permission.WRITE);
83    cc.setObject("item", tag);
84    title = "Edit tag -- " + HTML.encodeTags(tag.getName());
85    try
86    {
87      ItemSubtype tagType = tag.getItemSubtype();
88      if (tagType != null) currentTagTypeId = tagType.getId();
89    }
90    catch (PermissionDeniedException ex)
91    {
92      readCurrentTagType = false;
93    }
94  }
95 
96  // Query to retrieve tag types
97  final ItemQuery<ItemSubtype> tagTypeQuery = ItemSubtype.getQuery(itemType);
98  tagTypeQuery.include(Include.ALL);
99  tagTypeQuery.order(Orders.asc(Hql.property("name")));
100 
101  JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.item(itemType), tag);
102  ExtensionsInvoker invoker = EditUtil.useEditExtensions(jspContext);
103  %>
104  <base:page type="popup" title="<%=title%>" id="edit-page">
105  <base:head scripts="tabcontrol-2.js,~tags.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="tag">
112    <input type="hidden" name="cmd" value="UpdateItem">
113
114    <t:tabcontrol id="settings" 
115      subclass="content dialogtabcontrol"
116      position="bottom"  remember="<%=tag != null%>"
117      extensions="<%=invoker%>">
118    <t:tab id="info" title="Tag" helpid="tag.edit">
119      <table class="fullform input100 smaller">
120      <tr>
121        <th>Name</th>
122        <td><input class="text required auto-init" data-auto-init="<%=tag == null ? "focus-select" : "focus" %>"
123          type="text" name="name" 
124          value="<%=HTML.encodeTags(tag == null ? Values.getString(cc.getPropertyValue("name"), "New tag") : tag.getName())%>" 
125          maxlength="<%=Tag.MAX_NAME_LENGTH%>"></td>
126        <td></td>
127      </tr>
128      <tr>
129        <th>Type</th>
130        <td>
131          <select name="tagtype_id" 
132            <%=!readCurrentTagType ? "disabled readonly class=\"disabled\"" : "class=\"required\""%>>
133          <%
134          if (!readCurrentTagType)
135          {
136            %>
137            <option value="-1">- denied -
138            <%
139          }
140          else
141          {
142            for (ItemSubtype tagType : tagTypeQuery.list(dc))
143            {
144              int id = tagType.getId();
145              if (id != currentTagTypeId && tagType.isRemoved()) continue;
146              %>
147              <option value="<%=id == currentTagTypeId && tag != null ? -id : id%>" 
148                <%=id == currentTagTypeId ? "selected" : ""%>
149                ><%=HTML.encodeTags(tagType.getName())%>
150              <%
151            }
152          }
153          %>
154          </select>
155        </td>
156        <td></td>
157      </tr>
158      <tr class="dynamic">
159        <th>Description</th>
160        <td>
161          <textarea class="text" rows="6" name="description" id="description"
162            ><%=HTML.encodeTags(tag == null ? cc.getPropertyValue("description") : tag.getDescription())%></textarea>
163        </td>
164        <td style="width: 20px;">
165          <base:zoom textarea="description" title="Description" />
166        </td>
167      </tr>
168      </table>
169    </t:tab>
170    <t:tab id="annotations" title="Annotations" helpid="annotations.edit">
171      <jsp:include page="../../common/annotations/annotate_frameset.jsp">
172        <jsp:param name="item_type" value="<%=itemType.name()%>" />
173        <jsp:param name="item_id" value="<%=itemId%>" />
174        <jsp:param name="ID" value="<%=ID%>" />
175      </jsp:include>
176    </t:tab>
177    </t:tabcontrol>
178    </form>
179   
180    <div class="legend">
181      <base:icon image="required.png" />= required information
182    </div>
183
184    <base:buttongroup subclass="dialogbuttons">
185      <base:button id="btnSave" title="Save" />
186      <base:button id="close" title="Cancel" />
187    </base:buttongroup>
188  </base:body>
189  </base:page>
190  <%
191}
192finally
193{
194  if (dc != null) dc.close();
195}
196%>
Note: See TracBrowser for help on using the repository browser.