Author: slaws
Date: Fri May 13 13:57:16 2011
New Revision: 1102740

URL: http://svn.apache.org/viewvc?rev=1102740&view=rev
Log:
change to follow the pattern Luciano has in node-manager. Also take a copy of 
the html page from there to see what that's doing. 

Added:
    
tuscany/sandbox/slaws/domain-view/src/main/java/org/apache/tuscany/sca/domain/Composite.java
    
tuscany/sandbox/slaws/domain-view/src/main/java/org/apache/tuscany/sca/domain/CompositeImpl.java
    
tuscany/sandbox/slaws/domain-view/src/main/java/org/apache/tuscany/sca/domain/Domain.java
    
tuscany/sandbox/slaws/domain-view/src/main/java/org/apache/tuscany/sca/domain/DomainImpl.java
    
tuscany/sandbox/slaws/domain-view/src/main/java/org/apache/tuscany/sca/domain/DomainView.java
    
tuscany/sandbox/slaws/domain-view/src/main/java/org/apache/tuscany/sca/domain/Tuscany.java
    tuscany/sandbox/slaws/domain-view/src/main/resources/ui/
    tuscany/sandbox/slaws/domain-view/src/main/resources/ui/component.gif   
(with props)
    tuscany/sandbox/slaws/domain-view/src/main/resources/ui/composite.gif   
(with props)
    tuscany/sandbox/slaws/domain-view/src/main/resources/ui/index.html
    tuscany/sandbox/slaws/domain-view/src/main/resources/ui/interface.gif   
(with props)
    tuscany/sandbox/slaws/domain-view/src/main/resources/ui/property.gif   
(with props)
    tuscany/sandbox/slaws/domain-view/src/main/resources/ui/reference.gif   
(with props)
    tuscany/sandbox/slaws/domain-view/src/main/resources/ui/service.gif   (with 
props)
Removed:
    tuscany/sandbox/slaws/domain-view/src/main/java/org/apache/tuscany/sca/impl/
Modified:
    tuscany/sandbox/slaws/domain-view/pom.xml
    tuscany/sandbox/slaws/domain-view/src/main/resources/domain.composite

Modified: tuscany/sandbox/slaws/domain-view/pom.xml
URL: 
http://svn.apache.org/viewvc/tuscany/sandbox/slaws/domain-view/pom.xml?rev=1102740&r1=1102739&r2=1102740&view=diff
==============================================================================
--- tuscany/sandbox/slaws/domain-view/pom.xml (original)
+++ tuscany/sandbox/slaws/domain-view/pom.xml Fri May 13 13:57:16 2011
@@ -42,6 +42,11 @@
         </dependency>
         <dependency>
             <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-implementation-widget-runtime-dojo</artifactId>
+            <version>2.0-SNAPSHOT</version>
+        </dependency>        
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
             <artifactId>tuscany-binding-sca-runtime</artifactId>
             <version>2.0-SNAPSHOT</version>
         </dependency>       

Added: 
tuscany/sandbox/slaws/domain-view/src/main/java/org/apache/tuscany/sca/domain/Composite.java
URL: 
http://svn.apache.org/viewvc/tuscany/sandbox/slaws/domain-view/src/main/java/org/apache/tuscany/sca/domain/Composite.java?rev=1102740&view=auto
==============================================================================
--- 
tuscany/sandbox/slaws/domain-view/src/main/java/org/apache/tuscany/sca/domain/Composite.java
 (added)
+++ 
tuscany/sandbox/slaws/domain-view/src/main/java/org/apache/tuscany/sca/domain/Composite.java
 Fri May 13 13:57:16 2011
@@ -0,0 +1,47 @@
+/*
+ * 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.    
+ */
+
+package org.apache.tuscany.sca.domain;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface Composite {
+    
+    @GET
+    @Produces( {MediaType.TEXT_HTML})
+    @Path("{domainname}/composite")
+    public String get();
+    
+
+    @GET
+    @Produces( {MediaType.APPLICATION_ATOM_XML, 
+                MediaType.APPLICATION_JSON,
+                MediaType.APPLICATION_XML, 
+                MediaType.TEXT_HTML})
+    @Path("{domainname}/composite/{compositename}")                
+    public String getComposite(@PathParam("compositename") String domainName);
+    
+}
\ No newline at end of file

