incubator-aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From z..@apache.org
Subject svn commit: r942856 [1/2] - in /incubator/aries/trunk/samples-sandbox/demo-sample/demo-prototype: ./ src/main/java/org/apache/aries/samples/demo/prototype/ src/main/java/org/apache/aries/samples/demo/prototype/dummy/ src/main/java/org/apache/aries/samp...
Date Mon, 10 May 2010 19:14:18 GMT
Author: zoe
Date: Mon May 10 19:14:17 2010
New Revision: 942856

URL: http://svn.apache.org/viewvc?rev=942856&view=rev
Log:
ARIES-304 Part2: Update the prototype code to use the API bundle. Move the Javascript classes down to web/demo

Added:
    incubator/aries/trunk/samples-sandbox/demo-sample/demo-prototype/src/main/java/org/apache/aries/samples/demo/prototype/dummy/
    incubator/aries/trunk/samples-sandbox/demo-sample/demo-prototype/src/main/java/org/apache/aries/samples/demo/prototype/dummy/DummyInfoProvider.java
    incubator/aries/trunk/samples-sandbox/demo-sample/demo-prototype/src/main/resources/OSGI-INF/
    incubator/aries/trunk/samples-sandbox/demo-sample/demo-prototype/src/main/resources/OSGI-INF/blueprint/
    incubator/aries/trunk/samples-sandbox/demo-sample/demo-prototype/src/main/resources/OSGI-INF/blueprint/blueprint.xml
    incubator/aries/trunk/samples-sandbox/demo-sample/demo-prototype/src/main/resources/web/demo/
    incubator/aries/trunk/samples-sandbox/demo-sample/demo-prototype/src/main/resources/web/demo/Bundle.js
    incubator/aries/trunk/samples-sandbox/demo-sample/demo-prototype/src/main/resources/web/demo/BundleAppearance.js
      - copied unchanged from r942847, incubator/aries/trunk/samples-sandbox/demo-sample/demo-prototype/src/main/resources/web/BundleAppearance.js
    incubator/aries/trunk/samples-sandbox/demo-sample/demo-prototype/src/main/resources/web/demo/BundleStatusGrid.js
    incubator/aries/trunk/samples-sandbox/demo-sample/demo-prototype/src/main/resources/web/demo/Dependency.js
    incubator/aries/trunk/samples-sandbox/demo-sample/demo-prototype/src/main/resources/web/demo/DwrLoadingDialog.js
    incubator/aries/trunk/samples-sandbox/demo-sample/demo-prototype/src/main/resources/web/demo/LayoutManager.js
    incubator/aries/trunk/samples-sandbox/demo-sample/demo-prototype/src/main/resources/web/demo/Preferences.js
      - copied unchanged from r942847, incubator/aries/trunk/samples-sandbox/demo-sample/demo-prototype/src/main/resources/web/Preferences.js
    incubator/aries/trunk/samples-sandbox/demo-sample/demo-prototype/src/main/resources/web/demo/ProviderSelector.js
    incubator/aries/trunk/samples-sandbox/demo-sample/demo-prototype/src/main/resources/web/demo/SimpleInitialLayout.js
    incubator/aries/trunk/samples-sandbox/demo-sample/demo-prototype/src/main/resources/web/demo/TwistieSection.js
Removed:
    incubator/aries/trunk/samples-sandbox/demo-sample/demo-prototype/src/main/java/org/apache/aries/samples/demo/prototype/info/BundleInfo.java
    incubator/aries/trunk/samples-sandbox/demo-sample/demo-prototype/src/main/java/org/apache/aries/samples/demo/prototype/info/BundleInfoProvider.java
    incubator/aries/trunk/samples-sandbox/demo-sample/demo-prototype/src/main/resources/web/Bundle.js
    incubator/aries/trunk/samples-sandbox/demo-sample/demo-prototype/src/main/resources/web/BundleAppearance.js
    incubator/aries/trunk/samples-sandbox/demo-sample/demo-prototype/src/main/resources/web/Dependency.js
    incubator/aries/trunk/samples-sandbox/demo-sample/demo-prototype/src/main/resources/web/Preferences.js
    incubator/aries/trunk/samples-sandbox/demo-sample/demo-prototype/src/main/resources/web/TwistieSection.js
Modified:
    incubator/aries/trunk/samples-sandbox/demo-sample/demo-prototype/pom.xml
    incubator/aries/trunk/samples-sandbox/demo-sample/demo-prototype/src/main/java/org/apache/aries/samples/demo/prototype/BundleDependencies.java
    incubator/aries/trunk/samples-sandbox/demo-sample/demo-prototype/src/main/java/org/apache/aries/samples/demo/prototype/ServerSideClass.java
    incubator/aries/trunk/samples-sandbox/demo-sample/demo-prototype/src/main/java/org/apache/aries/samples/demo/prototype/info/impl/BundleContextInfoProvider.java
    incubator/aries/trunk/samples-sandbox/demo-sample/demo-prototype/src/main/java/org/apache/aries/samples/demo/prototype/info/impl/BundleInfoImpl.java
    incubator/aries/trunk/samples-sandbox/demo-sample/demo-prototype/src/main/resources/web/index.html

Modified: incubator/aries/trunk/samples-sandbox/demo-sample/demo-prototype/pom.xml
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/samples-sandbox/demo-sample/demo-prototype/pom.xml?rev=942856&r1=942855&r2=942856&view=diff
==============================================================================
--- incubator/aries/trunk/samples-sandbox/demo-sample/demo-prototype/pom.xml (original)
+++ incubator/aries/trunk/samples-sandbox/demo-sample/demo-prototype/pom.xml Mon May 10 19:14:17 2010
@@ -50,6 +50,11 @@
 			<groupId>org.apache.aries.application</groupId>
 			<artifactId>org.apache.aries.application.utils</artifactId>
 		</dependency>
+        <dependency>
+			<groupId>org.apache.aries.samples.demo</groupId>
+			<artifactId>org.apache.aries.samples.demo.api</artifactId>
+			<version>0.2-incubating-SNAPSHOT</version>
+		</dependency>
 	</dependencies>
 
     

Modified: incubator/aries/trunk/samples-sandbox/demo-sample/demo-prototype/src/main/java/org/apache/aries/samples/demo/prototype/BundleDependencies.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/samples-sandbox/demo-sample/demo-prototype/src/main/java/org/apache/aries/samples/demo/prototype/BundleDependencies.java?rev=942856&r1=942855&r2=942856&view=diff
==============================================================================
--- incubator/aries/trunk/samples-sandbox/demo-sample/demo-prototype/src/main/java/org/apache/aries/samples/demo/prototype/BundleDependencies.java (original)
+++ incubator/aries/trunk/samples-sandbox/demo-sample/demo-prototype/src/main/java/org/apache/aries/samples/demo/prototype/BundleDependencies.java Mon May 10 19:14:17 2010
@@ -7,7 +7,7 @@
  * "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
+ * 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

Modified: incubator/aries/trunk/samples-sandbox/demo-sample/demo-prototype/src/main/java/org/apache/aries/samples/demo/prototype/ServerSideClass.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/samples-sandbox/demo-sample/demo-prototype/src/main/java/org/apache/aries/samples/demo/prototype/ServerSideClass.java?rev=942856&r1=942855&r2=942856&view=diff
==============================================================================
--- incubator/aries/trunk/samples-sandbox/demo-sample/demo-prototype/src/main/java/org/apache/aries/samples/demo/prototype/ServerSideClass.java (original)
+++ incubator/aries/trunk/samples-sandbox/demo-sample/demo-prototype/src/main/java/org/apache/aries/samples/demo/prototype/ServerSideClass.java Mon May 10 19:14:17 2010
@@ -7,7 +7,7 @@
  * "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
+ * 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
@@ -30,24 +30,30 @@ import java.util.concurrent.TimeUnit;
 import javax.servlet.ServletContext;
 
 import org.directwebremoting.Browser;
-import org.directwebremoting.ServerContextFactory;
-import org.directwebremoting.ScriptSession;
 import org.directwebremoting.ScriptBuffer;
+import org.directwebremoting.ScriptSession;
+import org.directwebremoting.ServerContextFactory;
 import org.directwebremoting.ui.dwr.Util;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceReference;
+import org.apache.aries.samples.demo.api.BundleInfo;
+import org.apache.aries.samples.demo.api.BundleInfoProvider;
 
-import org.apache.aries.samples.demo.prototype.info.BundleInfo;
-import org.apache.aries.samples.demo.prototype.info.BundleInfoProvider;
-import org.apache.aries.samples.demo.prototype.info.impl.BundleContextInfoProvider;
-
-
-public class ServerSideClass implements Runnable, BundleInfoProvider.BundleInfoListener {
+public class ServerSideClass implements Runnable {
 
+	private String bundleInfoProviderHint="";
+	private String bundleInfoProviderOptions="";
+	
 	private BundleInfoProvider bundleInfoProvider=null;
+	
+	private Map<BundleInfoProvider, BundleInfoProvider.BundleInfoListener>listeners=new HashMap<BundleInfoProvider,BundleInfoProvider.BundleInfoListener>();
 
     protected transient boolean active = false;
 	
+	private static Map<String, String> coords = new HashMap<String, String>();
+	
     private final class UpdatePageInvocation implements Runnable {
     	
 		private final String output;
@@ -57,6 +63,7 @@ public class ServerSideClass implements 
 		}
 
 		public void run() {
+			//add the clock update
 		    Util.setValue("displayMessage", "Server Time is : "+String.valueOf(output) );
 		    
 		    //make test fn that does the blue/red indicator
@@ -64,23 +71,39 @@ public class ServerSideClass implements 
 		}
 	}
 
+    private class ListenerImpl implements BundleInfoProvider.BundleInfoListener{
+    	String server;
+    	String options;
+    	public ListenerImpl(String server, String options){
+    		this.server=server;
+    		this.options=options;
+    	}
+    	public void addNewBundleInfo(BundleInfo b) {
+    		if(this.server.equals(bundleInfoProviderHint) &&
+    		   this.options.equals(bundleInfoProviderOptions)){
+    			   //todo: only issue the add for the new bundle, and affected other bundles.
+    			   getInitialBundles(bundleInfoProviderHint, bundleInfoProviderOptions);
+    		   }	
+    	}
+
+
+    	public void updateBundleInfo(BundleInfo b) {
+    		if(this.server.equals(bundleInfoProviderHint) &&
+ 		   this.options.equals(bundleInfoProviderOptions)){
+ 			   //todo: only issue the add for the new bundle, and affected other bundles.
+ 			   getInitialBundles(bundleInfoProviderHint, bundleInfoProviderOptions);
+ 		   }
+    	}
+
+    	
+    }
+    
 	public ServerSideClass() {
+		System.err.println("SSC Built!");
+		
         ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor(1);
         executor.scheduleAtFixedRate(this, 1, 1, TimeUnit.SECONDS); 
-        
-    	ServletContext context = ServerContextFactory.get().getServletContext();
-		Object o = context.getAttribute("osgi-bundlecontext");
-		if(o!=null){
-			if(o instanceof BundleContext){
-				BundleContext b_ctx = (BundleContext)o;
-				this.bundleInfoProvider = new BundleContextInfoProvider(b_ctx);
-				this.bundleInfoProvider.registerBundleInfoListener(this);
-			}
-		}
-		
-		if(this.bundleInfoProvider==null){
-		   throw new RuntimeException("Unable to instantiate the bundleInfoProvider");
-		}
+       	
     }
 
     public void run() {
@@ -111,7 +134,7 @@ public class ServerSideClass implements 
 		case Bundle.STARTING : return "STARTING";
 		case Bundle.STOPPING : return "STOPPING";
 		case Bundle.ACTIVE : return "ACTIVE";
-		default : return "UNKNOWN";
+		default : return "UNKNOWN["+bundleState+"]";
 		}
 	}    
 
