summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/tags/2.0.1-RC1/modules/node-manager/src/test/resources/ui/index.html
blob: 4405422c537d5fcbd0e70b8f06025db1864875f0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
<!--
    * Licensed to the Apache Software Foundation (ASF) under one
    * or more contributor license agreements.  See the NOTICE file
    * distributed with this work for additional information
    * regarding copyright ownership.  The ASF licenses this file
    * to you under the Apache License, Version 2.0 (the
    * "License"); you may not use this file except in compliance
    * with the License.  You may obtain a copy of the License at
    * 
    *   http://www.apache.org/licenses/LICENSE-2.0
    * 
    * Unless required by applicable law or agreed to in writing,
    * software distributed under the License is distributed on an
    * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    * KIND, either express or implied.  See the License for the
    * specific language governing permissions and limitations
    * under the License.    
-->
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Tuscany SCA Domain Components</title>

<script type="text/javascript" src="/dojo/dojo.js"></script>

<style type="text/css">
body,html {
	font-family: helvetica, arial, sans-serif;
	font-size: 90%;
}

.componentIcon {
	margin-left: 16px;
	width: 16px;
	height: 16px;
	background: url('component.gif') no-repeat;
}

.serviceIcon {
	margin-left: 16px;
	width: 16px;
	height: 16px;
	background: url('service.gif') no-repeat;
}

.referenceIcon {
	margin-left: 16px;
	width: 16px;
	height: 16px;
	background: url('reference.gif') no-repeat;
}
</style>

</head>

<body>
	<div id="header" style="border-bottom: solid 1px silver; overflow: hidden;">
		<img src="http://tuscany.apache.org/images/TuscanyLogo.jpg" style="float:right;"/>
		<h1>Tuscany SCA Domain</h1>
	</div> <!-- end header div -->

    <div id="container" style="border:1px solid silver">
		<div id="navigation" style="position:absolute; float:left; width:30%; height:80%; padding:10px; border:1px solid silver">
			<div id="treeDomain" /> </div>
		</div> <!-- end navigation div -->
			
		<div id="images" style="position:absolute; float:left; width:60%; height:80%; left:35%; padding:10px; border:1px solid silver">

			<table style="margin-left:auto; margin-right:auto;" border="0" cellspacing="0" cellpadding="1">
			   <tr>
			      <td><a href="javascript:updatePage(-1)">prev</a></td>
				  <td><a href="javascript:updatePage(1)">next</a></td>
			   </tr>
			   <tr>
			      <td colspan="4">
					  <table id="tableImageThumb" style="margin-left:auto; margin-right:auto;" border="0" cellspacing="0" cellpadding="1"></table>
				  
			      </td>
			   </tr>
			</table>
		</div> <!-- end images div -->
			
	</div> <!-- end container div -->
		
</body>