Added: 
tuscany/sandbox/slaws/domain-view/src/main/java/org/apache/tuscany/sca/domain/CompositeImpl.java
URL: 
http://svn.apache.org/viewvc/tuscany/sandbox/slaws/domain-view/src/main/java/org/apache/tuscany/sca/domain/CompositeImpl.java?rev=1102740&view=auto
==============================================================================
--- 
tuscany/sandbox/slaws/domain-view/src/main/java/org/apache/tuscany/sca/domain/CompositeImpl.java
 (added)
+++ 
tuscany/sandbox/slaws/domain-view/src/main/java/org/apache/tuscany/sca/domain/CompositeImpl.java
 Fri May 13 13:57:16 2011
@@ -0,0 +1,40 @@
+/*
+ * 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.    
+ */
+
+package org.apache.tuscany.sca.domain;
+
+/**
+ * Some hand crafted HTTP code to help me think about what info is missing
+ * from the domain registry
+ *  
+ */
+public class CompositeImpl implements Composite {
+    
+    public String get() {
+        String outputHTML = "<p/>get";
+        return outputHTML;
+    }    
+    
+   
+    public String getComposite(String domainName) {
+        String outputHTML = "<p/>get composite";
+        return outputHTML;
+    } 
+    
+}
\ No newline at end of file

Added: 
tuscany/sandbox/slaws/domain-view/src/main/java/org/apache/tuscany/sca/domain/Domain.java
URL: 
http://svn.apache.org/viewvc/tuscany/sandbox/slaws/domain-view/src/main/java/org/apache/tuscany/sca/domain/Domain.java?rev=1102740&view=auto
==============================================================================
--- 
tuscany/sandbox/slaws/domain-view/src/main/java/org/apache/tuscany/sca/domain/Domain.java
 (added)
+++ 
tuscany/sandbox/slaws/domain-view/src/main/java/org/apache/tuscany/sca/domain/Domain.java
 Fri May 13 13:57:16 2011
@@ -0,0 +1,85 @@
+/*
+ * 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.    
+ */
+
+package org.apache.tuscany.sca.domain;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface Domain {
+    
+    @GET
+    @Produces( {MediaType.TEXT_HTML})
+    public String get();
+    
+    @Path("{domainname}")
+    @GET
+    @Produces( {MediaType.APPLICATION_ATOM_XML, 
+                MediaType.APPLICATION_JSON,
+                MediaType.APPLICATION_XML, 
+                MediaType.TEXT_HTML})
+    public String getDomainServiceDocument(@PathParam("domainname") String 
domainName);
+    
+    @Path("{domainname}/contribution")
+    @GET
+    @Produces( {MediaType.APPLICATION_ATOM_XML, 
+                MediaType.APPLICATION_JSON,
+                MediaType.APPLICATION_XML, 
+                MediaType.TEXT_HTML})
+    public String getContributions(@PathParam("domainname") String domainName);
+    
+    @Path("{domainname}/composite")
+    @GET
+    @Produces( {MediaType.APPLICATION_ATOM_XML, 
+                MediaType.APPLICATION_JSON,
+                MediaType.APPLICATION_XML, 
+                MediaType.TEXT_HTML})
+    public String getComposites(@PathParam("domainname") String domainName);   
 
+    
+    @Path("{domainname}/component")
+    @GET
+    @Produces( {MediaType.APPLICATION_ATOM_XML, 
+                MediaType.APPLICATION_JSON,
+                MediaType.APPLICATION_XML, 
+                MediaType.TEXT_HTML})
+    public String getComponents(@PathParam("domainname") String domainName);
+    
+    @Path("{domainname}/endpoints")
+    @GET
+    @Produces( {MediaType.APPLICATION_ATOM_XML, 
+                MediaType.APPLICATION_JSON,
+                MediaType.APPLICATION_XML, 
+                MediaType.TEXT_HTML})
+    public String getEndpoints(@PathParam("domainname") String domainName);    
+    
+    @Path("{domainname}/node")
+    @GET
+    @Produces( {MediaType.APPLICATION_ATOM_XML, 
+                MediaType.APPLICATION_JSON,
+                MediaType.APPLICATION_XML, 
+                MediaType.TEXT_HTML})
+    public String getNodes(@PathParam("domainname") String domainName);    
+    
+}
\ No newline at end of file

Added: 
tuscany/sandbox/slaws/domain-view/src/main/java/org/apache/tuscany/sca/domain/DomainImpl.java
URL: 
http://svn.apache.org/viewvc/tuscany/sandbox/slaws/domain-view/src/main/java/org/apache/tuscany/sca/domain/DomainImpl.java?rev=1102740&view=auto
==============================================================================
--- 
tuscany/sandbox/slaws/domain-view/src/main/java/org/apache/tuscany/sca/domain/DomainImpl.java
 (added)
