diff options
Diffstat (limited to 'winery/org.eclipse.winery.topologymodeler/src/main/webapp/WEB-INF/tags/common/templates')
10 files changed, 1038 insertions, 0 deletions
diff --git a/winery/org.eclipse.winery.topologymodeler/src/main/webapp/WEB-INF/tags/common/templates/CSSForTypes.tag b/winery/org.eclipse.winery.topologymodeler/src/main/webapp/WEB-INF/tags/common/templates/CSSForTypes.tag new file mode 100644 index 0000000..1df2d82 --- /dev/null +++ b/winery/org.eclipse.winery.topologymodeler/src/main/webapp/WEB-INF/tags/common/templates/CSSForTypes.tag @@ -0,0 +1,50 @@ +<%-- +/******************************************************************************* + * Copyright (c) 2013 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 description="Generates style element for node types and relationship types" pageEncoding="UTF-8" %> + +<%@attribute name="nodeTypes" required="true" type="java.util.Collection" %> +<%@attribute name="relationshipTypes" required="true" type="java.util.Collection" %> + +<%@tag import="java.util.Collection"%> +<%@tag import="javax.xml.namespace.QName"%> +<%@tag import="org.eclipse.winery.common.ModelUtilities"%> +<%@tag import="org.eclipse.winery.common.Util"%> +<%@tag import="org.eclipse.winery.model.tosca.TNodeType"%> +<%@tag import="org.eclipse.winery.model.tosca.TRelationshipType"%> + +<style> +<% + for (TNodeType nt: (Collection<TNodeType>) nodeTypes) { + String borderColor = ModelUtilities.getBorderColor(nt); + String cssName = Util.makeCSSName(nt.getTargetNamespace(), nt.getName()); +%> + div.NodeTemplateShape.<%=cssName%> { + border-color: <%=borderColor%>; + } +<% + } + + // relationship types CSS + for (TRelationshipType rt: (Collection<TRelationshipType>) relationshipTypes) { + String color = ModelUtilities.getColor(rt); + QName qname = new QName(rt.getTargetNamespace(), rt.getName()); + String cssName = Util.makeCSSName(qname) + "_box"; +%> + div.<%=cssName%> { + background: <%=color%>; + } +<% + } +%> +</style> diff --git a/winery/org.eclipse.winery.topologymodeler/src/main/webapp/WEB-INF/tags/common/templates/defineCreateConnectorEndpointsFunction.tag b/winery/org.eclipse.winery.topologymodeler/src/main/webapp/WEB-INF/tags/common/templates/defineCreateConnectorEndpointsFunction.tag new file mode 100644 index 0000000..26f139a --- /dev/null +++ b/winery/org.eclipse.winery.topologymodeler/src/main/webapp/WEB-INF/tags/common/templates/defineCreateConnectorEndpointsFunction.tag @@ -0,0 +1,42 @@ +<%-- +/******************************************************************************* + * Copyright (c) 2013 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 description="Defines the javascript function createConnectorEndpoints globally. Quick hack to avoid huge hacking at the repository" pageEncoding="UTF-8"%> + +<%@tag import="java.util.Collection"%> +<%@tag import="org.eclipse.winery.model.tosca.TRelationshipType"%> +<%@tag import="org.eclipse.winery.common.Util"%> + +<%@attribute name="relationshipTypes" type="java.util.Collection" required="true" %> + +<script> +function createConnectorEndpoints(nodeTemplateShapeSet) { +<% + for (TRelationshipType relationshipType: (Collection<TRelationshipType>) relationshipTypes) { +%> + nodeTemplateShapeSet.find(".<%=Util.makeCSSName(relationshipType.getTargetNamespace(), relationshipType.getName()) %>").each(function(i,e) { + var p = $(e).parent(); + var grandparent = $(p).parent(); + + jsPlumb.makeSource($(e), { + parent:grandparent, + anchor:"Continuous", + connectionType: "{<%=relationshipType.getTargetNamespace()%>}<%=relationshipType.getName()%>", + endpoint:"Blank" + }); + }); +<% + } +%> +} +</script> diff --git a/winery/org.eclipse.winery.topologymodeler/src/main/webapp/WEB-INF/tags/common/templates/nodetemplates/nodeTemplateRenderer.tag b/winery/org.eclipse.winery.topologymodeler/src/main/webapp/WEB-INF/tags/common/templates/nodetemplates/nodeTemplateRenderer.tag new file mode 100644 index 0000000..16bc737 --- /dev/null +++ b/winery/org.eclipse.winery.topologymodeler/src/main/webapp/WEB-INF/tags/common/templates/nodetemplates/nodeTemplateRenderer.tag @@ -0,0 +1,266 @@ +<%-- +/******************************************************************************* + * Copyright (c) 2012-2013 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: + * Uwe Breitenbücher - skeletton for node template shapes + * Oliver Kopp - initial API and implementation and/or initial documentation + *******************************************************************************/ +--%> +<%@tag language="java" pageEncoding="UTF-8" description="This tag is used for both real nodeTemplate node rendering and rendering of a 'template' used to create a nodeTemplateShape. The latter is called by palette.jsp. Therefore, this tag has to be more general."%> +<%-- Parameters --%> + +<%-- template and palette --%> +<%@attribute name="client" required="true" description="IWineryRepository" type="org.eclipse.winery.common.interfaces.IWineryRepository"%> +<%@attribute name="repositoryURL" required="true" type="java.lang.String" description="The URL of winery's repository"%> +<%@attribute name="topologyModelerURI" required="false" type="java.lang.String" description="The URL of winery topology modeler's URI - required for images/. Has to end with '/'. Can be left blank."%> +<%@attribute name="relationshipTypes" description="the known relationship types" required="true" type="java.util.Collection"%> + +<%-- only for topology modeler --%> +<%@attribute name="nodeTemplate" type="org.eclipse.winery.model.tosca.TNodeTemplate"%> +<%@attribute name="top"%> +<%@attribute name="left"%> + +<%-- only for palette.jsp --%> +<%@attribute name="nodeType" type="org.eclipse.winery.model.tosca.TNodeType" %> +<%@attribute name="nodeTypeQName" type="javax.xml.namespace.QName"%> + +<%@tag import="org.eclipse.winery.model.tosca.TArtifactTemplate"%> +<%@tag import="org.eclipse.winery.model.tosca.TArtifactType"%> +<%@tag import="org.eclipse.winery.model.tosca.TCapability"%> +<%@tag import="org.eclipse.winery.model.tosca.TDeploymentArtifact"%> +<%@tag import="org.eclipse.winery.model.tosca.TDeploymentArtifacts"%> +<%@tag import="org.eclipse.winery.model.tosca.TEntityType.PropertiesDefinition"%> +<%@tag import="org.eclipse.winery.model.tosca.TNodeTemplate"%> +<%@tag import="org.eclipse.winery.model.tosca.TNodeTemplate.Capabilities"%> +<%@tag import="org.eclipse.winery.model.tosca.TNodeTemplate.Requirements"%> +<%@tag import="org.eclipse.winery.model.tosca.TNodeTemplate.Policies"%> +<%@tag import="org.eclipse.winery.model.tosca.TNodeType"%> +<%@tag import="org.eclipse.winery.model.tosca.TPolicy"%> +<%@tag import="org.eclipse.winery.model.tosca.TRelationshipType"%> +<%@tag import="org.eclipse.winery.model.tosca.TRequirement"%> +<%@tag import="org.eclipse.winery.common.ModelUtilities"%> +<%@tag import="org.eclipse.winery.common.Util"%> +<%@tag import="org.eclipse.winery.common.ids.definitions.ArtifactTemplateId"%> +<%@tag import="org.eclipse.winery.common.ids.definitions.ArtifactTypeId"%> +<%@tag import="org.eclipse.winery.common.interfaces.IWineryRepository"%> +<%@tag import="org.w3c.dom.Element" %> +<%@tag import="org.apache.commons.configuration.Configuration"%> +<%@tag import="org.apache.commons.lang3.StringUtils"%> +<%@tag import="org.apache.commons.lang3.StringEscapeUtils"%> +<%@tag import="java.io.StringWriter" %> +<%@tag import="java.util.Collections"%> +<%@tag import="java.util.Collection"%> +<%@tag import="java.util.Iterator"%> +<%@tag import="java.util.List"%> +<%@tag import="java.util.Map"%> +<%@tag import="java.util.UUID"%> +<%@tag import="javax.xml.namespace.QName"%> +<%@tag import="javax.xml.transform.OutputKeys"%> +<%@tag import="javax.xml.transform.Transformer"%> +<%@tag import="javax.xml.transform.TransformerFactory"%> +<%@tag import="javax.xml.transform.dom.DOMSource"%> +<%@tag import="javax.xml.transform.stream.StreamResult"%> + +<%@taglib prefix="nt" tagdir="/WEB-INF/tags/common/templates/nodetemplates" %> +<%@taglib prefix="ntrq" tagdir="/WEB-INF/tags/common/templates/nodetemplates/reqscaps" %> +<%@taglib prefix="pol" tagdir="/WEB-INF/tags/common/policies" %> +<%@taglib prefix="props" tagdir="/WEB-INF/tags/common/templates" %> + +<% + String visualElementId; + + boolean paletteMode; + if (nodeTemplate == null) { + // we are in palette mode + // --> we render a template to be inserted in the drawing area by drag'n'drop + paletteMode = true; + assert(nodeType != null); + assert(nodeTypeQName != null); + + // these values are only pseudo values, they get all overwritten in drop function of palette.jsp + visualElementId = UUID.randomUUID().toString(); + left = "0"; + top = "0"; + } else { + // we render a real node template + paletteMode = false; + nodeTypeQName = nodeTemplate.getType(); + nodeType = client.getType(nodeTypeQName, TNodeType.class); + if (nodeType == null) { +%> + <script>vShowError("Could not get node type <%=nodeTypeQName%>");</script> +<% + return; + } + + visualElementId = nodeTemplate.getId(); + } + + String nodeTypeCSSName = Util.makeCSSName(nodeTypeQName); +%> + + <div class="NodeTemplateShape unselectable <%=nodeTypeCSSName%> <%if (paletteMode){%> hidden<%}%>" id="<%=visualElementId%>" style="left: <%=left%>px; top: <%=top%>px"> + <div class="headerContainer"> + <img class="icon" onerror="var that=this; require(['winery-common-topologyrendering'], function(wct){wct.imageError(that);});" src="<%=repositoryURL%>/nodetypes/<%=Util.DoubleURLencode(nodeTypeQName)%>/visualappearance/50x50" /> + <% + String name; + if (paletteMode) { + name = ""; // will be changed on drop + } else { + name = nodeTemplate.getName(); + if (StringUtils.isEmpty(name)) { + name = visualElementId; + } + } + %> + <div class="minMaxInstances"> + <span class="minInstances"><% + if (!paletteMode) { + %><%=Util.renderMinInstances(nodeTemplate.getMinInstances())%><% + } + %></span> + <span class="maxInstances"><% + if (!paletteMode) { + %><%=Util.renderMaxInstances(nodeTemplate.getMaxInstances())%><% + } + %></span> + </div> + <div class="id nodetemplate"><%=visualElementId%></div> + <div class="name nodetemplate"><%=name%></div> + <div class="type nodetemplate"><%=Util.qname2hrefWithName(repositoryURL, TNodeType.class, nodeTypeQName, nodeType.getName())%></div> + <span class="typeQName hidden"><%=nodeTypeQName%></span> + <span class="typeNamespace hidden"><%=nodeTypeQName.getNamespaceURI()%></span> + </div> + <div class="endpointContainer"> + <% + for (TRelationshipType relationshipType: (Collection<TRelationshipType>) relationshipTypes) { + %> + <div class="connectorEndpoint <%=Util.makeCSSName(relationshipType.getTargetNamespace(), relationshipType.getName())%>"> + <div class="connectorBox <%=Util.makeCSSName(relationshipType.getTargetNamespace(), relationshipType.getName())%>_box"></div> + <div class="connectorLabel"><%=relationshipType.getName()%></div> + </div> + <% + } + %> + </div> + + <%-- Properties --%> + <props:properties + propertiesDefinition="<%=nodeType.getPropertiesDefinition()%>" + wpd="<%=ModelUtilities.getWinerysPropertiesDefinition(nodeType)%>" + template="<%=paletteMode ? null : nodeTemplate %>" + pathToImages="${topologyModelerURI}images/" /> + + <%-- Deployment Artifacts --%> + + <% + List<TDeploymentArtifact> deploymentArtifacts; + if (paletteMode) { + deploymentArtifacts = Collections.emptyList(); + } else { + TDeploymentArtifacts tDeploymentArtifacts = nodeTemplate.getDeploymentArtifacts(); + if (tDeploymentArtifacts == null) { + deploymentArtifacts = Collections.emptyList(); + } else { + deploymentArtifacts = tDeploymentArtifacts.getDeploymentArtifact(); + } + } + // Render even if (deploymentArtifacts.isEmpty()), because user could add some with drag'n'drop + + // following is required to render artifact specific content + TransformerFactory transFactory = TransformerFactory.newInstance(); + Transformer transformer = transFactory.newTransformer(); + transformer.setOutputProperty(OutputKeys.INDENT, "yes"); + transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes"); + %> + + <div class="deploymentArtifactsContainer"> + + <div class="header">Deployment Artifacts</div> + <div class="content"> + <% + if (!paletteMode) { + for (TDeploymentArtifact deploymentArtifact : deploymentArtifacts) { + %> + <div class="deploymentArtifact row" onclick="showDeploymentArtifactInformation('<%=visualElementId%>', '<%=deploymentArtifact.getName()%>');"> + <textarea class="hidden"><%=org.eclipse.winery.common.Util.getXMLAsString(org.eclipse.winery.model.tosca.TDeploymentArtifact.class, deploymentArtifact)%></textarea> + <div class="col-xs-4 overflowhidden deploymentArtifact name"><%=deploymentArtifact.getName()%></div> + <div class="col-xs-4 overflowhidden artifactTemplate"><% + QName artifactRef; + if ((artifactRef = deploymentArtifact.getArtifactRef()) != null) { + ArtifactTemplateId atId = new ArtifactTemplateId(artifactRef); + %><%=client.getName(atId)%><% + } + %></div> + <div class="col-xs-4 overflowhidden artifactType"><% + ArtifactTypeId atyId = new ArtifactTypeId(deploymentArtifact.getArtifactType()); + %><%=client.getName(atyId)%></div> + </div> + <% + } + } + %> + + <div class="row addDA"> + <button class="btn btn-default btn-xs center-block addDA">Add new</button> + </div> + + <div class="row addnewartifacttemplate"> + <div class="center-block">Drop to add new deployment artifact. Not yet implemented.</div> + </div> + </div> + </div> + + <%-- Requirements and Capabilities --%> + <% + List<TRequirement> reqList; + if (paletteMode) { + reqList = null; + } else { + Requirements reqs = nodeTemplate.getRequirements(); + if (reqs == null) { + reqList = null; + } else { + reqList = reqs.getRequirement(); + } + } + %> + <ntrq:reqs list="<%=reqList%>" repositoryURL="${repositoryURL}" pathToImages="${topologyModelerURI}images/" client="${client}" /> + + <% + List<TCapability> capList; + if (paletteMode) { + capList = null; + } else { + Capabilities caps = nodeTemplate.getCapabilities(); + if (caps == null) { + capList = null; + } else { + capList = caps.getCapability(); + } + } + %> + <ntrq:caps list="<%=capList%>" repositoryURL="${repositoryURL}" pathToImages="${topologyModelerURI}images/" client="${client}"/> + + <%-- Policies --%> + <% + List<TPolicy> policyList; + if (paletteMode) { + policyList = null; + } else { + Policies policies = nodeTemplate.getPolicies(); + if (policies == null) { + policyList = null; + } else { + policyList = policies.getPolicy(); + } + } + %> + <pol:policies list="<%=policyList%>" repositoryURL="${repositoryURL}" /> +</div> diff --git a/winery/org.eclipse.winery.topologymodeler/src/main/webapp/WEB-INF/tags/common/templates/nodetemplates/reqscaps/caps.tag b/winery/org.eclipse.winery.topologymodeler/src/main/webapp/WEB-INF/tags/common/templates/nodetemplates/reqscaps/caps.tag new file mode 100644 index 0000000..af70ff6 --- /dev/null +++ b/winery/org.eclipse.winery.topologymodeler/src/main/webapp/WEB-INF/tags/common/templates/nodetemplates/reqscaps/caps.tag @@ -0,0 +1,33 @@ +<%-- +/******************************************************************************* + * Copyright (c) 2012-2013 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 description="Renders the list of requirements or capabilties" pageEncoding="UTF-8"%> +<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> +<%@taglib prefix="nt" tagdir="/WEB-INF/tags/common/templates/nodetemplates/reqscaps" %> + +<%@attribute name="client" required="true" description="IWineryRepository" type="org.eclipse.winery.common.interfaces.IWineryRepository"%> +<%@attribute name="list" required="false" type="java.util.List"%> +<%@attribute name="repositoryURL" required="true" %> +<%@attribute name="pathToImages" required="true" description="The path (URI path) to the image/ url, where xml.png is available. Has to end with '/'"%> + +<nt:reqsorcaps + headerLabel="Capabilities" + cssClassPrefix="capabilities" + list="${list}" + shortName="Cap" + TReqOrCapTypeClass="<%=org.eclipse.winery.model.tosca.TCapabilityType.class%>" + repositoryURL="${repositoryURL}" + typeURLFragment="capabilitytypes" + pathToImages="${pathToImages}" + client="${client}" +/> diff --git a/winery/org.eclipse.winery.topologymodeler/src/main/webapp/WEB-INF/tags/common/templates/nodetemplates/reqscaps/reqs.tag b/winery/org.eclipse.winery.topologymodeler/src/main/webapp/WEB-INF/tags/common/templates/nodetemplates/reqscaps/reqs.tag new file mode 100644 index 0000000..473443e --- /dev/null +++ b/winery/org.eclipse.winery.topologymodeler/src/main/webapp/WEB-INF/tags/common/templates/nodetemplates/reqscaps/reqs.tag @@ -0,0 +1,33 @@ +<%-- +/******************************************************************************* + * Copyright (c) 2012-2013 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 description="Renders the list of requirements or capabilties" pageEncoding="UTF-8"%> +<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> +<%@taglib prefix="nt" tagdir="/WEB-INF/tags/common/templates/nodetemplates/reqscaps" %> + +<%@attribute name="client" required="true" description="IWineryRepository" type="org.eclipse.winery.common.interfaces.IWineryRepository"%> +<%@attribute name="list" required="false" type="java.util.List"%> +<%@attribute name="repositoryURL" required="true" %> +<%@attribute name="pathToImages" required="true" description="The path (URI path) to the image/ url, where xml.png is available. Has to end with '/'"%> + +<nt:reqsorcaps + headerLabel="Requirements" + cssClassPrefix="requirements" + list="${list}" + shortName="Req" + TReqOrCapTypeClass="<%=org.eclipse.winery.model.tosca.TRequirementType.class%>" + repositoryURL="${repositoryURL}" + typeURLFragment="requirementtypes" + pathToImages="${pathToImages}" + client="${client}" +/> diff --git a/winery/org.eclipse.winery.topologymodeler/src/main/webapp/WEB-INF/tags/common/templates/nodetemplates/reqscaps/reqsorcaps.tag b/winery/org.eclipse.winery.topologymodeler/src/main/webapp/WEB-INF/tags/common/templates/nodetemplates/reqscaps/reqsorcaps.tag new file mode 100644 index 0000000..6046730 --- /dev/null +++ b/winery/org.eclipse.winery.topologymodeler/src/main/webapp/WEB-INF/tags/common/templates/nodetemplates/reqscaps/reqsorcaps.tag @@ -0,0 +1,63 @@ +<%-- +/******************************************************************************* + * Copyright (c) 2012-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 description="Renders the list of requirements or capabilties" pageEncoding="UTF-8"%> + +<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> +<%@taglib prefix="wc" uri="http://www.eclipse.org/winery/functions"%> +<%@taglib prefix="nt" tagdir="/WEB-INF/tags/common/templates/nodetemplates/reqscaps" %> +<%@taglib prefix="props" tagdir="/WEB-INF/tags/common/templates" %> + +<%@attribute name="list" required="false" type="java.util.List" %> +<%@attribute name="headerLabel" required="true" description="Used for the heading" %> +<%@attribute name="cssClassPrefix" required="true" %> +<%@attribute name="TReqOrCapTypeClass" required="true" type="java.lang.Class" %> +<%@attribute name="repositoryURL" required="true" %> +<%@attribute name="typeURLFragment" required="true" description="requirementtypes|capabilitytypes"%> +<%@attribute name="shortName" required="true" description="Used for diag id, function name suffix, Req|Cap"%> +<%@attribute name="client" required="true" description="IWineryRepository" type="org.eclipse.winery.common.interfaces.IWineryRepository"%> +<%@attribute name="pathToImages" required="true" description="The path (URI path) to the image/ url, where xml.png is available. Has to end with '/'"%> + +<%@tag import="org.eclipse.winery.common.ModelUtilities"%> + +<div class="${cssClassPrefix}Container"> + <div class="header">${headerLabel}</div> + <div class="content"> + <c:forEach var="item" items="${list}"> + <div class="reqorcap ${cssClassPrefix} row" id="${item.id}"> + <div class="col-xs-4 id reqorcap">${item.id}</div> + <div class="col-xs-4 name reqorcap">${item.name}</div> + <div class="col-xs-4 type reqorcap">${wc:qname2href(repositoryURL, TReqOrCapTypeClass, item.type)}</div> + <c:set var="type" value="${wc:getType(client, item.type, TReqOrCapTypeClass)}" /> + <props:properties + template="${item}" + propertiesDefinition="${type.propertiesDefinition}" + wpd="${wc:winerysPropertiesDefinition(type)}" + pathToImages="${pathToImages}" /> + </div> + </c:forEach> + <div class="addnewreqorcap row" style="display:none;"> + <button class="btn btn-default btn-xs center-block" onclick="showAddOrUpdateDiagFor${shortName}($(this).parent().parent().parent().parent().attr('id'));">Add new</button> + </div> + </div> +</div> + +<%-- parameters: o.id, o.name, o.type, o.xml. Has to be consistent with above HTML --%> +<script type="text/x-tmpl" id="tmpl-${shortName}"> + <div class="reqorcap ${cssClassPrefix}" id="{%=o.id%}"> + <div class="col-xs-4 id reqorcap">{%=o.id%}</div> + <div class="col-xs-4 name reqorcap">{%=o.name%}</div> + <div class="col-xs-4 type reqorcap">{%#require("winery-support-common").qname2href("${repositoryURL}", "${typeURLFragment}", o.type)%}</div> + <div id="toBeReplacedByProperties"></div> + </div> +</script> diff --git a/winery/org.eclipse.winery.topologymodeler/src/main/webapp/WEB-INF/tags/common/templates/properties.tag b/winery/org.eclipse.winery.topologymodeler/src/main/webapp/WEB-INF/tags/common/templates/properties.tag new file mode 100644 index 0000000..4cc6f0a --- /dev/null +++ b/winery/org.eclipse.winery.topologymodeler/src/main/webapp/WEB-INF/tags/common/templates/properties.tag @@ -0,0 +1,103 @@ +<%-- +/******************************************************************************* + * Copyright (c) 2012-2013 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 description="Rendering for properties. A separate CSS has to be provided to style the content. Thus, this tag is reusable both in the topology modeler and in the management UI. Requires global javaScript function editPropertiesXML(visualElementId)" pageEncoding="UTF-8"%> +<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> + +<%@attribute name="propertiesDefinition" required="true" type="org.eclipse.winery.model.tosca.TEntityType.PropertiesDefinition" description="The TOSCA-conforming properties definition. May be null."%> +<%@attribute name="wpd" required="true" type="org.eclipse.winery.common.propertydefinitionkv.WinerysPropertiesDefinition" description="Winery's K/V properties definition. May be null"%> +<%@attribute name="template" required="true" type="org.eclipse.winery.model.tosca.TEntityTemplate" description="The template to display properties. Has to be null in case of the palette mode of the topology modeler"%> +<%@attribute name="pathToImages" required="true" description="The path (URI path) to the image/ url, where xml.png is available. Has to end with '/'"%> + +<%@tag import="org.eclipse.winery.common.ModelUtilities"%> +<%@tag import="org.eclipse.winery.common.propertydefinitionkv.WinerysPropertiesDefinition"%> +<%@tag import="org.eclipse.winery.common.propertydefinitionkv.PropertyDefinitionKV"%> +<%@tag import="org.eclipse.winery.common.propertydefinitionkv.PropertyDefinitionKVList"%> + +<% +if ((propertiesDefinition != null) || (wpd != null)) { +// properties exist +%> + <div class="propertiesContainer"> + <div class="header">Properties</div> + <div class="content"> + <% + if (wpd == null) { + // no winery's special properties definition, but "normal" TOSCA properties definition + + if (propertiesDefinition.getType() != null) { + %> + <span class="properties_type">XSD Type: <%=propertiesDefinition.getType()%></span> + <% + } else { + %> + <span class="properties_element">XSD Element: <%=propertiesDefinition.getElement()%></span> + <% + } + %> + <textarea class="properties_xml"><% + if (template != null) { + %><%=org.eclipse.winery.common.Util.getXMLAsString(org.eclipse.winery.model.tosca.TEntityTemplate.Properties.class, template.getProperties())%><% + } + %></textarea> + <%-- We have to do use $(this).parent().parent().parent().attr('id') instead of <%=visualElementId%> as on drag'n'drop from the palette, this binding is NOT changed, but the Id changes --> the user does NOT want to edit the properties from the palette entry, but from the node template --%> + <button class="btn btn-default" onclick="editPropertiesXML($(this).parent().parent().parent().attr('id'));"><img src="${pathToImages}xml.png"></img>View</button> + <% + } else { + // Winery special mode + java.util.Properties props; + if (template == null) { + // setting null only because of dump compiler. + // We never read props if in paletteMode + props = null; + } else { + props = ModelUtilities.getPropertiesKV(template); + } + %> + <%-- stores wrapper element name and namespace to ease serialization--%> + <span class="elementName"><%=wpd.getElementName()%></span> + <span class="namespace"><%=wpd.getNamespace()%></span> + <table> + <% + PropertyDefinitionKVList list = wpd.getPropertyDefinitionKVList(); + if (list != null) { + // iterate on all defined properties + for (PropertyDefinitionKV propdef: list) { + String key = propdef.getKey(); + String value; + if (template == null) { + value = ""; + } else { + // assign value, but change "null" to "" if no property is defined + if ((value = props.getProperty(key)) == null) { + value = ""; + } + } + %> + <tr class="KVProperty"> + <td><span class="<%= key %> KVPropertyKey"><%= key %></span></td> + <td><a class="KVPropertyValue" href="#" data-type="text" data-title="Enter <%= key %>"><%=value %></a></td> + </tr> + <% + } + } + %> + </table> + <% + } + %> + </div> + </div> +<% +} +%> diff --git a/winery/org.eclipse.winery.topologymodeler/src/main/webapp/WEB-INF/tags/common/templates/propertiesBasic.tag b/winery/org.eclipse.winery.topologymodeler/src/main/webapp/WEB-INF/tags/common/templates/propertiesBasic.tag new file mode 100644 index 0000000..5e850b1 --- /dev/null +++ b/winery/org.eclipse.winery.topologymodeler/src/main/webapp/WEB-INF/tags/common/templates/propertiesBasic.tag @@ -0,0 +1,112 @@ +<%-- +/******************************************************************************* + * Copyright (c) 2012-2013 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 description="Has to be included once before ussage of properties.tag. Used in topology modeler and in properties.jsp of entitytemplates" pageEncoding="UTF-8"%> + +<%@tag import="org.eclipse.winery.common.constants.Namespaces" %> + +<%@taglib prefix="o" tagdir="/WEB-INF/tags/common/orioneditor"%> + +<div class="modal fade" id="PropertyXMLDiag"> + <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">Property</h4> + </div> + <div class="modal-body"> + <!-- embed the XML editor without a save button. We provide the save button by ourselves --> + <o:orioneditorarea areaid="PropertyXML" withoutsavebutton="true"/> + </div> + <div class="modal-footer"> + <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button> + <button type="button" class="btn btn-primary" onclick="savePropertiesXMLChanges();">Save</button> + </div> + </div> + </div> +</div> + +<script> +// global variable set by editPropertiesXML and read by savePropertiesXMLChanges +var nodeTemplateIdsTextAreaPropertiesXMLEditing; + +function editPropertiesXML(nodeTemplateId) { + // code mirror does not update content if field not fully shown + // therefore, we hook in into the "shown" event + $("#PropertyXMLDiag").off("shown.bs.modal"); + $("#PropertyXMLDiag").on("shown.bs.modal", function() { + nodeTemplateIdsTextAreaPropertiesXMLEditing = $("#" + nodeTemplateId).children(".propertiesContainer").children(".content").children("textarea"); + var val = nodeTemplateIdsTextAreaPropertiesXMLEditing.val(); + window.winery.orionareas["PropertyXML"].editor.setText(val); + window.winery.orionareas["PropertyXML"].fixEditorHeight(); + }); + $("#PropertyXMLDiag").modal("show"); + nodeTemplateIdSelectedForPropertiesXMLEditing = nodeTemplateId; +} + +function savePropertiesXMLChanges() { + var val = window.winery.orionareas["PropertyXML"].editor.getText(); + nodeTemplateIdsTextAreaPropertiesXMLEditing.text(val); + $("#PropertyXMLDiag").modal("hide"); +} + +/** + * @param properties - the properties div + * @param w - an XMLWriter + */ +function savePropertiesFromDivToXMLWriter(properties, w, writeNamespaceDeclaration) { + if (properties.length != 0) { + // properties exist + var contentDiv = properties.children("div.content"); + var xmlProperties = contentDiv.children("textarea.properties_xml"); + if (xmlProperties.length == 0) { + // K/V properties -> winery special: XSD defined at node type + + var elementName = contentDiv.children("span.elementName").text(); + var namespace = contentDiv.children("span.namespace").text(); + + w.writeStartElement("Properties"); + if (writeNamespaceDeclaration){ + w.writeAttributeString("xmlns", "<%=Namespaces.TOSCA_NAMESPACE%>"); + } + w.writeStartElement(elementName); + w.writeAttributeString("xmlns", namespace); + properties.children("div.content").children("table").children("tbody").children("tr").each(function() { + var keyEl = $(this).children("td:first-child"); + var key = keyEl.text(); + var valueEl = keyEl.next().children("a"); + var value; + if (valueEl.hasClass("editable-empty")) { + value = ""; + } else { + value = valueEl.text(); + value = value.replace(/\]\]>/g, "]]]]><![CDATA[>"); + value = "<![CDATA[" + value + "]]>"; + } + w.writeStartElement(key); + w.writeString(value); + w.writeEndElement(); + }); + w.writeEndElement(); + // close "Properties" + w.writeEndElement(); + } else { + // just put the content of the XML field as child of the current node template + // The sourrinding tag "properties" is included in the XML field + var data = xmlProperties.text(); + w.writeXML(data); + } + } + +} +</script> diff --git a/winery/org.eclipse.winery.topologymodeler/src/main/webapp/WEB-INF/tags/common/templates/registerConnectionTypesAndConnectNodeTemplates.tag b/winery/org.eclipse.winery.topologymodeler/src/main/webapp/WEB-INF/tags/common/templates/registerConnectionTypesAndConnectNodeTemplates.tag new file mode 100644 index 0000000..fb55f9e --- /dev/null +++ b/winery/org.eclipse.winery.topologymodeler/src/main/webapp/WEB-INF/tags/common/templates/registerConnectionTypesAndConnectNodeTemplates.tag @@ -0,0 +1,205 @@ +<%-- +/******************************************************************************* + * Copyright (c) 2012-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 description="Registers the connection types to jsPlumb" pageEncoding="UTF-8"%> + +<%@attribute name="relationshipTypes" description="the known relationship types" required="true" type="java.util.Collection"%> +<%@attribute name="relationshipTemplates" description="the relationship templates to render" required="true" type="java.util.Collection"%> +<%@attribute name="ondone" description="JavaScript code executed when everything has been done" required="false"%> +<%@attribute name="repositoryURL" required="true" %> +<%@attribute name="readOnly" required="false" type="java.lang.Boolean"%> + +<%@tag import="java.util.Collection"%> +<%@tag import="org.eclipse.winery.model.tosca.TRequirement"%> +<%@tag import="org.eclipse.winery.model.tosca.TCapability"%> +<%@tag import="org.eclipse.winery.model.tosca.TNodeTemplate"%> +<%@tag import="org.eclipse.winery.model.tosca.TRelationshipType"%> +<%@tag import="org.eclipse.winery.model.tosca.TRelationshipTemplate"%> +<%@tag import="org.eclipse.winery.model.tosca.TRelationshipTemplate.SourceElement"%> +<%@tag import="org.eclipse.winery.model.tosca.TRelationshipTemplate.TargetElement"%> +<%@tag import="org.eclipse.winery.common.Util"%> + +<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> + +<% +Collection<TRelationshipType> relationshipTypesCasted = (Collection<TRelationshipType>) relationshipTypes; +Collection<TRelationshipTemplate> relationshipTemplatesCasted = (Collection<TRelationshipTemplate>) relationshipTemplates; +%> + +<script> +// we should load jquery and jquery.ui to have it available at jsPlumb +// however, jquery.ui cannot be loaded as it conflicts with bootstrap (when using toogle buttons) +require(["jquery", "jsplumb", "winery-common-topologyrendering"], function(globallyavailablea, jsPlumb, wct) { + jsPlumb.bind("ready", function() { + /** + * Shows error if req or cap does not exist + */ + function getNodeTemplateIdForReqOrCapId(id) { + var reqOrCap = $("#" + id); + if (reqOrCap.length == 0) { + vShowError("Requirement/Capability with id " + id + " not found"); + } + var res = reqOrCap.parent().parent().parent().attr("id"); + return res; + } + + // register the "selected" type to enable selection of arrows + jsPlumb.registerConnectionTypes({ + "selected":{ + paintStyle:{ strokeStyle:"red", lineWidth:5 }, + hoverPaintStyle:{ lineWidth: 7 } + } + }); + +<% + int i=0; + String when = ""; + String whenRes = ""; + if (relationshipTypesCasted.isEmpty()) { +%> + vShowError("No relationship types exist. Please add relationship types to the repository"); +<% + } + for (TRelationshipType relationshipType: relationshipTypesCasted) { + String fnName = "ajaxRTdata" + i; + when = when + fnName + "(), "; + whenRes = whenRes + fnName + ", "; +%> + function <%=fnName%>() { return $.ajax({ + url: "<%=repositoryURL%>/relationshiptypes/<%=Util.DoubleURLencode(relationshipType.getTargetNamespace())%>/<%=Util.DoubleURLencode(relationshipType.getName())%>/visualappearance/", + dataType: "json", + success: function(data, textStatus, jqXHR) { + jsPlumb.registerConnectionType( + "{<%=relationshipType.getTargetNamespace()%>}<%=relationshipType.getName()%>", + data); + }, + error: function(jqXHR, textStatus, errorThrown) { + vShowAJAXError("Could not load relationship type {<%=relationshipType.getTargetNamespace()%>}<%=relationshipType.getName()%>", jqXHR, errorThrown); + } + });}; +<% + i++; + } + + if (!relationshipTypesCasted.isEmpty()) { + // strip last comma + when = when.substring(0, when.length()-2); + whenRes = whenRes.substring(0, whenRes.length()-2); + } +%> + // as soon as all relationship types are registered as jsPlumb object, + // create connection end points and connect the nodes + $.when(<%=when%>).done(function(<%=whenRes%>){ + require(["winery-common-topologyrendering"], function(wct) { + // A NodeTemplateShape also appears in the palette. There, it is hidden. + // These should not be initialized as the template will be initialized later on + + <c:if test="${readOnly}">wct.setReadOnly();</c:if> + + // Quick hack: All node templates are draggable, even in the readonly view + wct.initNodeTemplate(jsPlumb.getSelector(".NodeTemplateShape:not('.hidden')"), true); + + var sourceId; + var targetId; +<% + for (TRelationshipTemplate relationshipTemplate : relationshipTemplatesCasted) { +%> + var req = undefined; + var cap = undefined; +<% + // Source: Either NodeTemplate or Requirement + SourceElement sourceElement = relationshipTemplate.getSourceElement(); + if (sourceElement == null) { + %>vShowError("sourceElement is null for <%=relationshipTemplate.getId()%>");<% + continue; + } + Object source = sourceElement.getRef(); + if (source instanceof TRequirement) { +%> + req = "<%=((TRequirement)source).getId()%>"; + sourceId = getNodeTemplateIdForReqOrCapId(req); +<% + } else { + TNodeTemplate sourceT = (TNodeTemplate) source; + if (sourceT == null) { + %>vShowError("sourceElement.getRef() is null for <%=relationshipTemplate.getId()%>");<% + continue; + } +%> + sourceId = "<%=sourceT.getId()%>"; +<% + } + + // Target: Either NodeTemplate or Requirement + TargetElement targetElement = relationshipTemplate.getTargetElement(); + if (targetElement == null) { + %>vShowError("targetElement is null for <%=relationshipTemplate.getId()%>");<% + continue; + } + Object target = targetElement.getRef(); + if (target instanceof TCapability) { +%> + cap = "<%=((TCapability)target).getId()%>"; + targetId = getNodeTemplateIdForReqOrCapId(cap); +<% + } else { + TNodeTemplate targetT = (TNodeTemplate) target; + if (targetT == null) { + %>vShowError("targetElement.getRef() is null for <%=relationshipTemplate.getId()%>");<% + continue; + } +%> + targetId = "<%=targetT.getId()%>"; +<% + } +%> + var c = jsPlumb.connect({ + source: sourceId, + target: targetId, + type:"<%=relationshipTemplate.getType()%>" + }); + wct.handleConnectionCreated(c); + // we have to store the TOSCA id as jsPlumb does not allow to pass ids from user's side + // we could overwrite c.id, but we are not aware the side effects... + winery.connections[c.id].id = "<%=relationshipTemplate.getId()%>"; + if (req) { + winery.connections[c.id].req = req; + } + if (cap) { + winery.connections[c.id].cap = cap; + } +<% + if (relationshipTemplate.getName() != null) { +%> + winery.connections[c.id].name = "<%=relationshipTemplate.getName()%>"; +<% + } + } +%> + + // all connections are there + // we can register the events now + + jsPlumb.bind("connection", wct.handleConnectionCreated); + + ${ondone} + + // end of the when waiting for all relationship types + }); + // end of require binding + }); + // jsPlumb.ready + }); +// requirejs +}); +</script> diff --git a/winery/org.eclipse.winery.topologymodeler/src/main/webapp/WEB-INF/tags/common/templates/toggleButtons.tag b/winery/org.eclipse.winery.topologymodeler/src/main/webapp/WEB-INF/tags/common/templates/toggleButtons.tag new file mode 100644 index 0000000..05ed289 --- /dev/null +++ b/winery/org.eclipse.winery.topologymodeler/src/main/webapp/WEB-INF/tags/common/templates/toggleButtons.tag @@ -0,0 +1,131 @@ +<%-- +/******************************************************************************* + * Copyright (c) 2013 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 description="Toggle buttons for visual appearance" pageEncoding="UTF-8"%> +<script> +var JQUERY_ANIMATION_DURATION = 400; + +function doShowOrHide(elements, showThem) { + if (elements.length == 0) { + // e.g., no properties defined + return; + } + if (showThem) { + elements.slideDown(); + } else { + elements.slideUp(); + } + window.setTimeout(function() { + jsPlumb.repaint(elements.parent()); + }, JQUERY_ANIMATION_DURATION); +} + +function showIds(cb) { + var elements; + if ($("div.NodeTemplateShape.selected").size() > 0) { + elements = $("div.NodeTemplateShape.selected div.id.nodetemplate"); + } else { + elements = $("div.NodeTemplateShape:visible div.id.nodetemplate"); + } + + if ($(cb).hasClass("active")) { + elements.fadeOut(); + } else { + elements.fadeIn(); + } + // no repaint required as no nodes are moved + // window.setTimeout(jsPlumb.repaintEverything, JQUERY_ANIMATION_DURATION); +} + +/** + * Toogles visiblity of both node types and relationship types + */ +function showTypes(showThem) { + // types at node templates + var elements; + var typesOfRelationshipTemplates; + if ($("div.NodeTemplateShape.selected").size() > 0) { + elements = $("div.NodeTemplateShape.selected div.type.nodetemplate"); + // TODO: We should put into typesOfRelationshipTemplates all type divs of relationshiptemplates connecting highlighted node templates + // This should be done when doing the multiselect + // And there should be a second if similar to the node templates for relationship templates + typesOfRelationshipTemplates = $(".todo"); + } else { + elements = $("div.NodeTemplateShape:visible div.type.nodetemplate"); + // TODO: we should check for a single relationship template being selected + typesOfRelationshipTemplates = $(".relationshipTypeLabel"); + } + + if (showThem) { + elements.fadeIn(); + typesOfRelationshipTemplates.fadeIn(); + } else { + elements.fadeOut(); + typesOfRelationshipTemplates.fadeOut(); + } + + // no repaint required as no nodes are moved + // window.setTimeout(jsPlumb.repaintEverything, JQUERY_ANIMATION_DURATION); +} + +function showOrHideProperties(showThem) { + var elements; + if ($("div.NodeTemplateShape.selected").size() > 0) { + elements = $("div.NodeTemplateShape.selected > div.propertiesContainer"); + } else { + elements = $("div.NodeTemplateShape:visible > div.propertiesContainer"); + } + doShowOrHide(elements, showThem); +} + + +function showOrHideDeploymentArtifacts(showThem) { + var elements; + if ($("div.NodeTemplateShape.selected").size() > 0) { + elements = $("div.NodeTemplateShape:visible.selected > div.deploymentArtifactsContainer"); + } else { + elements = $("div.NodeTemplateShape:visible > div.deploymentArtifactsContainer"); + } + doShowOrHide(elements, showThem); +} + +function showOrHideReqCaps(showThem) { + var elements; + if ($("div.NodeTemplateShape.selected").size() > 0) { + elements = $("div.NodeTemplateShape:visible.selected > div.requirementsContainer, div.NodeTemplateShape:visible.selected > div.capabilitiesContainer"); + } else { + elements = $("div.NodeTemplateShape:visible > div.requirementsContainer, div.NodeTemplateShape:visible > div.capabilitiesContainer"); + } + doShowOrHide(elements, showThem); +} + +function showOrHidePolicies(showThem) { + var elements; + if ($("div.NodeTemplateShape.selected").size() > 0) { + elements = $("div.NodeTemplateShape:visible.selected > div.policiesContainer"); + } else { + elements = $("div.NodeTemplateShape:visible > div.policiesContainer"); + } + doShowOrHide(elements, showThem); +} +</script> + +<div class="btn-group" data-toggle="buttons-checkbox" id="toggleButtons"> + <button class="btn btn-default" id="toggleIdVisibility" onclick="showIds(this);">Ids</button> + <button class="btn active" id="toggleTypeVisibility" onclick="showTypes(!$(this).hasClass('active'));">Types</button> + <button class="btn btn-default" id="togglePropertiesVisibility" onclick="showOrHideProperties(!$(this).hasClass('active'));">Properties</button> + <button class="btn btn-default" id="toggleDeploymentArtifactsVisibility" onclick="showOrHideDeploymentArtifacts(!$(this).hasClass('active'));">Deployment Artifacts</button> + <button class="btn btn-default" id="toggleReqCapsVisibility" onclick="showOrHideReqCaps(!$(this).hasClass('active'));">Requirements & Capabilities</button> + <button class="btn btn-default" id="PoliciesVisibility" onclick="showOrHidePolicies(!$(this).hasClass('active'));">Policies</button> +</div> + |