summaryrefslogtreecommitdiffstats
path: root/java/sca
diff options
context:
space:
mode:
authorjsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68>2008-08-04 20:26:31 +0000
committerjsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68>2008-08-04 20:26:31 +0000
commitb4384d70fc8c4dc583f0677a94372efa054d6516 (patch)
treeabf21bad428be03baef188d9c79997030450f840 /java/sca
parent9214aad2a30d89a5f7422eda58f074ddc7ba165c (diff)
Isolate widgets from each other, have them work off the HTML div that they're in instead of the parent document.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@682493 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca')
-rw-r--r--java/sca/modules/domain-manager/src/main/resources/cloud-gadget.html104
-rw-r--r--java/sca/modules/domain-manager/src/main/resources/cloud.html6
-rw-r--r--java/sca/modules/domain-manager/src/main/resources/composite-gadget.html57
-rw-r--r--java/sca/modules/domain-manager/src/main/resources/composite.html4
-rw-r--r--java/sca/modules/domain-manager/src/main/resources/toolbar-gadget.html5
-rw-r--r--java/sca/modules/domain-manager/src/main/resources/utils.js20
-rw-r--r--java/sca/modules/domain-manager/src/main/resources/workspace-gadget.html47
-rw-r--r--java/sca/modules/domain-manager/src/main/resources/workspace.html4
8 files changed, 169 insertions, 78 deletions
diff --git a/java/sca/modules/domain-manager/src/main/resources/cloud-gadget.html b/java/sca/modules/domain-manager/src/main/resources/cloud-gadget.html
index 7052a68f40..dc8aa672b8 100644
--- a/java/sca/modules/domain-manager/src/main/resources/cloud-gadget.html
+++ b/java/sca/modules/domain-manager/src/main/resources/cloud-gadget.html
@@ -29,7 +29,7 @@
<body>
<div id="cloudComposite">
- <form name="cloudCompositeForm">
+ <form id="cloudCompositeForm">
<div id="composites" ></div>
<br>
<input type="button" onClick="startNode()" value="Start" />
@@ -40,7 +40,7 @@
<br><br>
- <form name="newNodeForm">
+ <form id="newNodeForm">
<table width="100%">
<tr><th>Add a Node</th></tr>
<tr><td>Add a node to the cloud. The node will run the SCA components declared in the specified composite.</td></tr>
@@ -60,7 +60,6 @@
</body>
<script type="text/javascript">
- var gadget = gadget(window, document);
//@Reference
var cloudComposite = new Reference("cloudComposite");
@@ -71,6 +70,11 @@
//@Reference
var processCollection = new Reference("processCollection");
+ var gadget = gadget(window, document);
+
+ var newNodeForm = elementByID(gadget, 'newNodeForm');
+ var compositesElement = elementByID(gadget, 'composites');
+
function getNodes() {
cloudComposite.get("", getNodesResponse);
}
@@ -99,8 +103,20 @@
var entries = feed.getElementsByTagName("entry");
var composites = "";
composites += '<table width="100%">';
- composites += '<tr><th>Node</th><th>Status</th><th>Composite</th>' +
- '<th>Contribution</th><th>Node Config</th></tr>';
+ composites += '<tr><th>Node</th>';
+ if (gadget.showStatus) {
+ composites += '<th>Status</th>';
+ }
+ if (gadget.showComposites) {
+ composites += '<th>Composite</th>';
+ }
+ if (gadget.showContributions) {
+ composites += '<th>Contribution</th>';
+ }
+ if (gadget.showConfigurations) {
+ composites += '<th>Node Config</th>';
+ }
+ composites += '</tr>';
for (var i=0; i<entries.length; i++) {
var nodeId = entries[i].getElementsByTagName("id")[0].firstChild.nodeValue;
@@ -135,21 +151,35 @@
if (content.indexOf('<span id="problem"') != -1) {
composites += '<td><input name="composites" type="checkbox" value="' + nodeId + '">' +
'<a href=\"' + nodeLink + '\">' + nodeName + '</a></td>';
- composites += '<td><span id="status_' + nodeName + '">unknown</span></td>';
- composites += '<td>' + content + '</td>';
- composites += '<td>' + uri + '</td>';
+ if (gadget.showStatus) {
+ composites += '<td><span id="status_' + nodeName + '">unknown</span></td>';
+ }
+ if (gadget.showComposites) {
+ composites += '<td>' + content + '</td>';
+ }
+ if (gadget.showContributions) {
+ composites += '<td>' + uri + '</td>';
+ }
} else {
composites += '<td><input name="composites" type="checkbox" value="' + nodeId + '">' +
'<a href=\"' + nodeLink + '\">' + nodeName + '</a></td>';
- composites += '<td><span id="status_' + nodeName + '">unknown</span></td>';
- composites += '<td><a href=\"' + compositeLink + '\">' + qname + '</a></td>';
- composites += '<td><a href="/contribution/' + uri + '">' + uri + '</a></td>';
+ if (gadget.showStatus) {
+ composites += '<td><span id="status_' + nodeName + '">unknown</span></td>';
+ }
+ if (gadget.showComposites) {
+ composites += '<td><a href=\"' + compositeLink + '\">' + qname + '</a></td>';
+ }
+ if (gadget.showContributions) {
+ composites += '<td><a href="/contribution/' + uri + '">' + uri + '</a></td>';
+ }
+ }
+ if (gadget.showConfigurations) {
+ composites += '<td><a href="/node-config/' + nodeName + '"><img src="icons/feed-icon.png" border="0"></a></td>';
}
- composites += '<td><a href="/node-config/' + nodeName + '"><img src="icons/feed-icon.png" border="0"></a></td>';
composites += '</tr>';
}
composites += '</table>';
- gadget.getElementById("composites").innerHTML = composites;
+ compositesElement.innerHTML = composites;
processCollection.get("", getProcessesResponse);
}
@@ -165,13 +195,15 @@
nodeStatus[nodeName] = 'started';
}
- for (var i = 0; i < nodeNames.length; i++) {
- var element = gadget.getElementById('status_' + nodeNames[i]);
- var nodeName = nodeNames[i];
- if (nodeStatus[nodeName] == null) {
- element.innerHTML = '<span>stopped</span>';
- } else {
- element.innerHTML = '<span><a style="color: green" href="/processes/?node=' + nodeName + '">started</a></span>';
+ if (gadget.showStatus) {
+ for (var i = 0; i < nodeNames.length; i++) {
+ var element = elementByID(gadget, 'status_' + nodeNames[i]);
+ var nodeName = nodeNames[i];
+ if (nodeStatus[nodeName] == null) {
+ element.innerHTML = '<span>stopped</span>';
+ } else {
+ element.innerHTML = '<span><a style="color: green" href="/processes/?node=' + nodeName + '">started</a></span>';
+ }
}
}
}
@@ -192,11 +224,11 @@
}
function addNode() {
- var nodeName = gadget.newNodeForm.nodeName.value;
- var nodeURI = gadget.newNodeForm.nodeURI.value;
- var compositeNamespace = gadget.newNodeForm.compositeNamespace.value;
- var compositeName = gadget.newNodeForm.compositeName.value;
- var contributionURI = gadget.newNodeForm.contributionURI.value;
+ var nodeName = newNodeForm.nodeName.value;
+ var nodeURI = newNodeForm.nodeURI.value;
+ var compositeNamespace = newNodeForm.compositeNamespace.value;
+ var compositeName = newNodeForm.compositeName.value;
+ var contributionURI = newNodeForm.contributionURI.value;
var id = 'composite:' +
'http://tuscany.apache.org/cloud' + ';' +
'http://tuscany.apache.org/cloud' + ';' +
@@ -227,11 +259,11 @@
}
function addNodeResponse() {
- gadget.newNodeForm.nodeName.value = "";
- gadget.newNodeForm.nodeURI.value = "";
- gadget.newNodeForm.compositeNamespace.value = "";
- gadget.newNodeForm.compositeName.value = "";
- gadget.newNodeForm.contributionURI.value = "";
+ newNodeForm.nodeName.value = "";
+ newNodeForm.nodeURI.value = "";
+ newNodeForm.compositeNamespace.value = "";
+ newNodeForm.compositeName.value = "";
+ newNodeForm.contributionURI.value = "";
getNodes();
}
@@ -308,7 +340,7 @@
}
function suggestCompositeNames() {
- var inputns = gadget.newNodeForm.compositeNamespace.value;
+ var inputns = newNodeForm.compositeNamespace.value;
var names = new Array();
for (var uri in deployedComposites) {
var qname = compositeName(uri);
@@ -323,8 +355,8 @@
}
function suggestContributionURIs() {
- var inputns = gadget.newNodeForm.compositeNamespace.value;
- var inputname = gadget.newNodeForm.compositeName.value;
+ var inputns = newNodeForm.compositeNamespace.value;
+ var inputname = newNodeForm.compositeName.value;
var uris = new Array();
for (var uri in deployedComposites) {
var qname = compositeName(uri);
@@ -341,9 +373,9 @@
getNodes();
getComposites();
- suggest(gadget.newNodeForm.compositeNamespace, suggestCompositeNamespaces);
- suggest(gadget.newNodeForm.compositeName, suggestCompositeNames);
- suggest(gadget.newNodeForm.contributionURI, suggestContributionURIs);
+ suggest(newNodeForm.compositeNamespace, suggestCompositeNamespaces);
+ suggest(newNodeForm.compositeName, suggestCompositeNames);
+ suggest(newNodeForm.contributionURI, suggestContributionURIs);
</script>
</html>
diff --git a/java/sca/modules/domain-manager/src/main/resources/cloud.html b/java/sca/modules/domain-manager/src/main/resources/cloud.html
index 08a24cad26..2a64f91f54 100644
--- a/java/sca/modules/domain-manager/src/main/resources/cloud.html
+++ b/java/sca/modules/domain-manager/src/main/resources/cloud.html
@@ -47,8 +47,14 @@
function ongadget(win, doc) {
if (doc == content(toolbarGadget)) {
toolbarGadgetDiv.innerHTML = doc.body.innerHTML;
+ return toolbarGadgetDiv;
} else if (doc == content(cloudGadget)) {
cloudGadgetDiv.innerHTML = doc.body.innerHTML;
+ cloudGadgetDiv.showStatus = true;
+ cloudGadgetDiv.showComposites = true;
+ cloudGadgetDiv.showContributions = true;
+ cloudGadgetDiv.showConfigurations = true;
+ return cloudGadgetDiv;
}
return document;
}
diff --git a/java/sca/modules/domain-manager/src/main/resources/composite-gadget.html b/java/sca/modules/domain-manager/src/main/resources/composite-gadget.html
index 062af53667..1cfbd70333 100644
--- a/java/sca/modules/domain-manager/src/main/resources/composite-gadget.html
+++ b/java/sca/modules/domain-manager/src/main/resources/composite-gadget.html
@@ -29,7 +29,7 @@
<body>
<div id="domainComposite">
- <form name="domainCompositeForm">
+ <form id="domainCompositeForm">
<div id="composites" ></div>
<br>
<input type="button" onClick="deleteComposite()" value="Delete" />
@@ -37,7 +37,7 @@
<br><br>
- <form name="newCompositeForm">
+ <form id="newCompositeForm">
<table width="100%">
<tr><th>Add Composite</th></tr>
<tr><td>Add an SCA composite describing your SCA service components.</td></tr>
@@ -55,14 +55,17 @@
</body>
<script type="text/javascript">
- var gadget = gadget(window, document);
-
//@Reference
var domainComposite = new Reference("domainComposite");
//@Reference
var workspace = new Reference("workspace");
+ var gadget = gadget(window, document);
+
+ var newCompositeForm = elementByID(gadget, 'newCompositeForm');
+ var compositesElement = elementByID(gadget, 'composites');
+
function getComposites() {
domainComposite.get("", getCompositesResponse);
}
@@ -82,10 +85,14 @@
var entries = feed.getElementsByTagName("entry");
var composites = "";
composites += '<table width="100%">';
- composites += '<tr><th>Composite</th>' +
- '<th>Contribution</th>' +
- '<th>Components</th>' +
- '</tr>';
+ composites += '<tr><th>Composite</th>';
+ if (gadget.showContributions) {
+ composites += '<th>Contribution</th>';
+ }
+ if (gadget.showComponents) {
+ composites += '<th>Components</th>';
+ }
+ composites += '</tr>';
//'<th>Composite Configuration</th>' +
for (var i=0; i<entries.length; i++) {
@@ -114,13 +121,17 @@
composites += '<tr>'
composites += '<td><input name="composites" type="checkbox" value="' + id + '">';
composites += '<a href=\"' + link + '\">' + qname + '</a></td>';
- composites += '<td><a href="/contribution/' + uri + '">' + uri + '</a></td>';
- composites += '<td class=tdw>' + components + '</td>';
+ if (gadget.showContributions) {
+ composites += '<td><a href="/contribution/' + uri + '">' + uri + '</a></td>';
+ }
+ if (gadget.showComponents) {
+ composites += '<td class=tdw>' + components + '</td>';
+ }
//composites += '<td><a href="/composite-config/?composite=' + id + '"><img src="icons/feed-icon.png" border="0"></a></td>';
composites += '</tr>';
}
composites += '</table>';
- gadget.getElementById("composites").innerHTML = composites;
+ compositesElement.innerHTML = composites;
}
}
@@ -140,9 +151,9 @@
function addComposite() {
var id = 'composite:' +
- gadget.newCompositeForm.contributionURI.value + ';' +
- gadget.newCompositeForm.compositeNamespace.value + ';' +
- gadget.newCompositeForm.compositeName.value;
+ newCompositeForm.contributionURI.value + ';' +
+ newCompositeForm.compositeNamespace.value + ';' +
+ newCompositeForm.compositeName.value;
var entry = '<entry xmlns="http://www.w3.org/2005/Atom">' +
'<title>' + id +'</title>' +
'<id>' + id + '</id>' +
@@ -151,9 +162,9 @@
}
function addCompositeResponse() {
- gadget.newCompositeForm.compositeNamespace.value = "";
- gadget.newCompositeForm.compositeName.value = "";
- gadget.newCompositeForm.contributionURI.value = "";
+ newCompositeForm.compositeNamespace.value = "";
+ newCompositeForm.compositeName.value = "";
+ newCompositeForm.contributionURI.value = "";
getComposites();
}
@@ -204,7 +215,7 @@
}
function suggestCompositeNames() {
- var inputns = gadget.newCompositeForm.compositeNamespace.value;
+ var inputns = newCompositeForm.compositeNamespace.value;
var names = new Array();
for (var uri in contributedComposites) {
var qname = compositeName(uri);
@@ -219,8 +230,8 @@
}
function suggestContributionURIs() {
- var inputns = gadget.newCompositeForm.compositeNamespace.value;
- var inputname = gadget.newCompositeForm.compositeName.value;
+ var inputns = newCompositeForm.compositeNamespace.value;
+ var inputname = newCompositeForm.compositeName.value;
var uris = new Array();
for (var uri in contributedComposites) {
var qname = compositeName(uri);
@@ -237,9 +248,9 @@
getComposites();
getContributions();
- suggest(gadget.newCompositeForm.compositeNamespace, suggestCompositeNamespaces);
- suggest(gadget.newCompositeForm.compositeName, suggestCompositeNames);
- suggest(gadget.newCompositeForm.contributionURI, suggestContributionURIs);
+ suggest(newCompositeForm.compositeNamespace, suggestCompositeNamespaces);
+ suggest(newCompositeForm.compositeName, suggestCompositeNames);
+ suggest(newCompositeForm.contributionURI, suggestContributionURIs);
</script>
</html>
diff --git a/java/sca/modules/domain-manager/src/main/resources/composite.html b/java/sca/modules/domain-manager/src/main/resources/composite.html
index 33f4535499..f7fcec868f 100644
--- a/java/sca/modules/domain-manager/src/main/resources/composite.html
+++ b/java/sca/modules/domain-manager/src/main/resources/composite.html
@@ -47,8 +47,12 @@
function ongadget(win, doc) {
if (doc == content(toolbarGadget)) {
toolbarGadgetDiv.innerHTML = doc.body.innerHTML;
+ return toolbarGadgetDiv;
} else if (doc == content(compositeGadget)) {
compositeGadgetDiv.innerHTML = doc.body.innerHTML;
+ compositeGadgetDiv.showContributions = true;
+ compositeGadgetDiv.showComponents = true;
+ return compositeGadgetDiv;
}
return document;
}
diff --git a/java/sca/modules/domain-manager/src/main/resources/toolbar-gadget.html b/java/sca/modules/domain-manager/src/main/resources/toolbar-gadget.html
index 2cc555473c..c9389affc3 100644
--- a/java/sca/modules/domain-manager/src/main/resources/toolbar-gadget.html
+++ b/java/sca/modules/domain-manager/src/main/resources/toolbar-gadget.html
@@ -39,8 +39,9 @@
tools[3] = new Tool("Files", "../files");
var home = new Tool("Home", "../home");
-
- gadget.getElementById('toolbar').innerHTML = toolbar(home, tools);
+
+ var toolbarDiv = elementByID(gadget, 'toolbar');
+ toolbarDiv.innerHTML = toolbar(home, tools);
</script>
</html>
diff --git a/java/sca/modules/domain-manager/src/main/resources/utils.js b/java/sca/modules/domain-manager/src/main/resources/utils.js
index 20f0148954..77ed807e85 100644
--- a/java/sca/modules/domain-manager/src/main/resources/utils.js
+++ b/java/sca/modules/domain-manager/src/main/resources/utils.js
@@ -210,7 +210,25 @@ function content(win) {
}
/**
- * Install a gadget
+ * Returns a child element with the given id.
+ */
+function elementByID(node, id) {
+ for (var i in node.childNodes) {
+ var child = node.childNodes[i];
+ if (child.id == id) {
+ return child;
+ } else {
+ child = elementByID(child, id);
+ if (child != null) {
+ return child;
+ }
+ }
+ }
+ return null;
+}
+
+/**
+ * Install a gadget.
*/
function gadget(win, doc) {
var ongadget = null;
diff --git a/java/sca/modules/domain-manager/src/main/resources/workspace-gadget.html b/java/sca/modules/domain-manager/src/main/resources/workspace-gadget.html
index 9e4c6c014d..a86ef512f7 100644
--- a/java/sca/modules/domain-manager/src/main/resources/workspace-gadget.html
+++ b/java/sca/modules/domain-manager/src/main/resources/workspace-gadget.html
@@ -29,7 +29,7 @@
<body>
<div id="workspace">
- <form name="workspaceForm">
+ <form id="workspaceForm">
<div id="contributions" ></div>
<br>
<input type="button" onClick="deleteContribution()" value="Delete" />
@@ -37,7 +37,7 @@
<br><br>
- <form name="newContributionForm">
+ <form id="newContributionForm">
<table width="100%">
<tr><th>Add Contribution</th></tr>
<tr><td>Add an SCA contribution containing your application artifacts to the SCA domain.</td></tr>
@@ -54,11 +54,15 @@
</body>
<script type="text/javascript">
- var gadget = gadget(window, document);
-
+
//@Reference
var workspace = new Reference("workspace");
+ var gadget = gadget(window, document);
+
+ var newContributionForm = elementByID(gadget, 'newContributionForm');
+ var contributionsElement = elementByID(gadget, 'contributions');
+
function getContributions() {
workspace.get("", getContributionsResponse);
}
@@ -68,7 +72,14 @@
var entries = feed.getElementsByTagName("entry");
var contributions = "";
contributions += '<table width="100%">';
- contributions += '<tr><th>Contribution</th><th>Dependencies</td><th>Deployable Composites</th></tr>';
+ contributions += '<tr><th>Contribution</th>';
+ if (gadget.showDependencies) {
+ contributions += '<th>Dependencies</td>';
+ }
+ if (gadget.showDeployables) {
+ contributions += '<th>Deployable Composites</th>';
+ }
+ contributions += '</tr>';
for (var i=0; i<entries.length; i++) {
var id = entries[i].getElementsByTagName("id")[0].firstChild.nodeValue;
var location = entries[i].getElementsByTagName("link")[0].getAttribute("href");
@@ -104,13 +115,17 @@
}
problems += content.substring(bs, es + 7);
}
-
- contributions += '<td class=tdw>' + dependencies + problems + ' </td>';
- contributions += '<td class=tdw>' + deployables + '</td>';
+
+ if (gadget.showDependencies) {
+ contributions += '<td class=tdw>' + dependencies + problems + ' </td>';
+ }
+ if (gadget.showDeployables) {
+ contributions += '<td class=tdw>' + deployables + '</td>';
+ }
contributions += '</tr>';
}
contributions += '</table>';
- gadget.getElementById('contributions').innerHTML = contributions;
+ contributionsElement.innerHTML = contributions;
}
}
@@ -147,8 +162,8 @@
}
function addContribution() {
- var id = gadget.newContributionForm.contributionID.value;
- var location = gadget.newContributionForm.contributionLocation.value;
+ var id = newContributionForm.contributionID.value;
+ var location = newContributionForm.contributionLocation.value;
var entry = '<entry xmlns="http://www.w3.org/2005/Atom">' +
'<title>Contribution - ' + id +'</title>' +
'<id>' + id + '</id>' +
@@ -158,8 +173,8 @@
}
function addContributionResponse() {
- gadget.newContributionForm.contributionID.value = "";
- gadget.newContributionForm.contributionLocation.value = "";
+ newContributionForm.contributionID.value = "";
+ newContributionForm.contributionLocation.value = "";
getContributions();
}
@@ -178,7 +193,7 @@
for (var i=0; i<suggestedContributions.length; i++) {
var uri = suggestedContributions[i];
var id = uri.substring(0, uri.indexOf(':'));
- if (id == gadget.newContributionForm.contributionID.value) {
+ if (id == newContributionForm.contributionID.value) {
var location = uri.substring(uri.indexOf(':') +1);
locations[location] = location;
}
@@ -188,8 +203,8 @@
getContributions();
getSuggestedContributions();
- suggest(gadget.newContributionForm.contributionID, suggestContributionIDs);
- suggest(gadget.newContributionForm.contributionLocation, suggestContributionLocations);
+ suggest(newContributionForm.contributionID, suggestContributionIDs);
+ suggest(newContributionForm.contributionLocation, suggestContributionLocations);
</script>
</html>
diff --git a/java/sca/modules/domain-manager/src/main/resources/workspace.html b/java/sca/modules/domain-manager/src/main/resources/workspace.html
index f3114b3a14..9d40a2ecc6 100644
--- a/java/sca/modules/domain-manager/src/main/resources/workspace.html
+++ b/java/sca/modules/domain-manager/src/main/resources/workspace.html
@@ -46,8 +46,12 @@
function ongadget(win, doc) {
if (doc == content(toolbarGadget)) {
toolbarGadgetDiv.innerHTML = doc.body.innerHTML;
+ return toolbarGadgetDiv;
} else if (doc == content(workspaceGadget)) {
workspaceGadgetDiv.innerHTML = doc.body.innerHTML;
+ workspaceGadgetDiv.showDependencies = true;
+ workspaceGadgetDiv.showDeployables = true;
+ return workspaceGadgetDiv;
}
return document;
}