+++ 
tuscany/sandbox/slaws/domain-view/src/main/java/org/apache/tuscany/sca/domain/DomainImpl.java
 Fri May 13 13:57:16 2011
@@ -0,0 +1,90 @@
+/*
+ * 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.    
+ */
+
+package org.apache.tuscany.sca.domain;
+
+import java.io.File;
+import java.util.List;
+
+import org.apache.tuscany.sca.impl.NodeImpl;
+
+
+/**
+ * Some hand crafted HTTP code to help me think about what info is missing
+ * from the domain registry
+ *  
+ */
+public class DomainImpl implements Domain {
+    
+    public String get() {
+        String outputHTML = "<p/>enter URL in the form 
http://host:port/sca/domain/yourdomainnamehere";;
+        return outputHTML;
+    }    
+    
+    public String getDomainServiceDocument(String domainName) {
+        String outputHTML = "<p/><a href=\"" + domainName + 
"/contribution\">contributions</a>" + 
+                            "<p/><a href=\"" + domainName + 
"/composite\">composites</a>" + 
+                            "<p/><a href=\"" + domainName + 
"/endpoint\">endpoints</a>" +
+                            "<p/><a href=\"" + domainName + 
"/node\">nodes</a>";
+        return outputHTML;
+    } 
+    
+    public String getContributions(String domainName) {
+        NodeImpl node = (NodeImpl)DomainView.domainAccessPointNode;
+        List<String> contributions = node.getInstalledContributionURIs();
+        return contributions.toString();
+    }
+    
+    public String getComposites(String domainName){
+        NodeImpl node = (NodeImpl)DomainView.domainAccessPointNode;
+        return node.getDomainLevelCompositeAsString();
+    } 
+    
+    public String getComponents(String domainName) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+    
+    public String getEndpoints(String domainName) {
+        NodeImpl node = (NodeImpl)DomainView.domainAccessPointNode;
+        return node.getEndpointRegistry().getEndpoints().toString();
+    }
+    
+    public String getNodes(String domainName){
+        // use the domain on the file system in lieu of info in the registry
+        File domainDir = new File("target/test-classes/" + domainName);
+        String nodes = "";
+        
+        for (File subDir : domainDir.listFiles()){
+            if (subDir.isDirectory()){
+                nodes += subDir.getName() + "\n";
+            }
+        }
+        return nodes;
+    }     
+    
+    // utilities
+    
+    public String prettyPrintXMLString(String inXML){
+        return inXML.replaceAll("<", "&lt;").replaceAll(">", "&gt;");
+        
+        // etc. need to read and write a structured version
+    }
+
+}
\ No newline at end of file

Added: 
tuscany/sandbox/slaws/domain-view/src/main/java/org/apache/tuscany/sca/domain/DomainView.java
URL: 
http://svn.apache.org/viewvc/tuscany/sandbox/slaws/domain-view/src/main/java/org/apache/tuscany/sca/domain/DomainView.java?rev=1102740&view=auto
==============================================================================
--- 
tuscany/sandbox/slaws/domain-view/src/main/java/org/apache/tuscany/sca/domain/DomainView.java
 (added)
+++ 
tuscany/sandbox/slaws/domain-view/src/main/java/org/apache/tuscany/sca/domain/DomainView.java
 Fri May 13 13:57:16 2011
@@ -0,0 +1,56 @@
+/*
+ * 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.    
+ */
+
+package org.apache.tuscany.sca.domain;
+
+import org.apache.tuscany.sca.Node;
+import org.apache.tuscany.sca.TuscanyRuntime;
+
+/**
+ * Main class for Tuscany. Just looking at what it means to read config from a 
directory structure. 
+ *  
+ */
+public class DomainView {
+    
+    public static Node domainAccessPointNode = null;
+    private static Node domainViewNode = null;
+
+    public static void main(String[] args) throws Exception {
+        String domainName = args[0];
+               
+        TuscanyRuntime tuscanyRuntime = TuscanyRuntime.newInstance();
+        
+        // a node to access the specified domain
+        domainAccessPointNode = tuscanyRuntime.createNode("uri:" + domainName);
+        
+        // a node to run the domain view app. Just starts in the local domain 
"domainview"
+        domainViewNode = tuscanyRuntime.createNode("domainview");
+        domainViewNode.installContribution("target/classes");
+        
+        System.out.print("Press a key to stop");
+        try{
+            System.in.read();
+        } catch(Exception ex){
+            // do nothing
+        }
+        
+        domainViewNode.stop();
+    }
+      
+}
\ No newline at end of file