@@ -129,7 +152,62 @@ public class ServerSideClass implements 
      * this is invoked by a page onload.. so until it's invoked.. we dont care
      * about bundles.. 
      */
-    public void getInitialBundles(){
+    public void getInitialBundles(String dataProvider, String options){
+    	
+    	System.err.println("GET INITIAL BUNDLES ASKED TO USE DATAPROVIDER "+dataProvider+" OPTIONS "+options);
+    	
+    	if(dataProvider==null)
+    		throw new IllegalArgumentException("Unable to accept 'null' as a dataProvider");
+    	
+    	//do we need to update?
+    	if( !this.bundleInfoProviderHint.equals(dataProvider) ||
+    	    !this.bundleInfoProviderOptions.equals(options)){
+    		    		
+    		this.bundleInfoProviderHint = dataProvider;
+    		this.bundleInfoProviderOptions = options;
+    		if(this.bundleInfoProviderOptions==null){
+    			this.bundleInfoProviderOptions="";
+    		}    		    		
+    		
+    		if(!(this.bundleInfoProvider==null)){
+    			//we already had a provider.. we need to shut down the existing bundles in the browsers..
+    			addFunctionCall("forgetAboutAllBundles");
+    		}
+    		
+        	ServletContext context = org.directwebremoting.ServerContextFactory.get().getServletContext();
+    		Object o = context.getAttribute("osgi-bundlecontext");
+    		if(o!=null){
+    			if(o instanceof BundleContext){
+    				BundleContext b_ctx = (BundleContext)o;
+    				
+    				System.err.println("Looking up bcip");
+    				try{
+    				ServiceReference sr[] = b_ctx.getServiceReferences(BundleInfoProvider.class.getName(), "(displayName="+this.bundleInfoProviderHint+")");
+    				if(sr!=null){
+    					System.err.println("Getting bcip");
+    					this.bundleInfoProvider = (BundleInfoProvider)b_ctx.getService(sr[0]);
+    					System.err.println("Got bcip "+this.bundleInfoProvider);
+    				}else{
+    					System.err.println("UNABLE TO FIND BCIP!!");
+    					System.err.println("UNABLE TO FIND BCIP!!");
+    					System.err.println("UNABLE TO FIND BCIP!!");
+    				}
+    				}catch(InvalidSyntaxException ise){
+    					
+    				}
+    				//this.bundleInfoProvider = new BundleContextInfoProvider(b_ctx);
+    				if(this.bundleInfoProvider!=null){
+    					if(!listeners.containsKey(this.bundleInfoProvider)){    
+    						BundleInfoProvider.BundleInfoListener l = new ListenerImpl(this.bundleInfoProviderHint, this.bundleInfoProviderOptions);
+    						listeners.put(this.bundleInfoProvider, l);
+    						this.bundleInfoProvider.registerBundleInfoListener(l);
+    					}
+    				}
+    			}
+    		}
+    		
+    	}
+    	
     	
     	BundleDependencies bd = new BundleDependencies();
     	
@@ -150,22 +228,32 @@ public class ServerSideClass implements 
     					bundleStateToString(b.getState()), 
     					b.getVersion());
     			   			
+    			System.err.println("Adding dependencies");
     			Set<Long> dependencies = new HashSet<Long>();
     			for(long id : b.getDependencies() ){
+    				System.err.println(".. "+id);
     				dependencies.add(id);
     			}
     			
+    			System.err.println("Adding impdeps");
     			Set<Long> impDeps = new HashSet<Long>();
     			for(BundleInfo.PackageInfo p: b.getImportedPackages()){
+    				System.err.println(".. "+p.getSuppliedBy()+" "+String.valueOf(p));
     				if(p.getSuppliedBy() != -1){
     					impDeps.add(p.getSuppliedBy());
     				}
     			}
     			
+    			System.err.println("Adding expdeps");
     			Set<Long> expDeps = new HashSet<Long>();
     			for(BundleInfo.PackageInfo p: b.getExportedPackages()){
-    				if(p.getSuppliedBy() != -1){
-    					expDeps.add(p.getSuppliedBy());
+    				if(p.getUsedBy()!=null){
+	    				for(long l : p.getUsedBy()){
+		    				System.err.println(".. "+l+" "+String.valueOf(p));
+		    				if(l != -1){
+		    					expDeps.add(l);
+		    				}
+	    				}
     				}
     			}
     			
@@ -174,10 +262,30 @@ public class ServerSideClass implements 
     			allExpDep.put(b.getBundleId(), expDeps);
     		}
     	}    	
+    	
+    	System.err.println("MAP "+allImpDep+"  "+allExpDep);
+    	
     	bd.setTotalDependencies(allDep);
     	bd.setPackageImportDependencies(allImpDep);
     	bd.setPackageExportDependencies(allExpDep);
-		addFunctionCall("setBundleDependencies",bd);   	
+		addFunctionCall("setBundleDependencies",bd);  
+		
+    }
+    
+    private void addFunctionCall(String name, Object... params){
+		final ScriptBuffer script = new ScriptBuffer();					
+        script.appendScript(name).appendScript("(");
+        for(int i = 0; i < params.length; i++)
+        {
+            if(i != 0)script.appendScript(",");
+            script.appendData(params[i]);
+        }
+        script.appendScript(");");        
+        Browser.withAllSessions(new Runnable(){ public void run(){
+    		for(ScriptSession s: Browser.getTargetSessions()){
+    			s.addScript(script);
+    		} 
+        }});      
     }
     
     public String[] getPackageImports(long bundleId){
@@ -217,62 +325,76 @@ public class ServerSideClass implements 
     	
     	BundleInfo bi = bundleInfoProvider.getBundleForId(bundleId);
     	
-//    	System.err.println("Got "+bi+" for "+bundleId);    	
-//    	System.err.println(".. "+bi.getSymbolicName());    	
-//    	System.err.println("exp packages is "+String.valueOf(bi.getExportedPackages()));
+    	System.err.println("Got "+bi+" for "+bundleId);    	
+    	System.err.println(".. "+bi.getSymbolicName());    	
+    	System.err.println("exp packages is "+String.valueOf(bi.getExportedPackages()));
     	
     	ArrayList<String> exps = new ArrayList<String>();
 		for(BundleInfo.PackageInfo p: bi.getExportedPackages()){
-			//System.err.println("processing "+p.getName());
+			
+			System.err.println(p);
+			
+			System.err.println("processing "+p.getName());
 			
 			if(p.getSuppliedBy() != -1){
-				//System.err.println("adding to list");
+				System.err.println("adding to list");
 				exps.add(p.getName());
 			}else{
-				//System.err.println("ignoring -1");
+				System.err.println("ignoring -1");
 			}
 		}
 		
-		//System.err.println("converting to array");
+		System.err.println("converting to array");
 		String[] result = new String[exps.size()];
 		if(result.length==0){
-			//System.err.println("returning no exports");
+			System.err.println("returning no exports");
 			result = new String[]{"No Exports"};
 		}else{
-			//System.err.println("calling toArray "+exps.size());
+			System.err.println("calling toArray "+exps.size());
 			result = exps.toArray(result);
-			//System.err.println("returning "+result.length+" results");
+			System.err.println("returning "+result.length+" results");
 		}
     	return result;
     }
-	//
-	//Replacement for ScriptSessions.addFunctionCall
-	//
-	private void addFunctionCall(String name, Object... params){
-		final ScriptBuffer script = new ScriptBuffer();					
-		script.appendScript(name).appendScript("(");
-		for(int i = 0; i < params.length; i++)
-		{
-		    if(i != 0)script.appendScript(",");
-		    script.appendData(params[i]);
-		}
-		script.appendScript(");");        
-		Browser.withAllSessions(new Runnable(){ public void run(){
-			for(ScriptSession s: Browser.getTargetSessions()){
-				s.addScript(script);
-			}	 
-		}});      
-	}
 
-	// @Override
-	public void addNewBundleInfo(BundleInfo b) {
-		//todo: only issue the add for the new bundle, and affected other bundles.
-		getInitialBundles();
-	}
 
-	// @Override
-	public void updateBundleInfo(BundleInfo b) {
-		//todo: only issue the add for the new bundle, and affected other bundles.
-		getInitialBundles();
+	
+	public String[] getProviders(){
+		System.err.println("Getting providers...");
+		ArrayList<String> result=new ArrayList<String>();
+    	ServletContext context = ServerContextFactory.get().getServletContext();
+		Object o = context.getAttribute("osgi-bundlecontext");
+		if(o!=null){
+			if(o instanceof BundleContext){
+				BundleContext b_ctx = (BundleContext)o;
+				try{
+					System.err.println("Getting providers [2]...");
+					ServiceReference[] srs = b_ctx.getServiceReferences(BundleInfoProvider.class.getName(), null);
+					System.err.println("Got.. "+srs);
+					if(srs==null || srs.length==0){
+						System.err.println("NO DATA PROVIDERS");
+						throw new RuntimeException("Unable to find any data providers");
+					}
+					System.err.println("Processing srs as loop.");
+					for(ServiceReference sr : srs){
+						System.err.println("Processing srs entry...");
+						
+						String name = (String.valueOf(sr.getProperty("displayName")));
+						
+						result.add(name);
+					}	
+					System.err.println("Processed srs as loop.");
+				}catch(InvalidSyntaxException e){
+					//wont happen, the exception relates to the filter, (2nd arg above), which is constant null.
+				}
+			}
+		}	
+		System.err.println("Returning "+result.size());
+		String[] arr = new String[result.size()];
+		arr = result.toArray(arr);
+		for(String x: arr){
+			System.err.println(" - "+x);
+		}
+		return arr;
 	}
 }

