1 /*******************************************************************************
2 * Copyright (c) 2014 University of Stuttgart.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * and the Apache License 2.0 which both accompany this distribution,
6 * and are available at http://www.eclipse.org/legal/epl-v10.html
7 * and http://www.apache.org/licenses/LICENSE-2.0
10 * Oliver Kopp - initial API and implementation
11 * Tobias Binz - communication with the parent window
12 *******************************************************************************/
15 * Called from the renderer as soon as the whole topology is loaded
17 function wineryViewExternalScriptOnLoad() {
19 function getIdOfNodeTemplateShape(element) {
20 var nodeTemplate = element.closest("div.NodeTemplateShape");
21 var id = nodeTemplate.children("div.headerContainer").children("div.id").text();
25 jsPlumb.bind("ready", function() {
26 jsPlumb.bind("click", function(conn, originalEvent) {
27 var id = winery.connections[conn.id].id;
29 targetRelationshipTemplateRef: id
36 $("div.NodeTemplateShape").on("click", function(e) {
37 var id = getIdOfNodeTemplateShape($(e.target));
38 // send id and empty property as no property has been clicked
48 $("tr.KVProperty").on("click", function(e) {
49 var trKVProperty = $(e.target).closest("tr.KVProperty");
50 var key = trKVProperty.children("td").children("span.KVPropertyKey").text();
52 var content = trKVProperty.closest("div.content");
53 var elementName = content.children("span.elementName").text();
55 // form namespace-unaware XPath
56 var xpath = "/*[local-name()='" + elementName + "']/*[local-name()='" + key + "']";
59 targetPropertyRef: xpath,
60 targetObjectRef: getIdOfNodeTemplateShape(trKVProperty)
64 // do not trigger click on NodeTemplateShape -> we included both values in the message
68 $("div.requirements").on("click", function(e) {
69 var reqorcap = $(e.target).closest("div.requirements");
70 var id = reqorcap.children("div.id").text();
80 $("div.capabilities").on("click", function(e) {
81 var reqorcap = $(e.target).closest("div.capabilities");
82 var id = reqorcap.children("div.id").text();
94 function sendMessage(message) {
95 window.parent.postMessage(message, "*");