Added: 
tuscany/sandbox/slaws/domain-view/src/main/java/org/apache/tuscany/sca/domain/Tuscany.java
URL: 
http://svn.apache.org/viewvc/tuscany/sandbox/slaws/domain-view/src/main/java/org/apache/tuscany/sca/domain/Tuscany.java?rev=1102740&view=auto
==============================================================================
--- 
tuscany/sandbox/slaws/domain-view/src/main/java/org/apache/tuscany/sca/domain/Tuscany.java
 (added)
+++ 
tuscany/sandbox/slaws/domain-view/src/main/java/org/apache/tuscany/sca/domain/Tuscany.java
 Fri May 13 13:57:16 2011
@@ -0,0 +1,133 @@
+/*
+ * 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.    
+ */
+
+package org.apache.tuscany.sca.domain;
+
+import java.io.File;
+import java.io.FilenameFilter;
+import java.io.IOException;
+import java.net.ServerSocket;
+import java.net.Socket;
+import java.net.URL;
+
+import org.apache.tuscany.sca.Node;
+import org.apache.tuscany.sca.TuscanyRuntime;
+
+/**
+ * Main class for Tuscany. Just looking at what it means to read config from a 
directory structure. 
+ *  
+ */
+public class Tuscany {
+    
+    public static Node node = null;
+
+    public static void main(String[] args) throws Exception {
+        String domainName = args[0];
+        String nodeName = args[1];
+        int deamonPort = -1;
+        
+        if (args.length > 2){
+            deamonPort = Integer.parseInt(args[2]);
+        }
+        
+        // find the domain directory
+        File currentDirectory = new File(".");
+        File domainDirectory = findDirectory(currentDirectory, domainName);
+        System.out.println("Domain: " + domainDirectory.getPath());
+        
+        // find a sub directory that ends in nodeName
+        File nodeDirectory = findDirectory(currentDirectory, nodeName);
+        System.out.println("Node: " + nodeDirectory.getPath());
+        
+        TuscanyRuntime tuscanyRuntime = TuscanyRuntime.newInstance();
+        
+        URL nodeConfigURL = nodeDirectory.toURI().resolve("node.xml").toURL();
+        node = tuscanyRuntime.createNodeFromXML(nodeConfigURL.toString());
+        
+        try {
+            //node.start();
+            
+            // for testing we're going to set up a deamon that listens for 
+            // a shutdown message on a specified port (well it actually just 
+            // waits for a client to connect to the port as that's all we need
+            // for now). If no port is specified then just stop straight away
+            
+            if (deamonPort >= 0){
+                // Its a runtime that has to act as a deamon
+                ServerSocket serverSocket = null;
+                    
+                try {
+                    serverSocket = new ServerSocket(deamonPort);
+                } catch (IOException e) {
+                    System.out.println("Can't create a ServerSocket on port: " 
+ deamonPort);
+                    return;
+                }
+                
+                // all we're doing here is waiting for a connection. If we 
wanted to implement
+                // a real deamon we should perhaps listen to what's coming in 
over the resulting socket
+                // and see if a shutdown has been requested
+                Socket clientSocket = null;
+                try {
+                    clientSocket = serverSocket.accept();
+                } catch (IOException e) {
+                    System.out.println("Accept failed on port: " + deamonPort);
+                    return;
+                }
+            } 
+        
+        } finally {
+            node.stop();
+        }
+    }
+    
+    /**
+     * Just walks down the tree (depth first) looking for a directory ending 
in the  
+     * name. 
+     */
+    private static File findDirectory(File currentDirectory, String name){
+        File directory = null;
+        
+        if (currentDirectory.getPath().endsWith(name)){
+            directory = currentDirectory;
+        } else {
+            File[] subDirectories = currentDirectory.listFiles(new 
DirectoryFilter());
+            for (File aDirectory : subDirectories) {
+                directory = findDirectory(aDirectory, name);
+                
+                if (directory != null){
+                    break;
+                }
+            }
+        }
+        
+        return directory;
+    }
+    
+    private static class DirectoryFilter implements FilenameFilter {
+
+        public boolean accept(File dir, String name) {
+            if(new File(dir, name).isDirectory()) {
+                return true;
+            }
+            
+            return false;
+        }
+    }
+      
+}
\ No newline at end of file