<script type="text/javascript">
    dojo.require("dojo.data.ItemFileWriteStore");
    dojo.require("dijit.Tree");
    dojo.require("dojox.xml.parser");
    dojo.require("tuscany.RestService");
    //dojo.require("tuscany.Composite");

    var restClient;
    
	var store;
	var treeModel;
	var treeControl;

    var composite;


	function prepare() {
        store = new dojo.data.ItemFileWriteStore({
            data: {
                identifier: 'id',
                label: 'label',
                type: 'type',
                items: [ ]
            }
        });
        treeModel = new dijit.tree.ForestStoreModel({
            store: store
        });
        
        treeControl = new dijit.Tree({
            model: treeModel,
            showRoot: false,
            getIconClass: function(/*dojo.data.Item*/ item, /*Boolean*/ opened) {
            	console.log("##" + item.type);
            	if(item.type != undefined) {
            		if(item.type == 'component') {
            			return "componentIcon";
            		} else if(item.type == 'service' || item.type == 'service-binding') {
            			return "serviceIcon";
            		} else if(item.type == 'reference' || item.type == 'reference-binding') {
            			return "referenceIcon";
            		} 
            	}
            	return "serviceIcon";
            },
			onClick: showArtifactDocumentation,
            _createTreeNode: function(/*Object*/ args) {
                var tnode = new dijit._TreeNode(args);
                tnode.labelNode.innerHTML = args.label;
                return tnode;
            }
        },"treeDomain");

        restClient = new tuscany.RestService("/domain","text/plain");
        
		showDomainArtifacts();			
    }

    
    function composite_getResponse(xmlResponse, exception) {
    	if(exception){
			alert(exception.message);
			return;
		}
    	
    	var componentNode = xmlResponse.getElementsByTagName ("component");
    	//loop trough all components
        for (c = 0; c < componentNode.length; c++) {
        	var componentAttributes = componentNode[c].attributes;
       	 	var componentItem = store.newItem({id:componentAttributes['uri'].value, label:componentAttributes['name'].value, type:'component'});
       	 	
       	 	//loop trough all services
       	    var serviceNode = componentNode[c].getElementsByTagName ("service");
       	 	for(s = 0; s < serviceNode.length; s++) {
            	var serviceAttributes = serviceNode[s].attributes;
            	var serviceId = componentAttributes['uri'].value + "/" + serviceAttributes['name'].value;
            	
            	var parentInfo={
    					parent: componentItem,
    					attribute: "children"
    				};
            	
           	 	var serviceItem = store.newItem({id:serviceId, label:serviceAttributes['name'].value, type:'service'}, parentInfo);
           	 	
           	 	//loop trough children to find bindings
           	 	for(b=0; b < serviceNode[s].childNodes.length; b ++) {
           	 		var childNode = serviceNode[s].childNodes[b];
           	 		if(childNode.nodeName.indexOf('binding') == 0) {
           	 			var bindingId = serviceId + "/" + childNode.nodeName;
           	 			
           	 			var parentInfo={
    						parent: serviceItem,
    						attribute: "children"
    					};
           	 			
           	 			var bindingItem = store.newItem({id:bindingId, label:childNode.nodeName, type:'service-binding'}, parentInfo);
           	 		}
    	 		}
       	 	}

       	 	
       	 	//loop trough all references
       	    var referenceNode = componentNode[c].getElementsByTagName ("reference");
       	 	for(r = 0; r < referenceNode.length; r++) {
            	var referenceAttributes = referenceNode[r].attributes;
            	var referenceId = componentAttributes['uri'].value + "/" + referenceAttributes['name'].value;
            	
            	var parentInfo={
    					parent: componentItem,
    					attribute: "children"
    				};
            	
           	 	var referenceItem = store.newItem({id:serviceId, label:referenceAttributes['name'].value, type:'reference'}, parentInfo);
           	 	
           	 	//loop trough children to find bindings
           	 	for(b=0; b < referenceNode[s].childNodes.length; b ++) {
           	 		var childNode = referenceNode[s].childNodes[b];
           	 		if(childNode.nodeName.indexOf('binding') == 0) {
           	 			var bindingId = serviceId + "/" + childNode.nodeName;
           	 			
           	 			var parentInfo={
    						parent: serviceItem,
    						attribute: "children"
    					};
           	 			
           	 			var bindingItem = store.newItem({id:bindingId, label:childNode.nodeName, type:'reference-binding'}, parentInfo);
           	 		}
    	 		}

       	 		
       	 	}
       	 	
        }
    	
    	//var composite = new tuscany.Composite(xmlResponse);
    	

    	/*
    	 var itemTags = xmlResponse.getElementsByTagName ("component");
         for (i = 0; i < itemTags.length; i++) {
        	 var attributes = itemTags[i].attributes;
        	 alert(attributes[0].name);
             var recordNode = itemTags[i].getElementsByTagName ("name")[0];
             if (recordNode.textContent != undefined) {
                 alert(recordNode.textContent);
             }
             else {
                 alert(recordNode.text);
             }
         }
         */

         compositeXML = dojox.xml.parser.innerXML(xmlResponse);


    	//alert(compositeXML);

    }

    function showDomainArtifacts() {
    	restClient.get("default").addCallback(composite_getResponse);
    }
    
    function showArtifactDocumentation(/*dojo.data.Item*/ item) {
    	alert('showing documentation for' + item.id);
    }
    
    function guidGenerator() {
        var S4 = function() {
           return (((1+Math.random())*0x10000)|0).toString(16).substring(1);
        };
        return (S4()+S4()+"-"+S4()+"-"+S4()+"-"+S4()+"-"+S4()+S4()+S4());
    }

    
    dojo.addOnLoad(prepare);
</script>

</body>

</html>