7a2c067b66551e847c45402f2d67266d89ec9486
[vfc/nfvo/wfengine.git] / winery / org.eclipse.winery.topologymodeler / src / main / webapp / WEB-INF / tags / common / QNameChooser.tag
1 <%--
2 /*******************************************************************************
3  * Copyright (c) 2012-2014 University of Stuttgart.
4  * All rights reserved. This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License v1.0
6  * and the Apache License 2.0 which both accompany this distribution,
7  * and are available at http://www.eclipse.org/legal/epl-v10.html
8  * and http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Contributors:
11  *    Oliver Kopp - initial API and implementation and/or initial documentation
12  *******************************************************************************/
13 --%>
14 <%@tag description="Dialog parts for choosing a QName" pageEncoding="UTF-8"%>
15
16 <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
17 <%@taglib prefix="wc" uri="http://www.eclipse.org/winery/functions"%>
18
19 <%@attribute name="allQNames" required="true" type="java.util.Collection" description="Collection&lt;QName&gt; of all available QNames" %>
20 <%@attribute name="includeNONE" required="false" type="java.lang.Boolean" description="Should (none) be included as option?"%>
21 <%@attribute name="selected" required="false" description="The initial value to select"%>
22 <%@attribute name="labelOfSelectField" required="true"%>
23 <%@attribute name="idOfSelectField" required="true"%>
24
25 <div class="form-group">
26         <c:if test="${not empty labelOfSelectField}"><label for="${idOfSelectField}" class="control-label">${labelOfSelectField}:</label></c:if>
27         <select id="${idOfSelectField}" name="${idOfSelectField}" class="form-control">
28                 <c:if test="${includeNONE}"><option value="(none)">(none)</option></c:if>
29                 <c:forEach var="namespaceEntry" items="${wc:convertQNameListToNamespaceToLocalNameList(allQNames)}">
30                         <optgroup label="${namespaceEntry.key}">
31                                 <c:forEach var="localName" items="${namespaceEntry.value}">
32                                         <option value="{${namespaceEntry.key}}${localName}">${localName}</option>
33                                 </c:forEach>
34                         </optgroup>
35                 </c:forEach>
36         </select>
37 </div>
38
39 <script>
40 $(function(){
41         $("#${idOfSelectField}").select2();
42         <c:if test="${not empty selected}">
43                 $("#${idOfSelectField}").select2("val", "${selected}");
44         </c:if>
45 });
46 </script>