1 | <%-- $Id: edit_tag.jsp 6306 2013-08-13 13:15:33Z 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.Tag" |
---|
34 | import="net.sf.basedb.core.ItemSubtype" |
---|
35 | import="net.sf.basedb.core.PermissionDeniedException" |
---|
36 | import="net.sf.basedb.core.ItemQuery" |
---|
37 | import="net.sf.basedb.core.Include" |
---|
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.core.plugin.GuiContext" |
---|
43 | import="net.sf.basedb.clients.web.extensions.ExtensionsControl" |
---|
44 | import="net.sf.basedb.clients.web.extensions.JspContext" |
---|
45 | import="net.sf.basedb.clients.web.extensions.edit.EditUtil" |
---|
46 | import="net.sf.basedb.util.extensions.ExtensionsInvoker" |
---|
47 | import="net.sf.basedb.util.Values" |
---|
48 | %> |
---|
49 | <%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> |
---|
50 | <%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %> |
---|
51 | <%@ taglib prefix="ext" uri="/WEB-INF/extensions.tld" %> |
---|
52 | <% |
---|
53 | final Item itemType = Item.TAG; |
---|
54 | final SessionControl sc = Base.getExistingSessionControl(pageContext, true); |
---|
55 | final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null); |
---|
56 | final int itemId = cc.getId(); |
---|
57 | final String ID = sc.getId(); |
---|
58 | final float scale = Base.getScale(sc); |
---|
59 | final DbControl dc = sc.newDbControl(); |
---|
60 | try |
---|
61 | { |
---|
62 | String title = null; |
---|
63 | Tag tag = null; |
---|
64 | boolean readCurrentTagType = true; |
---|
65 | int currentTagTypeId = 0; |
---|
66 | |
---|
67 | if (itemId == 0) |
---|
68 | { |
---|
69 | title = "Create tag"; |
---|
70 | cc.removeObject("item"); |
---|
71 | currentTagTypeId = Values.getInt(request.getParameter("tagtype_id")); |
---|
72 | if (currentTagTypeId == 0) |
---|
73 | { |
---|
74 | int recentTagTypeId = Values.getInt(cc.getRecent(Item.ITEMSUBTYPE.name(), 0)); |
---|
75 | currentTagTypeId = Values.getInt(cc.getPropertyValue("itemSubtype"), recentTagTypeId); |
---|
76 | } |
---|
77 | } |
---|
78 | else |
---|
79 | { |
---|
80 | tag = Tag.getById(dc, itemId); |
---|
81 | tag.checkPermission(Permission.WRITE); |
---|
82 | cc.setObject("item", tag); |
---|
83 | title = "Edit tag -- " + HTML.encodeTags(tag.getName()); |
---|
84 | try |
---|
85 | { |
---|
86 | ItemSubtype tagType = tag.getItemSubtype(); |
---|
87 | if (tagType != null) currentTagTypeId = tagType.getId(); |
---|
88 | } |
---|
89 | catch (PermissionDeniedException ex) |
---|
90 | { |
---|
91 | readCurrentTagType = false; |
---|
92 | } |
---|
93 | } |
---|
94 | |
---|
95 | // Query to retrieve protocol types |
---|
96 | final ItemQuery<ItemSubtype> tagTypeQuery = ItemSubtype.getQuery(itemType); |
---|
97 | tagTypeQuery.include(Include.ALL); |
---|
98 | tagTypeQuery.order(Orders.asc(Hql.property("name"))); |
---|
99 | |
---|
100 | JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.item(itemType), tag); |
---|
101 | ExtensionsInvoker invoker = EditUtil.useEditExtensions(jspContext); |
---|
102 | %> |
---|
103 | <base:page type="popup" title="<%=title%>" id="edit-page"> |
---|
104 | <base:head scripts="tabcontrol-2.js,~tags.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="tag"> |
---|
111 | <input type="hidden" name="cmd" value="UpdateItem"> |
---|
112 | |
---|
113 | <t:tabcontrol id="settings" |
---|
114 | subclass="content dialogtabcontrol" |
---|
115 | position="bottom" remember="<%=tag != null%>" |
---|
116 | extensions="<%=invoker%>"> |
---|
117 | <t:tab id="info" title="Tag" helpid="tag.edit"> |
---|
118 | <table class="fullform input100 smaller"> |
---|
119 | <tr> |
---|
120 | <th>Name</th> |
---|
121 | <td><input class="text required auto-init" data-auto-init="<%=tag == null ? "focus-select" : "focus" %>" |
---|
122 | type="text" name="name" |
---|
123 | value="<%=HTML.encodeTags(tag == null ? Values.getString(cc.getPropertyValue("name"), "New tag") : tag.getName())%>" |
---|
124 | maxlength="<%=Tag.MAX_NAME_LENGTH%>"></td> |
---|
125 | <td></td> |
---|
126 | </tr> |
---|
127 | <tr> |
---|
128 | <th>Type</th> |
---|
129 | <td> |
---|
130 | <select name="tagtype_id" |
---|
131 | <%=!readCurrentTagType ? "disabled readonly class=\"disabled\"" : "class=\"required\""%>> |
---|
132 | <% |
---|
133 | if (!readCurrentTagType) |
---|
134 | { |
---|
135 | %> |
---|
136 | <option value="-1">- denied - |
---|
137 | <% |
---|
138 | } |
---|
139 | else |
---|
140 | { |
---|
141 | for (ItemSubtype tagType : tagTypeQuery.list(dc)) |
---|
142 | { |
---|
143 | int id = tagType.getId(); |
---|
144 | if (id != currentTagTypeId && tagType.isRemoved()) continue; |
---|
145 | %> |
---|
146 | <option value="<%=id == currentTagTypeId && tag != null ? -id : id%>" |
---|
147 | <%=id == currentTagTypeId ? "selected" : ""%> |
---|
148 | ><%=HTML.encodeTags(tagType.getName())%> |
---|
149 | <% |
---|
150 | } |
---|
151 | } |
---|
152 | %> |
---|
153 | </select> |
---|
154 | </td> |
---|
155 | <td></td> |
---|
156 | </tr> |
---|
157 | <tr class="dynamic"> |
---|
158 | <th>Description</th> |
---|
159 | <td> |
---|
160 | <textarea class="text" rows="6" name="description" id="description" |
---|
161 | ><%=HTML.encodeTags(tag == null ? cc.getPropertyValue("description") : tag.getDescription())%></textarea> |
---|
162 | </td> |
---|
163 | <td style="width: 20px;"> |
---|
164 | <base:zoom textarea="description" title="Description" /> |
---|
165 | </td> |
---|
166 | </tr> |
---|
167 | </table> |
---|
168 | </t:tab> |
---|
169 | </t:tabcontrol> |
---|
170 | </form> |
---|
171 | |
---|
172 | <div class="legend"> |
---|
173 | <base:icon image="required.png" />= required information |
---|
174 | </div> |
---|
175 | |
---|
176 | <base:buttongroup subclass="dialogbuttons"> |
---|
177 | <base:button id="btnSave" title="Save" /> |
---|
178 | <base:button id="close" title="Cancel" /> |
---|
179 | </base:buttongroup> |
---|
180 | </base:body> |
---|
181 | </base:page> |
---|
182 | <% |
---|
183 | } |
---|
184 | finally |
---|
185 | { |
---|
186 | if (dc != null) dc.close(); |
---|
187 | } |
---|
188 | %> |
---|