Modified: tuscany/sandbox/slaws/domain-view/src/main/resources/domain.composite
URL: 
http://svn.apache.org/viewvc/tuscany/sandbox/slaws/domain-view/src/main/resources/domain.composite?rev=1102740&r1=1102739&r2=1102740&view=diff
==============================================================================
--- tuscany/sandbox/slaws/domain-view/src/main/resources/domain.composite 
(original)
+++ tuscany/sandbox/slaws/domain-view/src/main/resources/domain.composite Fri 
May 13 13:57:16 2011
@@ -22,11 +22,33 @@
            targetNamespace="http://sample";
            name="domainview">
 
+ 
+    <component name="DomainUI">
+        <tuscany:implementation.widget location="ui/index.html" />
+        <service name="Widget">
+            <tuscany:binding.rest uri="/sca" />
+        </service>
+    </component>   
+
     <component name="Domain">
-        <implementation.java 
class="org.apache.tuscany.sca.domain.interop.Domain"/>
+        <implementation.java class="org.apache.tuscany.sca.domain.DomainImpl"/>
         <service name="Domain">
-            <tuscany:binding.rest uri="http://localhost:8085/sca"/>
+            <tuscany:binding.rest uri="/sca/domain">
+                <tuscany:operationSelector.jaxrs/>
+            </tuscany:binding.rest>
+        </service>
+    </component>
+
+<!--
+ don't know how to map multiple components to a variable root
+    <component name="Composite">
+        <implementation.java 
class="org.apache.tuscany.sca.domain.CompositeImpl"/>
+        <service name="Composite">
+            <tuscany:binding.rest uri="/sca/domain">
+                <tuscany:operationSelector.jaxrs/>
+            </tuscany:binding.rest>
         </service>
     </component>
+-->
 
 </composite>

Added: tuscany/sandbox/slaws/domain-view/src/main/resources/ui/component.gif
URL: 
http://svn.apache.org/viewvc/tuscany/sandbox/slaws/domain-view/src/main/resources/ui/component.gif?rev=1102740&view=auto
==============================================================================
Binary file - no diff available.

Propchange: 
tuscany/sandbox/slaws/domain-view/src/main/resources/ui/component.gif
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: tuscany/sandbox/slaws/domain-view/src/main/resources/ui/composite.gif
URL: 
http://svn.apache.org/viewvc/tuscany/sandbox/slaws/domain-view/src/main/resources/ui/composite.gif?rev=1102740&view=auto
==============================================================================
Binary file - no diff available.

Propchange: 
tuscany/sandbox/slaws/domain-view/src/main/resources/ui/composite.gif
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: tuscany/sandbox/slaws/domain-view/src/main/resources/ui/index.html
URL: 
http://svn.apache.org/viewvc/tuscany/sandbox/slaws/domain-view/src/main/resources/ui/index.html?rev=1102740&view=auto
==============================================================================
--- tuscany/sandbox/slaws/domain-view/src/main/resources/ui/index.html (added)
+++ tuscany/sandbox/slaws/domain-view/src/main/resources/ui/index.html Fri May 
13 13:57:16 2011
@@ -0,0 +1,250 @@
+<!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>

Added: tuscany/sandbox/slaws/domain-view/src/main/resources/ui/interface.gif
URL: 
http://svn.apache.org/viewvc/tuscany/sandbox/slaws/domain-view/src/main/resources/ui/interface.gif?rev=1102740&view=auto
==============================================================================
Binary file - no diff available.

Propchange: 
tuscany/sandbox/slaws/domain-view/src/main/resources/ui/interface.gif
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: tuscany/sandbox/slaws/domain-view/src/main/resources/ui/property.gif
URL: 
http://svn.apache.org/viewvc/tuscany/sandbox/slaws/domain-view/src/main/resources/ui/property.gif?rev=1102740&view=auto
==============================================================================
Binary file - no diff available.

Propchange: tuscany/sandbox/slaws/domain-view/src/main/resources/ui/property.gif
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: tuscany/sandbox/slaws/domain-view/src/main/resources/ui/reference.gif
URL: 
http://svn.apache.org/viewvc/tuscany/sandbox/slaws/domain-view/src/main/resources/ui/reference.gif?rev=1102740&view=auto
==============================================================================
Binary file - no diff available.

Propchange: 
tuscany/sandbox/slaws/domain-view/src/main/resources/ui/reference.gif
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: tuscany/sandbox/slaws/domain-view/src/main/resources/ui/service.gif
URL: 
http://svn.apache.org/viewvc/tuscany/sandbox/slaws/domain-view/src/main/resources/ui/service.gif?rev=1102740&view=auto
==============================================================================
Binary file - no diff available.

Propchange: tuscany/sandbox/slaws/domain-view/src/main/resources/ui/service.gif
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream


Reply via email to