diff options
Diffstat (limited to 'winery/org.eclipse.winery.repository/src/main/webapp/WEB-INF/tags/servicetemplates/boundarydefinitions')
3 files changed, 376 insertions, 0 deletions
diff --git a/winery/org.eclipse.winery.repository/src/main/webapp/WEB-INF/tags/servicetemplates/boundarydefinitions/browseForReqOrCap.tag b/winery/org.eclipse.winery.repository/src/main/webapp/WEB-INF/tags/servicetemplates/boundarydefinitions/browseForReqOrCap.tag new file mode 100644 index 0000000..5195f9b --- /dev/null +++ b/winery/org.eclipse.winery.repository/src/main/webapp/WEB-INF/tags/servicetemplates/boundarydefinitions/browseForReqOrCap.tag @@ -0,0 +1,161 @@ +<%-- +/******************************************************************************* + * Copyright (c) 2014 University of Stuttgart. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * and the Apache License 2.0 which both accompany this distribution, + * and are available at http://www.eclipse.org/legal/epl-v10.html + * and http://www.apache.org/licenses/LICENSE-2.0 + * + * Contributors: + * Oliver Kopp - initial API and implementation and/or initial documentation + *******************************************************************************/ +--%> + +<%@tag pageEncoding="UTF-8"%> + +<%@attribute name="label" description="Requirement|Capability" required="true" %> +<%@attribute name="requirementsOrCapabilities" description="requirements|capabilities" required="true" %> +<%@attribute name="reqOrCap" description="requirement|capability" required="true" %> + +<%@taglib prefix="b" tagdir="/WEB-INF/tags/servicetemplates/boundarydefinitions"%> + +<b:browseForX XShort="${reqOrCap}" XLong="${label}" /> + +<div class="modal fade" id="${reqOrCap}Diag"> + <div class="modal-dialog"> + <div class="modal-content"> + <div class="modal-header"> + <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> + <h4 class="modal-title"><span id="addOrUpdate${reqOrCap}Span"></span> ${label}</h4> + </div> + <div class="modal-body"> + <form> + <fieldset> + <div class="form-group"> + <label for="${reqOrCap}Name">Name</label> + <div> + <input name="${reqOrCap}Name" id="${reqOrCap}Name" class="form-control" type="text"> + </div> + </div> + <div class="form-group"> + <label for="${reqOrCap}RefDiv">${label}</label> + <div id="${reqOrCap}RefDiv" class="row"> + <div class="col-xs-10"> + <input id="X${reqOrCap}Ref" class="form-control" type="text"> <%-- The input id is prefixed with "X" as "requirementRef" alone does not work --%> + </div> + <div class="col-xs-2"> + <button type="button" class="btn btn-default btn-sm" onclick="browseFor${reqOrCap}($('#XReqRef'));">Browse</button> + </div> + </div> + </div> + </fieldset> + </form> + </div> + + <div class="modal-footer"> + <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> + <button id="add${reqOrCap}" type="button" class="btn btn-primary" onclick="addorUpdate${reqOrCap}(false);">Add</button> + <button id="delete${reqOrCap}" type="button" class="btn btn-danger" onclick="delete${reqOrCap}t();">Delete</button> + <button id="update${reqOrCap}" type="button" class="btn btn-primary" onclick="addorUpdate${reqOrCap}(true);">Update</button> + </div> + </div> + </div> +</div> + + +<script> +/** + * Triggered by the browse button at requirements. In the dialog Add/Change Requirement + */ +function browseFor${reqOrCap}(field) { + $("#${reqOrCap}ReferenceField").val($("#X${reqOrCap}Ref").val()); + $("#browseFor${reqOrCap}Diag").modal("show"); +} + +/** + * Called by click on "Set" button at the browseForReqDiag + */ +function set${reqOrCap}Ref() { + $("#X${reqOrCap}Ref").val($("#${reqOrCap}ReferenceField").val()); + $("#browseFor${reqOrCap}Diag").modal("hide"); +} + +/** + * Called from the modal after the user clicks "Add" or "Delete" + */ +function addorUpdate${reqOrCap}(update) { + var data = { + name: $("#${reqOrCap}Name").val(), + ref: $("#X${reqOrCap}Ref").val() + } + + $.ajax({ + url: "boundarydefinitions/${requirementsOrCapabilities}/", + data: data, + type: "POST" + }).fail(function(jqXHR, textStatus, errorThrown) { + vShowAJAXError("Could not add ${label}", jqXHR, errorThrown); + }).done(function(id) { + // data is the new id + var tableRow = [id, data.name, data.ref]; + ${requirementsOrCapabilities}TableInfo.table.fnAddData(tableRow); + + if (update) { + // update is implemented as delete + recreate + // after successfull creation, we can delete + deleteOnServerAndInTable(${requirementsOrCapabilities}TableInfo, '${label}', 'boundarydefinitions/${requirementsOrCapabilities}/', undefined, undefined, undefined, true); + // TODO: we should hook into onSuccess/onError, but currently these are not exposed from deleteResource to deleteOnServerAndInTable + vShowSuccess("Successfully updated ${label}."); + } else { + vShowSuccess("Successfully added ${label}."); + } + + + $('#${reqOrCap}Diag').modal('hide'); + }); +}; + +function deleteRequirement() { + $('#${reqOrCap}Diag').modal('hide'); + $("#delete${reqOrCap}").click(); +} + +/** + * Called from the buttons in the table if the user clicks "Add" or "Edit" + */ +function open${reqOrCap}Editor(update) { + if (update) { + if (${requirementsOrCapabilities}TableInfo.selectedRow) { + require(["winery-support"], function(ws) { + if (ws.isEmptyTable(${requirementsOrCapabilities}TableInfo)) { + vShowError("No ${requirementsOrCapabilities} available"); + return; + } + + var data = ${requirementsOrCapabilities}TableInfo.table.fnGetData(${requirementsOrCapabilities}TableInfo.table.selectedRow); + // we don't require the id as deleteOnServerAndInTable automatically deletes the selectedRow + $("#${reqOrCap}Name").val(data[0][1]); + $("#X${reqOrCap}Ref").val(data[0][2]); + + $("#add${reqOrCap}").hide(); + $("#update${reqOrCap}").show(); + $("#delete${reqOrCap}").show(); + + $("#addOrUpdate${reqOrCap}Span").text("Change"); + $('#${reqOrCap}Diag').modal('show'); + }); + } else { + vShowError("No ${label} selected"); + } + } else { + // create a new req/cap + $("#add${reqOrCap}").show(); + $("#update${reqOrCap}").hide(); + $("#delete${reqOrCap}").hide(); + $("#addOrUpdate${reqOrCap}Span").text("Add"); + $('#${reqOrCap}Diag').modal('show'); + } +} + +</script> diff --git a/winery/org.eclipse.winery.repository/src/main/webapp/WEB-INF/tags/servicetemplates/boundarydefinitions/browseForServiceTemplatePropertyReqOrCap.tag b/winery/org.eclipse.winery.repository/src/main/webapp/WEB-INF/tags/servicetemplates/boundarydefinitions/browseForServiceTemplatePropertyReqOrCap.tag new file mode 100644 index 0000000..430d4db --- /dev/null +++ b/winery/org.eclipse.winery.repository/src/main/webapp/WEB-INF/tags/servicetemplates/boundarydefinitions/browseForServiceTemplatePropertyReqOrCap.tag @@ -0,0 +1,166 @@ +<%-- +/******************************************************************************* + * Copyright (c) 2013-2014 University of Stuttgart. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * and the Apache License 2.0 which both accompany this distribution, + * and are available at http://www.eclipse.org/legal/epl-v10.html + * and http://www.apache.org/licenses/LICENSE-2.0 + * + * Contributors: + * Oliver Kopp - initial API and implementation and/or initial documentation + *******************************************************************************/ +--%> + +<%@tag pageEncoding="UTF-8"%> + +<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> +<%@taglib prefix="bd" tagdir="/WEB-INF/tags/servicetemplates/boundarydefinitions" %> + +<%@attribute name="definedPropertiesAsJSONString" required="true" %> + +<div class="modal fade z1051" id="browseForServiceTemplatePropertyDiag" > + <div class="modal-dialog"> + <div class="modal-content"> + <div class="modal-header"> + <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> + <h4 class="modal-title">Choose Property of Service Template</h4> + </div> + + <div class="modal-body"> + <p class="text-info">Please click on a node to select the element</p> + <div id='propertymappingstree'></div> + <form> + <fieldset> + <div class="form-group"> + <label for="newServiceTemplatePropertyRef">Reference to the property of the Service Template</label> + <input type="text" id="newServiceTemplatePropertyRef" class="form-control" /> + </div> + </fieldset> + </form> + </div> + + <div class="modal-footer"> + <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> + <button type="button" class="btn btn-primary" onclick="setServiceTemplatePropertyRef();">Set</button> + </div> + </div> + </div> +</div> + +<%-- Browse for property --%> +<%-- +The following cannot be used as we return TWO things: the template and the property +<bd:browseForX XShort="Property" XLong="Node Template, Relationship Template, or directly a property" /> +--%> +<div class="modal fade z1051" id="browseForTemplateProperty"> + <div class="modal-dialog" style="width:1000px;"> + <div class="modal-content"> + <div class="modal-header"> + <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> + <h4 class="modal-title">Choose Node Template, Relationship Template, or directly a property</h4> + </div> + + <div class="modal-body"> + <p class="text-info">Please click on the desired element</p> + <iframe id="topologyTemplatePreview" class="topologyTemplatePreviewSizing" src="topologytemplate/?view=propertySelection&script=${pageContext.request.contextPath}/js/boundaryDefinitionsXSelection.js"></iframe> + <form> + <fieldset> + <div class="form-group"> + <label for="newObjectRef">Reference to the object in the topology template</label> + <input type="text" id="newObjectRef" class="form-control newObjectRef" /> <%-- newObjectRef required as --%> + </div> + <div class="form-group"> + <label for="newObjectPropertyRef">Reference to the object's property</label> + <input type="text" id="newObjectPropertyRef" class="form-control" /> + </div> + </fieldset> + </form> + </div> + + <div class="modal-footer"> + <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> + <button type="button" class="btn btn-primary" onclick="setTemplateAndTemplatePropertyRef();">Set</button> + </div> + </div> + </div> +</div> + +<bd:browseForReqOrCap label="Requirement" reqOrCap="Req" requirementsOrCapabilities="requirements"/> +<bd:browseForReqOrCap label="Capability" reqOrCap="Cap" requirementsOrCapabilities="capabilities"/> + +<script> +//global variable to hold the reference to the input field where the selection of the service template property should be written into +//Requried as both a property mapping and a property constraint refer to a property of the service template. +var fieldToWriteSelectedServiceTemplateProperty; + +function setServiceTemplatePropertyRef() { + fieldToWriteSelectedServiceTemplateProperty.val($("#newServiceTemplatePropertyRef").val()); + $("#browseForServiceTemplatePropertyDiag").modal("hide"); +} + +function browseForServiceTemplateProperty(field) { + fieldToWriteSelectedServiceTemplateProperty = field; + $("#newServiceTemplatePropertyRef").val(field.val()); + $("#browseForServiceTemplatePropertyDiag").modal("show"); +} + + +/** + * Opens topology and lets user select a node template, relationship template, + */ +function browseForTemplateAndProperty() { + $("#newObjectRef").val($("#targetObjectRef").val()); + $("#newObjectPropertyRef").val($("#targetPropertyRef").val()); + $("#browseForTemplateProperty").modal("show"); +} + +function setTemplateAndTemplatePropertyRef() { + $("#targetObjectRef").val($("#newObjectRef").val()); + // always copy over targetPropertyRef, even if it's empty + $("#targetPropertyRef").val($("#newObjectPropertyRef").val()); + + $("#browseForTemplateProperty").modal("hide"); +} + +<c:if test="${not empty definedPropertiesAsJSONString}"> +// initialize the xmltree of the service template properties +// xmltree has to be inialized once and not more than once +// Therefore, we put it here and not in some shown events +require(["xmltree"], function(xmltree) { + new xmltree({ + xml: '${definedPropertiesAsJSONString}', + container: '#propertymappingstree', + startCollapsed: false, + clickCallback: serviceTemplatePropertyClicked + }); +}); +</c:if> + +function serviceTemplatePropertyClicked(li, xpath, event) { + require(["winery-support"], function(ws) { + var pathFragmentRegExp = ws.QName_RegExp + "(.*)"; + var pathFragmentPattern = new RegExp(pathFragmentRegExp); + + // Transform the XPath to an XPath being namespace unaware + // This is required as the OpenTOSCA container does not implement XPath processing in a namespace-aware manner + var fragments = xpath.split("/"); + var path = []; + $(fragments).each(function(i,e) { + var res = pathFragmentPattern.exec(e); + if (res != null) { + if (typeof res[1] !== undefined) { + e = "*[local-name()='" + res[3] + "']" + res[5]; + } + } + path.push(e); + }); + xpath = path.join("/"); + + $("#newServiceTemplatePropertyRef").val(xpath); + }); +} + +/* communication with the iframe is at boundarydefinitions.jsp as we also need it for "Interfaces" */ + +</script>
\ No newline at end of file diff --git a/winery/org.eclipse.winery.repository/src/main/webapp/WEB-INF/tags/servicetemplates/boundarydefinitions/browseForX.tag b/winery/org.eclipse.winery.repository/src/main/webapp/WEB-INF/tags/servicetemplates/boundarydefinitions/browseForX.tag new file mode 100644 index 0000000..4b38b62 --- /dev/null +++ b/winery/org.eclipse.winery.repository/src/main/webapp/WEB-INF/tags/servicetemplates/boundarydefinitions/browseForX.tag @@ -0,0 +1,49 @@ +<%-- +/******************************************************************************* + * Copyright (c) 2014 University of Stuttgart. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * and the Apache License 2.0 which both accompany this distribution, + * and are available at http://www.eclipse.org/legal/epl-v10.html + * and http://www.apache.org/licenses/LICENSE-2.0 + * + * Contributors: + * Oliver Kopp - initial API and implementation and/or initial documentation + *******************************************************************************/ +--%> + +<%@tag pageEncoding="UTF-8"%> + +<%@attribute name="XShort" description="The X to browse for. Short form. E.g., Req, Cap, ..." required="true" %> +<%@attribute name="XLong" description="The X to browse for. Long form. E.g., Requirement, Capability, ..." required="true" %> + + +<%-- Browse for property --%> +<div class="modal fade z1051" id="browseFor${XShort}Diag"> + <div class="modal-dialog" style="width:1000px;"> + <div class="modal-content"> + <div class="modal-header"> + <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> + <h4 class="modal-title">Choose a ${XLong}</h4> + </div> + + <div class="modal-body"> + <p class="text-info">Please click on the desired ${XLong}</p> + <iframe id="topologyTemplatePreview" class="topologyTemplatePreviewSizing" src="topologytemplate/?view=${XShort}Selection&script=${pageContext.request.contextPath}/js/boundaryDefinitionsXSelection.js"></iframe> + <form> + <fieldset> + <div class="form-group"> + <label for="${XShort}RefeferenceField">Reference to the ${XLong} in the topology template</label> + <input type="text" id="${XShort}ReferenceField" class="form-control newObjectRef" /> + </div> + </fieldset> + </form> + </div> + + <div class="modal-footer"> + <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> + <button type="button" class="btn btn-primary" onclick="set${XShort}Ref();">Set</button> + </div> + </div> + </div> +</div> |