Added: incubator/aries/trunk/samples-sandbox/demo-sample/demo-prototype/src/main/java/org/apache/aries/samples/demo/prototype/dummy/DummyInfoProvider.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/samples-sandbox/demo-sample/demo-prototype/src/main/java/org/apache/aries/samples/demo/prototype/dummy/DummyInfoProvider.java?rev=942856&view=auto
==============================================================================
--- incubator/aries/trunk/samples-sandbox/demo-sample/demo-prototype/src/main/java/org/apache/aries/samples/demo/prototype/dummy/DummyInfoProvider.java (added)
+++ incubator/aries/trunk/samples-sandbox/demo-sample/demo-prototype/src/main/java/org/apache/aries/samples/demo/prototype/dummy/DummyInfoProvider.java Mon May 10 19:14:17 2010
@@ -0,0 +1,102 @@
+/**
+ * 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.aries.samples.demo.prototype.dummy;
+
+import org.apache.aries.samples.demo.api.BundleInfo;
+import org.apache.aries.samples.demo.api.BundleInfoProvider;
+import org.apache.aries.samples.demo.prototype.info.impl.BundleInfoImpl;
+
+public class DummyInfoProvider implements BundleInfoProvider {
+	
+	BundleInfoImpl a = new BundleInfoImpl();
+	BundleInfoImpl b = new BundleInfoImpl();
+	BundleInfoImpl c = new BundleInfoImpl();
+	
+	BundleInfoImpl.PackageInfoImpl p1 = new BundleInfoImpl.PackageInfoImpl();
+	BundleInfoImpl.PackageInfoImpl p2 = new BundleInfoImpl.PackageInfoImpl();
+	BundleInfoImpl.PackageInfoImpl p3 = new BundleInfoImpl.PackageInfoImpl();
+	
+	public DummyInfoProvider(){
+		
+		p1.setName("package.one");
+		p1.setSuppliedBy(1);
+		p1.setVersion("1.0.0");
+		p1.setUsedBy(new long[]{1,2});
+		
+		p2.setName("package.two");
+		p2.setSuppliedBy(1);
+		p2.setVersion("2.0.0");
+		p2.setUsedBy(new long[]{1,2});
+		
+		p3.setName("package.three");
+		p3.setSuppliedBy(2);
+		p3.setVersion("3.0.0");
+		p3.setUsedBy(new long[]{3});
+		
+		a.setBundleId(1);
+		a.setSymbolicName("Uber.Bundle");
+		a.setImportedPackages(new BundleInfo.PackageInfo[]{p1});
+		a.setExportedPackages(new BundleInfo.PackageInfo[]{p1,p2});
+		a.setDependencies(new long[]{1,2});
+		a.setRegisteredServices(new String[]{});
+		a.setServicesInUse(new String[]{});
+		a.setVersion("1.0.0");
+		a.setState(1);
+		
+		b.setBundleId(2);
+		b.setSymbolicName("Fred");
+		b.setImportedPackages(new BundleInfo.PackageInfo[]{p1,p2});
+		b.setExportedPackages(new BundleInfo.PackageInfo[]{p3});
+		b.setDependencies(new long[]{1,2,3});
+		b.setRegisteredServices(new String[]{});
+		b.setServicesInUse(new String[]{});
+		b.setVersion("1.0.0");
+		b.setState(1);
+		
+		c.setBundleId(3);
+		c.setSymbolicName("Wilma");
+		c.setImportedPackages(new BundleInfo.PackageInfo[]{p3});
+		c.setExportedPackages(new BundleInfo.PackageInfo[]{});
+		c.setDependencies(new long[]{2,3});
+		c.setRegisteredServices(new String[]{});
+		c.setServicesInUse(new String[]{});
+		c.setVersion("1.0.0");
+		c.setState(1);
+	}
+
+	@Override
+	public BundleInfo[] getBundles() {
+		// TODO Auto-generated method stub
+		return new BundleInfo[]{a,b,c};
+	}
+
+	@Override
+	public BundleInfo getBundleForId(long id) {
+		if(id==1) return a;
+		if(id==2) return b;
+		if(id==3) return c;
+		return null;
+	}
+
+	@Override
+	public void registerBundleInfoListener(BundleInfoListener listener) {
+		//no-op
+	}
+
+}

Modified: incubator/aries/trunk/samples-sandbox/demo-sample/demo-prototype/src/main/java/org/apache/aries/samples/demo/prototype/info/impl/BundleContextInfoProvider.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/samples-sandbox/demo-sample/demo-prototype/src/main/java/org/apache/aries/samples/demo/prototype/info/impl/BundleContextInfoProvider.java?rev=942856&r1=942855&r2=942856&view=diff
==============================================================================
--- incubator/aries/trunk/samples-sandbox/demo-sample/demo-prototype/src/main/java/org/apache/aries/samples/demo/prototype/info/impl/BundleContextInfoProvider.java (original)
+++ incubator/aries/trunk/samples-sandbox/demo-sample/demo-prototype/src/main/java/org/apache/aries/samples/demo/prototype/info/impl/BundleContextInfoProvider.java Mon May 10 19:14:17 2010
@@ -7,7 +7,7 @@
  * "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
+ * 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
@@ -20,53 +20,73 @@ package org.apache.aries.samples.demo.pr
 
 import java.util.ArrayList;
 import java.util.Collections;
+import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 
 import org.apache.aries.application.utils.manifest.ManifestHeaderProcessor;
 import org.apache.aries.application.utils.manifest.ManifestHeaderProcessor.NameValueMap;
-import org.apache.aries.application.utils.manifest.ManifestHeaderProcessor.NameValuePair;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.BundleEvent;
 import org.osgi.framework.BundleListener;
-import org.apache.aries.samples.demo.prototype.info.BundleInfo;
-import org.apache.aries.samples.demo.prototype.info.BundleInfoProvider;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.packageadmin.ExportedPackage;
+import org.osgi.service.packageadmin.PackageAdmin;
+import org.apache.aries.samples.demo.api.BundleInfo;
+import org.apache.aries.samples.demo.api.BundleInfoProvider;
 
 public class BundleContextInfoProvider implements BundleInfoProvider, BundleListener {
 	
+	private Map<Long, BundleInfo>biCache = new HashMap<Long,BundleInfo>();
+	
 	private List<BundleInfoListener> listeners=null;
 
 	private BundleContext ctx=null;
 	
 	public BundleContextInfoProvider(BundleContext ctx){
+		System.err.println("BCIP built!");
 		this.ctx = ctx;
 		this.listeners = Collections.synchronizedList(new ArrayList<BundleInfoListener>());
 		this.ctx.addBundleListener(this);
+		
+		System.err.println("BUNDLE 0 **********************************************");
+		Bundle b = ctx.getBundle(0);
+		System.err.println(b.getSymbolicName()+" "+b.getVersion()+" "+b.getLocation());
+		
+		System.err.println("PROP IS "+System.getProperty("org.osgi.framework.system.packages"));
+		
 	}
 	
 	
-	// @Override
+
 	public BundleInfo[] getBundles() {
+		System.err.println("BCIP getBundles called");
 		Bundle[] bundles = this.ctx.getBundles();
 		BundleInfo[] result = new BundleInfo[bundles.length];
 		
 		for(int i=0; i<bundles.length; i++){
+			System.err.println("BCIP converting "+i);
 			result[i] = getBundleForId(bundles[i].getBundleId());
 		}
 
+		System.err.println("BCIP returning data");
 		return result;
 	}
 
-	// @Override
+
 	public void registerBundleInfoListener(BundleInfoListener listener) {
 		listeners.add(listener);
 	}
 
 
-	// @Override
+
 	public BundleInfo getBundleForId(long id) {
+		if(biCache.containsKey(id)){
+			return biCache.get(id);
+		}
+		
 		Bundle b = ctx.getBundle(id);		
 		BundleInfoImpl bii = new BundleInfoImpl();
 		
@@ -79,16 +99,51 @@ public class BundleContextInfoProvider i
 				
 		ArrayList<BundleInfo.PackageInfo> imps = new ArrayList<BundleInfo.PackageInfo>();
 		String importString = (String)b.getHeaders().get("Import-Package");			
-		if(importString!=null){					
+		if(importString!=null){								
+						
 			Map<String, NameValueMap<String, String>> imports = ManifestHeaderProcessor.parseImportString(importString);
 			for(Map.Entry<String, NameValueMap<String, String>> packageImport : imports.entrySet()){
 				
 				BundleInfoImpl.PackageInfoImpl pii = new BundleInfoImpl.PackageInfoImpl();
 				pii.setName(packageImport.getKey());
+				pii.setSuppliedBy(-1);
+				
+				ServiceReference sr = ctx.getServiceReference(PackageAdmin.class.getName());
+				PackageAdmin pa = (PackageAdmin)ctx.getService(sr);
 				
-				long sid=0;
-				allDepSet.add(sid);				
-				pii.setSuppliedBy(sid);
+				//am I a fragment ?
+				Bundle hosts[] = pa.getHosts(b);
+				
+				ExportedPackage eps[] = pa.getExportedPackages(pii.getName());
+				boolean found=false;
+				if(eps!=null&&eps.length>0){
+					for(ExportedPackage ep: eps){
+						Bundle ibs[] = ep.getImportingBundles();
+						if(ibs.length>0){
+							for(Bundle ib : ibs){
+								Bundle match = null;
+								match = (ib.getBundleId() == b.getBundleId()) ? ib : null;								
+								//If I'm a fragment, and I haven't found a match yet, perhaps
+								//my host has performed the import.
+								if(match==null && hosts!=null && hosts.length>0){
+									for(Bundle h : hosts){
+										if(match==null){
+											//is our fragment host, an importer of this package?
+											match=(h.getBundleId() == ib.getBundleId())?h:null;
+										}
+									}
+								}								
+								if(match!=null){
+									//resp.print(indent+"  <bundle-id>"+ep.getExportingBundle().getBundleId()+"</bundle-id>\n");
+									long sid=ep.getExportingBundle().getBundleId();
+									allDepSet.add(sid);								
+									pii.setSuppliedBy(sid);
+								}
+							}
+						}
+					}
+				}								
+			
 				pii.setParameters(new ArrayList<String[]>());
 				pii.setSupplyCandidates(new long[]{});
 				pii.setVersion("");
@@ -101,24 +156,34 @@ public class BundleContextInfoProvider i
 		bii.setImportedPackages(impArr);
 		
 		ArrayList<BundleInfo.PackageInfo> exps = new ArrayList<BundleInfo.PackageInfo>();
-		String exportString = (String)b.getHeaders().get("Export-Package");
-		if(exportString!=null){
-			List<NameValuePair<String, NameValueMap<String, String>>> exports = ManifestHeaderProcessor.parseExportString(exportString);
-			for(NameValuePair<String, NameValueMap<String, String>> export : exports){
-				
+	
+		ServiceReference sr = ctx.getServiceReference(PackageAdmin.class.getName());
+		PackageAdmin pa = (PackageAdmin)ctx.getService(sr);
+
+		ExportedPackage[] eps = pa.getExportedPackages(b);
+		if(eps!=null&&eps.length>0){
+			for(ExportedPackage ep: eps){
 				BundleInfoImpl.PackageInfoImpl pii = new BundleInfoImpl.PackageInfoImpl();
-				pii.setName(export.getName());		
-				
-				long sid=0;
-				allDepSet.add(sid);				
-				pii.setSuppliedBy(sid);
+				pii.setName(ep.getName());		
 				pii.setParameters(new ArrayList<String[]>());
 				pii.setSupplyCandidates(new long[]{});
-				pii.setVersion("");
-				
-				exps.add(pii);
+				pii.setVersion("");			
+				pii.setUsedBy(new long[0]);
+				Bundle ibs[] = ep.getImportingBundles();
+				if(ibs.length>0){
+					long ids[] = new long[ibs.length];
+					int idx=0;
+					for(Bundle ib: ibs){
+						ids[idx]=ib.getBundleId();
+						allDepSet.add(ib.getBundleId());							
+					}
+					pii.setUsedBy(ids);
+
+					exps.add(pii);
+				}
 			}
-		}		
+		}
+		
 		BundleInfo.PackageInfo[] expArr = new BundleInfo.PackageInfo[exps.size()];
 		expArr = exps.toArray(expArr);
 		bii.setExportedPackages(expArr);
@@ -131,13 +196,25 @@ public class BundleContextInfoProvider i
 		}
 		bii.setDependencies(allDepArr);
 		
+		biCache.put(bii.getBundleId(), bii);		
 		return bii;
 	}
 
 
-	// @Override
+
 	public void bundleChanged(BundleEvent arg0) {
+		long id = arg0.getBundle().getBundleId();
+		if(biCache.containsKey(id)){
+			BundleInfo bi = biCache.get(id);
+			for(long related : bi.getDependencies()){
+				if(biCache.containsKey(related)){
+					biCache.remove(related);
+				}
+			}
+			biCache.remove(id);
+		}		
 		BundleInfo bi = getBundleForId(arg0.getBundle().getBundleId());
+		
 		for(BundleInfoListener bil : listeners){
 			if(arg0.getType()==BundleEvent.INSTALLED){
 				bil.addNewBundleInfo(bi);

Modified: incubator/aries/trunk/samples-sandbox/demo-sample/demo-prototype/src/main/java/org/apache/aries/samples/demo/prototype/info/impl/BundleInfoImpl.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/samples-sandbox/demo-sample/demo-prototype/src/main/java/org/apache/aries/samples/demo/prototype/info/impl/BundleInfoImpl.java?rev=942856&r1=942855&r2=942856&view=diff
==============================================================================
--- incubator/aries/trunk/samples-sandbox/demo-sample/demo-prototype/src/main/java/org/apache/aries/samples/demo/prototype/info/impl/BundleInfoImpl.java (original)
+++ incubator/aries/trunk/samples-sandbox/demo-sample/demo-prototype/src/main/java/org/apache/aries/samples/demo/prototype/info/impl/BundleInfoImpl.java Mon May 10 19:14:17 2010
@@ -7,7 +7,7 @@
  * "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
+ * 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
@@ -20,11 +20,11 @@ package org.apache.aries.samples.demo.pr
 
 import java.util.List;
 
-import org.apache.aries.samples.demo.prototype.info.BundleInfo;
+import org.apache.aries.samples.demo.api.BundleInfo;
 
 public class BundleInfoImpl implements BundleInfo {
 
-	   static class PackageInfoImpl implements BundleInfo.PackageInfo{
+	   public static class PackageInfoImpl implements BundleInfo.PackageInfo{
 		   public String getName() {
 			return name;
 		}
@@ -60,8 +60,16 @@ public class BundleInfoImpl implements B
 		   List<String[]> parameters;
 		   long suppliedBy;
 		   long[] supplyCandidates;
+		   long[] usedBy;
 		   
-	   }
+
+		public long[] getUsedBy() {
+			return this.usedBy;
+		}
+		public void setUsedBy(long[] usedBy){
+			this.usedBy = usedBy;		   
+		}
+	}
 	
 	
 	long bundleId;

Added: incubator/aries/trunk/samples-sandbox/demo-sample/demo-prototype/src/main/resources/OSGI-INF/blueprint/blueprint.xml
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/samples-sandbox/demo-sample/demo-prototype/src/main/resources/OSGI-INF/blueprint/blueprint.xml?rev=942856&view=auto
==============================================================================
--- incubator/aries/trunk/samples-sandbox/demo-sample/demo-prototype/src/main/resources/OSGI-INF/blueprint/blueprint.xml (added)
+++ incubator/aries/trunk/samples-sandbox/demo-sample/demo-prototype/src/main/resources/OSGI-INF/blueprint/blueprint.xml Mon May 10 19:14:17 2010
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
+
+  <bean id="contextInfoProvider" class="org.apache.aries.samples.demo.prototype.info.impl.BundleContextInfoProvider">
+    <argument ref="blueprintBundleContext"/>
+  </bean>
+  <service ref="contextInfoProvider" interface="org.apache.aries.samples.demo.api.BundleInfoProvider">
+  	<service-properties>
+  	  <entry key="displayName" value="BundleContextInfoProvider"/>
+  	</service-properties>
+  </service>
+  
+  <bean id="dummyInfoProvider" class="org.apache.aries.samples.demo.prototype.dummy.DummyInfoProvider">
+  </bean>
+  <service ref="dummyInfoProvider" interface="org.apache.aries.samples.demo.api.BundleInfoProvider">
+  	<service-properties>
+  	  <entry key="displayName" value="DummyInfoProvider"/>
+  	</service-properties>
+  </service>
+
+</blueprint>

Added: incubator/aries/trunk/samples-sandbox/demo-sample/demo-prototype/src/main/resources/web/demo/Bundle.js
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/samples-sandbox/demo-sample/demo-prototype/src/main/resources/web/demo/Bundle.js?rev=942856&view=auto
==============================================================================
--- incubator/aries/trunk/samples-sandbox/demo-sample/demo-prototype/src/main/resources/web/demo/Bundle.js (added)
+++ incubator/aries/trunk/samples-sandbox/demo-sample/demo-prototype/src/main/resources/web/demo/Bundle.js Mon May 10 19:14:17 2010
@@ -0,0 +1,354 @@
+dojo.provide("demo.Bundle");
+dojo.require("demo.TwistieSection");
+dojo.require("dojox.gfx");
+dojo.require("dojox.gfx.fx");
+dojo.require("dojox.gfx.Moveable");
+dojo.require("dojo.data.ItemFileWriteStore");
+
+//Bundle
+// looks after a bundle shape on the surface.
+//
+//TODO:
+// - currently the import/exports are externally managed, these need bringing in
+//   so the bundle looks after obtaining/updating them.
+//   - convert package info to more than just string/implied-to-from info.
+//   - update twisties to work over new data.
+//   - prevent duplicate dependency adding.. 
+// - add added/modified/deleted events so that other objects can act on them.
+// - add service deps (once package deps model is fixed)
+// - add decorators, bundle state icons, 
+dojo.declare("demo.Bundle", [], {
+
+	//properties
+	id: null,
+	name: null,
+	state: null,	
+	version: null,
+	hidden: false,
+
+	//gfx objects
+	group: null,
+	surface: null,
+	outline: null,
+	
+	textName: null,
+	nameRule: null,
+	
+	importTwistie: null,
+	exportTwistie: null,
+	
+	textState: null,
+	stateRule: null,
+	
+	textVersion: null,
+	versionRule: null,
+		
+	//dimensions/coords
+	x: 0,
+	y: 0,
+	minWidth: 150,
+	minHeight: 80,
+	ruleOffset: 5,
+	ruleHeight: 20,
+	width: null,
+	height: null,
+	selected: false,
+	
+	linesFrom: null,
+	linesTo: null,	
+	
+	constructor: function(surface, id, name, state, version) {
+	this.surface=surface;
+	this.id=id;
+	this.name=name;
+	this.version=version;
+	this.state=state;
+	this.x=0;
+	this.y=0;
+	this.height=115;
+	this.width=this.minWidth;
+	
+	this.linesFrom = new Array();
+	this.linesTo = new Array();
+	
+	this.calcWidthBasedOnContent();
+	
+	this.initGfx();
+	
+	var bundleThis = this;
+	var importCallBack = function(){
+	    var importCallback = function(data)
+	    {
+	      if (data != null && typeof data == 'object'){
+		      bundleThis.importTwistie.items = data;	 
+		      bundleThis.importTwistie.addItemsToDisplay();
+		      bundleThis.resize();
+	      }
+	    };				
+		ServerSideClass.getPackageImports(id, importCallback);
+	};
+	var exportCallBack = function(){
+	    var exportCallback = function(data)
+	    {
+	      if (data != null && typeof data == 'object'){
+		      bundleThis.exportTwistie.items = data;	 
+		      bundleThis.exportTwistie.addItemsToDisplay();
+		      bundleThis.resize();
+	      }
+	    };				
+		ServerSideClass.getPackageExports(id, exportCallback);
+	};
+	
+	//name, parentGroup, owningBundle, x, y
+	var impy = (this.ruleHeight*2)+this.ruleOffset+25;
+	var expy = impy+12;
+	this.importTwistie=new demo.TwistieSection("Imports", this.group, this, 5, impy, importCallBack);
+	this.exportTwistie=new demo.TwistieSection("Exports", this.group, this, 5, expy, exportCallBack);
+	
+	//update size to account for twisties.
+	this.resize();
+
+	var mover = new dojox.gfx.Moveable(this.group);
+    dojo.connect(mover, "onMoved", this, "onMoved");  
+    
+    this.group.connect("onclick",dojo.hitch(this,"onClick"));
+    this.group.connect("onmouseenter",dojo.hitch(this,"onMouseEnter"));
+    this.group.connect("onmouseleave",dojo.hitch(this,"onMouseLeave"));
+    
+    dojo.publish("demo.bundle.create",[this]);
+},
+removeSelf: function() {
+	//console.log("removing bundle "+this.id+" from surface");
+	this.surface.remove(this.group);
+	dojo.publish("demo.bundle.delete", [this]);
+	
+	//console.log("processing bundle "+this.id+" lines to for removal");
+	//TODO: do I need to destroy, or otherwise remove the sub-elements?
+	dojo.forEach(this.linesTo, function(line){
+		//console.log("removing line to");
+		line.removeSelf();
+		//console.log("line to removed");
+	});
+	//console.log("processing bundle "+this.id+" lines from for removal");
+	dojo.forEach(this.linesFrom, function(line){
+		//console.log("removing line from");
+		line.removeSelf();	
+		//console.log("line from removed");
+	});
+},
+initGfx: function() {
+	this.group = this.surface.createGroup();
+
+	this.outline = this.group.createRect({x: 0, y: 0, width: this.width, height: this.height, r: 5})
+	.setStroke({width: 2, color: '#808080'})
+	.setFill({type: "linear",  x1: 0, y1: 0, x2: 150, y2: 80,
+			colors: [{ offset: 0, color: "#ffff80" },{ offset: 1, color: "#ffffff" } ]});
+	
+	this.createNameRule(this.width);
+	this.createStateRule(this.width);
+	this.createVersionRule(this.width);
+
+	var stateidstr = "" + this.id + ":" + this.state;
+	
+	this.createNameText(this.name);
+	this.createStateText(stateidstr);
+	this.createVersionText(this.version);
+        
+},
+createNameText: function(name){
+	var y = (this.ruleHeight*0.5)+this.ruleOffset+5;
+	this.textName = this.group.createText({x: 5, y: y, text: name, align: "start"})
+	.setFont({family: "times", size: "12pt"})
+	.setFill("#000000");	
+},
+createVersionText: function(version){
+	var y = (this.ruleHeight*1.5)+this.ruleOffset+5;
+	this.textVersion = this.group.createText({x: 5, y: y, text: version, align: "start"})
+	.setFont({family: "times", size: "12pt"})
+	.setFill("#000000");	
+},
+createStateText: function(state){
+	var y = (this.ruleHeight*2.5)+this.ruleOffset+5;
+	this.textState = this.group.createText({x: 5, y: y, text: state, align: "start"})
+	.setFont({family: "times", size: "12pt"})
+	.setFill("#000000");	
+},
+createNameRule: function(width){
+	var y = (this.ruleHeight+this.ruleOffset);
+	this.nameRule = this.group.createLine({x1:0, y1: y, x2: width, y2: y})
+	.setStroke({width:1, color: '#808080'});
+},
+createVersionRule: function(width){
+	var y = (this.ruleHeight*2)+this.ruleOffset;
+	this.versionRule = this.group.createLine({x1:0, y1:y, x2: width, y2: y})
+	.setStroke({width:1, color: '#808080'});
+},
+createStateRule: function(width){
+	var y = (this.ruleHeight*3)+this.ruleOffset;
+	this.stateRule = this.group.createLine({x1:0, y1:y, x2: width, y2: y})
+	.setStroke({width:1, color: '#808080'});
+},
+resize: function(){
+	var width = this.width;
+	if(width < this.importTwistie.width ){
+		width = this.importTwistie.width;
+	}
+	if(width < this.exportTwistie.width ){
+		width = this.exportTwistie.width;
+	}
+	
+	var height = this.height;
+	if( this.importTwistie.height > 0 || this.exportTwistie.height > 0 ){
+		height = height + this.importTwistie.height;
+		height = height + this.exportTwistie.height;	
+	}
+	
+	var impy = (this.ruleHeight*2)+this.ruleOffset+25;
+	var expy = impy+12+this.importTwistie.height;
+	//make the export twistie appear in the correct location.
+	this.exportTwistie.updatePosition(5,(expy));
+
+	this.group.remove(this.nameRule);
+	this.group.remove(this.versionRule);
+	this.group.remove(this.stateRule);
+	this.createNameRule(width);
+	this.createStateRule(width);
+	this.createVersionRule(width);
+	this.outline.setShape({x: 0, y: 0, width: width, height: height, r: 5});
+	this.group.moveToFront();
+	
+	dojo.forEach(this.linesTo, function(line){ line.updateLine() });
+	dojo.forEach(this.linesFrom, function(line){ line.updateLine() });
+},
+calcWidthBasedOnContent: function(){
+	this.width=this.minWidth;
+	//adjust the width, based on the name length
+	if(this.name.length > 18){
+		var extra = this.name.length - 18;
+		extra = extra * 7;
+		var proposedNewWidth = this.minWidth + extra;
+		if(proposedNewWidth > this.width){
+			this.width = proposedNewWidth;
+		}	
+	}
+	//adjust the width, based on the version length
+	if(this.version.length > 18){
+		var extra = this.version.length - 18;
+		extra = extra * 8;
+		var proposedNewWidth = this.minWidth + extra;	
+		if(proposedNewWidth > this.width){
+			this.width = proposedNewWidth;
+		}	
+	}	
+},
+update: function(id, name, state, version) {	
+	if(this.name != name || this.state != state || this.version != version){
+		this.name = name;		
+		this.state = state;
+		this.version = version;
+		
+		this.calcWidthBasedOnContent();
+	
+		this.group.remove(this.textName);
+		this.createNameText(this.name);
+
+		this.group.remove(this.textState);
+		var stateidstr = "" + id + ":" + this.state;
+		this.createStateText(this.state);
+		
+		this.group.remove(this.versionText);
+		this.createVersionText(this.version);
+		
+		dojo.publish("demo.bundle.update",[this.id,name,state,version]);
+	}
+},
+moveToNewPlace: function(x, y) {
+	if(!this.hidden){
+	  this.group.setTransform({dx:x, dy:y});
+    }
+	this.x = x;
+	this.y = y;
+	this.updateAfterMove();	
+},
+toggleHidden: function(){
+	var hideMe = !this.hidden;	
+	if(hideMe){
+		//cheat.. move it off canvas..
+		this.group.setTransform({dx:-1000, dy:-1000});	
+	}else{
+		//bring it back =) good job we remembered where it was supposed to go !
+		this.group.setTransform({dx:this.x, dy:this.y});	
+	}
+		
+	this.hidden = hideMe;
+	dojo.publish("demo.bundle.hidden",[this.id,hideMe]);
+	
+	//en/disable all lines to/from..
+	dojo.forEach(this.linesTo, function(line){  line.updateVisibility(); line.updateLine(); });
+	dojo.forEach(this.linesFrom, function(line){ line.updateVisibility(); line.updateLine(); });
+},
+onMoved: function(mover, shift) {   
+    this.x=this.group.matrix.dx;
+    this.y=this.group.matrix.dy;
+    
+	this.updateAfterMove();
+},
+updateAfterMove: function(){
+	//todo, move line updates to lines.. not here.. 
+	dojo.forEach(this.linesTo, function(line){ line.updateLine(); });
+	dojo.forEach(this.linesFrom, function(line){ line.updateLine(); });
+	
+	dojo.publish("demo.bundle.move",[this.id,this.x,this.y]);
+},
+pulse: function() {
+	var endColor = this.selected ? "#FF3030" : "#808080";
+	dojox.gfx.fx.animateStroke({
+	    shape: this.outline,
+	    duration: 500,
+	    color: {start: "#6F0000", end: endColor},
+	    width: {start:10, end: 2},
+	    join:  {values: ["miter", "bevel", "round"]}
+	}).play();
+	dojo.forEach( this.linesTo, function(line){
+		dojox.gfx.fx.animateStroke({
+		    shape: line.line,
+		    duration: 500,
+		    color: {start: "#6F0000", end: line.stroke},
+		    join:  {values: ["miter", "bevel", "round"]}
+		}).play();
+	});
+	dojo.forEach( this.linesFrom, function(line){
+		dojox.gfx.fx.animateStroke({
+		    shape: line.line,
+		    duration: 500,
+		    color: {start: "#6F0000", end: line.stroke},
+		    join:  {values: ["miter", "bevel", "round"]}
+		}).play();
+	});
+},
+glow: function(){
+	var endColor = this.selected ? "#FF3030" : "#808080";
+	//this.outline.setStroke({width: 2, color: '#808080'});
+	dojox.gfx.fx.animateStroke({
+	    shape: this.outline,
+	    duration: 500,
+	    color: {start: "#FF3030", end: endColor},
+	    width: {start: 3, end: 2},
+	    join:  {values: ["miter", "bevel", "round"]}
+	}).play();	
+},
+onClick: function() {
+	this.group.moveToFront();
+	this.pulse();
+	//this.selected=!this.selected;
+},
+onMouseEnter: function() {
+	this.outline.setStroke({width: 3, color: '#FF3030'});
+	this.selected=true;
+},
+onMouseLeave: function() {
+	this.selected=false;
+	this.glow();
+}
+
+});
\ No newline at end of file

Added: incubator/aries/trunk/samples-sandbox/demo-sample/demo-prototype/src/main/resources/web/demo/BundleStatusGrid.js
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/samples-sandbox/demo-sample/demo-prototype/src/main/resources/web/demo/BundleStatusGrid.js?rev=942856&view=auto
==============================================================================
--- incubator/aries/trunk/samples-sandbox/demo-sample/demo-prototype/src/main/resources/web/demo/BundleStatusGrid.js (added)
+++ incubator/aries/trunk/samples-sandbox/demo-sample/demo-prototype/src/main/resources/web/demo/BundleStatusGrid.js Mon May 10 19:14:17 2010
@@ -0,0 +1,190 @@
+//dojo.provide allows pages use all types declared in this resource
+dojo.provide("demo.BundleStatusGrid");
+dojo.require("dojox.grid.DataGrid");
+dojo.require("dojo.data.ItemFileWriteStore");
+
+dojo.declare("demo.BundleStatusGrid", [], {
+	grid:null,
+	jsonStore:null,
+	dataItems:{ identifier : 'id',	label : 'name',	items : [] },
+	lastMouseOverIndex:-1,
+constructor : function(where) {
+	var layout = [ 
+	{
+		name : "ID",
+		field : "id",
+		width : "20px"
+	}, {
+		name : "SymbolicName",
+		field : "name",
+		width : "155px"
+	}, {
+		name : "State",
+		field : "state",
+		width : "12px",
+		formatter : this.makeStateImage
+	}, {
+		name : "x",
+		field : "x",
+		width : "15px"
+	}, {
+		name : "y",
+		field : "y",
+		width : "15px"
+	}, {
+		name: 'Show', 
+		field: 'id', 
+		width: '22px', 
+		formatter: this.makeHideButton
+	}		
+	];
+
+	this.jsonStore = new dojo.data.ItemFileWriteStore( {
+		data : this.dataItems
+	});
+
+	var grid = new dojox.grid.DataGrid( {
+		structure : layout,
+		store : this.jsonStore
+	}, where);
+	grid.startup();
+	
+	var _this=this;
+
+	dojo.connect(window, "onresize", grid, "resize");
+	dojo.connect(grid, "onRowClick", function(evt){
+		var items = evt.grid.selection.getSelected();
+		if(items!=null){
+			dojo.forEach( items, function(bundle){
+				console.log(bundle);
+				console.log(bundle.id);
+				//I'd like to just do bundle.pulse here, but that doesnt work..
+				bundles[bundle.id].pulse();
+			});
+		} 
+	});
+	dojo.connect(grid, "onRowMouseOver", function(evt){
+		if(_this.lastMouseOverIndex!=evt.rowIndex){
+			bundles[evt.grid.getItem(evt.rowIndex).id].glow();			
+			_this.lastMouseOverIndex=evt.rowIndex;
+		}
+	});
+	dojo.connect(grid, "onRowMouseOut", function(evt){
+		if(_this.lastMouseOverIndex!=-1){
+			_this.lastMouseOverIndex=-1;
+		}
+	});	
+
+	dojo.subscribe("demo.bundle.create", this, this.onBundleCreate);
+	dojo.subscribe("demo.bundle.delete", this, this.onBundleDelete);
+	dojo.subscribe("demo.bundle.update", this, this.onBundleUpdate);
+	dojo.subscribe("demo.bundle.hidden", this, this.onBundleHidden);
+	dojo.subscribe("demo.bundle.move", this, this.onBundleMove);
+},
+onBundleCreate: function(bundle){
+	console.log(">onBundleCreate");
+	console.log(bundle);
+	//add the bundle to the backing store
+	if (this.jsonStore != null) {
+		this.jsonStore.newItem(bundle);
+	}
+	this.jsonStore.save();
+	console.log("<onBundleCreate");
+},
+onBundleDelete: function(bundle){
+	console.log("onBundleDelete");
+	console.log(bundle);
+	console.log("invoking fetch for "+bundle.id);
+	var _this=this;
+	this.jsonStore.fetch({query: { id: bundle.id }, onComplete: function(item){
+		console.log("Deleting "+item[0].id);
+		console.log(item[0]);
+		_this.jsonStore.deleteItem(item[0]);
+	}});
+	this.jsonStore.save();
+	console.log("<onBundleDelete");
+},
+onBundleUpdate: function(id,name,state,version){
+	console.log(">onBundleUpdate");
+	var _this=this;
+	this.jsonStore.fetch({query: { id: id }, onComplete: function(item){
+		_this.jsonStore.setValue(item[0], "name", name);
+		_this.jsonStore.setValue(item[0], "state", state);
+		_this.jsonStore.setValue(item[0], "version", version);
+	}});
+	this.jsonStore.save();
+	console.log("<onBundleUpdate");
+},
+onBundleHidden: function(id,hidden){
+	console.log(">onBundleHidden");
+	var _this=this;
+	this.jsonStore.fetch({query: { id: id }, onComplete: function(item){
+		_this.jsonStore.setValue(item[0], "hidden", hidden);
+	}});
+	this.jsonStore.save();
+	console.log("<onBundleHidden");
+},
+onBundleMove: function(id,x,y){
+	//console.log("onBundleMove");
+	var _this=this;
+	this.jsonStore.fetch({query: { id: id }, onComplete: function(item){
+		_this.jsonStore.setValue(item[0], "x", x);
+		_this.jsonStore.setValue(item[0], "y", y);
+	}});
+	this.jsonStore.save();
+},
+makeHideButton: function(pk){
+	var checked="";
+	var text="Show "+bundles[pk].name;
+	if(!bundles[pk].hidden){
+		checked="checked";
+		text="Hide "+bundles[pk].name;
+	}
+	var showBox = "<div dojoType=\"dijit.form.Button\">";
+	showBox = showBox + "<input type=\"checkbox\" ";
+	showBox = showBox + "title=\""+text+"\" ";
+	showBox = showBox + "onClick=\"hideBundle('"+pk+"')\" "+checked+">";
+	showBox = showBox + "</div>";
+
+	//return hideButton;
+	return showBox;
+},
+makeHideStatus: function(hidden){
+	var img;
+	if(hidden){
+		img="\"../dojo/dojo/resources/images/dndCopy.png\"";
+	}else{
+		img="\"../dojo/dojo/resources/images/dndNoCopy.png\"";
+	}
+	var hideButton = "<img src="+img;
+	hideButton = hideButton + " width=\"18\" height=\"18\"";
+	hideButton = hideButton + "\">";
+	return hideButton;		
+},
+makeStateImage: function(state){
+	var img=null;
+
+	if(state=="UNINSTALLED"){
+		img = "../images/dndNoMove.png";
+	}else if(state=="INSTALLED"){
+		img = "../images/dndCopy.png";
+	}else if(state=="RESOLVED"){
+		img = "../images/dndNoCopy.png";
+	}else if(state=="STARTING"){
+		//todo: starting img
+		img = "../images/resolved.png";
+	}else if(state=="STOPPING"){
+		//todo: stopping img
+		img = "../images/resolved.png";
+	}else if(state=="ACTIVE"){
+		img = "../images/running.png";
+	}	
+	var hideButton = "";
+	if(img!=null){
+		hideButton = hideButton + "<img src=\""+img;
+		hideButton = hideButton + "\" width=\"12\" height=\"12\" alt=\"";
+		hideButton = hideButton + state + "\" title=\""+state+"\">";
+	}
+	return hideButton;		    		
+}
+});

Added: incubator/aries/trunk/samples-sandbox/demo-sample/demo-prototype/src/main/resources/web/demo/Dependency.js
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/samples-sandbox/demo-sample/demo-prototype/src/main/resources/web/demo/Dependency.js?rev=942856&view=auto
==============================================================================
--- incubator/aries/trunk/samples-sandbox/demo-sample/demo-prototype/src/main/resources/web/demo/Dependency.js (added)
+++ incubator/aries/trunk/samples-sandbox/demo-sample/demo-prototype/src/main/resources/web/demo/Dependency.js Mon May 10 19:14:17 2010
@@ -0,0 +1,103 @@
+dojo.provide("demo.Dependency");
+dojo.require("dojox.gfx");
+dojo.require("dojox.gfx.Moveable");
+dojo.require("dojo.data.ItemFileWriteStore");
+
+//Dependency
+// represents a line between two bundles.
+//
+//TODO: 
+// - have bundle manage these, not index.html
+// - add methods for pulse & glow.
+// - add methods for line offset adjust & reset
+//   - this will allow lines to move to rows of a twistie, then snap back
+// - for services, will need to target the little triangle..
+dojo.declare("demo.Dependency", [], {	
+	
+	//object properties	
+	surface: null,
+	fromBundle: null,
+	toBundle: null,
+	name: null,
+	type: null,
+	visible: null,
+	typeOffset: 0,
+	
+	//gfx objects
+	line: null,
+	
+	//internals
+	stroke: null,
+	
+	//am I deleted?
+	removed: false,
+	
+constructor: function(surface, name, type, fromBundle, toBundle) {
+	this.surface=surface;
+	this.name=name;
+	this.fromBundle=fromBundle;
+	this.toBundle=toBundle;
+    this.type=type;
+	this.stroke = '#000000';
+    this.setStroke();
+	this.updateVisibility();
+	this.updateLine();   
+    //this.line.connect("onmouseenter",dojo.hitch(this,"onMouseEnter"));
+    //this.line.connect("onmouseleave",dojo.hitch(this,"onMouseLeave"));
+},
+setStroke: function(){	
+	if(this.type=="packageImport"){
+		this.typeOffset=5;
+		this.stroke = '#F08080';
+	}else if(this.type=="packageExport"){
+		this.stroke = '#80F080';
+		this.typeOffset=-5;
+	}else if(this.type=="serviceExport"){
+		this.stroke = '#F080F0';
+		this.typeOffset=10;
+	}else if(this.type=="serviceImport"){
+		this.stroke = '#8080F0';
+		this.typeOffset=-10;
+	}
+},
+updateVisibility: function(){
+	this.visible = (!this.fromBundle.hidden) && (!this.toBundle.hidden);
+	
+	if(!this.visible){
+		if(this.line==null){
+			this.line = this.surface.createLine({x1: -1000, y1: -1000, x2: -1000, y2: -1000})
+		            .setStroke(this.stroke);
+		}else{
+			this.line.setShape({x1: -1000, y1: -1000, x2: -1000, y2: -1000});
+		}
+	}else{
+		this.updateLine();
+	}
+},
+updateLine: function(){
+	if(this.visible){
+		var fromx = this.fromBundle.x + (this.fromBundle.width / 2) + this.typeOffset;
+		var fromy = this.fromBundle.y + (this.fromBundle.height / 2)+ this.typeOffset;
+		var tox = this.toBundle.x + (this.toBundle.width / 2)+ this.typeOffset;
+		var toy = this.toBundle.y + (this.toBundle.height / 2)+ this.typeOffset;
+		if(this.line==null){
+			this.line = this.surface.createLine({x1: fromx, y1: fromy, x2: tox, y2: toy})
+		            .setStroke(this.stroke);
+		}else{
+			this.line.setShape({x1: fromx, y1: fromy, x2: tox, y2: toy});
+		}
+		this.line.moveToBack();
+	}
+},
+removeSelf: function(){
+	console.log("Line from "+this.fromBundle.id+" to "+this.toBundle.id+" being removed");
+	if(!this.removed){
+		console.log("Line from "+this.fromBundle.id+" to "+this.toBundle.id+" being removed from surface");
+		this.surface.remove(this.line);
+		console.log("Line from "+this.fromBundle.id+" to "+this.toBundle.id+" being marked as deleted");
+		this.removed = true;
+	}else{
+		console.log("Line from "+this.fromBundle.id+" to "+this.toBundle.id+" already marked as deleted");
+	}
+}
+});
\ No newline at end of file

Added: incubator/aries/trunk/samples-sandbox/demo-sample/demo-prototype/src/main/resources/web/demo/DwrLoadingDialog.js
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/samples-sandbox/demo-sample/demo-prototype/src/main/resources/web/demo/DwrLoadingDialog.js?rev=942856&view=auto
==============================================================================
--- incubator/aries/trunk/samples-sandbox/demo-sample/demo-prototype/src/main/resources/web/demo/DwrLoadingDialog.js (added)
+++ incubator/aries/trunk/samples-sandbox/demo-sample/demo-prototype/src/main/resources/web/demo/DwrLoadingDialog.js Mon May 10 19:14:17 2010
@@ -0,0 +1,32 @@
+// dojo.provide allows pages use all types declared in this resource
+dojo.provide("demo.DwrLoadingDialog");
+dojo.require("dijit.Dialog");
+
+dojo.declare("demo.DwrLoadingDialog", [], {
+	loadingMessage:"Loading data from server..<br>waiting for <span id='count'>0</span> items",
+    dialog:null,
+    count:0,
+	constructor : function() {
+		this.dialog = new dijit.Dialog({title:"Loading...", id:"loadDialog"});
+		this.dialog.attr('content', this.loadingMessage);
+		dojo.body().appendChild(this.dialog.domNode);
+		this.dialog.hide();
+		
+		dwr.engine.setPreHook(this.dwrPreHook);
+		dwr.engine.setPostHook(this.dwrPostHook);
+	},
+	dwrPreHook: function(){
+		console.log("***************** PRE HOOK");
+		if(this.count==0){
+			this.dialog.show();
+			this.count++;
+			dojo.byId('count').innerHtml = ""+this.count;
+		}
+	},
+	dwrPostHook: function(){
+		console.log("***************** POST HOOK");
+		this.count--;
+		if(this.count==0) this.dialog.hide();
+		dojo.byId('count').innerHtml = ""+this.count;
+	}	
+});
\ No newline at end of file

Added: incubator/aries/trunk/samples-sandbox/demo-sample/demo-prototype/src/main/resources/web/demo/LayoutManager.js
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/samples-sandbox/demo-sample/demo-prototype/src/main/resources/web/demo/LayoutManager.js?rev=942856&view=auto
==============================================================================
--- incubator/aries/trunk/samples-sandbox/demo-sample/demo-prototype/src/main/resources/web/demo/LayoutManager.js (added)
+++ incubator/aries/trunk/samples-sandbox/demo-sample/demo-prototype/src/main/resources/web/demo/LayoutManager.js Mon May 10 19:14:17 2010
@@ -0,0 +1,247 @@
+// dojo.provide allows pages use all types declared in this resource
+dojo.provide("demo.LayoutManager");
+dojo.require("dijit.form.Button");
+dojo.require("dijit.form.ComboBox");
+dojo.require("dojo.data.ItemFileWriteStore");
+
+//LayoutManager
+// looks after the loading & saving of arrangements of bundles on the surface.
+// stores configurations by name, by provider.
+//
+// listens for provider change notifications to know what the current provider is,
+// when a provider is selected, all current layouts are discarded, and the layout
+// set for the new provider is setup.
+//
+// the list of layouts for a provider is stored in a cookie as 
+//    "ozzy.demo.ui.layouts.<providerName>"
+// the layout data for each layout is stored in a cookie as 
+//    "ozzy.demo.ui.coords.<providerName>.<layoutName>"
+//
+// both are stored as a json encoded array.
+//
+// if a provider is selected that we havent seen before, a new cookie is created
+// with a layout entry of 'default'.
+//
+// coord save load is now based over bundle name & version, not id.
+// load will only move bundles it is able to match, 
+// if a provider gives back different bundles to the ones saved with coords, the
+// mismatches are ignored.
+//
+// TODO:
+//   - delete Layout.
+//   - (possible) remove load button & trigger off of selection of dropdown.
+//   - writeProtect 'default' so it is always the one seen 1st time.
+//   - activate loadCoords after provider change.
+//   - store 'active' layout to reload on switching to provider
+//   - allow dynamic contributions to layout from layout plugins
+//     these would add fixed entries to the layout dropdown, and would
+//     arrange the layout according to logic rather than a saved layout.
+//     these could live server side, or client side, and be added via ajax.
+dojo.declare("demo.LayoutManager", [], {
+	loadButton:null,
+	saveButton:null,
+	layoutSelector:null,
+	disabled:true,
+	items:[],
+	layouts:null,
+	
+	constructor : function(where) {
+	  var _this=this;
+	  this.loadButton = new dijit.form.Button( 
+			  {label: "Load Coords", onClick: function(){_this.loadCoords();} });
+	  this.saveButton = new dijit.form.Button( 
+			  {label: "Save Coords", onClick: function(){_this.saveCoords();} });
+	  
+      this.layouts = new dojo.data.ItemFileWriteStore( {data : {identifier: 'name', items: this.items }});
+      
+	  this.layoutSelector = new dijit.form.ComboBox( {id: "BundleLayoutSelector",  store: this.layouts} );
+	  
+	  this.layoutSelector.attr('value',"default");
+	    
+	  dojo.byId(where).appendChild(this.layoutSelector.domNode);
+	  dojo.byId(where).appendChild(this.loadButton.domNode);
+	  dojo.byId(where).appendChild(this.saveButton.domNode);
+	  	  
+	  this.disable();
+	  
+	  dojo.subscribe("demo.provider.change", this, this.onProviderChange);
+	},
+	onProviderChange: function(evt){
+		  console.log("OnProviderChange");
+		  console.log(evt);
+		  this.enable();
+		  
+		  this.removeAllLayoutsFromMenu();
+			
+		  console.log("Adding default if missing");
+		  this.addDefaultLayoutIfMissing(providerSelector.getProvider());	 	  
+		  this.getLayoutsForProvider(providerSelector.getProvider());
+		  
+		  this.layoutSelector.attr('value',"default");
+	},
+	removeAllLayoutsFromMenu: function(){
+		  this.layoutSelector.attr('value',"");
+		  var _this=this;
+			function deleteItems(items, request){
+				console.log("total removal query");
+				console.log(items);
+				console.log(request);			
+				dojo.forEach(items, function(item){
+					console.log("deleting "+item.name);
+					_this.layouts.deleteItem(item);
+				});		
+			    console.log("end process");
+			}
+			this.layouts.fetch({query:{}, onComplete: deleteItems});
+			this.layouts.save();
+			
+			this.items=[];
+			this.layouts.close();
+	},
+	enable: function(){
+		this.loadButton.attr('disabled',false);
+		this.saveButton.attr('disabled',false);
+		this.layoutSelector.attr('disabled',false);
+	},
+	disable: function(){
+		this.loadButton.attr('disabled',true);
+		this.saveButton.attr('disabled',true);
+		this.layoutSelector.attr('disabled',true);
+	},
+	addDefaultLayoutIfMissing: function(provider){
+		  var bundle_layouts_str = dojo.cookie("ozzy.demo.ui.layouts."+provider);
+		  if(bundle_layouts_str==null){
+			    console.log("No cookie found listing layouts.. adding default & creating one.");
+				this.layouts.newItem({name: "default"});
+				this.layouts.save();
+				this.saveLayoutsToCookie();
+				this.layoutSelector.attr('value',"default");
+				this.saveCoords();
+				this.removeAllLayoutsFromMenu();
+		  }	
+	},
+	saveLayoutsToCookie: function(){
+		var name = "ozzy.demo.ui.layouts."+providerSelector.getProvider();
+		console.log("Saving layouts to "+name);
+		var names = new Array();		
+		
+		var _this=this;
+		function process(items, request){
+			console.log("total namegather query");
+			console.log(items);
+			console.log(request);			
+			dojo.forEach(items, function(item){
+				var name = _this.layouts.getValue(item, 'name');
+				console.log("name "+name);
+				names.push(name);
+			});		
+		    console.log("end process");
+		}
+		this.layouts.fetch({query:{}, onComplete: process});
+		
+		//dojo.forEach(this.items, function(item){ console.log(item); console.log(item.name[0]); names.push(item.name[0])});
+		console.log("Names to save..")
+		console.log(names);
+		dojo.cookie(name, dojo.toJson(names));
+		console.log("Saved");
+	},
+	getLayoutsForProvider: function(provider){	  			 
+	  var bundle_layouts_str = dojo.cookie("ozzy.demo.ui.layouts."+provider);
+	  if(bundle_layouts_str!=null){
+		  var names = dojo.fromJson(bundle_layouts_str);
+		  console.log("Loaded for provider"+provider);
+		  console.log(bundle_layouts_str);
+		  console.log(names);
+		  var _this=this;
+		  dojo.forEach(names, function(name){
+			  _this.layouts.newItem({name: name});
+		  });
+		  this.layouts.save();
+		  this.layoutSelector.attr('value',"default");
+	  }else{
+		  //do-nothng.
+	  }
+	  	  
+	},	
+	saveCoords: function() {
+		console.log("Save coords");
+		var bundle_coords = new Array();
+		var idx=0;
+		var coords_cookie="";
+		
+		var coord_data = new Array();
+		
+		dojo.forEach(bundles, function(bundle){
+			if(bundle!=null){
+				var x=bundle.x;
+				var y=bundle.y;		
+				var h=bundle.hidden ? 1 : 0;
+				
+				coord_data.push( {name:bundle.name, ver:bundle.version, x: x, y: y, h: h});			
+			}		
+		});	
+		var coords_json = dojo.toJson(coord_data);
+				
+		dojo.cookie("ozzy.demo.ui.coords."+providerSelector.getProvider()+"."+this.layoutSelector.attr('value'), coords_json);
+		
+		var match=false;
+		var name = this.layoutSelector.attr('value');
+		console.log("checking layouts for "+name);
+	    this.layouts.fetch({query: { name: name }, onComplete: function(item){
+	    	if(item!=null && item.length>0){
+	    		console.log("Found it");
+	    		console.log(item);
+	    		match=true;
+	    	}
+	    }});
+	    console.log("adding if needed");
+	    if(!match){
+	    	console.log("adding "+name);
+			this.layouts.newItem({name: name});
+			this.layouts.save();
+			console.log("pushing to cookie");
+			this.saveLayoutsToCookie();
+	    }
+		
+		//dwr.util.setValue("coords_status", "Done");
+	},
+	loadCoords: function() {
+		console.log("Load coords");
+		var bundle_coords_str = dojo.cookie("ozzy.demo.ui.coords."+providerSelector.getProvider()+"."+this.layoutSelector.attr('value'));
+		if(bundle_coords_str != null){
+			var bundle_coord_data = dojo.fromJson(bundle_coords_str);
+			dojo.forEach(bundle_coord_data, function(bi){
+				var id=-1;
+				dojo.forEach(bundles, function(b){ 
+						if(b!=null){
+							console.log(b);
+							console.log("Inside foreach");
+							if((b.name==bi.name) && (b.version==bi.ver)){
+								id=b.id;
+							} 
+						}
+					});
+				
+				console.log("id "+id)
+				
+				//we may not know the bundle yet.. just ignore it for now.
+				if(bundles[id]!=null){				
+					bundles[id].x = bi.x;
+					bundles[id].y = bi.y;						
+					moveBundle(bundles[id], bi.x, bi.y);
+					
+					var h2=bundles[id].hidden ? 1 : 0;
+					//	console.log("Bundle "+id+" had hidden flag of "+h+" ("+h2+") and current state of "+bundles[id].hidden);
+					if( bi.h!=h2 ){
+						//console.log("Flipping hidden state on bundle.."); 
+						bundles[id].toggleHidden();
+					}
+				}				
+			});
+
+			//dwr.util.setValue("coords_status", "Done");
+		}else{
+			//dwr.util.setValue("coords_status", "No cookie found");
+		}
+	}	
+});
\ No newline at end of file

Added: incubator/aries/trunk/samples-sandbox/demo-sample/demo-prototype/src/main/resources/web/demo/ProviderSelector.js
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/samples-sandbox/demo-sample/demo-prototype/src/main/resources/web/demo/ProviderSelector.js?rev=942856&view=auto
==============================================================================
--- incubator/aries/trunk/samples-sandbox/demo-sample/demo-prototype/src/main/resources/web/demo/ProviderSelector.js (added)
+++ incubator/aries/trunk/samples-sandbox/demo-sample/demo-prototype/src/main/resources/web/demo/ProviderSelector.js Mon May 10 19:14:17 2010
@@ -0,0 +1,91 @@
+// dojo.provide allows pages use all types declared in this resource
+dojo.provide("demo.ProviderSelector");
+dojo.require("dojo.data.ItemFileWriteStore");
+dojo.require("dijit.form.ComboBox");
+dojo.require("dijit.form.Select");
+dojo.require("dijit.form.FilteringSelect");
+
+//ProviderSelector
+// looks after the providers, and allows selection of one. 
+// 
+// when user uses a new provider, 
+// - asks the server for the bundles for that provider
+// - issues an event to 
+//     "demo.provider.change"
+//   with the new provider as the payload.
+// 
+//TODO:
+// - Make the provider list dynamic, currently providers are only retrieved at construction
+//   Suspect this also requires a serverside rewrite to use a serviceTracker, rather than a single lookup.
+//   - add is already present, remove will need adding for dynamic.
+// - (possible) auto activate provider on select, rather than requiring a 'use' button.
+// - respond to server setting a provider (needed if another client alters the view on a shared session {the default})
+dojo.declare("demo.ProviderSelector", [], {
+	
+	providerSelector:null,
+	whereProvider:null,
+	whereOptions:null,
+	providers:null,
+	initialSelect:true,
+	
+constructor : function( whereProvider) {
+	//and this stuff, should really be combined with the provider stuff to make 
+	//cookie stored provider configs.
+	//dojo.byId(whereProvider).appendChild("Data Provider: ");
+	this.whereProvider = whereProvider;
+
+	console.log("creating store");
+    var providers = new dojo.data.ItemFileWriteStore( {data : {identifier: 'value', label: 'label', items:[]}});
+	this.providerSelector = new dijit.form.FilteringSelect( {id: "ProviderSelector",  searchAttr: "value", store: providers} );
+	this.providers=providers;
+	
+	//oddball hackery to link button to this instance.. 
+	//otherwise 'this' inside the handleButton becomes the Button, not me.
+	var _this=this;
+	var useButton = new dijit.form.Button( 
+			  {label: "Use Provider", onClick: function(){
+				  _this.handleButton();
+			  }});
+	
+	console.log("looking up.. ");
+	dojo.byId(whereProvider).appendChild(this.providerSelector.domNode);
+	dojo.byId(whereProvider).appendChild(useButton.domNode);
+    
+	var _this=this;
+	var providerCallback = function(data)
+	{
+		console.log("callback...")
+		console.log(data);
+		if (data != null && typeof data == 'object'){
+			dojo.forEach( data, function(provider){			      
+				_this.addProvider(provider);
+			});
+		}
+	}
+	console.log("Requesting initial providers");
+	ServerSideClass.getProviders(providerCallback);		
+},
+addProvider: function(provider){
+	console.log("adding provider "+provider);
+	this.providers.newItem({value: provider, label: provider});
+	if(this.initialSelect){
+		this.providerSelector.attr('value',provider);
+		this.initialSelect=false;		
+	}
+},
+notifyChangeOfProvider: function(provider){
+
+	this.providerSelector.attr('value',provider);
+	console.log("getting bundles for prov");
+	ServerSideClass.getInitialBundles(this.getProvider(), "");
+	console.log("Publishing provider change to "+provider);
+	dojo.publish("demo.provider.change",[provider]);
+},
+getProvider: function(){
+	return dijit.byId("ProviderSelector").value;
+},
+handleButton: function(){
+	this.notifyChangeOfProvider(this.getProvider());
+}
+		
+});
\ No newline at end of file

Added: incubator/aries/trunk/samples-sandbox/demo-sample/demo-prototype/src/main/resources/web/demo/SimpleInitialLayout.js
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/samples-sandbox/demo-sample/demo-prototype/src/main/resources/web/demo/SimpleInitialLayout.js?rev=942856&view=auto
==============================================================================
--- incubator/aries/trunk/samples-sandbox/demo-sample/demo-prototype/src/main/resources/web/demo/SimpleInitialLayout.js (added)
+++ incubator/aries/trunk/samples-sandbox/demo-sample/demo-prototype/src/main/resources/web/demo/SimpleInitialLayout.js Mon May 10 19:14:17 2010
@@ -0,0 +1,38 @@
+// dojo.provide allows pages use all types declared in this resource
+dojo.provide("demo.SimpleInitialLayout");
+
+dojo.declare("demo.SimpleInitialLayout", [], {
+	lastCreatedX:0,
+	lastCreatedY:0,
+	lastCreatedWidth:0,
+	lastCreatedHeight:0,
+	surfaceX:0,
+	surfaceY:0,
+	constructor: function(x,y){
+		this.surfaceX=x;
+		this.surfaceY=y;
+	},
+	placeBundle: function(bundle){
+		//Move the new bundle so it appears in a nice way
+		var end = this.lastCreatedX + this.lastCreatedWidth + 5;
+		if (end + bundle.width < this.surfaceX) {
+			bundle.moveToNewPlace(end, this.lastCreatedY);
+		} else {
+			if ((this.lastCreatedY + this.lastCreatedHeight + 5) < this.surfaceY) {
+				bundle.moveToNewPlace(5, (this.lastCreatedY
+						+ this.lastCreatedHeight + 5));		
+			}			
+		}	
+		this.lastCreatedX = bundle.x;
+		this.lastCreatedWidth = bundle.width;
+		this.lastCreatedY = bundle.y;
+		this.lastCreatedHeight = bundle.height;		
+	},
+	reset: function(){
+		this.lastCreatedX=0;
+		this.lastCreatedY=0;
+		this.lastCreatedWidth=0;
+		this.lastCreatedHeight=0;		
+	}
+			
+});
\ No newline at end of file

Added: incubator/aries/trunk/samples-sandbox/demo-sample/demo-prototype/src/main/resources/web/demo/TwistieSection.js
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/samples-sandbox/demo-sample/demo-prototype/src/main/resources/web/demo/TwistieSection.js?rev=942856&view=auto
==============================================================================
--- incubator/aries/trunk/samples-sandbox/demo-sample/demo-prototype/src/main/resources/web/demo/TwistieSection.js (added)
+++ incubator/aries/trunk/samples-sandbox/demo-sample/demo-prototype/src/main/resources/web/demo/TwistieSection.js Mon May 10 19:14:17 2010
@@ -0,0 +1,181 @@
+dojo.provide("demo.TwistieSection");
+dojo.require("dojox.gfx");
+dojo.require("dojox.gfx.Moveable");
+dojo.require("dojo.data.ItemFileWriteStore");
+
+//TwistieSection
+// Manages an expandable component in a bundle
+//
+// TODO:
+//  - update renderer to cope with massive import/exports, ie bundle 0)
+//    - render max no of rows, add scroller, all needs doing by hand.
+//    - needs careful thought
+//  - current 'items' array is just text, for the breakout dependency show, 
+//    will need individual attach coords for deplines. 
+//  - may need to add custom events to issue when mouseover per item.
+//  - may need to add custom events to issue when items are clicked? 
+//    -item being clickable may be troublesome, maybe use a small handle to click beside each item.
+//  - for services, render one triangle per expanded item, adjust any dependency to target triangle.
+dojo.declare("demo.TwistieSection", [], {
+	
+	//object properties	
+	parentGroup: null,
+	owningBundle: null,
+	name: null,
+	x: null,
+	y: null,
+	getItemsCallback: null,
+	items: null,
+	isOpen: null,
+	width: 0,
+	height: 0,
+	itemsObtained: false,
+	
+	//groups
+	twistieGroup: null,
+	twistieHandleGroup: null,
+	
+	//group items
+	twistieHandle: null,
+	twistieText: null,
+	itemTexts: null,
+	
+	constructor: function(name, parentGroup, owningBundle, x, y, getItemsCallBack) {
+	this.surface=surface;
+	this.name=name;
+	this.parentGroup=parentGroup;
+	this.owningBundle=owningBundle;
+	this.x=x;
+	this.y=y;
+	this.isOpen=false;
+	this.getItemsCallback = getItemsCallBack;
+
+	this.items=["Loading..."];
+	this.itemTexts = new Array();
+
+	this.twistieGroup = this.parentGroup.createGroup();	
+	this.twistieHandleGroup = this.twistieGroup.createGroup();
+
+	this.createText(this.name);
+
+	this.createTwistie();
+	
+	this.twistieHandleGroup.connect("onclick",dojo.hitch(this,"twistieHandler"));            
+},
+createText: function(name){
+	var textOffset = this.y + 8;
+	var x = this.x + 17;
+	this.twistieText = this.twistieGroup.createText({x: x, y: textOffset, text: name, align: "start"})
+    .setFont({family: "times", size: "8pt"})
+	.setFill("#000000");	
+},
+createTwistie: function(){
+	var pys = this.y;
+	var pym = pys+5;
+	var pye = pys+10;
+	var px = this.x + 5;
+	var pxm = this.x + 10;
+	var pxe = this.x + 15;
+	this.twistieHandle = this.twistieHandleGroup.createPolyline([{x:px,y:pys},{x:pxe,y:pym},{x:px,y:pye}])
+	//.setStroke({width: 2, color: '#808080'})
+	.setFill("#000000");
+	
+	if(this.isOpen){
+		this.twistieHandle.setShape([{x:px,y:pys},{x:pxe,y:pys},{x:pxm,y:pye}]);
+	}
+},
+updatePosition: function(x,y){
+	
+	this.twistieHandleGroup.remove(this.twistieHandle);
+	this.twistieGroup.remove(this.twistieHandle);
+	this.twistieGroup.remove(this.twistieText);
+	
+	this.x=x;
+	this.y=y;
+	
+	if(this.isOpen){
+		this.removeItemsFromDisplay();
+		this.addItemsToDisplay();
+	}
+
+	this.createText(this.name);
+	this.createTwistie();
+	
+},
+removeItemsFromDisplay: function(){
+	var _this = this;
+	if(this.itemTexts!=null){
+		dojo.forEach( this.itemTexts , function(t){
+			_this.twistieGroup.remove(t);	
+		});
+	}
+	this.height = 0;
+	this.width = 0;
+},
+addItemsToDisplay: function(){
+	var maxLengthSeen = 0;
+	var extraHeight = 0;
+	if(this.items!=null){
+		extraHeight = extraHeight + (this.items.length * 10);
+		var pyt = this.y + 18;
+		var pxt = this.x + 17;
+		var idx=0;
+		
+		//make sure we clean up 1st.
+		this.removeItemsFromDisplay();
+		
+		for(idx=0; idx<this.items.length; idx++){						
+			//extra isOpen to try to prevent the add loop still adding while closed..
+			if(this.isOpen){
+
+				this.itemTexts[idx] = this.twistieGroup.createText({x: pxt, y: pyt, text: this.items[idx], align: "start"})
+				.setFont({family: "times", size: "8pt"})
+				.setFill("#000000");
+								
+				pyt = pyt + 10;
+				if(maxLengthSeen< this.items[idx].length){
+					maxLengthSeen = this.items[idx].length;
+				}
+			}
+		}
+	}
+	
+    //25 chars or so will fit into minwidth.. 
+	var extraWidth = this.owningBundle.minWidth;				
+	if(maxLengthSeen>25){
+		var extraW = maxLengthSeen-25;
+		extraW = extraW * 6;
+		extraWidth = extraWidth + extraW;
+	}
+	
+	if(extraWidth<this.width){
+		extraWidth = this.owningBundle.width;
+	}
+	
+	this.height = extraHeight;
+	this.width = extraWidth;
+},
+twistieHandler: function() {
+	var pys = this.y;
+	var pym = pys+5;
+	var pye = pys+10;
+	this.isOpen=!this.isOpen;
+	
+	this.twistieHandleGroup.remove(this.twistieHandle);
+	this.createTwistie();
+	
+	if(this.isOpen){	
+		if(!this.itemsObtained){
+			//hook up the imports to the bundle.			
+			this.getItemsCallback();
+			this.itemsObtained=true;
+		}else{
+			this.addItemsToDisplay();
+		}
+	}else{			
+		this.removeItemsFromDisplay();
+	}
+	this.owningBundle.resize();	
+}
+
+});
\ No newline at end of file



Mime
View raw message